From c6856aa94c8f354b32629c0f894a55c708deb3b0 Mon Sep 17 00:00:00 2001 From: mage2-team <mage2-team@magento.com> Date: Fri, 7 Mar 2014 10:55:09 -0800 Subject: [PATCH] 2.0.0.0-dev68 * Cache: * Implemented depersonalization of private content generation * Implemented content invalidation * Added Edge Side Includes (ESI) support * Added a built-in caching application * GitHub requests: * [#454](https://github.com/magento/magento2/pull/454) -- Allow to specify list of IPs in a body on maintenance.flag which will be granted access even if the flag is on * [#204](https://github.com/magento/magento2/issues/204) -- Mage_ImportExport: Exporting configurable products ignores multiple configurable options * [#418](https://github.com/magento/magento2/issues/418) -- Echo vs print * [#419](https://github.com/magento/magento2/issues/419) -- Some translation keys are not correct. * [#244](https://github.com/magento/magento2/issues/244) -- Retrieve base host URL without path in error processor * [#411](https://github.com/magento/magento2/issues/411) -- Missed column 'payment_method' of table 'sales_flat_quote_address' * [#284](https://github.com/magento/magento2/pull/284) -- Fix for Issue #278 (Import -> Stores with large amount of Configurable Products) * Fixed bugs: * Fixed an issue where Mage_Eav_Model_Entity_Type::fetchNewIncrementId() did not rollback on exception * Fixed an issue where a category containing more than 1000 products could not be saved * Fixed inappropriate error messages displayed during installation when required extensions were not installed * Fixed synopsis of the install.php script * Fixed an issue where the schedule of recurring payments was not displayed in the shopping cart * Modularity improvements: * Introduced the OfflinePayments module - a saparate module for offline payment methods * Added the ability to enable/disable the Paypal module * Moved the framework part of the Locale functionality from the Core module to library * The Locale logic was split among appropriate classes in library, according to their responsibilities * Removed the deprecated DHL functionality * Introduced the OfflineShipping module for offline shipping carrier functionality: Flatrate, Tablerate, Freeshipping, Pickup * Introduced a separate module for the DHL shipping carrier * Introduced a separate module for the Fedex shipping carrier * Introduced a separate module for the UPS shipping carrier * Introduced a separate module for the USPS shipping carrier * Framework Improvements: * Added the ability to intercept internal public calls * Added the ability to access public interface of the intercepted object * Added a static integrity test for plugin interface validation * Added support for both class addressing approaches in DI: with and without slash ("\") at the beginning of a class name * Customer Service usage: * Refactored the Customer module blocks and controllers to use customer service layer * Security: * Introduced the ability to hash a password with a random salt of default length (32 chars) by the encryption library * Utilized a random salt of default length for admin users, and frontend customers --- CHANGELOG.md | 43 + app/bootstrap.php | 15 +- .../AdminNotification/Block/ToolbarEntry.php | 4 +- .../Authorizenet/Model/Authorizenet.php | 6 +- .../Magento/Authorizenet/Model/Directpost.php | 6 +- .../Authorizenet/etc/adminhtml/system.xml | 4 +- .../Authorizenet/view/adminhtml/info/cc.phtml | 2 +- .../view/adminhtml/info/pdf.phtml | 2 +- .../Authorizenet/view/frontend/info/cc.phtml | 2 +- .../Magento/Backend/App/AbstractAction.php | 10 +- .../Magento/Backend/App/Action/Context.php | 22 +- .../App/Action/Plugin/Authentication.php | 17 +- .../App/Action/Plugin/MassactionKey.php | 19 +- app/code/Magento/Backend/Block/Context.php | 11 +- app/code/Magento/Backend/Block/Dashboard.php | 5 - .../Magento/Backend/Block/Dashboard/Graph.php | 21 +- .../Backend/Block/Dashboard/Tab/Amounts.php | 4 +- .../Backend/Block/Dashboard/Tab/Orders.php | 4 +- app/code/Magento/Backend/Block/Menu.php | 12 +- app/code/Magento/Backend/Block/Page.php | 21 +- app/code/Magento/Backend/Block/Page/Head.php | 3 + .../Block/System/Account/Edit/Form.php | 10 +- .../Backend/Block/System/Config/Form.php | 2 - .../System/Config/Form/Field/Datetime.php | 7 +- .../System/Config/Form/Field/Notification.php | 8 +- .../Block/System/Design/Edit/Tab/General.php | 2 +- app/code/Magento/Backend/Block/Template.php | 8 +- .../Backend/Block/Template/Context.php | 20 +- .../Magento/Backend/Block/Widget/Form.php | 8 +- .../Block/Widget/Grid/Column/Filter/Date.php | 32 +- .../Widget/Grid/Column/Filter/Datetime.php | 22 +- .../Widget/Grid/Column/Renderer/Country.php | 23 +- .../Widget/Grid/Column/Renderer/Currency.php | 23 +- .../Widget/Grid/Column/Renderer/Date.php | 23 +- .../Widget/Grid/Column/Renderer/Datetime.php | 8 +- .../Widget/Grid/Column/Renderer/Price.php | 22 +- .../Controller/Adminhtml/System/Account.php | 2 +- .../Controller/Adminhtml/System/Config.php | 22 - .../Controller/Adminhtml/System/Design.php | 6 +- .../Magento/Backend/Helper/Dashboard/Data.php | 3 - .../Backend/Helper/Dashboard/Order.php | 3 - app/code/Magento/Backend/Helper/Data.php | 14 +- .../Model/Config/Backend/Currency/Allow.php | 14 +- .../Backend/Model/Config/Backend/Locale.php | 18 +- .../Backend/Model/Config/Source/Locale.php | 12 +- .../Model/Config/Source/Locale/Country.php | 12 +- .../Model/Config/Source/Locale/Currency.php | 18 +- .../Config/Source/Locale/Currency/All.php | 12 +- .../Model/Config/Source/Locale/Timezone.php | 12 +- .../Config/Source/Locale/Weekdaycodes.php | 12 +- .../Model/Config/Source/Locale/Weekdays.php | 12 +- .../Magento/Backend/Model/Locale/Manager.php | 2 +- .../Model/{Locale.php => Locale/Resolver.php} | 63 +- app/code/Magento/Backend/Model/View.php | 9 + app/code/Magento/Backend/etc/adminhtml/di.xml | 13 +- app/code/Magento/Backend/etc/di.xml | 1 + app/code/Magento/Backend/etc/module.xml | 2 - .../layout/adminhtml_system_config_edit.xml | 1 - .../view/adminhtml/widget/grid/extended.phtml | 4 +- app/code/Magento/Backup/Model/Backup.php | 12 +- .../Magento/Backup/Model/Resource/Helper.php | 6 +- .../Catalog/Product/View/Type/Bundle.php | 10 +- .../Initialization/Helper/Plugin/Bundle.php | 9 +- .../Magento/Bundle/Model/Plugin/QuoteItem.php | 20 +- .../Magento/Bundle/Model/Product/Price.php | 6 +- .../Bundle/Model/Resource/Price/Index.php | 14 +- .../view/adminhtml/js/bundle-product.js | 4 +- .../layout/checkout_cart_item_renderers.xml | 2 +- .../checkout_cart_sidebar_item_renderers.xml | 2 +- ...checkout_onepage_review_item_renderers.xml | 3 +- .../Magento/CacheInvalidate/Helper/Data.php | 44 + .../CacheInvalidate/Model/Observer.php | 110 ++ .../Magento/CacheInvalidate/etc/events.xml | 33 + .../Magento/CacheInvalidate/etc/module.xml | 35 + .../Magento/Captcha/Model/Resource/Log.php | 6 +- .../Product/Attribute/Edit/Tab/Advanced.php | 2 +- .../Catalog/Block/Adminhtml/Product/Grid.php | 3 +- .../Adminhtml/Product/Helper/Form/Price.php | 12 +- .../Magento/Catalog/Block/Category/View.php | 12 +- app/code/Magento/Catalog/Block/Navigation.php | 12 +- .../Catalog/Block/Product/Compare/Sidebar.php | 19 + .../Catalog/Block/Product/ListProduct.php | 15 + .../Catalog/Block/Product/NewProduct.php | 15 +- .../Magento/Catalog/Block/Product/Price.php | 12 +- .../Block/Product/ProductList/Related.php | 16 +- .../Block/Product/ProductList/Upsell.php | 16 +- .../Magento/Catalog/Block/Product/View.php | 22 +- .../Block/Product/View/Options/Type/Date.php | 2 +- .../Catalog/Controller/Adminhtml/Category.php | 3 +- .../Catalog/Controller/Adminhtml/Product.php | 6 +- .../Adminhtml/Product/Action/Attribute.php | 4 +- .../Catalog/Helper/Product/Composite.php | 18 +- .../Helper/Product/Edit/Action/Attribute.php | 8 +- app/code/Magento/Catalog/Model/Category.php | 12 +- app/code/Magento/Catalog/Model/Design.php | 22 +- .../Catalog/Model/Entity/Attribute.php | 13 +- .../Flat/Plugin/IndexerConfigData.php | 28 +- .../Category/Flat/Plugin/StoreGroup.php | 20 +- .../Category/Product/Plugin/StoreGroup.php | 20 +- .../Indexer/Product/Flat/Plugin/Import.php | 5 +- .../Product/Flat/Plugin/IndexerConfigData.php | 26 +- .../Indexer/Product/Flat/Plugin/Store.php | 16 +- .../Product/Flat/Plugin/StoreGroup.php | 20 +- app/code/Magento/Catalog/Model/Observer.php | 12 +- app/code/Magento/Catalog/Model/Plugin/Log.php | 5 +- .../Model/Plugin/QuoteItemProductOption.php | 24 +- app/code/Magento/Catalog/Model/Product.php | 22 +- .../Product/Attribute/Backend/Startdate.php | 14 +- .../Catalog/Model/Product/Compare/Item.php | 16 +- .../Model/Product/Option/Type/Date.php | 30 +- .../Catalog/Model/Product/Type/Price.php | 16 +- .../Model/Resource/AbstractResource.php | 6 +- .../Catalog/Model/Resource/Category.php | 6 +- .../Catalog/Model/Resource/Eav/Attribute.php | 9 +- .../Catalog/Model/Resource/Product.php | 6 +- .../Model/Resource/Product/Collection.php | 14 +- .../Product/Compare/Item/Collection.php | 6 +- .../Model/Resource/Product/Indexer/Price.php | 14 +- .../Magento/Catalog/Model/Resource/Url.php | 39 +- app/code/Magento/Catalog/Model/Url.php | 38 +- app/code/Magento/Catalog/etc/adminhtml/di.xml | 3 - app/code/Magento/Catalog/etc/di.xml | 6 +- app/code/Magento/Catalog/etc/frontend/di.xml | 10 - app/code/Magento/Catalog/etc/module.xml | 1 + .../catalog/category/edit/form.phtml | 6 +- .../catalog/product/composite/configure.phtml | 2 +- .../frontend/layout/catalog_category_view.xml | 7 + .../frontend/layout/catalog_product_view.xml | 7 + .../CatalogInventory/Block/Qtyincrements.php | 12 +- .../Block/Stockqty/DefaultStockqty.php | 12 +- .../CatalogInventory/Model/Stock/Item.php | 26 +- .../Magento/CatalogInventory/etc/events.xml | 2 +- .../Adminhtml/Promo/Catalog/Edit/Tab/Main.php | 2 +- .../Controller/Adminhtml/Promo/Catalog.php | 4 +- .../Magento/CatalogRule/Model/Observer.php | 18 +- .../CatalogRule/Model/Resource/Rule.php | 6 +- app/code/Magento/CatalogRule/Model/Rule.php | 8 +- .../CatalogSearch/Block/Advanced/Form.php | 5 +- .../Model/Resource/Advanced/Collection.php | 12 +- .../CatalogSearch/Model/Resource/Fulltext.php | 28 +- .../Model/Resource/Fulltext/Collection.php | 6 +- .../CatalogSearch/Model/Resource/Query.php | 6 +- .../Model/Resource/Search/Collection.php | 6 +- app/code/Magento/Centinel/Helper/Data.php | 2 +- .../Checkout/Block/Cart/Item/Renderer.php | 15 +- .../Magento/Checkout/Block/Cart/Shipping.php | 9 +- .../Magento/Checkout/Block/Cart/Sidebar.php | 17 +- .../Block/Onepage/Payment/Methods.php | 14 +- app/code/Magento/Checkout/Controller/Cart.php | 114 +- .../Express/RedirectLoginInterface.php | 59 + app/code/Magento/Checkout/Helper/Data.php | 12 +- .../Checkout/Helper/ExpressRedirect.php | 95 ++ app/code/Magento/Checkout/Model/Session.php | 33 +- .../Magento/Checkout/Model/Type/Onepage.php | 27 +- app/code/Magento/Checkout/etc/frontend/di.xml | 10 - .../Checkout/view/frontend/js/opcheckout.js | 9 - .../frontend/layout/catalog_category_view.xml | 36 + .../frontend/layout/catalog_product_view.xml | 36 + .../layout/checkout_cart_item_renderers.xml | 4 +- .../checkout_cart_sidebar_item_renderers.xml | 6 +- .../layout/checkout_onepage_index.xml | 7 +- .../layout/checkout_onepage_paymentmethod.xml | 4 - ...checkout_onepage_review_item_renderers.xml | 2 +- .../Checkout/view/frontend/layout/default.xml | 2 +- .../Block/Adminhtml/Page/Edit/Tab/Design.php | 2 +- app/code/Magento/Cms/Block/Block.php | 12 +- app/code/Magento/Cms/Block/Page.php | 12 +- .../Magento/Cms/Controller/Adminhtml/Page.php | 6 +- app/code/Magento/Cms/Helper/Page.php | 15 +- app/code/Magento/Cms/Model/Block.php | 12 +- app/code/Magento/Cms/Model/Page.php | 12 +- app/code/Magento/Cms/Model/Resource/Block.php | 6 +- app/code/Magento/Cms/Model/Resource/Page.php | 6 +- .../Product/Edit/Tab/Super/Config.php | 72 +- .../Product/Edit/Tab/Super/Config/Matrix.php | 20 +- .../Block/Cart/Item/Renderer/Configurable.php | 16 +- .../Block/Product/View/Type/Configurable.php | 80 +- .../Adminhtml/Product/Builder/Plugin.php | 20 +- .../Helper/Plugin/Configurable.php | 9 +- .../Helper/Product/Configuration/Plugin.php | 22 +- .../Group/AttributeMapper/Plugin.php | 20 +- .../Entity/Product/Type/Configurable.php | 22 +- .../Order/Admin/Item/Plugin/Configurable.php | 54 +- .../CartConfiguration/Plugin/Configurable.php | 23 +- .../Model/Product/Type/Configurable/Price.php | 6 +- .../Model/Product/Type/Plugin.php | 9 +- .../Plugin/Configurable.php | 27 +- .../Model/Product/Validator/Plugin.php | 30 +- .../Option/Plugin/ConfigurableProduct.php | 22 +- .../Product/Collection/AssociatedProduct.php | 6 +- .../Resource/Product/Type/Configurable.php | 2 +- .../ConfigurableProduct/etc/module.xml | 1 + app/code/Magento/Connect/Helper/Data.php | 3 - .../Model/System/Config/Backend/Links.php | 13 +- .../Magento/Core/App/Action/Plugin/Design.php | 16 +- .../Core/App/Action/Plugin/Install.php | 16 +- .../Core/App/Action/Plugin/LastUrl.php | 16 +- .../Core/App/Action/Plugin/Session.php | 157 -- .../Core/App/Action/Plugin/StoreCheck.php | 24 +- .../Plugin/DispatchExceptionHandler.php | 18 +- .../Plugin/RequestPreprocessor.php | 19 +- .../App/FrontController/Plugin/UrlRewrite.php | 29 +- .../code/Magento/Core/Block/RequireCookie.php | 24 +- app/code/Magento/Core/Filter/DateTime.php | 31 - app/code/Magento/Core/Helper/Data.php | 16 +- app/code/Magento/Core/Helper/File/Media.php | 6 +- app/code/Magento/Core/Helper/Js.php | 8 +- app/code/Magento/Core/Helper/Translate.php | 36 +- app/code/Magento/Core/Model/AbstractModel.php | 2 + app/code/Magento/Core/Model/App.php | 53 +- app/code/Magento/Core/Model/App/Area.php | 26 +- .../Core/Model/App/Area/DesignExceptions.php | 79 + app/code/Magento/Core/Model/App/Emulation.php | 32 +- .../Model/Asset/Plugin/CleanMergedJsCss.php | 14 +- app/code/Magento/Core/Model/Design.php | 24 +- .../Core/Model/File/Storage/Database.php | 4 +- .../Storage/Database/AbstractDatabase.php | 6 +- .../Model/File/Storage/Directory/Database.php | 4 +- .../Core/Model/File/Storage/Response.php | 12 +- app/code/Magento/Core/Model/Layout.php | 5 + app/code/Magento/Core/Model/Locale.php | 939 ---------- .../Magento/Core/Model/LocaleInterface.php | 383 ----- .../Magento/Core/Model/Mview/View/State.php | 2 +- .../Core/Model/Resource/AbstractResource.php | 2 +- .../Core/Model/Resource/Translate/String.php | 14 +- app/code/Magento/Core/Model/Store.php | 24 +- .../Core/Model/Store/ConfigInterface.php | 19 +- app/code/Magento/Core/Model/Store/Group.php | 12 +- .../Magento/Core/Model/Store/Storage/Db.php | 18 +- .../TemplateEngine/Plugin/DebugHints.php | 9 +- app/code/Magento/Core/Model/Url/Rewrite.php | 14 +- app/code/Magento/Core/Model/View/Design.php | 12 +- app/code/Magento/Core/Model/Website.php | 20 +- app/code/Magento/Core/etc/di.xml | 45 +- app/code/Magento/Core/etc/layouts.xsd | 3 +- app/code/Magento/Core/i18n/de_DE.csv | 4 +- app/code/Magento/Core/i18n/en_US.csv | 4 +- app/code/Magento/Core/i18n/es_ES.csv | 4 +- app/code/Magento/Core/i18n/fr_FR.csv | 4 +- app/code/Magento/Core/i18n/nl_NL.csv | 4 +- app/code/Magento/Core/i18n/pt_BR.csv | 4 +- app/code/Magento/Core/i18n/zh_CN.csv | 4 +- .../Core/view/frontend/js/require-cookie.js | 68 + .../Core/view/frontend/require_cookie.phtml | 34 + .../Cron/Plugin/ApplicationInitializer.php | 9 +- .../Backend/Config/Structure/Converter.php | 5 +- app/code/Magento/Cron/Model/Schedule.php | 6 +- .../Model/System/Config/Initial/Converter.php | 5 +- app/code/Magento/Cron/etc/module.xml | 1 + .../Controller/Adminhtml/System/Currency.php | 2 +- .../Magento/CurrencySymbol/Helper/Data.php | 5 +- .../Model/System/Currencysymbol.php | 8 +- .../Customer/Block/Account/Customer.php | 24 +- .../Customer/Block/Account/Dashboard.php | 138 +- .../Block/Account/Dashboard/Address.php | 62 +- .../Block/Account/Dashboard/Block.php | 6 +- .../Block/Account/Dashboard/Hello.php | 31 +- .../Customer/Block/Account/Dashboard/Info.php | 39 +- .../Block/Account/Dashboard/Newsletter.php | 32 +- .../Block/Account/Dashboard/Sidebar.php | 18 +- .../Customer/Block/Account/Forgotpassword.php | 14 +- .../Customer/Block/Account/Resetpassword.php | 20 +- .../Magento/Customer/Block/Address/Edit.php | 147 +- .../Address/Renderer/DefaultRenderer.php | 8 +- .../Magento/Customer/Block/Adminhtml/Edit.php | 129 +- .../Customer/Block/Adminhtml/Edit/Form.php | 74 +- .../Edit/Renderer/Attribute/Group.php | 24 +- .../Block/Adminhtml/Edit/Renderer/Newpass.php | 6 +- .../Block/Adminhtml/Edit/Renderer/Region.php | 12 +- .../Block/Adminhtml/Edit/Tab/Account.php | 254 ++- .../Block/Adminhtml/Edit/Tab/Addresses.php | 230 ++- .../Block/Adminhtml/Edit/Tab/Cart.php | 120 +- .../Block/Adminhtml/Edit/Tab/Carts.php | 44 +- .../Adminhtml/Edit/Tab/GenericMetadata.php | 115 ++ .../Block/Adminhtml/Edit/Tab/Newsletter.php | 72 +- .../Tab/Newsletter/Grid/Filter/Status.php | 52 +- .../Tab/Newsletter/Grid/Renderer/Action.php | 22 +- .../Tab/Newsletter/Grid/Renderer/Status.php | 15 +- .../Block/Adminhtml/Edit/Tab/Orders.php | 67 +- .../Block/Adminhtml/Edit/Tab/View.php | 118 +- .../Adminhtml/Edit/Tab/View/Accordion.php | 70 +- .../Block/Adminhtml/Edit/Tab/View/Cart.php | 135 +- .../Edit/Tab/View/Grid/Renderer/Item.php | 25 +- .../Block/Adminhtml/Edit/Tab/View/Orders.php | 66 +- .../Block/Adminhtml/Edit/Tab/View/Sales.php | 74 +- .../Adminhtml/Edit/Tab/View/Wishlist.php | 54 +- .../Wishlist/Grid/Renderer/Description.php | 17 +- .../Customer/Block/Adminhtml/Edit/Tabs.php | 25 +- .../Magento/Customer/Block/Adminhtml/Grid.php | 5 + .../Customer/Block/Adminhtml/Group/Edit.php | 40 +- .../Block/Adminhtml/Group/Edit/Form.php | 54 +- app/code/Magento/Customer/Block/Form/Edit.php | 73 +- .../Magento/Customer/Block/Form/Register.php | 9 +- .../Magento/Customer/Block/Newsletter.php | 30 +- .../Customer/Block/Widget/AbstractWidget.php | 2 +- .../Magento/Customer/Block/Widget/Dob.php | 2 +- .../Magento/Customer/Block/Widget/Gender.php | 54 +- .../Magento/Customer/Block/Widget/Name.php | 45 +- .../Magento/Customer/Block/Widget/Taxvat.php | 46 +- .../Magento/Customer/Controller/Account.php | 439 +++-- .../Adminhtml/Cart/Product/Composite/Cart.php | 26 +- .../Customer/Controller/Adminhtml/Group.php | 97 +- .../Customer/Controller/Adminhtml/Index.php | 707 ++++---- .../Wishlist/Product/Composite/Wishlist.php | 27 +- .../RegistryConstants.php} | 34 +- app/code/Magento/Customer/Helper/Address.php | 6 + app/code/Magento/Customer/Helper/Data.php | 2 +- .../Model/Attribute/Data/Postcode.php | 10 +- .../Magento/Customer/Model/Config/Share.php | 19 + app/code/Magento/Customer/Model/Customer.php | 10 +- .../Model/Layout/DepersonalizePlugin.php | 135 ++ .../Model/Metadata/ElementFactory.php | 4 +- .../Magento/Customer/Model/Metadata/Form.php | 51 +- .../Model/Metadata/Form/AbstractData.php | 42 +- .../Customer/Model/Metadata/Form/Date.php | 4 +- .../Customer/Model/Metadata/Form/File.php | 8 +- .../Model/Metadata/Form/Multiline.php | 4 +- .../Customer/Model/Metadata/Form/Text.php | 8 +- .../Customer/Model/Metadata/FormFactory.php | 8 +- .../Customer/Model/Metadata/Validator.php | 6 +- .../Customer/Model/Resource/Address.php | 6 +- .../Customer/Model/Resource/Customer.php | 6 +- app/code/Magento/Customer/Model/Session.php | 64 +- .../Service/V1/CustomerAccountService.php | 216 ++- .../V1/CustomerAccountServiceInterface.php | 120 +- .../V1/CustomerAddressCurrentService.php | 81 + ...CustomerAddressCurrentServiceInterface.php | 51 + .../Service/V1/CustomerAddressService.php | 6 +- .../V1/CustomerAddressServiceInterface.php | 20 +- .../Service/V1/CustomerCurrentService.php | 135 ++ ...hp => CustomerCurrentServiceInterface.php} | 29 +- .../V1/CustomerGroupServiceInterface.php | 2 +- .../Service/V1/CustomerMetadataService.php | 91 +- .../Customer/Service/V1/CustomerService.php | 24 +- .../Service/V1/CustomerServiceInterface.php | 20 + .../Customer/Service/V1/Dto/Address.php | 26 +- .../Service/V1/Dto/AddressBuilder.php | 11 +- .../Service/V1/Dto/CustomerBuilder.php | 22 + .../Service/V1/Dto/Eav/AttributeMetadata.php | 11 + .../V1/Dto/Eav/AttributeMetadataBuilder.php | 49 +- app/code/Magento/Customer/etc/di.xml | 4 + app/code/Magento/Customer/etc/frontend/di.xml | 12 +- app/code/Magento/Customer/etc/module.xml | 1 + app/code/Magento/Customer/i18n/de_DE.csv | 2 +- app/code/Magento/Customer/i18n/en_US.csv | 2 +- app/code/Magento/Customer/i18n/es_ES.csv | 2 +- app/code/Magento/Customer/i18n/fr_FR.csv | 2 +- app/code/Magento/Customer/i18n/nl_NL.csv | 2 +- app/code/Magento/Customer/i18n/pt_BR.csv | 2 +- .../tab/account/form/renderer/group.phtml | 1 + .../view/adminhtml/tab/addresses.phtml | 8 +- .../Customer/view/adminhtml/tab/cart.phtml | 2 +- .../frontend/account/link/authorization.phtml | 11 +- .../Customer/view/frontend/form/edit.phtml | 4 +- .../layout/customer_account_create.xml | 7 + .../layout/customer_account_login.xml | 7 + .../Customer/view/frontend/layout/default.xml | 6 +- .../view/frontend/widget/gender.phtml | 2 +- .../Customer/view/frontend/widget/name.phtml | 14 +- .../Adminhtml/Editor/Toolbar/Buttons/Edit.php | 2 +- .../Model/Plugin/ThemeCopyService.php | 31 +- .../Block/Adminhtml}/Unitofmeasure.php | 38 +- .../Carrier/Dhl => Dhl/Model}/AbstractDhl.php | 12 +- .../Model/Carrier.php} | 59 +- .../Plugin/Checkout/Block/Cart/Shipping.php | 65 + .../Rma/Edit/Tab/General/Shippingmethod.php | 59 + .../{Usa => Dhl}/Model/Resource/Setup.php | 26 +- .../Model}/Source/Contenttype.php | 10 +- .../Model}/Source/Method/AbstractMethod.php | 12 +- .../Magento/Dhl/Model/Source/Method/Doc.php | 38 + .../Model}/Source/Method/Freedoc.php | 13 +- .../Model}/Source/Method/Freenondoc.php | 13 +- .../Model/Source/Method}/Generic.php | 13 +- .../Dhl/Model/Source/Method/Nondoc.php | 38 + .../Model/Source/Method}/Size.php | 11 +- .../Model/Source/Method/Unitofmeasure.php} | 13 +- app/code/Magento/Dhl/etc/adminhtml/system.xml | 175 ++ app/code/Magento/Dhl/etc/config.xml | 61 + .../international => Dhl/etc}/countries.xml | 2 - app/code/Magento/Dhl/etc/di.xml | 41 + app/code/Magento/{Usa => Dhl}/etc/module.xml | 10 +- .../sql/dhl_setup/install-2.0.0.0.php} | 7 +- .../dhl => Dhl/view/adminhtml}/logo.jpg | Bin .../view/adminhtml}/unitofmeasure.phtml | 20 +- app/code/Magento/Directory/Block/Currency.php | 8 + app/code/Magento/Directory/Model/Country.php | 16 +- app/code/Magento/Directory/Model/Currency.php | 30 +- .../Directory/Model/Currency/Filter.php | 23 +- .../Model/Resource/Country/Collection.php | 22 +- .../Directory/Model/Resource/Region.php | 14 +- .../Model/Resource/Region/Collection.php | 12 +- .../Magento/Directory/etc/adminhtml/di.xml | 1 - .../Directory/etc/adminhtml/system.xml | 6 +- .../Helper/Plugin/Downloadable.php | 9 +- .../Magento/Downloadable/Helper/Download.php | 8 +- .../CartConfiguration/Plugin/Downloadable.php | 22 +- .../Plugin/Downloadable.php | 22 +- .../Attribute/Edit/Main/AbstractMain.php | 2 +- .../Eav/Model/Attribute/Data/AbstractData.php | 30 +- .../Magento/Eav/Model/Attribute/Data/Date.php | 4 +- .../Magento/Eav/Model/Attribute/Data/File.php | 8 +- .../Magento/Eav/Model/Attribute/Data/Text.php | 8 +- app/code/Magento/Eav/Model/Entity.php | 6 +- .../Eav/Model/Entity/AbstractEntity.php | 16 +- .../Magento/Eav/Model/Entity/Attribute.php | 40 +- .../Entity/Attribute/Backend/Datetime.php | 18 +- .../Entity/Attribute/Frontend/Datetime.php | 18 +- .../Entity/Collection/AbstractCollection.php | 2 +- app/code/Magento/Eav/Model/Entity/Type.php | 61 +- .../Controller/Adminhtml/Email/Template.php | 2 +- .../Fedex.php => Fedex/Model/Carrier.php} | 16 +- .../Rma/Edit/Tab/General/Shippingmethod.php | 59 + .../Fedex => Fedex/Model}/Source/Dropoff.php | 6 +- .../Model}/Source/Freemethod.php | 6 +- .../Fedex => Fedex/Model}/Source/Generic.php | 8 +- .../Fedex => Fedex/Model}/Source/Method.php | 6 +- .../Model}/Source/Packaging.php | 6 +- .../Magento/Fedex/etc/adminhtml/system.xml | 145 ++ app/code/Magento/Fedex/etc/config.xml | 56 + app/code/Magento/Fedex/etc/di.xml | 38 + app/code/Magento/Fedex/etc/module.xml | 36 + .../etc/wsdl}/RateService_v10.wsdl | 0 .../etc/wsdl}/RateService_v9.wsdl | 0 .../etc/wsdl}/ShipService_v10.wsdl | 0 .../etc/wsdl}/ShipService_v9.wsdl | 0 .../etc/wsdl}/TrackService_v5.wsdl | 0 .../sql/fedex_setup/install-2.0.0.0.php} | 2 +- .../Message/Multishipping/Plugin/ItemsBox.php | 19 +- .../Magento/GiftMessage/Helper/Message.php | 3 - .../GiftMessage/Model/Plugin/QuoteItem.php | 24 +- app/code/Magento/GiftMessage/etc/module.xml | 1 + .../Model/Config/Source/Language.php | 8 +- .../GoogleCheckout/Controller/Redirect.php | 51 +- .../GoogleCheckout/Model/Api/Xml/Callback.php | 12 +- .../GoogleCheckout/Model/Api/Xml/Checkout.php | 4 +- .../Magento/GoogleCheckout/Model/Payment.php | 4 +- .../Magento/GoogleCheckout/etc/module.xml | 2 - .../GoogleOptimizer/Block/Code/Category.php | 14 +- .../GoogleOptimizer/Block/Code/Product.php | 14 +- .../Model/Attribute/DefaultAttribute.php | 2 +- .../Attribute/SalePriceEffectiveDate.php | 6 +- .../GoogleShopping/Model/Service/Item.php | 6 +- .../Block/Adminhtml/Order/Create/Sidebar.php | 39 +- .../Block/Cart/Item/Renderer/Grouped.php | 16 +- .../Block/Stockqty/Type/Grouped.php | 15 + .../Helper/ProductLinks/Plugin/Grouped.php | 9 +- .../Product/Configuration/Plugin/Grouped.php | 22 +- .../Cart/Configuration/Plugin/Grouped.php | 20 +- .../Model/Product/Type/Plugin.php | 5 +- .../Grouped/AssociatedProductsCollection.php | 6 +- .../Product/Quote/Plugin/Initializer.php | 27 +- app/code/Magento/GroupedProduct/etc/di.xml | 3 + .../layout/checkout_cart_item_renderers.xml | 2 +- .../checkout_cart_sidebar_item_renderers.xml | 2 +- ...checkout_onepage_review_item_renderers.xml | 2 +- .../Block/Adminhtml/Export/Filter.php | 2 +- app/code/Magento/ImportExport/Helper/Data.php | 3 - .../Model/Export/Entity/AbstractEav.php | 14 +- .../Model/Export/Entity/AbstractEntity.php | 14 +- .../Model/Export/Entity/Eav/Customer.php | 6 +- .../Export/Entity/Eav/Customer/Address.php | 6 +- .../Model/Export/Entity/Product.php | 6 +- .../Model/Import/Entity/Product.php | 12 +- app/code/Magento/Indexer/Model/Indexer.php | 4 +- .../Install/App/Action/Plugin/Design.php | 11 +- .../Magento/Install/App/Action/Plugin/Dir.php | 12 +- app/code/Magento/Install/App/Console.php | 13 +- app/code/Magento/Install/App/Output.php | 63 +- app/code/Magento/Install/Block/Locale.php | 57 +- app/code/Magento/Install/Model/Installer.php | 69 +- .../Install/Model/Installer/Console.php | 121 +- .../Model/Oauth/Nonce/Generator.php | 6 +- .../Model/Oauth/Token/Provider.php | 6 +- app/code/Magento/Integration/etc/di.xml | 4 +- app/code/Magento/Log/Model/Resource/Log.php | 6 +- .../Magento/Log/Model/Resource/Visitor.php | 6 +- .../Log/Model/Resource/Visitor/Online.php | 6 +- app/code/Magento/Log/Model/Visitor.php | 13 +- app/code/Magento/Log/etc/module.xml | 1 + .../Multishipping/Controller/Checkout.php | 44 +- .../layout/multishipping_checkout_billing.xml | 4 - .../Block/Adminhtml/Queue/Edit/Form.php | 6 +- .../Newsletter/Controller/Adminhtml/Queue.php | 2 +- .../Controller/Adminhtml/Template.php | 2 +- app/code/Magento/Newsletter/Model/Queue.php | 22 +- .../Model/Resource/Queue/Collection.php | 6 +- .../Newsletter/Model/Resource/Subscriber.php | 6 +- .../Newsletter/Model/Resource/Template.php | 6 +- .../Magento/Newsletter/Model/Subscriber.php | 34 +- .../view/frontend/layout/default.xml | 2 +- .../Block/Form/Banktransfer.php | 4 +- .../Block/Form/Cashondelivery.php | 4 +- .../Block/Form/Ccsave.php | 7 +- .../Block/Form/Checkmo.php | 6 +- .../Block/Form/Purchaseorder.php | 7 +- .../Block/Info/Ccsave.php | 4 +- .../Block/Info/Checkmo.php | 8 +- .../Block/Info/Purchaseorder.php | 8 +- .../Model}/Banktransfer.php | 6 +- .../Model}/Cashondelivery.php | 6 +- .../Model}/Ccsave.php | 8 +- .../Model}/Checkmo.php | 8 +- .../OfflinePayments/Model/Observer.php | 47 + .../Model}/Purchaseorder.php | 8 +- .../OfflinePayments/etc/adminhtml/system.xml | 274 +++ .../Magento/OfflinePayments/etc/config.xml | 72 + .../Magento/OfflinePayments/etc/events.xml | 30 + .../Magento/OfflinePayments/etc/module.xml | 37 + .../Magento/OfflinePayments/etc/payment.xml | 59 + .../view/adminhtml/form/banktransfer.phtml | 0 .../view/adminhtml/form/cashondelivery.phtml | 0 .../view/adminhtml/form/ccsave.phtml | 0 .../view/adminhtml/form/checkmo.phtml | 0 .../view/adminhtml/form/purchaseorder.phtml | 0 .../view/adminhtml/info/checkmo.phtml | 0 .../view/adminhtml/info/pdf/checkmo.phtml | 0 .../adminhtml/info/pdf/purchaseorder.phtml | 0 .../view/adminhtml/info/purchaseorder.phtml | 0 .../view/frontend/form/banktransfer.phtml | 0 .../view/frontend/form/cashondelivery.phtml | 0 .../view/frontend/form/ccsave.phtml | 0 .../view/frontend/form/checkmo.phtml | 0 .../view/frontend/form/purchaseorder.phtml | 0 .../view/frontend/info/checkmo.phtml | 0 .../view/frontend/info/purchaseorder.phtml | 0 .../Adminhtml/Carrier/Tablerate/Grid.php | 20 +- .../Block/Adminhtml}/Form/Field/Export.php | 16 +- .../Block/Adminhtml}/Form/Field/Import.php | 7 +- .../Controller/Adminhtml/System/Config.php | 82 + .../Model/Carrier/Flatrate.php | 6 +- .../Model/Carrier/Freeshipping.php | 10 +- .../Model/Carrier/Pickup.php | 4 +- .../Model/Carrier/Tablerate.php | 10 +- .../Model/Config/Backend/Tablerate.php | 10 +- .../Model/Config/Source/Flatrate.php | 4 +- .../Model/Config/Source/Tablerate.php | 14 +- .../Model/Observer/SalesRule/ActionsTab.php | 56 + .../Plugin/Checkout/Block/Cart/Shipping.php} | 36 +- .../Model/Quote/Freeshipping.php | 21 +- .../Model/Resource/Carrier/Tablerate.php | 20 +- .../Resource/Carrier/Tablerate/Collection.php | 12 +- .../Model/SalesRule/Calculator.php | 75 + .../OfflineShipping/Model/SalesRule/Rule.php | 45 + .../OfflineShipping/etc/adminhtml/events.xml | 30 + .../etc/adminhtml/routes.xml} | 8 +- .../OfflineShipping/etc/adminhtml/system.xml | 174 ++ .../Magento/OfflineShipping/etc/config.xml | 62 + .../{Usa => OfflineShipping}/etc/di.xml | 5 +- .../Magento/OfflineShipping/etc/fieldset.xml | 40 + .../Magento/OfflineShipping/etc/module.xml | 44 + .../Magento/OfflineShipping/etc/sales.xml | 32 + .../install-2.0.0.0.php} | 51 +- app/code/Magento/Ogone/Model/Api.php | 12 +- app/code/Magento/Ogone/Model/Config.php | 6 +- .../Magento/PageCache/Block/Javascript.php | 26 +- .../Magento/PageCache/Controller/Block.php | 55 +- app/code/Magento/PageCache/Helper/Data.php | 45 +- .../Model/App/FrontController/CachePlugin.php | 84 + .../App/FrontController/HeaderPlugin.php | 119 -- app/code/Magento/PageCache/Model/Config.php | 18 + .../PageCache/Model/Layout/LayoutPlugin.php | 102 ++ app/code/Magento/PageCache/Model/Observer.php | 105 +- .../System/Config/Source/Application.php | 8 +- app/code/Magento/PageCache/etc/config.xml | 4 +- app/code/Magento/PageCache/etc/events.xml | 6 + .../Magento/PageCache/etc/frontend/di.xml | 33 + .../PageCache/view/frontend/js/page-cache.js | 4 +- app/code/Magento/Payment/Block/Form.php | 4 +- .../Magento/Payment/Block/Form/Container.php | 4 +- app/code/Magento/Payment/Block/Info.php | 2 +- app/code/Magento/Payment/Block/Info/Cc.php | 4 +- app/code/Magento/Payment/Helper/Data.php | 7 +- app/code/Magento/Payment/Model/Config.php | 14 +- app/code/Magento/Payment/Model/Info.php | 2 +- .../Payment/Model/Method/AbstractMethod.php | 2 +- app/code/Magento/Payment/Model/Method/Cc.php | 14 +- .../Magento/Payment/Model/Method/Factory.php | 6 +- .../Magento/Payment/Model/MethodInterface.php | 52 + app/code/Magento/Payment/Model/Observer.php | 16 - .../Magento/Payment/etc/adminhtml/system.xml | 243 --- app/code/Magento/Payment/etc/config.xml | 41 - app/code/Magento/Payment/etc/events.xml | 3 - app/code/Magento/Payment/etc/module.xml | 2 +- app/code/Magento/Payment/etc/payment.xml | 31 - .../Adminhtml/Billing/Agreement/Grid.php | 9 - .../Adminhtml/Settlement/Details/Form.php | 16 +- .../Magento/Paypal/Block/Express/Form.php | 4 +- .../Magento/Paypal/Block/Express/Shortcut.php | 12 +- app/code/Magento/Paypal/Block/Logo.php | 14 +- .../Magento/Paypal/Block/Standard/Form.php | 16 +- .../Controller/Express/AbstractExpress.php | 43 +- .../Magento/Paypal/Controller/Hostedpro.php | 17 +- .../Magento/Paypal/Controller/Payflow.php | 23 +- .../Paypal/Controller/Payflowadvanced.php | 159 +- .../Magento/Paypal/Controller/Standard.php | 12 +- app/code/Magento/Paypal/Helper/Checkout.php | 22 - app/code/Magento/Paypal/Helper/Data.php | 54 - .../Magento/Paypal/Model/Api/AbstractApi.php | 12 +- app/code/Magento/Paypal/Model/Api/Nvp.php | 6 +- .../Magento/Paypal/Model/Api/PayflowNvp.php | 6 +- .../Model/Billing/AbstractAgreement.php | 4 +- .../Paypal/Model/Billing/Agreement.php | 6 +- app/code/Magento/Paypal/Model/Config.php | 8 +- app/code/Magento/Paypal/Model/Direct.php | 6 +- .../Magento/Paypal/Model/Express/Checkout.php | 12 +- app/code/Magento/Paypal/Model/Hostedpro.php | 6 +- app/code/Magento/Paypal/Model/Payflowlink.php | 6 +- app/code/Magento/Paypal/Model/Payflowpro.php | 6 +- .../Paypal/Model/Payment/Transaction.php | 6 +- .../Paypal/Model/Report/Settlement.php | 4 +- .../Magento/Paypal/Model/Resource/Cert.php | 6 +- .../Model/Resource/Report/Settlement.php | 10 +- app/code/Magento/Paypal/etc/di.xml | 10 + .../Paypal/view/frontend/js/opcheckout.js | 46 + .../layout/checkout_onepage_index.xml | 30 + .../Paypal/view/frontend/onepage.phtml | 37 + .../Magento/Persistent/Controller/Index.php | 1 - app/code/Magento/Persistent/Helper/Data.php | 3 - .../Magento/Persistent/Helper/Session.php | 3 - .../Magento/Persistent/Model/Observer.php | 35 +- .../Persistent/etc/frontend/events.xml | 13 +- app/code/Magento/Persistent/etc/module.xml | 2 - .../Magento/ProductAlert/Model/Observer.php | 6 +- .../ProductAlert/Model/Resource/Price.php | 6 +- .../ProductAlert/Model/Resource/Stock.php | 6 +- .../Customer/Edit/Tab/RecurringProfile.php | 9 +- .../Block/Catalog/Product/View/Profile.php | 8 +- .../RecurringProfile/Block/Plugin/Payment.php | 7 +- .../Controller/Adminhtml/RecurringProfile.php | 4 +- .../RecurringProfile/Model/Observer.php | 14 +- .../RecurringProfile/Model/Profile.php | 9 +- .../Model/RecurringProfile.php | 56 +- .../RecurringProfile/etc/frontend/events.xml | 2 +- .../Adminhtml/Config/Form/Field/YtdStart.php | 2 +- .../Reports/Block/Adminhtml/Filter/Form.php | 2 +- .../Magento/Reports/Block/Adminhtml/Grid.php | 14 +- .../Grid/Column/Renderer/Currency.php | 2 +- .../Sales/Grid/Column/Renderer/Date.php | 28 +- .../Magento/Reports/Block/Product/Viewed.php | 16 +- .../Adminhtml/Report/AbstractReport.php | 20 +- .../Adminhtml/Report/Statistics.php | 9 +- app/code/Magento/Reports/Helper/Data.php | 8 +- .../Magento/Reports/Model/DateFactory.php | 6 +- app/code/Magento/Reports/Model/Event.php | 6 +- app/code/Magento/Reports/Model/Plugin/Log.php | 5 +- .../Model/Resource/Order/Collection.php | 16 +- .../Model/Resource/Product/Collection.php | 6 +- .../Index/Collection/AbstractCollection.php | 6 +- .../Resource/Product/Lowstock/Collection.php | 6 +- .../Model/Resource/Refresh/Collection.php | 16 +- .../Model/Resource/Report/AbstractReport.php | 24 +- .../Model/Resource/Report/Collection.php | 39 +- .../Model/Resource/Report/Product/Viewed.php | 6 +- .../Report/Product/Viewed/Collection.php | 4 +- .../Review/Block/Customer/ListCustomer.php | 19 +- .../Magento/Review/Block/Customer/Recent.php | 2 +- .../Magento/Review/Block/Customer/View.php | 2 +- .../Magento/Review/Block/Product/View.php | 3 + app/code/Magento/Review/Block/View.php | 2 +- .../Magento/Review/Model/Resource/Review.php | 6 +- .../Resource/Review/Product/Collection.php | 6 +- app/code/Magento/Review/etc/frontend/di.xml | 8 - .../frontend/layout/catalog_product_view.xml | 36 + .../Rss/App/Action/Plugin/Authentication.php | 29 +- app/code/Magento/Rss/Block/AbstractBlock.php | 3 +- .../Rss/Block/Catalog/AbstractCatalog.php | 1 - .../Magento/Rss/Block/Catalog/Category.php | 16 +- .../Magento/Rss/Block/Catalog/NewCatalog.php | 13 +- .../Magento/Rss/Block/Catalog/NotifyStock.php | 3 +- app/code/Magento/Rss/Block/Catalog/Review.php | 5 +- .../Magento/Rss/Block/Catalog/Salesrule.php | 8 +- .../Magento/Rss/Block/Catalog/Special.php | 25 +- app/code/Magento/Rss/Block/ListBlock.php | 54 +- app/code/Magento/Rss/Block/Order/Details.php | 5 +- app/code/Magento/Rss/Block/Order/NewOrder.php | 9 +- app/code/Magento/Rss/Block/Order/Status.php | 17 +- app/code/Magento/Rss/Block/Wishlist.php | 4 +- .../Rss/Controller/Adminhtml/Authenticate.php | 3 +- .../Rss/Controller/Adminhtml/Catalog.php | 7 +- .../Rss/Controller/Adminhtml/Order.php | 5 +- app/code/Magento/Rss/Controller/Catalog.php | 18 +- app/code/Magento/Rss/Controller/Index.php | 6 +- app/code/Magento/Rss/Controller/Order.php | 5 +- app/code/Magento/Rss/Helper/Order.php | 3 +- app/code/Magento/Rss/Model/Resource/Order.php | 6 +- app/code/Magento/Rss/Model/Rss.php | 27 +- .../Rss/Model/System/Config/Backend/Links.php | 4 +- app/code/Magento/Rule/Model/AbstractModel.php | 16 +- .../Model/Condition/AbstractCondition.php | 8 +- .../Magento/Rule/Model/Condition/Context.php | 16 +- .../Condition/Product/AbstractProduct.php | 14 +- app/code/Magento/Rule/Model/Rule.php | 6 +- .../Order/Create/Billing/Method/Form.php | 2 +- .../Block/Adminhtml/Order/Create/Data.php | 12 +- .../Block/Adminhtml/Order/Create/Form.php | 10 +- .../Order/Create/Form/AbstractForm.php | 2 +- .../Adminhtml/Order/Create/Form/Address.php | 4 +- .../Adminhtml/Order/View/Tab/History.php | 4 +- .../Block/Adminhtml/Transactions/Detail.php | 4 +- .../Magento/Sales/Block/Reorder/Sidebar.php | 22 +- .../Creditmemo/AbstractCreditmemo.php | 4 +- .../Adminhtml/Invoice/AbstractInvoice.php | 4 +- .../Sales/Controller/Adminhtml/Order.php | 8 +- .../Adminhtml/Shipment/AbstractShipment.php | 4 +- app/code/Magento/Sales/Controller/Guest.php | 4 +- app/code/Magento/Sales/Helper/Guest.php | 13 +- app/code/Magento/Sales/Helper/Reorder.php | 3 - .../Magento/Sales/Model/AbstractModel.php | 18 +- .../Magento/Sales/Model/AdminOrder/Create.php | 7 +- app/code/Magento/Sales/Model/Observer.php | 44 +- app/code/Magento/Sales/Model/Order.php | 12 +- .../Magento/Sales/Model/Order/Creditmemo.php | 10 +- .../Sales/Model/Order/Creditmemo/Comment.php | 6 +- .../Magento/Sales/Model/Order/Invoice.php | 14 +- .../Sales/Model/Order/Invoice/Comment.php | 6 +- .../Sales/Model/Order/Payment/Transaction.php | 6 +- .../Sales/Model/Order/Pdf/AbstractPdf.php | 12 +- .../Sales/Model/Order/Pdf/Creditmemo.php | 18 +- .../Magento/Sales/Model/Order/Pdf/Invoice.php | 18 +- .../Sales/Model/Order/Pdf/Shipment.php | 18 +- .../Magento/Sales/Model/Order/Shipment.php | 8 +- .../Sales/Model/Order/Shipment/Comment.php | 6 +- .../Sales/Model/Order/Shipment/Track.php | 6 +- .../Sales/Model/Order/Status/History.php | 6 +- .../Sales/Model/Quote/Address/RateRequest.php | 10 +- .../Model/Quote/Address/RateResult/Method.php | 12 +- app/code/Magento/Sales/Model/Quote/Item.php | 12 +- .../Magento/Sales/Model/Quote/Payment.php | 2 +- .../Model/Resource/Report/Bestsellers.php | 6 +- .../Report/Bestsellers/Collection.php | 4 +- .../Sales/Model/Resource/Report/Order.php | 6 +- .../Sales/Model/Resource/Sale/Collection.php | 15 +- .../Magento/Sales/Model/Service/Quote.php | 128 +- .../Magento/Sales/etc/adminhtml/events.xml | 3 - app/code/Magento/Sales/etc/fieldset.xml | 6 - .../Sales/sql/sales_setup/install-1.6.0.0.php | 18 - .../Sales/view/frontend/layout/default.xml | 4 +- .../SalesRule/Block/Adminhtml/Promo/Quote.php | 9 +- .../Block/Adminhtml/Promo/Quote/Edit.php | 6 +- .../Block/Adminhtml/Promo/Quote/Edit/Form.php | 15 +- .../Promo/Quote/Edit/Tab/Actions.php | 33 +- .../Promo/Quote/Edit/Tab/Conditions.php | 22 +- .../Promo/Quote/Edit/Tab/Coupons.php | 21 +- .../Promo/Quote/Edit/Tab/Coupons/Form.php | 6 +- .../Promo/Quote/Edit/Tab/Coupons/Grid.php | 12 +- .../Tab/Coupons/Grid/Column/Renderer/Used.php | 7 +- .../Adminhtml/Promo/Quote/Edit/Tab/Labels.php | 24 +- .../Adminhtml/Promo/Quote/Edit/Tab/Main.php | 26 +- .../Quote/Edit/Tab/Main/Renderer/Checkbox.php | 3 +- .../Block/Adminhtml/Promo/Quote/Edit/Tabs.php | 9 +- .../Block/Adminhtml/Promo/Widget/Chooser.php | 6 +- .../Controller/Adminhtml/Promo/Quote.php | 64 +- app/code/Magento/SalesRule/Exception.php | 2 - app/code/Magento/SalesRule/Helper/Coupon.php | 3 +- app/code/Magento/SalesRule/Helper/Data.php | 24 +- app/code/Magento/SalesRule/Model/Coupon.php | 16 +- .../SalesRule/Model/Coupon/Codegenerator.php | 2 - .../SalesRule/Model/Coupon/Massgenerator.php | 14 +- app/code/Magento/SalesRule/Model/Observer.php | 53 +- .../Plugin/QuoteConfigProductAttributes.php | 33 +- .../SalesRule/Model/Quote/Discount.php | 25 +- .../Model/Quote/Nominal/Discount.php | 3 +- .../SalesRule/Model/Resource/Coupon.php | 21 +- .../Model/Resource/Coupon/Collection.php | 26 +- .../SalesRule/Model/Resource/Coupon/Usage.php | 18 +- .../Model/Resource/Report/Collection.php | 16 +- .../SalesRule/Model/Resource/Report/Rule.php | 17 +- .../Model/Resource/Report/Rule/Createdat.php | 13 +- .../Model/Resource/Report/Rule/Updatedat.php | 11 +- .../Resource/Report/Updatedat/Collection.php | 4 +- .../Magento/SalesRule/Model/Resource/Rule.php | 38 +- .../Model/Resource/Rule/Collection.php | 25 +- .../Model/Resource/Rule/Customer.php | 9 +- .../Resource/Rule/Customer/Collection.php | 5 +- .../Model/Resource/Rule/Quote/Collection.php | 3 +- .../SalesRule/Model/Resource/Setup.php | 3 +- app/code/Magento/SalesRule/Model/Rule.php | 75 +- .../Model/Rule/Action/Collection.php | 2 - .../SalesRule/Model/Rule/Action/Product.php | 17 +- .../Model/Rule/Condition/Address.php | 15 +- .../Model/Rule/Condition/Combine.php | 4 +- .../Model/Rule/Condition/Product.php | 12 +- .../Model/Rule/Condition/Product/Combine.php | 10 +- .../Model/Rule/Condition/Product/Found.php | 10 +- .../Rule/Condition/Product/Subselect.php | 20 +- .../Magento/SalesRule/Model/Rule/Customer.php | 18 +- .../System/Config/Source/Coupon/Format.php | 7 +- .../Magento/SalesRule/Model/Validator.php | 131 +- app/code/Magento/SalesRule/etc/module.xml | 1 + app/code/Magento/SalesRule/etc/sales.xml | 1 - .../sql/salesrule_setup/install-1.6.0.0.php | 5 - .../Block/Adminhtml/Order/Packaging.php | 22 +- .../Magento/Shipping/Block/Tracking/Popup.php | 8 +- .../Controller/Adminhtml/Order/Shipment.php | 3 +- .../Data.php => Shipping/Helper/Carrier.php} | 112 +- .../Model/Carrier/AbstractCarrierOnline.php} | 16 +- .../Model/Carrier/Source/GenericInterface.php | 34 + .../Model/Config/Source/Online}/Mode.php | 15 +- .../Config/Source/Online}/Requesttype.php | 14 +- app/code/Magento/Shipping/Model/Observer.php | 14 +- .../Shipping/Model/Order/Pdf/Packaging.php | 38 +- .../Magento/Shipping/Model/Order/Track.php | 6 +- .../Model/Simplexml/Element.php | 7 +- .../Shipping/Model/Tracking/Result/Status.php | 20 +- .../Magento/Shipping/etc/adminhtml/system.xml | 143 -- app/code/Magento/Shipping/etc/config.xml | 33 - app/code/Magento/Shipping/etc/module.xml | 1 - .../adminhtml/order/packaging/packed.phtml | 12 +- .../adminhtml/order/packaging/popup.phtml | 2 +- .../Block/Adminhtml/Grid/Renderer/Time.php | 6 +- app/code/Magento/Sitemap/Model/Sitemap.php | 6 +- app/code/Magento/Tax/Helper/Data.php | 26 +- app/code/Magento/Tax/Model/Observer.php | 26 +- .../Magento/Tax/Model/Resource/Report/Tax.php | 6 +- app/code/Magento/Theme/Block/Html.php | 23 +- app/code/Magento/Theme/Block/Html/Footer.php | 13 +- app/code/Magento/Theme/Block/Html/Head.php | 10 +- app/code/Magento/Theme/Block/Html/Topmenu.php | 30 +- .../Theme/view/frontend/layout/default.xml | 2 +- .../Block/Backend/System/CarrierConfig.php} | 37 +- app/code/Magento/Ups/Helper/Config.php | 337 ++++ .../Carrier/Ups.php => Ups/Model/Carrier.php} | 373 +--- .../Model/Config}/Source/Container.php | 10 +- .../Model/Config}/Source/DestType.php | 10 +- .../Model/Config}/Source/Freemethod.php | 10 +- .../Model/Config}/Source/Generic.php | 22 +- .../Model/Config}/Source/Method.php | 10 +- .../Model/Config}/Source/OriginShipment.php | 15 +- .../Model/Config}/Source/Pickup.php | 12 +- .../Ups => Ups/Model/Config}/Source/Type.php | 16 +- .../Model/Config}/Source/Unitofmeasure.php | 12 +- app/code/Magento/Ups/etc/adminhtml/system.xml | 174 ++ app/code/Magento/Ups/etc/config.xml | 64 + app/code/Magento/Ups/etc/module.xml | 36 + .../layout/adminhtml_system_config_edit.xml | 30 + .../system/shipping/carrier_config.phtml} | 13 +- .../Usa/Model/Shipping/Carrier/Dhl.php | 1517 ----------------- .../Dhl/International/Source/Method/Doc.php | 45 - .../International/Source/Method/Generic.php | 61 - .../Dhl/International/Source/Method/Size.php | 44 - .../Source/Method/Unitofmeasure.php | 44 - .../Carrier/Dhl/Source/Protection/Value.php | 44 - .../Carrier/Usps/Source/Container.php | 38 - .../Carrier/Usps/Source/Freemethod.php | 41 - app/code/Magento/Usa/etc/adminhtml/system.xml | 702 -------- app/code/Magento/Usa/etc/config.xml | 164 -- app/code/Magento/Usa/i18n/de_DE.csv | 296 ---- app/code/Magento/Usa/i18n/en_US.csv | 381 ----- app/code/Magento/Usa/i18n/es_ES.csv | 296 ---- app/code/Magento/Usa/i18n/fr_FR.csv | 296 ---- app/code/Magento/Usa/i18n/nl_NL.csv | 296 ---- app/code/Magento/Usa/i18n/pt_BR.csv | 296 ---- app/code/Magento/Usa/i18n/zh_CN.csv | 296 ---- .../Magento/User/Block/User/Edit/Tab/Main.php | 10 +- .../User/Controller/Adminhtml/User.php | 4 +- app/code/Magento/User/Model/Role.php | 16 +- app/code/Magento/User/Model/User.php | 2 +- app/code/Magento/User/etc/module.xml | 2 +- .../user_setup/upgrade-1.6.1.3-1.6.1.4.php | 2 +- .../user_setup/upgrade-1.6.1.5-1.6.1.6.php | 36 + .../Order/Packaging/Plugin/DisplayGirth.php | 57 +- .../Tab/General/Shipping/Packaging/Plugin.php | 119 ++ app/code/Magento/Usps/Helper/Data.php | 70 + .../Usps.php => Usps/Model/Carrier.php} | 49 +- .../Magento/Usps/Model/Source/Container.php | 38 + .../Dhl => Usps/Model}/Source/Freemethod.php | 17 +- .../Usps => Usps/Model}/Source/Generic.php | 34 +- .../Usps => Usps/Model}/Source/Machinable.php | 12 +- .../Dhl => Usps/Model}/Source/Method.php | 12 +- app/code/Magento/Usps/Model/Source/Size.php | 38 + app/code/Magento/Usps/etc/adminhtml/di.xml | 46 + .../Magento/Usps/etc/adminhtml/system.xml | 162 ++ app/code/Magento/Usps/etc/config.xml | 57 + app/code/Magento/Usps/etc/module.xml | 36 + .../sql/usps_setup/install-2.0.0.0.php} | 25 +- app/code/Magento/Webapi/Controller/Soap.php | 25 +- .../Model/Plugin/AuthorizationServiceV1.php | 29 +- .../Model/Plugin/IntegrationServiceV1.php | 20 +- .../Magento/Webapi/Model/Plugin/Setup.php | 9 +- app/code/Magento/Webapi/Model/Soap/Fault.php | 22 +- .../Magento/Wishlist/Block/AbstractBlock.php | 2 +- .../Wishlist/Block/Customer/Sidebar.php | 17 +- app/code/Magento/Wishlist/Block/Link.php | 19 +- .../Controller/AbstractController.php | 2 +- app/code/Magento/Wishlist/Model/Item.php | 29 +- .../Magento/Wishlist/Model/Item/Option.php | 11 +- .../Model/Resource/Item/Collection.php | 10 +- .../Model/Resource/Item/Collection/Grid.php | 4 +- app/code/Magento/Wishlist/Model/Wishlist.php | 23 +- app/code/Magento/Wishlist/etc/frontend/di.xml | 10 - .../frontend/layout/catalog_category_view.xml | 36 + .../frontend/layout/catalog_product_view.xml | 36 + .../Wishlist/view/frontend/layout/default.xml | 2 +- .../Magento_Customer/layout/default.xml | 4 +- app/etc/di.xml | 62 +- dev/shell/install.php | 55 +- .../Magento/TestFramework/Application.php | 3 +- .../TestFramework/Interception/PluginList.php | 15 +- .../Magento/TestFramework/ObjectManager.php | 28 +- .../TestFramework/ObjectManager/Config.php | 2 +- .../TestFramework/ObjectManagerFactory.php | 35 +- .../testsuite/Magento/Test/CookieTest.php | 3 +- .../testsuite/Magento/Test/ResponseTest.php | 3 +- .../Test/TestCase/ControllerAbstractTest.php | 5 +- .../Magento/Backend/Block/Widget/GridTest.php | 4 +- .../Magento/Backend/Model/AuthTest.php | 1 + .../ResolverTest.php} | 18 +- .../Backend/Model/_files/config_section.php | 86 +- .../Controller/Adminhtml/CategoryTest.php | 1 + .../Adminhtml/Product/AttributeTest.php | 26 +- .../Controller/Product/CompareTest.php | 6 +- .../Magento/Catalog/Model/CategoryTest.php | 1 + .../Indexer/Product/Flat/Action/RowTest.php | 4 +- .../Indexer/Product/Flat/ProcessorTest.php | 4 + .../Magento/Catalog/Model/ProductTest.php | 2 +- .../Magento/Catalog/Model/UrlTest.php | 5 - .../CatalogSearch/Controller/ResultTest.php | 3 + .../Magento/CatalogSearch/_files/query.php | 3 - .../Magento/Centinel/Helper/DataTest.php | 2 +- .../testsuite/Magento/Code/GeneratorTest.php | 155 +- .../ParentClassWithoutNamespace.php | 106 -- .../SourceClassWithNamespaceInterceptor.php | 218 --- .../SourceClassWithoutNamespace.php | 133 -- ...SourceClassWithoutNamespaceInterceptor.php | 219 --- .../SourceClassWithoutNamespaceProxy.php | 167 -- ...ceInterfaceWithoutNamespaceInterceptor.php | 182 -- .../SourceClassWithNamespaceFactory.php | 6 +- .../SourceClassWithNamespaceInterceptor.php | 189 ++ .../SourceClassWithNamespaceProxy.php | 36 +- .../Magento/Core/Helper/DataTest.php | 7 - .../Magento/Core/Model/App/AreaTest.php | 6 + .../testsuite/Magento/Core/Model/AppTest.php | 13 - .../Magento/Core/Model/DesignTest.php | 14 +- .../Magento/Core/Model/LayoutTest.php | 4 +- .../Magento/Core/Model/StoreTest.php | 2 +- .../Core/Model/Theme/Source/ThemeTest.php | 2 +- .../Core/_files/db_translate_admin_store.php | 2 +- .../Core/_files/second_third_store.php | 66 + .../Block/Account/Dashboard/AddressTest.php | 32 +- .../Block/Account/Dashboard/HelloTest.php | 88 + .../Account/Dashboard/NewsletterTest.php | 70 + .../Customer/Block/Account/DashboardTest.php | 127 ++ .../Customer/Block/Address/EditTest.php | 27 +- .../Address/Renderer/DefaultRendererTest.php | 6 +- .../Edit/Renderer/Attribute/GroupTest.php | 84 + .../Block/Adminhtml/Edit/Tab/AccountTest.php | 181 ++ .../Adminhtml/Edit/Tab/AddressesTest.php | 176 ++ .../Block/Adminhtml/Edit/Tab/CartTest.php | 125 ++ .../Block/Adminhtml/Edit/Tab/CartsTest.php | 96 ++ .../Adminhtml/Edit/Tab/NewsletterTest.php | 91 + .../Block/Adminhtml/Edit/Tab/OrdersTest.php | 103 ++ .../Adminhtml/Edit/Tab/View/AccordionTest.php | 80 +- .../Adminhtml/Edit/Tab/View/CartTest.php | 137 ++ .../Adminhtml/Edit/Tab/View/OrdersTest.php | 130 ++ .../Adminhtml/Edit/Tab/View/SalesTest.php | 148 ++ .../Block/Adminhtml/Edit/Tab/ViewTest.php | 99 +- .../Block/Adminhtml/Edit/TabsTest.php | 149 ++ .../Customer/Block/Adminhtml/EditTest.php | 160 ++ .../Customer/Block/Adminhtml/GridTest.php | 7 +- .../Block/Adminhtml/Group/Edit/FormTest.php | 36 +- .../Block/Adminhtml/Group/EditTest.php | 38 +- .../Customer/Block/Widget/GenderTest.php | 30 +- .../Customer/Block/Widget/NameTest.php | 91 + .../Customer/Block/Widget/TaxvatTest.php | 62 + .../Customer/Controller/AccountTest.php | 211 ++- .../Customer/Controller/AddressTest.php | 7 +- .../Cart/Product/Composite/CartTest.php | 119 ++ .../Controller/Adminhtml/GroupTest.php | 54 +- .../Controller/Adminhtml/IndexTest.php | 760 ++++++++- .../Customer/Model/Config/ShareTest.php | 65 + .../Model/Metadata/FormFactoryTest.php | 1 - .../Customer/Model/Metadata/FormTest.php | 26 +- .../Magento/Customer/Model/SessionTest.php | 10 - .../Service/V1/CustomerAccountServiceTest.php | 157 +- .../V1/CustomerMetadataServiceTest.php | 9 - .../_files/attribute_user_fullname.php | 40 + .../_files/customer_primary_addresses.php | 20 +- .../Magento/Customer/_files/quote.php | 67 + .../Magento/Customer/_files/sales_order.php | 38 + .../Block/Adminhtml}/UnitofmeasureTest.php | 6 +- .../Magento/Gdata/Gshopping/ContentTest.php | 4 +- .../Block/Adminhtml/Export/FilterTest.php | 4 +- .../Model/Export/Entity/AbstractEavTest.php | 2 +- .../Entity/Eav/Customer/AddressTest.php | 2 +- .../Interception/Fixture/Intercepted.php | 73 + .../Fixture/Intercepted/InterfacePlugin.php | 67 + .../Fixture/Intercepted/Plugin.php | 67 + .../Fixture/InterceptedInterface.php | 34 + .../Fixture/InterceptedParent.php | 40 + .../Fixture/InterceptedParentInterface.php | 32 + .../Magento/Interception/GeneralTest.php | 168 ++ .../ResolverTest.php} | 9 +- .../Multishipping/Controller/CheckoutTest.php | 9 +- .../Magento/Payment/Block/InfoTest.php | 9 +- .../Magento/Payment/Helper/DataTest.php | 2 +- .../Payment/Model/Config/ReaderTest.php | 6 +- .../Magento/Payment/Model/ConfigTest.php | 2 +- .../Magento/Payment/Model/_files/payment.xml | 4 +- .../Magento/Payment/Model/_files/payment2.xml | 4 +- .../Magento/Paypal/Model/VoidTest.php | 4 +- .../Driver/Standard/Output/FirebugTest.php | 7 +- .../Catalog/Product/View/ProfileTest.php | 8 +- .../_files/recurring_profile.php | 26 +- .../Magento/Rss/Controller/IndexTest.php | 8 +- .../Order/Create/Form/AbstractTest.php | 2 +- .../Block/Adminhtml/Order/Create/FormTest.php | 8 +- .../Quote/Address/CollectTotalsTest.php | 4 +- .../Model/Resource/Sale/CollectionTest.php | 4 +- .../Magento/Sales/Model/Service/QuoteTest.php | 19 +- .../Integrity/Magento/Payment/MethodsTest.php | 2 +- .../Magento/Widget/TemplateFilesTest.php | 8 +- ...lesTest.php => CarrierConfigFilesTest.php} | 8 +- .../Magento/Theme/Block/HtmlTest.php | 2 - .../testsuite/Magento/TranslateTest.php | 2 +- .../UpsTest.php => Ups/Model/CarrierTest.php} | 20 +- .../testsuite/Magento/User/Model/UserTest.php | 30 + .../View/Element/AbstractBlockTest.php | 4 +- .../Magento/View/PublicationTest.php | 52 +- .../view/adminhtml/product/product.css | 897 ++++++++++ .../images/gallery-image-base-label.png | Bin 0 -> 1892 bytes .../view/adminhtml/images/allinone.png | Bin 0 -> 7141 bytes .../ModuleC/view/adminhtml/images/logo.png | Bin 0 -> 1869 bytes .../Magento/ModuleC/view/adminhtml/styles.css | 31 + .../Magento/Wishlist/Controller/IndexTest.php | 5 +- .../TestFramework/Helper/Categories.php | 2 +- .../Magento/TestFramework/Utility/Classes.php | 11 + .../Magento/TestFramework/Utility/Files.php | 17 + .../Test/Integrity/Di/CompilerTest.php | 79 +- .../Test/Integrity/Phrase/ArgumentsTest.php | 18 + .../Integrity/_files/blacklist/namespace.txt | 3 + .../Integrity/_files/blacklist/reference.txt | 1 + .../Magento/Test/Js/_files/whitelist/core.txt | 1 + .../Test/Legacy/_files/obsolete_classes.php | 79 +- .../Legacy/_files/obsolete_config_nodes.php | 6 +- .../Test/Legacy/_files/obsolete_constants.php | 42 +- .../Test/Legacy/_files/obsolete_methods.php | 57 +- .../Legacy/_files/obsolete_properties.php | 6 +- .../Test/Php/_files/blacklist/common.txt | 3 +- .../Php/_files/phpcpd/blacklist/common.txt | 7 +- .../Test/Php/_files/whitelist/common.txt | 7 +- .../Magento/Test/Block/Adminhtml.php | 5 - .../Helper/ObjectManagerTest.php | 3 +- .../Magento/App/Action/ForwardTest.php | 6 +- .../Plugin/ClickjackingTest.php | 28 +- .../Magento/App/FrontControllerTest.php | 4 +- .../Magento/App/PageCache/IdentifierTest.php | 45 +- .../Magento/App/PageCache/KernelTest.php | 206 +++ .../Magento/App/PageCache/PageCacheTest.php | 30 +- .../Model => App/PageCache}/VersionTest.php | 30 +- .../Magento/App/Resource/ConfigTest.php | 2 +- .../Magento/App/Response/HttpTest.php | 99 +- .../App/Route/Config/_files/routes.php | 16 +- .../App/Route/Config/_files/routes.xml | 16 +- .../App/Action/Plugin/MassactionKeyTest.php | 40 +- .../Grid/Column/Renderer/CurrencyTest.php | 6 +- .../Adminhtml/System/AccountTest.php | 6 +- .../Magento/Backend/Helper/DataTest.php | 5 +- .../Backend/Model/Locale/ManagerTest.php | 2 +- .../Magento/Backend/Model/TranslateTest.php | 8 +- .../Helper/Plugin/BundleTest.php | 13 +- .../Bundle/Model/Plugin/QuoteItemTest.php | 51 +- .../CacheInvalidate/Model/ObserverTest.php | 131 ++ .../Catalog/Block/Category/ViewTest.php | 58 + .../Magento/Catalog/Block/NavigationTest.php | 56 + .../Block/Product/Compare/SidebarTest.php | 72 + .../Catalog/Block/Product/ListProductTest.php | 95 ++ .../Catalog/Block/Product/NewProductTest.php | 52 + .../Catalog/Block/Product/PriceTest.php | 58 + .../Block/Product/ProductList/RelatedTest.php | 65 + .../Block/Product/ProductList/UpsellTest.php | 65 + .../Catalog/Block/Product/ViewTest.php | 17 + .../Helper/HandlerFactoryTest.php | 4 +- .../Flat/Plugin/IndexerConfigDataTest.php | 44 +- .../Category/Flat/Plugin/StoreGroupTest.php | 114 +- .../Category/Flat/Plugin/StoreViewTest.php | 61 +- .../Product/Plugin/StoreGroupTest.php | 40 +- .../Category/Product/Plugin/StoreViewTest.php | 39 +- .../Product/Flat/Plugin/ImportTest.php | 3 +- .../Flat/Plugin/IndexerConfigDataTest.php | 60 +- .../Product/Flat/Plugin/StoreGroupTest.php | 36 +- .../Indexer/Product/Flat/Plugin/StoreTest.php | 36 +- .../Magento/Catalog/Model/Plugin/LogTest.php | 23 +- .../Plugin/QuoteItemProductOptionTest.php | 54 +- .../Model/Product/Compare/ItemTest.php | 54 + .../Product/CopyConstructorFactoryTest.php | 8 +- .../Magento/Catalog/Model/ProductTest.php | 1 - .../Catalog/Model/Resource/AbstractTest.php | 2 +- .../Model/Resource/Eav/AttributeTest.php | 3 +- .../Block/QtyincrementsTest.php | 71 + .../Block/Stockqty/DefaultStockqtyTest.php | 71 + .../Model/Adminhtml/Stock/ItemTest.php | 20 +- .../Checkout/Block/Cart/Item/RendererTest.php | 13 +- .../Checkout/Block/Cart/SidebarTest.php | 20 + .../Magento/Checkout/Helper/DataTest.php | 6 +- .../Checkout/Helper/ExpressRedirectTest.php | 173 ++ .../Magento/Checkout/Model/SessionTest.php | 101 ++ .../testsuite/Magento/Cms/Block/BlockTest.php | 54 + .../testsuite/Magento/Cms/Block/PageTest.php | 54 + .../testsuite/Magento/Code/GeneratorTest.php | 67 +- .../GeneratorTest/SimpleClassPluginB.php | 40 - .../Code/Plugin/InvocationChainTest.php | 50 - .../Edit/Tab/Super/Config/MatrixTest.php | 18 +- .../Cart/Item/Renderer/ConfigurableTest.php | 18 + .../Adminhtml/Product/Builder/PluginTest.php | 33 +- .../Helper/Plugin/ConfigurableTest.php | 13 +- .../Product/Configuration/PluginTest.php | 26 +- .../Admin/Item/Plugin/ConfigurableTest.php | 36 +- .../Plugin/ConfigurableTest.php | 28 +- .../Plugin/ConfigurableTest.php | 20 +- .../Model/Product/Validator/PluginTest.php | 39 +- .../Core/App/Action/Plugin/DesignTest.php | 11 +- .../Core/App/Action/Plugin/InstallTest.php | 36 +- .../Core/App/Action/Plugin/LastUrlTest.php | 11 +- .../Core/App/Action/Plugin/StoreCheckTest.php | 32 +- .../Plugin/DispatchExceptionHandlerTest.php | 21 +- .../FrontController/Plugin/InstallTest.php | 26 +- .../Plugin/RequestPreprocessorTest.php | 34 +- .../Core/Controller/Response/HttpTest.php | 8 +- .../File/Storage/Directory/DatabaseTest.php | 4 +- .../Core/Model/File/Storage/MediaTest.php | 2 +- .../Magento/Core/Model/LocaleTest.php | 135 -- .../TemplateEngine/Plugin/DebugHintsTest.php | 12 +- .../Plugin/ApplicationInitializerTest.php | 28 +- .../PreProcessor/Cache/Plugin/LessTest.php | 121 +- .../Customer/Block/Account/CustomerTest.php | 42 +- .../Block/Account/Dashboard/InfoTest.php | 78 +- .../Magento/Customer/Block/Widget/DobTest.php | 28 +- .../Customer/Block/Widget/GenderTest.php | 85 +- .../Customer/Block/Widget/NameTest.php | 6 +- .../Customer/Block/Widget/TaxvatTest.php | 39 +- .../Controller/Adminhtml/IndexTest.php | 230 ++- .../Magento/Customer/Model/CustomerTest.php | 28 +- .../Model/Layout/DepersonalizePluginTest.php | 266 +++ .../Model/Metadata/Form/AbstractDataTest.php | 13 +- .../Metadata/Form/AbstractFormTestCase.php | 8 +- .../Model/Metadata/Form/BooleanTest.php | 9 +- .../Customer/Model/Metadata/Form/DateTest.php | 18 +- .../Customer/Model/Metadata/Form/FileTest.php | 1 + .../Model/Metadata/Form/HiddenTest.php | 1 + .../Model/Metadata/Form/ImageTest.php | 1 + .../Model/Metadata/Form/MultilineTest.php | 1 + .../Model/Metadata/Form/MultiselectTest.php | 1 + .../Model/Metadata/Form/SelectTest.php | 1 + .../Customer/Model/Metadata/Form/TextTest.php | 1 + .../Model/Metadata/Form/TextareaTest.php | 1 + .../Customer/Model/Metadata/ValidatorTest.php | 17 +- .../Service/V1/CustomerAccountServiceTest.php | 300 ++-- .../V1/CustomerAddressCurrentServiceTest.php | 115 ++ .../Service/V1/CustomerCurrentServiceTest.php | 166 ++ .../Service/V1/CustomerServiceTest.php | 40 + .../Customer/Service/V1/Dto/AddressTest.php | 3 + .../Model/Plugin/ThemeCopyServiceTest.php | 27 +- .../Model/CarrierTest.php} | 44 +- .../Dhl => Dhl/Model}/_files/countries.xml | 0 .../Model}/_files/rates_request_data_dhl.php | 0 .../Model}/_files/response_shipping_label.xml | 0 .../_files/success_dhl_response_rates.xml} | 0 .../Model/Resource/Country/CollectionTest.php | 6 +- .../Helper/Plugin/DownloadableTest.php | 12 +- .../Plugin/DownloadableTest.php | 21 +- .../Eav/Model/Attribute/Data/TextTest.php | 7 +- .../Magento/Eav/Model/Entity/AbstractTest.php | 4 +- .../Magento/Eav/Model/Entity/TypeTest.php | 121 ++ .../Magento/Encryption/EncryptorTest.php | 175 +- .../Model/Plugin/QuoteItemTest.php | 66 +- .../Model/Config/Source/LanguageTest.php | 4 +- .../Block/Code/CategoryTest.php | 70 + .../Block/Code/ProductTest.php | 70 + .../Adminhtml/Order/Create/SidebarTest.php | 43 +- .../Block/Cart/Item/Renderer/GroupedTest.php | 18 + .../Block/Stockqty/Type/GroupedTest.php | 84 + .../ProductLinks/Plugin/GroupedTest.php | 21 +- .../Configuration/Plugin/GroupedTest.php | 43 +- .../Cart/Configuration/Plugin/GroupedTest.php | 27 +- .../Model/Product/Type/PluginTest.php | 12 +- .../Magento/Http/AuthenticationTest.php | 6 +- .../Entity/Eav/Customer/AddressTest.php | 4 +- .../Model/Export/Entity/Eav/CustomerTest.php | 6 +- .../Import/Entity/CustomerCompositeTest.php | 4 +- .../Install/App/Action/Plugin/DirTest.php | 16 +- .../Magento/Install/App/ConsoleTest.php | 30 +- .../Magento/Integration/Oauth/OauthTest.php | 4 +- .../Interception/Config/ConfigTest.php | 24 +- .../Model/ItemContainerPlugin/Simple.php | 7 +- .../Module/Model/ItemPlugin/Advanced.php | 20 +- .../Custom/Module/Model/ItemPlugin/Simple.php | 7 +- .../Interception/FactoryDecoratorTest.php | 77 - .../Interception/ObjectManager/ConfigTest.php | 79 + .../PluginList/PluginListTest.php | 93 +- .../Locale/Hierarchy/Config/ConverterTest.php | 6 +- .../Hierarchy/Config/FileResolverTest.php | 8 +- .../Config/_files/custom/hierarchy_config.xml | 0 .../_files/default/hierarchy_config.xml | 0 .../Magento/Locale/Hierarchy/ConfigTest.php | 2 +- .../{Core/Model => }/Locale/ValidatorTest.php | 10 +- .../unit/testsuite/Magento/Log/LoggerTest.php | 10 +- .../testsuite/Magento/Math/RandomTest.php | 5 - .../Declaration/Reader/FilesystemTest.php | 13 +- .../Magento/Module/DependencyManagerTest.php | 157 ++ .../ObjectManager/Config/ConfigTest.php | 37 +- .../ObjectManager/ObjectManagerTest.php | 8 + .../Model}/BanktransferTest.php | 6 +- .../Model}/CashondeliveryTest.php | 6 +- .../Adminhtml}/Form/Field/ExportTest.php | 12 +- .../Adminhtml}/Form/Field/ImportTest.php | 6 +- .../Model/SalesRule/CalculatorTest.php | 64 + .../testsuite/Magento/Ogone/Model/ApiTest.php | 6 +- .../PageCache/Controller/BlockTest.php | 79 +- .../Magento/PageCache/Helper/DataTest.php | 71 + .../App/FrontController/CachePluginTest.php | 134 ++ .../App/FrontController/HeaderPluginTest.php | 177 -- .../Model/Layout/LayoutPluginTest.php | 151 ++ .../Magento/PageCache/Model/ObserverTest.php | 210 +++ .../Block/Info/ContainerAbstractTest.php | 2 +- .../Payment/Model/Config/ConverterTest.php | 2 +- .../Payment/Model/Config/_files/payment.xml | 4 +- .../Payment/Model/Method/FactoryTest.php | 2 +- .../Magento/Paypal/Block/Express/FormTest.php | 6 + .../Paypal/Block/PayflowExpress/FormTest.php | 6 + .../Magento/Paypal/Helper/CheckoutTest.php | 79 - .../Magento/Paypal/Helper/DataTest.php | 37 - .../Magento/Persistent/Model/ObserverTest.php | 178 ++ .../Block/Plugin/PaymentTest.php | 10 +- .../Block/Profile/GridTest.php | 4 +- .../Block/Profile/Related/Orders/GridTest.php | 4 +- .../Reports/Block/Product/ViewedTest.php | 63 + .../Magento/Reports/Model/Plugin/LogTest.php | 41 +- .../Model/Resource/Report/CollectionTest.php | 4 +- .../Sales/Block/Reorder/SidebarTest.php | 73 + .../Sales/Model/Order/Pdf/AbstractTest.php | 2 +- .../Sales/Model/Order/Pdf/InvoiceTest.php | 7 +- .../Magento/SalesRule/Model/ValidatorTest.php | 14 +- .../Block/Adminhtml/Order/TrackingTest.php | 2 +- .../Magento/Shipping/Helper/CarrierTest.php | 91 + .../Shipping/Model/Order/TrackTest.php | 4 +- .../Model/Simplexml/ElementTest.php | 5 +- .../DateTime}/Filter/DateTest.php | 6 +- .../DateTime}/Filter/DateTimeTest.php | 6 +- .../testsuite/Magento/Stdlib/DateTimeTest.php | 4 +- .../code/Magento/SomeModule/Helper/Test.php | 2 +- .../Magento/Theme/Block/Html/FooterTest.php | 52 + .../Magento/Ups/Helper/ConfigTest.php | 72 + .../Dhl/_files/rates_request_data_dhlintl.php | 67 - .../Usa/Model/Shipping/Carrier/DhlTest.php | 179 -- .../_files/success_dhl_response_rates.xml | 71 - .../Magento/{Usa => Usps}/Helper/DataTest.php | 15 +- .../Model/CarrierTest.php} | 20 +- .../Model}/Source/GenericTest.php | 18 +- .../Model}/_files/rates_request_data.php | 2 +- .../_files/return_shipment_request_data.php | 0 .../_files/success_usps_response_rates.xml | 2 +- .../success_usps_response_return_shipment.xml | 2 +- .../Magento/Webapi/Controller/SoapTest.php | 25 +- .../Model/Plugin/IntegrationServiceV1Test.php | 30 +- .../Magento/Webapi/Model/Plugin/SetupTest.php | 61 +- .../Magento/Webapi/Model/Soap/FaultTest.php | 21 +- .../Wishlist/Block/Customer/SidebarTest.php | 74 + .../Magento/Wishlist/Controller/IndexTest.php | 4 +- .../Magento/Tools/Dependency/Circular.php | 4 + .../Magento/Tools/Di/Compiler/Directory.php | 9 +- dev/tools/Magento/Tools/Di/compiler.php | 16 +- .../Tools/Migration/factory_table_names.php | 2 +- .../Tools/Migration/get_aliases_map.php | 2 +- .../Magento/Tools/Migration/themes_view.php | 16 +- .../lib/Magento/Connect/Frontend/CLI.php | 2 +- index.php | 1 - lib/Cm/Cache/Backend/File.php | 719 ++++++++ lib/Cm/Cache/Backend/Redis.php | 912 ++++++++++ lib/Magento/App/ActionInterface.php | 7 + lib/Magento/App/Cache/Frontend/Factory.php | 13 +- lib/Magento/App/Cache/Proxy.php | 2 - lib/Magento/App/Cache/Type/AccessProxy.php | 2 - lib/Magento/App/Cache/Type/Block.php | 2 - lib/Magento/App/Cache/Type/Collection.php | 2 - lib/Magento/App/Cache/Type/Config.php | 2 - lib/Magento/App/Cache/Type/Layout.php | 2 - lib/Magento/App/Cache/Type/Translate.php | 2 - lib/Magento/App/EntryPoint/EntryPoint.php | 6 +- lib/Magento/App/FrontController.php | 3 +- .../FrontController/Plugin/Clickjacking.php | 5 +- lib/Magento/App/Helper/AbstractHelper.php | 8 - lib/Magento/App/Helper/Context.php | 16 - .../Magento/App/Http/Context.php | 42 +- lib/Magento/App/ObjectManagerFactory.php | 28 +- lib/Magento/App/PageCache/Cache.php | 35 + lib/Magento/App/PageCache/Identifier.php | 54 + lib/Magento/App/PageCache/Kernel.php | 97 ++ .../Magento/App/PageCache}/Version.php | 38 +- lib/Magento/App/Request/Http.php | 8 + lib/Magento/App/Response/Http.php | 91 +- lib/Magento/App/View.php | 10 + lib/Magento/App/ViewInterface.php | 6 + lib/Magento/AppInterface.php | 14 - .../Cache/Frontend/Decorator/Profiler.php | 2 - lib/Magento/Code/Generator.php | 88 +- lib/Magento/Code/Generator/Interceptor.php | 336 ---- lib/Magento/Code/Plugin/InvocationChain.php | 84 - lib/Magento/Connect/Frontend/CLI.php | 14 +- .../Cache/Plugin/ImportCleaner.php | 9 +- .../Cache/Plugin/InstructionPreProcessor.php | 10 +- .../Css/PreProcessor/Cache/Plugin/Less.php | 29 +- .../CodeGenerator.php => Currency.php} | 17 +- .../Magento/CurrencyFactory.php | 21 +- lib/Magento/CurrencyInterface.php | 268 +++ lib/Magento/DB/Adapter/AdapterInterface.php | 2 +- lib/Magento/DB/Adapter/Pdo/Mysql.php | 6 +- lib/Magento/Data/Form/Element/Date.php | 22 +- lib/Magento/Data/Form/Filter/Date.php | 2 +- lib/Magento/Encryption/Encryptor.php | 26 +- lib/Magento/Encryption/EncryptorInterface.php | 9 +- lib/Magento/Error/Handler.php | 8 +- lib/Magento/HTTP/Adapter/Curl.php | 8 +- lib/Magento/Image/AdapterFactory.php | 2 - lib/Magento/Interception/Chain.php | 38 + lib/Magento/Interception/Chain/Chain.php | 91 + .../Code/Generator/Interceptor.php | 302 ++++ .../Interception/Code/InterfaceValidator.php | 234 +++ .../Interception/Code/ValidatorException.php | 8 +- .../CodeGenerator/CodeGenerator.php | 53 - lib/Magento/Interception/Config.php | 12 - lib/Magento/Interception/Config/Config.php | 44 +- lib/Magento/Interception/Definition.php | 4 + .../Interception/Definition/Runtime.php | 35 +- lib/Magento/Interception/FactoryDecorator.php | 102 -- .../Interception/ObjectManager/Config.php | 70 + lib/Magento/Interception/PluginList.php | 15 +- .../Interception/PluginList/PluginList.php | 161 +- .../SimpleClass.php => lib/Magento/Locale.php | 16 +- .../Model => lib/Magento}/Locale/Config.php | 18 +- .../Magento/Locale/ConfigInterface.php | 21 +- lib/Magento/Locale/Currency.php | 114 ++ lib/Magento/Locale/CurrencyInterface.php | 53 + lib/Magento/Locale/Format.php | 147 ++ lib/Magento/Locale/FormatInterface.php | 56 + .../Locale/Hierarchy/Config/Converter.php | 2 +- .../Locale/Hierarchy/Config/FileResolver.php | 2 +- .../Locale/Hierarchy/Config/Reader.php | 8 +- .../Locale/Hierarchy/Config/SchemaLocator.php | 2 +- lib/Magento/Locale/Lists.php | 291 ++++ lib/Magento/Locale/ListsInterface.php | 99 ++ lib/Magento/Locale/Resolver.php | 207 +++ lib/Magento/Locale/ResolverInterface.php | 100 ++ .../Magento/Locale/ScopeConfigInterface.php | 26 +- .../Magento}/Locale/Validator.php | 8 +- lib/Magento/LocaleFactory.php | 61 + lib/Magento/LocaleInterface.php | 337 ++++ lib/Magento/Math/Random.php | 28 +- .../Module/Declaration/Reader/Filesystem.php | 135 +- lib/Magento/Module/DependencyManager.php | 141 ++ .../Module/DependencyManagerInterface.php | 51 + .../Module/FrontController/Plugin/Install.php | 19 +- lib/Magento/Mview/View/StateInterface.php | 2 +- .../Magento/Object/IdentityInterface.php | 19 +- lib/Magento/ObjectManager.php | 9 - .../Code/Generator/Factory.php | 3 +- .../Code/Generator/Proxy.php | 6 +- lib/Magento/ObjectManager/Config/Config.php | 22 +- .../ObjectManager/DefinitionFactory.php | 8 +- lib/Magento/ObjectManager/ObjectManager.php | 11 - .../Service/Entity/AbstractDtoBuilder.php | 4 +- lib/Magento/Stdlib/Cookie.php | 2 - lib/Magento/Stdlib/DateTime.php | 6 +- lib/Magento/Stdlib/DateTime/Date.php | 47 + lib/Magento/Stdlib/DateTime/DateFactory.php | 61 + lib/Magento/Stdlib/DateTime/DateInterface.php | 1304 ++++++++++++++ .../Magento/Stdlib/DateTime/DateTime.php | 20 +- .../Magento/Stdlib/DateTime}/Filter/Date.php | 33 +- .../Stdlib/DateTime/Filter/DateTime.php | 34 +- lib/Magento/Stdlib/DateTime/Timezone.php | 305 ++++ .../Stdlib/DateTime/TimezoneInterface.php | 169 ++ lib/Magento/Translate.php | 46 +- .../Translate/Locale/Resolver/Plugin.php | 75 + lib/Magento/TranslateInterface.php | 9 + lib/Magento/Url.php | 2 - {app/code => lib}/Magento/Url/Validator.php | 0 lib/Magento/Validator/Object.php | 2 - lib/Magento/View/Block/IdentityInterface.php | 38 + lib/Magento/View/Element/AbstractBlock.php | 32 +- lib/Magento/View/Element/Context.php | 60 +- lib/Magento/View/Element/Html/Calendar.php | 24 +- lib/Magento/View/Element/Template/Context.php | 12 +- pub/errors/processor.php | 10 +- pub/lib/mage/validation.js | 4 +- pub/lib/mage/validation/dob-rule.js | 4 +- pub/lib/varien/js.js | 8 +- 1385 files changed, 32592 insertions(+), 19235 deletions(-) rename app/code/Magento/Backend/Model/{Locale.php => Locale/Resolver.php} (58%) create mode 100644 app/code/Magento/CacheInvalidate/Helper/Data.php create mode 100644 app/code/Magento/CacheInvalidate/Model/Observer.php create mode 100644 app/code/Magento/CacheInvalidate/etc/events.xml create mode 100644 app/code/Magento/CacheInvalidate/etc/module.xml create mode 100644 app/code/Magento/Checkout/Controller/Express/RedirectLoginInterface.php create mode 100644 app/code/Magento/Checkout/Helper/ExpressRedirect.php create mode 100644 app/code/Magento/Checkout/view/frontend/layout/catalog_category_view.xml create mode 100644 app/code/Magento/Checkout/view/frontend/layout/catalog_product_view.xml delete mode 100644 app/code/Magento/Core/App/Action/Plugin/Session.php rename dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleClassPluginA.php => app/code/Magento/Core/Block/RequireCookie.php (69%) delete mode 100644 app/code/Magento/Core/Filter/DateTime.php create mode 100644 app/code/Magento/Core/Model/App/Area/DesignExceptions.php delete mode 100644 app/code/Magento/Core/Model/Locale.php delete mode 100644 app/code/Magento/Core/Model/LocaleInterface.php create mode 100644 app/code/Magento/Core/view/frontend/js/require-cookie.js create mode 100644 app/code/Magento/Core/view/frontend/require_cookie.phtml mode change 100644 => 100755 app/code/Magento/Customer/Block/Account/Customer.php create mode 100644 app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/GenericMetadata.php mode change 100644 => 100755 app/code/Magento/Customer/Block/Form/Edit.php mode change 100644 => 100755 app/code/Magento/Customer/Controller/Account.php mode change 100644 => 100755 app/code/Magento/Customer/Controller/Adminhtml/Index.php rename app/code/Magento/Customer/{Service/V1/Dto/Response/CreateCustomerAccountResponseBuilder.php => Controller/RegistryConstants.php} (62%) mode change 100644 => 100755 app/code/Magento/Customer/Helper/Address.php create mode 100644 app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php mode change 100644 => 100755 app/code/Magento/Customer/Model/Session.php mode change 100644 => 100755 app/code/Magento/Customer/Service/V1/CustomerAccountService.php mode change 100644 => 100755 app/code/Magento/Customer/Service/V1/CustomerAccountServiceInterface.php create mode 100644 app/code/Magento/Customer/Service/V1/CustomerAddressCurrentService.php create mode 100644 app/code/Magento/Customer/Service/V1/CustomerAddressCurrentServiceInterface.php mode change 100644 => 100755 app/code/Magento/Customer/Service/V1/CustomerAddressServiceInterface.php create mode 100644 app/code/Magento/Customer/Service/V1/CustomerCurrentService.php rename app/code/Magento/Customer/Service/V1/{Dto/Response/CreateCustomerAccountResponse.php => CustomerCurrentServiceInterface.php} (70%) mode change 100644 => 100755 app/code/Magento/Customer/view/frontend/form/edit.phtml rename app/code/Magento/{Usa/Block/Adminhtml/Dhl => Dhl/Block/Adminhtml}/Unitofmeasure.php (77%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Dhl => Dhl/Model}/AbstractDhl.php (85%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Dhl/International.php => Dhl/Model/Carrier.php} (97%) create mode 100644 app/code/Magento/Dhl/Model/Plugin/Checkout/Block/Cart/Shipping.php create mode 100644 app/code/Magento/Dhl/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php rename app/code/Magento/{Usa => Dhl}/Model/Resource/Setup.php (77%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Dhl/International => Dhl/Model}/Source/Contenttype.php (75%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Dhl/International => Dhl/Model}/Source/Method/AbstractMethod.php (79%) create mode 100644 app/code/Magento/Dhl/Model/Source/Method/Doc.php rename app/code/Magento/{Usa/Model/Shipping/Carrier/Dhl/International => Dhl/Model}/Source/Method/Freedoc.php (73%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Dhl/International => Dhl/Model}/Source/Method/Freenondoc.php (73%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Dhl/Source => Dhl/Model/Source/Method}/Generic.php (81%) create mode 100644 app/code/Magento/Dhl/Model/Source/Method/Nondoc.php rename app/code/Magento/{Usa/Model/Shipping/Carrier/Usps/Source => Dhl/Model/Source/Method}/Size.php (84%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Usps/Source/Method.php => Dhl/Model/Source/Method/Unitofmeasure.php} (81%) create mode 100644 app/code/Magento/Dhl/etc/adminhtml/system.xml create mode 100644 app/code/Magento/Dhl/etc/config.xml rename app/code/Magento/{Usa/etc/dhl/international => Dhl/etc}/countries.xml (99%) create mode 100644 app/code/Magento/Dhl/etc/di.xml rename app/code/Magento/{Usa => Dhl}/etc/module.xml (84%) mode change 100755 => 100644 rename app/code/Magento/{Usa/sql/usa_setup/upgrade-1.6.0.2-1.6.0.3.php => Dhl/sql/dhl_setup/install-2.0.0.0.php} (88%) rename app/code/Magento/{Usa/view/adminhtml/dhl => Dhl/view/adminhtml}/logo.jpg (100%) rename app/code/Magento/{Usa/view/adminhtml/dhl => Dhl/view/adminhtml}/unitofmeasure.phtml (59%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Fedex.php => Fedex/Model/Carrier.php} (99%) create mode 100644 app/code/Magento/Fedex/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php rename app/code/Magento/{Usa/Model/Shipping/Carrier/Fedex => Fedex/Model}/Source/Dropoff.php (85%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Fedex => Fedex/Model}/Source/Freemethod.php (87%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Fedex => Fedex/Model}/Source/Generic.php (85%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Fedex => Fedex/Model}/Source/Method.php (85%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Fedex => Fedex/Model}/Source/Packaging.php (85%) create mode 100644 app/code/Magento/Fedex/etc/adminhtml/system.xml create mode 100644 app/code/Magento/Fedex/etc/config.xml create mode 100644 app/code/Magento/Fedex/etc/di.xml create mode 100644 app/code/Magento/Fedex/etc/module.xml rename app/code/Magento/{Usa/etc/wsdl/FedEx => Fedex/etc/wsdl}/RateService_v10.wsdl (100%) rename app/code/Magento/{Usa/etc/wsdl/FedEx => Fedex/etc/wsdl}/RateService_v9.wsdl (100%) rename app/code/Magento/{Usa/etc/wsdl/FedEx => Fedex/etc/wsdl}/ShipService_v10.wsdl (100%) rename app/code/Magento/{Usa/etc/wsdl/FedEx => Fedex/etc/wsdl}/ShipService_v9.wsdl (100%) rename app/code/Magento/{Usa/etc/wsdl/FedEx => Fedex/etc/wsdl}/TrackService_v5.wsdl (100%) rename app/code/Magento/{Usa/sql/usa_setup/upgrade-1.6.0.0-1.6.0.1.php => Fedex/sql/fedex_setup/install-2.0.0.0.php} (98%) rename app/code/Magento/{Payment => OfflinePayments}/Block/Form/Banktransfer.php (94%) rename app/code/Magento/{Payment => OfflinePayments}/Block/Form/Cashondelivery.php (94%) rename app/code/Magento/{Payment => OfflinePayments}/Block/Form/Ccsave.php (86%) rename app/code/Magento/{Payment => OfflinePayments}/Block/Form/Checkmo.php (86%) rename app/code/Magento/{Payment => OfflinePayments}/Block/Form/Purchaseorder.php (86%) rename app/code/Magento/{Payment => OfflinePayments}/Block/Info/Ccsave.php (95%) rename app/code/Magento/{Payment => OfflinePayments}/Block/Info/Checkmo.php (91%) rename app/code/Magento/{Payment => OfflinePayments}/Block/Info/Purchaseorder.php (82%) rename app/code/Magento/{Payment/Model/Method => OfflinePayments/Model}/Banktransfer.php (90%) rename app/code/Magento/{Payment/Model/Method => OfflinePayments/Model}/Cashondelivery.php (90%) rename app/code/Magento/{Payment/Model/Method => OfflinePayments/Model}/Ccsave.php (83%) rename app/code/Magento/{Payment/Model/Method => OfflinePayments/Model}/Checkmo.php (89%) create mode 100644 app/code/Magento/OfflinePayments/Model/Observer.php rename app/code/Magento/{Payment/Model/Method => OfflinePayments/Model}/Purchaseorder.php (85%) create mode 100644 app/code/Magento/OfflinePayments/etc/adminhtml/system.xml create mode 100644 app/code/Magento/OfflinePayments/etc/config.xml create mode 100644 app/code/Magento/OfflinePayments/etc/events.xml create mode 100644 app/code/Magento/OfflinePayments/etc/module.xml create mode 100644 app/code/Magento/OfflinePayments/etc/payment.xml rename app/code/Magento/{Payment => OfflinePayments}/view/adminhtml/form/banktransfer.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/adminhtml/form/cashondelivery.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/adminhtml/form/ccsave.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/adminhtml/form/checkmo.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/adminhtml/form/purchaseorder.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/adminhtml/info/checkmo.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/adminhtml/info/pdf/checkmo.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/adminhtml/info/pdf/purchaseorder.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/adminhtml/info/purchaseorder.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/frontend/form/banktransfer.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/frontend/form/cashondelivery.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/frontend/form/ccsave.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/frontend/form/checkmo.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/frontend/form/purchaseorder.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/frontend/info/checkmo.phtml (100%) rename app/code/Magento/{Payment => OfflinePayments}/view/frontend/info/purchaseorder.phtml (100%) rename app/code/Magento/{Shipping => OfflineShipping}/Block/Adminhtml/Carrier/Tablerate/Grid.php (86%) rename app/code/Magento/{Backend/Block/System/Config => OfflineShipping/Block/Adminhtml}/Form/Field/Export.php (87%) rename app/code/Magento/{Backend/Block/System/Config => OfflineShipping/Block/Adminhtml}/Form/Field/Import.php (93%) create mode 100644 app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config.php rename app/code/Magento/{Shipping => OfflineShipping}/Model/Carrier/Flatrate.php (96%) rename app/code/Magento/{Shipping => OfflineShipping}/Model/Carrier/Freeshipping.php (94%) rename app/code/Magento/{Shipping => OfflineShipping}/Model/Carrier/Pickup.php (97%) rename app/code/Magento/{Shipping => OfflineShipping}/Model/Carrier/Tablerate.php (96%) rename app/code/Magento/{Shipping => OfflineShipping}/Model/Config/Backend/Tablerate.php (86%) rename app/code/Magento/{Shipping => OfflineShipping}/Model/Config/Source/Flatrate.php (92%) rename app/code/Magento/{Shipping => OfflineShipping}/Model/Config/Source/Tablerate.php (76%) create mode 100644 app/code/Magento/OfflineShipping/Model/Observer/SalesRule/ActionsTab.php rename app/code/Magento/{Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Nondoc.php => OfflineShipping/Model/Plugin/Checkout/Block/Cart/Shipping.php} (55%) rename app/code/Magento/{SalesRule => OfflineShipping}/Model/Quote/Freeshipping.php (86%) rename app/code/Magento/{Shipping => OfflineShipping}/Model/Resource/Carrier/Tablerate.php (96%) rename app/code/Magento/{Shipping => OfflineShipping}/Model/Resource/Carrier/Tablerate/Collection.php (87%) create mode 100644 app/code/Magento/OfflineShipping/Model/SalesRule/Calculator.php create mode 100644 app/code/Magento/OfflineShipping/Model/SalesRule/Rule.php create mode 100644 app/code/Magento/OfflineShipping/etc/adminhtml/events.xml rename app/code/Magento/{PageCache/etc/di.xml => OfflineShipping/etc/adminhtml/routes.xml} (84%) create mode 100644 app/code/Magento/OfflineShipping/etc/adminhtml/system.xml create mode 100644 app/code/Magento/OfflineShipping/etc/config.xml rename app/code/Magento/{Usa => OfflineShipping}/etc/di.xml (79%) create mode 100644 app/code/Magento/OfflineShipping/etc/fieldset.xml create mode 100644 app/code/Magento/OfflineShipping/etc/module.xml create mode 100644 app/code/Magento/OfflineShipping/etc/sales.xml rename app/code/Magento/{Shipping/sql/shipping_setup/install-1.6.0.0.php => OfflineShipping/sql/offlineshipping_setup/install-2.0.0.0.php} (65%) create mode 100644 app/code/Magento/PageCache/Model/App/FrontController/CachePlugin.php delete mode 100644 app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php create mode 100644 app/code/Magento/PageCache/Model/Layout/LayoutPlugin.php create mode 100644 app/code/Magento/PageCache/etc/frontend/di.xml create mode 100644 app/code/Magento/Payment/Model/MethodInterface.php create mode 100644 app/code/Magento/Paypal/view/frontend/js/opcheckout.js create mode 100644 app/code/Magento/Paypal/view/frontend/layout/checkout_onepage_index.xml create mode 100644 app/code/Magento/Paypal/view/frontend/onepage.phtml mode change 100755 => 100644 app/code/Magento/Persistent/etc/module.xml create mode 100644 app/code/Magento/Review/view/frontend/layout/catalog_product_view.xml rename app/code/Magento/{Usa/Helper/Data.php => Shipping/Helper/Carrier.php} (59%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/AbstractCarrier.php => Shipping/Model/Carrier/AbstractCarrierOnline.php} (97%) create mode 100644 app/code/Magento/Shipping/Model/Carrier/Source/GenericInterface.php rename app/code/Magento/{Usa/Model/Shipping/Carrier/AbstractCarrier/Source => Shipping/Model/Config/Source/Online}/Mode.php (82%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/AbstractCarrier/Source => Shipping/Model/Config/Source/Online}/Requesttype.php (81%) rename app/code/Magento/{Usa => Shipping}/Model/Simplexml/Element.php (92%) rename app/code/Magento/{Backend/Block/System/Shipping/Ups.php => Ups/Block/Backend/System/CarrierConfig.php} (71%) create mode 100644 app/code/Magento/Ups/Helper/Config.php rename app/code/Magento/{Usa/Model/Shipping/Carrier/Ups.php => Ups/Model/Carrier.php} (80%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Ups => Ups/Model/Config}/Source/Container.php (84%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Ups => Ups/Model/Config}/Source/DestType.php (84%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Ups => Ups/Model/Config}/Source/Freemethod.php (85%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Ups => Ups/Model/Config}/Source/Generic.php (73%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Ups => Ups/Model/Config}/Source/Method.php (84%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Ups => Ups/Model/Config}/Source/OriginShipment.php (78%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Ups => Ups/Model/Config}/Source/Pickup.php (83%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Ups => Ups/Model/Config}/Source/Type.php (76%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Ups => Ups/Model/Config}/Source/Unitofmeasure.php (83%) create mode 100644 app/code/Magento/Ups/etc/adminhtml/system.xml create mode 100644 app/code/Magento/Ups/etc/config.xml create mode 100644 app/code/Magento/Ups/etc/module.xml create mode 100644 app/code/Magento/Ups/view/adminhtml/layout/adminhtml_system_config_edit.xml rename app/code/Magento/{Backend/view/adminhtml/system/shipping/ups.phtml => Ups/view/adminhtml/system/shipping/carrier_config.phtml} (95%) delete mode 100644 app/code/Magento/Usa/Model/Shipping/Carrier/Dhl.php delete mode 100644 app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Doc.php delete mode 100644 app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Generic.php delete mode 100644 app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Size.php delete mode 100644 app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Unitofmeasure.php delete mode 100644 app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Value.php delete mode 100644 app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Container.php delete mode 100644 app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Freemethod.php delete mode 100644 app/code/Magento/Usa/etc/adminhtml/system.xml delete mode 100644 app/code/Magento/Usa/etc/config.xml delete mode 100644 app/code/Magento/Usa/i18n/de_DE.csv delete mode 100644 app/code/Magento/Usa/i18n/en_US.csv delete mode 100644 app/code/Magento/Usa/i18n/es_ES.csv delete mode 100644 app/code/Magento/Usa/i18n/fr_FR.csv delete mode 100644 app/code/Magento/Usa/i18n/nl_NL.csv delete mode 100644 app/code/Magento/Usa/i18n/pt_BR.csv delete mode 100644 app/code/Magento/Usa/i18n/zh_CN.csv create mode 100644 app/code/Magento/User/sql/user_setup/upgrade-1.6.1.5-1.6.1.6.php rename dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleObjectManager.php => app/code/Magento/Usps/Block/Adminhtml/Order/Packaging/Plugin/DisplayGirth.php (54%) create mode 100644 app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php create mode 100644 app/code/Magento/Usps/Helper/Data.php rename app/code/Magento/{Usa/Model/Shipping/Carrier/Usps.php => Usps/Model/Carrier.php} (98%) mode change 100755 => 100644 create mode 100644 app/code/Magento/Usps/Model/Source/Container.php rename app/code/Magento/{Usa/Model/Shipping/Carrier/Dhl => Usps/Model}/Source/Freemethod.php (75%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Usps => Usps/Model}/Source/Generic.php (63%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Usps => Usps/Model}/Source/Machinable.php (81%) rename app/code/Magento/{Usa/Model/Shipping/Carrier/Dhl => Usps/Model}/Source/Method.php (81%) create mode 100644 app/code/Magento/Usps/Model/Source/Size.php create mode 100644 app/code/Magento/Usps/etc/adminhtml/di.xml create mode 100644 app/code/Magento/Usps/etc/adminhtml/system.xml create mode 100644 app/code/Magento/Usps/etc/config.xml create mode 100644 app/code/Magento/Usps/etc/module.xml rename app/code/Magento/{Usa/sql/usa_setup/upgrade-1.6.0.1-1.6.0.2.php => Usps/sql/usps_setup/install-2.0.0.0.php} (91%) create mode 100644 app/code/Magento/Wishlist/view/frontend/layout/catalog_category_view.xml create mode 100644 app/code/Magento/Wishlist/view/frontend/layout/catalog_product_view.xml rename dev/tests/integration/testsuite/Magento/Backend/Model/{LocaleTest.php => Locale/ResolverTest.php} (83%) delete mode 100644 dev/tests/integration/testsuite/Magento/Code/GeneratorTest/ParentClassWithoutNamespace.php delete mode 100644 dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithNamespaceInterceptor.php delete mode 100644 dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespace.php delete mode 100644 dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespaceInterceptor.php delete mode 100644 dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespaceProxy.php delete mode 100644 dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceInterfaceWithoutNamespaceInterceptor.php rename dev/tests/integration/testsuite/Magento/Code/{GeneratorTest => _expected}/SourceClassWithNamespaceFactory.php (91%) create mode 100644 dev/tests/integration/testsuite/Magento/Code/_expected/SourceClassWithNamespaceInterceptor.php rename dev/tests/integration/testsuite/Magento/Code/{GeneratorTest => _expected}/SourceClassWithNamespaceProxy.php (79%) create mode 100644 dev/tests/integration/testsuite/Magento/Core/_files/second_third_store.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/HelloTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/NewsletterTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Account/DashboardTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/GroupTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/AccountTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/AddressesTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartsTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/NewsletterTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/OrdersTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/CartTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/OrdersTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/SalesTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/TabsTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/EditTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Widget/NameTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php mode change 100644 => 100755 dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/CartTest.php mode change 100644 => 100755 dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Model/Config/ShareTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_fullname.php rename app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Shipmenttype.php => dev/tests/integration/testsuite/Magento/Customer/_files/customer_primary_addresses.php (74%) create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/quote.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/sales_order.php rename dev/tests/integration/testsuite/Magento/{Usa/Block/Adminhtml/Dhl => Dhl/Block/Adminhtml}/UnitofmeasureTest.php (86%) create mode 100644 dev/tests/integration/testsuite/Magento/Interception/Fixture/Intercepted.php create mode 100644 dev/tests/integration/testsuite/Magento/Interception/Fixture/Intercepted/InterfacePlugin.php create mode 100644 dev/tests/integration/testsuite/Magento/Interception/Fixture/Intercepted/Plugin.php create mode 100644 dev/tests/integration/testsuite/Magento/Interception/Fixture/InterceptedInterface.php create mode 100644 dev/tests/integration/testsuite/Magento/Interception/Fixture/InterceptedParent.php create mode 100644 dev/tests/integration/testsuite/Magento/Interception/Fixture/InterceptedParentInterface.php create mode 100644 dev/tests/integration/testsuite/Magento/Interception/GeneralTest.php rename dev/tests/integration/testsuite/Magento/{Core/Model/LocaleTest.php => Locale/ResolverTest.php} (84%) rename dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/{UsaConfigFilesTest.php => CarrierConfigFilesTest.php} (95%) rename dev/tests/integration/testsuite/Magento/{Usa/Model/Shipping/Carrier/UpsTest.php => Ups/Model/CarrierTest.php} (66%) create mode 100644 dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleA/view/adminhtml/product/product.css create mode 100644 dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleB/view/adminhtml/images/gallery-image-base-label.png create mode 100644 dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleC/view/adminhtml/images/allinone.png create mode 100644 dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleC/view/adminhtml/images/logo.png create mode 100644 dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleC/view/adminhtml/styles.css rename app/code/Magento/Backend/Helper/Addresses.php => dev/tests/unit/testsuite/Magento/App/PageCache/IdentifierTest.php (52%) create mode 100644 dev/tests/unit/testsuite/Magento/App/PageCache/KernelTest.php rename app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Rounding.php => dev/tests/unit/testsuite/Magento/App/PageCache/PageCacheTest.php (60%) rename dev/tests/unit/testsuite/Magento/{PageCache/Model => App/PageCache}/VersionTest.php (86%) create mode 100644 dev/tests/unit/testsuite/Magento/CacheInvalidate/Model/ObserverTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Block/Category/ViewTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Block/NavigationTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Block/Product/Compare/SidebarTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ListProductTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Block/Product/NewProductTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Block/Product/PriceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ProductList/RelatedTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ProductList/UpsellTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Compare/ItemTest.php create mode 100644 dev/tests/unit/testsuite/Magento/CatalogInventory/Block/QtyincrementsTest.php create mode 100644 dev/tests/unit/testsuite/Magento/CatalogInventory/Block/Stockqty/DefaultStockqtyTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Checkout/Helper/ExpressRedirectTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Cms/Block/BlockTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Cms/Block/PageTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleClassPluginB.php delete mode 100644 dev/tests/unit/testsuite/Magento/Code/Plugin/InvocationChainTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Core/Model/LocaleTest.php mode change 100644 => 100755 dev/tests/unit/testsuite/Magento/Customer/Block/Account/CustomerTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressCurrentServiceTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerCurrentServiceTest.php rename dev/tests/unit/testsuite/Magento/{Usa/Model/Shipping/Carrier/Dhl/InternationalTest.php => Dhl/Model/CarrierTest.php} (85%) rename dev/tests/unit/testsuite/Magento/{Usa/Model/Shipping/Carrier/Dhl => Dhl/Model}/_files/countries.xml (100%) rename dev/tests/unit/testsuite/Magento/{Usa/Model/Shipping/Carrier => Dhl/Model}/_files/rates_request_data_dhl.php (100%) rename dev/tests/unit/testsuite/Magento/{Usa/Model/Shipping/Carrier/Dhl => Dhl/Model}/_files/response_shipping_label.xml (100%) rename dev/tests/unit/testsuite/Magento/{Usa/Model/Shipping/Carrier/Dhl/_files/success_dhlintl_response_rates.xml => Dhl/Model/_files/success_dhl_response_rates.xml} (100%) create mode 100644 dev/tests/unit/testsuite/Magento/Eav/Model/Entity/TypeTest.php create mode 100644 dev/tests/unit/testsuite/Magento/GoogleOptimizer/Block/Code/CategoryTest.php create mode 100644 dev/tests/unit/testsuite/Magento/GoogleOptimizer/Block/Code/ProductTest.php create mode 100644 dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Stockqty/Type/GroupedTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Interception/FactoryDecoratorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Interception/ObjectManager/ConfigTest.php rename dev/tests/unit/testsuite/Magento/{Core/Model => }/Locale/Hierarchy/Config/ConverterTest.php (91%) rename dev/tests/unit/testsuite/Magento/{Core/Model => }/Locale/Hierarchy/Config/FileResolverTest.php (90%) rename dev/tests/unit/testsuite/Magento/{Core/Model => }/Locale/Hierarchy/Config/_files/custom/hierarchy_config.xml (100%) rename dev/tests/unit/testsuite/Magento/{Core/Model => }/Locale/Hierarchy/Config/_files/default/hierarchy_config.xml (100%) rename dev/tests/unit/testsuite/Magento/{Core/Model => }/Locale/ValidatorTest.php (84%) create mode 100644 dev/tests/unit/testsuite/Magento/Module/DependencyManagerTest.php rename dev/tests/unit/testsuite/Magento/{Payment/Model/Method => OfflinePayments/Model}/BanktransferTest.php (93%) rename dev/tests/unit/testsuite/Magento/{Payment/Model/Method => OfflinePayments/Model}/CashondeliveryTest.php (91%) rename dev/tests/unit/testsuite/Magento/{Backend/Block/System/Config => OfflineShipping/Block/Adminhtml}/Form/Field/ExportTest.php (86%) rename dev/tests/unit/testsuite/Magento/{Backend/Block/System/Config => OfflineShipping/Block/Adminhtml}/Form/Field/ImportTest.php (93%) create mode 100644 dev/tests/unit/testsuite/Magento/OfflineShipping/Model/SalesRule/CalculatorTest.php create mode 100644 dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/CachePluginTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php create mode 100644 dev/tests/unit/testsuite/Magento/PageCache/Model/Layout/LayoutPluginTest.php create mode 100644 dev/tests/unit/testsuite/Magento/PageCache/Model/ObserverTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Persistent/Model/ObserverTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Reports/Block/Product/ViewedTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Sales/Block/Reorder/SidebarTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Shipping/Helper/CarrierTest.php rename dev/tests/unit/testsuite/Magento/{Usa => Shipping}/Model/Simplexml/ElementTest.php (88%) rename dev/tests/unit/testsuite/Magento/{Core => Stdlib/DateTime}/Filter/DateTest.php (74%) rename dev/tests/unit/testsuite/Magento/{Core => Stdlib/DateTime}/Filter/DateTimeTest.php (75%) create mode 100644 dev/tests/unit/testsuite/Magento/Theme/Block/Html/FooterTest.php create mode 100644 dev/tests/unit/testsuite/Magento/Ups/Helper/ConfigTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Dhl/_files/rates_request_data_dhlintl.php delete mode 100644 dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/DhlTest.php delete mode 100644 dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/success_dhl_response_rates.xml rename dev/tests/unit/testsuite/Magento/{Usa => Usps}/Helper/DataTest.php (89%) mode change 100755 => 100644 rename dev/tests/unit/testsuite/Magento/{Usa/Model/Shipping/Carrier/UspsTest.php => Usps/Model/CarrierTest.php} (91%) rename dev/tests/unit/testsuite/Magento/{Usa/Model/Shipping/Carrier/Usps => Usps/Model}/Source/GenericTest.php (76%) mode change 100755 => 100644 rename dev/tests/unit/testsuite/Magento/{Usa/Model/Shipping/Carrier => Usps/Model}/_files/rates_request_data.php (99%) rename dev/tests/unit/testsuite/Magento/{Usa/Model/Shipping/Carrier => Usps/Model}/_files/return_shipment_request_data.php (100%) rename dev/tests/unit/testsuite/Magento/{Usa/Model/Shipping/Carrier => Usps/Model}/_files/success_usps_response_rates.xml (99%) rename dev/tests/unit/testsuite/Magento/{Usa/Model/Shipping/Carrier => Usps/Model}/_files/success_usps_response_return_shipment.xml (97%) create mode 100644 dev/tests/unit/testsuite/Magento/Wishlist/Block/Customer/SidebarTest.php create mode 100644 lib/Cm/Cache/Backend/File.php create mode 100644 lib/Cm/Cache/Backend/Redis.php rename app/code/Magento/Backend/Model/Config/Source/Currency.php => lib/Magento/App/Http/Context.php (62%) create mode 100644 lib/Magento/App/PageCache/Cache.php create mode 100644 lib/Magento/App/PageCache/Identifier.php create mode 100644 lib/Magento/App/PageCache/Kernel.php rename {app/code/Magento/PageCache/Model => lib/Magento/App/PageCache}/Version.php (74%) delete mode 100644 lib/Magento/Code/Generator/Interceptor.php delete mode 100644 lib/Magento/Code/Plugin/InvocationChain.php rename lib/Magento/{Interception/CodeGenerator.php => Currency.php} (63%) rename dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespaceFactory.php => lib/Magento/CurrencyFactory.php (70%) create mode 100644 lib/Magento/CurrencyInterface.php create mode 100644 lib/Magento/Interception/Chain.php create mode 100644 lib/Magento/Interception/Chain/Chain.php create mode 100644 lib/Magento/Interception/Code/Generator/Interceptor.php create mode 100644 lib/Magento/Interception/Code/InterfaceValidator.php rename app/code/Magento/Usa/sql/usa_setup/install-1.6.0.0.php => lib/Magento/Interception/Code/ValidatorException.php (91%) delete mode 100644 lib/Magento/Interception/CodeGenerator/CodeGenerator.php delete mode 100644 lib/Magento/Interception/FactoryDecorator.php create mode 100644 lib/Magento/Interception/ObjectManager/Config.php rename dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleClass.php => lib/Magento/Locale.php (79%) rename {app/code/Magento/Core/Model => lib/Magento}/Locale/Config.php (96%) rename app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Dutypaymenttype.php => lib/Magento/Locale/ConfigInterface.php (75%) create mode 100644 lib/Magento/Locale/Currency.php create mode 100644 lib/Magento/Locale/CurrencyInterface.php create mode 100644 lib/Magento/Locale/Format.php create mode 100644 lib/Magento/Locale/FormatInterface.php rename {app/code/Magento/Core/Model => lib/Magento}/Locale/Hierarchy/Config/Converter.php (98%) rename {app/code/Magento/Core/Model => lib/Magento}/Locale/Hierarchy/Config/FileResolver.php (97%) rename {app/code/Magento/Core/Model => lib/Magento}/Locale/Hierarchy/Config/Reader.php (87%) rename {app/code/Magento/Core/Model => lib/Magento}/Locale/Hierarchy/Config/SchemaLocator.php (97%) create mode 100644 lib/Magento/Locale/Lists.php create mode 100644 lib/Magento/Locale/ListsInterface.php create mode 100644 lib/Magento/Locale/Resolver.php create mode 100644 lib/Magento/Locale/ResolverInterface.php rename dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceInterfaceWithoutNamespace.php => lib/Magento/Locale/ScopeConfigInterface.php (71%) rename {app/code/Magento/Core/Model => lib/Magento}/Locale/Validator.php (88%) create mode 100644 lib/Magento/LocaleFactory.php create mode 100644 lib/Magento/LocaleInterface.php create mode 100644 lib/Magento/Module/DependencyManager.php create mode 100644 lib/Magento/Module/DependencyManagerInterface.php rename dev/tests/integration/testsuite/Magento/Code/GeneratorTest/ParentInterfaceWithoutNamespace.php => lib/Magento/Object/IdentityInterface.php (80%) rename lib/Magento/{ => ObjectManager}/Code/Generator/Factory.php (99%) rename lib/Magento/{ => ObjectManager}/Code/Generator/Proxy.php (99%) create mode 100644 lib/Magento/Stdlib/DateTime/Date.php create mode 100644 lib/Magento/Stdlib/DateTime/DateFactory.php create mode 100644 lib/Magento/Stdlib/DateTime/DateInterface.php rename app/code/Magento/Core/Model/Date.php => lib/Magento/Stdlib/DateTime/DateTime.php (90%) rename {app/code/Magento/Core => lib/Magento/Stdlib/DateTime}/Filter/Date.php (53%) rename app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Mode.php => lib/Magento/Stdlib/DateTime/Filter/DateTime.php (55%) create mode 100644 lib/Magento/Stdlib/DateTime/Timezone.php create mode 100644 lib/Magento/Stdlib/DateTime/TimezoneInterface.php create mode 100644 lib/Magento/Translate/Locale/Resolver/Plugin.php rename {app/code => lib}/Magento/Url/Validator.php (100%) create mode 100644 lib/Magento/View/Block/IdentityInterface.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 80e7697127d..fd3a3bd43cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,46 @@ +2.0.0.0-dev68 +============= +* Cache: + * Implemented depersonalization of private content generation + * Implemented content invalidation + * Added Edge Side Includes (ESI) support + * Added a built-in caching application +* GitHub requests: + * [#454](https://github.com/magento/magento2/pull/454) -- Allow to specify list of IPs in a body on maintenance.flag which will be granted access even if the flag is on + * [#204](https://github.com/magento/magento2/issues/204) -- Mage_ImportExport: Exporting configurable products ignores multiple configurable options + * [#418](https://github.com/magento/magento2/issues/418) -- Echo vs print + * [#419](https://github.com/magento/magento2/issues/419) -- Some translation keys are not correct. + * [#244](https://github.com/magento/magento2/issues/244) -- Retrieve base host URL without path in error processor + * [#411](https://github.com/magento/magento2/issues/411) -- Missed column 'payment_method' of table 'sales_flat_quote_address' + * [#284](https://github.com/magento/magento2/pull/284) -- Fix for Issue #278 (Import -> Stores with large amount of Configurable Products) +* Fixed bugs: + * Fixed an issue where Mage_Eav_Model_Entity_Type::fetchNewIncrementId() did not rollback on exception + * Fixed an issue where a category containing more than 1000 products could not be saved + * Fixed inappropriate error messages displayed during installation when required extensions were not installed + * Fixed synopsis of the install.php script + * Fixed an issue where the schedule of recurring payments was not displayed in the shopping cart +* Modularity improvements: + * Introduced the OfflinePayments module - a saparate module for offline payment methods + * Added the ability to enable/disable the Paypal module + * Moved the framework part of the Locale functionality from the Core module to library + * The Locale logic was split among appropriate classes in library, according to their responsibilities + * Removed the deprecated DHL functionality + * Introduced the OfflineShipping module for offline shipping carrier functionality: Flatrate, Tablerate, Freeshipping, Pickup + * Introduced a separate module for the DHL shipping carrier + * Introduced a separate module for the Fedex shipping carrier + * Introduced a separate module for the UPS shipping carrier + * Introduced a separate module for the USPS shipping carrier +* Framework Improvements: + * Added the ability to intercept internal public calls + * Added the ability to access public interface of the intercepted object + * Added a static integrity test for plugin interface validation + * Added support for both class addressing approaches in DI: with and without slash ("\") at the beginning of a class name +* Customer Service usage: + * Refactored the Customer module blocks and controllers to use customer service layer +* Security: + * Introduced the ability to hash a password with a random salt of default length (32 chars) by the encryption library + * Utilized a random salt of default length for admin users, and frontend customers + 2.0.0.0-dev67 ============= * GitHub requests: diff --git a/app/bootstrap.php b/app/bootstrap.php index ca035bc61d7..5e09eae4edc 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -77,16 +77,19 @@ if (file_exists($classMapPath)) { if (!defined('BARE_BOOTSTRAP')) { if (file_exists(BP . '/maintenance.flag')) { - if (PHP_SAPI == 'cli') { - echo 'Service temporarily unavailable due to maintenance downtime.'; - } else { - include_once BP . '/pub/errors/503.php'; + + if (!in_array($_SERVER['REMOTE_ADDR'], explode(",", file_get_contents(BP . '/maintenance.flag')))) { + if (PHP_SAPI == 'cli') { + echo 'Service temporarily unavailable due to maintenance downtime.'; + } else { + include_once BP . '/pub/errors/503.php'; + } + exit; } - exit; } if (!empty($_SERVER['MAGE_PROFILER'])) { \Magento\Profiler::applyConfig($_SERVER['MAGE_PROFILER'], dirname(__DIR__), !empty($_REQUEST['isAjax'])); } } -date_default_timezone_set(\Magento\Core\Model\LocaleInterface::DEFAULT_TIMEZONE); +date_default_timezone_set(\Magento\Stdlib\DateTime\TimezoneInterface::DEFAULT_TIMEZONE); diff --git a/app/code/Magento/AdminNotification/Block/ToolbarEntry.php b/app/code/Magento/AdminNotification/Block/ToolbarEntry.php index e5f26daba64..618b3361fa4 100644 --- a/app/code/Magento/AdminNotification/Block/ToolbarEntry.php +++ b/app/code/Magento/AdminNotification/Block/ToolbarEntry.php @@ -84,8 +84,8 @@ class ToolbarEntry extends \Magento\Backend\Block\Template public function formatNotificationDate($dateString) { if (date('Ymd') == date('Ymd', strtotime($dateString))) { - return $this->formatTime($dateString, \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT, false); + return $this->formatTime($dateString, \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT, false); } - return $this->formatDate($dateString, \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM, true); + return $this->formatDate($dateString, \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, true); } } diff --git a/app/code/Magento/Authorizenet/Model/Authorizenet.php b/app/code/Magento/Authorizenet/Model/Authorizenet.php index 25dd3b95184..0a6fe3fb28a 100644 --- a/app/code/Magento/Authorizenet/Model/Authorizenet.php +++ b/app/code/Magento/Authorizenet/Model/Authorizenet.php @@ -248,7 +248,7 @@ class Authorizenet extends \Magento\Payment\Model\Method\Cc * @param \Magento\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Logger $logger * @param \Magento\Module\ModuleListInterface $moduleList - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService * @param \Magento\Authorizenet\Model\Authorizenet\CardsFactory $cardsFactory * @param \Magento\Authorizenet\Model\Authorizenet\RequestFactory $requestFactory @@ -267,7 +267,7 @@ class Authorizenet extends \Magento\Payment\Model\Method\Cc \Magento\Logger\AdapterFactory $logAdapterFactory, \Magento\Logger $logger, \Magento\Module\ModuleListInterface $moduleList, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, \Magento\Authorizenet\Model\Authorizenet\CardsFactory $cardsFactory, \Magento\Authorizenet\Model\Authorizenet\RequestFactory $requestFactory, @@ -290,7 +290,7 @@ class Authorizenet extends \Magento\Payment\Model\Method\Cc $logAdapterFactory, $logger, $moduleList, - $locale, + $localeDate, $centinelService, $data ); diff --git a/app/code/Magento/Authorizenet/Model/Directpost.php b/app/code/Magento/Authorizenet/Model/Directpost.php index a5e807c840b..df6cf8d03f6 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost.php +++ b/app/code/Magento/Authorizenet/Model/Directpost.php @@ -87,7 +87,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet * @param \Magento\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Logger $logger * @param \Magento\Module\ModuleListInterface $moduleList - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService * @param \Magento\Authorizenet\Model\Authorizenet\CardsFactory $cardsFactory * @param \Magento\Authorizenet\Model\Authorizenet\RequestFactory $requestFactory @@ -111,7 +111,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet \Magento\Logger\AdapterFactory $logAdapterFactory, \Magento\Logger $logger, \Magento\Module\ModuleListInterface $moduleList, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, \Magento\Authorizenet\Model\Authorizenet\CardsFactory $cardsFactory, \Magento\Authorizenet\Model\Authorizenet\RequestFactory $requestFactory, @@ -133,7 +133,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet $logAdapterFactory, $logger, $moduleList, - $locale, + $localeDate, $centinelService, $cardsFactory, $requestFactory, diff --git a/app/code/Magento/Authorizenet/etc/adminhtml/system.xml b/app/code/Magento/Authorizenet/etc/adminhtml/system.xml index a32dd7a97ce..e21df028018 100644 --- a/app/code/Magento/Authorizenet/etc/adminhtml/system.xml +++ b/app/code/Magento/Authorizenet/etc/adminhtml/system.xml @@ -88,7 +88,7 @@ </field> <field id="currency" translate="label" type="select" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="0"> <label>Accepted Currency</label> - <source_model>Magento\Backend\Model\Config\Source\Currency</source_model> + <source_model>Magento\Backend\Model\Config\Source\Locale\Currency</source_model> </field> <field id="allowspecific" translate="label" type="allowspecific" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> <label>Payment from Applicable Countries</label> @@ -172,7 +172,7 @@ </field> <field id="currency" translate="label" type="select" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> <label>Accepted Currency</label> - <source_model>Magento\Backend\Model\Config\Source\Currency</source_model> + <source_model>Magento\Backend\Model\Config\Source\Locale\Currency</source_model> </field> <field id="debug" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0"> <label>Debug</label> diff --git a/app/code/Magento/Authorizenet/view/adminhtml/info/cc.phtml b/app/code/Magento/Authorizenet/view/adminhtml/info/cc.phtml index cf99895f5c0..20e54ca8411 100644 --- a/app/code/Magento/Authorizenet/view/adminhtml/info/cc.phtml +++ b/app/code/Magento/Authorizenet/view/adminhtml/info/cc.phtml @@ -38,7 +38,7 @@ <?php foreach ($cards as $key => $card): ?> <?php if ($showCount): ?> - <span><?php echo sprintf(__('Credit Card %s'), $key + 1); ?></span> + <span><?php echo __('Credit Card %1', $key + 1); ?></span> <?php endif;?> <table class="data-table<?php if ($showCount):?> offset<?php endif;?>"> diff --git a/app/code/Magento/Authorizenet/view/adminhtml/info/pdf.phtml b/app/code/Magento/Authorizenet/view/adminhtml/info/pdf.phtml index f71c39fda14..ff8e25d7f94 100644 --- a/app/code/Magento/Authorizenet/view/adminhtml/info/pdf.phtml +++ b/app/code/Magento/Authorizenet/view/adminhtml/info/pdf.phtml @@ -33,7 +33,7 @@ <?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?>{{pdf_row_separator}} <?php foreach ($cards as $key => $card): ?> <?php if ($showCount): ?> - <?php echo sprintf(__('Credit Card %s'), $key + 1); ?> + <?php echo __('Credit Card %1', $key + 1); ?> {{pdf_row_separator}} <?php endif;?> diff --git a/app/code/Magento/Authorizenet/view/frontend/info/cc.phtml b/app/code/Magento/Authorizenet/view/frontend/info/cc.phtml index b15d7c62deb..24269dee7db 100644 --- a/app/code/Magento/Authorizenet/view/frontend/info/cc.phtml +++ b/app/code/Magento/Authorizenet/view/frontend/info/cc.phtml @@ -39,7 +39,7 @@ <?php foreach ($cards as $key => $card): ?> <?php if ($showCount): ?> - <dt><?php echo sprintf(__('Credit Card %s'), $key + 1); ?></dt> + <dt><?php echo __('Credit Card %1', $key + 1); ?></dt> <?php endif; ?> <dd class="content"> <table class="data table"> diff --git a/app/code/Magento/Backend/App/AbstractAction.php b/app/code/Magento/Backend/App/AbstractAction.php index c6b5a29ad22..f34b91e9e43 100644 --- a/app/code/Magento/Backend/App/AbstractAction.php +++ b/app/code/Magento/Backend/App/AbstractAction.php @@ -83,9 +83,9 @@ abstract class AbstractAction extends \Magento\App\Action\Action protected $_backendUrl; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ResolverInterface */ - protected $_locale; + protected $_localeResolver; /** * @var bool @@ -114,7 +114,7 @@ abstract class AbstractAction extends \Magento\App\Action\Action $this->_backendUrl = $context->getBackendUrl(); $this->_formKeyValidator = $context->getFormKeyValidator(); $this->_title = $context->getTitle(); - $this->_locale = $context->getLocale(); + $this->_localeResolver = $context->getLocaleResolver(); $this->_canUseBaseUrl = $context->getCanUseBaseUrl(); $this->_session = $context->getSession(); } @@ -300,12 +300,12 @@ abstract class AbstractAction extends \Magento\App\Action\Action protected function _processLocaleSettings() { $forceLocale = $this->getRequest()->getParam('locale', null); - if ($this->_objectManager->get('Magento\Core\Model\Locale\Validator')->isValid($forceLocale)) { + if ($this->_objectManager->get('Magento\Locale\Validator')->isValid($forceLocale)) { $this->_getSession()->setSessionLocale($forceLocale); } if (is_null($this->_getSession()->getLocale())) { - $this->_getSession()->setLocale($this->_locale->getLocaleCode()); + $this->_getSession()->setLocale($this->_localeResolver->getLocaleCode()); } return $this; diff --git a/app/code/Magento/Backend/App/Action/Context.php b/app/code/Magento/Backend/App/Action/Context.php index 6cdccaa8c0b..3f2c79f5a2c 100644 --- a/app/code/Magento/Backend/App/Action/Context.php +++ b/app/code/Magento/Backend/App/Action/Context.php @@ -61,11 +61,6 @@ class Context extends \Magento\App\Action\Context */ protected $_title; - /** - * @var \Magento\Core\Model\LocaleInterface - */ - protected $_locale; - /** * @var bool */ @@ -76,6 +71,11 @@ class Context extends \Magento\App\Action\Context */ protected $_session; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\App\RequestInterface $request * @param \Magento\App\ResponseInterface $response @@ -93,7 +93,7 @@ class Context extends \Magento\App\Action\Context * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator * @param \Magento\App\Action\Title $title - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver * @param bool $canUseBaseUrl */ public function __construct( @@ -113,7 +113,7 @@ class Context extends \Magento\App\Action\Context \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Core\App\Action\FormKeyValidator $formKeyValidator, \Magento\App\Action\Title $title, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ResolverInterface $localeResolver, $canUseBaseUrl = false ) { parent::__construct( @@ -135,7 +135,7 @@ class Context extends \Magento\App\Action\Context $this->_backendUrl = $backendUrl; $this->_formKeyValidator = $formKeyValidator; $this->_title = $title; - $this->_locale = $locale; + $this->_localeResolver = $localeResolver; $this->_canUseBaseUrl = $canUseBaseUrl; } @@ -188,11 +188,11 @@ class Context extends \Magento\App\Action\Context } /** - * @return \Magento\Core\Model\LocaleInterface + * @return \Magento\Locale\ResolverInterface */ - public function getLocale() + public function getLocaleResolver() { - return $this->_locale; + return $this->_localeResolver; } /** diff --git a/app/code/Magento/Backend/App/Action/Plugin/Authentication.php b/app/code/Magento/Backend/App/Action/Plugin/Authentication.php index 7f093c09c08..fd798fcc403 100644 --- a/app/code/Magento/Backend/App/Action/Plugin/Authentication.php +++ b/app/code/Magento/Backend/App/Action/Plugin/Authentication.php @@ -86,13 +86,18 @@ class Authentication } /** - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\Backend\App\AbstractAction $subject + * @param callable $proceed + * @param \Magento\App\RequestInterface $request + * * @return mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundDispatch(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - $request = $arguments[0]; + public function aroundDispatch( + \Magento\Backend\App\AbstractAction $subject, + \Closure $proceed, + \Magento\App\RequestInterface $request + ) { $requestedActionName = $request->getActionName(); if (in_array($requestedActionName, $this->_openActions)) { $request->setDispatched(true); @@ -105,7 +110,7 @@ class Authentication } } $this->_auth->getAuthStorage()->refreshAcl(); - return $invocationChain->proceed($arguments); + return $proceed($request); } /** diff --git a/app/code/Magento/Backend/App/Action/Plugin/MassactionKey.php b/app/code/Magento/Backend/App/Action/Plugin/MassactionKey.php index af7fa913429..1aeb83cb203 100644 --- a/app/code/Magento/Backend/App/Action/Plugin/MassactionKey.php +++ b/app/code/Magento/Backend/App/Action/Plugin/MassactionKey.php @@ -31,19 +31,24 @@ class MassactionKey /** * Process massaction key * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\Backend\App\AbstractAction $subject + * @param callable $proceed + * @param \Magento\App\RequestInterface $request + * * @return mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundDispatch(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - $request = $arguments[0]; + public function aroundDispatch( + \Magento\Backend\App\AbstractAction $subject, + \Closure $proceed, + \Magento\App\RequestInterface $request + ) { $key = $request->getPost('massaction_prepare_key'); if ($key) { $postData = $request->getPost($key); $value = is_array($postData) ? $postData : explode(',', $postData); $request->setPost($key, $value ? $value : null); } - return $invocationChain->proceed($arguments); + return $proceed($request); } -} \ No newline at end of file +} diff --git a/app/code/Magento/Backend/Block/Context.php b/app/code/Magento/Backend/Block/Context.php index 7237c52d9c5..8f19926a653 100644 --- a/app/code/Magento/Backend/Block/Context.php +++ b/app/code/Magento/Backend/Block/Context.php @@ -49,15 +49,13 @@ class Context extends \Magento\View\Element\Context * @param \Magento\Session\SessionManagerInterface $session * @param \Magento\Session\SidResolverInterface $sidResolver * @param \Magento\Core\Model\Store\Config $storeConfig - * @param \Magento\App\FrontController $frontController * @param \Magento\View\Url $viewUrl * @param \Magento\View\ConfigInterface $viewConfig * @param \Magento\App\Cache\StateInterface $cacheState * @param \Magento\Logger $logger - * @param \Magento\Core\Model\App $app * @param \Magento\Escaper $escaper * @param \Magento\Filter\FilterManager $filterManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\AuthorizationInterface $authorization * @param array $data * @@ -74,23 +72,20 @@ class Context extends \Magento\View\Element\Context \Magento\Session\SessionManagerInterface $session, \Magento\Session\SidResolverInterface $sidResolver, \Magento\Core\Model\Store\Config $storeConfig, - \Magento\App\FrontController $frontController, \Magento\View\Url $viewUrl, \Magento\View\ConfigInterface $viewConfig, \Magento\App\Cache\StateInterface $cacheState, \Magento\Logger $logger, - \Magento\Core\Model\App $app, \Magento\Escaper $escaper, \Magento\Filter\FilterManager $filterManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\AuthorizationInterface $authorization, array $data = array() ) { $this->_authorization = $authorization; parent::__construct( $request, $layout, $eventManager, $urlBuilder, $translator, $cache, $design, $session, $sidResolver, - $storeConfig, $frontController, $viewUrl, $viewConfig, $cacheState, $logger, $app, $escaper, - $filterManager, $locale, $data + $storeConfig, $viewUrl, $viewConfig, $cacheState, $logger, $escaper, $filterManager, $localeDate, $data ); } diff --git a/app/code/Magento/Backend/Block/Dashboard.php b/app/code/Magento/Backend/Block/Dashboard.php index acced031a83..4a997b7596c 100644 --- a/app/code/Magento/Backend/Block/Dashboard.php +++ b/app/code/Magento/Backend/Block/Dashboard.php @@ -28,11 +28,6 @@ namespace Magento\Backend\Block; class Dashboard extends \Magento\Backend\Block\Template { - /** - * @var \Magento\Core\Model\LocaleInterface - */ - protected $_locale; - /** * Location of the "Enable Chart" config param */ diff --git a/app/code/Magento/Backend/Block/Dashboard/Graph.php b/app/code/Magento/Backend/Block/Dashboard/Graph.php index 3c2b2dd1624..263e793b1cd 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Graph.php +++ b/app/code/Magento/Backend/Block/Dashboard/Graph.php @@ -121,19 +121,27 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard */ protected $_dashboardData = null; + /** + * @var \Magento\Locale\ListsInterface + */ + protected $_localeLists = null; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Reports\Model\Resource\Order\CollectionFactory $collectionFactory * @param \Magento\Backend\Helper\Dashboard\Data $dashboardData + * @param \Magento\Locale\ListsInterface $localeLists * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Reports\Model\Resource\Order\CollectionFactory $collectionFactory, \Magento\Backend\Helper\Dashboard\Data $dashboardData, + \Magento\Locale\ListsInterface $localeLists, array $data = array() ) { $this->_dashboardData = $dashboardData; + $this->_localeLists = $localeLists; parent::__construct($context, $collectionFactory, $data); } @@ -217,7 +225,7 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard } $timezoneLocal = $this->_storeConfig->getConfig( - \Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_TIMEZONE + $this->_localeDate->getDefaultTimezonePath() ); list ($dateStart, $dateEnd) = $this->_collectionFactory->create() @@ -316,7 +324,6 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard $yorigin = 0; if ($minvalue >= 0 && $maxvalue >= 0) { - $miny = 0; if ($maxvalue > 10) { $p = pow(10, $this->_getPow($maxvalue)); $maxy = (ceil($maxvalue/$p))*$p; @@ -376,9 +383,7 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard $params['chd'] .= $buffer; - $labelBuffer = ""; $valueBuffer = array(); - $rangeBuffer = ""; if (sizeof($this->_axisLabels) > 0) { $params['chxt'] = implode(',', array_keys($this->_axisLabels)); @@ -393,18 +398,18 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard switch ($this->getDataHelper()->getParam('period')) { case '24h': $this->_axisLabels[$idx][$_index] = $this->formatTime( - new \Zend_Date($_label, 'yyyy-MM-dd HH:00'), 'short', false + new \Magento\Stdlib\DateTime\Date($_label, 'yyyy-MM-dd HH:00'), 'short', false ); break; case '7d': case '1m': $this->_axisLabels[$idx][$_index] = $this->formatDate( - new \Zend_Date($_label, 'yyyy-MM-dd') + new \Magento\Stdlib\DateTime\Date($_label, 'yyyy-MM-dd') ); break; case '1y': case '2y': - $formats = $this->_locale->getTranslationList('datetime'); + $formats = $this->_localeLists->getTranslationList('datetime'); $format = isset($formats['yyMM']) ? $formats['yyMM'] : 'MM/yyyy'; $format = str_replace(array("yyyy", "yy", "MM"), array("Y", "y", "m"), $format); $this->_axisLabels[$idx][$_index] = date($format, strtotime($_label)); @@ -431,8 +436,6 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard } else { $deltaY = 100; } - // setting range values for y axis - $rangeBuffer = $indexid . "," . $miny . "," . $maxy . "|"; } $indexid++; } diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Amounts.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Amounts.php index 922cf5665c5..33421894e7a 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Tab/Amounts.php +++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Amounts.php @@ -40,6 +40,7 @@ class Amounts extends \Magento\Backend\Block\Dashboard\Graph * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Reports\Model\Resource\Order\CollectionFactory $collectionFactory * @param \Magento\Backend\Helper\Dashboard\Data $dashboardData + * @param \Magento\Locale\ListsInterface $localeLists * @param \Magento\Backend\Helper\Dashboard\Order $dataHelper * @param array $data */ @@ -47,11 +48,12 @@ class Amounts extends \Magento\Backend\Block\Dashboard\Graph \Magento\Backend\Block\Template\Context $context, \Magento\Reports\Model\Resource\Order\CollectionFactory $collectionFactory, \Magento\Backend\Helper\Dashboard\Data $dashboardData, + \Magento\Locale\ListsInterface $localeLists, \Magento\Backend\Helper\Dashboard\Order $dataHelper, array $data = array() ) { $this->_dataHelper = $dataHelper; - parent::__construct($context, $collectionFactory, $dashboardData, $data); + parent::__construct($context, $collectionFactory, $dashboardData, $localeLists, $data); } /** diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Orders.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Orders.php index eb209bcc5ee..ec9ba628b6c 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Tab/Orders.php +++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Orders.php @@ -40,6 +40,7 @@ class Orders extends \Magento\Backend\Block\Dashboard\Graph * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Reports\Model\Resource\Order\CollectionFactory $collectionFactory * @param \Magento\Backend\Helper\Dashboard\Data $dashboardData + * @param \Magento\Locale\ListsInterface $localeLists * @param \Magento\Backend\Helper\Dashboard\Order $dataHelper * @param array $data */ @@ -47,11 +48,12 @@ class Orders extends \Magento\Backend\Block\Dashboard\Graph \Magento\Backend\Block\Template\Context $context, \Magento\Reports\Model\Resource\Order\CollectionFactory $collectionFactory, \Magento\Backend\Helper\Dashboard\Data $dashboardData, + \Magento\Locale\ListsInterface $localeLists, \Magento\Backend\Helper\Dashboard\Order $dataHelper, array $data = array() ) { $this->_dataHelper = $dataHelper; - parent::__construct($context, $collectionFactory, $dashboardData, $data); + parent::__construct($context, $collectionFactory, $dashboardData, $localeLists, $data); } /** diff --git a/app/code/Magento/Backend/Block/Menu.php b/app/code/Magento/Backend/Block/Menu.php index 279e1eb4ab0..0135932a4e8 100644 --- a/app/code/Magento/Backend/Block/Menu.php +++ b/app/code/Magento/Backend/Block/Menu.php @@ -75,11 +75,17 @@ class Menu extends \Magento\Backend\Block\Template protected $_menuConfig; /** - * @param \Magento\Backend\Block\Template\Context $context + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + + /** + * @param Template\Context $context * @param \Magento\Backend\Model\UrlInterface $url * @param \Magento\Backend\Model\Menu\Filter\IteratorFactory $iteratorFactory * @param \Magento\Backend\Model\Auth\Session $authSession * @param \Magento\Backend\Model\Menu\Config $menuConfig + * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data */ public function __construct( @@ -88,12 +94,14 @@ class Menu extends \Magento\Backend\Block\Template \Magento\Backend\Model\Menu\Filter\IteratorFactory $iteratorFactory, \Magento\Backend\Model\Auth\Session $authSession, \Magento\Backend\Model\Menu\Config $menuConfig, + \Magento\Locale\ResolverInterface $localeResolver, array $data = array() ) { $this->_url = $url; $this->_iteratorFactory = $iteratorFactory; $this->_authSession = $authSession; $this->_menuConfig = $menuConfig; + $this->_localeResolver = $localeResolver; parent::__construct($context, $data); } @@ -280,7 +288,7 @@ class Menu extends \Magento\Backend\Block\Template 'admin_top_nav', $this->getActive(), $this->_authSession->getUser()->getId(), - $this->_locale->getLocaleCode() + $this->_localeResolver->getLocaleCode() ); // Add additional key parameters if needed $newCacheKeyInfo = $this->getAdditionalCacheKeyInfo(); diff --git a/app/code/Magento/Backend/Block/Page.php b/app/code/Magento/Backend/Block/Page.php index 1c0405fe230..04a6bf6099d 100644 --- a/app/code/Magento/Backend/Block/Page.php +++ b/app/code/Magento/Backend/Block/Page.php @@ -40,6 +40,25 @@ class Page extends \Magento\Backend\Block\Template */ protected $_template = 'admin/page.phtml'; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + + /** + * @param Template\Context $context + * @param \Magento\Locale\ResolverInterface $localeResolver + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Template\Context $context, + \Magento\Locale\ResolverInterface $localeResolver, + array $data = array() + ) { + parent::__construct($context, $data); + $this->_localeResolver = $localeResolver; + } + /** * Class constructor * @@ -60,7 +79,7 @@ class Page extends \Magento\Backend\Block\Template public function getLang() { if (!$this->hasData('lang')) { - $this->setData('lang', substr($this->_locale->getLocaleCode(), 0, 2)); + $this->setData('lang', substr($this->_localeResolver->getLocaleCode(), 0, 2)); } return $this->getData('lang'); } diff --git a/app/code/Magento/Backend/Block/Page/Head.php b/app/code/Magento/Backend/Block/Page/Head.php index b92773e5671..9c91d25e500 100644 --- a/app/code/Magento/Backend/Block/Page/Head.php +++ b/app/code/Magento/Backend/Block/Page/Head.php @@ -52,6 +52,7 @@ class Head extends \Magento\Theme\Block\Html\Head * @param \Magento\View\Asset\GroupedCollection $assets * @param \Magento\View\Asset\MergeService $assetMergeService * @param \Magento\View\Asset\MinifyService $assetMinifyService + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\App\Action\Title $titles * @param \Magento\Data\Form\FormKey $formKey * @param array $data @@ -63,6 +64,7 @@ class Head extends \Magento\Theme\Block\Html\Head \Magento\View\Asset\GroupedCollection $assets, \Magento\View\Asset\MergeService $assetMergeService, \Magento\View\Asset\MinifyService $assetMinifyService, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\App\Action\Title $titles, \Magento\Data\Form\FormKey $formKey, array $data = array() @@ -76,6 +78,7 @@ class Head extends \Magento\Theme\Block\Html\Head $assets, $assetMergeService, $assetMinifyService, + $localeResolver, $data ); $this->formKey = $formKey; diff --git a/app/code/Magento/Backend/Block/System/Account/Edit/Form.php b/app/code/Magento/Backend/Block/System/Account/Edit/Form.php index e53511f6f22..26c69a18a42 100644 --- a/app/code/Magento/Backend/Block/System/Account/Edit/Form.php +++ b/app/code/Magento/Backend/Block/System/Account/Edit/Form.php @@ -44,12 +44,18 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic */ protected $_userFactory; + /** + * @var \Magento\Locale\ListsInterface + */ + protected $_localeLists; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory * @param \Magento\User\Model\UserFactory $userFactory * @param \Magento\Backend\Model\Auth\Session $authSession + * @param \Magento\Locale\ListsInterface $localeLists * @param array $data */ public function __construct( @@ -58,10 +64,12 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic \Magento\Data\FormFactory $formFactory, \Magento\User\Model\UserFactory $userFactory, \Magento\Backend\Model\Auth\Session $authSession, + \Magento\Locale\ListsInterface $localeLists, array $data = array() ) { $this->_userFactory = $userFactory; $this->_authSession = $authSession; + $this->_localeLists = $localeLists; parent::__construct($context, $registry, $formFactory, $data); } @@ -128,7 +136,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic 'name' => 'interface_locale', 'label' => __('Interface Locale'), 'title' => __('Interface Locale'), - 'values' => $this->_locale->getTranslatedOptionLocales(), + 'values' => $this->_localeLists->getTranslatedOptionLocales(), 'class' => 'select', )); diff --git a/app/code/Magento/Backend/Block/System/Config/Form.php b/app/code/Magento/Backend/Block/System/Config/Form.php index 89baf3e2ab6..169c78f69e3 100644 --- a/app/code/Magento/Backend/Block/System/Config/Form.php +++ b/app/code/Magento/Backend/Block/System/Config/Form.php @@ -603,8 +603,6 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic protected function _getAdditionalElementTypes() { return array( - 'export' => 'Magento\Backend\Block\System\Config\Form\Field\Export', - 'import' => 'Magento\Backend\Block\System\Config\Form\Field\Import', 'allowspecific' => 'Magento\Backend\Block\System\Config\Form\Field\Select\Allowspecific', 'image' => 'Magento\Backend\Block\System\Config\Form\Field\Image', 'file' => 'Magento\Backend\Block\System\Config\Form\Field\File', diff --git a/app/code/Magento/Backend/Block/System/Config/Form/Field/Datetime.php b/app/code/Magento/Backend/Block/System/Config/Form/Field/Datetime.php index 905d981dc61..6c7749aaee7 100644 --- a/app/code/Magento/Backend/Block/System/Config/Form/Field/Datetime.php +++ b/app/code/Magento/Backend/Block/System/Config/Form/Field/Datetime.php @@ -26,6 +26,7 @@ namespace Magento\Backend\Block\System\Config\Form\Field; use Magento\Data\Form\Element\AbstractElement; +use Magento\View\Element\Template; /** * Backend system config datetime field renderer @@ -38,9 +39,9 @@ class Datetime extends \Magento\Backend\Block\System\Config\Form\Field */ protected function _getElementHtml(AbstractElement $element) { - $format = $this->_app->getLocale()->getDateTimeFormat( - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM + $format = $this->_localeDate->getDateTimeFormat( + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM ); - return $this->_app->getLocale()->date(intval($element->getValue()))->toString($format); + return $this->_localeDate->date(intval($element->getValue()))->toString($format); } } diff --git a/app/code/Magento/Backend/Block/System/Config/Form/Field/Notification.php b/app/code/Magento/Backend/Block/System/Config/Form/Field/Notification.php index cfac0de5299..037271ec89a 100644 --- a/app/code/Magento/Backend/Block/System/Config/Form/Field/Notification.php +++ b/app/code/Magento/Backend/Block/System/Config/Form/Field/Notification.php @@ -38,10 +38,10 @@ class Notification extends \Magento\Backend\Block\System\Config\Form\Field */ protected function _getElementHtml(AbstractElement $element) { - $element->setValue($this->_app->loadCache('admin_notifications_lastcheck')); - $format = $this->_app->getLocale()->getDateTimeFormat( - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM + $element->setValue($this->_cache->load('admin_notifications_lastcheck')); + $format = $this->_localeDate->getDateTimeFormat( + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM ); - return $this->_app->getLocale()->date(intval($element->getValue()))->toString($format); + return $this->_localeDate->date(intval($element->getValue()))->toString($format); } } diff --git a/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php b/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php index 009d9a903ed..be5219b7342 100644 --- a/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php +++ b/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php @@ -101,7 +101,7 @@ class General extends \Magento\Backend\Block\Widget\Form\Generic 'required' => true, )); - $dateFormat = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $dateFormat = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); $fieldset->addField('date_from', 'date', array( 'label' => __('Date From'), 'title' => __('Date From'), diff --git a/app/code/Magento/Backend/Block/Template.php b/app/code/Magento/Backend/Block/Template.php index e2df01f908e..5ce56c19d63 100644 --- a/app/code/Magento/Backend/Block/Template.php +++ b/app/code/Magento/Backend/Block/Template.php @@ -38,11 +38,6 @@ class Template extends \Magento\View\Element\Template */ protected $_authorization; - /** - * @var \Magento\Core\Model\LocaleInterface - */ - protected $_locale; - /** * @var \Magento\Math\Random */ @@ -58,6 +53,7 @@ class Template extends \Magento\View\Element\Template */ protected $formKey; + /** * @var \Magento\Code\NameBuilder */ @@ -71,7 +67,7 @@ class Template extends \Magento\View\Element\Template \Magento\Backend\Block\Template\Context $context, array $data = array() ) { - $this->_locale = $context->getLocale(); + $this->_localeDate = $context->getLocaleDate(); $this->_authorization = $context->getAuthorization(); $this->mathRandom = $context->getMathRandom(); $this->_backendSession = $context->getBackendSession(); diff --git a/app/code/Magento/Backend/Block/Template/Context.php b/app/code/Magento/Backend/Block/Template/Context.php index 406d4b42b2b..0155a1f41df 100644 --- a/app/code/Magento/Backend/Block/Template/Context.php +++ b/app/code/Magento/Backend/Block/Template/Context.php @@ -66,15 +66,13 @@ class Context extends \Magento\View\Element\Template\Context * @param \Magento\Core\Model\Session $session * @param \Magento\Session\SidResolverInterface $sidResolver * @param \Magento\Core\Model\Store\Config $storeConfig - * @param \Magento\App\FrontController $frontController * @param \Magento\View\Url $viewUrl * @param \Magento\View\ConfigInterface $viewConfig * @param \Magento\App\Cache\StateInterface $cacheState * @param \Magento\Logger $logger - * @param \Magento\Core\Model\App $app * @param \Magento\Escaper $escaper * @param \Magento\Filter\FilterManager $filterManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\App\Filesystem $filesystem * @param \Magento\View\FileSystem $viewFileSystem * @param \Magento\View\TemplateEnginePool $enginePool @@ -100,15 +98,13 @@ class Context extends \Magento\View\Element\Template\Context \Magento\Core\Model\Session $session, \Magento\Session\SidResolverInterface $sidResolver, \Magento\Core\Model\Store\Config $storeConfig, - \Magento\App\FrontController $frontController, \Magento\View\Url $viewUrl, \Magento\View\ConfigInterface $viewConfig, \Magento\App\Cache\StateInterface $cacheState, \Magento\Logger $logger, - \Magento\Core\Model\App $app, \Magento\Escaper $escaper, \Magento\Filter\FilterManager $filterManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\App\Filesystem $filesystem, \Magento\View\FileSystem $viewFileSystem, \Magento\View\TemplateEnginePool $enginePool, @@ -137,15 +133,13 @@ class Context extends \Magento\View\Element\Template\Context $session, $sidResolver, $storeConfig, - $frontController, $viewUrl, $viewConfig, $cacheState, $logger, - $app, $escaper, $filterManager, - $locale, + $localeDate, $filesystem, $viewFileSystem, $enginePool, @@ -183,14 +177,6 @@ class Context extends \Magento\View\Element\Template\Context return $this->_backendSession; } - /** - * @return \Magento\Core\Model\LocaleInterface - */ - public function getLocale() - { - return $this->_locale; - } - /** * @return \Magento\Math\Random */ diff --git a/app/code/Magento/Backend/Block/Widget/Form.php b/app/code/Magento/Backend/Block/Widget/Form.php index 0c0d7d6cd51..346b34e82f1 100644 --- a/app/code/Magento/Backend/Block/Widget/Form.php +++ b/app/code/Magento/Backend/Block/Widget/Form.php @@ -44,11 +44,6 @@ class Form extends \Magento\Backend\Block\Widget */ protected $_template = 'Magento_Backend::widget/form.phtml'; - /** - * @var \Magento\Core\Model\LocaleInterface - */ - protected $_locale; - /** * @param \Magento\Backend\Block\Template\Context $context * @param array $data @@ -57,7 +52,6 @@ class Form extends \Magento\Backend\Block\Widget \Magento\Backend\Block\Template\Context $context, array $data = array() ) { - $this->_locale = $context->getLocale(); parent::__construct($context, $data); } @@ -251,7 +245,7 @@ class Form extends \Magento\Backend\Block\Widget break; case 'date': $element->setImage($this->getViewFileUrl('images/grid-cal.gif')); - $element->setDateFormat($this->_locale->getDateFormatWithLongYear()); + $element->setDateFormat($this->_localeDate->getDateFormatWithLongYear()); break; case 'multiline': $element->setLineCount($attribute->getMultilineCount()); diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php index fe6204aae17..50c0189d50e 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php @@ -36,19 +36,27 @@ class Date */ protected $mathRandom; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\Backend\Block\Context $context * @param \Magento\Core\Model\Resource\Helper $resourceHelper * @param \Magento\Math\Random $mathRandom + * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, \Magento\Core\Model\Resource\Helper $resourceHelper, \Magento\Math\Random $mathRandom, + \Magento\Locale\ResolverInterface $localeResolver, array $data = array() ) { $this->mathRandom = $mathRandom; + $this->_localeResolver = $localeResolver; parent::__construct($context, $resourceHelper, $data); } @@ -69,7 +77,7 @@ class Date public function getHtml() { $htmlId = $this->mathRandom->getUniqueHash($this->_getHtmlId()); - $format = $this->getLocale()->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $format = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); $html = '<div class="range" id="' . $htmlId . '_range"><div class="range-line date">' . '<input type="text" name="' . $this->_getHtmlName() . '[from]" id="' . $htmlId . '_from"' . ' value="' . $this->getEscapedValue('from') . '" class="input-text no-changes" placeholder="' . __('From') . '" ' @@ -81,7 +89,7 @@ class Date . $this->getUiId('filter', $this->_getHtmlName(), 'to') . '/>' . '</div></div>'; $html .= '<input type="hidden" name="' . $this->_getHtmlName() . '[locale]"' - . ' value="' . $this->getLocale()->getLocaleCode() . '"/>'; + . ' value="' . $this->_localeResolver->getLocaleCode() . '"/>'; $html .= '<script type="text/javascript"> (function( $ ) { $("#' . $htmlId . '_range").dateRange({ @@ -108,7 +116,7 @@ class Date { $value = $this->getValue($index); if ($value instanceof \Zend_Date) { - return $value->toString($this->getLocale()->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT)); + return $value->toString($this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT)); } return $value; } @@ -165,31 +173,21 @@ class Date return $this; } - /** - * Retrieve locale - * - * @return \Magento\Core\Model\LocaleInterface - */ - public function getLocale() - { - return $this->_locale; - } - /** * Convert given date to default (UTC) timezone * * @param string $date * @param string $locale - * @return \Zend_Date|null + * @return \Magento\Stdlib\DateTime\Date|null */ protected function _convertDate($date, $locale) { try { - $dateObj = $this->getLocale()->date(null, null, $locale, false); + $dateObj = $this->_localeDate->date(null, null, $locale, false); //set default timezone for store (admin) $dateObj->setTimezone( - $this->_storeConfig->getConfig(\Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_TIMEZONE) + $this->_storeConfig->getConfig($this->_localeDate->getDefaultTimezonePath()) ); //set beginning of day @@ -201,7 +199,7 @@ class Date $dateObj->set($date, \Zend_Date::DATE_SHORT, $locale); //convert store date to default date in UTC timezone without DST - $dateObj->setTimezone(\Magento\Core\Model\LocaleInterface::DEFAULT_TIMEZONE); + $dateObj->setTimezone(\Magento\Stdlib\DateTime\TimezoneInterface::DEFAULT_TIMEZONE); return $dateObj; } catch (\Exception $e) { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Datetime.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Datetime.php index d3066beb292..febbbeddd5c 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Datetime.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Datetime.php @@ -61,10 +61,10 @@ class Datetime //calculate end date considering timezone specification $datetimeTo->setTimezone( - $this->_storeConfig->getConfig(\Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_TIMEZONE) + $this->_storeConfig->getConfig($this->_localeDate->getDefaultTimezonePath()) ); $datetimeTo->addDay(1)->subSecond(1); - $datetimeTo->setTimezone(\Magento\Core\Model\LocaleInterface::DEFAULT_TIMEZONE); + $datetimeTo->setTimezone(\Magento\Stdlib\DateTime\TimezoneInterface::DEFAULT_TIMEZONE); } return $value; } @@ -74,28 +74,28 @@ class Datetime * * @param string $date * @param string $locale - * @return \Zend_Date|null + * @return \Magento\Stdlib\DateTime\Date|null */ protected function _convertDate($date, $locale) { if ($this->getColumn()->getFilterTime()) { try { - $dateObj = $this->getLocale()->date(null, null, $locale, false); + $dateObj = $this->getLocaleDate()->date(null, null, $locale, false); //set default timezone for store (admin) $dateObj->setTimezone( - $this->_storeConfig->getConfig(\Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_TIMEZONE) + $this->_storeConfig->getConfig($this->_localeDate->getDefaultTimezonePath()) ); //set date with applying timezone of store $dateObj->set( $date, - $this->getLocale()->getDateTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT), + $this->getLocaleDate()->getDateTimeFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT), $locale ); //convert store date to default date in UTC timezone without DST - $dateObj->setTimezone(\Magento\Core\Model\LocaleInterface::DEFAULT_TIMEZONE); + $dateObj->setTimezone(\Magento\Stdlib\DateTime\TimezoneInterface::DEFAULT_TIMEZONE); return $dateObj; } catch (\Exception $e) { @@ -113,11 +113,11 @@ class Datetime public function getHtml() { $htmlId = $this->mathRandom->getUniqueHash($this->_getHtmlId()); - $format = $this->getLocale()->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $format = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); $timeFormat = ''; if ($this->getColumn()->getFilterTime()) { - $timeFormat = $this->getLocale()->getTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $timeFormat = $this->_localeDate->getTimeFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); } $html = '<div class="range" id="' . $htmlId . '_range"><div class="range-line date">' @@ -131,7 +131,7 @@ class Datetime . $this->getUiId('filter', $this->_getHtmlName(), 'to') . '/>' . '</div></div>'; $html .= '<input type="hidden" name="' . $this->_getHtmlName() . '[locale]"' - . ' value="' . $this->getLocale()->getLocaleCode() . '"/>'; + . ' value="' . $this->_localeResolver->getLocaleCode() . '"/>'; $html .= '<script type="text/javascript"> (function( $ ) { $("#'.$htmlId.'_range").dateRange({ @@ -164,7 +164,7 @@ class Datetime $value = $this->getValue($index); if ($value instanceof \Zend_Date) { return $value->toString( - $this->getLocale()->getDateTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT) + $this->_localeDate->getDateTimeFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT) ); } return $value; diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Country.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Country.php index 9d6c5da8a5e..2fa95c94a37 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Country.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Country.php @@ -29,9 +29,30 @@ */ namespace Magento\Backend\Block\Widget\Grid\Column\Renderer; +use Magento\View\Element\AbstractBlock; + class Country extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { + /** + * @var \Magento\Locale\ListsInterface + */ + protected $localeLists; + + /** + * @param \Magento\Backend\Block\Context $context + * @param \Magento\Locale\ListsInterface $localeLists + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Context $context, + \Magento\Locale\ListsInterface $localeLists, + array $data = array() + ) { + parent::__construct($context, $data); + $this->localeLists = $localeLists; + } + /** * Render country grid column * @@ -41,7 +62,7 @@ class Country public function render(\Magento\Object $row) { if ($data = $row->getData($this->getColumn()->getIndex())) { - $name = $this->_locale->getCountryTranslation($data); + $name = $this->localeLists->getCountryTranslation($data); if (empty($name)) { $name = $this->escapeHtml($data); } diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php index 9c4e6ac51e4..fbb53e63adb 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php @@ -54,13 +54,6 @@ class Currency */ protected $_storeManager; - /** - * Locale - * - * @var \Magento\Core\Model\LocaleInterface - */ - protected $_locale; - /** * @var \Magento\Directory\Model\Currency\DefaultLocator */ @@ -71,11 +64,18 @@ class Currency */ protected $_baseCurrency; + /** + * @var \Magento\Locale\CurrencyInterface + */ + protected $_localeCurrency; + /** * @param \Magento\Backend\Block\Context $context * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\Currency\DefaultLocator $currencyLocator * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory + * @param \Magento\App\ConfigInterface $config + * @param \Magento\Locale\CurrencyInterface $localeCurrency * @param array $data */ public function __construct( @@ -83,12 +83,17 @@ class Currency \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Directory\Model\Currency\DefaultLocator $currencyLocator, \Magento\Directory\Model\CurrencyFactory $currencyFactory, + \Magento\App\ConfigInterface $config, + \Magento\Locale\CurrencyInterface $localeCurrency, array $data = array() ) { parent::__construct($context, $data); $this->_storeManager = $storeManager; $this->_currencyLocator = $currencyLocator; - $baseCurrencyCode = $this->_app->getBaseCurrencyCode(); + $this->_localeCurrency = $localeCurrency; + $baseCurrencyCode = $config->getValue( + \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, 'default' + ); $this->_baseCurrency = $currencyFactory->create()->load($baseCurrencyCode); } @@ -105,7 +110,7 @@ class Currency $data = floatval($data) * $this->_getRate($row); $sign = (bool)(int)$this->getColumn()->getShowNumberSign() && ($data > 0) ? '+' : ''; $data = sprintf("%f", $data); - $data = $this->_locale->currency($currency_code)->toCurrency($data); + $data = $this->_localeCurrency->getCurrency($currency_code)->toCurrency($data); return $sign . $data; } return $this->getColumn()->getDefault(); diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Date.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Date.php index 6ede1067d60..ddc5fb07ebc 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Date.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Date.php @@ -43,6 +43,17 @@ class Date */ protected static $_format = null; + /** + * @param \Magento\Backend\Block\Context $context + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Context $context, + array $data = array() + ) { + parent::__construct($context, $data); + } + /** * Retrieve date format * @@ -54,8 +65,8 @@ class Date if (!$format) { if (is_null(self::$_format)) { try { - self::$_format = $this->_locale->getDateFormat( - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM + self::$_format = $this->_localeDate->getDateFormat( + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM ); } catch (\Exception $e) { @@ -79,17 +90,17 @@ class Date $format = $this->_getFormat(); try { if ($this->getColumn()->getGmtoffset()) { - $data = $this->_locale->date($data, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT)->toString($format); + $data = $this->_localeDate->date($data, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT)->toString($format); } else { - $data = $this->_locale->date($data, \Zend_Date::ISO_8601, null, false)->toString($format); + $data = $this->_localeDate->date($data, \Zend_Date::ISO_8601, null, false)->toString($format); } } catch (\Exception $e) { if ($this->getColumn()->getTimezone()) { - $data = $this->_locale->date($data, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT)->toString($format); + $data = $this->_localeDate->date($data, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT)->toString($format); } else { - $data = $this->_locale->date($data, null, null, false)->toString($format); + $data = $this->_localeDate->date($data, null, null, false)->toString($format); } } return $data; diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php index 65d3dc021bd..27d05f58db9 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php @@ -50,8 +50,8 @@ class Datetime if (!$format) { if (is_null(self::$_format)) { try { - self::$_format = $this->_locale->getDateTimeFormat( - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM + self::$_format = $this->_localeDate->getDateTimeFormat( + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM ); } catch (\Exception $e) { @@ -74,11 +74,11 @@ class Datetime if ($data = $this->_getValue($row)) { $format = $this->_getFormat(); try { - $data = $this->_locale->date($data, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT)->toString($format); + $data = $this->_localeDate->date($data, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT)->toString($format); } catch (\Exception $e) { - $data = $this->_locale->date($data, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT)->toString($format); + $data = $this->_localeDate->date($data, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT)->toString($format); } return $data; } diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Price.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Price.php index f5da304218e..7e316a3e3c9 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Price.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Price.php @@ -43,6 +43,26 @@ class Price */ protected static $_currencies = array(); + /** + * @var \Magento\Locale\CurrencyInterface + */ + protected $_localeCurrency; + + /** + * @param \Magento\Backend\Block\Context $context + * @param \Magento\Locale\CurrencyInterface $localeCurrency + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Context $context, + \Magento\Locale\CurrencyInterface $localeCurrency, + array $data = array() + ) { + parent::__construct($context, $data); + $this->_localeCurrency = $localeCurrency; + } + + /** * Renders grid column * @@ -60,7 +80,7 @@ class Price $data = floatval($data) * $this->_getRate($row); $data = sprintf("%f", $data); - $data = $this->_locale->currency($currencyCode)->toCurrency($data); + $data = $this->_localeCurrency->getCurrency($currencyCode)->toCurrency($data); return $data; } return $this->getColumn()->getDefault(); diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Account.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Account.php index d4458b59328..21ee1c849b5 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Account.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Account.php @@ -75,7 +75,7 @@ class Account extends Action $user->setPasswordConfirmation($passwordConfirmation); } - if ($this->_objectManager->get('Magento\Core\Model\Locale\Validator')->isValid($interfaceLocale)) { + if ($this->_objectManager->get('Magento\Locale\Validator')->isValid($interfaceLocale)) { $user->setInterfaceLocale($interfaceLocale); $this->_objectManager->get('Magento\Backend\Model\Locale\Manager') diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Config.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Config.php index 336ccfaf4e4..8d5bd6cb191 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Config.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Config.php @@ -119,26 +119,4 @@ class Config extends AbstractConfig $this->getResponse()->setBody('success'); } } - - /** - * Export shipping table rates in csv format - * - * @return ResponseInterface - */ - public function exportTableratesAction() - { - $fileName = 'tablerates.csv'; - /** @var $gridBlock \Magento\Shipping\Block\Adminhtml\Carrier\Tablerate\Grid */ - $gridBlock = $this->_view->getLayout() - ->createBlock('Magento\Shipping\Block\Adminhtml\Carrier\Tablerate\Grid'); - $website = $this->_storeManager->getWebsite($this->getRequest()->getParam('website')); - if ($this->getRequest()->getParam('conditionName')) { - $conditionName = $this->getRequest()->getParam('conditionName'); - } else { - $conditionName = $website->getConfig('carriers/tablerate/condition_name'); - } - $gridBlock->setWebsiteId($website->getId())->setConditionName($conditionName); - $content = $gridBlock->getCsvFile(); - return $this->_fileFactory->create($fileName, $content, \Magento\App\Filesystem::VAR_DIR); - } } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Design.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Design.php index c5e6908a7e3..eaddd427e2d 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Design.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Design.php @@ -37,19 +37,19 @@ class Design extends Action protected $_coreRegistry = null; /** - * @var \Magento\Core\Filter\Date + * @var \Magento\Stdlib\DateTime\Filter\Date */ protected $dateFilter; /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Registry $coreRegistry - * @param \Magento\Core\Filter\Date $dateFilter + * @param \Magento\Stdlib\DateTime\Filter\Date $dateFilter */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Registry $coreRegistry, - \Magento\Core\Filter\Date $dateFilter + \Magento\Stdlib\DateTime\Filter\Date $dateFilter ) { $this->_coreRegistry = $coreRegistry; $this->dateFilter = $dateFilter; diff --git a/app/code/Magento/Backend/Helper/Dashboard/Data.php b/app/code/Magento/Backend/Helper/Dashboard/Data.php index 59ce6aff161..c1b85636570 100644 --- a/app/code/Magento/Backend/Helper/Dashboard/Data.php +++ b/app/code/Magento/Backend/Helper/Dashboard/Data.php @@ -44,7 +44,6 @@ class Data extends \Magento\Core\Helper\Data * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Locale $locale * @param \Magento\App\State $appState * @param string $installDate * @param bool $dbCompatibleMode @@ -53,7 +52,6 @@ class Data extends \Magento\Core\Helper\Data \Magento\App\Helper\Context $context, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Locale $locale, \Magento\App\State $appState, $installDate, $dbCompatibleMode = true @@ -62,7 +60,6 @@ class Data extends \Magento\Core\Helper\Data $context, $coreStoreConfig, $storeManager, - $locale, $appState, $dbCompatibleMode ); diff --git a/app/code/Magento/Backend/Helper/Dashboard/Order.php b/app/code/Magento/Backend/Helper/Dashboard/Order.php index baa27155bc4..2f254a3dfec 100644 --- a/app/code/Magento/Backend/Helper/Dashboard/Order.php +++ b/app/code/Magento/Backend/Helper/Dashboard/Order.php @@ -39,7 +39,6 @@ class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Locale $locale * @param \Magento\App\State $appState * @param \Magento\Reports\Model\Resource\Order\Collection $orderCollection * @param bool $dbCompatibleMode @@ -48,7 +47,6 @@ class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard \Magento\App\Helper\Context $context, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Locale $locale, \Magento\App\State $appState, \Magento\Reports\Model\Resource\Order\Collection $orderCollection, $dbCompatibleMode = true @@ -58,7 +56,6 @@ class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard $context, $coreStoreConfig, $storeManager, - $locale, $appState, $dbCompatibleMode ); diff --git a/app/code/Magento/Backend/Helper/Data.php b/app/code/Magento/Backend/Helper/Data.php index 4add847c7f4..f2448dac067 100644 --- a/app/code/Magento/Backend/Helper/Data.php +++ b/app/code/Magento/Backend/Helper/Data.php @@ -45,9 +45,9 @@ class Data extends AbstractHelper protected $_routeConfig; /** - * @var \Magento\Core\Model\App + * @var \Magento\Locale\ResolverInterface */ - protected $_app; + protected $_locale; /** * @var \Magento\Backend\Model\UrlInterface @@ -72,7 +72,7 @@ class Data extends AbstractHelper /** * @param \Magento\App\Helper\Context $context * @param \Magento\App\Route\Config $routeConfig - * @param \Magento\AppInterface $app + * @param \Magento\Locale\ResolverInterface $locale * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Backend\Model\Auth $auth * @param \Magento\Backend\App\Area\FrontNameResolver $frontNameResolver @@ -81,7 +81,7 @@ class Data extends AbstractHelper public function __construct( \Magento\App\Helper\Context $context, \Magento\App\Route\Config $routeConfig, - \Magento\AppInterface $app, + \Magento\Locale\ResolverInterface $locale, \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Backend\Model\Auth $auth, \Magento\Backend\App\Area\FrontNameResolver $frontNameResolver, @@ -89,7 +89,7 @@ class Data extends AbstractHelper ) { parent::__construct($context); $this->_routeConfig = $routeConfig; - $this->_app = $app; + $this->_locale = $locale; $this->_backendUrl = $backendUrl; $this->_auth = $auth; $this->_frontNameResolver = $frontNameResolver; @@ -114,7 +114,7 @@ class Data extends AbstractHelper public function setPageHelpUrl($url = null) { if (is_null($url)) { - $request = $this->_app->getRequest(); + $request = $this->_request; $frontModule = $request->getControllerModule(); if (!$frontModule) { $frontModule = $this->_routeConfig->getModulesByFrontName($request->getModuleName()); @@ -125,7 +125,7 @@ class Data extends AbstractHelper } } $url = 'http://www.magentocommerce.com/gethelp/'; - $url.= $this->_app->getLocale()->getLocaleCode().'/'; + $url.= $this->_locale->getLocaleCode().'/'; $url.= $frontModule.'/'; $url.= $request->getControllerName().'/'; $url.= $request->getActionName().'/'; diff --git a/app/code/Magento/Backend/Model/Config/Backend/Currency/Allow.php b/app/code/Magento/Backend/Model/Config/Backend/Currency/Allow.php index 502e3d9daf4..c1775df1546 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Currency/Allow.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Currency/Allow.php @@ -33,9 +33,9 @@ namespace Magento\Backend\Model\Config\Backend\Currency; class Allow extends AbstractCurrency { /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\CurrencyInterface */ - protected $_locale; + protected $_localeCurrency; /** * @param \Magento\Model\Context $context @@ -43,7 +43,7 @@ class Allow extends AbstractCurrency * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\CurrencyInterface $localeCurrency * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -54,12 +54,12 @@ class Allow extends AbstractCurrency \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\CurrencyInterface $localeCurrency, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - $this->_locale = $locale; + $this->_localeCurrency = $localeCurrency; parent::__construct($context, $registry, $storeManager, $config, $coreStoreConfig, $resource, $resourceCollection, $data); } @@ -77,14 +77,14 @@ class Allow extends AbstractCurrency foreach ($this->_getAllowedCurrencies() as $currencyCode) { if (!in_array($currencyCode, $this->_getInstalledCurrencies())) { $exceptions[] = __('Selected allowed currency "%1" is not available in installed currencies.', - $this->_locale->currency($currencyCode)->getName() + $this->_localeCurrency->getCurrency($currencyCode)->getName() ); } } if (!in_array($this->_getCurrencyDefault(), $this->_getAllowedCurrencies())) { $exceptions[] = __('Default display currency "%1" is not available in allowed currencies.', - $this->_locale->currency($this->_getCurrencyDefault())->getName() + $this->_localeCurrency->getCurrency($this->_getCurrencyDefault())->getName() ); } diff --git a/app/code/Magento/Backend/Model/Config/Backend/Locale.php b/app/code/Magento/Backend/Model/Config/Backend/Locale.php index 36b304696b0..7c84ac4dbdb 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Locale.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Locale.php @@ -36,11 +36,6 @@ class Locale extends \Magento\Core\Model\Config\Value */ protected $_configsFactory; - /** - * @var \Magento\Core\Model\LocaleInterface - */ - protected $_locale; - /** * @var \Magento\Core\Model\Website\Factory */ @@ -51,15 +46,20 @@ class Locale extends \Magento\Core\Model\Config\Value */ protected $_storeFactory; + /** + * @var \Magento\Locale\CurrencyInterface + */ + protected $_localeCurrency; + /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Resource\Config\Data\CollectionFactory $configsFactory - * @param \Magento\Core\Model\LocaleInterface $locale * @param \Magento\Core\Model\Website\Factory $websiteFactory * @param \Magento\Core\Model\StoreFactory $storeFactory + * @param \Magento\Locale\CurrencyInterface $localeCurrency * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -72,17 +72,17 @@ class Locale extends \Magento\Core\Model\Config\Value \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, \Magento\Core\Model\Resource\Config\Data\CollectionFactory $configsFactory, - \Magento\Core\Model\LocaleInterface $locale, \Magento\Core\Model\Website\Factory $websiteFactory, \Magento\Core\Model\StoreFactory $storeFactory, + \Magento\Locale\CurrencyInterface $localeCurrency, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { $this->_configsFactory = $configsFactory; - $this->_locale = $locale; $this->_websiteFactory = $websiteFactory; $this->_storeFactory = $storeFactory; + $this->_localeCurrency = $localeCurrency; parent::__construct($context, $registry, $storeManager, $config, $resource, $resourceCollection, $data); } @@ -105,7 +105,7 @@ class Locale extends \Magento\Core\Model\Config\Value if (preg_match('/(base|default)$/', $data->getPath(), $match)) { if (!in_array($data->getValue(), $values)) { - $currencyName = $this->_locale->currency($data->getValue())->getName(); + $currencyName = $this->_localeCurrency->getCurrency($data->getValue())->getName(); if ($match[1] == 'base') { $fieldName = __('Base currency'); } else { diff --git a/app/code/Magento/Backend/Model/Config/Source/Locale.php b/app/code/Magento/Backend/Model/Config/Source/Locale.php index 2dfb3ee4f7e..fea8bd9ae63 100644 --- a/app/code/Magento/Backend/Model/Config/Source/Locale.php +++ b/app/code/Magento/Backend/Model/Config/Source/Locale.php @@ -32,16 +32,16 @@ namespace Magento\Backend\Model\Config\Source; class Locale implements \Magento\Option\ArrayInterface { /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ListsInterface */ - protected $_locale; + protected $_localeLists; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ListsInterface $localeLists */ - public function __construct(\Magento\Core\Model\LocaleInterface $locale) + public function __construct(\Magento\Locale\ListsInterface $localeLists) { - $this->_locale = $locale; + $this->_localeLists = $localeLists; } /** @@ -49,6 +49,6 @@ class Locale implements \Magento\Option\ArrayInterface */ public function toOptionArray() { - return $this->_locale->getOptionLocales(); + return $this->_localeLists->getOptionLocales(); } } diff --git a/app/code/Magento/Backend/Model/Config/Source/Locale/Country.php b/app/code/Magento/Backend/Model/Config/Source/Locale/Country.php index 995d7431b51..0ca74664cea 100644 --- a/app/code/Magento/Backend/Model/Config/Source/Locale/Country.php +++ b/app/code/Magento/Backend/Model/Config/Source/Locale/Country.php @@ -32,16 +32,16 @@ namespace Magento\Backend\Model\Config\Source\Locale; class Country implements \Magento\Option\ArrayInterface { /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ListsInterface */ - protected $_locale; + protected $_localeLists; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ListsInterface $localeLists */ - public function __construct(\Magento\Core\Model\LocaleInterface $locale) + public function __construct(\Magento\Locale\ListsInterface $localeLists) { - $this->_locale = $locale; + $this->_localeLists = $localeLists; } /** @@ -49,6 +49,6 @@ class Country implements \Magento\Option\ArrayInterface */ public function toOptionArray() { - return $this->_locale->getOptionCountries(); + return $this->_localeLists->getOptionCountries(); } } diff --git a/app/code/Magento/Backend/Model/Config/Source/Locale/Currency.php b/app/code/Magento/Backend/Model/Config/Source/Locale/Currency.php index 61949a54a88..0aad08af203 100644 --- a/app/code/Magento/Backend/Model/Config/Source/Locale/Currency.php +++ b/app/code/Magento/Backend/Model/Config/Source/Locale/Currency.php @@ -34,19 +34,19 @@ class Currency implements \Magento\Option\ArrayInterface /** * @var array */ - protected $_option; + protected $_options; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ListsInterface */ - protected $_locale; + protected $_localeLists; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ListsInterface $localeLists */ - public function __construct(\Magento\Core\Model\LocaleInterface $locale) + public function __construct(\Magento\Locale\ListsInterface $localeLists) { - $this->_locale = $locale; + $this->_localeLists = $localeLists; } /** @@ -54,6 +54,10 @@ class Currency implements \Magento\Option\ArrayInterface */ public function toOptionArray() { - return $this->_locale->getOptionCurrencies(); + if (!$this->_options) { + $this->_options = $this->_localeLists->getOptionCurrencies(); + } + $options = $this->_options; + return $options; } } diff --git a/app/code/Magento/Backend/Model/Config/Source/Locale/Currency/All.php b/app/code/Magento/Backend/Model/Config/Source/Locale/Currency/All.php index 1d7a8061792..d8b6afc7638 100644 --- a/app/code/Magento/Backend/Model/Config/Source/Locale/Currency/All.php +++ b/app/code/Magento/Backend/Model/Config/Source/Locale/Currency/All.php @@ -34,16 +34,16 @@ class All implements \Magento\Option\ArrayInterface protected $_options; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ListsInterface */ - protected $_locale; + protected $_localeLists; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ListsInterface $localeLists */ - public function __construct(\Magento\Core\Model\LocaleInterface $locale) + public function __construct(\Magento\Locale\ListsInterface $localeLists) { - $this->_locale = $locale; + $this->_localeLists = $localeLists; } /** @@ -53,7 +53,7 @@ class All implements \Magento\Option\ArrayInterface public function toOptionArray($isMultiselect = false) { if (!$this->_options) { - $this->_options = $this->_locale->getOptionAllCurrencies(); + $this->_options = $this->_localeLists->getOptionAllCurrencies(); } $options = $this->_options; if (!$isMultiselect) { diff --git a/app/code/Magento/Backend/Model/Config/Source/Locale/Timezone.php b/app/code/Magento/Backend/Model/Config/Source/Locale/Timezone.php index e67bb0c3ba2..46fdad41e1a 100644 --- a/app/code/Magento/Backend/Model/Config/Source/Locale/Timezone.php +++ b/app/code/Magento/Backend/Model/Config/Source/Locale/Timezone.php @@ -32,16 +32,16 @@ namespace Magento\Backend\Model\Config\Source\Locale; class Timezone implements \Magento\Option\ArrayInterface { /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ListsInterface */ - protected $_locale; + protected $_localeLists; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ListsInterface $localeLists */ - public function __construct(\Magento\Core\Model\LocaleInterface $locale) + public function __construct(\Magento\Locale\ListsInterface $localeLists) { - $this->_locale = $locale; + $this->_localeLists = $localeLists; } /** @@ -49,6 +49,6 @@ class Timezone implements \Magento\Option\ArrayInterface */ public function toOptionArray() { - return $this->_locale->getOptionTimezones(); + return $this->_localeLists->getOptionTimezones(); } } diff --git a/app/code/Magento/Backend/Model/Config/Source/Locale/Weekdaycodes.php b/app/code/Magento/Backend/Model/Config/Source/Locale/Weekdaycodes.php index 13e8cf16439..bf7b3474165 100644 --- a/app/code/Magento/Backend/Model/Config/Source/Locale/Weekdaycodes.php +++ b/app/code/Magento/Backend/Model/Config/Source/Locale/Weekdaycodes.php @@ -32,16 +32,16 @@ namespace Magento\Backend\Model\Config\Source\Locale; class Weekdaycodes implements \Magento\Option\ArrayInterface { /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ListsInterface */ - protected $_locale; + protected $_localeLists; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ListsInterface $localeLists */ - public function __construct(\Magento\Core\Model\LocaleInterface $locale) + public function __construct(\Magento\Locale\ListsInterface $localeLists) { - $this->_locale = $locale; + $this->_localeLists = $localeLists; } /** @@ -49,6 +49,6 @@ class Weekdaycodes implements \Magento\Option\ArrayInterface */ public function toOptionArray() { - return $this->_locale->getOptionWeekdays(true, true); + return $this->_localeLists->getOptionWeekdays(true, true); } } diff --git a/app/code/Magento/Backend/Model/Config/Source/Locale/Weekdays.php b/app/code/Magento/Backend/Model/Config/Source/Locale/Weekdays.php index ab6d059fba1..ea06a823085 100644 --- a/app/code/Magento/Backend/Model/Config/Source/Locale/Weekdays.php +++ b/app/code/Magento/Backend/Model/Config/Source/Locale/Weekdays.php @@ -32,16 +32,16 @@ namespace Magento\Backend\Model\Config\Source\Locale; class Weekdays implements \Magento\Option\ArrayInterface { /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ListsInterface */ - protected $_locale; + protected $_localeLists; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ListsInterface $localeLists */ - public function __construct(\Magento\Core\Model\LocaleInterface $locale) + public function __construct(\Magento\Locale\ListsInterface $localeLists) { - $this->_locale = $locale; + $this->_localeLists = $localeLists; } /** @@ -49,6 +49,6 @@ class Weekdays implements \Magento\Option\ArrayInterface */ public function toOptionArray() { - return $this->_locale->getOptionWeekdays(); + return $this->_localeLists->getOptionWeekdays(); } } diff --git a/app/code/Magento/Backend/Model/Locale/Manager.php b/app/code/Magento/Backend/Model/Locale/Manager.php index a4c42d64324..8bbe6e178f3 100644 --- a/app/code/Magento/Backend/Model/Locale/Manager.php +++ b/app/code/Magento/Backend/Model/Locale/Manager.php @@ -92,7 +92,7 @@ class Manager */ public function getUserInterfaceLocale() { - $interfaceLocale = \Magento\Core\Model\LocaleInterface::DEFAULT_LOCALE; + $interfaceLocale = \Magento\Locale\ResolverInterface::DEFAULT_LOCALE; $userData = $this->_authSession->getUser(); if ($userData && $userData->getInterfaceLocale()) { diff --git a/app/code/Magento/Backend/Model/Locale.php b/app/code/Magento/Backend/Model/Locale/Resolver.php similarity index 58% rename from app/code/Magento/Backend/Model/Locale.php rename to app/code/Magento/Backend/Model/Locale/Resolver.php index 6104023ecb5..b7c8d171cc3 100644 --- a/app/code/Magento/Backend/Model/Locale.php +++ b/app/code/Magento/Backend/Model/Locale/Resolver.php @@ -23,14 +23,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Backend\Model; +namespace Magento\Backend\Model\Locale; /** * Backend locale model - * - * @author Magento Core Team <core@magentocommerce.com> */ -class Locale extends \Magento\Core\Model\Locale +class Resolver extends \Magento\Locale\Resolver { /** * @var \Magento\Backend\Model\Session @@ -48,67 +46,46 @@ class Locale extends \Magento\Core\Model\Locale protected $_request; /** - * @var \Magento\Core\Model\Locale\Validator + * @var \Magento\Locale\Validator */ protected $_localeValidator; /** - * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Core\Helper\Translate $translate - * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\App\State $appState - * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Locale\Config $config - * @param \Magento\Core\Model\App $app - * @param \Magento\Stdlib\DateTime $dateTime - * @param \Magento\Core\Model\Date $dateModel + * @param \Magento\Locale\ScopeConfigInterface $scopeConfig + * @param \Magento\AppInterface $app + * @param \Magento\LocaleFactory $localeFactory + * @param $defaultLocalePath + * @param \Magento\ObjectManager $objectManager * @param \Magento\Backend\Model\Session $session - * @param \Magento\Backend\Model\Locale\Manager $localeManager + * @param Manager $localeManager * @param \Magento\App\RequestInterface $request - * @param \Magento\Core\Model\Locale\Validator $localeValidator - * @param mixed $locale - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) + * @param \Magento\Locale\Validator $localeValidator + * @param string|null $locale */ public function __construct( - \Magento\Event\ManagerInterface $eventManager, - \Magento\Core\Helper\Translate $translate, - \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\App\State $appState, - \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Locale\Config $config, - \Magento\Core\Model\App $app, - \Magento\Stdlib\DateTime $dateTime, - \Magento\Core\Model\Date $dateModel, + \Magento\Locale\ScopeConfigInterface $scopeConfig, + \Magento\AppInterface $app, + \Magento\LocaleFactory $localeFactory, + $defaultLocalePath, + \Magento\ObjectManager $objectManager, \Magento\Backend\Model\Session $session, \Magento\Backend\Model\Locale\Manager $localeManager, \Magento\App\RequestInterface $request, - \Magento\Core\Model\Locale\Validator $localeValidator, + \Magento\Locale\Validator $localeValidator, $locale = null ) { $this->_session = $session; $this->_localeManager = $localeManager; $this->_request = $request; $this->_localeValidator = $localeValidator; - parent::__construct( - $eventManager, - $translate, - $coreStoreConfig, - $appState, - $storeManager, - $config, - $app, - $dateTime, - $dateModel, - $locale - ); + parent::__construct($scopeConfig, $app, $localeFactory, $defaultLocalePath, $locale); } /** * Set locale * - * @param string $locale - * @return $this + * @param string $locale + * @return $this */ public function setLocale($locale = null) { diff --git a/app/code/Magento/Backend/Model/View.php b/app/code/Magento/Backend/Model/View.php index 76e3c050f22..48df3aa0fa4 100644 --- a/app/code/Magento/Backend/Model/View.php +++ b/app/code/Magento/Backend/Model/View.php @@ -70,4 +70,13 @@ class View extends \Magento\App\View return $this; } + /** + * Returns is layout loaded + * + * @return bool + */ + public function isLayoutLoaded() + { + return $this->_isLayoutLoaded; + } } diff --git a/app/code/Magento/Backend/etc/adminhtml/di.xml b/app/code/Magento/Backend/etc/adminhtml/di.xml index 95980106634..80bafdd19a4 100644 --- a/app/code/Magento/Backend/etc/adminhtml/di.xml +++ b/app/code/Magento/Backend/etc/adminhtml/di.xml @@ -25,7 +25,7 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <preference for="Magento\Authorization\RoleLocator" type="Magento\Backend\Model\Authorization\RoleLocator" /> - <preference for="Magento\Core\Model\LocaleInterface" type="Magento\Backend\Model\Locale" /> + <preference for="Magento\Locale\ResolverInterface" type="Magento\Backend\Model\Locale\Resolver" /> <preference for="Magento\App\Action\Context" type="Magento\Backend\App\Action\Context" /> <preference for="Magento\UrlInterface" type="Magento\Backend\Model\UrlInterface" /> <preference for="Magento\Backend\Model\Auth\StorageInterface" type="Magento\Backend\Model\Auth\Session" /> @@ -115,11 +115,6 @@ </argument> </arguments> </type> - <type name="Magento\Core\App\Action\Plugin\Session"> - <arguments> - <argument name="sessionNamespace" xsi:type="const">Magento\Backend\App\AbstractAction::SESSION_NAMESPACE</argument> - </arguments> - </type> <type name="Magento\Backend\App\AbstractAction"> <plugin name="adminAuthentication" type="Magento\Backend\App\Action\Plugin\Authentication" sortOrder="100" /> <plugin name="adminMassactionKey" type="Magento\Backend\App\Action\Plugin\MassactionKey" sortOrder="11" /> @@ -137,4 +132,10 @@ <argument name="defaultGroup" xsi:type="string">backend</argument> </arguments> </type> + <type name="Magento\Translate"> + <arguments> + <argument name="cache" xsi:type="object">Magento\App\Cache\Type\Translate</argument> + <argument name="locale" xsi:type="object">Magento\Backend\Model\Locale\Resolver\Proxy</argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Backend/etc/di.xml b/app/code/Magento/Backend/etc/di.xml index ea21e78278f..4d34f02574c 100644 --- a/app/code/Magento/Backend/etc/di.xml +++ b/app/code/Magento/Backend/etc/di.xml @@ -67,6 +67,7 @@ <arguments> <argument name="backendUrl" xsi:type="object">Magento\Backend\Model\UrlInterface\Proxy</argument> <argument name="auth" xsi:type="object">Magento\Backend\Model\Auth\Proxy</argument> + <argument name="locale" xsi:type="object">Magento\Backend\Model\Locale\Resolver\Proxy</argument> </arguments> </type> <type name="Magento\App\Router\NoRouteHandlerList"> diff --git a/app/code/Magento/Backend/etc/module.xml b/app/code/Magento/Backend/etc/module.xml index 9794c6bfc6c..ac5426b88bd 100755 --- a/app/code/Magento/Backend/etc/module.xml +++ b/app/code/Magento/Backend/etc/module.xml @@ -42,9 +42,7 @@ <module name="Magento_Sales"/> <module name="Magento_Catalog"/> <module name="Magento_User"/> - <module name="Magento_Usa"/> <module name="Magento_Cms"/> - <module name="Magento_Shipping"/> <module name="Magento_Backup"/> <module name="Magento_Email"/> <module name="Magento_Customer"/> diff --git a/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_system_config_edit.xml b/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_system_config_edit.xml index 9fce934606f..bb301b28523 100644 --- a/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_system_config_edit.xml +++ b/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_system_config_edit.xml @@ -32,7 +32,6 @@ </block> </referenceBlock> <referenceContainer name="js"> - <block class="Magento\Backend\Block\System\Shipping\Ups" template="Magento_Backend::system/shipping/ups.phtml"/> <block class="Magento\Backend\Block\Template" template="Magento_Backend::system/config/js.phtml"/> <block class="Magento\Backend\Block\Template" template="Magento_Backend::system/shipping/applicable_country.phtml"/> </referenceContainer> diff --git a/app/code/Magento/Backend/view/adminhtml/widget/grid/extended.phtml b/app/code/Magento/Backend/view/adminhtml/widget/grid/extended.phtml index 89f39664ed6..ae4fb53385b 100644 --- a/app/code/Magento/Backend/view/adminhtml/widget/grid/extended.phtml +++ b/app/code/Magento/Backend/view/adminhtml/widget/grid/extended.phtml @@ -135,7 +135,7 @@ $numColumns = sizeof($this->getColumns()); <?php endif ?> </div> <?php endif; ?> - <?php if ($this->getMassactionBlock()->isAvailable()): ?> + <?php if ($this->getMassactionBlock() && $this->getMassactionBlock()->isAvailable()): ?> <?php echo $this->getMassactionBlockHtml() ?> <?php endif ?> <div class="grid"> @@ -246,7 +246,7 @@ $numColumns = sizeof($this->getColumns()); <?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>; <?php echo $this->getJsObjectName() ?>.initGridRows(); <?php endif; ?> - <?php if ($this->getMassactionBlock()->isAvailable()): ?> + <?php if ($this->getMassactionBlock() && $this->getMassactionBlock()->isAvailable()): ?> <?php echo $this->getMassactionBlock()->getJavaScript() ?> <?php endif ?> <?php echo $this->getAdditionalJavaScript(); ?> diff --git a/app/code/Magento/Backup/Model/Backup.php b/app/code/Magento/Backup/Model/Backup.php index ddd429f01f2..a4c5c5911bb 100644 --- a/app/code/Magento/Backup/Model/Backup.php +++ b/app/code/Magento/Backup/Model/Backup.php @@ -65,9 +65,9 @@ class Backup extends \Magento\Object implements \Magento\Backup\Db\BackupInterfa /** * Locale model * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ResolverInterface */ - protected $_locale; + protected $_localeResolver; /** * Backend auth session @@ -88,7 +88,7 @@ class Backup extends \Magento\Object implements \Magento\Backup\Db\BackupInterfa /** * @param \Magento\Backup\Helper\Data $helper - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Backend\Model\Auth\Session $authSession * @param \Magento\Encryption\EncryptorInterface $encryptor * @param \Magento\App\Filesystem $filesystem @@ -96,7 +96,7 @@ class Backup extends \Magento\Object implements \Magento\Backup\Db\BackupInterfa */ public function __construct( \Magento\Backup\Helper\Data $helper, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Backend\Model\Auth\Session $authSession, \Magento\Encryption\EncryptorInterface $encryptor, \Magento\App\Filesystem $filesystem, @@ -108,7 +108,7 @@ class Backup extends \Magento\Object implements \Magento\Backup\Db\BackupInterfa $this->_filesystem = $filesystem; $this->varDirectory = $this->_filesystem->getDirectoryWrite(\Magento\App\Filesystem::VAR_DIR); $this->_helper = $helper; - $this->_locale = $locale; + $this->_localeResolver = $localeResolver; $this->_backendAuthSession = $authSession; } @@ -167,7 +167,7 @@ class Backup extends \Magento\Object implements \Magento\Backup\Db\BackupInterfa 'extension' => $this->_helper->getExtensionByType($backupData->getType()), 'display_name' => $this->_helper->nameToDisplayName($backupData->getName()), 'name' => $backupData->getName(), - 'date_object' => new \Zend_Date((int)$backupData->getTime(), $this->_locale->getLocaleCode()) + 'date_object' => new \Magento\Stdlib\DateTime\Date((int)$backupData->getTime(), $this->_localeResolver->getLocaleCode()) )); $this->setType($backupData->getType()); diff --git a/app/code/Magento/Backup/Model/Resource/Helper.php b/app/code/Magento/Backup/Model/Resource/Helper.php index 41e5fa63f53..792f752d79a 100644 --- a/app/code/Magento/Backup/Model/Resource/Helper.php +++ b/app/code/Magento/Backup/Model/Resource/Helper.php @@ -38,18 +38,18 @@ class Helper extends \Magento\Core\Model\Resource\Helper /** * Core Date * - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_coreDate; /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\Date $coreDate + * @param \Magento\Stdlib\DateTime\DateTime $coreDate * @param string $modulePrefix */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\Date $coreDate, + \Magento\Stdlib\DateTime\DateTime $coreDate, $modulePrefix ) { parent::__construct($resource, $modulePrefix); diff --git a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php index 3090b1c0d31..0768519752d 100644 --- a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php +++ b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php @@ -67,6 +67,11 @@ class Bundle extends \Magento\Catalog\Block\Product\View\AbstractView */ protected $jsonEncoder; + /** + * @var \Magento\Locale\FormatInterface + */ + protected $_localeFormat; + /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Catalog\Model\Config $catalogConfig @@ -84,6 +89,7 @@ class Bundle extends \Magento\Catalog\Block\Product\View\AbstractView * @param \Magento\Bundle\Model\Product\PriceFactory $productPrice * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Json\EncoderInterface $jsonEncoder + * @param \Magento\Locale\FormatInterface $localeFormat * @param array $data * @param array $priceBlockTypes * @@ -106,6 +112,7 @@ class Bundle extends \Magento\Catalog\Block\Product\View\AbstractView \Magento\Bundle\Model\Product\PriceFactory $productPrice, \Magento\Core\Helper\Data $coreData, \Magento\Json\EncoderInterface $jsonEncoder, + \Magento\Locale\FormatInterface $localeFormat, array $data = array(), array $priceBlockTypes = array() ) { @@ -113,6 +120,7 @@ class Bundle extends \Magento\Catalog\Block\Product\View\AbstractView $this->_productPrice = $productPrice; $this->coreData = $coreData; $this->jsonEncoder = $jsonEncoder; + $this->_localeFormat = $localeFormat; parent::__construct( $context, $catalogConfig, @@ -272,7 +280,7 @@ class Bundle extends \Magento\Catalog\Block\Product\View\AbstractView 'options' => $options, 'selected' => $selected, 'bundleId' => $currentProduct->getId(), - 'priceFormat' => $this->_locale->getJsPriceFormat(), + 'priceFormat' => $this->_localeFormat->getPriceFormat(), 'basePrice' => $this->coreData->currency($currentProduct->getPrice(), false, false), 'priceType' => $currentProduct->getPriceType(), 'specialPrice' => $currentProduct->getSpecialPrice(), diff --git a/app/code/Magento/Bundle/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Bundle.php b/app/code/Magento/Bundle/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Bundle.php index 859fd69cf39..760406ebeb8 100644 --- a/app/code/Magento/Bundle/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Bundle.php +++ b/app/code/Magento/Bundle/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Bundle.php @@ -42,11 +42,16 @@ class Bundle /** * Setting Bundle Items Data to product for father processing * + * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject * @param \Magento\Catalog\Model\Product $product + * * @return \Magento\Catalog\Model\Product + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterInitialize(\Magento\Catalog\Model\Product $product) - { + public function afterInitialize( + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject, + \Magento\Catalog\Model\Product $product + ) { if (($items = $this->request->getPost('bundle_options')) && !$product->getCompositeReadonly()) { $product->setBundleOptionsData($items); } diff --git a/app/code/Magento/Bundle/Model/Plugin/QuoteItem.php b/app/code/Magento/Bundle/Model/Plugin/QuoteItem.php index 1c2ecb0f5dd..d7aefc56d56 100644 --- a/app/code/Magento/Bundle/Model/Plugin/QuoteItem.php +++ b/app/code/Magento/Bundle/Model/Plugin/QuoteItem.php @@ -28,18 +28,22 @@ class QuoteItem /** * Add bundle attributes to order data * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\Sales\Model\Convert\Quote $subject + * @param callable $proceed + * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item + * * @return \Magento\Sales\Model\Order\Item|mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundItemToOrderItem(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { + public function aroundItemToOrderItem( + \Magento\Sales\Model\Convert\Quote $subject, + \Closure $proceed, + \Magento\Sales\Model\Quote\Item\AbstractItem $item + ) { /** @var $orderItem \Magento\Sales\Model\Order\Item */ - $orderItem = $invocationChain->proceed($arguments); - /** @var $quoteItem \Magento\Sales\Model\Quote\Item */ - $quoteItem = reset($arguments); + $orderItem = $proceed($item); - if ($attributes = $quoteItem->getProduct()->getCustomOption('bundle_selection_attributes')) { + if ($attributes = $item->getProduct()->getCustomOption('bundle_selection_attributes')) { $productOptions = $orderItem->getProductOptions(); $productOptions['bundle_selection_attributes'] = $attributes->getValue(); $orderItem->setProductOptions($productOptions); diff --git a/app/code/Magento/Bundle/Model/Product/Price.php b/app/code/Magento/Bundle/Model/Product/Price.php index 54c4bd514f1..673acb9bbca 100644 --- a/app/code/Magento/Bundle/Model/Product/Price.php +++ b/app/code/Magento/Bundle/Model/Product/Price.php @@ -62,7 +62,7 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price * * @param \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Tax\Helper\Data $taxData @@ -70,13 +70,13 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price public function __construct( \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Event\ManagerInterface $eventManager, \Magento\Tax\Helper\Data $taxData ) { $this->_taxData = $taxData; - parent::__construct($ruleFactory, $storeManager, $locale, $customerSession, $eventManager); + parent::__construct($ruleFactory, $storeManager, $localeDate, $customerSession, $eventManager); } public function getIsPricesCalculatedByIndex() diff --git a/app/code/Magento/Bundle/Model/Resource/Price/Index.php b/app/code/Magento/Bundle/Model/Resource/Price/Index.php index 7af95b08297..aa2bda3ce72 100644 --- a/app/code/Magento/Bundle/Model/Resource/Price/Index.php +++ b/app/code/Magento/Bundle/Model/Resource/Price/Index.php @@ -80,9 +80,9 @@ class Index extends \Magento\Core\Model\Resource\Db\AbstractDb protected $_catalogRuleFactory; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @var \Magento\Core\Model\StoreManagerInterface @@ -92,7 +92,7 @@ class Index extends \Magento\Core\Model\Resource\Db\AbstractDb /** * @param \Magento\App\Resource $resource * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\CatalogRule\Model\Resource\RuleFactory $catalogRuleFactory * @param \Magento\Customer\Model\GroupFactory $customerGroup * @param \Magento\Catalog\Model\Config $config @@ -101,7 +101,7 @@ class Index extends \Magento\Core\Model\Resource\Db\AbstractDb public function __construct( \Magento\App\Resource $resource, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\CatalogRule\Model\Resource\RuleFactory $catalogRuleFactory, \Magento\Customer\Model\GroupFactory $customerGroup, \Magento\Catalog\Model\Config $config, @@ -112,7 +112,7 @@ class Index extends \Magento\Core\Model\Resource\Db\AbstractDb $this->_config = $config; $this->_customerGroup = $customerGroup; $this->_catalogRuleFactory = $catalogRuleFactory; - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_storeManager = $storeManager; } @@ -545,7 +545,7 @@ class Index extends \Magento\Core\Model\Resource\Db\AbstractDb protected function _getBasePrice($productId, array $priceData, $website, $customerGroup) { $store = $website->getDefaultStore(); - $storeTimeStamp = $this->_locale->storeTimeStamp($store); + $storeTimeStamp = $this->_localeDate->scopeTimeStamp($store); $finalPrice = $this->_calculateSpecialPrice($priceData['price'], $priceData, $website); $rulePrice = $this->_catalogRuleFactory->create() @@ -842,7 +842,7 @@ class Index extends \Magento\Core\Model\Resource\Db\AbstractDb $specialPrice = $priceData['special_price']; if (!is_null($specialPrice) && $specialPrice != false) { - if ($this->_locale->isStoreDateInInterval($store, $priceData['special_from_date'], + if ($this->_localeDate->isScopeDateInInterval($store, $priceData['special_from_date'], $priceData['special_to_date'])) { $specialPrice = ($finalPrice * $specialPrice) / 100; $finalPrice = min($finalPrice, $specialPrice); diff --git a/app/code/Magento/Bundle/view/adminhtml/js/bundle-product.js b/app/code/Magento/Bundle/view/adminhtml/js/bundle-product.js index 71f4e360075..b5b11c98aa8 100644 --- a/app/code/Magento/Bundle/view/adminhtml/js/bundle-product.js +++ b/app/code/Magento/Bundle/view/adminhtml/js/bundle-product.js @@ -111,8 +111,8 @@ $selectionGrid.dialog({ title: $optionBox.find('input[name$="[title]"]').val() === '' ? $.mage.__('Add Products to New Option') : - $.mage.__('Add Products to Option "%s"') - .replace('%s',($('<div>').text($optionBox.find('input[name$="[title]"]').val()).html())), + $.mage.__('Add Products to Option "%1"') + .replace('%1',($('<div>').text($optionBox.find('input[name$="[title]"]').val()).html())), autoOpen: false, minWidth: 980, 'class': 'bundle', diff --git a/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_item_renderers.xml b/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_item_renderers.xml index a73407879fd..41dda14a4ed 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_item_renderers.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_item_renderers.xml @@ -25,6 +25,6 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceBlock name="checkout.cart.item.renderers"> - <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::cart/item/default.phtml" cacheable="false"/> + <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::cart/item/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml b/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml index 1412ba97b33..0341c1198db 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml @@ -25,6 +25,6 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceBlock name="checkout.cart.sidebar.item.renderers"> - <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::cart/sidebar/default.phtml" cacheable="false"/> + <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::cart/sidebar/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/checkout_onepage_review_item_renderers.xml b/app/code/Magento/Bundle/view/frontend/layout/checkout_onepage_review_item_renderers.xml index 53bc55d854c..c16893c8334 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/checkout_onepage_review_item_renderers.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/checkout_onepage_review_item_renderers.xml @@ -25,6 +25,5 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceBlock name="checkout.onepage.review.item.renderers"> - <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::onepage/review/item.phtml" cacheable="false"/> - </referenceBlock> + <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::onepage/review/item.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/CacheInvalidate/Helper/Data.php b/app/code/Magento/CacheInvalidate/Helper/Data.php new file mode 100644 index 00000000000..83f77f87a79 --- /dev/null +++ b/app/code/Magento/CacheInvalidate/Helper/Data.php @@ -0,0 +1,44 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * Page cache data helper + * + * @category Magento + * @package Magento_CacheInvalidate + */ +namespace Magento\CacheInvalidate\Helper; + +/** + * Class Data + */ +class Data extends \Magento\App\Helper\AbstractHelper +{ + /** + * Retrieve url + * + * @param string $route + * @param array $params + * @return string + */ + public function getUrl($route, array $params = array()) + { + return $this->_getUrl($route, $params); + } +} diff --git a/app/code/Magento/CacheInvalidate/Model/Observer.php b/app/code/Magento/CacheInvalidate/Model/Observer.php new file mode 100644 index 00000000000..df8f5426100 --- /dev/null +++ b/app/code/Magento/CacheInvalidate/Model/Observer.php @@ -0,0 +1,110 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_CacheInvalidate + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\CacheInvalidate\Model; + +/** + * Class Observer + */ +class Observer +{ + /** + * Application config object + * + * @var \Magento\App\ConfigInterface + */ + protected $_config; + + /** + * @var \Magento\CacheInvalidate\Helper\Data + */ + protected $_helper; + + /** + * @var \Magento\HTTP\Adapter\Curl + */ + protected $_curlAdapter; + + /** + * Constructor + * + * @param \Magento\PageCache\Model\Config $config + * @param \Magento\PageCache\Helper\Data $helper + * @param \Magento\HTTP\Adapter\Curl $curlAdapter + */ + public function __construct( + \Magento\PageCache\Model\Config $config, + \Magento\PageCache\Helper\Data $helper, + \Magento\HTTP\Adapter\Curl $curlAdapter + ){ + $this->_config = $config; + $this->_helper = $helper; + $this->_curlAdapter = $curlAdapter; + } + + /** + * If Varnish caching is enabled it collects array of tags + * of incoming object and asks to clean cache. + * + * @param \Magento\Event\Observer $observer + */ + public function invalidateVarnish(\Magento\Event\Observer $observer) + { + $object = $observer->getEvent()->getObject(); + if($object instanceof \Magento\Object\IdentityInterface) { + if($this->_config->getType() == \Magento\PageCache\Model\Config::VARNISH) { + $this->sendPurgeRequest(implode('|', $object->getIdentities())); + } + } + } + + /** + * Flash Varnish cache + * + * @param \Magento\Event\Observer $observer + */ + public function flushAllCache(\Magento\Event\Observer $observer) + { + if($this->_config->getType() == \Magento\PageCache\Model\Config::VARNISH) { + $this->sendPurgeRequest('.*'); + } + } + + /** + * Send curl purge request + * to invalidate cache by tags pattern + * + * @param string $tagsPattern + */ + protected function sendPurgeRequest($tagsPattern) + { + $headers = array("X-Magento-Tags-Pattern: {$tagsPattern}"); + $this->_curlAdapter->setOptions(array(CURLOPT_CUSTOMREQUEST => 'PURGE')); + $this->_curlAdapter->write('', $this->_helper->getUrl('*'), '1.1', $headers); + $this->_curlAdapter->read(); + $this->_curlAdapter->close(); + } +} diff --git a/app/code/Magento/CacheInvalidate/etc/events.xml b/app/code/Magento/CacheInvalidate/etc/events.xml new file mode 100644 index 00000000000..0f81b70a89e --- /dev/null +++ b/app/code/Magento/CacheInvalidate/etc/events.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <event name="clean_cache_by_tags"> + <observer name="invalidate_varnish" instance="Magento\CacheInvalidate\Model\Observer" method="invalidateVarnish" /> + </event> + <event name="adminhtml_cache_flush_system"> + <observer name="flush_varnish_pagecache" instance="Magento\CacheInvalidate\Model\Observer" method="flushAllCache" /> + </event> +</config> diff --git a/app/code/Magento/CacheInvalidate/etc/module.xml b/app/code/Magento/CacheInvalidate/etc/module.xml new file mode 100644 index 00000000000..ca0f2f6df18 --- /dev/null +++ b/app/code/Magento/CacheInvalidate/etc/module.xml @@ -0,0 +1,35 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <module name="Magento_CacheInvalidate" version="1.6.0.0" active="false"> + <sequence> + <module name="Magento_Core"/> + </sequence> + <depends> + <module name="Magento_PageCache"/> + </depends> + </module> +</config> diff --git a/app/code/Magento/Captcha/Model/Resource/Log.php b/app/code/Magento/Captcha/Model/Resource/Log.php index 8aebf8288e5..9473592319b 100644 --- a/app/code/Magento/Captcha/Model/Resource/Log.php +++ b/app/code/Magento/Captcha/Model/Resource/Log.php @@ -45,7 +45,7 @@ class Log extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Core Date * - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_coreDate; @@ -56,12 +56,12 @@ class Log extends \Magento\Core\Model\Resource\Db\AbstractDb /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\Date $coreDate + * @param \Magento\Stdlib\DateTime\DateTime $coreDate * @param \Magento\HTTP\PhpEnvironment\RemoteAddress $remoteAddress */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\Date $coreDate, + \Magento\Stdlib\DateTime\DateTime $coreDate, \Magento\HTTP\PhpEnvironment\RemoteAddress $remoteAddress ) { $this->_coreDate = $coreDate; diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php index 421af44996e..87c3b234678 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php @@ -140,7 +140,7 @@ class Advanced extends Generic ) ); - $dateFormat = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $dateFormat = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); $fieldset->addField( 'default_value_date', 'date', diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php index 235fa89f8ad..3392ae331b8 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php @@ -32,6 +32,7 @@ * @author Magento Core Team <core@magentocommerce.com> */ namespace Magento\Catalog\Block\Adminhtml\Product; +use Magento\Core\Model\Store; class Grid extends \Magento\Backend\Block\Widget\Grid\Extended { @@ -124,7 +125,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended } /** - * @return \Magento\Core\Model\Store + * @return Store */ protected function _getStore() { diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php index 6d309bb0180..750cb2e0a16 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Price.php @@ -48,16 +48,16 @@ class Price extends \Magento\Data\Form\Element\Text protected $_storeManager; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\CurrencyInterface */ - protected $_locale; + protected $_localeCurrency; /** * @param \Magento\Data\Form\Element\Factory $factoryElement * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection * @param \Magento\Escaper $escaper * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\CurrencyInterface $localeCurrency * @param \Magento\Tax\Helper\Data $taxData * @param array $data */ @@ -66,11 +66,11 @@ class Price extends \Magento\Data\Form\Element\Text \Magento\Data\Form\Element\CollectionFactory $factoryCollection, \Magento\Escaper $escaper, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\CurrencyInterface $localeCurrency, \Magento\Tax\Helper\Data $taxData, array $data = array() ) { - $this->_locale = $locale; + $this->_localeCurrency = $localeCurrency; $this->_storeManager = $storeManager; $this->_taxData = $taxData; parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -100,7 +100,7 @@ class Price extends \Magento\Data\Form\Element\Text $storeId = $this->getForm()->getDataObject()->getStoreId(); } $store = $this->_storeManager->getStore($storeId); - $html .= '<strong>' . $this->_locale->currency($store->getBaseCurrencyCode())->getSymbol() . '</strong>'; + $html .= '<strong>' . $this->_localeCurrency->getCurrency($store->getBaseCurrencyCode())->getSymbol() . '</strong>'; if ($this->_taxData->priceIncludesTax($store)) { if ($attribute->getAttributeCode()!=='cost') { $addJsObserver = true; diff --git a/app/code/Magento/Catalog/Block/Category/View.php b/app/code/Magento/Catalog/Block/Category/View.php index fbd25bc687a..ccc1d6dd476 100644 --- a/app/code/Magento/Catalog/Block/Category/View.php +++ b/app/code/Magento/Catalog/Block/Category/View.php @@ -33,7 +33,7 @@ */ namespace Magento\Catalog\Block\Category; -class View extends \Magento\View\Element\Template +class View extends \Magento\View\Element\Template implements \Magento\View\Block\IdentityInterface { /** * Core registry @@ -228,4 +228,14 @@ class View extends \Magento\View\Element\Template } return $res; } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + return $this->getCurrentCategory()->getIdentities(); + } } diff --git a/app/code/Magento/Catalog/Block/Navigation.php b/app/code/Magento/Catalog/Block/Navigation.php index bfdceeefa76..675a8913792 100644 --- a/app/code/Magento/Catalog/Block/Navigation.php +++ b/app/code/Magento/Catalog/Block/Navigation.php @@ -32,7 +32,7 @@ use Magento\Catalog\Model\Category; * * @SuppressWarnings(PHPMD.LongVariable) */ -class Navigation extends \Magento\View\Element\Template +class Navigation extends \Magento\View\Element\Template implements \Magento\View\Block\IdentityInterface { /** * @var Category @@ -503,4 +503,14 @@ class Navigation extends \Magento\View\Element\Template return $html; } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + return array(\Magento\Catalog\Model\Category::CACHE_TAG, \Magento\Core\Model\Store\Group::CACHE_TAG); + } } diff --git a/app/code/Magento/Catalog/Block/Product/Compare/Sidebar.php b/app/code/Magento/Catalog/Block/Product/Compare/Sidebar.php index 2bb946859c5..457fc2f63d4 100644 --- a/app/code/Magento/Catalog/Block/Product/Compare/Sidebar.php +++ b/app/code/Magento/Catalog/Block/Product/Compare/Sidebar.php @@ -35,6 +35,7 @@ namespace Magento\Catalog\Block\Product\Compare; class Sidebar extends \Magento\Catalog\Block\Product\Compare\AbstractCompare + implements \Magento\View\Block\IdentityInterface { /** * Compare Products Collection @@ -105,4 +106,22 @@ class Sidebar extends \Magento\Catalog\Block\Product\Compare\AbstractCompare { return $this->_getHelper()->getListUrl(); } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + $identities = array(); + foreach($this->getItems() as $item) { + $product = $item->getProduct(); + if ($product instanceof \Magento\Object\IdentityInterface) { + $identities[] = $product->getIdentities(); + } + } + $identities[] = \Magento\Catalog\Model\Product\Compare\Item::CACHE_TAG . '_' . $this->getCatalogCompareItemId(); + return $identities; + } } diff --git a/app/code/Magento/Catalog/Block/Product/ListProduct.php b/app/code/Magento/Catalog/Block/Product/ListProduct.php index e36830e5a14..ae2e4a614d8 100644 --- a/app/code/Magento/Catalog/Block/Product/ListProduct.php +++ b/app/code/Magento/Catalog/Block/Product/ListProduct.php @@ -38,6 +38,7 @@ use Magento\Eav\Model\Entity\Collection\AbstractCollection; use Magento\View\Element\AbstractBlock; class ListProduct extends \Magento\Catalog\Block\Product\AbstractProduct + implements \Magento\View\Block\IdentityInterface { /** * Default toolbar block name @@ -348,4 +349,18 @@ class ListProduct extends \Magento\Catalog\Block\Product\AbstractProduct return $this; } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + $identities = array(); + foreach ($this->_getProductCollection() as $item) { + $identities = array_merge($identities, $item->getIdentities()); + } + return array_merge($this->getLayer()->getCurrentCategory()->getIdentities(), $identities); + } } diff --git a/app/code/Magento/Catalog/Block/Product/NewProduct.php b/app/code/Magento/Catalog/Block/Product/NewProduct.php index 69e82649a41..b9066e047fb 100644 --- a/app/code/Magento/Catalog/Block/Product/NewProduct.php +++ b/app/code/Magento/Catalog/Block/Product/NewProduct.php @@ -32,6 +32,7 @@ namespace Magento\Catalog\Block\Product; * @SuppressWarnings(PHPMD.LongVariable) */ class NewProduct extends \Magento\Catalog\Block\Product\AbstractProduct + implements \Magento\View\Block\IdentityInterface { /** * Default value for products count that will be shown @@ -168,11 +169,11 @@ class NewProduct extends \Magento\Catalog\Block\Product\AbstractProduct */ protected function _getProductCollection() { - $todayStartOfDayDate = $this->_locale->date() + $todayStartOfDayDate = $this->_localeDate->date() ->setTime('00:00:00') ->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); - $todayEndOfDayDate = $this->_locale->date() + $todayEndOfDayDate = $this->_localeDate->date() ->setTime('23:59:59') ->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); @@ -240,4 +241,14 @@ class NewProduct extends \Magento\Catalog\Block\Product\AbstractProduct } return $this->_productsCount; } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + return array(\Magento\Catalog\Model\Product::CACHE_TAG); + } } diff --git a/app/code/Magento/Catalog/Block/Product/Price.php b/app/code/Magento/Catalog/Block/Product/Price.php index 199ee331d60..65848296c51 100644 --- a/app/code/Magento/Catalog/Block/Product/Price.php +++ b/app/code/Magento/Catalog/Block/Product/Price.php @@ -33,7 +33,7 @@ */ namespace Magento\Catalog\Block\Product; -class Price extends \Magento\View\Element\Template +class Price extends \Magento\View\Element\Template implements \Magento\View\Block\IdentityInterface { /** * @var null @@ -280,4 +280,14 @@ class Price extends \Magento\View\Element\Template { return $this->mathRandom->getRandomString($length, $chars); } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + return $this->getProduct()->getIdentities(); + } } diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Related.php b/app/code/Magento/Catalog/Block/Product/ProductList/Related.php index b1286581aac..2d7c65619cc 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Related.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Related.php @@ -33,7 +33,7 @@ use Magento\View\Element\AbstractBlock; * * @SuppressWarnings(PHPMD.LongVariable) */ -class Related extends \Magento\Catalog\Block\Product\AbstractProduct +class Related extends \Magento\Catalog\Block\Product\AbstractProduct implements \Magento\View\Block\IdentityInterface { /** * Default MAP renderer type @@ -176,4 +176,18 @@ class Related extends \Magento\Catalog\Block\Product\AbstractProduct { return $this->_itemCollection; } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + $identities = array(); + foreach ($this->getItems() as $item) { + $identities[] = $item->getIdentities(); + } + return $identities; + } } diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php b/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php index 415cdad407a..b54eb3ba097 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php @@ -34,7 +34,7 @@ use Magento\View\Element\AbstractBlock; * * @SuppressWarnings(PHPMD.LongVariable) */ -class Upsell extends \Magento\Catalog\Block\Product\AbstractProduct +class Upsell extends \Magento\Catalog\Block\Product\AbstractProduct implements \Magento\View\Block\IdentityInterface { /** * Default MAP renderer type @@ -293,4 +293,18 @@ class Upsell extends \Magento\Catalog\Block\Product\AbstractProduct return 0; } } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + $identities = array(); + foreach ($this->getItems() as $item) { + $identities[] = $item->getIdentities(); + } + return $identities; + } } diff --git a/app/code/Magento/Catalog/Block/Product/View.php b/app/code/Magento/Catalog/Block/Product/View.php index f746af32736..6c54512131f 100644 --- a/app/code/Magento/Catalog/Block/Product/View.php +++ b/app/code/Magento/Catalog/Block/Product/View.php @@ -29,7 +29,7 @@ namespace Magento\Catalog\Block\Product; /** * Product View block */ -class View extends \Magento\Catalog\Block\Product\AbstractProduct +class View extends \Magento\Catalog\Block\Product\AbstractProduct implements \Magento\View\Block\IdentityInterface { /** * Default MAP renderer type @@ -79,6 +79,11 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct */ protected $productTypeConfig; + /** + * @var \Magento\Locale\FormatInterface + */ + protected $_localeFormat; + /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Catalog\Model\Config $catalogConfig @@ -98,6 +103,7 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct * @param \Magento\Stdlib\String $string * @param \Magento\Catalog\Helper\Product $productHelper * @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig + * @param \Magento\Locale\FormatInterface $localeFormat * @param array $data * @param array $priceBlockTypes * @@ -122,6 +128,7 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct \Magento\Stdlib\String $string, \Magento\Catalog\Helper\Product $productHelper, \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig, + \Magento\Locale\FormatInterface $localeFormat, array $data = array(), array $priceBlockTypes = array() ) { @@ -132,6 +139,7 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct $this->_taxCalculation = $taxCalculation; $this->productTypeConfig = $productTypeConfig; $this->string = $string; + $this->_localeFormat = $localeFormat; parent::__construct( $context, $catalogConfig, @@ -286,7 +294,7 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct } $config = array( 'productId' => $product->getId(), - 'priceFormat' => $this->_locale->getJsPriceFormat(), + 'priceFormat' => $this->_localeFormat->getPriceFormat(), 'includeTax' => $this->_taxData->priceIncludesTax() ? 'true' : 'false', 'showIncludeTax' => $this->_taxData->displayPriceIncludingTax(), 'showBothPrices' => $this->_taxData->displayBothPrices(), @@ -395,4 +403,14 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct { return !$this->productTypeConfig->isProductSet($this->getProduct()->getTypeId()); } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + return $this->getProduct()->getIdentities(); + } } diff --git a/app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php b/app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php index 23a61640673..58fb9654222 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php +++ b/app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php @@ -122,7 +122,7 @@ class Date extends \Magento\Catalog\Block\Product\View\Options\AbstractOptions ->setName('options['.$this->getOption()->getId().'][date]') ->setClass('product-custom-option datetime-picker input-text') ->setImage($this->getViewFileUrl('Magento_Core::calendar.gif')) - ->setDateFormat($this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT)) + ->setDateFormat($this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT)) ->setValue($value) ->setYearsRange($yearStart . ':' . $yearEnd); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php index 0eb5f9d7506..59587fde202 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php @@ -315,8 +315,7 @@ class Category extends \Magento\Backend\App\Action $category->setAttributeSetId($category->getDefaultAttributeSetId()); if (isset($data['category_products']) && !$category->getProductsReadonly()) { - $products = array(); - parse_str($data['category_products'], $products); + $products = json_decode($data['category_products'], true); $category->setPostedProducts($products); } $this->_eventManager->dispatch( diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product.php index 543ea434758..11acf976146 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product.php @@ -53,7 +53,7 @@ class Product extends \Magento\Backend\App\Action protected $registry = null; /** - * @var \Magento\Core\Filter\Date + * @var \Magento\Stdlib\DateTime\Filter\Date */ protected $_dateFilter; @@ -90,7 +90,7 @@ class Product extends \Magento\Backend\App\Action /** * @param Action\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Filter\Date $dateFilter + * @param \Magento\Stdlib\DateTime\Filter\Date $dateFilter * @param Product\Initialization\Helper $initializationHelper * @param Product\Initialization\StockDataFilter $stockFilter * @param \Magento\Catalog\Model\Product\Copier $productCopier @@ -101,7 +101,7 @@ class Product extends \Magento\Backend\App\Action public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Registry $registry, - \Magento\Core\Filter\Date $dateFilter, + \Magento\Stdlib\DateTime\Filter\Date $dateFilter, \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $initializationHelper, \Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter $stockFilter, \Magento\Catalog\Model\Product\Copier $productCopier, diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php index e2a20429b53..34ff4580d27 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute.php @@ -96,8 +96,8 @@ class Attribute extends Action try { if ($attributesData) { - $dateFormat = $this->_objectManager->get('Magento\Core\Model\LocaleInterface') - ->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $dateFormat = $this->_objectManager->get('Magento\Stdlib\DateTime\TimezoneInterface') + ->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); $storeId = $this->_helper->getSelectedStoreId(); foreach ($attributesData as $attributeCode => $value) { diff --git a/app/code/Magento/Catalog/Helper/Product/Composite.php b/app/code/Magento/Catalog/Helper/Product/Composite.php index 9eaa3849816..1f027a15eb2 100644 --- a/app/code/Magento/Catalog/Helper/Product/Composite.php +++ b/app/code/Magento/Catalog/Helper/Product/Composite.php @@ -25,6 +25,8 @@ */ namespace Magento\Catalog\Helper\Product; +use Magento\Customer\Controller\RegistryConstants; + /** * Adminhtml catalog product composite helper * @@ -41,11 +43,11 @@ class Composite extends \Magento\App\Helper\AbstractHelper */ protected $_coreRegistry = null; - /** - * Catalog product - * - * @var \Magento\Catalog\Helper\Product - */ + /** + * Catalog product + * + * @var \Magento\Catalog\Helper\Product + */ protected $_catalogProduct = null; /** @@ -166,7 +168,7 @@ class Composite extends \Magento\App\Helper\AbstractHelper throw new \Magento\Core\Exception($configureResult->getMessage()); }; - $currentStoreId = (int) $configureResult->getCurrentStoreId(); + $currentStoreId = (int)$configureResult->getCurrentStoreId(); if (!$currentStoreId) { $currentStoreId = $this->_storeManager->getStore()->getId(); } @@ -183,13 +185,13 @@ class Composite extends \Magento\App\Helper\AbstractHelper // Register customer we're working with $currentCustomer = $configureResult->getCurrentCustomer(); if (!$currentCustomer) { - $currentCustomerId = (int) $configureResult->getCurrentCustomerId(); + $currentCustomerId = (int)$configureResult->getCurrentCustomerId(); if ($currentCustomerId) { $currentCustomer = $this->_customerFactory->create()->load($currentCustomerId); } } if ($currentCustomer) { - $this->_coreRegistry->register('current_customer', $currentCustomer); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER, $currentCustomer); } // Prepare buy request values diff --git a/app/code/Magento/Catalog/Helper/Product/Edit/Action/Attribute.php b/app/code/Magento/Catalog/Helper/Product/Edit/Action/Attribute.php index 6f3a8fc4659..de9b9aacbc5 100644 --- a/app/code/Magento/Catalog/Helper/Product/Edit/Action/Attribute.php +++ b/app/code/Magento/Catalog/Helper/Product/Edit/Action/Attribute.php @@ -70,7 +70,7 @@ class Attribute extends \Magento\Backend\Helper\Data /** * @param \Magento\App\Helper\Context $context * @param \Magento\App\Route\Config $routeConfig - * @param \Magento\AppInterface $app + * @param \Magento\Locale\ResolverInterface $locale * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Backend\Model\Auth $auth * @param \Magento\Backend\App\Area\FrontNameResolver $frontNameResolver @@ -82,7 +82,7 @@ class Attribute extends \Magento\Backend\Helper\Data public function __construct( \Magento\App\Helper\Context $context, \Magento\App\Route\Config $routeConfig, - \Magento\AppInterface $app, + \Magento\Locale\ResolverInterface $locale, \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Backend\Model\Auth $auth, \Magento\Backend\App\Area\FrontNameResolver $frontNameResolver, @@ -94,7 +94,9 @@ class Attribute extends \Magento\Backend\Helper\Data $this->_eavConfig = $eavConfig; $this->_session = $session; $this->_productsFactory = $productsFactory; - parent::__construct($context, $routeConfig, $app, $backendUrl, $auth, $frontNameResolver, $mathRandom); + parent::__construct( + $context, $routeConfig, $locale, $backendUrl, $auth, $frontNameResolver, $mathRandom + ); } /** diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php index 13a77872b55..63358691525 100644 --- a/app/code/Magento/Catalog/Model/Category.php +++ b/app/code/Magento/Catalog/Model/Category.php @@ -35,7 +35,7 @@ namespace Magento\Catalog\Model; * * @SuppressWarnings(PHPMD.LongVariable) */ -class Category extends \Magento\Catalog\Model\AbstractModel +class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\Object\IdentityInterface { /** * Entity code. @@ -1095,4 +1095,14 @@ class Category extends \Magento\Catalog\Model\AbstractModel $this->reindex(); return parent::_afterDeleteCommit(); } + + /** + * Get identities + * + * @return array + */ + public function getIdentities() + { + return array(self::CACHE_TAG . '_' . $this->getId()); + } } diff --git a/app/code/Magento/Catalog/Model/Design.php b/app/code/Magento/Catalog/Model/Design.php index 6a4ff5a355e..2c2012e243b 100644 --- a/app/code/Magento/Catalog/Model/Design.php +++ b/app/code/Magento/Catalog/Model/Design.php @@ -45,16 +45,14 @@ class Design extends \Magento\Core\Model\AbstractModel protected $_design = null; /** - * Locale - * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\View\DesignInterface $design * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -63,13 +61,13 @@ class Design extends \Magento\Core\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\View\DesignInterface $design, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_design = $design; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -112,7 +110,7 @@ class Design extends \Magento\Core\Model\AbstractModel return $this->_extractSettings($object); } } else { - return $this->_extractSettings($category); + return $this->_extractSettings($category); } } @@ -130,10 +128,10 @@ class Design extends \Magento\Core\Model\AbstractModel } $date = $object->getCustomDesignDate(); if (array_key_exists('from', $date) && array_key_exists('to', $date) - && $this->_locale->isStoreDateInInterval(null, $date['from'], $date['to'])) { - $settings->setCustomDesign($object->getCustomDesign()) - ->setPageLayout($object->getPageLayout()) - ->setLayoutUpdates((array)$object->getCustomLayoutUpdate()); + && $this->_localeDate->isScopeDateInInterval(null, $date['from'], $date['to'])) { + $settings->setCustomDesign($object->getCustomDesign()) + ->setPageLayout($object->getPageLayout()) + ->setLayoutUpdates((array)$object->getCustomLayoutUpdate()); } return $settings; } diff --git a/app/code/Magento/Catalog/Model/Entity/Attribute.php b/app/code/Magento/Catalog/Model/Entity/Attribute.php index ac657aaa3d0..5a1057b55ad 100644 --- a/app/code/Magento/Catalog/Model/Entity/Attribute.php +++ b/app/code/Magento/Catalog/Model/Entity/Attribute.php @@ -66,12 +66,7 @@ use \Magento\Catalog\Model\Attribute\LockValidatorInterface; * @method \Magento\Catalog\Model\Entity\Attribute setIsWysiwygEnabled(int $value) * @method int getIsUsedForPromoRules() * @method \Magento\Catalog\Model\Entity\Attribute setIsUsedForPromoRules(int $value) - * - * @category Magento - * @package Magento_Catalog - * @author Magento Core Team <core@magentocommerce.com> */ - class Attribute extends \Magento\Eav\Model\Entity\Attribute { /** @@ -104,7 +99,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Validator\UniversalFactory $universalFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Catalog\Model\ProductFactory $catalogProductFactory * @param LockValidatorInterface $lockValidator * @param \Magento\Core\Model\Resource\AbstractResource $resource @@ -120,8 +115,9 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Validator\UniversalFactory $universalFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Catalog\Model\ProductFactory $catalogProductFactory, + \Magento\Locale\ResolverInterface $localeResolver, LockValidatorInterface $lockValidator, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, @@ -137,8 +133,9 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute $storeManager, $resourceHelper, $universalFactory, - $locale, + $localeDate, $catalogProductFactory, + $localeResolver, $resource, $resourceCollection, $data diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/IndexerConfigData.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/IndexerConfigData.php index 9eb313c6286..8161f2a9300 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/IndexerConfigData.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/IndexerConfigData.php @@ -39,24 +39,32 @@ class IndexerConfigData } /** - * Unset indexer data in configuration if flat is disabled + * Unset indexer data in configuration if flat is disabled + * + * @param \Magento\Indexer\Model\Config\Data $subject + * @param callable $proceed + * @param string $path + * @param mixed $default * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain * @return mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundGet(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - $data = $invocationChain->proceed($arguments); + public function aroundGet( + \Magento\Indexer\Model\Config\Data $subject, + \Closure $proceed, + $path = null, + $default = null + ) { + $data = $proceed($path, $default); if (!$this->state->isFlatEnabled()) { $indexerId = \Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID; - if ((!isset($arguments['path']) || !$arguments['path']) && isset($data[$indexerId])) { + if (!$path && isset($data[$indexerId])) { unset($data[$indexerId]); - } elseif (isset($arguments['path'])) { - list($firstKey, ) = explode('/', $arguments['path']); + } elseif ($path) { + list($firstKey, ) = explode('/', $path); if ($firstKey == $indexerId) { - $data = isset($arguments['default']) ? $arguments['default'] : null; + $data = $default ?: null; } } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php index e63de758571..ef4edbe733d 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroup.php @@ -70,18 +70,22 @@ class StoreGroup { return $group->dataHasChangedFor('root_category_id') && !$group->isObjectNew(); } - + /** - * Process to invalidate indexer + * @param \Magento\Core\Model\Resource\Db\AbstractDb $subject + * @param callable $proceed + * @param \Magento\Core\Model\AbstractModel $group * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundSave(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - $needInvalidating = $this->validate($arguments[0]); - $objectResource = $invocationChain->proceed($arguments); + public function aroundSave( + \Magento\Core\Model\Resource\Db\AbstractDb $subject, + \Closure $proceed, + \Magento\Core\Model\AbstractModel $group + ) { + $needInvalidating = $this->validate($group); + $objectResource = $proceed($group); if ($needInvalidating && $this->state->isFlatEnabled()) { $this->getIndexer()->invalidate(); } diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php index 3e5d5b02a50..f415626de72 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroup.php @@ -53,16 +53,18 @@ class StoreGroup } /** - * Process to invalidate indexer - * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @param \Magento\Core\Model\Resource\Db\AbstractDb $subject + * @param callable $proceed + * @param \Magento\Core\Model\AbstractModel $group + * @return mixed */ - public function aroundSave(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - $needInvalidating = $this->validate($arguments[0]); - $objectResource = $invocationChain->proceed($arguments); + public function aroundSave( + \Magento\Core\Model\Resource\Db\AbstractDb $subject, + \Closure $proceed, + \Magento\Core\Model\AbstractModel $group + ) { + $needInvalidating = $this->validate($group); + $objectResource = $proceed($group); if ($needInvalidating) { $this->getIndexer()->invalidate(); } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/Import.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/Import.php index e72178db3a2..a8df6ba9f13 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/Import.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/Import.php @@ -45,10 +45,13 @@ class Import /** * After improt handler * + * @param \Magento\ImportExport\Model\Import $subject * @param Object $import + * * @return mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterImportSource($import) + public function afterImportSource(\Magento\ImportExport\Model\Import $subject, $import) { $this->_productFlatIndexerProcessor->markIndexerAsInvalid(); return $import; diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/IndexerConfigData.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/IndexerConfigData.php index 8d2956b1135..eaf1914a82d 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/IndexerConfigData.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/IndexerConfigData.php @@ -45,23 +45,31 @@ class IndexerConfigData /** * Around get handler * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\Indexer\Model\Config\Data $subject + * @param callable $proceed + * @param string $path + * @param string $default * * @return mixed|null + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * */ - public function aroundGet(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - $data = $invocationChain->proceed($arguments); + public function aroundGet( + \Magento\Indexer\Model\Config\Data $subject, + \Closure $proceed, + $path = null, + $default = null + ) { + $data = $proceed($path, $default); if (!$this->_state->isFlatEnabled()) { $indexerId = \Magento\Catalog\Model\Indexer\Product\Flat\Processor::INDEXER_ID; - if ((!isset($arguments['path']) || !$arguments['path']) && isset($data[$indexerId])) { + if (!$path && isset($data[$indexerId])) { unset($data[$indexerId]); - } elseif (isset($arguments['path'])) { - list($firstKey, ) = explode('/', $arguments['path']); + } elseif ($path) { + list($firstKey, ) = explode('/', $path); if ($firstKey == $indexerId) { - $data = isset($arguments['default']) ? $arguments['default'] : null; + $data = $default ?: null; } } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/Store.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/Store.php index d185c6f97b4..04e52a583c1 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/Store.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/Store.php @@ -29,6 +29,8 @@ namespace Magento\Catalog\Model\Indexer\Product\Flat\Plugin; class Store { /** + * Product flat indexer processor + * * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor */ protected $_productFlatIndexerProcessor; @@ -45,16 +47,16 @@ class Store /** * Before save handler * - * @param array $methodArguments - * @return array + * @param \Magento\Core\Model\Resource\Store $subject + * @param \Magento\Core\Model\AbstractModel $object + * + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeSave(array $methodArguments) + public function beforeSave(\Magento\Core\Model\Resource\Store $subject, \Magento\Core\Model\AbstractModel $object) { - /** @var $store \Magento\Core\Model\Store */ - $store = $methodArguments[0]; - if (!$store->getId() || $store->dataHasChangedFor('group_id')) { + if (!$object->getId() || $object->dataHasChangedFor('group_id')) { $this->_productFlatIndexerProcessor->markIndexerAsInvalid(); } - return $methodArguments; } } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreGroup.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreGroup.php index c5b7ea9b871..f9a085fc58b 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreGroup.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreGroup.php @@ -29,6 +29,8 @@ namespace Magento\Catalog\Model\Indexer\Product\Flat\Plugin; class StoreGroup { /** + * Product flat indexer processor + * * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor */ protected $_productFlatIndexerProcessor; @@ -45,16 +47,18 @@ class StoreGroup /** * Before save handler * - * @param array $methodArguments - * @return array + * @param \Magento\Core\Model\Resource\Store\Group $subject + * @param \Magento\Core\Model\AbstractModel $object + * + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeSave(array $methodArguments) - { - /** @var $storeGroup \Magento\Core\Model\Store\Group */ - $storeGroup = $methodArguments[0]; - if (!$storeGroup->getId() || $storeGroup->dataHasChangedFor('root_category_id')) { + public function beforeSave( + \Magento\Core\Model\Resource\Store\Group $subject, + \Magento\Core\Model\AbstractModel $object + ) { + if (!$object->getId() || $object->dataHasChangedFor('root_category_id')) { $this->_productFlatIndexerProcessor->markIndexerAsInvalid(); } - return $methodArguments; } } diff --git a/app/code/Magento/Catalog/Model/Observer.php b/app/code/Magento/Catalog/Model/Observer.php index 15a97752a2d..9acaf319c66 100644 --- a/app/code/Magento/Catalog/Model/Observer.php +++ b/app/code/Magento/Catalog/Model/Observer.php @@ -172,9 +172,12 @@ class Observer */ public function addCatalogToTopmenuItems(\Magento\Event\Observer $observer) { + $block = $observer->getEvent()->getBlock(); + $block->addIdentity(\Magento\Catalog\Model\Category::CACHE_TAG); $this->_addCategoriesToMenu( $this->_catalogCategory->getStoreCategories(), - $observer->getMenu() + $observer->getMenu(), + $block ); } @@ -183,9 +186,10 @@ class Observer * * @param \Magento\Data\Tree\Node\Collection|array $categories * @param \Magento\Data\Tree\Node $parentCategoryNode + * @param \Magento\Theme\Block\Html\Topmenu $block * @return void */ - protected function _addCategoriesToMenu($categories, $parentCategoryNode) + protected function _addCategoriesToMenu($categories, $parentCategoryNode, $block) { foreach ($categories as $category) { if (!$category->getIsActive()) { @@ -194,6 +198,8 @@ class Observer $nodeId = 'category-node-' . $category->getId(); + $block->addIdentity(\Magento\Catalog\Model\Category::CACHE_TAG . '_' . $category->getId()); + $tree = $parentCategoryNode->getTree(); $categoryData = array( 'name' => $category->getName(), @@ -210,7 +216,7 @@ class Observer $subcategories = $category->getChildren(); } - $this->_addCategoriesToMenu($subcategories, $categoryNode); + $this->_addCategoriesToMenu($subcategories, $categoryNode, $block); } } diff --git a/app/code/Magento/Catalog/Model/Plugin/Log.php b/app/code/Magento/Catalog/Model/Plugin/Log.php index b83d8f28658..4d0450d17f4 100644 --- a/app/code/Magento/Catalog/Model/Plugin/Log.php +++ b/app/code/Magento/Catalog/Model/Plugin/Log.php @@ -44,10 +44,13 @@ class Log * Catalog Product Compare Items Clean * after plugin for clean method * + * @param \Magento\Log\Model\Resource\Log $subject * @param \Magento\Log\Model\Resource\Log $logResourceModel + * * @return \Magento\Log\Model\Resource\Log + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterClean($logResourceModel) + public function afterClean(\Magento\Log\Model\Resource\Log $subject, $logResourceModel) { $this->_productCompareItem->clean(); return $logResourceModel; diff --git a/app/code/Magento/Catalog/Model/Plugin/QuoteItemProductOption.php b/app/code/Magento/Catalog/Model/Plugin/QuoteItemProductOption.php index 9c09fa1a079..f1ada51b7c7 100644 --- a/app/code/Magento/Catalog/Model/Plugin/QuoteItemProductOption.php +++ b/app/code/Magento/Catalog/Model/Plugin/QuoteItemProductOption.php @@ -26,22 +26,26 @@ namespace Magento\Catalog\Model\Plugin; class QuoteItemProductOption { /** - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\Sales\Model\Convert\Quote $subject + * @param callable $proceed + * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item + * * @return \Magento\Sales\Model\Order\Item + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundItemToOrderItem(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { + public function aroundItemToOrderItem( + \Magento\Sales\Model\Convert\Quote $subject, + \Closure $proceed, + \Magento\Sales\Model\Quote\Item\AbstractItem $item + ) { /** @var $orderItem \Magento\Sales\Model\Order\Item */ - $orderItem = $invocationChain->proceed($arguments); - /** @var $quoteItem \Magento\Sales\Model\Quote\Item */ - $quoteItem = reset($arguments); + $orderItem = $proceed($item); - if (is_array($quoteItem->getOptions())) { - foreach ($quoteItem->getOptions() as $itemOption) { + if (is_array($item->getOptions())) { + foreach ($item->getOptions() as $itemOption) { $code = explode('_', $itemOption->getCode()); if (isset($code[1]) && is_numeric($code[1])) { - $option = $quoteItem->getProduct()->getOptionById($code[1]); + $option = $item->getProduct()->getOptionById($code[1]); if ($option && $option->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_FILE) { try { $option->groupFactory($option->getType()) diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index 11bc51f7596..4a5dba27676 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -40,7 +40,8 @@ namespace Magento\Catalog\Model; * * @SuppressWarnings(PHPMD.LongVariable) */ -class Product extends \Magento\Catalog\Model\AbstractModel + +class Product extends \Magento\Catalog\Model\AbstractModel implements \Magento\Object\IdentityInterface { /** * Entity code. @@ -258,13 +259,12 @@ class Product extends \Magento\Catalog\Model\AbstractModel * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param Product\Url $url * @param Product\Link $productLink - * @param \Magento\Catalog\Model\Product\Configuration\Item\OptionFactory $itemOptionFactory + * @param Product\Configuration\Item\OptionFactory $itemOptionFactory * @param \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory - * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory + * @param CategoryFactory $categoryFactory * @param Product\Option $catalogProductOption * @param Product\Visibility $catalogProductVisibility - * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $catalogProductStatus + * @param Product\Attribute\Source\Status $catalogProductStatus * @param Product\Media\Config $catalogProductMediaConfig * @param \Magento\Index\Model\Indexer $indexIndexer * @param Product\Type $catalogProductType @@ -289,7 +289,6 @@ class Product extends \Magento\Catalog\Model\AbstractModel Product\Link $productLink, \Magento\Catalog\Model\Product\Configuration\Item\OptionFactory $itemOptionFactory, \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory, - \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Product\Option $catalogProductOption, \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, @@ -310,7 +309,6 @@ class Product extends \Magento\Catalog\Model\AbstractModel ) { $this->_itemOptionFactory = $itemOptionFactory; $this->_stockItemFactory = $stockItemFactory; - $this->_productFactory = $productFactory; $this->_categoryFactory = $categoryFactory; $this->_optionInstance = $catalogProductOption; $this->_catalogProductVisibility = $catalogProductVisibility; @@ -2035,4 +2033,14 @@ class Product extends \Magento\Catalog\Model\AbstractModel $this->getTypeInstance()->setImageFromChildProduct($this); return parent::getImage(); } + + /** + * Get identities + * + * @return array + */ + public function getIdentities() + { + return array(self::CACHE_TAG . '_' . $this->getId()); + } } diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Startdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Startdate.php index 4f9ee7e28a1..768732e75bc 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Startdate.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Startdate.php @@ -38,7 +38,7 @@ class Startdate extends \Magento\Eav\Model\Entity\Attribute\Backend\Datetime /** * Date model * - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -46,16 +46,16 @@ class Startdate extends \Magento\Eav\Model\Entity\Attribute\Backend\Datetime * Constructor * * @param \Magento\Logger $logger - * @param \Magento\Core\Model\LocaleInterface $locale - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate + * @param \Magento\Stdlib\DateTime\DateTime $date */ public function __construct( \Magento\Logger $logger, - \Magento\Core\Model\LocaleInterface $locale, - \Magento\Core\Model\Date $date + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Stdlib\DateTime\DateTime $date ) { $this->_date = $date; - parent::__construct($logger, $locale); + parent::__construct($logger, $localeDate); } /** @@ -72,7 +72,7 @@ class Startdate extends \Magento\Eav\Model\Entity\Attribute\Backend\Datetime return false; } if ($startDate == '' && $object->getSpecialPrice()) { - $startDate = $this->_locale->date(); + $startDate = $this->_localeDate->date(); } return $startDate; diff --git a/app/code/Magento/Catalog/Model/Product/Compare/Item.php b/app/code/Magento/Catalog/Model/Product/Compare/Item.php index 5a70c2cd51b..836da9cac48 100644 --- a/app/code/Magento/Catalog/Model/Product/Compare/Item.php +++ b/app/code/Magento/Catalog/Model/Product/Compare/Item.php @@ -42,8 +42,12 @@ use Magento\Catalog\Model\Product; * @package Magento_Catalog * @author Magento Core Team <core@magentocommerce.com> */ -class Item extends \Magento\Core\Model\AbstractModel +class Item extends \Magento\Core\Model\AbstractModel implements \Magento\Object\IdentityInterface { + /** + * Model cache tag + */ + const CACHE_TAG = 'compare_item'; /** * Prefix of model events names @@ -286,4 +290,14 @@ class Item extends \Magento\Core\Model\AbstractModel } return $this->getData('visitor_id'); } + + /** + * Get identities + * + * @return array + */ + public function getIdentities() + { + return array(self::CACHE_TAG . '_' . $this->getId()); + } } diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/Date.php b/app/code/Magento/Catalog/Model/Product/Option/Type/Date.php index 09b21ebeae1..75a032b222c 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/Date.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/Date.php @@ -40,25 +40,23 @@ class Date extends \Magento\Catalog\Model\Product\Option\Type\DefaultType protected $_formattedOptionValue = null; /** - * Locale model - * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param array $data */ public function __construct( \Magento\Checkout\Model\Session $checkoutSession, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, array $data = array() ) { - $this->_locale = $locale; + $this->_localeDate = $localeDate; parent::__construct($checkoutSession, $coreStoreConfig, $data); } @@ -145,8 +143,8 @@ class Date extends \Magento\Catalog\Model\Product\Option\Type\DefaultType if ($this->_dateExists()) { if ($this->useCalendar()) { - $format = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); - $timestamp += $this->_locale->date($value['date'], $format, null, false)->getTimestamp(); + $format = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); + $timestamp += $this->_localeDate->date($value['date'], $format, null, false)->getTimestamp(); } else { $timestamp += mktime(0, 0, 0, $value['month'], $value['day'], $value['year']); } @@ -168,7 +166,7 @@ class Date extends \Magento\Catalog\Model\Product\Option\Type\DefaultType $timestamp += 60 * 60 * $value['hour'] + 60 * $value['minute']; } - $date = new \Zend_Date($timestamp); + $date = new \Magento\Stdlib\DateTime\Date($timestamp); $result = $date->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); // Save date in internal format to avoid locale date bugs @@ -192,15 +190,15 @@ class Date extends \Magento\Catalog\Model\Product\Option\Type\DefaultType $option = $this->getOption(); if ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE) { - $format = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM); - $result = $this->_locale->date($optionValue, \Zend_Date::ISO_8601, null, false) + $format = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM); + $result = $this->_localeDate->date($optionValue, \Zend_Date::ISO_8601, null, false) ->toString($format); } elseif ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE_TIME) { - $format = $this->_locale->getDateTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); - $result = $this->_locale + $format = $this->_localeDate->getDateTimeFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); + $result = $this->_localeDate ->date($optionValue, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT, null, false)->toString($format); } elseif ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_TIME) { - $date = new \Zend_Date($optionValue); + $date = new \Magento\Stdlib\DateTime\Date($optionValue); $result = date($this->is24hTimeFormat() ? 'H:i' : 'h:i a', $date->getTimestamp()); } else { $result = $optionValue; @@ -246,7 +244,7 @@ class Date extends \Magento\Catalog\Model\Product\Option\Type\DefaultType return null; } - $date = new \Zend_Date($timestamp); + $date = new \Magento\Stdlib\DateTime\Date($timestamp); return $date->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); } diff --git a/app/code/Magento/Catalog/Model/Product/Type/Price.php b/app/code/Magento/Catalog/Model/Product/Type/Price.php index 409beb8b3ef..847495360bb 100644 --- a/app/code/Magento/Catalog/Model/Product/Type/Price.php +++ b/app/code/Magento/Catalog/Model/Product/Type/Price.php @@ -60,11 +60,9 @@ class Price protected $_customerSession; /** - * Locale - * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * Store manager @@ -85,20 +83,20 @@ class Price * * @param \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Event\ManagerInterface $eventManager */ public function __construct( \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Event\ManagerInterface $eventManager ) { $this->_ruleFactory = $ruleFactory; $this->_storeManager = $storeManager; - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_customerSession = $customerSession; $this->_eventManager = $eventManager; } @@ -458,7 +456,7 @@ class Price $finalPrice = $this->calculateSpecialPrice($finalPrice, $specialPrice, $specialPriceFrom, $specialPriceTo, $sId); if ($rulePrice === false) { - $storeTimestamp = $this->_locale->storeTimeStamp($sId); + $storeTimestamp = $this->_localeDate->scopeTimeStamp($sId); $rulePrice = $this->_ruleFactory->create() ->getRulePrice($storeTimestamp, $wId, $gId, $productId); } @@ -486,7 +484,7 @@ class Price $store = null) { if (!is_null($specialPrice) && $specialPrice != false) { - if ($this->_locale->isStoreDateInInterval($store, $specialPriceFrom, $specialPriceTo)) { + if ($this->_localeDate->isScopeDateInInterval($store, $specialPriceFrom, $specialPriceTo)) { $finalPrice = min($finalPrice, $specialPrice); } } diff --git a/app/code/Magento/Catalog/Model/Resource/AbstractResource.php b/app/code/Magento/Catalog/Model/Resource/AbstractResource.php index 4fdd7b435fe..25fb1dbe6da 100644 --- a/app/code/Magento/Catalog/Model/Resource/AbstractResource.php +++ b/app/code/Magento/Catalog/Model/Resource/AbstractResource.php @@ -61,7 +61,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity * @param \Magento\App\Resource $resource * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Validator\UniversalFactory $universalFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager @@ -72,7 +72,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity \Magento\App\Resource $resource, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Validator\UniversalFactory $universalFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, @@ -81,7 +81,7 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity ) { $this->_storeManager = $storeManager; $this->_modelFactory = $modelFactory; - parent::__construct($resource, $eavConfig, $attrSetEntity, $locale, $resourceHelper, $universalFactory); + parent::__construct($resource, $eavConfig, $attrSetEntity, $localeFormat, $resourceHelper, $universalFactory); } /** diff --git a/app/code/Magento/Catalog/Model/Resource/Category.php b/app/code/Magento/Catalog/Model/Resource/Category.php index 59c21880c8b..f3c5f4b185a 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category.php +++ b/app/code/Magento/Catalog/Model/Resource/Category.php @@ -91,7 +91,7 @@ class Category extends AbstractResource * @param \Magento\App\Resource $resource * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Validator\UniversalFactory $universalFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager @@ -107,7 +107,7 @@ class Category extends AbstractResource \Magento\App\Resource $resource, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Validator\UniversalFactory $universalFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, @@ -121,7 +121,7 @@ class Category extends AbstractResource $resource, $eavConfig, $attrSetEntity, - $locale, + $localeFormat, $resourceHelper, $universalFactory, $storeManager, diff --git a/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php index 6baa5772cd5..7787874694e 100644 --- a/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php +++ b/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php @@ -132,8 +132,9 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Validator\UniversalFactory $universalFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Catalog\Model\ProductFactory $catalogProductFactory + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Index\Model\Indexer $indexIndexer * @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor * @param \Magento\Catalog\Helper\Product\Flat\Indexer $productFlatIndexerHelper @@ -151,8 +152,9 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Validator\UniversalFactory $universalFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Catalog\Model\ProductFactory $catalogProductFactory, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Index\Model\Indexer $indexIndexer, \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor, \Magento\Catalog\Helper\Product\Flat\Indexer $productFlatIndexerHelper, @@ -174,8 +176,9 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute $storeManager, $resourceHelper, $universalFactory, - $locale, + $localeDate, $catalogProductFactory, + $localeResolver, $resource, $resourceCollection, $data diff --git a/app/code/Magento/Catalog/Model/Resource/Product.php b/app/code/Magento/Catalog/Model/Resource/Product.php index f5e1f7050d1..79cb46edfbd 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product.php +++ b/app/code/Magento/Catalog/Model/Resource/Product.php @@ -66,7 +66,7 @@ class Product extends AbstractResource * @param \Magento\App\Resource $resource * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Validator\UniversalFactory $universalFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager @@ -81,7 +81,7 @@ class Product extends AbstractResource \Magento\App\Resource $resource, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Validator\UniversalFactory $universalFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, @@ -96,7 +96,7 @@ class Product extends AbstractResource $resource, $eavConfig, $attrSetEntity, - $locale, + $localeFormat, $resourceHelper, $universalFactory, $storeManager, diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php index 533023987b1..4045f291190 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php @@ -227,11 +227,9 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl protected $_customerSession; /** - * Locale - * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * Catalog url @@ -275,7 +273,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl * @param Store\Config $coreStoreConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Stdlib\DateTime $dateTime * @param \Zend_Db_Adapter_Abstract $connection @@ -298,7 +296,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\Resource\Url $catalogUrl, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Stdlib\DateTime $dateTime, $connection = null @@ -308,7 +306,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl $this->_coreStoreConfig = $coreStoreConfig; $this->_productOptionFactory = $productOptionFactory; $this->_catalogUrl = $catalogUrl; - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_customerSession = $customerSession; $this->_resourceHelper = $resourceHelper; $this->dateTime = $dateTime; @@ -1313,7 +1311,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Collection\AbstractColl $wId = $this->_storeManager->getWebsite()->getId(); $gId = $this->_customerSession->getCustomerGroupId(); - $storeDate = $this->_locale->storeTimeStamp($this->getStoreId()); + $storeDate = $this->_localeDate->scopeTimeStamp($this->getStoreId()); $conditions = 'price_rule.product_id = e.entity_id AND '; $conditions .= "price_rule.rule_date = '" . $this->dateTime->formatDate($storeDate, false) . "' AND "; $conditions .= $this->getConnection()->quoteInto('price_rule.website_id = ? AND', $wId); diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php index 913d0ac97de..b5323b7dbf0 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Compare/Item/Collection.php @@ -87,7 +87,7 @@ class Collection * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Catalog\Model\Resource\Product\Compare\Item $catalogProductCompareItem @@ -112,7 +112,7 @@ class Collection \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\Resource\Url $catalogUrl, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Stdlib\DateTime $dateTime, \Magento\Catalog\Model\Resource\Product\Compare\Item $catalogProductCompareItem, @@ -137,7 +137,7 @@ class Collection $coreStoreConfig, $productOptionFactory, $catalogUrl, - $locale, + $localeDate, $customerSession, $dateTime, $connection diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price.php index c3e74fca295..f21c37f6872 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price.php @@ -56,11 +56,9 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource protected $_catalogProductType; /** - * Locale - * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * Store manager @@ -99,7 +97,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource * @param \Magento\App\Resource $resource * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Catalog\Model\Product\Type $catalogProductType * @param \Magento\App\ConfigInterface $config * @param \Magento\Catalog\Model\Resource\Product\Indexer\Price\Factory $indexerPriceFactory @@ -109,7 +107,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource \Magento\App\Resource $resource, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Catalog\Model\Product\Type $catalogProductType, \Magento\App\ConfigInterface $config, \Magento\Catalog\Model\Resource\Product\Indexer\Price\Factory $indexerPriceFactory, @@ -117,7 +115,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource ) { $this->_currencyFactory = $currencyFactory; $this->_storeManager = $storeManager; - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_catalogProductType = $catalogProductType; $this->_config = $config; $this->_indexerPriceFactory = $indexerPriceFactory; @@ -658,7 +656,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource /** @var $store \Magento\Core\Model\Store */ $store = $this->_storeManager->getStore($item['store_id']); if ($store) { - $timestamp = $this->_locale->storeTimeStamp($store); + $timestamp = $this->_localeDate->scopeTimeStamp($store); $data[] = array( 'website_id' => $website->getId(), 'website_date' => $this->dateTime->formatDate($timestamp, false), diff --git a/app/code/Magento/Catalog/Model/Resource/Url.php b/app/code/Magento/Catalog/Model/Resource/Url.php index 8730b428a18..d58ee859dbf 100644 --- a/app/code/Magento/Catalog/Model/Resource/Url.php +++ b/app/code/Magento/Catalog/Model/Resource/Url.php @@ -103,20 +103,15 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb protected $_storeManager; /** - * Load core Url rewrite model - * - * @return void + * @var Product */ - protected function _construct() - { - $this->_init('core_url_rewrite', 'url_rewrite_id'); - } + protected $productResource; /** * @param \Magento\App\Resource $resource * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Catalog\Model\Product $catalogProduct + * @param Product $productResource * @param \Magento\Catalog\Model\Category $catalogCategory * @param \Magento\Logger $logger */ @@ -124,18 +119,28 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb \Magento\App\Resource $resource, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig, - \Magento\Catalog\Model\Product $catalogProduct, + Product $productResource, \Magento\Catalog\Model\Category $catalogCategory, \Magento\Logger $logger ) { $this->_storeManager = $storeManager; $this->_eavConfig = $eavConfig; - $this->_catalogProduct = $catalogProduct; + $this->productResource = $productResource; $this->_catalogCategory = $catalogCategory; $this->_logger = $logger; parent::__construct($resource); } + /** + * Load core Url rewrite model + * + * @return void + */ + protected function _construct() + { + $this->_init('core_url_rewrite', 'url_rewrite_id'); + } + /** * Retrieve stores array or store model * @@ -163,16 +168,6 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb return $this->_catalogCategory; } - /** - * Retrieve product model singleton - * - * @return \Magento\Catalog\Model\Product - */ - public function getProductModel() - { - return $this->_catalogProduct; - } - /** * Retrieve rewrite by idPath * @@ -561,7 +556,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb { $adapter = $this->_getWriteAdapter(); if (!isset($this->_productAttributes[$attributeCode])) { - $attribute = $this->getProductModel()->getResource()->getAttribute($attributeCode); + $attribute = $this->productResource->getAttribute($attributeCode); $this->_productAttributes[$attributeCode] = array( 'entity_type_id' => $attribute->getEntityTypeId(), @@ -635,7 +630,7 @@ class Url extends \Magento\Core\Model\Resource\Db\AbstractDb { $adapter = $this->_getReadAdapter(); if (!isset($this->_productAttributes[$attributeCode])) { - $attribute = $this->getProductModel()->getResource()->getAttribute($attributeCode); + $attribute = $this->productResource->getAttribute($attributeCode); $this->_productAttributes[$attributeCode] = array( 'entity_type_id' => $attribute->getEntityTypeId(), diff --git a/app/code/Magento/Catalog/Model/Url.php b/app/code/Magento/Catalog/Model/Url.php index e5322a21e1b..fa03d772bb1 100644 --- a/app/code/Magento/Catalog/Model/Url.php +++ b/app/code/Magento/Catalog/Model/Url.php @@ -149,26 +149,32 @@ class Url protected $_urlFactory; /** - * Construct - * - * @param \Magento\Catalog\Model\Resource\UrlFactory $urlFactory - * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory + * @var \Magento\Catalog\Model\Product\Url + */ + protected $productUrl; + + /** + * @param Resource\UrlFactory $urlFactory + * @param CategoryFactory $categoryFactory * @param \Magento\Catalog\Helper\Category $catalogCategory * @param \Magento\Catalog\Helper\Product $catalogProduct * @param \Magento\Catalog\Helper\Data $catalogData + * @param Product\Url $productUrl */ public function __construct( \Magento\Catalog\Model\Resource\UrlFactory $urlFactory, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Helper\Category $catalogCategory, \Magento\Catalog\Helper\Product $catalogProduct, - \Magento\Catalog\Helper\Data $catalogData + \Magento\Catalog\Helper\Data $catalogData, + Product\Url $productUrl ) { $this->_urlFactory = $urlFactory; $this->_categoryFactory = $categoryFactory; $this->_catalogCategory = $catalogCategory; $this->_catalogProduct = $catalogProduct; $this->_catalogData = $catalogData; + $this->productUrl = $productUrl; } /** @@ -238,16 +244,6 @@ class Url return $this->getResource()->getCategoryModel(); } - /** - * Retrieve product model singleton - * - * @return \Magento\Catalog\Model\Product - */ - public function getProductModel() - { - return $this->getResource()->getProductModel(); - } - /** * Returns store root category, uses caching for it * @@ -395,9 +391,9 @@ class Url return $this; } if ($product->getUrlKey() == '') { - $urlKey = $this->getProductModel()->formatUrlKey($product->getName()); + $urlKey = $this->productUrl->formatUrlKey($product->getName()); } else { - $urlKey = $this->getProductModel()->formatUrlKey($product->getUrlKey()); + $urlKey = $this->productUrl->formatUrlKey($product->getUrlKey()); } $idPath = $this->generatePath('id', $product, $category); @@ -819,9 +815,9 @@ class Url public function getProductRequestPath($product, $category) { if ($product->getUrlKey() == '') { - $urlKey = $this->getProductModel()->formatUrlKey($product->getName()); + $urlKey = $this->productUrl->formatUrlKey($product->getName()); } else { - $urlKey = $this->getProductModel()->formatUrlKey($product->getUrlKey()); + $urlKey = $this->productUrl->formatUrlKey($product->getUrlKey()); } $storeId = $category->getStoreId(); $suffix = $this->getProductUrlSuffix($storeId); @@ -956,9 +952,9 @@ class Url } if ($product->getUrlKey() == '') { - $urlKey = $this->getProductModel()->formatUrlKey($product->getName()); + $urlKey = $this->productUrl->formatUrlKey($product->getName()); } else { - $urlKey = $this->getProductModel()->formatUrlKey($product->getUrlKey()); + $urlKey = $this->productUrl->formatUrlKey($product->getUrlKey()); } $productUrlSuffix = $this->getProductUrlSuffix($category->getStoreId()); if ($category->getLevel() > 1) { diff --git a/app/code/Magento/Catalog/etc/adminhtml/di.xml b/app/code/Magento/Catalog/etc/adminhtml/di.xml index 2aa4eef40e5..52a5d0e53e2 100644 --- a/app/code/Magento/Catalog/etc/adminhtml/di.xml +++ b/app/code/Magento/Catalog/etc/adminhtml/di.xml @@ -57,9 +57,6 @@ </argument> </arguments> </type> - <type name="Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper"> - <plugin name="configurable" type="Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Configurable" sortOrder="50" /> - </type> <type name="Magento\Catalog\Helper\Flat\AbstractFlat"> <arguments> <argument name="isAvailable" xsi:type="boolean">false</argument> diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index e7f59d1044c..4648097d754 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -152,8 +152,8 @@ <plugin name="categoryStoreGroupAroundSave" type="Magento\Catalog\Model\Indexer\Category\Product\Plugin\StoreGroup"/> </type> <type name="Magento\Indexer\Model\Config\Data"> - <plugin name="indexerCategoryFlatConfigGet" type="Magento\Catalog\Model\Indexer\Category\Flat\Plugin\IndexerConfigData"/> - <plugin name="indexerProductFlatConfigGet" type="Magento\Catalog\Model\Indexer\Product\Flat\Plugin\IndexerConfigData"/> + <plugin name="indexerCategoryFlatConfigGet" type="Magento\Catalog\Model\Indexer\Category\Flat\Plugin\IndexerConfigData" disabled="true"/> + <plugin name="indexerProductFlatConfigGet" type="Magento\Catalog\Model\Indexer\Product\Flat\Plugin\IndexerConfigData" disabled="true"/> </type> <type name="Magento\Catalog\Model\Indexer\Category\Flat"> <arguments> @@ -228,7 +228,7 @@ <type name="Magento\Catalog\Model\Indexer\Product\Flat\Action\Rows"> <arguments> - <argument name="tableData" xsi:type="object">rowsFlatTableBuilder</argument> + <argument name="flatTableBuilder" xsi:type="object">rowsFlatTableBuilder</argument> </arguments> </type> diff --git a/app/code/Magento/Catalog/etc/frontend/di.xml b/app/code/Magento/Catalog/etc/frontend/di.xml index ed2f5b780f2..9a305951094 100644 --- a/app/code/Magento/Catalog/etc/frontend/di.xml +++ b/app/code/Magento/Catalog/etc/frontend/di.xml @@ -37,16 +37,6 @@ <type name="Magento\Sales\Model\Convert\Quote"> <plugin name="copy_quote_files_to_order" type="Magento\Catalog\Model\Plugin\QuoteItemProductOption"/> </type> - <virtualType name="compareProductInitSession" type="Magento\Core\App\Action\Plugin\Session"> - <arguments> - <argument name="cookieCheckActions" xsi:type="array"> - <item name="compareProductAdd" xsi:type="string">add</item> - </argument> - </arguments> - </virtualType> - <type name="Magento\Catalog\Controller\Product\Compare"> - <plugin name="sessionInitializer" type="compareProductInitSession" /> - </type> <type name="Magento\Catalog\Model\Indexer\AbstractFlatState"> <arguments> <argument name="isAvailable" xsi:type="boolean">true</argument> diff --git a/app/code/Magento/Catalog/etc/module.xml b/app/code/Magento/Catalog/etc/module.xml index 9f4c16f8f3f..5e43dfda6d7 100755 --- a/app/code/Magento/Catalog/etc/module.xml +++ b/app/code/Magento/Catalog/etc/module.xml @@ -49,6 +49,7 @@ <module name="Magento_Tax"/> <module name="Magento_Bundle"/> <module name="Magento_CatalogInventory"/> + <module name="Magento_ImportExport"/> <module name="Magento_Cron"/> <module name="Magento_Directory"/> <module name="Magento_CatalogRule"/> diff --git a/app/code/Magento/Catalog/view/adminhtml/catalog/category/edit/form.phtml b/app/code/Magento/Catalog/view/adminhtml/catalog/category/edit/form.phtml index 98865a6d86c..53e8059148f 100644 --- a/app/code/Magento/Catalog/view/adminhtml/catalog/category/edit/form.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/catalog/category/edit/form.phtml @@ -68,7 +68,7 @@ <?php if(($block = $this->getLayout()->getBlock('category.product.grid')) && ($_gridJsObject=$block->getJsObjectName())): ?> var categoryProducts = $H(<?php echo $this->getProductsJson() ?>); - $('in_category_products').value = categoryProducts.toQueryString(); + $('in_category_products').value = Object.toJSON(categoryProducts); function registerCategoryProduct(grid, element, checked){ if(checked){ @@ -83,7 +83,7 @@ } categoryProducts.unset(element.value); } - $('in_category_products').value = categoryProducts.toQueryString(); + $('in_category_products').value = Object.toJSON(categoryProducts); grid.reloadParams = {'selected_products[]':categoryProducts.keys()}; } function categoryProductRowClick(grid, event){ @@ -101,7 +101,7 @@ var element = Event.element(event); if(element && element.checkboxElement && element.checkboxElement.checked){ categoryProducts.set(element.checkboxElement.value, element.value); - $('in_category_products').value = categoryProducts.toQueryString(); + $('in_category_products').value = Object.toJSON(categoryProducts); } } diff --git a/app/code/Magento/Catalog/view/adminhtml/catalog/product/composite/configure.phtml b/app/code/Magento/Catalog/view/adminhtml/catalog/product/composite/configure.phtml index 5729075cff8..1b8f3ab4a14 100644 --- a/app/code/Magento/Catalog/view/adminhtml/catalog/product/composite/configure.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/catalog/product/composite/configure.phtml @@ -25,7 +25,7 @@ */ ?> <div id="product_composite_configure" class="product-configure-popup" style="display:none;"> - <iframe name="product_composite_configure_iframe" id="product_composite_configure_iframe" style="width:0; height:0; border:0px solid #fff; position:absolute; top:-1000px; left:-1000px" onload="window.productConfigure && productConfigure.onLoadIFrame()"></iframe> + <iframe name="product_composite_configure_iframe" id="product_composite_configure_iframe" src="#" style="width:0; height:0; border:0px solid #fff; position:absolute; top:-1000px; left:-1000px" onload="window.productConfigure && productConfigure.onLoadIFrame()"></iframe> <form action="" method="post" id="product_composite_configure_form" enctype="multipart/form-data" onsubmit="productConfigure.onConfirmBtn(); return false;" target="product_composite_configure_iframe"> <div class="entry-edit"> <div id="product_composite_configure_messages" style="display: none;" > diff --git a/app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml b/app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml index 2a58a006602..3b2c2a55d5e 100644 --- a/app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml +++ b/app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml @@ -83,6 +83,13 @@ </action> </block> </block> + <block class="Magento\Core\Block\RequireCookie" name="require-cookie" template="Magento_Core::require_cookie.phtml"> + <arguments> + <argument name="triggers" xsi:type="array"> + <item name="compareProductLink" xsi:type="string">.action.tocompare</item> + </argument> + </arguments> + </block> </referenceContainer> <update handle="MAP_popup"/> </layout> diff --git a/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml index 3db5375d3d6..b6ce571df12 100644 --- a/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml +++ b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml @@ -124,6 +124,13 @@ </arguments> </block> </block> + <block class="Magento\Core\Block\RequireCookie" name="require-cookie" template="Magento_Core::require_cookie.phtml"> + <arguments> + <argument name="triggers" xsi:type="array"> + <item name="compareProductLink" xsi:type="string">.action.tocompare</item> + </argument> + </arguments> + </block> </referenceContainer> <referenceContainer name="content.aside"> <block class="Magento\Catalog\Block\Product\ProductList\Related" name="catalog.product.related" template="Magento_Catalog::product/list/items.phtml"> diff --git a/app/code/Magento/CatalogInventory/Block/Qtyincrements.php b/app/code/Magento/CatalogInventory/Block/Qtyincrements.php index ca53988242a..518e53e198f 100644 --- a/app/code/Magento/CatalogInventory/Block/Qtyincrements.php +++ b/app/code/Magento/CatalogInventory/Block/Qtyincrements.php @@ -34,7 +34,7 @@ */ namespace Magento\CatalogInventory\Block; -class Qtyincrements extends \Magento\View\Element\Template +class Qtyincrements extends \Magento\View\Element\Template implements \Magento\View\Block\IdentityInterface { /** * Qty Increments cache @@ -99,4 +99,14 @@ class Qtyincrements extends \Magento\View\Element\Template } return $this->_qtyIncrements; } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + return $this->getProduct()->getIdentities(); + } } diff --git a/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php b/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php index bb14075acff..2d47d515946 100644 --- a/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php +++ b/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php @@ -34,7 +34,7 @@ */ namespace Magento\CatalogInventory\Block\Stockqty; -class DefaultStockqty extends AbstractStockqty +class DefaultStockqty extends AbstractStockqty implements \Magento\View\Block\IdentityInterface { /** * Render block HTML @@ -48,4 +48,14 @@ class DefaultStockqty extends AbstractStockqty } return parent::_toHtml(); } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + return $this->getProduct()->getIdentities(); + } } diff --git a/app/code/Magento/CatalogInventory/Model/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Stock/Item.php index feaccc4285b..09e1335d976 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/Item.php @@ -165,11 +165,9 @@ class Item extends \Magento\Core\Model\AbstractModel protected $_storeManager; /** - * Locale model - * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\FormatInterface */ - protected $_locale; + protected $_localeFormat; /** * @var Status @@ -191,6 +189,11 @@ class Item extends \Magento\Core\Model\AbstractModel */ protected $mathDivision; + /** + * @var \Magento\Stdlib\DateTime\TimezoneInterface + */ + protected $_localeDate; + /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry @@ -201,8 +204,9 @@ class Item extends \Magento\Core\Model\AbstractModel * @param \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Math\Division $mathDivision + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -217,8 +221,9 @@ class Item extends \Magento\Core\Model\AbstractModel \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\FormatInterface $localeFormat, \Magento\Math\Division $mathDivision, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -232,8 +237,9 @@ class Item extends \Magento\Core\Model\AbstractModel $this->_catalogInventoryMinsaleqty = $catalogInventoryMinsaleqty; $this->_coreStoreConfig = $coreStoreConfig; $this->_storeManager = $storeManager; - $this->_locale = $locale; + $this->_localeFormat = $localeFormat; $this->mathDivision = $mathDivision; + $this->_localeDate = $localeDate; } /** @@ -609,7 +615,7 @@ class Item extends \Magento\Core\Model\AbstractModel $result->setHasError(false); if (!is_numeric($qty)) { - $qty = $this->_locale->getNumber($qty); + $qty = $this->_localeFormat->getNumber($qty); } /** @@ -627,7 +633,7 @@ class Item extends \Magento\Core\Model\AbstractModel $result->setItemQty($qty); if (!is_numeric($qty)) { - $qty = $this->_locale->getNumber($qty); + $qty = $this->_localeFormat->getNumber($qty); } $origQty = intval($origQty); $result->setOrigQty($origQty); @@ -818,7 +824,7 @@ class Item extends \Magento\Core\Model\AbstractModel // if qty is below notify qty, update the low stock date to today date otherwise set null $this->setLowStockDate(null); if ($this->verifyNotification()) { - $this->setLowStockDate($this->_locale->date(null, null, null, false) + $this->setLowStockDate($this->_localeDate->date(null, null, null, false) ->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT) ); } diff --git a/app/code/Magento/CatalogInventory/etc/events.xml b/app/code/Magento/CatalogInventory/etc/events.xml index df4ba2365c8..d6122c30754 100644 --- a/app/code/Magento/CatalogInventory/etc/events.xml +++ b/app/code/Magento/CatalogInventory/etc/events.xml @@ -57,7 +57,7 @@ <event name="sales_model_service_quote_submit_failure"> <observer name="inventory" instance="Magento\CatalogInventory\Model\Observer" method="revertQuoteInventory" /> </event> - <event name="paypal_payment_cancel"> + <event name="restore_quote"> <observer name="inventory" instance="Magento\CatalogInventory\Model\Observer" method="revertQuoteInventory" /> </event> <event name="sales_order_item_cancel"> diff --git a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Main.php b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Main.php index 631c5ce80bf..8c7ce53a58f 100644 --- a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Main.php +++ b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Main.php @@ -184,7 +184,7 @@ class Main extends Generic implements TabInterface 'values' => $this->_customerGroup->create()->toOptionArray() )); - $dateFormat = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $dateFormat = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); $fieldset->addField('from_date', 'date', array( 'name' => 'from_date', 'label' => __('From Date'), diff --git a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php index baacc29d157..4a3cc30204e 100644 --- a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php +++ b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php @@ -37,7 +37,7 @@ use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; use Magento\CatalogRule\Model\Rule\Job; use Magento\Core\Exception; -use Magento\Core\Filter\Date; +use Magento\Stdlib\DateTime\Filter\Date; use Magento\Registry; use Magento\Rule\Model\Condition\AbstractCondition; use Magento\Rule\Model\Action\AbstractAction; @@ -60,7 +60,7 @@ class Catalog extends Action protected $_coreRegistry = null; /** - * @var \Magento\Core\Filter\Date + * @var \Magento\Stdlib\DateTime\Filter\Date */ protected $_dateFilter; diff --git a/app/code/Magento/CatalogRule/Model/Observer.php b/app/code/Magento/CatalogRule/Model/Observer.php index c89adb6b800..a9b8389d05a 100644 --- a/app/code/Magento/CatalogRule/Model/Observer.php +++ b/app/code/Magento/CatalogRule/Model/Observer.php @@ -38,7 +38,7 @@ use Magento\CatalogRule\Model\Resource\Rule\Collection; use Magento\CatalogRule\Model\Rule\Product\Price; use Magento\Registry; use Magento\Core\Model\StoreManagerInterface; -use Magento\Core\Model\LocaleInterface; +use Magento\Stdlib\DateTime\TimezoneInterface; use Magento\Customer\Model\Group; use Magento\Customer\Model\Session as CustomerModelSession; use Magento\Event\Observer as EventObserver; @@ -99,9 +99,9 @@ class Observer protected $_storeManager; /** - * @var LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @var \Magento\CatalogRule\Model\Resource\RuleFactory @@ -126,7 +126,7 @@ class Observer * @param RuleFactory $ruleFactory * @param FlagFactory $flagFactory * @param StoreManagerInterface $storeManager - * @param LocaleInterface $locale + * @param TimezoneInterface $localeDate * @param CustomerModelSession $customerSession * @param BackendModelSession $backendSession * @param Registry $coreRegistry @@ -143,7 +143,7 @@ class Observer RuleFactory $ruleFactory, FlagFactory $flagFactory, StoreManagerInterface $storeManager, - LocaleInterface $locale, + TimezoneInterface $localeDate, CustomerModelSession $customerSession, BackendModelSession $backendSession, Registry $coreRegistry, @@ -157,7 +157,7 @@ class Observer $this->_ruleFactory = $ruleFactory; $this->_flagFactory = $flagFactory; $this->_storeManager = $storeManager; - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_customerSession = $customerSession; $this->_backendSession = $backendSession; $this->_coreRegistry = $coreRegistry; @@ -243,7 +243,7 @@ class Observer if ($observer->hasDate()) { $date = $observer->getEvent()->getDate(); } else { - $date = $this->_locale->storeTimeStamp($storeId); + $date = $this->_localeDate->scopeTimeStamp($storeId); } if ($observer->hasWebsiteId()) { @@ -283,7 +283,7 @@ class Observer { $product = $observer->getEvent()->getProduct(); $storeId = $product->getStoreId(); - $date = $this->_locale->storeDate($storeId); + $date = $this->_localeDate->scopeDate($storeId); $key = false; $ruleData = $this->_coreRegistry->registry('rule_data'); @@ -480,7 +480,7 @@ class Observer if ($observer->getEvent()->hasDate()) { $date = $observer->getEvent()->getDate(); } else { - $date = $this->_locale->storeTimeStamp($store); + $date = $this->_localeDate->scopeTimeStamp($store); } $productIds = array(); diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule.php b/app/code/Magento/CatalogRule/Model/Resource/Rule.php index 2f315d2ff0e..aa4df0d3fc2 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Rule.php @@ -89,7 +89,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource protected $_eavConfig; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_coreDate; @@ -112,7 +112,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * @param \Magento\App\Resource $resource * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Product\ConditionFactory $conditionFactory - * @param \Magento\Core\Model\Date $coreDate + * @param \Magento\Stdlib\DateTime\DateTime $coreDate * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\CatalogRule\Helper\Data $catalogRuleData @@ -123,7 +123,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource \Magento\App\Resource $resource, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Product\ConditionFactory $conditionFactory, - \Magento\Core\Model\Date $coreDate, + \Magento\Stdlib\DateTime\DateTime $coreDate, \Magento\Eav\Model\Config $eavConfig, \Magento\Event\ManagerInterface $eventManager, \Magento\CatalogRule\Helper\Data $catalogRuleData, diff --git a/app/code/Magento/CatalogRule/Model/Rule.php b/app/code/Magento/CatalogRule/Model/Rule.php index 95f6e6ae46b..fc5e3118842 100644 --- a/app/code/Magento/CatalogRule/Model/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Rule.php @@ -171,7 +171,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\CatalogRule\Model\Rule\Condition\CombineFactory $combineFactory @@ -192,7 +192,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\CatalogRule\Model\Rule\Condition\CombineFactory $combineFactory, @@ -221,7 +221,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel $this->_cacheTypesList = $cacheTypesList; $this->_relatedCacheTypes = $relatedCacheTypes; $this->dateTime = $dateTime; - parent::__construct($context, $registry, $formFactory, $locale, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $formFactory, $localeDate, $resource, $resourceCollection, $data); } /** @@ -423,7 +423,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel } else { $customerGroupId = $this->_customerSession->getCustomerGroupId(); } - $dateTs = $this->_locale->storeTimeStamp($storeId); + $dateTs = $this->_localeDate->scopeTimeStamp($storeId); $cacheKey = date('Y-m-d', $dateTs) . "|$websiteId|$customerGroupId|$productId|$price"; if (!array_key_exists($cacheKey, self::$_priceRulesData)) { diff --git a/app/code/Magento/CatalogSearch/Block/Advanced/Form.php b/app/code/Magento/CatalogSearch/Block/Advanced/Form.php index 70f211eafff..d04a871691a 100644 --- a/app/code/Magento/CatalogSearch/Block/Advanced/Form.php +++ b/app/code/Magento/CatalogSearch/Block/Advanced/Form.php @@ -34,7 +34,6 @@ namespace Magento\CatalogSearch\Block\Advanced; use Magento\CatalogSearch\Model\Advanced; -use Magento\Core\Model\LocaleInterface; use Magento\Data\Collection\Db; use Magento\Directory\Model\CurrencyFactory; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; @@ -357,7 +356,9 @@ class Form extends Template ->setTitle($this->getAttributeLabel($attribute)) ->setValue($value) ->setImage($this->getViewFileUrl('Magento_Core::calendar.gif')) - ->setDateFormat($this->_locale->getDateFormat(LocaleInterface::FORMAT_TYPE_SHORT)) + ->setDateFormat( + $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT) + ) ->setClass('input-text') ->getHtml(); } diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php index 12c903eb1a0..39ac32d1eb6 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php @@ -39,7 +39,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Date * - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -59,10 +59,10 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Stdlib\DateTime $dateTime - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Zend_Db_Adapter_Abstract $connection * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -83,10 +83,10 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\Resource\Url $catalogUrl, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Stdlib\DateTime $dateTime, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, $connection = null ) { $this->_date = $date; @@ -106,7 +106,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $coreStoreConfig, $productOptionFactory, $catalogUrl, - $locale, + $localeDate, $customerSession, $dateTime, $connection diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php index 4a1384537ff..96dd3193fb1 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php @@ -45,7 +45,7 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb protected $_separator = '|'; /** - * Array of \Zend_Date objects per store + * Array of \Magento\Stdlib\DateTime\DateInterface objects per store * * @var array */ @@ -143,6 +143,16 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb */ protected $dateTime; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + + /** + * @var \Magento\Stdlib\DateTime\TimezoneInterface + */ + protected $_localeDate; + /** * @param \Magento\App\Resource $resource * @param \Magento\Catalog\Model\Product\Type $catalogProductType @@ -157,6 +167,8 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param Helper $resourceHelper * @param \Magento\Stdlib\DateTime $dateTime + * @param \Magento\Locale\ResolverInterface $localeResolver + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate */ public function __construct( \Magento\App\Resource $resource, @@ -171,7 +183,9 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\CatalogSearch\Model\Resource\Helper $resourceHelper, - \Magento\Stdlib\DateTime $dateTime + \Magento\Stdlib\DateTime $dateTime, + \Magento\Locale\ResolverInterface $localeResolver, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate ) { $this->_catalogProductType = $catalogProductType; $this->_eavConfig = $eavConfig; @@ -185,6 +199,8 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb $this->_resourceHelper = $resourceHelper; $this->_engineProvider = $engineProvider; $this->dateTime = $dateTime; + $this->_localeResolver = $localeResolver; + $this->_localeDate = $localeDate; parent::__construct($resource); } @@ -899,15 +915,13 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb protected function _getStoreDate($storeId, $date = null) { if (!isset($this->_dates[$storeId])) { - $timezone = $this->_coreStoreConfig->getConfig( - \Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_TIMEZONE, $storeId - ); + $timezone = $this->_coreStoreConfig->getConfig($this->_localeDate->getDefaultTimezonePath(), $storeId); $locale = $this->_coreStoreConfig->getConfig( - \Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_LOCALE, $storeId + $this->_localeResolver->getDefaultLocalePath(), $storeId ); $locale = new \Zend_Locale($locale); - $dateObj = new \Zend_Date(null, null, $locale); + $dateObj = new \Magento\Stdlib\DateTime\Date(null, null, $locale); $dateObj->setTimezone($timezone); $this->_dates[$storeId] = array($dateObj, $locale->getTranslation(null, 'date', $locale)); } diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php index ec2f3af864d..c75b734b224 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php @@ -64,7 +64,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\CatalogSearch\Helper\Data $catalogSearchData @@ -89,7 +89,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\Resource\Url $catalogUrl, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Stdlib\DateTime $dateTime, \Magento\CatalogSearch\Helper\Data $catalogSearchData, @@ -114,7 +114,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $coreStoreConfig, $productOptionFactory, $catalogUrl, - $locale, + $localeDate, $customerSession, $dateTime, $connection diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Query.php b/app/code/Magento/CatalogSearch/Model/Resource/Query.php index 4fb3aee4d55..cb94b39a985 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Query.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Query.php @@ -39,7 +39,7 @@ class Query extends AbstractDb /** * Date * - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -50,12 +50,12 @@ class Query extends AbstractDb /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Stdlib\DateTime $dateTime */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\Stdlib\DateTime $dateTime ) { $this->_date = $date; diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php index 84f430c25d6..800239aedff 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php @@ -71,7 +71,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory @@ -95,7 +95,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\Resource\Url $catalogUrl, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Stdlib\DateTime $dateTime, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, @@ -118,7 +118,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $coreStoreConfig, $productOptionFactory, $catalogUrl, - $locale, + $localeDate, $customerSession, $dateTime, $connection diff --git a/app/code/Magento/Centinel/Helper/Data.php b/app/code/Magento/Centinel/Helper/Data.php index 24f73f079ca..dc4a6358678 100644 --- a/app/code/Magento/Centinel/Helper/Data.php +++ b/app/code/Magento/Centinel/Helper/Data.php @@ -163,7 +163,7 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Return centinel block for payment form with logos * - * @param \Magento\Payment\Model\Method\AbstractMethod $method + * @param \Magento\Payment\Model\MethodInterface $method * @return \Magento\Centinel\Block\Logo */ public function getMethodFormBlock($method) diff --git a/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php b/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php index 06d93bdd350..183e98846b0 100644 --- a/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php +++ b/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php @@ -38,7 +38,7 @@ use Magento\Sales\Model\Quote\Item; * @method \Magento\Checkout\Block\Cart\Item\Renderer setDeleteUrl(string) */ -class Renderer extends \Magento\View\Element\Template +class Renderer extends \Magento\View\Element\Template implements \Magento\View\Block\IdentityInterface { /** * @var \Magento\Checkout\Model\Session @@ -502,4 +502,17 @@ class Renderer extends \Magento\View\Element\Template $this->_ignoreProductUrl = $ignore; return $this; } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + if ($this->getItem()) { + return $this->getProduct()->getIdentities(); + } + return array(); + } } diff --git a/app/code/Magento/Checkout/Block/Cart/Shipping.php b/app/code/Magento/Checkout/Block/Cart/Shipping.php index a9a10aa2f65..936c3abadac 100644 --- a/app/code/Magento/Checkout/Block/Cart/Shipping.php +++ b/app/code/Magento/Checkout/Block/Cart/Shipping.php @@ -215,20 +215,17 @@ class Shipping extends \Magento\Checkout\Block\Cart\AbstractCart */ public function getCityActive() { - return (bool)$this->_storeConfig->getConfig('carriers/dhl/active') - || (bool)$this->_storeConfig->getConfig('carriers/dhlint/active'); + return false; } /** - * Show State in Shipping Estimation + * Show State in Shipping Estimation. Result updated using plugins * * @return bool */ public function getStateActive() { - return (bool)$this->_storeConfig->getConfig('carriers/dhl/active') - || (bool)$this->_storeConfig->getConfig('carriers/tablerate/active') - || (bool)$this->_storeConfig->getConfig('carriers/dhlint/active'); + return false; } /** diff --git a/app/code/Magento/Checkout/Block/Cart/Sidebar.php b/app/code/Magento/Checkout/Block/Cart/Sidebar.php index eca95e13f06..02d3aad2502 100644 --- a/app/code/Magento/Checkout/Block/Cart/Sidebar.php +++ b/app/code/Magento/Checkout/Block/Cart/Sidebar.php @@ -32,7 +32,7 @@ namespace Magento\Checkout\Block\Cart; * @package Magento_Checkout * @author Magento Core Team <core@magentocommerce.com> */ -class Sidebar extends \Magento\Checkout\Block\Cart\AbstractCart +class Sidebar extends \Magento\Checkout\Block\Cart\AbstractCart implements \Magento\View\Block\IdentityInterface { const XML_PATH_CHECKOUT_SIDEBAR_COUNT = 'checkout/sidebar/count'; @@ -380,4 +380,19 @@ class Sidebar extends \Magento\Checkout\Block\Cart\AbstractCart } return $this; } + + /** + * Retrieve block cache tags + * + * @return array + */ + public function getIdentities() + { + $identities = array(); + /** @var $item \Magento\Sales\Model\Quote\Item */ + foreach ($this->getItems() as $item) { + $identities = array_merge($identities, $item->getProduct()->getIdentities()); + } + return $identities; + } } diff --git a/app/code/Magento/Checkout/Block/Onepage/Payment/Methods.php b/app/code/Magento/Checkout/Block/Onepage/Payment/Methods.php index 0137117317d..f59dd650b9a 100644 --- a/app/code/Magento/Checkout/Block/Onepage/Payment/Methods.php +++ b/app/code/Magento/Checkout/Block/Onepage/Payment/Methods.php @@ -69,7 +69,7 @@ class Methods extends \Magento\Payment\Block\Form\Container /** * Check payment method model * - * @param \Magento\Payment\Model\Method\AbstractMethod $method + * @param \Magento\Payment\Model\MethodInterface $method * @return bool */ protected function _canUseMethod($method) @@ -94,10 +94,10 @@ class Methods extends \Magento\Payment\Block\Form\Container /** * Payment method form html getter * - * @param \Magento\Payment\Model\Method\AbstractMethod $method + * @param \Magento\Payment\Model\MethodInterface $method * @return string */ - public function getPaymentMethodFormHtml(\Magento\Payment\Model\Method\AbstractMethod $method) + public function getPaymentMethodFormHtml(\Magento\Payment\Model\MethodInterface $method) { return $this->getChildHtml('payment.method.' . $method->getCode()); } @@ -105,10 +105,10 @@ class Methods extends \Magento\Payment\Block\Form\Container /** * Return method title for payment selection page * - * @param \Magento\Payment\Model\Method\AbstractMethod $method + * @param \Magento\Payment\Model\MethodInterface $method * @return string */ - public function getMethodTitle(\Magento\Payment\Model\Method\AbstractMethod $method) + public function getMethodTitle(\Magento\Payment\Model\MethodInterface $method) { $form = $this->getChildBlock('payment.method.' . $method->getCode()); if ($form && $form->hasMethodTitle()) { @@ -120,10 +120,10 @@ class Methods extends \Magento\Payment\Block\Form\Container /** * Payment method additional label part getter * - * @param \Magento\Payment\Model\Method\AbstractMethod $method + * @param \Magento\Payment\Model\MethodInterface $method * @return string */ - public function getMethodLabelAfterHtml(\Magento\Payment\Model\Method\AbstractMethod $method) + public function getMethodLabelAfterHtml(\Magento\Payment\Model\MethodInterface $method) { $form = $this->getChildBlock('payment.method.' . $method->getCode()); if ($form) { diff --git a/app/code/Magento/Checkout/Controller/Cart.php b/app/code/Magento/Checkout/Controller/Cart.php index a8cb2355b5f..168d425e0b6 100644 --- a/app/code/Magento/Checkout/Controller/Cart.php +++ b/app/code/Magento/Checkout/Controller/Cart.php @@ -23,8 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + namespace Magento\Checkout\Controller; +use Magento\Checkout\Model\Cart as CustomerCart; + /** * Shopping cart controller */ @@ -52,47 +55,35 @@ class Cart */ protected $_formKeyValidator; + /** + * @var \Magento\Checkout\Model\Cart + */ + protected $cart; + /** * @param \Magento\App\Action\Context $context * @param \Magento\Core\Model\Store\ConfigInterface $storeConfig * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator + * @param CustomerCart $cart */ public function __construct( \Magento\App\Action\Context $context, \Magento\Core\Model\Store\ConfigInterface $storeConfig, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\App\Action\FormKeyValidator $formKeyValidator + \Magento\Core\App\Action\FormKeyValidator $formKeyValidator, + CustomerCart $cart ) { $this->_formKeyValidator = $formKeyValidator; $this->_storeConfig = $storeConfig; $this->_checkoutSession = $checkoutSession; $this->_storeManager = $storeManager; + $this->cart = $cart; parent::__construct($context); } - /** - * Retrieve shopping cart model object - * - * @return \Magento\Checkout\Model\Cart - */ - protected function _getCart() - { - return $this->_objectManager->get('Magento\Checkout\Model\Cart'); - } - - /** - * Get current active quote instance - * - * @return \Magento\Sales\Model\Quote - */ - protected function _getQuote() - { - return $this->_getCart()->getQuote(); - } - /** * Set back redirect url to response * @@ -145,16 +136,15 @@ class Cart */ public function indexAction() { - $cart = $this->_getCart(); - if ($cart->getQuote()->getItemsCount()) { - $cart->init(); - $cart->save(); + if ($this->cart->getQuote()->getItemsCount()) { + $this->cart->init(); + $this->cart->save(); - if (!$this->_getQuote()->validateMinimumAmount()) { + if (!$this->cart->getQuote()->validateMinimumAmount()) { $currencyCode = $this->_objectManager->get('Magento\Core\Model\StoreManagerInterface')->getStore() ->getCurrentCurrencyCode(); - $minimumAmount = $this->_objectManager->get('Magento\Core\Model\LocaleInterface') - ->currency($currencyCode) + $minimumAmount = $this->_objectManager->get('Magento\Locale\CurrencyInterface') + ->getCurrency($currencyCode) ->toCurrency($this->_storeConfig->getConfig('sales/minimum_order/amount')); $warning = $this->_storeConfig->getConfig('sales/minimum_order/description') @@ -168,7 +158,7 @@ class Cart // Compose array of messages to add $messages = array(); /** @var \Magento\Message\MessageInterface $message */ - foreach ($cart->getQuote()->getMessages() as $message) { + foreach ($this->cart->getQuote()->getMessages() as $message) { if ($message) { // Escape HTML entities in quote message to prevent XSS $message->setText($this->_objectManager->get('Magento\Escaper')->escapeHtml($message->getText())); @@ -200,12 +190,11 @@ class Cart */ public function addAction() { - $cart = $this->_getCart(); $params = $this->getRequest()->getParams(); try { if (isset($params['qty'])) { $filter = new \Zend_Filter_LocalizedToNormalized( - array('locale' => $this->_objectManager->get('Magento\Core\Model\LocaleInterface')->getLocaleCode()) + array('locale' => $this->_objectManager->get('Magento\Locale\ResolverInterface')->getLocaleCode()) ); $params['qty'] = $filter->filter($params['qty']); } @@ -221,12 +210,12 @@ class Cart return; } - $cart->addProduct($product, $params); + $this->cart->addProduct($product, $params); if (!empty($related)) { - $cart->addProductsByIds(explode(',', $related)); + $this->cart->addProductsByIds(explode(',', $related)); } - $cart->save(); + $this->cart->save(); $this->_checkoutSession->setCartWasUpdated(true); @@ -238,7 +227,7 @@ class Cart ); if (!$this->_checkoutSession->getNoCartRedirect(true)) { - if (!$cart->getQuote()->getHasError()) { + if (!$this->cart->getQuote()->getHasError()){ $message = __('You added %1 to your shopping cart.', $this->_objectManager->get('Magento\Escaper')->escapeHtml($product->getName())); $this->messageManager->addSuccess($message); } @@ -284,10 +273,9 @@ class Cart ->addIdFilter($orderItemIds) ->load(); /* @var $itemsCollection \Magento\Sales\Model\Resource\Order\Item\Collection */ - $cart = $this->_getCart(); foreach ($itemsCollection as $item) { try { - $cart->addOrderItem($item, 1); + $this->cart->addOrderItem($item, 1); } catch (\Magento\Core\Exception $e) { if ($this->_checkoutSession->getUseNotice(true)) { $this->messageManager->addNotice($e->getMessage()); @@ -300,7 +288,7 @@ class Cart $this->_goBack(); } } - $cart->save(); + $this->cart->save(); $this->_checkoutSession->setCartWasUpdated(true); } $this->_goBack(); @@ -316,9 +304,8 @@ class Cart // Extract item and product to configure $id = (int) $this->getRequest()->getParam('id'); $quoteItem = null; - $cart = $this->_getCart(); if ($id) { - $quoteItem = $cart->getQuote()->getItemById($id); + $quoteItem = $this->cart->getQuote()->getItemById($id); } if (!$quoteItem) { @@ -351,7 +338,6 @@ class Cart */ public function updateItemOptionsAction() { - $cart = $this->_getCart(); $id = (int) $this->getRequest()->getParam('id'); $params = $this->getRequest()->getParams(); @@ -361,17 +347,17 @@ class Cart try { if (isset($params['qty'])) { $filter = new \Zend_Filter_LocalizedToNormalized( - array('locale' => $this->_objectManager->get('Magento\Core\Model\LocaleInterface')->getLocaleCode()) + array('locale' => $this->_objectManager->get('Magento\Locale\ResolverInterface')->getLocaleCode()) ); $params['qty'] = $filter->filter($params['qty']); } - $quoteItem = $cart->getQuote()->getItemById($id); + $quoteItem = $this->cart->getQuote()->getItemById($id); if (!$quoteItem) { throw new \Magento\Core\Exception(__("We can't find the quote item.")); } - $item = $cart->updateItem($id, new \Magento\Object($params)); + $item = $this->cart->updateItem($id, new \Magento\Object($params)); if (is_string($item)) { throw new \Magento\Core\Exception($item); } @@ -381,10 +367,10 @@ class Cart $related = $this->getRequest()->getParam('related_product'); if (!empty($related)) { - $cart->addProductsByIds(explode(',', $related)); + $this->cart->addProductsByIds(explode(',', $related)); } - $cart->save(); + $this->cart->save(); $this->_checkoutSession->setCartWasUpdated(true); @@ -392,7 +378,7 @@ class Cart array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse()) ); if (!$this->_checkoutSession->getNoCartRedirect(true)) { - if (!$cart->getQuote()->getHasError()) { + if (!$this->cart->getQuote()->getHasError()){ $message = __( '%1 was updated in your shopping cart.', $this->_objectManager->get('Magento\Escaper')->escapeHtml($item->getProduct()->getName()) @@ -465,20 +451,22 @@ class Cart $cartData = $this->getRequest()->getParam('cart'); if (is_array($cartData)) { $filter = new \Zend_Filter_LocalizedToNormalized( - array('locale' => $this->_objectManager->get('Magento\Core\Model\LocaleInterface')->getLocaleCode()) + array('locale' => $this->_objectManager->get('Magento\Locale\ResolverInterface')->getLocaleCode()) ); foreach ($cartData as $index => $data) { if (isset($data['qty'])) { $cartData[$index]['qty'] = $filter->filter(trim($data['qty'])); } } - $cart = $this->_getCart(); - if (!$cart->getCustomerSession()->getCustomerId() && $cart->getQuote()->getCustomerId()) { - $cart->getQuote()->setCustomerId(null); + if (!$this->cart->getCustomerSession()->getCustomerId() + && $this->cart->getQuote()->getCustomerId() + ) { + $this->cart->getQuote()->setCustomerId(null); } - $cartData = $cart->suggestItemsQty($cartData); - $cart->updateItems($cartData) + $cartData = $this->cart->suggestItemsQty($cartData); + $this->cart + ->updateItems($cartData) ->save(); } $this->_checkoutSession->setCartWasUpdated(true); @@ -500,7 +488,7 @@ class Cart protected function _emptyShoppingCart() { try { - $this->_getCart()->truncate()->save(); + $this->cart->truncate()->save(); $this->_checkoutSession->setCartWasUpdated(true); } catch (\Magento\Core\Exception $exception) { $this->messageManager->addError($exception->getMessage()); @@ -519,7 +507,7 @@ class Cart $id = (int) $this->getRequest()->getParam('id'); if ($id) { try { - $this->_getCart()->removeItem($id) + $this->cart->removeItem($id) ->save(); } catch (\Exception $e) { $this->messageManager->addError(__('We cannot remove the item.')); @@ -543,14 +531,14 @@ class Cart $regionId = (string) $this->getRequest()->getParam('region_id'); $region = (string) $this->getRequest()->getParam('region'); - $this->_getQuote()->getShippingAddress() + $this->cart->getQuote()->getShippingAddress() ->setCountryId($country) ->setCity($city) ->setPostcode($postcode) ->setRegionId($regionId) ->setRegion($region) ->setCollectShippingRates(true); - $this->_getQuote()->save(); + $this->cart->getQuote()->save(); $this->_goBack(); } @@ -561,7 +549,7 @@ class Cart { $code = (string) $this->getRequest()->getParam('estimate_method'); if (!empty($code)) { - $this->_getQuote()->getShippingAddress()->setShippingMethod($code)/*->collectTotals()*/->save(); + $this->cart->getQuote()->getShippingAddress()->setShippingMethod($code)/*->collectTotals()*/->save(); } $this->_goBack(); } @@ -576,7 +564,7 @@ class Cart /** * No reason continue with empty shopping cart */ - if (!$this->_getCart()->getQuote()->getItemsCount()) { + if (!$this->cart->getQuote()->getItemsCount()) { $this->_goBack(); return; } @@ -584,7 +572,7 @@ class Cart $couponCode = $this->getRequest()->getParam('remove') == 1 ? '' : trim($this->getRequest()->getParam('coupon_code')); - $oldCouponCode = $this->_getQuote()->getCouponCode(); + $oldCouponCode = $this->cart->getQuote()->getCouponCode(); if (!strlen($couponCode) && !strlen($oldCouponCode)) { $this->_goBack(); @@ -595,13 +583,13 @@ class Cart $codeLength = strlen($couponCode); $isCodeLengthValid = $codeLength && $codeLength <= \Magento\Checkout\Helper\Cart::COUPON_CODE_MAX_LENGTH; - $this->_getQuote()->getShippingAddress()->setCollectShippingRates(true); - $this->_getQuote()->setCouponCode($isCodeLengthValid ? $couponCode : '') + $this->cart->getQuote()->getShippingAddress()->setCollectShippingRates(true); + $this->cart->getQuote()->setCouponCode($isCodeLengthValid ? $couponCode : '') ->collectTotals() ->save(); if ($codeLength) { - if ($isCodeLengthValid && $couponCode == $this->_getQuote()->getCouponCode()) { + if ($isCodeLengthValid && $couponCode == $this->cart->getQuote()->getCouponCode()) { $this->messageManager->addSuccess( __( 'The coupon code "%1" was applied.', diff --git a/app/code/Magento/Checkout/Controller/Express/RedirectLoginInterface.php b/app/code/Magento/Checkout/Controller/Express/RedirectLoginInterface.php new file mode 100644 index 00000000000..926cdd2be50 --- /dev/null +++ b/app/code/Magento/Checkout/Controller/Express/RedirectLoginInterface.php @@ -0,0 +1,59 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Checkout\Controller\Express; + +interface RedirectLoginInterface +{ + /** + * Returns a list of action flags [flag_key] => boolean + * @return array + */ + public function getActionFlagList(); + + /** + * Returns before_auth_url redirect parameter for customer session + * @return string|null + */ + public function getCustomerBeforeAuthUrl(); + + /** + * Returns login url parameter for redirect + * @return string|null + */ + public function getLoginUrl(); + + /** + * Returns action name which requires redirect + * @return string|null + */ + public function getRedirectActionName(); + + /** + * Retrieve response object + * + * @return \Magento\App\ResponseInterface + */ + public function getResponse(); +} \ No newline at end of file diff --git a/app/code/Magento/Checkout/Helper/Data.php b/app/code/Magento/Checkout/Helper/Data.php index 0e95aa6ed78..1b9be76164c 100644 --- a/app/code/Magento/Checkout/Helper/Data.php +++ b/app/code/Magento/Checkout/Helper/Data.php @@ -61,9 +61,9 @@ class Data extends \Magento\App\Helper\AbstractHelper protected $_checkoutSession; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @var \Magento\Checkout\Model\Resource\Agreement\CollectionFactory @@ -87,7 +87,7 @@ class Data extends \Magento\App\Helper\AbstractHelper * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Checkout\Model\Session $checkoutSession - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Checkout\Model\Resource\Agreement\CollectionFactory $agreementCollectionFactory * @param \Magento\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\TranslateInterface $translator @@ -97,7 +97,7 @@ class Data extends \Magento\App\Helper\AbstractHelper \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Checkout\Model\Resource\Agreement\CollectionFactory $agreementCollectionFactory, \Magento\Mail\Template\TransportBuilder $transportBuilder, \Magento\TranslateInterface $translator @@ -105,7 +105,7 @@ class Data extends \Magento\App\Helper\AbstractHelper $this->_coreStoreConfig = $coreStoreConfig; $this->_storeManager = $storeManager; $this->_checkoutSession = $checkoutSession; - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_agreementCollectionFactory = $agreementCollectionFactory; $this->_transportBuilder = $transportBuilder; $this->_translator = $translator; @@ -306,7 +306,7 @@ class Data extends \Magento\App\Helper\AbstractHelper ->setTemplateVars(array( 'reason' => $message, 'checkoutType' => $checkoutType, - 'dateAndTime' => $this->_locale->date(), + 'dateAndTime' => $this->_localeDate->date(), 'customer' => $checkout->getCustomerFirstname() . ' ' . $checkout->getCustomerLastname(), 'customerEmail' => $checkout->getCustomerEmail(), 'billingAddress' => $checkout->getBillingAddress(), diff --git a/app/code/Magento/Checkout/Helper/ExpressRedirect.php b/app/code/Magento/Checkout/Helper/ExpressRedirect.php new file mode 100644 index 00000000000..83618e6fcfc --- /dev/null +++ b/app/code/Magento/Checkout/Helper/ExpressRedirect.php @@ -0,0 +1,95 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Checkout\Helper; + +use Magento\Checkout\Controller\Express\RedirectLoginInterface as RedirectLoginInterface; + +class ExpressRedirect extends \Magento\App\Helper\AbstractHelper +{ + /** + * @var \Magento\App\ActionFlag + */ + protected $_actionFlag; + + /** + * @var \Magento\ObjectManager + */ + protected $_objectManager; + + /** + * Customer session + * + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * @param \Magento\App\ActionFlag $actionFlag + * @param \Magento\ObjectManager $objectManager + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\App\Helper\Context $context + */ + public function __construct( + \Magento\App\ActionFlag $actionFlag, + \Magento\ObjectManager $objectManager, + \Magento\Customer\Model\Session $customerSession, + \Magento\App\Helper\Context $context + ) { + $this->_actionFlag = $actionFlag; + $this->_objectManager = $objectManager; + $this->_customerSession = $customerSession; + + parent::__construct($context); + } + + /** + * Performs redirect to login for checkout + * @param RedirectLoginInterface $expressRedirect + * @param string|null $customerBeforeAuthUrlDefault + */ + public function redirectLogin(RedirectLoginInterface $expressRedirect, $customerBeforeAuthUrlDefault = null) + { + $this->_actionFlag->set('', 'no-dispatch', true); + foreach ($expressRedirect->getActionFlagList() as $actionKey => $actionFlag) { + $this->_actionFlag->set('', $actionKey, $actionFlag); + } + + $expressRedirect->getResponse()->setRedirect( + $this->_objectManager->get('Magento\Core\Helper\Url')->addRequestParam( + $expressRedirect->getLoginUrl(), + array('context' => 'checkout') + ) + ); + + $customerBeforeAuthUrl = $customerBeforeAuthUrlDefault; + if ($expressRedirect->getCustomerBeforeAuthUrl()) { + $customerBeforeAuthUrl = $expressRedirect->getCustomerBeforeAuthUrl(); + } + if ($customerBeforeAuthUrl) { + $this->_customerSession + ->setBeforeAuthUrl($customerBeforeAuthUrl); + } + } +} \ No newline at end of file diff --git a/app/code/Magento/Checkout/Model/Session.php b/app/code/Magento/Checkout/Model/Session.php index 198157fb3b3..5608958fb8a 100644 --- a/app/code/Magento/Checkout/Model/Session.php +++ b/app/code/Magento/Checkout/Model/Session.php @@ -286,7 +286,7 @@ class Session extends \Magento\Session\SessionManager */ public function setQuoteId($quoteId) { - $this->setData($this->_getQuoteIdKey(), $quoteId); + $this->storage->setData($this->_getQuoteIdKey(), $quoteId); } /** @@ -466,4 +466,35 @@ class Session extends \Magento\Session\SessionManager } return $this->_order; } + + /** + * Restore last active quote + * + * @return bool True if quote restored successfully, false otherwise + */ + public function restoreQuote() + { + /** @var \Magento\Sales\Model\Order $order */ + $order = $this->getLastRealOrder(); + if ($order->getId()) { + /** @var \Magento\Sales\Model\Quote $quote */ + $quote = $this->_quoteFactory->create()->load($order->getQuoteId()); + if ($quote->getId()) { + $quote->setIsActive(1) + ->setReservedOrderId(null) + ->save(); + $this->replaceQuote($quote) + ->unsLastRealOrderId(); + $this->_eventManager->dispatch( + 'restore_quote', + array( + 'order' => $order, + 'quote' => $quote + ) + ); + return true; + } + } + return false; + } } diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php index 95e9a77dd32..7809e2f8c05 100644 --- a/app/code/Magento/Checkout/Model/Type/Onepage.php +++ b/app/code/Magento/Checkout/Model/Type/Onepage.php @@ -34,7 +34,6 @@ use Magento\Customer\Service\V1\Dto\AddressBuilder; use Magento\Customer\Service\V1\Dto\Address as AddressDto; use Magento\Customer\Service\V1\CustomerGroupServiceInterface; use Magento\Customer\Model\Metadata\Form; -use Magento\Customer\Service\V1\Dto\Response\CreateCustomerAccountResponse; use Magento\Customer\Service\V1\CustomerAccountServiceInterface; use Magento\Exception\NoSuchEntityException; use Magento\Customer\Service\V1\CustomerAddressServiceInterface; @@ -367,9 +366,9 @@ class Onepage \Magento\Customer\Service\V1\CustomerMetadataServiceInterface::ENTITY_TYPE_ADDRESS, 'customer_address_edit', [], + $this->_request->isAjax(), Form::IGNORE_INVISIBLE, - [], - $this->_request->isAjax() + [] ); if (!empty($customerAddressId)) { @@ -507,9 +506,9 @@ class Onepage CustomerMetadata::ENTITY_TYPE_CUSTOMER, 'checkout_register', $customerData, + $this->_request->isAjax(), Form::IGNORE_INVISIBLE, - [], - $this->_request->isAjax() + [] ); if ($isCustomerNew) { @@ -586,9 +585,9 @@ class Onepage 'customer_address', 'customer_address_edit', [], + $this->_request->isAjax(), Form::IGNORE_INVISIBLE, - [], - $this->_request->isAjax() + [] ); if (!empty($customerAddressId)) { @@ -687,11 +686,6 @@ class Onepage return array('error' => -1, 'message' => __('Invalid data')); } $quote = $this->getQuote(); - if ($quote->isVirtual()) { - $quote->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null); - } else { - $quote->getShippingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null); - } // shipping totals may be affected by payment method if (!$quote->isVirtual() && $quote->getShippingAddress()) { @@ -854,13 +848,13 @@ class Onepage /** * Involve new customer to system * - * @param CreateCustomerAccountResponse $createCustomerResponse * @return $this */ - protected function _involveNewCustomer(CreateCustomerAccountResponse $createCustomerResponse) + protected function _involveNewCustomer() { $customer = $this->getQuote()->getCustomerData(); - if ($createCustomerResponse->getStatus() == CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION) { + $confirmationStatus = $this->_accountService->getConfirmationStatus($customer->getCustomerId()); + if ($confirmationStatus === CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_REQUIRED) { $url = $this->_customerData->getEmailConfirmationUrl($customer->getEmail()); $this->messageManager->addSuccess( __('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%1">click here</a>.', $url) @@ -899,7 +893,7 @@ class Onepage if ($isNewCustomer) { try { - $this->_involveNewCustomer($quoteService->getCreateCustomerResponse()); + $this->_involveNewCustomer(); } catch (\Exception $e) { $this->_logger->logException($e); } @@ -918,7 +912,6 @@ class Onepage /** * a flag to set that there will be redirect to third party after confirmation - * eg: paypal standard ipn */ $redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl(); /** diff --git a/app/code/Magento/Checkout/etc/frontend/di.xml b/app/code/Magento/Checkout/etc/frontend/di.xml index a4a19590fc8..0ddb33dce86 100644 --- a/app/code/Magento/Checkout/etc/frontend/di.xml +++ b/app/code/Magento/Checkout/etc/frontend/di.xml @@ -36,14 +36,4 @@ </argument> </arguments> </type> - <virtualType name="checkoutCartInitSession" type="Magento\Core\App\Action\Plugin\Session"> - <arguments> - <argument name="cookieCheckActions" xsi:type="array"> - <item name="checkoutCartAdd" xsi:type="string">add</item> - </argument> - </arguments> - </virtualType> - <type name="Magento\Checkout\Controller\Cart"> - <plugin name="sessionInitializer" type="checkoutCartInitSession" /> - </type> </config> diff --git a/app/code/Magento/Checkout/view/frontend/js/opcheckout.js b/app/code/Magento/Checkout/view/frontend/js/opcheckout.js index 892cb9d1da0..f34cec74692 100644 --- a/app/code/Magento/Checkout/view/frontend/js/opcheckout.js +++ b/app/code/Magento/Checkout/view/frontend/js/opcheckout.js @@ -513,7 +513,6 @@ continueSelector: '#review-buttons-container .button', container: '#opc-review', agreementFormSelector:'#checkout-agreements input[type="checkbox"]', - submitContainer: '#checkout-review-submit' } }, @@ -522,14 +521,6 @@ var events = {}; events['click ' + this.options.review.continueSelector] = this._saveOrder; events['saveOrder' + this.options.review.container] = this._saveOrder; - events['contentUpdated' + this.options.review.container] = function() { - var paypalIframe = this.element.find(this.options.review.container) - .find('[data-container="paypal-iframe"]'); - if (paypalIframe.length) { - paypalIframe.show(); - $(this.options.review.submitContainer).hide(); - } - }; this._on(events); }, diff --git a/app/code/Magento/Checkout/view/frontend/layout/catalog_category_view.xml b/app/code/Magento/Checkout/view/frontend/layout/catalog_category_view.xml new file mode 100644 index 00000000000..f43e517aa09 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/layout/catalog_category_view.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceContainer name="content"> + <block class="Magento\Core\Block\RequireCookie" name="require-cookie" template="Magento_Core::require_cookie.phtml"> + <arguments> + <argument name="triggers" xsi:type="array"> + <item name="addToCartLink" xsi:type="string">.action.tocart</item> + </argument> + </arguments> + </block> + </referenceContainer> +</layout> diff --git a/app/code/Magento/Checkout/view/frontend/layout/catalog_product_view.xml b/app/code/Magento/Checkout/view/frontend/layout/catalog_product_view.xml new file mode 100644 index 00000000000..f43e517aa09 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/layout/catalog_product_view.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceContainer name="content"> + <block class="Magento\Core\Block\RequireCookie" name="require-cookie" template="Magento_Core::require_cookie.phtml"> + <arguments> + <argument name="triggers" xsi:type="array"> + <item name="addToCartLink" xsi:type="string">.action.tocart</item> + </argument> + </arguments> + </block> + </referenceContainer> +</layout> diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_item_renderers.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_item_renderers.xml index 58b443ce6ba..9c8f2332cb7 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_item_renderers.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_item_renderers.xml @@ -25,8 +25,8 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceBlock name="checkout.cart.item.renderers"> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="cart/item/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="simple" template="cart/item/default.phtml" cacheable="false"/> + <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="cart/item/default.phtml"/> + <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="simple" template="cart/item/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml index 1b657c135c1..724aca3315c 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml @@ -25,8 +25,8 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceBlock name="checkout.cart.sidebar.item.renderers"> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="cart/sidebar/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="simple" template="cart/sidebar/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="virtual" template="cart/sidebar/default.phtml" cacheable="false"/> + <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="cart/sidebar/default.phtml"/> + <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="simple" template="cart/sidebar/default.phtml"/> + <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="virtual" template="cart/sidebar/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_index.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_index.xml index 698d4799289..86381dd2c78 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_index.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_index.xml @@ -45,12 +45,7 @@ <block class="Magento\Checkout\Block\Onepage\Shipping\Method\Additional" name="checkout.onepage.shipping_method.additional" as="additional" template="onepage/shipping_method/additional.phtml"/> </block> <block class="Magento\Checkout\Block\Onepage\Payment" name="checkout.onepage.payment" as="payment" template="onepage/payment.phtml" cacheable="false"> - <block class="Magento\Checkout\Block\Onepage\Payment\Methods" name="checkout.payment.methods" as="methods" template="onepage/payment/methods.phtml" cacheable="false"> - <action method="setMethodFormTemplate"> - <argument name="method" xsi:type="string">purchaseorder</argument> - <argument name="template" xsi:type="string">Magento_Payment::form/purchaseorder.phtml</argument> - </action> - </block> + <block class="Magento\Checkout\Block\Onepage\Payment\Methods" name="checkout.payment.methods" as="methods" template="onepage/payment/methods.phtml" cacheable="false"/> <block class="Magento\View\Element\Template" name="checkout.onepage.payment.additional" as="additional"/> <block class="Magento\View\Element\Template" name="checkout.onepage.payment.methods_additional" as="methods_additional"/> </block> diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_paymentmethod.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_paymentmethod.xml index c73eba27b6f..28b4a433c6e 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_paymentmethod.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_paymentmethod.xml @@ -25,10 +25,6 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <block class="Magento\Checkout\Block\Onepage\Payment\Methods" name="payment_method" output="1" template="onepage/payment/methods.phtml" cacheable="false"> - <action method="setMethodFormTemplate"> - <argument name="method" xsi:type="string">purchaseorder</argument> - <argument name="template" xsi:type="string">Magento_Payment::form/purchaseorder.phtml</argument> - </action> <block class="Magento\View\Element\Template" name="checkout.onepage.payment.methods.scripts" as="scripts"/> <block class="Magento\View\Element\Template" name="checkout.onepage.payment.methods.additional" as="additional"/> </block> diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_review_item_renderers.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_review_item_renderers.xml index a28347c1176..ac24c92628f 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_review_item_renderers.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_review_item_renderers.xml @@ -25,7 +25,7 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceBlock name="checkout.onepage.review.item.renderers"> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="onepage/review/item.phtml" cacheable="false"/> + <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="onepage/review/item.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Checkout/view/frontend/layout/default.xml b/app/code/Magento/Checkout/view/frontend/layout/default.xml index e0333555e30..f8fae42de45 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/default.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/default.xml @@ -29,7 +29,7 @@ <block class="Magento\View\Element\Js\Components" name="checkout_page_head_components" template="Magento_Checkout::js/components.phtml"/> </referenceBlock> <referenceContainer name="header-wrapper"> - <block class="Magento\Checkout\Block\Cart\Sidebar" name="minicart" as="minicart" after="logo" template="cart/minicart.phtml" cacheable="false"> + <block class="Magento\Checkout\Block\Cart\Sidebar" name="minicart" as="minicart" after="logo" template="cart/minicart.phtml"> <block class="Magento\View\Element\RendererList" name="checkout.cart.sidebar.item.renderers" as="renderer.list" /> <container name="minicart.extra.info" as="minicart_info" label="My Cart Extra info"/> <container name="topCart.extra_actions" as="extra_actions" label="My Cart Extra Actions"> diff --git a/app/code/Magento/Cms/Block/Adminhtml/Page/Edit/Tab/Design.php b/app/code/Magento/Cms/Block/Adminhtml/Page/Edit/Tab/Design.php index 31b6b2926b5..21c23e63b8e 100644 --- a/app/code/Magento/Cms/Block/Adminhtml/Page/Edit/Tab/Design.php +++ b/app/code/Magento/Cms/Block/Adminhtml/Page/Edit/Tab/Design.php @@ -125,7 +125,7 @@ class Design 'disabled' => $isElementDisabled )); - $dateFormat = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $dateFormat = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); $designFieldset->addField('custom_theme_from', 'date', array( 'name' => 'custom_theme_from', diff --git a/app/code/Magento/Cms/Block/Block.php b/app/code/Magento/Cms/Block/Block.php index 83bf4353e12..ecd4e480ef5 100644 --- a/app/code/Magento/Cms/Block/Block.php +++ b/app/code/Magento/Cms/Block/Block.php @@ -29,7 +29,7 @@ namespace Magento\Cms\Block; /** * Cms block content block */ -class Block extends \Magento\View\Element\AbstractBlock +class Block extends \Magento\View\Element\AbstractBlock implements \Magento\View\Block\IdentityInterface { /** * @var \Magento\Cms\Model\Template\FilterProvider @@ -93,4 +93,14 @@ class Block extends \Magento\View\Element\AbstractBlock } return $html; } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + return array(\Magento\Cms\Model\Block::CACHE_TAG . '_' . $this->getBlockId()); + } } diff --git a/app/code/Magento/Cms/Block/Page.php b/app/code/Magento/Cms/Block/Page.php index 6bbfca883c2..e739e2fdfd5 100644 --- a/app/code/Magento/Cms/Block/Page.php +++ b/app/code/Magento/Cms/Block/Page.php @@ -28,7 +28,7 @@ namespace Magento\Cms\Block; /** * Cms page content block */ -class Page extends \Magento\View\Element\AbstractBlock +class Page extends \Magento\View\Element\AbstractBlock implements \Magento\View\Block\IdentityInterface { /** * @var \Magento\Cms\Model\Template\FilterProvider @@ -153,4 +153,14 @@ class Page extends \Magento\View\Element\AbstractBlock $html = $this->getLayout()->renderElement('messages') . $html; return $html; } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + return array(\Magento\Cms\Model\Page::CACHE_TAG . '_' . $this->getPageId()); + } } diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page.php b/app/code/Magento/Cms/Controller/Adminhtml/Page.php index d0713cd0fbf..33c451ae1eb 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Page.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Page.php @@ -42,19 +42,19 @@ class Page extends \Magento\Backend\App\Action protected $_coreRegistry = null; /** - * @var \Magento\Core\Filter\Date + * @var \Magento\Stdlib\DateTime\Filter\Date */ protected $_dateFilter; /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Registry $coreRegistry - * @param \Magento\Core\Filter\Date $dateFilter + * @param \Magento\Stdlib\DateTime\Filter\Date $dateFilter */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Registry $coreRegistry, - \Magento\Core\Filter\Date $dateFilter + \Magento\Stdlib\DateTime\Filter\Date $dateFilter ) { $this->_coreRegistry = $coreRegistry; $this->_dateFilter = $dateFilter; diff --git a/app/code/Magento/Cms/Helper/Page.php b/app/code/Magento/Cms/Helper/Page.php index bb2c47e7931..1278fb0fe69 100644 --- a/app/code/Magento/Cms/Helper/Page.php +++ b/app/code/Magento/Cms/Helper/Page.php @@ -65,11 +65,9 @@ class Page extends \Magento\App\Helper\AbstractHelper protected $messageManager; /** - * Locale - * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * Store manager @@ -103,7 +101,7 @@ class Page extends \Magento\App\Helper\AbstractHelper * @param \Magento\View\DesignInterface $design * @param \Magento\Cms\Model\PageFactory $pageFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Escaper $escaper * @param \Magento\App\ViewInterface $view */ @@ -115,7 +113,7 @@ class Page extends \Magento\App\Helper\AbstractHelper \Magento\View\DesignInterface $design, \Magento\Cms\Model\PageFactory $pageFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Escaper $escaper, \Magento\App\ViewInterface $view ) { @@ -126,7 +124,8 @@ class Page extends \Magento\App\Helper\AbstractHelper $this->_design = $design; $this->_pageFactory = $pageFactory; $this->_storeManager = $storeManager; - $this->_locale = $locale; + $this->_storeManager = $storeManager; + $this->_localeDate = $localeDate; $this->_escaper = $escaper; parent::__construct($context); } @@ -171,7 +170,7 @@ class Page extends \Magento\App\Helper\AbstractHelper return false; } - $inRange = $this->_locale->isStoreDateInInterval(null, $this->_page->getCustomThemeFrom(), + $inRange = $this->_localeDate->isScopeDateInInterval(null, $this->_page->getCustomThemeFrom(), $this->_page->getCustomThemeTo()); if ($this->_page->getCustomTheme()) { diff --git a/app/code/Magento/Cms/Model/Block.php b/app/code/Magento/Cms/Model/Block.php index 96b119da21a..9f5ef81f352 100644 --- a/app/code/Magento/Cms/Model/Block.php +++ b/app/code/Magento/Cms/Model/Block.php @@ -44,7 +44,7 @@ namespace Magento\Cms\Model; * @method int getIsActive() * @method \Magento\Cms\Model\Block setIsActive(int $value) */ -class Block extends \Magento\Core\Model\AbstractModel +class Block extends \Magento\Core\Model\AbstractModel implements \Magento\Object\IdentityInterface { /** * CMS block cache tag @@ -87,4 +87,14 @@ class Block extends \Magento\Core\Model\AbstractModel __('Make sure that static block content does not reference the block itself.') ); } + + /** + * Get identities + * + * @return array + */ + public function getIdentities() + { + return array(self::CACHE_TAG . '_' . $this->getId()); + } } diff --git a/app/code/Magento/Cms/Model/Page.php b/app/code/Magento/Cms/Model/Page.php index 4ac0adb57c7..b71f3f5aacb 100644 --- a/app/code/Magento/Cms/Model/Page.php +++ b/app/code/Magento/Cms/Model/Page.php @@ -66,7 +66,7 @@ namespace Magento\Cms\Model; * @method string getCustomThemeTo() * @method \Magento\Cms\Model\Page setCustomThemeTo(string $value) */ -class Page extends \Magento\Core\Model\AbstractModel +class Page extends \Magento\Core\Model\AbstractModel implements \Magento\Object\IdentityInterface { /** * No route page id @@ -154,4 +154,14 @@ class Page extends \Magento\Core\Model\AbstractModel self::STATUS_DISABLED => __('Disabled'), ); } + + /** + * Get identities + * + * @return array + */ + public function getIdentities() + { + return array(self::CACHE_TAG . '_' . $this->getId()); + } } diff --git a/app/code/Magento/Cms/Model/Resource/Block.php b/app/code/Magento/Cms/Model/Resource/Block.php index fc22d5abd10..2503e3f4f65 100644 --- a/app/code/Magento/Cms/Model/Resource/Block.php +++ b/app/code/Magento/Cms/Model/Resource/Block.php @@ -32,7 +32,7 @@ namespace Magento\Cms\Model\Resource; class Block extends \Magento\Core\Model\Resource\Db\AbstractDb { /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -47,12 +47,12 @@ class Block extends \Magento\Core\Model\Resource\Db\AbstractDb * Construct * * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Core\Model\StoreManagerInterface $storeManager */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\Core\Model\StoreManagerInterface $storeManager ) { parent::__construct($resource); diff --git a/app/code/Magento/Cms/Model/Resource/Page.php b/app/code/Magento/Cms/Model/Resource/Page.php index c9c863dac0d..d38a39606ca 100644 --- a/app/code/Magento/Cms/Model/Resource/Page.php +++ b/app/code/Magento/Cms/Model/Resource/Page.php @@ -39,7 +39,7 @@ class Page extends \Magento\Core\Model\Resource\Db\AbstractDb protected $_store = null; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -59,13 +59,13 @@ class Page extends \Magento\Core\Model\Resource\Db\AbstractDb * Construct * * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Stdlib\DateTime $dateTime */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Stdlib\DateTime $dateTime ) { diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config.php index b97431e8661..78b0aae7cfc 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config.php @@ -32,8 +32,6 @@ namespace Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super; use \Magento\ConfigurableProduct\Model\Product\Type\Configurable; use Magento\Catalog\Model\Product; -use Magento\Core\Model\App; -use Magento\Core\Model\LocaleInterface; class Config extends \Magento\Backend\Block\Widget @@ -60,17 +58,29 @@ class Config */ protected $_configurableType; + /** + * @var \Magento\Locale\CurrencyInterface + */ + protected $_localeCurrency; + /** * @var \Magento\Json\EncoderInterface */ protected $_jsonEncoder; + /** + * @var \Magento\App\ConfigInterface + */ + protected $_config; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Json\EncoderInterface $jsonEncoder - * @param \Magento\ConfigurableProduct\Model\Product\Type\Configurable $configurableType + * @param Configurable $configurableType * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Registry $coreRegistry + * @param \Magento\App\ConfigInterface $config + * @param \Magento\Locale\CurrencyInterface $localeCurrency * @param array $data */ public function __construct( @@ -79,12 +89,16 @@ class Config \Magento\ConfigurableProduct\Model\Product\Type\Configurable $configurableType, \Magento\Catalog\Helper\Data $catalogData, \Magento\Registry $coreRegistry, + \Magento\App\ConfigInterface $config, + \Magento\Locale\CurrencyInterface $localeCurrency, array $data = array() ) { $this->_configurableType = $configurableType; $this->_coreRegistry = $coreRegistry; $this->_catalogData = $catalogData; $this->_jsonEncoder = $jsonEncoder; + $this->_config = $config; + $this->_localeCurrency = $localeCurrency; parent::__construct($context, $data); } @@ -141,7 +155,7 @@ class Config public function isAttributesPricesReadonly() { return $this->getProduct()->getAttributesConfigurationReadonly() || - ($this->_catalogData->isPriceGlobal() && $this->isReadonly()); + ($this->_catalogData->isPriceGlobal() && $this->isReadonly()); } /** @@ -172,9 +186,9 @@ class Config 'target' => '#product-variations-matrix', 'eventData' => array( 'url' => $this->getUrl( - 'catalog/product_generateVariations/index', - array('_current' => true) - ), + 'catalog/product_generateVariations/index', + array('_current' => true) + ), ), ), ), @@ -192,20 +206,20 @@ class Config 'mage-init' => array( 'configurableAttribute' => array( 'url' => $this->getUrl( - 'catalog/product_attribute/new', - array( - 'store' => $this->getProduct()->getStoreId(), - 'product_tab' => 'variations', - 'popup' => 1, - '_query' => array( - 'attribute' => array( - 'is_global' => 1, - 'frontend_input' => 'select', - 'is_configurable' => 1 - ), + 'catalog/product_attribute/new', + array( + 'store' => $this->getProduct()->getStoreId(), + 'product_tab' => 'variations', + 'popup' => 1, + '_query' => array( + 'attribute' => array( + 'is_global' => 1, + 'frontend_input' => 'select', + 'is_configurable' => 1 + ), + ) ) ) - ) ) ) ), @@ -404,22 +418,6 @@ class Config return 'product-details'; } - /** - * @return App - */ - public function getApp() - { - return $this->_app; - } - - /** - * @return LocaleInterface - */ - public function getLocale() - { - return $this->_locale; - } - /** * Get base application currency * @@ -427,6 +425,8 @@ class Config */ public function getBaseCurrency() { - return $this->getLocale()->currency($this->getApp()->getBaseCurrencyCode()); + return $this->_localeCurrency->getCurrency( + $this->_config->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, 'default') + ); } } diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php index cae997622f2..d3b8a94b61a 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config/Matrix.php @@ -56,12 +56,24 @@ class Matrix */ protected $_config; + /** + * @var \Magento\App\ConfigInterface + */ + protected $_applicationConfig; + + /** + * @var \Magento\Locale\CurrencyInterface + */ + protected $_localeCurrency; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\ConfigurableProduct\Model\Product\Type\Configurable $configurableType * @param \Magento\Catalog\Model\Config $config * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Registry $coreRegistry + * @param \Magento\App\ConfigInterface $applicationConfig + * @param \Magento\Locale\CurrencyInterface $localeCurrency * @param array $data */ public function __construct( @@ -70,12 +82,16 @@ class Matrix \Magento\Catalog\Model\Config $config, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Registry $coreRegistry, + \Magento\App\ConfigInterface $applicationConfig, + \Magento\Locale\CurrencyInterface $localeCurrency, array $data = array() ) { $this->_configurableType = $configurableType; $this->_productFactory = $productFactory; $this->_config = $config; $this->_coreRegistry = $coreRegistry; + $this->_applicationConfig = $applicationConfig; + $this->_localeCurrency = $localeCurrency; parent::__construct($context, $data); } @@ -87,7 +103,9 @@ class Matrix */ public function renderPrice($price) { - return $this->_locale->currency($this->_app->getBaseCurrencyCode())->toCurrency(sprintf('%f', $price)); + return $this->_localeCurrency->getCurrency( + $this->_applicationConfig->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, 'default') + )->toCurrency(sprintf('%f', $price)); } /** diff --git a/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php index 38055b25ec3..8e389f672dd 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php @@ -28,7 +28,7 @@ use Magento\Catalog\Model\Config\Source\Product\Thumbnail as ThumbnailSource; /** * Shopping cart item render block for configurable products. */ -class Configurable extends \Magento\Checkout\Block\Cart\Item\Renderer +class Configurable extends \Magento\Checkout\Block\Cart\Item\Renderer implements \Magento\View\Block\IdentityInterface { /** * Path in config to the setting which defines if parent or child product should be used to generate a thumbnail. @@ -116,4 +116,18 @@ class Configurable extends \Magento\Checkout\Block\Cart\Item\Renderer } return $product; } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + $identities = parent::getIdentities(); + if ($this->getItem()) { + $identities = array_merge($identities, $this->getChildProduct()->getIdentities()); + } + return $identities; + } } diff --git a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php index ebaf66a7cd7..86a33c2e29e 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php @@ -26,6 +26,7 @@ namespace Magento\ConfigurableProduct\Block\Product\View\Type; use Magento\Catalog\Model\Product\PriceModifierInterface; +use Magento\Customer\Controller\RegistryConstants; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -37,14 +38,14 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView * * @var array */ - protected $_prices = array(); + protected $_prices = array(); /** * Prepared prices * * @var array */ - protected $_resPrices = array(); + protected $_resPrices = array(); /** * Catalog product @@ -222,26 +223,26 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView public function getJsonConfig() { $attributes = array(); - $options = array(); - $store = $this->getCurrentStore(); - $taxHelper = $this->_taxData; + $options = array(); + $store = $this->getCurrentStore(); + $taxHelper = $this->_taxData; $currentProduct = $this->getProduct(); $preConfiguredValues = null; $preConfiguredFlag = $currentProduct->hasPreconfiguredValues(); if ($preConfiguredFlag) { $preConfiguredValues = $currentProduct->getPreconfiguredValues(); - $defaultValues = array(); + $defaultValues = array(); } foreach ($this->getAllowProducts() as $product) { - $productId = $product->getId(); + $productId = $product->getId(); $image = $this->_imageHelper->init($product, 'image'); foreach ($this->getAllowAttributes() as $attribute) { - $productAttribute = $attribute->getProductAttribute(); + $productAttribute = $attribute->getProductAttribute(); $productAttributeId = $productAttribute->getId(); - $attributeValue = $product->getData($productAttribute->getAttributeCode()); + $attributeValue = $product->getData($productAttribute->getAttributeCode()); if (!isset($options[$productAttributeId])) { $options[$productAttributeId] = array(); } @@ -264,10 +265,10 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView $productAttribute = $attribute->getProductAttribute(); $attributeId = $productAttribute->getId(); $info = array( - 'id' => $productAttribute->getId(), - 'code' => $productAttribute->getAttributeCode(), - 'label' => $attribute->getLabel(), - 'options' => array() + 'id' => $productAttribute->getId(), + 'code' => $productAttribute->getAttributeCode(), + 'label' => $attribute->getLabel(), + 'options' => array() ); $optionPrices = array(); @@ -281,9 +282,12 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView $this->_preparePrice($value['pricing_value'], $value['is_percent']) ); $currentProduct->setParentId(true); - $currentProduct->setConfigurablePrice($this->priceModifier->modifyPrice( - $currentProduct->getConfigurablePrice(), $currentProduct - )); + $currentProduct->setConfigurablePrice( + $this->priceModifier->modifyPrice( + $currentProduct->getConfigurablePrice(), + $currentProduct + ) + ); $configurablePrice = $currentProduct->getConfigurablePrice(); if (isset($options[$attributeId][$value['value_index']])) { @@ -293,11 +297,11 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView } $info['options'][] = array( - 'id' => $value['value_index'], - 'label' => $value['label'], - 'price' => $configurablePrice, - 'oldPrice' => $this->_prepareOldPrice($value['pricing_value'], $value['is_percent']), - 'products' => $productsIndex, + 'id' => $value['value_index'], + 'label' => $value['label'], + 'price' => $configurablePrice, + 'oldPrice' => $this->_prepareOldPrice($value['pricing_value'], $value['is_percent']), + 'products' => $productsIndex, ); $optionPrices[] = $configurablePrice; } @@ -307,7 +311,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView */ foreach ($optionPrices as $optionPrice) { foreach ($optionPrices as $additional) { - $this->_preparePrice(abs($additional-$optionPrice)); + $this->_preparePrice(abs($additional - $optionPrice)); } } if ($this->_validateAttributeInfo($info)) { @@ -323,8 +327,8 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView } } - if (!$this->priceHelper->getCustomer() && $this->_coreRegistry->registry('current_customer')) { - $this->priceHelper->setCustomer($this->_coreRegistry->registry('current_customer')); + if (!$this->priceHelper->getCustomer() && $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER)) { + $this->priceHelper->setCustomer($this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER)); } $_request = $this->priceHelper->getRateRequest(false, false, false); @@ -336,23 +340,23 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView $currentTax = $this->priceHelper->getRate($_request); $taxConfig = array( - 'includeTax' => $taxHelper->priceIncludesTax(), - 'showIncludeTax' => $taxHelper->displayPriceIncludingTax(), - 'showBothPrices' => $taxHelper->displayBothPrices(), - 'defaultTax' => $defaultTax, - 'currentTax' => $currentTax, - 'inclTaxTitle' => __('Incl. Tax') + 'includeTax' => $taxHelper->priceIncludesTax(), + 'showIncludeTax' => $taxHelper->displayPriceIncludingTax(), + 'showBothPrices' => $taxHelper->displayBothPrices(), + 'defaultTax' => $defaultTax, + 'currentTax' => $currentTax, + 'inclTaxTitle' => __('Incl. Tax') ); $config = array( - 'attributes' => $attributes, - 'template' => str_replace('%s', '#{price}', $store->getCurrentCurrency()->getOutputFormat()), - 'basePrice' => $this->_registerJsPrice($this->_convertPrice($currentProduct->getFinalPrice())), - 'oldPrice' => $this->_registerJsPrice($this->_convertPrice($currentProduct->getPrice())), - 'productId' => $currentProduct->getId(), - 'chooseText' => __('Choose an Option...'), - 'taxConfig' => $taxConfig, - 'images' => $options['images'], + 'attributes' => $attributes, + 'template' => str_replace('%s', '#{price}', $store->getCurrentCurrency()->getOutputFormat()), + 'basePrice' => $this->_registerJsPrice($this->_convertPrice($currentProduct->getFinalPrice())), + 'oldPrice' => $this->_registerJsPrice($this->_convertPrice($currentProduct->getPrice())), + 'productId' => $currentProduct->getId(), + 'chooseText' => __('Choose an Option...'), + 'taxConfig' => $taxConfig, + 'images' => $options['images'], ); if ($preConfiguredFlag && !empty($defaultValues)) { diff --git a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Builder/Plugin.php b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Builder/Plugin.php index 5995ff5fea8..8a932e2eb97 100644 --- a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Builder/Plugin.php +++ b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Builder/Plugin.php @@ -25,7 +25,6 @@ namespace Magento\ConfigurableProduct\Controller\Adminhtml\Product\Builder; use Magento\Catalog\Model\ProductFactory; -use Magento\Code\Plugin\InvocationChain; use Magento\ConfigurableProduct\Model\Product\Type; class Plugin @@ -51,17 +50,20 @@ class Plugin } /** - * @param array $arguments - * @param InvocationChain $invocationChain + * @param \Magento\Catalog\Controller\Adminhtml\Product\Builder $subject + * @param callable $proceed + * @param \Magento\App\RequestInterface $request + * * @return \Magento\Catalog\Model\Product + * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - public function aroundBuild(array $arguments, InvocationChain $invocationChain) - { - /** @var \Magento\Catalog\Model\Product $product */ - $product = $invocationChain->proceed($arguments); - /** @var \Magento\App\RequestInterface $request */ - $request = $arguments[0]; + public function aroundBuild( + \Magento\Catalog\Controller\Adminhtml\Product\Builder $subject, + \Closure $proceed, + \Magento\App\RequestInterface $request + ) { + $product = $proceed($request); if ($request->has('attributes')) { $attributes = $request->getParam('attributes'); diff --git a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php index 0cc8aabb2b5..00a2e7ec65c 100644 --- a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php @@ -42,11 +42,16 @@ class Configurable /** * Initialize data for configurable product * + * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject * @param \Magento\Catalog\Model\Product $product + * * @return \Magento\Catalog\Model\Product + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterInitialize(\Magento\Catalog\Model\Product $product) - { + public function afterInitialize( + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject, + \Magento\Catalog\Model\Product $product + ) { $attributes = $this->request->getParam('attributes'); if (!empty($attributes)) { $this->productType->setUsedProductAttributeIds($attributes, $product); diff --git a/app/code/Magento/ConfigurableProduct/Helper/Product/Configuration/Plugin.php b/app/code/Magento/ConfigurableProduct/Helper/Product/Configuration/Plugin.php index 2a0c7583556..0d149e86d79 100644 --- a/app/code/Magento/ConfigurableProduct/Helper/Product/Configuration/Plugin.php +++ b/app/code/Magento/ConfigurableProduct/Helper/Product/Configuration/Plugin.php @@ -24,27 +24,29 @@ */ namespace Magento\ConfigurableProduct\Helper\Product\Configuration; -use Magento\Code\Plugin\InvocationChain; - class Plugin { /** * Retrieve configuration options for configurable product * - * @param array $arguments - * @param InvocationChain $invocationChain + * @param \Magento\Catalog\Helper\Product\Configuration $subject + * @param callable $proceed + * @param \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface $item + * * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundGetOptions(array $arguments, InvocationChain $invocationChain) - { - /** @var \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface $item */ - $item = $arguments[0]; + public function aroundGetOptions( + \Magento\Catalog\Helper\Product\Configuration $subject, + \Closure $proceed, + \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface $item + ) { $product = $item->getProduct(); $typeId = $product->getTypeId(); if ($typeId == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) { $attributes = $product->getTypeInstance()->getSelectedAttributesInfo($product); - return array_merge($attributes, $invocationChain->proceed($arguments)); + return array_merge($attributes, $proceed($item)); } - return $invocationChain->proceed($arguments); + return $proceed($item); } } diff --git a/app/code/Magento/ConfigurableProduct/Model/Entity/Product/Attribute/Group/AttributeMapper/Plugin.php b/app/code/Magento/ConfigurableProduct/Model/Entity/Product/Attribute/Group/AttributeMapper/Plugin.php index 4974db606b0..1a92c792d76 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Entity/Product/Attribute/Group/AttributeMapper/Plugin.php +++ b/app/code/Magento/ConfigurableProduct/Model/Entity/Product/Attribute/Group/AttributeMapper/Plugin.php @@ -25,7 +25,6 @@ */ namespace Magento\ConfigurableProduct\Model\Entity\Product\Attribute\Group\AttributeMapper; -use Magento\Code\Plugin\InvocationChain; use Magento\Registry; use Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\AttributeFactory; @@ -61,15 +60,20 @@ class Plugin /** * Add is_configurable field to attribute presentation * - * @param array $arguments - * @param InvocationChain $invocationChain - * @return mixed + * @param \Magento\Catalog\Model\Entity\Product\Attribute\Group\AttributeMapperInterface $subject + * @param callable $proceed + * @param \Magento\Eav\Model\Entity\Attribute $attribute + * + * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundMap($arguments, InvocationChain $invocationChain) - { + public function aroundMap( + \Magento\Catalog\Model\Entity\Product\Attribute\Group\AttributeMapperInterface $subject, + \Closure $proceed, + \Magento\Eav\Model\Entity\Attribute $attribute + ) { $setId = $this->registry->registry('current_attribute_set')->getId(); - $attribute = $arguments[0]; - $result = $invocationChain->proceed($arguments); + $result = $proceed($attribute); if (!isset($this->configurableAttributes[$setId])) { $this->configurableAttributes[$setId] = $this->attributeFactory->create()->getUsedAttributes($setId); } diff --git a/app/code/Magento/ConfigurableProduct/Model/Import/Entity/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Import/Entity/Product/Type/Configurable.php index 0e85fd9a58f..2c9b674481e 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Import/Entity/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Import/Entity/Product/Type/Configurable.php @@ -259,14 +259,30 @@ class Configurable /** * Array of SKU to array of super attribute values for all products. * + * @param array $bunch - portion of products to process + * @param array $newSku - imported variations list + * @param array $oldSku - present variations list * @return $this */ - protected function _loadSkuSuperAttributeValues() + protected function _loadSkuSuperAttributeValues($bunch, $newSku, $oldSku) { if ($this->_superAttributes) { $attrSetIdToName = $this->_entityModel->getAttrSetIdToName(); + + $productIds = array(); + foreach ($bunch as $rowData) { + if (!empty($rowData['_super_products_sku'])) { + if (isset($newSku[$rowData['_super_products_sku']])) { + $productIds[] = $newSku[$rowData['_super_products_sku']]['entity_id']; + } elseif (isset($oldSku[$rowData['_super_products_sku']])) { + $productIds[] = $oldSku[$rowData['_super_products_sku']]['entity_id']; + } + } + } + foreach ($this->_productColFac->create() ->addFieldToFilter('type_id', $this->_productTypesConfig->getComposableTypes()) + ->addFieldToFilter ('entity_id', array('in' => $productIds)) ->addAttributeToSelect(array_keys($this->_superAttributes)) as $product) { $attrSetName = $attrSetIdToName[$product->getAttributeSetId()]; @@ -401,7 +417,6 @@ class Configurable if ($this->_entityModel->getBehavior() == \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND) { $this->_loadSkuSuperData(); } - $this->_loadSkuSuperAttributeValues(); while ($bunch = $this->_entityModel->getNextBunch()) { $superAttributes = array( @@ -411,6 +426,9 @@ class Configurable 'super_link' => array(), 'relation' => array() ); + + $this->_loadSkuSuperAttributeValues($bunch, $newSku, $oldSku); + foreach ($bunch as $rowNum => $rowData) { if (!$this->_entityModel->isRowAllowedToImport($rowData, $rowNum)) { continue; diff --git a/app/code/Magento/ConfigurableProduct/Model/Order/Admin/Item/Plugin/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Order/Admin/Item/Plugin/Configurable.php index 4b7beeb884e..54fac3e11dd 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Order/Admin/Item/Plugin/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Order/Admin/Item/Plugin/Configurable.php @@ -42,63 +42,69 @@ class Configurable /** * Get item sku * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\Sales\Model\Order\Admin\Item $subject + * @param callable $proceed + * @param \Magento\Sales\Model\Order\Item $item * * @return string + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundGetSku(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - /** @var \Magento\Sales\Model\Order\Item $item */ - list($item) = $arguments; - + public function aroundGetSku( + \Magento\Sales\Model\Order\Admin\Item $subject, + \Closure $proceed, + \Magento\Sales\Model\Order\Item $item + ) { if ($item->getProductType() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) { $productOptions = $item->getProductOptions(); return $productOptions['simple_sku']; } - return $invocationChain->proceed($arguments); + return $proceed($item); } /** * Get item name * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\Sales\Model\Order\Admin\Item $subject + * @param callable $proceed + * @param \Magento\Sales\Model\Order\Item $item * * @return string + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundGetName(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - /** @var \Magento\Sales\Model\Order\Item $item */ - list($item) = $arguments; - + public function aroundGetName( + \Magento\Sales\Model\Order\Admin\Item $subject, + \Closure $proceed, + \Magento\Sales\Model\Order\Item $item + ) { if ($item->getProductType() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) { $productOptions = $item->getProductOptions(); return $productOptions['simple_name']; } - return $invocationChain->proceed($arguments); + return $proceed($item); } /** * Get product id * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\Sales\Model\Order\Admin\Item $subject + * @param callable $proceed + * @param \Magento\Sales\Model\Order\Item $item * * @return int + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundGetProductId(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - /** @var \Magento\Sales\Model\Order\Item $item */ - list($item) = $arguments; - + public function aroundGetProductId( + \Magento\Sales\Model\Order\Admin\Item $subject, + \Closure $proceed, + \Magento\Sales\Model\Order\Item $item + ) { if ($item->getProductType() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) { $productOptions = $item->getProductOptions(); $product = $this->productFactory->create(); return $product->getIdBySku($productOptions['simple_sku']); } - return $invocationChain->proceed($arguments); + return $proceed($item); } } diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/CartConfiguration/Plugin/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/CartConfiguration/Plugin/Configurable.php index 00d666da637..2d471cb04e1 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/CartConfiguration/Plugin/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/CartConfiguration/Plugin/Configurable.php @@ -26,26 +26,29 @@ namespace Magento\ConfigurableProduct\Model\Product\CartConfiguration\Plugin; -use Magento\Code\Plugin\InvocationChain; - class Configurable { /** * Decide whether product has been configured for cart or not * - * @param array $arguments - * @param InvocationChain $invocationChain + * @param \Magento\Catalog\Model\Product\CartConfiguration $subject + * @param callable $proceed + * @param \Magento\Catalog\Model\Product $product + * @param array $config + * * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundIsProductConfigured(array $arguments, InvocationChain $invocationChain) - { - /** @var $product \Magento\Catalog\Model\Product */ - list($product, $config) = $arguments; - + public function aroundIsProductConfigured( + \Magento\Catalog\Model\Product\CartConfiguration $subject, + \Closure $proceed, + \Magento\Catalog\Model\Product $product, + $config + ) { if ($product->getTypeId() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) { return isset($config['super_attribute']); } - return $invocationChain->proceed($arguments); + return $proceed($product, $config); } } diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php index d9024b0560d..dc7ecb665dd 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Price.php @@ -37,7 +37,7 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price /** * @param \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Event\ManagerInterface $eventManager * @param PriceModifierInterface $priceModifier @@ -45,13 +45,13 @@ class Price extends \Magento\Catalog\Model\Product\Type\Price public function __construct( \Magento\CatalogRule\Model\Resource\RuleFactory $ruleFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Event\ManagerInterface $eventManager, PriceModifierInterface $priceModifier ) { $this->priceModifier = $priceModifier; - parent::__construct($ruleFactory, $storeManager, $locale, $customerSession, $eventManager); + parent::__construct($ruleFactory, $storeManager, $localeDate, $customerSession, $eventManager); } /** diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Plugin.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Plugin.php index 996bc4f6e61..237afbe2a40 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Plugin.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Plugin.php @@ -44,11 +44,16 @@ class Plugin /** * Remove grouped product from list of visible product types * + * @param \Magento\Catalog\Model\Product\Type $subject * @param array $result * @return array + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterGetOptionArray($result) - { + public function afterGetOptionArray( + \Magento\Catalog\Model\Product\Type $subject, + array $result + ) { if (!$this->moduleManager->isOutputEnabled('Magento_ConfigurableProduct')) { unset($result[Configurable::TYPE_CODE]); } diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/TypeTransitionManager/Plugin/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/TypeTransitionManager/Plugin/Configurable.php index a6c38151720..2dbb67b7802 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/TypeTransitionManager/Plugin/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/TypeTransitionManager/Plugin/Configurable.php @@ -25,8 +25,7 @@ */ namespace Magento\ConfigurableProduct\Model\Product\TypeTransitionManager\Plugin; -use Magento\App\RequestInterface, - Magento\Code\Plugin\InvocationChain; +use Magento\App\RequestInterface; class Configurable { @@ -40,27 +39,31 @@ class Configurable /** * @param RequestInterface $request */ - public function __construct( - RequestInterface $request - ) { + public function __construct(RequestInterface $request) + { $this->request = $request; } /** * Change product type to configurable if needed * - * @param array $arguments - * @param InvocationChain $invocationChain + * @param \Magento\Catalog\Model\Product\TypeTransitionManager $subject + * @param callable $proceed + * @param \Magento\Catalog\Model\Product $product + * + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundProcessProduct(array $arguments, InvocationChain $invocationChain) - { - /** @var \Magento\Catalog\Model\Product $product */ - $product = $arguments[0]; + public function aroundProcessProduct( + \Magento\Catalog\Model\Product\TypeTransitionManager $subject, + \Closure $proceed, + \Magento\Catalog\Model\Product $product + ) { $attributes = $this->request->getParam('attributes'); if (!empty($attributes)) { $product->setTypeId(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE); return; } - $invocationChain->proceed($arguments); + $proceed($product); } } diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Validator/Plugin.php b/app/code/Magento/ConfigurableProduct/Model/Product/Validator/Plugin.php index ba512b779be..cdcbc4e4020 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Validator/Plugin.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Validator/Plugin.php @@ -26,10 +26,8 @@ namespace Magento\ConfigurableProduct\Model\Product\Validator; use Magento\App\RequestInterface; -use Magento\App\ResponseInterface; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\ProductFactory; -use Magento\Code\Plugin\InvocationChain; use Magento\Event\Manager; use Magento\Core\Helper; @@ -65,19 +63,23 @@ class Plugin /** * Validate product data * - * @param $arguments - * @param InvocationChain $invocationChain - * @return ResponseInterface + * @param Product\Validator $subject + * @param callable $proceed + * @param Product $product + * @param RequestInterface $request + * @param \Magento\Object $response + * + * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundValidate(array $arguments, InvocationChain $invocationChain) - { - /** @var Product $product */ - $product = $arguments[0]; - /** @var RequestInterface $request */ - $request = $arguments[1]; - /** @var \Magento\Object $response */ - $response = $arguments[2]; - $result = $invocationChain->proceed($arguments); + public function aroundValidate( + \Magento\Catalog\Model\Product\Validator $subject, + \Closure $proceed, + \Magento\Catalog\Model\Product $product, + \Magento\App\RequestInterface $request, + \Magento\Object $response + ) { + $result = $proceed($product, $request, $response); $variationProducts = (array)$request->getPost('variations-matrix'); if ($variationProducts) { $validationResult = $this->_validateProductVariations($product, $variationProducts, $request); diff --git a/app/code/Magento/ConfigurableProduct/Model/Quote/Item/QuantityValidator/Initializer/Option/Plugin/ConfigurableProduct.php b/app/code/Magento/ConfigurableProduct/Model/Quote/Item/QuantityValidator/Initializer/Option/Plugin/ConfigurableProduct.php index 6682d047a8b..5fb2b31f643 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Quote/Item/QuantityValidator/Initializer/Option/Plugin/ConfigurableProduct.php +++ b/app/code/Magento/ConfigurableProduct/Model/Quote/Item/QuantityValidator/Initializer/Option/Plugin/ConfigurableProduct.php @@ -31,23 +31,25 @@ class ConfigurableProduct /** * Initialize stock item for configurable product type * - * @param array $arguments + * @param \Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\Initializer\Option $subject + * @param \Magento\Sales\Model\Quote\Item\Option $option + * @param \Magento\Sales\Model\Quote\Item $quoteItem + * @param int $qty * - * @return array + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeInitialize(array $arguments) - { - /** @var \Magento\Sales\Model\Quote\Item\Option $option */ - /** @var \Magento\Sales\Model\Quote\Item $quoteItem */ - list($option, $quoteItem) = $arguments; - + public function beforeInitialize( + \Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\Initializer\Option $subject, + \Magento\Sales\Model\Quote\Item\Option $option, + \Magento\Sales\Model\Quote\Item $quoteItem, + $qty + ) { /* @var $stockItem \Magento\CatalogInventory\Model\Stock\Item */ $stockItem = $option->getProduct()->getStockItem(); if ($quoteItem->getProductType() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) { $stockItem->setProductName($quoteItem->getName()); } - - return $arguments; } } diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php index 5da0573a48b..3bf5be85dde 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php +++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Collection/AssociatedProduct.php @@ -72,7 +72,7 @@ class AssociatedProduct * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Registry $registryManager @@ -99,7 +99,7 @@ class AssociatedProduct \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\Resource\Url $catalogUrl, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Stdlib\DateTime $dateTime, \Magento\Registry $registryManager, @@ -126,7 +126,7 @@ class AssociatedProduct $coreStoreConfig, $productOptionFactory, $catalogUrl, - $locale, + $localeDate, $customerSession, $dateTime, $connection diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable.php index 5a5a8d07aa3..220a7da1945 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable.php @@ -232,7 +232,7 @@ class Configurable extends \Magento\Core\Model\Resource\Db\AbstractDb array() )->where('super_attribute.product_id = ?', $product->getId()); - $attributesOptionsData[$superAttribute->getAttributeId()] = $this->_getReadAdapter()->fetchAssoc($select); + $attributesOptionsData[$superAttribute->getAttributeId()] = $this->_getReadAdapter()->fetchAll($select); } return $attributesOptionsData; } diff --git a/app/code/Magento/ConfigurableProduct/etc/module.xml b/app/code/Magento/ConfigurableProduct/etc/module.xml index e672a24aa1e..652af01ec84 100644 --- a/app/code/Magento/ConfigurableProduct/etc/module.xml +++ b/app/code/Magento/ConfigurableProduct/etc/module.xml @@ -47,6 +47,7 @@ <module name="Magento_ImportExport" /> <module name="Magento_Customer" /> <module name="Magento_CatalogRule" /> + <module name="Magento_Directory" /> </depends> </module> </config> diff --git a/app/code/Magento/Connect/Helper/Data.php b/app/code/Magento/Connect/Helper/Data.php index afc081bda5a..fa681aaf96b 100644 --- a/app/code/Magento/Connect/Helper/Data.php +++ b/app/code/Magento/Connect/Helper/Data.php @@ -49,7 +49,6 @@ class Data extends \Magento\Core\Helper\Data * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Locale $locale * @param \Magento\App\State $appState * @param \Magento\App\Filesystem $filesystem * @param \Magento\Convert\Xml $xmlConverter @@ -59,7 +58,6 @@ class Data extends \Magento\Core\Helper\Data \Magento\App\Helper\Context $context, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Locale $locale, \Magento\App\State $appState, \Magento\App\Filesystem $filesystem, \Magento\Convert\Xml $xmlConverter, @@ -72,7 +70,6 @@ class Data extends \Magento\Core\Helper\Data $context, $coreStoreConfig, $storeManager, - $locale, $appState, $dbCompatibleMode ); diff --git a/app/code/Magento/Contacts/Model/System/Config/Backend/Links.php b/app/code/Magento/Contacts/Model/System/Config/Backend/Links.php index f2076dc9c33..86413945f44 100644 --- a/app/code/Magento/Contacts/Model/System/Config/Backend/Links.php +++ b/app/code/Magento/Contacts/Model/System/Config/Backend/Links.php @@ -30,7 +30,7 @@ */ namespace Magento\Contacts\Model\System\Config\Backend; -class Links extends \Magento\Backend\Model\Config\Backend\Cache +class Links extends \Magento\Backend\Model\Config\Backend\Cache implements \Magento\Object\IdentityInterface { /** * Cache tags to clean @@ -39,4 +39,15 @@ class Links extends \Magento\Backend\Model\Config\Backend\Cache */ protected $_cacheTags = array(\Magento\Core\Model\Store::CACHE_TAG, \Magento\Cms\Model\Block::CACHE_TAG); + + /** + * Get identities + * + * @return array + */ + public function getIdentities() + { + return array(\Magento\Core\Model\Store::CACHE_TAG, \Magento\Cms\Model\Block::CACHE_TAG); + } + } diff --git a/app/code/Magento/Core/App/Action/Plugin/Design.php b/app/code/Magento/Core/App/Action/Plugin/Design.php index 2f827f31ee2..4600a371c04 100644 --- a/app/code/Magento/Core/App/Action/Plugin/Design.php +++ b/app/code/Magento/Core/App/Action/Plugin/Design.php @@ -42,13 +42,19 @@ class Design /** * Initialize design * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\App\Action\Action $subject + * @param callable $proceed + * @param \Magento\App\RequestInterface $request + * * @return mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundDispatch(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { + public function aroundDispatch( + \Magento\App\Action\Action $subject, + \Closure $proceed, + \Magento\App\RequestInterface $request + ) { $this->_designLoader->load(); - return $invocationChain->proceed($arguments); + return $proceed($request); } } diff --git a/app/code/Magento/Core/App/Action/Plugin/Install.php b/app/code/Magento/Core/App/Action/Plugin/Install.php index c01e18ed402..03a20991462 100644 --- a/app/code/Magento/Core/App/Action/Plugin/Install.php +++ b/app/code/Magento/Core/App/Action/Plugin/Install.php @@ -69,12 +69,16 @@ class Install /** * Dispatch request * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain - * @return mixed + * @param \Magento\App\Action\Action $subject + * @param callable $proceed + * @param \Magento\App\RequestInterface $request + * @return \Magento\App\ResponseInterface */ - public function aroundDispatch(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { + public function aroundDispatch( + \Magento\App\Action\Action $subject, + \Closure $proceed, + \Magento\App\RequestInterface $request + ) { if (!$this->_appState->isInstalled()) { $this->_actionFlag->set('', \Magento\App\Action\Action::FLAG_NO_DISPATCH, true); $this->_response->setRedirect( @@ -82,6 +86,6 @@ class Install ); return $this->_response; } - return $invocationChain->proceed($arguments); + return $proceed($request); } } diff --git a/app/code/Magento/Core/App/Action/Plugin/LastUrl.php b/app/code/Magento/Core/App/Action/Plugin/LastUrl.php index c00533cb547..389d3cc455b 100644 --- a/app/code/Magento/Core/App/Action/Plugin/LastUrl.php +++ b/app/code/Magento/Core/App/Action/Plugin/LastUrl.php @@ -64,13 +64,19 @@ class LastUrl /** * Process request * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\App\Action\Action $subject + * @param callable $proceed + * @param \Magento\App\RequestInterface $request + * * @return mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundDispatch(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - $result = $invocationChain->proceed($arguments); + public function aroundDispatch( + \Magento\App\Action\Action $subject, + \Closure $proceed, + \Magento\App\RequestInterface $request + ) { + $result = $proceed($request); $this->_session->setLastUrl($this->_url->getUrl('*/*/*', array('_current' => true))); return $result; } diff --git a/app/code/Magento/Core/App/Action/Plugin/Session.php b/app/code/Magento/Core/App/Action/Plugin/Session.php deleted file mode 100644 index 1f4cb5fa6af..00000000000 --- a/app/code/Magento/Core/App/Action/Plugin/Session.php +++ /dev/null @@ -1,157 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Core\App\Action\Plugin; - -class Session -{ - /** - * @var \Magento\Core\Model\Session - */ - protected $_session; - - /** - * @var \Magento\Session\SidResolverInterface - */ - protected $_sidResolver; - - /** - * @var \Magento\Stdlib\Cookie - */ - protected $_cookie; - - /** - * @var string[] - */ - protected $_cookieCheckActions; - - /** - * @var \Magento\UrlInterface - */ - protected $_url; - - /** - * @var string - */ - protected $_sessionNamespace; - - /** - * @var \Magento\App\ActionFlag - */ - protected $_flag; - - /** - * @var \Magento\Core\Model\Store\Config - */ - protected $_storeConfig; - - /** - * @var \Magento\App\ResponseInterface - */ - protected $_response; - - /** - * @param \Magento\App\ActionFlag $flag - * @param \Magento\App\ResponseInterface $response - * @param \Magento\Core\Model\Session $session - * @param \Magento\Stdlib\Cookie $cookie - * @param \Magento\UrlInterface $url - * @param \Magento\Core\Model\Store\Config $storeConfig - * @param \Magento\Session\SidResolverInterface $sidResolver - * @param string $sessionNamespace - * @param string[] $cookieCheckActions - */ - public function __construct( - \Magento\App\ActionFlag $flag, - \Magento\App\ResponseInterface $response, - \Magento\Core\Model\Session $session, - \Magento\Stdlib\Cookie $cookie, - \Magento\UrlInterface $url, - \Magento\Core\Model\Store\Config $storeConfig, - \Magento\Session\SidResolverInterface $sidResolver, - $sessionNamespace = '', - array $cookieCheckActions = array() - ) { - $this->_session = $session; - $this->_response = $response; - $this->_sidResolver = $sidResolver; - $this->_cookie = $cookie; - $this->_cookieCheckActions = $cookieCheckActions; - $this->_url = $url; - $this->_sessionNamespace = $sessionNamespace; - $this->_flag = $flag; - $this->_storeConfig = $storeConfig; - } - - /** - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain - * @return mixed - */ - public function aroundDispatch(array $arguments = array(), \Magento\Code\Plugin\InvocationChain $invocationChain) - { - $request = $arguments[0]; - $checkCookie = in_array($request->getActionName(), $this->_cookieCheckActions) - && !$request->getParam('nocookie', false); - - $cookies = $this->_cookie->get(); - - if (empty($cookies)) { - if ($this->_session->getCookieShouldBeReceived()) { - $this->_session->unsCookieShouldBeReceived(); - if ($this->_storeConfig->getConfig('web/browser_capabilities/cookies')) { - $this->_forward($request); - return $this->_response; - } - } elseif ($checkCookie) { - if ($request->getQuery($this->_sidResolver->getSessionIdQueryParam($this->_session), false) - && $this->_url->getUseSession() - && $this->_sessionNamespace != \Magento\Backend\App\AbstractAction::SESSION_NAMESPACE - ) { - $this->_session->setCookieShouldBeReceived(true); - } else { - $this->_forward($request); - return $this->_response; - } - } - } - return $invocationChain->proceed($arguments); - } - - /** - * Forward to noCookies action - * - * @param \Magento\App\RequestInterface $request - * @return \Magento\App\RequestInterface - */ - protected function _forward(\Magento\App\RequestInterface $request) - { - $request->initForward(); - $request->setActionName('noCookies'); - $request->setControllerName('index'); - $request->setModuleName('core'); - $request->setDispatched(false); - return $request; - } -} diff --git a/app/code/Magento/Core/App/Action/Plugin/StoreCheck.php b/app/code/Magento/Core/App/Action/Plugin/StoreCheck.php index c4de0ef8733..ba7c3f58d93 100644 --- a/app/code/Magento/Core/App/Action/Plugin/StoreCheck.php +++ b/app/code/Magento/Core/App/Action/Plugin/StoreCheck.php @@ -25,7 +25,6 @@ namespace Magento\Core\App\Action\Plugin; - class StoreCheck { /** @@ -43,18 +42,21 @@ class StoreCheck } /** - * Dispatch request + * @param \Magento\App\Action\Action $subject + * @param callable $proceed + * @param \Magento\App\RequestInterface $request * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain - * @return mixed + * @return \Magento\App\ResponseInterface + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundDispatch(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - if (!$this->_storeManager->getStore()->getIsActive()) - { + public function aroundDispatch( + \Magento\App\Action\Action $subject, + \Closure $proceed, + \Magento\App\RequestInterface $request + ) { + if (!$this->_storeManager->getStore()->getIsActive()) { $this->_storeManager->throwStoreException(); } - return $invocationChain->proceed($arguments); + return $proceed($request); } -} \ No newline at end of file +} diff --git a/app/code/Magento/Core/App/FrontController/Plugin/DispatchExceptionHandler.php b/app/code/Magento/Core/App/FrontController/Plugin/DispatchExceptionHandler.php index ad537e54a5c..97a3f5d5331 100644 --- a/app/code/Magento/Core/App/FrontController/Plugin/DispatchExceptionHandler.php +++ b/app/code/Magento/Core/App/FrontController/Plugin/DispatchExceptionHandler.php @@ -57,19 +57,25 @@ class DispatchExceptionHandler /** * Handle dispatch exceptions * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\App\FrontController $subject + * @param callable $proceed + * @param \Magento\App\RequestInterface $request + * * @return mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundDispatch(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { + public function aroundDispatch( + \Magento\App\FrontController $subject, + \Closure $proceed, + \Magento\App\RequestInterface $request + ) { try { - return $invocationChain->proceed($arguments); + return $proceed($request); } catch (\Magento\Session\Exception $e) { header('Location: ' . $this->_storeManager->getStore()->getBaseUrl()); exit; } catch (\Magento\Core\Model\Store\Exception $e) { - require $this->filesystem->getPath(Filesystem::PUB) . '/errors/404.php'; + require $this->filesystem->getPath(Filesystem::PUB_DIR) . '/errors/404.php'; exit; } } diff --git a/app/code/Magento/Core/App/FrontController/Plugin/RequestPreprocessor.php b/app/code/Magento/Core/App/FrontController/Plugin/RequestPreprocessor.php index 8ac6239e9a4..d27d40d82d2 100644 --- a/app/code/Magento/Core/App/FrontController/Plugin/RequestPreprocessor.php +++ b/app/code/Magento/Core/App/FrontController/Plugin/RequestPreprocessor.php @@ -75,13 +75,18 @@ class RequestPreprocessor * Auto-redirect to base url (without SID) if the requested url doesn't match it. * By default this feature is enabled in configuration. * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain - * @return mixed + * @param \Magento\App\FrontController $subject + * @param callable $proceed + * @param \Magento\App\RequestInterface $request + * + * @return \Magento\App\ResponseInterface + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundDispatch(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - $request = $arguments[0]; + public function aroundDispatch( + \Magento\App\FrontController $subject, + \Closure $proceed, + \Magento\App\RequestInterface $request + ) { if ($this->_appState->isInstalled() && !$request->isPost() && $this->_isBaseUrlCheckEnabled()) { $baseUrl = $this->_storeManager->getStore()->getBaseUrl( \Magento\UrlInterface::URL_TYPE_WEB, @@ -105,7 +110,7 @@ class RequestPreprocessor } $request->setDispatched(false); - return $invocationChain->proceed($arguments); + return $proceed($request); } /** diff --git a/app/code/Magento/Core/App/FrontController/Plugin/UrlRewrite.php b/app/code/Magento/Core/App/FrontController/Plugin/UrlRewrite.php index 4960535c5cb..35f3cf2865d 100644 --- a/app/code/Magento/Core/App/FrontController/Plugin/UrlRewrite.php +++ b/app/code/Magento/Core/App/FrontController/Plugin/UrlRewrite.php @@ -41,8 +41,10 @@ class UrlRewrite * @param \Magento\Core\App\Request\RewriteService $rewriteService * @param \Magento\App\State $state */ - public function __construct(\Magento\Core\App\Request\RewriteService $rewriteService, \Magento\App\State $state) - { + public function __construct( + \Magento\Core\App\Request\RewriteService $rewriteService, + \Magento\App\State $state + ) { $this->_rewriteService = $rewriteService; $this->_state = $state; } @@ -50,17 +52,22 @@ class UrlRewrite /** * Perform url rewites * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain - * @return mixed + * @param \Magento\App\FrontController $subject + * @param callable $proceed + * @param \Magento\App\RequestInterface $request + * + * @return \Magento\App\ResponseInterface + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundDispatch(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { + public function aroundDispatch( + \Magento\App\FrontController $subject, + \Closure $proceed, + \Magento\App\RequestInterface $request + ) { if (!$this->_state->isInstalled()) { - return $invocationChain->proceed($arguments); + return $proceed($request); } - $request = $arguments[0]; $this->_rewriteService->applyRewrites($request); - return $invocationChain->proceed($arguments); + return $proceed($request); } -} \ No newline at end of file +} diff --git a/dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleClassPluginA.php b/app/code/Magento/Core/Block/RequireCookie.php similarity index 69% rename from dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleClassPluginA.php rename to app/code/Magento/Core/Block/RequireCookie.php index 9482b6809f7..4482f96e298 100644 --- a/dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleClassPluginA.php +++ b/app/code/Magento/Core/Block/RequireCookie.php @@ -19,23 +19,29 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Code - * @subpackage unit_tests + * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Code\Plugin\GeneratorTest; -class SimpleClassPluginA +/** + * Frontend form key content block + */ +namespace Magento\Core\Block; + +class RequireCookie extends \Magento\View\Element\Template { /** - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * Retrieve script options encoded to json + * * @return string */ - public function aroundDoWork(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) + public function getScriptOptions() { - return '<PluginA>' . $invocationChain->proceed($arguments) . '</PluginA>'; + $params = array( + 'noCookieUrl' => $this->getUrl('core/index/noCookies/'), + 'triggers' => $this->getTriggers() + ); + return json_encode($params); } } - diff --git a/app/code/Magento/Core/Filter/DateTime.php b/app/code/Magento/Core/Filter/DateTime.php deleted file mode 100644 index 0a22d90027c..00000000000 --- a/app/code/Magento/Core/Filter/DateTime.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php -/** - * Date/Time filter. Converts datetime from localized to internal format. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -/** - * @todo move this class to library when locale interface is moved - */ -namespace Magento\Core\Filter; - -use Magento\Core\Model\LocaleInterface; - -class DateTime extends Date -{ - /** - * @param LocaleInterface $locale - */ - public function __construct( - LocaleInterface $locale - ) { - parent::__construct($locale); - $this->_localToNormalFilter = new \Zend_Filter_LocalizedToNormalized(array( - 'date_format' => $locale->getDateTimeFormat(LocaleInterface::FORMAT_TYPE_SHORT) - )); - $this->_normalToLocalFilter = new \Zend_Filter_NormalizedToLocalized(array( - 'date_format' => \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT - )); - } -} diff --git a/app/code/Magento/Core/Helper/Data.php b/app/code/Magento/Core/Helper/Data.php index 7c27e83e885..8922686f541 100644 --- a/app/code/Magento/Core/Helper/Data.php +++ b/app/code/Magento/Core/Helper/Data.php @@ -46,10 +46,10 @@ class Data extends \Magento\App\Helper\AbstractHelper * @var string[] */ protected $_allowedFormats = array( - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_FULL, - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_LONG, - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM, - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_FULL, + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_LONG, + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT ); /** @@ -71,11 +71,6 @@ class Data extends \Magento\App\Helper\AbstractHelper */ protected $_storeManager; - /** - * @var \Magento\Core\Model\Locale - */ - protected $_locale; - /** * @var \Magento\App\State */ @@ -90,7 +85,6 @@ class Data extends \Magento\App\Helper\AbstractHelper * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Locale $locale * @param \Magento\App\State $appState * @param bool $dbCompatibleMode */ @@ -98,14 +92,12 @@ class Data extends \Magento\App\Helper\AbstractHelper \Magento\App\Helper\Context $context, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Locale $locale, \Magento\App\State $appState, $dbCompatibleMode = true ) { parent::__construct($context); $this->_coreStoreConfig = $coreStoreConfig; $this->_storeManager = $storeManager; - $this->_locale = $locale; $this->_appState = $appState; $this->_dbCompatibleMode = $dbCompatibleMode; } diff --git a/app/code/Magento/Core/Helper/File/Media.php b/app/code/Magento/Core/Helper/File/Media.php index 023228c3ee6..f50d81415ed 100644 --- a/app/code/Magento/Core/Helper/File/Media.php +++ b/app/code/Magento/Core/Helper/File/Media.php @@ -32,7 +32,7 @@ namespace Magento\Core\Helper\File; class Media extends \Magento\App\Helper\AbstractHelper { /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -45,12 +45,12 @@ class Media extends \Magento\App\Helper\AbstractHelper * Constructor * * @param \Magento\App\Helper\Context $context - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\App\Filesystem $filesystem */ public function __construct( \Magento\App\Helper\Context $context, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\App\Filesystem $filesystem ) { parent::__construct($context); diff --git a/app/code/Magento/Core/Helper/Js.php b/app/code/Magento/Core/Helper/Js.php index 0c90317e9ad..0435090cb27 100644 --- a/app/code/Magento/Core/Helper/Js.php +++ b/app/code/Magento/Core/Helper/Js.php @@ -192,9 +192,9 @@ class Js extends \Magento\App\Helper\AbstractHelper $this->_addTranslation('Please enter issue number or start date for switch/solo card type.', __('Please enter issue number or start date for switch/solo card type.')); //js.js $this->_addTranslation('This date is a required value.', __('This date is a required value.')); - $this->_addTranslation('Please enter a valid day (1-%d).', __('Please enter a valid day (1-%d).')); + $this->_addTranslation('Please enter a valid day (1-%1).', __('Please enter a valid day (1-%1).')); $this->_addTranslation('Please enter a valid month (1-12).', __('Please enter a valid month (1-12).')); - $this->_addTranslation('Please enter a valid year (1900-%d).', __('Please enter a valid year (1900-%d).')); + $this->_addTranslation('Please enter a valid year (1900-%1).', __('Please enter a valid year (1900-%1).')); $this->_addTranslation('Please enter a valid full date', __('Please enter a valid full date')); //various files $this->_addTranslation('Allow', __('Allow')); @@ -209,7 +209,7 @@ class Js extends \Magento\App\Helper\AbstractHelper $this->_addTranslation('Gift Options for ', __('Gift Options for ')); $this->_addTranslation('New Option', __('New Option')); $this->_addTranslation('Add Products to New Option', __('Add Products to New Option')); - $this->_addTranslation('Add Products to Option "%s"', __('Add Products to Option "%s"')); + $this->_addTranslation('Add Products to Option "%1"', __('Add Products to Option "%1"')); $this->_addTranslation('Add Selected Products', __('Add Selected Products')); $this->_addTranslation('Select type of option.', __('Select type of option.')); $this->_addTranslation('Please add rows to option.', __('Please add rows to option.')); @@ -246,7 +246,7 @@ class Js extends \Magento\App\Helper\AbstractHelper $this->_addTranslation('Close', __('Close')); $this->_addTranslation('Please enter a value less than or equal to %s.', __('Please enter a value less than or equal to %s.')); $this->_addTranslation('Please enter a value greater than or equal to %s.', __('Please enter a value greater than or equal to %s.')); - $this->_addTranslation('Maximum length of this field must be equal or less than %s symbols.', __('Maximum length of this field must be equal or less than %s symbols.')); + $this->_addTranslation('Maximum length of this field must be equal or less than %1 symbols.', __('Maximum length of this field must be equal or less than %1 symbols.')); $this->_addTranslation('No records found.', __('No records found.')); $this->_addTranslation('Recent items', __('Recent items')); $this->_addTranslation('Show all...', __('Show all...')); diff --git a/app/code/Magento/Core/Helper/Translate.php b/app/code/Magento/Core/Helper/Translate.php index 2455ddaf1f3..d2589494f61 100644 --- a/app/code/Magento/Core/Helper/Translate.php +++ b/app/code/Magento/Core/Helper/Translate.php @@ -45,28 +45,18 @@ class Translate extends \Magento\App\Helper\AbstractHelper */ protected $_inlineParser; - /** - * Translate library - * - * @var \Magento\Translate - */ - protected $_translator; - /** * @param \Magento\App\Helper\Context $context * @param \Magento\View\DesignInterface $design * @param \Magento\Translate\Inline\ParserInterface $inlineParser - * @param \Magento\Translate $translate */ public function __construct( \Magento\App\Helper\Context $context, \Magento\View\DesignInterface $design, - \Magento\Translate\Inline\ParserInterface $inlineParser, - \Magento\Translate $translate + \Magento\Translate\Inline\ParserInterface $inlineParser ) { $this->_design = $design; $this->_inlineParser = $inlineParser; - $this->_translator = $translate; parent::__construct($context); } @@ -92,28 +82,4 @@ class Translate extends \Magento\App\Helper\AbstractHelper } return $result; } - - /** - * This method initializes the Translate object for this instance. - * - * @param string $localeCode - * @param bool $forceReload - * @param null $area - * @return $this - */ - public function initTranslate($localeCode, $forceReload, $area = null) - { - $this->_translator->setLocale($localeCode); - - $dispatchResult = new \Magento\Object(array( - 'inline_type' => null - )); - $this->_eventManager->dispatch('translate_initialization_before', array( - 'translate_object' => $this->_translator, - 'result' => $dispatchResult - )); - $area = isset($area) ? $area : $this->_design->getArea(); - $this->_translator->init($area, $dispatchResult, $forceReload); - return $this; - } } diff --git a/app/code/Magento/Core/Model/AbstractModel.php b/app/code/Magento/Core/Model/AbstractModel.php index 67098c79a76..b7674027754 100644 --- a/app/code/Magento/Core/Model/AbstractModel.php +++ b/app/code/Magento/Core/Model/AbstractModel.php @@ -596,6 +596,7 @@ abstract class AbstractModel extends \Magento\Object { $this->cleanModelCache(); $this->_eventManager->dispatch('model_save_after', array('object' => $this)); + $this->_eventManager->dispatch('clean_cache_by_tags', array('object' => $this)); $this->_eventManager->dispatch($this->_eventPrefix . '_save_after', $this->_getEventData()); return $this; } @@ -660,6 +661,7 @@ abstract class AbstractModel extends \Magento\Object protected function _afterDelete() { $this->_eventManager->dispatch('model_delete_after', array('object' => $this)); + $this->_eventManager->dispatch('clean_cache_by_tags', array('object' => $this)); $this->_eventManager->dispatch($this->_eventPrefix . '_delete_after', $this->_getEventData()); return $this; } diff --git a/app/code/Magento/Core/Model/App.php b/app/code/Magento/Core/Model/App.php index 1e055605f13..e20ab31225a 100644 --- a/app/code/Magento/Core/Model/App.php +++ b/app/code/Magento/Core/Model/App.php @@ -50,7 +50,7 @@ class App implements \Magento\AppInterface /** * Magento version */ - const VERSION = '2.0.0.0-dev67'; + const VERSION = '2.0.0.0-dev68'; /** * Application run code @@ -84,13 +84,6 @@ class App implements \Magento\AppInterface */ protected $_areas = array(); - /** - * Application location object - * - * @var LocaleInterface - */ - protected $_locale; - /** * Application configuration object * @@ -98,20 +91,6 @@ class App implements \Magento\AppInterface */ protected $_config; - /** - * Application front controller - * - * @var \Magento\App\FrontControllerInterface - */ - protected $_frontController; - - /** - * Flag to identify whether front controller is initialized - * - * @var bool - */ - protected $_isFrontControllerInitialized = false; - /** * Cache object * @@ -169,7 +148,6 @@ class App implements \Magento\AppInterface * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\App\State $appState * @param \Magento\Config\Scope $configScope - * @param \Magento\App\FrontControllerInterface $frontController */ public function __construct( \Magento\App\ConfigInterface $config, @@ -177,8 +155,7 @@ class App implements \Magento\AppInterface \Magento\ObjectManager $objectManager, \Magento\Event\ManagerInterface $eventManager, \Magento\App\State $appState, - \Magento\Config\Scope $configScope, - \Magento\App\FrontControllerInterface $frontController + \Magento\Config\Scope $configScope ) { $this->_config = $config; $this->_cache = $cache; @@ -186,7 +163,6 @@ class App implements \Magento\AppInterface $this->_appState = $appState; $this->_eventManager = $eventManager; $this->_configScope = $configScope; - $this->_frontController = $frontController; } /** @@ -264,19 +240,6 @@ class App implements \Magento\AppInterface return self::DISTRO_LOCALE_CODE; } - /** - * Retrieve application locale object - * - * @return LocaleInterface - */ - public function getLocale() - { - if (!$this->_locale) { - $this->_locale = $this->_objectManager->get('Magento\Core\Model\LocaleInterface'); - } - return $this->_locale; - } - /** * Retrieve layout object * @@ -307,16 +270,6 @@ class App implements \Magento\AppInterface return $this->_config; } - /** - * Retrieve front controller object - * - * @return \Magento\App\FrontController - */ - public function getFrontController() - { - return $this->_frontController; - } - /** * Get core cache model * @@ -516,7 +469,7 @@ class App implements \Magento\AppInterface 'revision' => '0', 'patch' => '0', 'stability' => 'dev', - 'number' => '67', + 'number' => '68', ); } } diff --git a/app/code/Magento/Core/Model/App/Area.php b/app/code/Magento/Core/Model/App/Area.php index 3374b3a32f2..e0f7fc5f89c 100644 --- a/app/code/Magento/Core/Model/App/Area.php +++ b/app/code/Magento/Core/Model/App/Area.php @@ -117,6 +117,11 @@ class Area */ protected $_storeManager; + /** + * @var Area\DesignExceptions + */ + protected $_designExceptions; + /** * @param \Magento\Logger $logger * @param \Magento\Event\ManagerInterface $eventManager @@ -127,6 +132,7 @@ class Area * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\Design $design * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param Area\DesignExceptions $designExceptions * @param string $areaCode */ public function __construct( @@ -139,6 +145,7 @@ class Area \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\Design $design, \Magento\Core\Model\StoreManagerInterface $storeManager, + Area\DesignExceptions $designExceptions, $areaCode ) { $this->_coreStoreConfig = $coreStoreConfig; @@ -151,6 +158,7 @@ class Area $this->_logger = $logger; $this->_design = $design; $this->_storeManager = $storeManager; + $this->_designExceptions = $designExceptions; } /** @@ -197,21 +205,11 @@ class Area */ protected function _applyUserAgentDesignException($request) { - $userAgent = $request->getServer('HTTP_USER_AGENT'); - if (empty($userAgent)) { - return false; - } try { - $expressions = $this->_coreStoreConfig->getConfig('design/theme/ua_regexp'); - if (!$expressions) { - return false; - } - $expressions = unserialize($expressions); - foreach ($expressions as $rule) { - if (preg_match($rule['regexp'], $userAgent)) { - $this->_getDesign()->setDesignTheme($rule['value']); - return true; - } + $theme = $this->_designExceptions->getThemeForUserAgent($request); + if (false !== $theme) { + $this->_getDesign()->setDesignTheme($theme); + return true; } } catch (\Exception $e) { $this->_logger->logException($e); diff --git a/app/code/Magento/Core/Model/App/Area/DesignExceptions.php b/app/code/Magento/Core/Model/App/Area/DesignExceptions.php new file mode 100644 index 00000000000..72589be3190 --- /dev/null +++ b/app/code/Magento/Core/Model/App/Area/DesignExceptions.php @@ -0,0 +1,79 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Core + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Core\Model\App\Area; + +/** + * Class DesignExceptions + * @package Magento\Core\Model\App\Area + */ +class DesignExceptions +{ + /** + * Design exception key + */ + const XML_PATH_DESIGN_EXCEPTION = 'design/package/ua_regexp'; + + /** + * Core store config + * + * @var \Magento\Core\Model\Store\Config + */ + protected $coreStoreConfig; + + /** + * @param \Magento\Core\Model\Store\Config $coreStoreConfig + */ + public function __construct(\Magento\Core\Model\Store\Config $coreStoreConfig) + { + $this->coreStoreConfig = $coreStoreConfig; + } + + /** + * Get theme that should be applied for current user-agent according to design exceptions configuration + * + * @param \Magento\App\Request\Http $request + * @return string|bool + */ + public function getThemeForUserAgent(\Magento\App\Request\Http $request) + { + $userAgent = $request->getServer('HTTP_USER_AGENT'); + if (empty($userAgent)) { + return false; + } + $expressions = $this->coreStoreConfig->getConfig(self::XML_PATH_DESIGN_EXCEPTION); + if (!$expressions) { + return false; + } + $expressions = unserialize($expressions); + foreach ($expressions as $rule) { + if (preg_match($rule['regexp'], $userAgent)) { + return $rule['value']; + } + } + return false; + } +} diff --git a/app/code/Magento/Core/Model/App/Emulation.php b/app/code/Magento/Core/Model/App/Emulation.php index e6892c03653..86de9519cb6 100644 --- a/app/code/Magento/Core/Model/App/Emulation.php +++ b/app/code/Magento/Core/Model/App/Emulation.php @@ -35,11 +35,6 @@ namespace Magento\Core\Model\App; class Emulation extends \Magento\Object { - /** - * @var \Magento\Core\Model\App - */ - protected $_app; - /** * @var \Magento\Core\Model\StoreManagerInterface */ @@ -63,9 +58,9 @@ class Emulation extends \Magento\Object protected $_coreStoreConfig; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ResolverInterface */ - protected $_locale; + protected $_localeResolver; /** * @var \Magento\Core\Model\Design @@ -78,7 +73,6 @@ class Emulation extends \Magento\Object protected $_configFactory; /** - * @param \Magento\Core\Model\App $app * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\View\DesignInterface $viewDesign * @param \Magento\Core\Model\Design $design @@ -86,11 +80,10 @@ class Emulation extends \Magento\Object * @param \Magento\Core\Helper\Translate $helperTranslate * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Translate\Inline\ConfigFactory $configFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data */ public function __construct( - \Magento\Core\Model\App $app, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\View\DesignInterface $viewDesign, \Magento\Core\Model\Design $design, @@ -98,12 +91,11 @@ class Emulation extends \Magento\Object \Magento\Core\Helper\Translate $helperTranslate, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Translate\Inline\ConfigFactory $configFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ResolverInterface $localeResolver, array $data = array() ) { - $this->_locale = $locale; + $this->_localeResolver = $localeResolver; parent::__construct($data); - $this->_app = $app; $this->_storeManager = $storeManager; $this->_viewDesign = $viewDesign; $this->_design = $design; @@ -124,7 +116,7 @@ class Emulation extends \Magento\Object * @return \Magento\Object information about environment of the initial store */ public function startEnvironmentEmulation($storeId, $area = \Magento\Core\Model\App\Area::AREA_FRONTEND, - $emulateStoreInlineTranslation = false + $emulateStoreInlineTranslation = false ) { if ($area === null) { $area = \Magento\Core\Model\App\Area::AREA_FRONTEND; @@ -222,13 +214,13 @@ class Emulation extends \Magento\Object */ protected function _emulateLocale($storeId, $area = \Magento\Core\Model\App\Area::AREA_FRONTEND) { - $initialLocaleCode = $this->_locale->getLocaleCode(); + $initialLocaleCode = $this->_localeResolver->getLocaleCode(); $newLocaleCode = $this->_coreStoreConfig->getConfig( - \Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_LOCALE, + $this->_localeResolver->getDefaultLocalePath(), $storeId ); - $this->_locale->setLocaleCode($newLocaleCode); - $this->_helperTranslate->initTranslate($newLocaleCode, true, $area); + $this->_localeResolver->setLocaleCode($newLocaleCode); + $this->_translate->initLocale($newLocaleCode, $area); return $initialLocaleCode; } @@ -265,8 +257,8 @@ class Emulation extends \Magento\Object */ protected function _restoreInitialLocale($initialLocaleCode, $initialArea = \Magento\Core\Model\App\Area::AREA_ADMIN) { - $this->_app->getLocale()->setLocaleCode($initialLocaleCode); - $this->_helperTranslate->initTranslate($initialLocaleCode, true); + $this->_localeResolver->setLocaleCode($initialLocaleCode); + $this->_translate->initLocale($initialLocaleCode); return $this; } } diff --git a/app/code/Magento/Core/Model/Asset/Plugin/CleanMergedJsCss.php b/app/code/Magento/Core/Model/Asset/Plugin/CleanMergedJsCss.php index 99f9cf528f5..c945778bcaa 100644 --- a/app/code/Magento/Core/Model/Asset/Plugin/CleanMergedJsCss.php +++ b/app/code/Magento/Core/Model/Asset/Plugin/CleanMergedJsCss.php @@ -51,13 +51,17 @@ class CleanMergedJsCss /** * Clean files in database on cleaning merged assets * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\View\Asset\MergeService $subject + * @param callable $proceed + * * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundCleanMergedJsCss(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - $invocationChain->proceed($arguments); + public function aroundCleanMergedJsCss( + \Magento\View\Asset\MergeService $subject, + \Closure $proceed + ) { + $proceed(); /** @var \Magento\Filesystem\Directory\ReadInterface $pubCacheDirectory */ $pubCacheDirectory = $this->filesystem->getDirectoryRead(\Magento\App\Filesystem::PUB_VIEW_CACHE_DIR); diff --git a/app/code/Magento/Core/Model/Design.php b/app/code/Magento/Core/Model/Design.php index 31481e24c3b..9582b5d9bd0 100644 --- a/app/code/Magento/Core/Model/Design.php +++ b/app/code/Magento/Core/Model/Design.php @@ -41,7 +41,7 @@ use Magento\Core\Model\Resource\AbstractResource; * @method string getDateTo() * @method \Magento\Core\Model\Design setDateTo(string $value) */ -class Design extends AbstractModel +class Design extends AbstractModel implements \Magento\Object\IdentityInterface { /** * Cache tag @@ -65,9 +65,9 @@ class Design extends AbstractModel protected $_cacheTag = self::CACHE_TAG; /** - * @var LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @var \Magento\Stdlib\DateTime @@ -77,7 +77,7 @@ class Design extends AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -86,13 +86,13 @@ class Design extends AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_dateTime = $dateTime; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -117,7 +117,7 @@ class Design extends AbstractModel public function loadChange($storeId, $date = null) { if (is_null($date)) { - $date = $this->_dateTime->formatDate($this->_locale->storeTimeStamp($storeId), false); + $date = $this->_dateTime->formatDate($this->_localeDate->scopeTimeStamp($storeId), false); } $changeCacheId = 'design_change_' . md5($storeId . $date); @@ -153,4 +153,14 @@ class Design extends AbstractModel } return $this; } + + /** + * Get identities + * + * @return array + */ + public function getIdentities() + { + return array(self::CACHE_TAG . '_' . $this->getId()); + } } diff --git a/app/code/Magento/Core/Model/File/Storage/Database.php b/app/code/Magento/Core/Model/File/Storage/Database.php index ea79cca5761..123a622b643 100644 --- a/app/code/Magento/Core/Model/File/Storage/Database.php +++ b/app/code/Magento/Core/Model/File/Storage/Database.php @@ -66,7 +66,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb - * @param \Magento\Core\Model\Date $dateModel + * @param \Magento\Stdlib\DateTime\DateTime $dateModel * @param \Magento\Core\Model\App $app * @param \Magento\Core\Helper\File\Media $mediaHelper * @param \Magento\Core\Model\Resource\File\Storage\Database $resource @@ -79,7 +79,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb, - \Magento\Core\Model\Date $dateModel, + \Magento\Stdlib\DateTime\DateTime $dateModel, \Magento\Core\Model\App $app, \Magento\Core\Helper\File\Media $mediaHelper, \Magento\Core\Model\Resource\File\Storage\Database $resource, diff --git a/app/code/Magento/Core/Model/File/Storage/Database/AbstractDatabase.php b/app/code/Magento/Core/Model/File/Storage/Database/AbstractDatabase.php index 05a7be9709c..ce6b94730fa 100644 --- a/app/code/Magento/Core/Model/File/Storage/Database/AbstractDatabase.php +++ b/app/code/Magento/Core/Model/File/Storage/Database/AbstractDatabase.php @@ -48,7 +48,7 @@ abstract class AbstractDatabase extends \Magento\Core\Model\AbstractModel /** * Date model * - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -61,7 +61,7 @@ abstract class AbstractDatabase extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb - * @param \Magento\Core\Model\Date $dateModel + * @param \Magento\Stdlib\DateTime\DateTime $dateModel * @param \Magento\Core\Model\App $app * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -72,7 +72,7 @@ abstract class AbstractDatabase extends \Magento\Core\Model\AbstractModel \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb, - \Magento\Core\Model\Date $dateModel, + \Magento\Stdlib\DateTime\DateTime $dateModel, \Magento\Core\Model\App $app, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Core/Model/File/Storage/Directory/Database.php b/app/code/Magento/Core/Model/File/Storage/Directory/Database.php index 2ba22adeea4..83169ab6203 100644 --- a/app/code/Magento/Core/Model/File/Storage/Directory/Database.php +++ b/app/code/Magento/Core/Model/File/Storage/Directory/Database.php @@ -54,7 +54,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb - * @param \Magento\Core\Model\Date $dateModel + * @param \Magento\Stdlib\DateTime\DateTime $dateModel * @param \Magento\Core\Model\App $app * @param \Magento\Core\Model\File\Storage\Directory\DatabaseFactory $directoryFactory * @param \Magento\Core\Model\Resource\File\Storage\Directory\Database $resource @@ -66,7 +66,7 @@ class Database extends \Magento\Core\Model\File\Storage\Database\AbstractDatabas \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb, - \Magento\Core\Model\Date $dateModel, + \Magento\Stdlib\DateTime\DateTime $dateModel, \Magento\Core\Model\App $app, \Magento\Core\Model\File\Storage\Directory\DatabaseFactory $directoryFactory, \Magento\Core\Model\Resource\File\Storage\Directory\Database $resource, diff --git a/app/code/Magento/Core/Model/File/Storage/Response.php b/app/code/Magento/Core/Model/File/Storage/Response.php index 9350014a2d1..b0083664520 100644 --- a/app/code/Magento/Core/Model/File/Storage/Response.php +++ b/app/code/Magento/Core/Model/File/Storage/Response.php @@ -40,10 +40,18 @@ class Response extends Http protected $_filePath; /** + * Constructor + * + * @param \Magento\Stdlib\Cookie $cookie + * @param \Magento\App\Http\Context $context * @param \Magento\File\Transfer\Adapter\Http $transferAdapter */ - public function __construct(\Magento\File\Transfer\Adapter\Http $transferAdapter) - { + public function __construct( + \Magento\Stdlib\Cookie $cookie, + \Magento\App\Http\Context $context, + \Magento\File\Transfer\Adapter\Http $transferAdapter + ) { + parent::__construct($cookie, $context); $this->_transferAdapter = $transferAdapter; } diff --git a/app/code/Magento/Core/Model/Layout.php b/app/code/Magento/Core/Model/Layout.php index c90435005f5..935fa243eeb 100644 --- a/app/code/Magento/Core/Model/Layout.php +++ b/app/code/Magento/Core/Model/Layout.php @@ -855,6 +855,11 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn $block->setTemplate($templateFileName); } + if (!empty($node['ttl'])) { + $ttl = (int)$node['ttl']; + $block->setTtl($ttl); + } + $this->_scheduledStructure->unsetElement($elementName); // execute block methods diff --git a/app/code/Magento/Core/Model/Locale.php b/app/code/Magento/Core/Model/Locale.php deleted file mode 100644 index 88a65c51ae6..00000000000 --- a/app/code/Magento/Core/Model/Locale.php +++ /dev/null @@ -1,939 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Core - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Core\Model; - -/** - * Locale model - */ -class Locale implements LocaleInterface -{ - /** - * Default locale code - * - * @var string - */ - protected $_defaultLocale; - - /** - * Locale object - * - * @var \Zend_Locale - */ - protected $_locale; - - /** - * Locale code - * - * @var string - */ - protected $_localeCode; - - /** - * Emulated locales stack - * - * @var array - */ - protected $_emulatedLocales = array(); - - /** - * @var array - */ - protected static $_currencyCache = array(); - - /** - * Core event manager proxy - * - * @var \Magento\Event\ManagerInterface - */ - protected $_eventManager = null; - - /** - * @var \Magento\Core\Helper\Translate - */ - protected $_translate; - - /** - * Core store config - * - * @var \Magento\Core\Model\Store\Config - */ - protected $_coreStoreConfig; - - /** - * @var \Magento\App\State - */ - protected $_appState; - - /** - * @var StoreManagerInterface - */ - protected $_storeManager; - - /** - * @var \Magento\Core\Model\Locale\Config - */ - protected $_config; - - /** - * @var App - */ - protected $_app; - - /** - * @var \Magento\Stdlib\DateTime - */ - protected $dateTime; - - /** - * @var Date - */ - protected $_dateModel; - - /** - * @var string[] - */ - protected $_allowedFormats = array( - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_FULL, - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_LONG, - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM, - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT - ); - - /** - * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Core\Helper\Translate $translate - * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\App\State $appState - * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Locale\Config $config - * @param \Magento\Core\Model\App $app - * @param \Magento\Stdlib\DateTime $dateTime - * @param \Magento\Core\Model\Date $dateModel - * @param string $locale - */ - public function __construct( - \Magento\Event\ManagerInterface $eventManager, - \Magento\Core\Helper\Translate $translate, - \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\App\State $appState, - \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Locale\Config $config, - \Magento\Core\Model\App $app, - \Magento\Stdlib\DateTime $dateTime, - \Magento\Core\Model\Date $dateModel, - $locale = null - ) { - $this->_eventManager = $eventManager; - $this->_translate = $translate; - $this->_coreStoreConfig = $coreStoreConfig; - $this->_appState = $appState; - $this->_storeManager = $storeManager; - $this->_config = $config; - $this->_app = $app; - $this->dateTime = $dateTime; - $this->_dateModel = $dateModel; - $this->setLocale($locale); - } - - /** - * Set default locale code - * - * @param string $locale - * @return $this - */ - public function setDefaultLocale($locale) - { - $this->_defaultLocale = $locale; - return $this; - } - - /** - * Retrieve default locale code - * - * @return string - */ - public function getDefaultLocale() - { - if (!$this->_defaultLocale) { - $locale = $this->_coreStoreConfig->getConfig(\Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_LOCALE); - if (!$locale) { - $locale = \Magento\Core\Model\LocaleInterface::DEFAULT_LOCALE; - } - $this->_defaultLocale = $locale; - } - return $this->_defaultLocale; - } - - /** - * Set locale - * - * @param string $locale - * @return $this - */ - public function setLocale($locale = null) - { - if (($locale !== null) && is_string($locale)) { - $this->_localeCode = $locale; - } else { - $this->_localeCode = $this->getDefaultLocale(); - } - return $this; - } - - /** - * Retrieve timezone code - * - * @return string - */ - public function getTimezone() - { - return \Magento\Core\Model\LocaleInterface::DEFAULT_TIMEZONE; - } - - /** - * Gets the store config timezone - * - * @return string - */ - public function getConfigTimezone() - { - return $this->_storeManager->getStore()->getConfig('general/locale/timezone'); - } - - /** - * Retrieve currency code - * - * @return string - */ - public function getCurrency() - { - return \Magento\Core\Model\LocaleInterface::DEFAULT_CURRENCY; - } - - /** - * Retrieve locale object - * - * @return \Zend_Locale - */ - public function getLocale() - { - if (!$this->_locale) { - \Zend_Locale_Data::setCache($this->_app->getCache()->getLowLevelFrontend()); - $this->_locale = new \Zend_Locale($this->getLocaleCode()); - } elseif ($this->_locale->__toString() != $this->_localeCode) { - $this->setLocale($this->_localeCode); - } - - return $this->_locale; - } - - /** - * Retrieve locale code - * - * @return string - */ - public function getLocaleCode() - { - if ($this->_localeCode === null) { - $this->setLocale(); - } - return $this->_localeCode; - } - - /** - * Specify current locale code - * - * @param string $code - * @return LocaleInterface - */ - public function setLocaleCode($code) - { - $this->_localeCode = $code; - $this->_locale = null; - return $this; - } - - /** - * Get options array for locale dropdown in current locale - * - * @return array - */ - public function getOptionLocales() - { - return $this->_getOptionLocales(); - } - - /** - * Get translated to original locale options array for locale dropdown - * - * @return array - */ - public function getTranslatedOptionLocales() - { - return $this->_getOptionLocales(true); - } - - /** - * Get options array for locale dropdown - * - * @param bool $translatedName translation flag - * @return array - */ - protected function _getOptionLocales($translatedName = false) - { - $options = array(); - $locales = $this->getLocale()->getLocaleList(); - $languages = $this->getLocale()->getTranslationList('language', $this->getLocale()); - $countries = $this->getCountryTranslationList(); - - $allowed = $this->getAllowLocales(); - foreach (array_keys($locales) as $code) { - if (strstr($code, '_')) { - if (!in_array($code, $allowed)) { - continue; - } - $data = explode('_', $code); - if (!isset($languages[$data[0]]) || !isset($countries[$data[1]])) { - continue; - } - if ($translatedName) { - $label = ucwords($this->getLocale()->getTranslation($data[0], 'language', $code)) - . ' (' . $this->getLocale()->getTranslation($data[1], 'country', $code) . ') / ' - . $languages[$data[0]] . ' (' . $countries[$data[1]] . ')'; - } else { - $label = $languages[$data[0]] . ' (' . $countries[$data[1]] . ')'; - } - $options[] = array( - 'value' => $code, - 'label' => $label - ); - } - } - return $this->_sortOptionArray($options); - } - - /** - * Retrieve timezone option list - * - * @return array - */ - public function getOptionTimezones() - { - $options= array(); - $zones = $this->getTranslationList('windowstotimezone'); - ksort($zones); - foreach ($zones as $code => $name) { - $name = trim($name); - $options[] = array( - 'label' => empty($name) ? $code : $name . ' (' . $code . ')', - 'value' => $code, - ); - } - return $this->_sortOptionArray($options); - } - - /** - * Retrieve days of week option list - * - * @param bool $preserveCodes - * @param bool $ucFirstCode - * @return array - */ - public function getOptionWeekdays($preserveCodes = false, $ucFirstCode = false) - { - $options= array(); - $days = $this->getTranslationList('days'); - $days = $preserveCodes ? $days['format']['wide'] : array_values($days['format']['wide']); - foreach ($days as $code => $name) { - $options[] = array( - 'label' => $name, - 'value' => $ucFirstCode ? ucfirst($code) : $code, - ); - } - return $options; - } - - /** - * Retrieve country option list - * - * @return array - */ - public function getOptionCountries() - { - $options = array(); - $countries = $this->getCountryTranslationList(); - - foreach ($countries as $code=>$name) { - $options[] = array( - 'label' => $name, - 'value' => $code, - ); - } - return $this->_sortOptionArray($options); - } - - /** - * Retrieve currency option list - * - * @return array - */ - public function getOptionCurrencies() - { - $currencies = $this->getTranslationList('currencytoname'); - $options = array(); - $allowed = $this->getAllowCurrencies(); - - foreach ($currencies as $name => $code) { - if (!in_array($code, $allowed)) { - continue; - } - - $options[] = array( - 'label' => $name, - 'value' => $code, - ); - } - return $this->_sortOptionArray($options); - } - - /** - * Retrieve all currency option list - * - * @return array - */ - public function getOptionAllCurrencies() - { - $currencies = $this->getTranslationList('currencytoname'); - $options = array(); - foreach ($currencies as $name=>$code) { - $options[] = array( - 'label' => $name, - 'value' => $code, - ); - } - return $this->_sortOptionArray($options); - } - - /** - * @param array $option - * @return array - */ - protected function _sortOptionArray($option) - { - $data = array(); - foreach ($option as $item) { - $data[$item['value']] = $item['label']; - } - asort($data); - $option = array(); - foreach ($data as $key => $label) { - $option[] = array( - 'value' => $key, - 'label' => $label - ); - } - return $option; - } - - /** - * Retrieve array of allowed locales - * - * @return array - */ - public function getAllowLocales() - { - return $this->_config->getAllowedLocales(); - } - - /** - * Retrieve array of allowed currencies - * - * @return array - */ - public function getAllowCurrencies() - { - if ($this->_appState->isInstalled()) { - $data = $this->_storeManager->getStore() - ->getConfig(\Magento\Core\Model\LocaleInterface::XML_PATH_ALLOW_CURRENCIES_INSTALLED); - return explode(',', $data); - } else { - $data = $this->_config->getAllowedCurrencies(); - } - return $data; - } - - /** - * Retrieve ISO date format - * - * @param string $type - * @return string - */ - public function getDateFormat($type = null) - { - return $this->getTranslation($type, 'date'); - } - - /** - * Retrieve short date format with 4-digit year - * - * @return string - */ - public function getDateFormatWithLongYear() - { - return preg_replace('/(?<!y)yy(?!y)/', 'yyyy', - $this->getTranslation(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT, 'date')); - } - - - /** - * Retrieve ISO time format - * - * @param string $type - * @return string - */ - public function getTimeFormat($type = null) - { - return $this->getTranslation($type, 'time'); - } - - /** - * Retrieve ISO datetime format - * - * @param string $type - * @return string - */ - public function getDateTimeFormat($type) - { - return $this->getDateFormat($type) . ' ' . $this->getTimeFormat($type); - } - - /** - * Create \Zend_Date object for current locale - * - * @param mixed $date - * @param string $part - * @param string|\Zend_Locale $locale - * @param bool $useTimezone - * @return \Zend_Date - */ - public function date($date = null, $part = null, $locale = null, $useTimezone = true) - { - if (is_null($locale)) { - $locale = $this->getLocale(); - } - - if (empty($date)) { - // $date may be false, but \Zend_Date uses strict compare - $date = null; - } - $date = new \Zend_Date($date, $part, $locale); - if ($useTimezone) { - $timezone = $this->_storeManager->getStore() - ->getConfig(\Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_TIMEZONE); - if ($timezone) { - $date->setTimezone($timezone); - } - } - - return $date; - } - - /** - * Create \Zend_Date object with date converted to store timezone and store Locale - * - * @param null|string|bool|int|Store $store Information about store - * @param string|integer|\Zend_Date|array|null $date date in UTC - * @param boolean $includeTime flag for including time to date - * @return \Zend_Date - */ - public function storeDate($store=null, $date=null, $includeTime=false) - { - $timezone = $this->_storeManager->getStore($store) - ->getConfig(\Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_TIMEZONE); - $date = new \Zend_Date($date, null, $this->getLocale()); - $date->setTimezone($timezone); - if (!$includeTime) { - $date->setHour(0) - ->setMinute(0) - ->setSecond(0); - } - return $date; - } - - /** - * Format date using current locale options and time zone. - * - * @param date|\Zend_Date|null $date - * @param string $format See \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_* constants - * @param bool $showTime Whether to include time - * @return string - */ - public function formatDate( - $date = null, $format = \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT, $showTime = false - ) { - if (!in_array($format, $this->_allowedFormats, true)) { - return $date; - } - if (!($date instanceof \Zend_Date) && $date && !strtotime($date)) { - return ''; - } - if (is_null($date)) { - $date = $this->date( - $this->_dateModel->gmtTimestamp(), - null, - null - ); - } elseif (!$date instanceof \Zend_Date) { - $date = $this->date(strtotime($date), null, null); - } - - if ($showTime) { - $format = $this->getDateTimeFormat($format); - } else { - $format = $this->getDateFormat($format); - } - - return $date->toString($format); - } - - /** - * Format time using current locale options - * - * @param date|\Zend_Date|null $time - * @param string $format - * @param bool $showDate - * @return string - */ - public function formatTime( - $time = null, $format = \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT, $showDate = false - ) { - if (!in_array($format, $this->_allowedFormats, true)) { - return $time; - } - - if (is_null($time)) { - $date = $this->date(time()); - } elseif ($time instanceof \Zend_Date) { - $date = $time; - } else { - $date = $this->date(strtotime($time)); - } - - if ($showDate) { - $format = $this->getDateTimeFormat($format); - } else { - $format = $this->getTimeFormat($format); - } - - return $date->toString($format); - } - - /** - * Create \Zend_Date object with date converted from store's timezone - * to UTC time zone. Date can be passed in format of store's locale - * or in format which was passed as parameter. - * - * @param null|string|bool|int|Store $store Information about store - * @param string|integer|\Zend_Date|array|null $date date in store's timezone - * @param boolean $includeTime flag for including time to date - * @param null|string $format - * @return \Zend_Date - */ - public function utcDate($store, $date, $includeTime = false, $format = null) - { - $dateObj = $this->storeDate($store, $date, $includeTime); - $dateObj->set($date, $format); - $dateObj->setTimezone(\Magento\Core\Model\LocaleInterface::DEFAULT_TIMEZONE); - return $dateObj; - } - - /** - * Get store timestamp - * Timestamp will be built with store timezone settings - * - * @param null|string|bool|int|Store $store - * @return int - */ - public function storeTimeStamp($store=null) - { - $timezone = $this->_storeManager->getStore($store) - ->getConfig(\Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_TIMEZONE); - $currentTimezone = @date_default_timezone_get(); - @date_default_timezone_set($timezone); - $date = date('Y-m-d H:i:s'); - @date_default_timezone_set($currentTimezone); - return strtotime($date); - } - - /** - * Create \Zend_Currency object for current locale - * - * @param string $currency - * @return \Zend_Currency - */ - public function currency($currency) - { - \Magento\Profiler::start('locale/currency'); - if (!isset(self::$_currencyCache[$this->getLocaleCode()][$currency])) { - $options = array(); - try { - $currencyObject = new \Zend_Currency($currency, $this->getLocale()); - } catch (\Exception $e) { - $currencyObject = new \Zend_Currency($this->getCurrency(), $this->getLocale()); - $options['name'] = $currency; - $options['currency'] = $currency; - $options['symbol'] = $currency; - } - - $options = new \Magento\Object($options); - $this->_eventManager->dispatch('currency_display_options_forming', array( - 'currency_options' => $options, - 'base_code' => $currency - )); - - $currencyObject->setFormat($options->toArray()); - self::$_currencyCache[$this->getLocaleCode()][$currency] = $currencyObject; - } - \Magento\Profiler::stop('locale/currency'); - return self::$_currencyCache[$this->getLocaleCode()][$currency]; - } - - /** - * Returns the first found number from an string - * Parsing depends on given locale (grouping and decimal) - * - * Examples for input: - * ' 2345.4356,1234' = 23455456.1234 - * '+23,3452.123' = 233452.123 - * ' 12343 ' = 12343 - * '-9456km' = -9456 - * '0' = 0 - * '2 054,10' = 2054.1 - * '2'054.52' = 2054.52 - * '2,46 GB' = 2.46 - * - * @param string|float|int $value - * @return float|null - */ - public function getNumber($value) - { - if (is_null($value)) { - return null; - } - - if (!is_string($value)) { - return floatval($value); - } - - //trim spaces and apostrophes - $value = str_replace(array('\'', ' '), '', $value); - - $separatorComa = strpos($value, ','); - $separatorDot = strpos($value, '.'); - - if ($separatorComa !== false && $separatorDot !== false) { - if ($separatorComa > $separatorDot) { - $value = str_replace('.', '', $value); - $value = str_replace(',', '.', $value); - } else { - $value = str_replace(',', '', $value); - } - } elseif ($separatorComa !== false) { - $value = str_replace(',', '.', $value); - } - - return floatval($value); - } - - /** - * Functions returns array with price formatting info for js function - * formatCurrency in js/varien/js.js - * - * @return array - */ - public function getJsPriceFormat() - { - $format = \Zend_Locale_Data::getContent($this->getLocaleCode(), 'currencynumber'); - $symbols = \Zend_Locale_Data::getList($this->getLocaleCode(), 'symbols'); - - $pos = strpos($format, ';'); - if ($pos !== false) { - $format = substr($format, 0, $pos); - } - $format = preg_replace("/[^0\#\.,]/", "", $format); - $totalPrecision = 0; - $decimalPoint = strpos($format, '.'); - if ($decimalPoint !== false) { - $totalPrecision = (strlen($format) - (strrpos($format, '.')+1)); - } else { - $decimalPoint = strlen($format); - } - $requiredPrecision = $totalPrecision; - $t = substr($format, $decimalPoint); - $pos = strpos($t, '#'); - if ($pos !== false) { - $requiredPrecision = strlen($t) - $pos - $totalPrecision; - } - - if (strrpos($format, ',') !== false) { - $group = ($decimalPoint - strrpos($format, ',') - 1); - } else { - $group = strrpos($format, '.'); - } - $integerRequired = (strpos($format, '.') - strpos($format, '0')); - - $result = array( - 'pattern' => $this->_storeManager->getStore()->getCurrentCurrency()->getOutputFormat(), - 'precision' => $totalPrecision, - 'requiredPrecision' => $requiredPrecision, - 'decimalSymbol' => $symbols['decimal'], - 'groupSymbol' => $symbols['group'], - 'groupLength' => $group, - 'integerRequired' => $integerRequired - ); - - return $result; - } - - /** - * Push current locale to stack and replace with locale from specified store - * Event is not dispatched. - * - * @param int $storeId - * @return void - */ - public function emulate($storeId) - { - if ($storeId) { - $this->_emulatedLocales[] = clone $this->getLocale(); - $this->_locale = new \Zend_Locale( - $this->_coreStoreConfig->getConfig( - \Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_LOCALE, $storeId - )); - $this->_localeCode = $this->_locale->toString(); - - $this->_translate->initTranslate($this->_localeCode, true); - } else { - $this->_emulatedLocales[] = false; - } - } - - /** - * Get last locale, used before last emulation - * - * @return void - */ - public function revert() - { - $locale = array_pop($this->_emulatedLocales); - if ($locale) { - $this->_locale = $locale; - $this->_localeCode = $this->_locale->toString(); - - $this->_translate->initTranslate($this->_localeCode, true); - } - } - - /** - * Returns localized informations as array, supported are several - * types of information. - * For detailed information about the types look into the documentation - * - * @param string $path (Optional) Type of information to return - * @param string $value (Optional) Value for detail list - * @return array Array with the wished information in the given language - */ - public function getTranslationList($path = null, $value = null) - { - return $this->getLocale()->getTranslationList($path, $this->getLocale(), $value); - } - - /** - * Returns a localized information string, supported are several types of informations. - * For detailed information about the types look into the documentation - * - * @param string $value Name to get detailed information about - * @param string $path (Optional) Type of information to return - * @return string|false The wished information in the given language - */ - public function getTranslation($value = null, $path = null) - { - return $this->getLocale()->getTranslation($value, $path, $this->getLocale()); - } - - /** - * Returns the localized country name - * - * @param string $value Name to get detailed information about - * @return string|false - */ - public function getCountryTranslation($value) - { - return $this->getLocale()->getTranslation($value, 'country', $this->getLocale()); - } - - /** - * Returns an array with the name of all countries translated to the given language - * - * @return array - */ - public function getCountryTranslationList() - { - return $this->getLocale()->getTranslationList('territory', $this->getLocale(), 2); - } - - /** - * Checks if current date of the given store (in the store timezone) is within the range - * - * @param int|string|Store $store - * @param string|null $dateFrom - * @param string|null $dateTo - * @return bool - */ - public function isStoreDateInInterval($store, $dateFrom = null, $dateTo = null) - { - if (!$store instanceof \Magento\Core\Model\Store) { - $store = $this->_storeManager->getStore($store); - } - - $storeTimeStamp = $this->storeTimeStamp($store); - $fromTimeStamp = strtotime($dateFrom); - $toTimeStamp = strtotime($dateTo); - if ($dateTo) { - // fix date YYYY-MM-DD 00:00:00 to YYYY-MM-DD 23:59:59 - $toTimeStamp += 86400; - } - - $result = false; - if (!$this->dateTime->isEmptyDate($dateFrom) && $storeTimeStamp < $fromTimeStamp) { - } elseif (!$this->dateTime->isEmptyDate($dateTo) && $storeTimeStamp > $toTimeStamp) { - } else { - $result = true; - } - return $result; - } -} diff --git a/app/code/Magento/Core/Model/LocaleInterface.php b/app/code/Magento/Core/Model/LocaleInterface.php deleted file mode 100644 index d56761f6052..00000000000 --- a/app/code/Magento/Core/Model/LocaleInterface.php +++ /dev/null @@ -1,383 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Core - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Locale model interface - * - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\Core\Model; - -interface LocaleInterface -{ - /** - * Default locale name - */ - const DEFAULT_LOCALE = 'en_US'; - const DEFAULT_TIMEZONE = 'UTC'; - const DEFAULT_CURRENCY = 'USD'; - - /** - * XML path constants - */ - const XML_PATH_DEFAULT_LOCALE = 'general/locale/code'; - const XML_PATH_DEFAULT_TIMEZONE = 'general/locale/timezone'; - const XML_PATH_ALLOW_CURRENCIES_INSTALLED = 'system/currency/installed'; - - /** - * Date and time format codes - */ - const FORMAT_TYPE_FULL = 'full'; - const FORMAT_TYPE_LONG = 'long'; - const FORMAT_TYPE_MEDIUM= 'medium'; - const FORMAT_TYPE_SHORT = 'short'; - - /** - * Set default locale code - * - * @param string $locale - * @return $this - */ - public function setDefaultLocale($locale); - - /** - * Retrieve default locale code - * - * @return string - */ - public function getDefaultLocale(); - - /** - * Set locale - * - * @param string $locale - * @return $this - */ - public function setLocale($locale = null); - - /** - * Retrieve timezone code - * - * @return string - */ - public function getTimezone(); - - /** - * Retrieve currency code - * - * @return string - */ - public function getCurrency(); - - /** - * Retrieve locale object - * - * @return \Zend_Locale - */ - public function getLocale(); - - /** - * Retrieve locale code - * - * @return string - */ - public function getLocaleCode(); - - /** - * Specify current locale code - * - * @param string $code - * @return $this - */ - public function setLocaleCode($code); - - /** - * Get options array for locale dropdown in current locale - * - * @return array - */ - public function getOptionLocales(); - - /** - * Get translated to original locale options array for locale dropdown - * - * @return array - */ - public function getTranslatedOptionLocales(); - - /** - * Retrieve timezone option list - * - * @return array - */ - public function getOptionTimezones(); - - /** - * Retrieve days of week option list - * - * @param bool $preserveCodes - * @param bool $ucFirstCode - * @return array - */ - public function getOptionWeekdays($preserveCodes = false, $ucFirstCode = false); - - /** - * Retrieve country option list - * - * @return array - */ - public function getOptionCountries(); - - /** - * Retrieve currency option list - * - * @return array - */ - public function getOptionCurrencies(); - - /** - * Retrieve all currency option list - * - * @return array - */ - public function getOptionAllCurrencies(); - - /** - * Retrieve array of allowed locales - * - * @return array - */ - public function getAllowLocales(); - - /** - * Retrieve array of allowed currencies - * - * @return array - */ - public function getAllowCurrencies(); - - /** - * Retrieve ISO date format - * - * @param string $type - * @return string - */ - public function getDateFormat($type=null); - - /** - * Retrieve short date format with 4-digit year - * - * @return string - */ - public function getDateFormatWithLongYear(); - - /** - * Retrieve ISO time format - * - * @param string $type - * @return string - */ - public function getTimeFormat($type=null); - - /** - * Retrieve ISO datetime format - * - * @param string $type - * @return string - */ - public function getDateTimeFormat($type); - - /** - * Create \Zend_Date object for current locale - * - * @param string|integer|\Zend_Date|array|null $date - * @param string $part - * @param string|\Zend_Locale $locale - * @param bool $useTimezone - * @return \Zend_Date - */ - public function date($date = null, $part = null, $locale = null, $useTimezone = true); - - /** - * Create \Zend_Date object with date converted to store timezone and store Locale - * - * @param null|string|bool|int|Store $store Information about store - * @param string|integer|\Zend_Date|array|null $date date in UTC - * @param boolean $includeTime flag for including time to date - * @return \Zend_Date - */ - public function storeDate($store=null, $date=null, $includeTime=false); - - /** - * Create \Zend_Date object with date converted from store's timezone - * to UTC time zone. Date can be passed in format of store's locale - * or in format which was passed as parameter. - * - * @param null|string|bool|int|Store $store Information about store - * @param string|integer|\Zend_Date|array|null $date date in store's timezone - * @param boolean $includeTime flag for including time to date - * @param null|string $format - * @return \Zend_Date - */ - public function utcDate($store, $date, $includeTime = false, $format = null); - - /** - * Get store timestamp - * Timestamp will be built with store timezone settings - * - * @param null|string|bool|int|Store $store - * @return int - */ - public function storeTimeStamp($store=null); - - /** - * Create \Zend_Currency object for current locale - * - * @param string $currency - * @return \Zend_Currency - */ - public function currency($currency); - - /** - * Returns the first found number from an string - * Parsing depends on given locale (grouping and decimal) - * - * Examples for input: - * ' 2345.4356,1234' = 23455456.1234 - * '+23,3452.123' = 233452.123 - * ' 12343 ' = 12343 - * '-9456km' = -9456 - * '0' = 0 - * '2 054,10' = 2054.1 - * '2'054.52' = 2054.52 - * '2,46 GB' = 2.46 - * - * @param string|float|int $value - * @return float|null - */ - public function getNumber($value); - - /** - * Functions returns array with price formatting info for js function - * formatCurrency in js/varien/js.js - * - * @return array - */ - public function getJsPriceFormat(); - - /** - * Push current locale to stack and replace with locale from specified store - * Event is not dispatched. - * - * @param int $storeId - * @return void - */ - public function emulate($storeId); - - /** - * Get last locale, used before last emulation - * - * @return void - */ - public function revert(); - - /** - * Returns localized informations as array, supported are several - * types of informations. - * For detailed information about the types look into the documentation - * - * @param string $path (Optional) Type of information to return - * @param string $value (Optional) Value for detail list - * @return array Array with the wished information in the given language - */ - public function getTranslationList($path = null, $value = null); - - /** - * Returns a localized information string, supported are several types of informations. - * For detailed information about the types look into the documentation - * - * @param string $value Name to get detailed information about - * @param string $path (Optional) Type of information to return - * @return string|false The wished information in the given language - */ - public function getTranslation($value = null, $path = null); - - /** - * Returns the localized country name - * - * @param string $value Name to get detailed information about - * @return string|false - */ - public function getCountryTranslation($value); - - /** - * Returns an array with the name of all countries translated to the given language - * - * @return array - */ - public function getCountryTranslationList(); - - /** - * Checks if current date of the given store (in the store timezone) is within the range - * - * @param int|string|Store $store - * @param string|null $dateFrom - * @param string|null $dateTo - * @return bool - */ - public function isStoreDateInInterval($store, $dateFrom = null, $dateTo = null); - - /** - * Format date using current locale options and time zone. - * - * @param \Zend_Date|null $date - * @param string $format - * @param bool $showTime - * @return string - */ - public function formatDate( - $date = null, $format = \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT, $showTime = false - ); - - /** - * Format time using current locale options - * - * @param \Zend_Date|null $time - * @param string $format - * @param bool $showDate - * @return string - */ - public function formatTime( - $time = null, $format = \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT, $showDate = false - ); - - /** - * Gets the store config timezone - * - * @return string - */ - public function getConfigTimezone(); -} diff --git a/app/code/Magento/Core/Model/Mview/View/State.php b/app/code/Magento/Core/Model/Mview/View/State.php index a861563aee9..9b0f35f071b 100644 --- a/app/code/Magento/Core/Model/Mview/View/State.php +++ b/app/code/Magento/Core/Model/Mview/View/State.php @@ -159,7 +159,7 @@ class State extends \Magento\Core\Model\AbstractModel implements \Magento\Mview\ /** * Set state updated time * - * @param string|int|\Zend_Date $updated + * @param string|int|\Magento\Stdlib\DateTime\DateInterface $updated * @return $this */ public function setUpdated($updated) diff --git a/app/code/Magento/Core/Model/Resource/AbstractResource.php b/app/code/Magento/Core/Model/Resource/AbstractResource.php index 46a19258ca0..56e7f32c7e9 100644 --- a/app/code/Magento/Core/Model/Resource/AbstractResource.php +++ b/app/code/Magento/Core/Model/Resource/AbstractResource.php @@ -221,7 +221,7 @@ abstract class AbstractResource { $type = strtolower($type); if ($type == 'decimal' || $type == 'numeric' || $type == 'float') { - $value = \Magento\App\ObjectManager::getInstance()->get('Magento\Core\Model\LocaleInterface') + $value = \Magento\App\ObjectManager::getInstance()->get('Magento\Locale\FormatInterface') ->getNumber($value); } return $value; diff --git a/app/code/Magento/Core/Model/Resource/Translate/String.php b/app/code/Magento/Core/Model/Resource/Translate/String.php index ffb641a792a..15efa84d5bd 100644 --- a/app/code/Magento/Core/Model/Resource/Translate/String.php +++ b/app/code/Magento/Core/Model/Resource/Translate/String.php @@ -36,9 +36,9 @@ namespace Magento\Core\Model\Resource\Translate; class String extends \Magento\Core\Model\Resource\Db\AbstractDb { /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ResolverInterface */ - protected $_locale; + protected $_localeResolver; /** * @var \Magento\Core\Model\StoreManagerInterface @@ -47,16 +47,16 @@ class String extends \Magento\Core\Model\Resource\Db\AbstractDb /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Core\Model\StoreManagerInterface $storeManager */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Core\Model\StoreManagerInterface $storeManager ) { parent::__construct($resource); - $this->_locale = $locale; + $this->_localeResolver = $localeResolver; $this->_storeManager = $storeManager; } @@ -203,7 +203,7 @@ class String extends \Magento\Core\Model\Resource\Db\AbstractDb public function deleteTranslate($string, $locale = null, $storeId = null) { if (is_null($locale)) { - $locale = $this->_locale->getLocaleCode(); + $locale = $this->_localeResolver->getLocaleCode(); } $where = array( @@ -237,7 +237,7 @@ class String extends \Magento\Core\Model\Resource\Db\AbstractDb $table = $this->getMainTable(); if (is_null($locale)) { - $locale = $this->_locale->getLocaleCode(); + $locale = $this->_localeResolver->getLocaleCode(); } if (is_null($storeId)) { diff --git a/app/code/Magento/Core/Model/Store.php b/app/code/Magento/Core/Model/Store.php index f1cc2001222..2893876bc6b 100644 --- a/app/code/Magento/Core/Model/Store.php +++ b/app/code/Magento/Core/Model/Store.php @@ -40,7 +40,7 @@ use Magento\Directory\Model\Currency\Filter; * @method \Magento\Core\Model\Store setIsActive(int $value) */ class Store extends AbstractModel - implements \Magento\BaseScopeInterface, \Magento\Url\ScopeInterface + implements \Magento\BaseScopeInterface, \Magento\Url\ScopeInterface, \Magento\Object\IdentityInterface { /** * Entity name @@ -298,9 +298,9 @@ class Store extends AbstractModel protected $_cookie; /** - * @var \Magento\App\ResponseInterface + * @var \Magento\App\Http\Context */ - protected $response; + protected $_httpContext; /** * @param Context $context @@ -317,7 +317,7 @@ class Store extends AbstractModel * @param StoreManagerInterface $storeManager * @param \Magento\Session\SidResolverInterface $sidResolver * @param \Magento\Stdlib\Cookie $cookie - * @param \Magento\App\ResponseInterface $response + * @param \Magento\App\Http\Context $httpContext * @param \Magento\Data\Collection\Db $resourceCollection * @param bool $isCustomEntryPoint * @param array $data @@ -337,7 +337,7 @@ class Store extends AbstractModel \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Session\SidResolverInterface $sidResolver, \Magento\Stdlib\Cookie $cookie, - \Magento\App\ResponseInterface $response, + \Magento\App\Http\Context $httpContext, \Magento\Data\Collection\Db $resourceCollection = null, $isCustomEntryPoint = false, array $data = array() @@ -354,7 +354,7 @@ class Store extends AbstractModel $this->_storeManager = $storeManager; $this->_sidResolver = $sidResolver; $this->_cookie = $cookie; - $this->response = $response; + $this->_httpContext = $httpContext; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -950,7 +950,7 @@ class Store extends AbstractModel */ public function setCurrentCurrency($currency) { - $this->response->setVary('current_currency', $currency->getCurrencyCode()); + $this->_httpContext->setValue('current_currency', $currency->getCurrencyCode()); $this->setData('current_currency', $currency); return $this; } @@ -1291,4 +1291,14 @@ class Store extends AbstractModel { return $this->_url; } + + /** + * Get identities + * + * @return array + */ + public function getIdentities() + { + return array(self::CACHE_TAG . '_' . $this->getId()); + } } diff --git a/app/code/Magento/Core/Model/Store/ConfigInterface.php b/app/code/Magento/Core/Model/Store/ConfigInterface.php index da07b095c01..e2d47cd4fcc 100644 --- a/app/code/Magento/Core/Model/Store/ConfigInterface.php +++ b/app/code/Magento/Core/Model/Store/ConfigInterface.php @@ -25,23 +25,6 @@ */ namespace Magento\Core\Model\Store; -interface ConfigInterface +interface ConfigInterface extends \Magento\Locale\ScopeConfigInterface { - /** - * Retrieve store config value - * - * @param string $path - * @param mixed $store - * @return mixed - */ - public function getConfig($path, $store = null); - - /** - * Retrieve store config flag - * - * @param string $path - * @param mixed $store - * @return bool - */ - public function getConfigFlag($path, $store = null); } diff --git a/app/code/Magento/Core/Model/Store/Group.php b/app/code/Magento/Core/Model/Store/Group.php index c71648df131..02a6d8d73c2 100644 --- a/app/code/Magento/Core/Model/Store/Group.php +++ b/app/code/Magento/Core/Model/Store/Group.php @@ -40,7 +40,7 @@ namespace Magento\Core\Model\Store; use Magento\Core\Model\Website; -class Group extends \Magento\Core\Model\AbstractModel +class Group extends \Magento\Core\Model\AbstractModel implements \Magento\Object\IdentityInterface { const ENTITY = 'store_group'; const CACHE_TAG = 'store_group'; @@ -396,4 +396,14 @@ class Group extends \Magento\Core\Model\AbstractModel } return $this->_isReadOnly; } + + /** + * Get identities + * + * @return array + */ + public function getIdentities() + { + return array(self::CACHE_TAG . '_' . $this->getId()); + } } diff --git a/app/code/Magento/Core/Model/Store/Storage/Db.php b/app/code/Magento/Core/Model/Store/Storage/Db.php index c163ed0122b..db0d6cecf17 100644 --- a/app/code/Magento/Core/Model/Store/Storage/Db.php +++ b/app/code/Magento/Core/Model/Store/Storage/Db.php @@ -158,9 +158,9 @@ class Db implements StorageInterface protected $_url; /** - * @var \Magento\App\ResponseInterface + * @var \Magento\App\Http\Context */ - protected $response; + protected $_httpContext; /** * @param StoreFactory $storeFactory @@ -170,10 +170,10 @@ class Db implements StorageInterface * @param \Magento\Stdlib\Cookie $cookie * @param State $appState * @param \Magento\Backend\Model\UrlInterface $url - * @param \Magento\App\ResponseInterface $response - * @param bool $isSingleStoreAllowed - * @param string $scopeCode - * @param string $scopeType + * @param \Magento\App\Http\Context $httpContext + * @param $isSingleStoreAllowed + * @param $scopeCode + * @param $scopeType * @param null $currentStore */ public function __construct( @@ -184,7 +184,7 @@ class Db implements StorageInterface \Magento\Stdlib\Cookie $cookie, State $appState, \Magento\Backend\Model\UrlInterface $url, - \Magento\App\ResponseInterface $response, + \Magento\App\Http\Context $httpContext, $isSingleStoreAllowed, $scopeCode, $scopeType, @@ -200,7 +200,7 @@ class Db implements StorageInterface $this->_appState = $appState; $this->_cookie = $cookie; $this->_url = $url; - $this->response = $response; + $this->_httpContext = $httpContext; if ($currentStore) { $this->_currentStore = $currentStore; } @@ -302,7 +302,7 @@ class Db implements StorageInterface $this->_cookie->set(Store::COOKIE_NAME, null); } else { $this->_cookie->set(Store::COOKIE_NAME, $this->_currentStore, true); - $this->response->setVary(Store::ENTITY, $this->_currentStore); + $this->_httpContext->setValue(Store::ENTITY, $this->_currentStore); } } return; diff --git a/app/code/Magento/Core/Model/TemplateEngine/Plugin/DebugHints.php b/app/code/Magento/Core/Model/TemplateEngine/Plugin/DebugHints.php index 60a760ff12a..0ce386669f1 100644 --- a/app/code/Magento/Core/Model/TemplateEngine/Plugin/DebugHints.php +++ b/app/code/Magento/Core/Model/TemplateEngine/Plugin/DebugHints.php @@ -67,11 +67,16 @@ class DebugHints /** * Wrap template engine instance with the debugging hints decorator, depending of the store configuration * + * @param \Magento\View\TemplateEngineFactory $subject * @param \Magento\View\TemplateEngineInterface $invocationResult + * * @return \Magento\View\TemplateEngineInterface + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterCreate(\Magento\View\TemplateEngineInterface $invocationResult) - { + public function afterCreate( + \Magento\View\TemplateEngineFactory $subject, + \Magento\View\TemplateEngineInterface $invocationResult + ) { if ($this->_storeConfig->getConfig(self::XML_PATH_DEBUG_TEMPLATE_HINTS) && $this->_coreData->isDevAllowed()) { $showBlockHints = $this->_storeConfig->getConfig(self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS); return $this->_objectManager->create( diff --git a/app/code/Magento/Core/Model/Url/Rewrite.php b/app/code/Magento/Core/Model/Url/Rewrite.php index 47ec70ca3fc..3fd093e66e9 100644 --- a/app/code/Magento/Core/Model/Url/Rewrite.php +++ b/app/code/Magento/Core/Model/Url/Rewrite.php @@ -85,9 +85,9 @@ class Rewrite extends \Magento\Core\Model\AbstractModel protected $_storeManager; /** - * @var \Magento\App\ResponseInterface + * @var \Magento\App\Http\Context */ - protected $response; + protected $_httpContext; /** * @param \Magento\Model\Context $context @@ -95,7 +95,7 @@ class Rewrite extends \Magento\Core\Model\AbstractModel * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\App $app * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\App\ResponseInterface $response + * @param \Magento\App\Http\Context $httpContext * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -106,7 +106,7 @@ class Rewrite extends \Magento\Core\Model\AbstractModel \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\App $app, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\App\ResponseInterface $response, + \Magento\App\Http\Context $httpContext, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -114,7 +114,7 @@ class Rewrite extends \Magento\Core\Model\AbstractModel $this->_coreStoreConfig = $coreStoreConfig; $this->_app = $app; $this->_storeManager = $storeManager; - $this->response = $response; + $this->_httpContext = $httpContext; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -319,7 +319,7 @@ class Rewrite extends \Magento\Core\Model\AbstractModel $this->setStoreId($currentStore->getId())->loadByIdPath($this->getIdPath()); $this->_app->getCookie()->set(\Magento\Core\Model\Store::COOKIE_NAME, $currentStore->getCode(), true); - $this->response->setVary(\Magento\Core\Model\Store::ENTITY, $currentStore->getCode()); + $this->_httpContext->setValue(\Magento\Core\Model\Store::ENTITY, $currentStore->getCode()); $targetUrl = $request->getBaseUrl(). '/' . $this->getRequestPath(); $this->_sendRedirectHeaders($targetUrl, true); @@ -336,7 +336,7 @@ class Rewrite extends \Magento\Core\Model\AbstractModel if ($external === 'http:/' || $external === 'https:') { $destinationStoreCode = $this->_storeManager->getStore($this->getStoreId())->getCode(); $this->_app->getCookie()->set(\Magento\Core\Model\Store::COOKIE_NAME, $destinationStoreCode, true); - $this->response->setVary(\Magento\Core\Model\Store::ENTITY, $destinationStoreCode); + $this->_httpContext->setValue(\Magento\Core\Model\Store::ENTITY, $destinationStoreCode); $this->_sendRedirectHeaders($this->getTargetPath(), $isPermanentRedirectOption); } else { diff --git a/app/code/Magento/Core/Model/View/Design.php b/app/code/Magento/Core/Model/View/Design.php index a3a715e1a85..789b5ff0ed4 100644 --- a/app/code/Magento/Core/Model/View/Design.php +++ b/app/code/Magento/Core/Model/View/Design.php @@ -81,9 +81,9 @@ class Design implements \Magento\View\DesignInterface private $_storeConfig; /** - * @var \Magento\Core\Model\App + * @var \Magento\Locale\ResolverInterface */ - protected $_app; + protected $_locale; /** * @var \Magento\App\State @@ -96,7 +96,7 @@ class Design implements \Magento\View\DesignInterface * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Store\ConfigInterface $storeConfig * @param \Magento\Core\Model\ThemeFactory $themeFactory - * @param \Magento\Core\Model\App $app + * @param \Magento\Locale\ResolverInterface $locale * @param \Magento\App\State $appState * @param array $themes */ @@ -106,7 +106,7 @@ class Design implements \Magento\View\DesignInterface \Magento\App\ConfigInterface $config, \Magento\Core\Model\Store\ConfigInterface $storeConfig, \Magento\Core\Model\ThemeFactory $themeFactory, - \Magento\Core\Model\App $app, + \Magento\Locale\ResolverInterface $locale, \Magento\App\State $appState, array $themes ) { @@ -117,7 +117,7 @@ class Design implements \Magento\View\DesignInterface $this->_storeConfig = $storeConfig; $this->_appState = $appState; $this->_themes = $themes; - $this->_app = $app; + $this->_locale = $locale; } /** @@ -242,7 +242,7 @@ class Design implements \Magento\View\DesignInterface $params = array( 'area' => $this->getArea(), 'themeModel' => $this->getDesignTheme(), - 'locale' => $this->_app->getLocale()->getLocaleCode() + 'locale' => $this->_locale->getLocaleCode() ); return $params; diff --git a/app/code/Magento/Core/Model/Website.php b/app/code/Magento/Core/Model/Website.php index f204b346673..fde790b433a 100644 --- a/app/code/Magento/Core/Model/Website.php +++ b/app/code/Magento/Core/Model/Website.php @@ -45,9 +45,9 @@ namespace Magento\Core\Model; * @method int getIsDefault() * @method \Magento\Core\Model\Website setIsDefault(int $value) */ -class Website extends \Magento\Core\Model\AbstractModel +class Website extends \Magento\Core\Model\AbstractModel implements \Magento\Object\IdentityInterface { - const ENTITY = 'core_website'; + const ENTITY = 'core_website'; const CACHE_TAG = 'website'; /** @@ -283,7 +283,7 @@ class Website extends \Magento\Core\Model\AbstractModel if ($this->getDefaultGroupId() == $group->getId()) { $this->_defaultGroup = $group; } - $this->_groupsCount ++; + $this->_groupsCount++; } } @@ -391,7 +391,7 @@ class Website extends \Magento\Core\Model\AbstractModel if ($this->getDefaultGroup() && $this->getDefaultGroup()->getDefaultStoreId() == $store->getId()) { $this->_defaultStore = $store; } - $this->_storesCount ++; + $this->_storesCount++; } } @@ -412,7 +412,7 @@ class Website extends \Magento\Core\Model\AbstractModel if ($this->getDefaultGroup() && $this->getDefaultGroup()->getDefaultStoreId() == $store->getId()) { $this->_defaultStore = $store; } - $this->_storesCount ++; + $this->_storesCount++; } } @@ -613,4 +613,14 @@ class Website extends \Magento\Core\Model\AbstractModel } return $this->_isReadOnly; } + + /** + * Get identities + * + * @return array + */ + public function getIdentities() + { + return array(self::CACHE_TAG . '_' . $this->getId()); + } } diff --git a/app/code/Magento/Core/etc/di.xml b/app/code/Magento/Core/etc/di.xml index fdff1688e9f..944ae416bcb 100644 --- a/app/code/Magento/Core/etc/di.xml +++ b/app/code/Magento/Core/etc/di.xml @@ -31,7 +31,6 @@ <preference for="Magento\Authorization\Policy" type="Magento\Authorization\Policy\DefaultPolicy" /> <preference for="Magento\Authorization\RoleLocator" type="Magento\Authorization\RoleLocator\DefaultRoleLocator" /> <preference for="Magento\Session\SessionManagerInterface" type="Magento\Core\Model\Session" /> - <preference for="Magento\Core\Model\LocaleInterface" type="Magento\Core\Model\Locale" /> <preference for="Magento\Core\Model\DataService\ConfigInterface" type="Magento\Core\Model\DataService\Config" /> <preference for="Magento\App\ConfigInterface" type="Magento\App\Config" /> <preference for="Magento\App\ReinitableConfigInterface" type="Magento\App\ReinitableConfig" /> @@ -76,6 +75,14 @@ <preference for="Magento\Css\PreProcessor\AdapterInterface" type="Magento\Css\PreProcessor\Adapter\Oyejorge" /> <preference for="Magento\Translate\ResourceInterface" type="Magento\Core\Model\Resource\Translate" /> <preference for="Magento\BaseScopeResolverInterface" type="Magento\Core\Model\BaseScopeResolver" /> + <preference for="Magento\LocaleInterface" type="Magento\Locale" /> + <preference for="Magento\Locale\CurrencyInterface" type="Magento\Locale\Currency" /> + <preference for="Magento\CurrencyInterface" type="Magento\Currency" /> + <preference for="Magento\Locale\FormatInterface" type="Magento\Locale\Format" /> + <preference for="Magento\Locale\ResolverInterface" type="Magento\Locale\Resolver" /> + <preference for="Magento\Stdlib\DateTime\TimezoneInterface" type="Magento\Stdlib\DateTime\Timezone" /> + <preference for="Magento\Stdlib\DateTime\DateInterface" type="Magento\Stdlib\DateTime\Date" /> + <preference for="Magento\Locale\ScopeConfigInterface" type="Magento\Core\Model\Store\Config" /> <preference for="Magento\Less\PreProcessor\ErrorHandlerInterface" type="Magento\Less\PreProcessor\ErrorHandler" /> <type name="Magento\Translate\Inline"> <arguments> @@ -96,7 +103,7 @@ <arguments> <argument name="areas" xsi:type="array"> <item name="frontend" xsi:type="array"> - <item name="frontName" xsi:type="string"></item> + <item name="frontName" xsi:type="null" /> <item name="router" xsi:type="string">standard</item> </item> </argument> @@ -367,7 +374,7 @@ </type> <type name="Magento\Locale\Hierarchy\Config"> <arguments> - <argument name="reader" xsi:type="object">Magento\Core\Model\Locale\Hierarchy\Config\Reader</argument> + <argument name="reader" xsi:type="object">Magento\Locale\Hierarchy\Config\Reader</argument> </arguments> </type> <type name="Magento\Core\Model\Resource\Helper"> @@ -375,11 +382,6 @@ <argument name="modulePrefix" xsi:type="string">core</argument> </arguments> </type> - <type name="Magento\Core\Helper\Data"> - <arguments> - <argument name="locale" xsi:type="object">Magento\Core\Model\Locale\Proxy</argument> - </arguments> - </type> <type name="Magento\Core\Model\Resource\Setup\Migration"> <arguments> <argument name="confPathToMapFile" xsi:type="string">app/etc/aliases_to_classes_map.json</argument> @@ -461,11 +463,6 @@ <argument name="url" xsi:type="object">Magento\Backend\Model\UrlInterface\Proxy</argument> </arguments> </type> - <type name="Magento\Core\Model\App"> - <arguments> - <argument name="frontController" xsi:type="object">Magento\App\FrontController\Proxy</argument> - </arguments> - </type> <type name="Magento\Core\Model\App\Area"> <arguments> <argument name="translator" xsi:type="object">Magento\Translate</argument> @@ -480,14 +477,8 @@ <type name="Magento\App\Action\Action"> <plugin name="installInitializer" type="Magento\Core\App\Action\Plugin\Install" sortOrder="5"/> <plugin name="storeCheck" type="Magento\Core\App\Action\Plugin\StoreCheck" sortOrder="10"/> - <plugin name="sessionInitializer" type="Magento\Core\App\Action\Plugin\Session" sortOrder="20"/> <plugin name="designLoader" type="Magento\Core\App\Action\Plugin\Design" sortOrder="30"/> </type> - <type name="Magento\Core\Model\Locale"> - <arguments> - <argument name="dateModel" xsi:type="object">Magento\Core\Model\Date\Proxy</argument> - </arguments> - </type> <virtualType name="Magento\Core\Model\Session\Storage" type="Magento\Session\Storage"> <arguments> <argument name="namespace" xsi:type="string">core</argument> @@ -522,6 +513,11 @@ <argument name="fileSource" xsi:type="object">Magento\Less\File\Source\Aggregated</argument> </arguments> </type> + <type name="Magento\Less\PreProcessor\Instruction\Import"> + <arguments> + <argument name="preProcessor" xsi:type="object">Magento\Less\PreProcessor\Proxy</argument> + </arguments> + </type> <type name="Magento\Less\File\Source\Aggregated"> <arguments> <argument name="libraryFiles" xsi:type="object">Magento\Less\File\Source\Library</argument> @@ -554,4 +550,15 @@ </argument> </arguments> </type> + <type name="Magento\Stdlib\DateTime\Timezone"> + <arguments> + <argument name="defaultTimezonePath" xsi:type="string">general/locale/timezone</argument> + </arguments> + </type> + <type name="Magento\Locale\Resolver"> + <plugin name="initLocale" type="Magento\Translate\Locale\Resolver\Plugin" sortOrder="10"/> + <arguments> + <argument name="defaultLocalePath" xsi:type="string">general/locale/code</argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Core/etc/layouts.xsd b/app/code/Magento/Core/etc/layouts.xsd index e982e10f9b3..4f9c1b6ffe7 100644 --- a/app/code/Magento/Core/etc/layouts.xsd +++ b/app/code/Magento/Core/etc/layouts.xsd @@ -257,7 +257,8 @@ <xs:attribute type="xs:string" name="acl" use="optional"/> <xs:attribute type="xs:string" name="ifconfig" use="optional"/> <xs:attribute type="xs:string" name="group" use="optional" /> - <xs:attribute name="cacheable" type="xs:boolean" default="true" use="optional"/> + <xs:attribute type="xs:boolean" name="cacheable" default="true" use="optional"/> + <xs:attribute type="xs:int" name="ttl" use="optional"/> </xs:complexType> <xs:complexType name="actionType"> diff --git a/app/code/Magento/Core/i18n/de_DE.csv b/app/code/Magento/Core/i18n/de_DE.csv index a11e3f1b42a..fc018a13627 100644 --- a/app/code/Magento/Core/i18n/de_DE.csv +++ b/app/code/Magento/Core/i18n/de_DE.csv @@ -216,7 +216,7 @@ "Please enter a valid date equal to or greater than %s","Bitte geben Sie ein gültiges Datum gleich oder größer als %s an." "Please enter a valid date less than or equal to %s","Bitte geben Sie ein gültiges Datum kleiner oder gleich %s an." "Please enter a valid date.","Bitte geben Sie ein gültiges Datum ein." -"Please enter a valid day (1-%d).","Bitte geben Sie einen gültigen Tag ein (1-%d)." +"Please enter a valid day (1-%1).","Bitte geben Sie einen gültigen Tag ein (1-%1)." "Please enter a valid email address. For example johndoe@domain.com.","Bitte geben Sie eine gültige E-Mail Adresse ein. Zum Beispiel johndoe@domain.com" "Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.","Bitte geben Sie eine gültige Faxnummer an. Zum Beispiel (123) 456-7890 oder 123-456-7890." "Please enter a valid full date","Bitte geben Sie ein vollständiges, gültiges Datum an." @@ -224,7 +224,7 @@ "Please enter a valid number in this field.","Bitte geben Sie in dieses Feld eine gültige Nummer ein." "Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.","Bitte geben Sie eine gültige Telefonnummer ein. Zum Beispiel (123)456-7890 oder 123-456-7890." "Please enter a valid social security number. For example 123-45-6789.","Bitte geben Sie eine gültige Sozialversicherungsnummer ein. Zum Beispiel 123-45-6789." -"Please enter a valid year (1900-%d).","Bitte geben Sie ein gültiges Jahr an (1900-%d)." +"Please enter a valid year (1900-%1).","Bitte geben Sie ein gültiges Jahr an (1900-%1)." "Please enter a valid zip code.","Bitte geben Sie eine gültige Postleitzahl ein." "Please enter a valid zip code. For example 90602 or 90602-1234.","Bitte geben Sie eine gültige Postleitzahl ein. Zum Beispiel 90602 oder 90602-1234." "Please enter issue number or start date for switch/solo card type.","Bitte geben Sie Ihre Ausgabenummer oder das Erstellungsdatum Ihrer EC-/Debitkarte an." diff --git a/app/code/Magento/Core/i18n/en_US.csv b/app/code/Magento/Core/i18n/en_US.csv index 7178a29477e..7f163736c50 100644 --- a/app/code/Magento/Core/i18n/en_US.csv +++ b/app/code/Magento/Core/i18n/en_US.csv @@ -217,7 +217,7 @@ "Please enter a valid date equal to or greater than %s","Please enter a valid date equal to or greater than %s" "Please enter a valid date less than or equal to %s","Please enter a valid date less than or equal to %s" "Please enter a valid date.","Please enter a valid date." -"Please enter a valid day (1-%d).","Please enter a valid day (1-%d)." +"Please enter a valid day (1-%1).","Please enter a valid day (1-%1)." "Please enter a valid email address. For example johndoe@domain.com.","Please enter a valid email address. For example johndoe@domain.com." "Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.","Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890." "Please enter a valid full date","Please enter a valid full date" @@ -225,7 +225,7 @@ "Please enter a valid number in this field.","Please enter a valid number in this field." "Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.","Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890." "Please enter a valid social security number. For example 123-45-6789.","Please enter a valid social security number. For example 123-45-6789." -"Please enter a valid year (1900-%d).","Please enter a valid year (1900-%d)." +"Please enter a valid year (1900-%1).","Please enter a valid year (1900-%1)." "Please enter a valid zip code.","Please enter a valid zip code." "Please enter a valid zip code. For example 90602 or 90602-1234.","Please enter a valid zip code. For example 90602 or 90602-1234." "Please enter issue number or start date for switch/solo card type.","Please enter issue number or start date for switch/solo card type." diff --git a/app/code/Magento/Core/i18n/es_ES.csv b/app/code/Magento/Core/i18n/es_ES.csv index 7a4da9e30d0..80bc314650a 100644 --- a/app/code/Magento/Core/i18n/es_ES.csv +++ b/app/code/Magento/Core/i18n/es_ES.csv @@ -216,7 +216,7 @@ "Please enter a valid date equal to or greater than %s","Por favor, introduzca una fecha válida igual o superior a %s" "Please enter a valid date less than or equal to %s","Por favor, introduzca una fecha válida menor o igual a %s" "Please enter a valid date.","Ingrese una fecha válida." -"Please enter a valid day (1-%d).","Por favor, introduzca un dÃa válido (1-%d)." +"Please enter a valid day (1-%1).","Por favor, introduzca un dÃa válido (1-%1)." "Please enter a valid email address. For example johndoe@domain.com.","Ingrese una dirección de correo electrónico válida. Por ejemplo: juanperez@dominio.com." "Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.","Por favor, introduzca un número de fax válido. Por ejemplo (123) 456-7890 o 123-456-7890." "Please enter a valid full date","Por favor, introduzca una fecha válida completa" @@ -224,7 +224,7 @@ "Please enter a valid number in this field.","Ingrese un número válido en este campo." "Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.","Ingrese un número de teléfono válido. Por ejemplo: (123) 456-7890 o 123-456-7890." "Please enter a valid social security number. For example 123-45-6789.","Ingrese un número de seguro social válido. Por ejemplo: 123-45-6789." -"Please enter a valid year (1900-%d).","Por favor, introduzca un año válido (1900-%d)." +"Please enter a valid year (1900-%1).","Por favor, introduzca un año válido (1900-%1)." "Please enter a valid zip code.","Ingrese un código postal válido." "Please enter a valid zip code. For example 90602 or 90602-1234.","Ingrese un código postal válido. Por ejemplo: 90602 o 90602-1234." "Please enter issue number or start date for switch/solo card type.","Por favor, introduzca un número de emisión o fecha de inicio para el tipo de tarjeta switch/solo." diff --git a/app/code/Magento/Core/i18n/fr_FR.csv b/app/code/Magento/Core/i18n/fr_FR.csv index a3f06ffb322..7241ea4de0b 100644 --- a/app/code/Magento/Core/i18n/fr_FR.csv +++ b/app/code/Magento/Core/i18n/fr_FR.csv @@ -216,7 +216,7 @@ "Please enter a valid date equal to or greater than %s","Veuillez entrer une date valide également ou supérieure à %s" "Please enter a valid date less than or equal to %s","Veuillez entrer une date valide inférieure ou égale à %s" "Please enter a valid date.","Veuillez entrer une date valide." -"Please enter a valid day (1-%d).","Veuillez entrer un jour valide (1-%d)." +"Please enter a valid day (1-%1).","Veuillez entrer un jour valide (1-%1)." "Please enter a valid email address. For example johndoe@domain.com.","Veuillez entrer une adresse courriel valide. Par exemple pierremaistre@domaine.com." "Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.","Veuillez entrer un numéro de fax valide. Par exemple (123) 456-7890 ou 123-456-7890." "Please enter a valid full date","Veuillez entrer une date complète valide" @@ -224,7 +224,7 @@ "Please enter a valid number in this field.","Veuillez entrer un numéro valide dans ce champ." "Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.","Veuillez entrer un numéro de téléphone valide. Par exemple (123) 456-7890 ou 123-456-7890." "Please enter a valid social security number. For example 123-45-6789.","Veuillez entrer un numéro de sécurité sociale valide. Par exemple 123-54-6789." -"Please enter a valid year (1900-%d).","Veuillez entrer une année valide (1900-%d)." +"Please enter a valid year (1900-%1).","Veuillez entrer une année valide (1900-%1)." "Please enter a valid zip code.","Veuillez entrer un code postal valide." "Please enter a valid zip code. For example 90602 or 90602-1234.","Veuillez entrer un code postal valide. Par exemple 90602 ou 90602-1234." "Please enter issue number or start date for switch/solo card type.","Veuillez entrer le numéro de problème ou la date de début pour le type de carte Switch/Solo." diff --git a/app/code/Magento/Core/i18n/nl_NL.csv b/app/code/Magento/Core/i18n/nl_NL.csv index 22cb4d194c9..01063598220 100644 --- a/app/code/Magento/Core/i18n/nl_NL.csv +++ b/app/code/Magento/Core/i18n/nl_NL.csv @@ -216,7 +216,7 @@ "Please enter a valid date equal to or greater than %s","Voer een geldige datum in groter dan of gelijk aan %s" "Please enter a valid date less than or equal to %s","Voer a.u.b. een geldige datum in die minder of gelijk aan %s is." "Please enter a valid date.","Voer a.u.b. een geldige datum in." -"Please enter a valid day (1-%d).","Voer a.u.b. een geldige dag in (1-%d)." +"Please enter a valid day (1-%1).","Voer a.u.b. een geldige dag in (1-%1)." "Please enter a valid email address. For example johndoe@domain.com.","Voer a.u.b. een geldig e-mailadres in. Bijvoorbeeld johndoe@domain.com." "Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.","Voer een geldig faxnummer in. Bijvoorbeeld (123) 456-7890 of 123-456-7890." "Please enter a valid full date","Voer a.u.b. een geldige, volledige datum in" @@ -224,7 +224,7 @@ "Please enter a valid number in this field.","Voer in dit veld een geldig nummer in." "Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.","Voer een geldig telefoonnummer in. Bijvoorbeeld (123) 456-7890 of 123-456-7890." "Please enter a valid social security number. For example 123-45-6789.","Voer a.u.b. een geldig BSN-nummer in. Bijvoorbeeld 123456789." -"Please enter a valid year (1900-%d).","Voer een geldig jaar in (1900-%d)." +"Please enter a valid year (1900-%1).","Voer een geldig jaar in (1900-%1)." "Please enter a valid zip code.","Voer een geldige postcode in." "Please enter a valid zip code. For example 90602 or 90602-1234.","Voer a.u.b. een geldige postcode in. Bijvoorbeeld 1234 AB." "Please enter issue number or start date for switch/solo card type.","Voer uitgavenummer in of start datum voor switch/solo kaarttype." diff --git a/app/code/Magento/Core/i18n/pt_BR.csv b/app/code/Magento/Core/i18n/pt_BR.csv index 0d3821d22f2..1f9bfa9d64f 100644 --- a/app/code/Magento/Core/i18n/pt_BR.csv +++ b/app/code/Magento/Core/i18n/pt_BR.csv @@ -218,7 +218,7 @@ local até que o processo de sincronização esteja completo." "Please enter a valid date equal to or greater than %s","Por favor insira uma data válida igual ou superior a %s" "Please enter a valid date less than or equal to %s","Por favor insira uma data válida menor ou igual a %s" "Please enter a valid date.","Por favor insira uma data válida." -"Please enter a valid day (1-%d).","Por favor insira um dia válido (1-%d)." +"Please enter a valid day (1-%1).","Por favor insira um dia válido (1-%1)." "Please enter a valid email address. For example johndoe@domain.com.","Por favor insira um endereço de e-mail válido. Por exemplo joao@domain.com." "Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.","Por favor insira um número de fax válido. Por exemplo (123) 456-7890 ou 123-456-7890." "Please enter a valid full date","Por favor insira uma data válida completa" @@ -226,7 +226,7 @@ local até que o processo de sincronização esteja completo." "Please enter a valid number in this field.","Por favor insira um número válido neste campo." "Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.","Por favor insira um número de telefone válido. Por exemplo (123) 456-7890 ou 123-456-7890." "Please enter a valid social security number. For example 123-45-6789.","Por favor insira um número válido de segurança social. Por exemplo 123-45-6789." -"Please enter a valid year (1900-%d).","Por favor insira um ano válido (1900-%d)." +"Please enter a valid year (1900-%1).","Por favor insira um ano válido (1900-%1)." "Please enter a valid zip code.","Por favor insira um código postal válido." "Please enter a valid zip code. For example 90602 or 90602-1234.","Por favor insira um código postal válido. Por exemplo 90602 ou 90602-1234." "Please enter issue number or start date for switch/solo card type.","Por favor insira o número de emissão ou data de inÃcio para tipo de cartão switch/solo." diff --git a/app/code/Magento/Core/i18n/zh_CN.csv b/app/code/Magento/Core/i18n/zh_CN.csv index b6a4ba9e18b..042555f0eed 100644 --- a/app/code/Magento/Core/i18n/zh_CN.csv +++ b/app/code/Magento/Core/i18n/zh_CN.csv @@ -216,7 +216,7 @@ "Please enter a valid date equal to or greater than %s","请输入ç‰äºŽæˆ–大于 %s 的有效日期" "Please enter a valid date less than or equal to %s","请输入å°äºŽæˆ–ç‰äºŽ %s 的有效日期" "Please enter a valid date.","请输入有效日期" -"Please enter a valid day (1-%d).","请输入有效天数(1-%d)。" +"Please enter a valid day (1-%1).","请输入有效天数(1-%1)。" "Please enter a valid email address. For example johndoe@domain.com.","请输入有效邮件地å€ã€‚例如johndoe@domain.com。" "Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.","è¯·è¾“å…¥æœ‰æ•ˆä¼ çœŸå·ç ,例如 (123) 456-7890 或 123-456-7890。" "Please enter a valid full date","请输入有效完整日期" @@ -224,7 +224,7 @@ "Please enter a valid number in this field.","请在æ¤åŒºåŸŸè¾“入有效的数å—。" "Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.","请输入有效的电è¯å·ç 。例如 (123) 456-7890 或 123-456-7890。" "Please enter a valid social security number. For example 123-45-6789.","请输入有效社会安全å·ç ,例如123-45-6789。" -"Please enter a valid year (1900-%d).","请输入有效年份(1900-%d)。" +"Please enter a valid year (1900-%1).","请输入有效年份(1900-%1)。" "Please enter a valid zip code.","请输入有效的邮政编ç 。" "Please enter a valid zip code. For example 90602 or 90602-1234.","请输入有效邮编,例如90602或90602-1234。" "Please enter issue number or start date for switch/solo card type.","请输入Switch/Soloç±»å¡çš„é¢å‘å·æˆ–开始日期。" diff --git a/app/code/Magento/Core/view/frontend/js/require-cookie.js b/app/code/Magento/Core/view/frontend/js/require-cookie.js new file mode 100644 index 00000000000..bc1fa19f288 --- /dev/null +++ b/app/code/Magento/Core/view/frontend/js/require-cookie.js @@ -0,0 +1,68 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category mage + * @package mage + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +/*jshint evil:true browser:true jquery:true */ +(function ($) { + $.widget('mage.requireCookie', { + options: { + event: 'click', + noCookieUrl: 'enable-cookies', + triggers: ['.action.login', '.action.submit'] + }, + + /** + * Constructor + * @private + */ + _create: function() { + this._bind(); + }, + + /** + * This method binds elements found in this widget. + * @private + */ + _bind: function() { + var events = {}; + $.each(this.options.triggers, function(index, value) { + events['click ' + value] = '_checkCookie'; + }); + this._on(events); + }, + + /** + * This method set the url for the redirect. + * @private + */ + _checkCookie: function(event) { + $.cookie("test", 1); + if ($.cookie("test")) { + $.cookie("test", null); + } else { + event.preventDefault(); + window.location = this.options.noCookieUrl; + } + } + }); +})(jQuery); diff --git a/app/code/Magento/Core/view/frontend/require_cookie.phtml b/app/code/Magento/Core/view/frontend/require_cookie.phtml new file mode 100644 index 00000000000..13c1fec3d8a --- /dev/null +++ b/app/code/Magento/Core/view/frontend/require_cookie.phtml @@ -0,0 +1,34 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<?php /** @var \Magento\Core\Block\RequireCookie $this */ ?> +<script type="text/javascript"> + //<![CDATA[ + (function ($) { + head.js("<?php echo $this->getViewFileUrl('Magento_Core::js/require-cookie.js')?>", function () { + $('body').requireCookie(<?php echo $this->getScriptOptions(); ?>); + }); + })(jQuery); + //]]> +</script> \ No newline at end of file diff --git a/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php b/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php index 61a74544e7c..abf82020aee 100644 --- a/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php +++ b/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php @@ -54,14 +54,15 @@ class ApplicationInitializer /** * Perform required checks before cron run * - * @param array $methodArguments - * @return array + * @param \Magento\App\Cron $subject + * + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeExecute(array $methodArguments) + public function beforeLaunch(\Magento\App\Cron $subject) { $this->_sidResolver->setUseSessionInUrl(false); $this->_application->requireInstalledInstance(); - return $methodArguments; } } diff --git a/app/code/Magento/Cron/Model/Backend/Config/Structure/Converter.php b/app/code/Magento/Cron/Model/Backend/Config/Structure/Converter.php index 8fc8e91085c..c80f93ef508 100644 --- a/app/code/Magento/Cron/Model/Backend/Config/Structure/Converter.php +++ b/app/code/Magento/Cron/Model/Backend/Config/Structure/Converter.php @@ -44,10 +44,13 @@ class Converter /** * Modify system configuration for cron * + * @param \Magento\Backend\Model\Config\Structure\Converter $subject * @param array $result + * * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterConvert(array $result) + public function afterConvert(\Magento\Backend\Model\Config\Structure\Converter $subject, array $result) { $groupIterator = 0; if (!isset($result['config']['system']['sections']['system']['children']['cron']['children']['template'])) { diff --git a/app/code/Magento/Cron/Model/Schedule.php b/app/code/Magento/Cron/Model/Schedule.php index 951501b05fe..c4be7dfa982 100644 --- a/app/code/Magento/Cron/Model/Schedule.php +++ b/app/code/Magento/Cron/Model/Schedule.php @@ -61,14 +61,14 @@ class Schedule extends \Magento\Core\Model\AbstractModel const STATUS_ERROR = 'error'; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -76,7 +76,7 @@ class Schedule extends \Magento\Core\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Cron/Model/System/Config/Initial/Converter.php b/app/code/Magento/Cron/Model/System/Config/Initial/Converter.php index 1ad44b44474..3286f60d320 100644 --- a/app/code/Magento/Cron/Model/System/Config/Initial/Converter.php +++ b/app/code/Magento/Cron/Model/System/Config/Initial/Converter.php @@ -44,10 +44,13 @@ class Converter /** * Modify global configuration for cron * + * @param \Magento\App\Config\Initial\Converter $subject * @param array $result + * * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterConvert(array $result) + public function afterConvert(\Magento\App\Config\Initial\Converter $subject, array $result) { if (isset($result['data']['default']['system'])) { $result['data']['default']['system']['cron'] = $this->groupsConfig->get(); diff --git a/app/code/Magento/Cron/etc/module.xml b/app/code/Magento/Cron/etc/module.xml index a456382a38f..6cfa7305a07 100755 --- a/app/code/Magento/Cron/etc/module.xml +++ b/app/code/Magento/Cron/etc/module.xml @@ -30,6 +30,7 @@ </sequence> <depends> <module name="Magento_Core"/> + <module name="Magento_Backend"/> </depends> </module> </config> diff --git a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency.php b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency.php index d7189e52cba..0090f9380bb 100644 --- a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency.php +++ b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency.php @@ -138,7 +138,7 @@ class Currency extends \Magento\Backend\App\Action foreach ($data as $currencyCode => $rate) { foreach( $rate as $currencyTo => $value ) { $value = abs($this->_objectManager - ->get('Magento\Core\Model\LocaleInterface') + ->get('Magento\Locale\FormatInterface') ->getNumber($value) ); $data[$currencyCode][$currencyTo] = $value; diff --git a/app/code/Magento/CurrencySymbol/Helper/Data.php b/app/code/Magento/CurrencySymbol/Helper/Data.php index bcf8e377f2d..0b58ff07f91 100644 --- a/app/code/Magento/CurrencySymbol/Helper/Data.php +++ b/app/code/Magento/CurrencySymbol/Helper/Data.php @@ -44,7 +44,6 @@ class Data extends \Magento\Core\Helper\Data * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Locale $locale * @param \Magento\App\State $appState * @param \Magento\CurrencySymbol\Model\System\CurrencysymbolFactory $symbolFactory * @param bool $dbCompatibleMode @@ -53,7 +52,6 @@ class Data extends \Magento\Core\Helper\Data \Magento\App\Helper\Context $context, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Locale $locale, \Magento\App\State $appState, \Magento\CurrencySymbol\Model\System\CurrencysymbolFactory $symbolFactory, $dbCompatibleMode = true @@ -63,7 +61,6 @@ class Data extends \Magento\Core\Helper\Data $context, $coreStoreConfig, $storeManager, - $locale, $appState, $dbCompatibleMode ); @@ -84,7 +81,7 @@ class Data extends \Magento\Core\Helper\Data if ($customCurrencySymbol) { $currencyOptions['symbol'] = $customCurrencySymbol; - $currencyOptions['display'] = \Zend_Currency::USE_SYMBOL; + $currencyOptions['display'] = \Magento\Currency::USE_SYMBOL; } } diff --git a/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php b/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php index 8b3f02ba2ab..6b64cd97269 100644 --- a/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php +++ b/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php @@ -110,7 +110,7 @@ class Currencysymbol protected $_storeManager; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\LocaleInterface */ protected $_locale; @@ -132,7 +132,7 @@ class Currencysymbol * @param \Magento\Backend\Model\Config\Factory $configFactory * @param \Magento\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Core\Model\System\Store $systemStore * @param \Magento\Event\ManagerInterface $eventManager */ @@ -142,7 +142,7 @@ class Currencysymbol \Magento\Backend\Model\Config\Factory $configFactory, \Magento\App\Cache\TypeListInterface $cacheTypeList, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Core\Model\System\Store $systemStore, \Magento\Event\ManagerInterface $eventManager ) { @@ -150,7 +150,7 @@ class Currencysymbol $this->_configFactory = $configFactory; $this->_cacheTypeList = $cacheTypeList; $this->_storeManager = $storeManager; - $this->_locale = $locale; + $this->_locale = $localeResolver->getLocale(); $this->_systemStore = $systemStore; $this->_eventManager = $eventManager; $this->_coreStoreConfig = $coreStoreConfig; diff --git a/app/code/Magento/Customer/Block/Account/Customer.php b/app/code/Magento/Customer/Block/Account/Customer.php old mode 100644 new mode 100755 index 4f8969ce874..cb13f1b6ba8 --- a/app/code/Magento/Customer/Block/Account/Customer.php +++ b/app/code/Magento/Customer/Block/Account/Customer.php @@ -33,18 +33,30 @@ class Customer extends \Magento\View\Element\Template */ protected $_customerSession; + /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */ + protected $_customerService; + + /** @var \Magento\Customer\Helper\View */ + protected $_viewHelper; + /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Customer\Model\Session $session + * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService + * @param \Magento\Customer\Helper\View $viewHelper * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Customer\Model\Session $session, + \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, + \Magento\Customer\Helper\View $viewHelper, array $data = array() ) { parent::__construct($context, $data); $this->_customerSession = $session; + $this->_customerService = $customerService; + $this->_viewHelper = $viewHelper; $this->_isScopePrivate = true; } @@ -53,17 +65,23 @@ class Customer extends \Magento\View\Element\Template * * @return bool */ - public function customerLoggedIn() { return (bool)$this->_customerSession->isLoggedIn(); } /** - * @return string + * Return the full name of the customer currently logged in + * + * @return string|null */ public function getCustomerName() { - return $this->escapeHtml($this->_customerSession->getCustomer()->getName()); + try { + $customer = $this->_customerService->getCustomer($this->_customerSession->getCustomerId()); + return $this->escapeHtml($this->_viewHelper->getCustomerName($customer)); + } catch (\Magento\Exception\NoSuchEntityException $e) { + return null; + } } } diff --git a/app/code/Magento/Customer/Block/Account/Dashboard.php b/app/code/Magento/Customer/Block/Account/Dashboard.php index 2f5ce780529..63951666936 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard.php @@ -18,21 +18,17 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Account; + +use Magento\Customer\Service\V1\CustomerServiceInterface; +use Magento\Customer\Service\V1\CustomerAddressServiceInterface; /** * Customer dashboard block - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Account; - class Dashboard extends \Magento\View\Element\Template { /** @@ -51,96 +47,184 @@ class Dashboard extends \Magento\View\Element\Template protected $_subscriberFactory; /** + * @var CustomerServiceInterface + */ + protected $_customerService; + + /** + * @var CustomerAddressServiceInterface + */ + protected $_addressService; + + /** + * Constructor + * * @param \Magento\View\Element\Template\Context $context * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory + * @param CustomerServiceInterface $customerService + * @param CustomerAddressServiceInterface $addressService * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, + CustomerServiceInterface $customerService, + CustomerAddressServiceInterface $addressService, array $data = array() ) { $this->_customerSession = $customerSession; $this->_subscriberFactory = $subscriberFactory; + $this->_customerService = $customerService; + $this->_addressService = $addressService; parent::__construct($context, $data); $this->_isScopePrivate = true; } + /** + * Return the Customer given the customer Id stored in the session. + * + * @return \Magento\Customer\Service\V1\Dto\Customer + */ public function getCustomer() { - return $this->_customerSession->getCustomer(); + return $this->_customerService->getCustomer($this->_customerSession->getCustomerId()); } + /** + * Retrieve the Url for editing the customer's account. + * + * @return string + */ public function getAccountUrl() { - return $this->_urlBuilder->getUrl('customer/account/edit', array('_secure'=>true)); + return $this->_urlBuilder->getUrl('customer/account/edit', ['_secure' => true]); } + /** + * Retrieve the Url for customer addresses. + * + * @return string + */ public function getAddressesUrl() { - return $this->_urlBuilder->getUrl('customer/address/index', array('_secure'=>true)); + return $this->_urlBuilder->getUrl('customer/address/index', ['_secure' => true]); } + /** + * Retrieve the Url for editing the specified address. + * + * @param \Magento\Customer\Service\V1\Dto\Address $address + * @return string + */ public function getAddressEditUrl($address) { - return $this->_urlBuilder->getUrl('customer/address/edit', array('_secure'=>true, 'id'=>$address->getId())); + return $this->_urlBuilder->getUrl('customer/address/edit', ['_secure' => true, 'id' => $address->getId()]); } + /** + * Retrieve the Url for customer orders. + * + * @return string + */ public function getOrdersUrl() { - return $this->_urlBuilder->getUrl('customer/order/index', array('_secure'=>true)); + return $this->_urlBuilder->getUrl('customer/order/index', ['_secure' => true]); } + /** + * Retrieve the Url for customer reviews. + * + * @return string + */ public function getReviewsUrl() { - return $this->_urlBuilder->getUrl('review/customer/index', array('_secure'=>true)); + return $this->_urlBuilder->getUrl('review/customer/index', ['_secure' => true]); } + /** + * Retrieve the Url for managing customer wishlist. + * + * @return string + */ public function getWishlistUrl() { - return $this->_urlBuilder->getUrl('customer/wishlist/index', array('_secure'=>true)); + return $this->_urlBuilder->getUrl('customer/wishlist/index', ['_secure' => true]); } + /** + * Retrieve the subscription object (i.e. the subscriber). + * + * @return \Magento\Newsletter\Model\Subscriber + */ public function getSubscriptionObject() { - if(is_null($this->_subscription)) { - $this->_subscription = $this->_createSubscriber()->loadByCustomer($this->getCustomer()); + if (is_null($this->_subscription)) { + $this->_subscription = + $this->_createSubscriber()->loadByCustomer($this->_customerSession->getCustomerId()); } return $this->_subscription; } + /** + * Retrieve the Url for managing newsletter subscriptions. + * + * @return string + */ public function getManageNewsletterUrl() { return $this->getUrl('newsletter/manage'); } + /** + * Retrieve subscription text, either subscribed or not. + * + * @return string + */ public function getSubscriptionText() { - if($this->getSubscriptionObject()->isSubscribed()) { + if ($this->getSubscriptionObject()->isSubscribed()) { return __('You subscribe to our newsletter.'); } return __('You are currently not subscribed to our newsletter.'); } + /** + * Retrieve the customer's primary addresses (i.e. default billing and shipping). + * + * @return \Magento\Customer\Service\V1\Dto\Address[]|bool + */ public function getPrimaryAddresses() { - $addresses = $this->getCustomer()->getPrimaryAddresses(); - if (empty($addresses)) { - return false; + $addresses = []; + $customerId = $this->getCustomer()->getCustomerId(); + + if ($defaultBilling = $this->_addressService->getDefaultBillingAddress($customerId)) { + $addresses[] = $defaultBilling; } - return $addresses; + + if ($defaultShipping = $this->_addressService->getDefaultShippingAddress($customerId)) { + if ($defaultBilling) { + if ($defaultBilling->getId() != $defaultShipping->getId()) { + $addresses[] = $defaultShipping; + } + } else { + $addresses[] = $defaultShipping; + } + } + + return (empty($addresses)) ? false : $addresses; } /** - * Get back url in account dashboard + * Get back Url in account dashboard. * - * This method is copypasted in: - * \Magento\Wishlist\Block\Customer\Wishlist - because of strange inheritance - * \Magento\Customer\Block\Address\Book - because of secure url + * This method is copy/pasted in: + * \Magento\Wishlist\Block\Customer\Wishlist - Because of strange inheritance + * \Magento\Customer\Block\Address\Book - Because of secure Url * * @return string */ @@ -154,6 +238,8 @@ class Dashboard extends \Magento\View\Element\Template } /** + * Create an instance of a subscriber. + * * @return \Magento\Newsletter\Model\Subscriber */ protected function _createSubscriber() diff --git a/app/code/Magento/Customer/Block/Account/Dashboard/Address.php b/app/code/Magento/Customer/Block/Account/Dashboard/Address.php index 0aa939cd9f7..1e72313dc5b 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard/Address.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard/Address.php @@ -20,57 +20,47 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Customer\Block\Account\Dashboard; +use Magento\Exception\NoSuchEntityException; + class Address extends \Magento\View\Element\Template { /** - * @var \Magento\Customer\Model\Session + * @var \Magento\Customer\Model\Address\Config */ - protected $_customerSession; + protected $_addressConfig; /** - * @var \Magento\Customer\Service\V1\CustomerServiceInterface + * @var \Magento\Customer\Service\V1\CustomerCurrentServiceInterface */ - protected $_customerService; + protected $customerCurrentService; /** - * @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface + * @var \Magento\Customer\Service\V1\CustomerAddressCurrentServiceInterface */ - protected $_addressService; + protected $customerAddressCurrentService; - /** - * @var \Magento\Customer\Model\Address\Config - */ - protected $_addressConfig; - /** * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService - * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService + * @param \Magento\Customer\Service\V1\CustomerCurrentServiceInterface $customerCurrentService + * @param \Magento\Customer\Service\V1\CustomerAddressCurrentServiceInterface $customerAddressCurrentService * @param \Magento\Customer\Model\Address\Config $addressConfig * @param array $data */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Customer\Model\Session $customerSession, - \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, - \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService, - \Magento\Customer\Model\Address\Config $addressConfig, + \Magento\View\Element\Template\Context $context, + \Magento\Customer\Service\V1\CustomerCurrentServiceInterface $customerCurrentService, + \Magento\Customer\Service\V1\CustomerAddressCurrentServiceInterface $customerAddressCurrentService, + \Magento\Customer\Model\Address\Config $addressConfig, array $data = array() ) { - $this->_customerSession = $customerSession; - $this->_customerService = $customerService; - $this->_addressService = $addressService; - $this->_addressConfig = $addressConfig; + $this->customerCurrentService = $customerCurrentService; + $this->customerAddressCurrentService = $customerAddressCurrentService; + $this->_addressConfig = $addressConfig; parent::__construct($context, $data); $this->_isScopePrivate = true; } @@ -83,8 +73,8 @@ class Address extends \Magento\View\Element\Template public function getCustomer() { try { - return $this->_customerService->getCustomer($this->_customerSession->getId()); - } catch (\Magento\Exception\NoSuchEntityException $e) { + return $this->customerCurrentService->getCustomer(); + } catch (NoSuchEntityException $e) { return null; } } @@ -97,8 +87,8 @@ class Address extends \Magento\View\Element\Template public function getPrimaryShippingAddressHtml() { try { - $address = $this->_addressService->getDefaultShippingAddress($this->_customerSession->getCustomerId()); - } catch (\Magento\Exception\NoSuchEntityException $e) { + $address = $this->customerAddressCurrentService->getDefaultShippingAddress(); + } catch (NoSuchEntityException $e) { return __('You have not set a default shipping address.'); } @@ -117,8 +107,8 @@ class Address extends \Magento\View\Element\Template public function getPrimaryBillingAddressHtml() { try { - $address = $this->_addressService->getDefaultBillingAddress($this->_customerSession->getCustomerId()); - } catch (\Magento\Exception\NoSuchEntityException $e) { + $address = $this->customerAddressCurrentService->getDefaultBillingAddress(); + } catch (NoSuchEntityException $e) { return __('You have not set a default billing address.'); } @@ -134,7 +124,8 @@ class Address extends \Magento\View\Element\Template if (is_null($this->getCustomer())) { return ''; } else { - return $this->_urlBuilder->getUrl('customer/address/edit', array('id'=>$this->getCustomer()->getDefaultShipping())); + return $this->_urlBuilder + ->getUrl('customer/address/edit', ['id'=>$this->getCustomer()->getDefaultShipping()]); } } @@ -143,7 +134,8 @@ class Address extends \Magento\View\Element\Template if (is_null($this->getCustomer())) { return ''; } else { - return $this->_urlBuilder->getUrl('customer/address/edit', array('id'=>$this->getCustomer()->getDefaultBilling())); + return $this->_urlBuilder + ->getUrl('customer/address/edit', ['id'=>$this->getCustomer()->getDefaultBilling()]); } } diff --git a/app/code/Magento/Customer/Block/Account/Dashboard/Block.php b/app/code/Magento/Customer/Block/Account/Dashboard/Block.php index 90b78723cd8..da34adcd435 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard/Block.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard/Block.php @@ -18,18 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - namespace Magento\Customer\Block\Account\Dashboard; class Block extends \Magento\View\Element\Template { /** + * Account dashboard block constructor. + * * @param \Magento\View\Element\Template\Context $context * @param array $data */ diff --git a/app/code/Magento/Customer/Block/Account/Dashboard/Hello.php b/app/code/Magento/Customer/Block/Account/Dashboard/Hello.php index 67fa4726799..9f1a52ca400 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard/Hello.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard/Hello.php @@ -18,13 +18,9 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - namespace Magento\Customer\Block\Account\Dashboard; class Hello extends \Magento\View\Element\Template @@ -35,23 +31,46 @@ class Hello extends \Magento\View\Element\Template protected $_customerSession; /** + * @var \Magento\Customer\Helper\View + */ + protected $_viewHelper; + + /** + * @var \Magento\Customer\Service\V1\CustomerServiceInterface + */ + protected $_customerService; + + /** + * Constructor + * * @param \Magento\View\Element\Template\Context $context * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Customer\Helper\View $viewHelper + * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Customer\Model\Session $customerSession, + \Magento\Customer\Helper\View $viewHelper, + \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, array $data = array() ) { $this->_customerSession = $customerSession; + $this->_viewHelper = $viewHelper; + $this->_customerService = $customerService; parent::__construct($context, $data); $this->_isScopePrivate = true; } + /** + * Concatenate all customer name parts into full customer name. + * + * @return string + */ public function getCustomerName() { - return $this->_customerSession->getCustomer()->getName(); + $customer = $this->_customerService->getCustomer($this->_customerSession->getCustomerId()); + return $this->_viewHelper->getCustomerName($customer); } - } diff --git a/app/code/Magento/Customer/Block/Account/Dashboard/Info.php b/app/code/Magento/Customer/Block/Account/Dashboard/Info.php index 453dc7217b2..ed116525bae 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard/Info.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard/Info.php @@ -39,11 +39,6 @@ class Info extends \Magento\View\Element\Template */ protected $_subscription; - /** - * @var \Magento\Customer\Model\Session - */ - protected $_customerSession; - /** * @var \Magento\Newsletter\Model\SubscriberFactory */ @@ -54,29 +49,21 @@ class Info extends \Magento\View\Element\Template */ protected $_metadataService; - /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */ - protected $_customerService; - /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService - * @param CustomerMetadataServiceInterface $metadataService - * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory - * @param array $data + * @var \Magento\Customer\Service\V1\CustomerCurrentServiceInterface */ + protected $customerCurrentService; + public function __construct( \Magento\View\Element\Template\Context $context, - \Magento\Customer\Model\Session $customerSession, - \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, + \Magento\Customer\Service\V1\CustomerCurrentServiceInterface $customerCurrentService, CustomerMetadataServiceInterface $metadataService, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, array $data = array() ) { - $this->_customerSession = $customerSession; - $this->_customerService = $customerService; - $this->_metadataService = $metadataService; - $this->_subscriberFactory = $subscriberFactory; + $this->customerCurrentService = $customerCurrentService; + $this->_metadataService = $metadataService; + $this->_subscriberFactory = $subscriberFactory; parent::__construct($context, $data); $this->_isScopePrivate = true; } @@ -89,7 +76,7 @@ class Info extends \Magento\View\Element\Template public function getCustomer() { try { - return $this->_customerService->getCustomer($this->_customerSession->getId()); + return $this->customerCurrentService->getCustomer(); } catch (NoSuchEntityException $e) { return null; } @@ -99,6 +86,8 @@ class Info extends \Magento\View\Element\Template * Get the full name of a customer * * @return string full name + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function getName() { @@ -149,6 +138,8 @@ class Info extends \Magento\View\Element\Template * Gets Customer subscription status * * @return bool + * + * @SuppressWarnings(PHPMD.BooleanGetMethodName) */ public function getIsSubscribed() { @@ -156,9 +147,9 @@ class Info extends \Magento\View\Element\Template } /** - * Newsletter module availability + * Newsletter module availability * - * @return boolean + * @return bool */ public function isNewsletterEnabled() { @@ -174,7 +165,7 @@ class Info extends \Magento\View\Element\Template } /** - * @param $attributeCode + * @param string $attributeCode * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata|null */ protected function _getAttributeMetadata($attributeCode) diff --git a/app/code/Magento/Customer/Block/Account/Dashboard/Newsletter.php b/app/code/Magento/Customer/Block/Account/Dashboard/Newsletter.php index 9f811f948a9..8d42eaa2b8e 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard/Newsletter.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard/Newsletter.php @@ -18,40 +18,40 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Account\Dashboard; /** - * Dashboard neswletter info - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> + * Dashboard newsletter info */ - -namespace Magento\Customer\Block\Account\Dashboard; - class Newsletter extends \Magento\View\Element\Template { /** + * The subscriber. + * * @var \Magento\Newsletter\Model\Subscriber */ protected $_subscription; /** + * Session model. + * * @var \Magento\Customer\Model\Session */ protected $_customerSession; /** + * Factory for creating new Subscriber instances. + * * @var \Magento\Newsletter\Model\SubscriberFactory */ protected $_subscriberFactory; /** + * Initialize the Dashboard\Newsletter instance. + * * @param \Magento\View\Element\Template\Context $context * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory @@ -69,15 +69,23 @@ class Newsletter extends \Magento\View\Element\Template $this->_isScopePrivate = true; } + /** + * Fetch the subscription object. Create the subscriber by loading using the customerId. + * + * @return \Magento\Newsletter\Model\Subscriber + */ public function getSubscriptionObject() { - if(is_null($this->_subscription)) { - $this->_subscription = $this->_createSubscriber()->loadByCustomer($this->_customerSession->getCustomer()); + if (is_null($this->_subscription)) { + $this->_subscription = + $this->_createSubscriber()->loadByCustomer($this->_customerSession->getCustomerId()); } return $this->_subscription; } /** + * Use the factory to create an empty Subscriber model instance. + * * @return \Magento\Newsletter\Model\Subscriber */ protected function _createSubscriber() diff --git a/app/code/Magento/Customer/Block/Account/Dashboard/Sidebar.php b/app/code/Magento/Customer/Block/Account/Dashboard/Sidebar.php index 1c7b6db8958..7ac7d6c0bce 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard/Sidebar.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard/Sidebar.php @@ -18,22 +18,14 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Account\Dashboard; /** * Account dashboard sidebar - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Customer\Block\Account\Dashboard; - class Sidebar extends \Magento\View\Element\Template { protected $_cartItemsCount; @@ -107,7 +99,7 @@ class Sidebar extends \Magento\View\Element\Template public function getCartItemsCount() { - if( !$this->_cartItemsCount ) { + if (!$this->_cartItemsCount) { $this->_cartItemsCount = $this->_createQuote() ->setId($this->_checkoutSession->getQuote()->getId()) ->getItemsCollection() @@ -119,7 +111,7 @@ class Sidebar extends \Magento\View\Element\Template public function getWishlist() { - if( !$this->_wishlist ) { + if (!$this->_wishlist) { $this->_wishlist = $this->_createWishList()->loadByCustomer($this->_customerSession->getCustomer()); $this->_wishlist->getItemCollection() ->addAttributeToSelect('name') @@ -147,7 +139,7 @@ class Sidebar extends \Magento\View\Element\Template public function getCompareItems() { - if( !$this->_compareItems ) { + if ( !$this->_compareItems ) { $this->_compareItems = $this->_createProductCompareCollection()->setStoreId($this->_storeManager->getStore()->getId()); $this->_compareItems->setCustomerId( @@ -168,7 +160,7 @@ class Sidebar extends \Magento\View\Element\Template public function getCompareRemoveUrlTemplate() { - return $this->getUrl('catalog/product_compare/remove',array('product'=>'#{id}')); + return $this->getUrl('catalog/product_compare/remove', ['product'=>'#{id}']); } public function getCompareAddUrlTemplate() diff --git a/app/code/Magento/Customer/Block/Account/Forgotpassword.php b/app/code/Magento/Customer/Block/Account/Forgotpassword.php index a541d59fc9f..aef2409f988 100644 --- a/app/code/Magento/Customer/Block/Account/Forgotpassword.php +++ b/app/code/Magento/Customer/Block/Account/Forgotpassword.php @@ -18,31 +18,25 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Account; /** * Customer account navigation sidebar - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Customer\Block\Account; - class Forgotpassword extends \Magento\View\Element\Template { /** + * Forgot Password Constructor. + * * @param \Magento\View\Element\Template\Context $context * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, - array $data = array() + array $data = [] ) { parent::__construct($context, $data); $this->_isScopePrivate = true; diff --git a/app/code/Magento/Customer/Block/Account/Resetpassword.php b/app/code/Magento/Customer/Block/Account/Resetpassword.php index abf0f023048..90e4556603e 100644 --- a/app/code/Magento/Customer/Block/Account/Resetpassword.php +++ b/app/code/Magento/Customer/Block/Account/Resetpassword.php @@ -18,31 +18,27 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Account; + +use Magento\View\Element\Template\Context; /** * Customer reset password form - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Customer\Block\Account; - class Resetpassword extends \Magento\View\Element\Template { /** - * @param \Magento\View\Element\Template\Context $context + * Reset Password Constructor. + * + * @param Context $context * @param array $data */ public function __construct( - \Magento\View\Element\Template\Context $context, - array $data = array() + Context $context, + array $data = [] ) { parent::__construct($context, $data); $this->_isScopePrivate = true; diff --git a/app/code/Magento/Customer/Block/Address/Edit.php b/app/code/Magento/Customer/Block/Address/Edit.php index 6ebadbf7139..f403950b0a2 100644 --- a/app/code/Magento/Customer/Block/Address/Edit.php +++ b/app/code/Magento/Customer/Block/Address/Edit.php @@ -18,29 +18,26 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - -/** - * Customer address edit block - */ namespace Magento\Customer\Block\Address; use Magento\Customer\Service\V1\Dto\Address; use Magento\Customer\Service\V1\Dto\Customer; use Magento\Exception\NoSuchEntityException; +/** + * Customer address edit block + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Edit extends \Magento\Directory\Block\Data { /** * @var Address */ protected $_address = null; - protected $_countryCollection; - protected $_regionCollection; /** * @var \Magento\App\ConfigInterface @@ -52,11 +49,6 @@ class Edit extends \Magento\Directory\Block\Data */ protected $_customerSession; - /** - * @var \Magento\Customer\Service\V1\CustomerServiceInterface - */ - protected $_customerService; - /** * @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface */ @@ -65,9 +57,16 @@ class Edit extends \Magento\Directory\Block\Data /** * @var \Magento\Customer\Service\V1\Dto\AddressBuilder */ - private $_addressBuilder; + protected $_addressBuilder; /** + * @var \Magento\Customer\Service\V1\CustomerCurrentServiceInterface + */ + protected $customerCurrentService; + + /** + * Constructor + * * @param \Magento\View\Element\Template\Context $context * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Json\EncoderInterface $jsonEncoder @@ -76,10 +75,12 @@ class Edit extends \Magento\Directory\Block\Data * @param \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory * @param \Magento\App\ConfigInterface $config * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService * @param \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder + * @param \Magento\Customer\Service\V1\CustomerCurrentServiceInterface $customerCurrentService * @param array $data + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\View\Element\Template\Context $context, @@ -90,22 +91,33 @@ class Edit extends \Magento\Directory\Block\Data \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory, \Magento\App\ConfigInterface $config, \Magento\Customer\Model\Session $customerSession, - \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService, \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder, + \Magento\Customer\Service\V1\CustomerCurrentServiceInterface $customerCurrentService, array $data = array() ) { - $this->_config = $config; - $this->_customerSession = $customerSession; - $this->_customerService = $customerService; - $this->_addressService = $addressService; - $this->_addressBuilder = $addressBuilder; + $this->_config = $config; + $this->_customerSession = $customerSession; + $this->_addressService = $addressService; + $this->_addressBuilder = $addressBuilder; + $this->customerCurrentService = $customerCurrentService; parent::__construct( - $context, $coreData, $jsonEncoder, $configCacheType, $regionCollectionFactory, $countryCollectionFactory, $data + $context, + $coreData, + $jsonEncoder, + $configCacheType, + $regionCollectionFactory, + $countryCollectionFactory, + $data ); $this->_isScopePrivate = true; } + /** + * Prepare the layout of the address edit block. + * + * @return $this + */ protected function _prepareLayout() { parent::_prepareLayout(); @@ -120,12 +132,14 @@ class Edit extends \Magento\Directory\Block\Data } if (is_null($this->_address) || !$this->_address->getId()) { - $this->_address = $this->_addressBuilder->setPrefix($this->getCustomer()->getPrefix()) - ->setFirstname($this->getCustomer()->getFirstname()) - ->setMiddlename($this->getCustomer()->getMiddlename()) - ->setLastname($this->getCustomer()->getLastname()) - ->setSuffix($this->getCustomer()->getSuffix()) - ->create(); + $this->_address = + $this->_addressBuilder + ->setPrefix($this->getCustomer()->getPrefix()) + ->setFirstname($this->getCustomer()->getFirstname()) + ->setMiddlename($this->getCustomer()->getMiddlename()) + ->setLastname($this->getCustomer()->getLastname()) + ->setSuffix($this->getCustomer()->getSuffix()) + ->create(); } if ($headBlock = $this->getLayout()->getBlock('head')) { @@ -143,10 +157,12 @@ class Edit extends \Magento\Directory\Block\Data ->populateWithArray(array_merge($this->_address->__toArray(), $postedData)) ->create(); } + + return $this; } /** - * Generate name block html + * Generate name block html. * * @return string */ @@ -159,6 +175,11 @@ class Edit extends \Magento\Directory\Block\Data return $nameBlock->toHtml(); } + /** + * Return the title, either editing an existing address, or adding a new one. + * + * @return string + */ public function getTitle() { if ($title = $this->getData('title')) { @@ -166,13 +187,17 @@ class Edit extends \Magento\Directory\Block\Data } if ($this->getAddress()->getId()) { $title = __('Edit Address'); - } - else { + } else { $title = __('Add New Address'); } return $title; } + /** + * Return the Url to go back. + * + * @return string + */ public function getBackUrl() { if ($this->getData('back_url')) { @@ -186,15 +211,22 @@ class Edit extends \Magento\Directory\Block\Data } } + /** + * Return the Url for saving. + * + * @return string + */ public function getSaveUrl() { return $this->_urlBuilder->getUrl( 'customer/address/formPost', - array('_secure'=>true, 'id'=>$this->getAddress()->getId()) + ['_secure' => true, 'id' => $this->getAddress()->getId()] ); } /** + * Return the associated address. + * * @return Address */ public function getAddress() @@ -203,6 +235,8 @@ class Edit extends \Magento\Directory\Block\Data } /** + * Return the specified numbered street line. + * * @param int $lineNumber * @return string */ @@ -212,6 +246,11 @@ class Edit extends \Magento\Directory\Block\Data return isset($street[$lineNumber-1]) ? $street[$lineNumber-1] : ''; } + /** + * Return the country Id. + * + * @return int|null|string + */ public function getCountryId() { if ($countryId = $this->getAddress()->getCountryId()) { @@ -221,7 +260,7 @@ class Edit extends \Magento\Directory\Block\Data } /** - * Return the name of the region for the address being edited + * Return the name of the region for the address being edited. * * @return string region name */ @@ -232,7 +271,7 @@ class Edit extends \Magento\Directory\Block\Data } /** - * Return the id of the region being edited + * Return the id of the region being edited. * * @return int region id */ @@ -242,11 +281,21 @@ class Edit extends \Magento\Directory\Block\Data return is_null($region) ? 0 : $region->getRegionId(); } + /** + * Retrieve the number of addresses associated with the customer given a customer Id. + * + * @return int + */ public function getCustomerAddressCount() { - return count($this->_customerSession->getCustomer()->getAddresses()); + return count($this->_addressService->getAddresses($this->_customerSession->getCustomerId())); } + /** + * Determine if the address can be set as the default billing address. + * + * @return bool|int + */ public function canSetAsDefaultBilling() { if (!$this->getAddress()->getId()) { @@ -255,6 +304,11 @@ class Edit extends \Magento\Directory\Block\Data return !$this->isDefaultBilling(); } + /** + * Determine if the address can be set as the default shipping address. + * + * @return bool|int + */ public function canSetAsDefaultShipping() { if (!$this->getAddress()->getId()) { @@ -263,24 +317,41 @@ class Edit extends \Magento\Directory\Block\Data return !$this->isDefaultShipping(); } + /** + * Is the address the default billing address? + * + * @return bool + */ public function isDefaultBilling() { return (bool)$this->getAddress()->isDefaultBilling(); } + /** + * Is the address the default shipping address? + * + * @return bool + */ public function isDefaultShipping() { return (bool)$this->getAddress()->isDefaultShipping(); } /** + * Retrieve the Customer Dto using the customer Id from the customer session. + * * @return Customer */ public function getCustomer() { - return $this->_customerService->getCustomer($this->_customerSession->getId()); + return $this->customerCurrentService->getCustomer(); } + /** + * Return back button Url, either to customer address or account. + * + * @return string + */ public function getBackButtonUrl() { if ($this->getCustomerAddressCount()) { @@ -291,10 +362,10 @@ class Edit extends \Magento\Directory\Block\Data } /** - * Get config + * Get config value. * * @param string $path - * @return mixed + * @return string|null */ public function getConfig($path) { diff --git a/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php b/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php index 255f6176741..58ae508ee69 100644 --- a/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php +++ b/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php @@ -132,6 +132,9 @@ class DefaultRenderer /** * {@inheritdoc} + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ public function render(\Magento\Customer\Model\Address\AbstractAddress $address, $format = null) { @@ -204,6 +207,9 @@ class DefaultRenderer /** * {@inheritdoc} + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ public function renderArray($addressAttributes, $format = null) { @@ -233,7 +239,7 @@ class DefaultRenderer $data['country'] = $this->_countryFactory->create(['id' => $addressAttributes['country_id']])->getName(); } elseif ($attributeCode == 'region' && isset($addressAttributes['region'])) { - $data['region'] = __($addressAttributes['region']['region']); + $data['region'] = __($addressAttributes['region']); } elseif (isset($addressAttributes[$attributeCode])) { $value = $addressAttributes[$attributeCode]; $dataModel = $this->_elementFactory->create($attributeMetadata, $value, 'customer_address'); diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit.php b/app/code/Magento/Customer/Block/Adminhtml/Edit.php index 7522db41be9..41c9d5fd479 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit.php @@ -18,21 +18,17 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\Customer\Service\V1\CustomerServiceInterface; /** * Customer edit block - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml; - class Edit extends \Magento\Backend\Block\Widget\Form\Container { /** @@ -43,16 +39,38 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container protected $_coreRegistry = null; /** + * Customer service + * + * @var CustomerServiceInterface + */ + protected $_customerService; + + /** + * Customer view helper + * + * @var \Magento\Customer\Helper\View + */ + protected $_viewHelper; + + /** + * Constructor + * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Registry $registry + * @param CustomerServiceInterface $customerService + * @param \Magento\Customer\Helper\View $viewHelper * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Registry $registry, + CustomerServiceInterface $customerService, + \Magento\Customer\Helper\View $viewHelper, array $data = array() ) { $this->_coreRegistry = $registry; + $this->_customerService = $customerService; + $this->_viewHelper = $viewHelper; parent::__construct($context, $data); } @@ -62,12 +80,14 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container $this->_controller = 'adminhtml'; $this->_blockGroup = 'Magento_Customer'; - if ($this->getCustomerId() && $this->_authorization->isAllowed('Magento_Sales::create')) { - $this->_addButton('order', array( + $customerId = $this->getCustomerId(); + + if ($customerId && $this->_authorization->isAllowed('Magento_Sales::create')) { + $this->_addButton('order', [ 'label' => __('Create Order'), 'onclick' => 'setLocation(\'' . $this->getCreateOrderUrl() . '\')', 'class' => 'add', - ), 0); + ], 0); } parent::_construct(); @@ -75,87 +95,120 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container $this->_updateButton('save', 'label', __('Save Customer')); $this->_updateButton('delete', 'label', __('Delete Customer')); - $customer = $this->_coreRegistry->registry('current_customer'); - if ($customer && $this->_coreRegistry->registry('current_customer')->isReadonly()) { + if ($customerId && $this->_customerService->isReadonly($customerId)) { $this->_removeButton('save'); $this->_removeButton('reset'); } - if (!$customer || !$this->_coreRegistry->registry('current_customer')->isDeleteable()) { + if (!$customerId || !$this->_customerService->isDeleteable($customerId)) { $this->_removeButton('delete'); } - if ($customer && $customer->getId()) { - $url = $this->getUrl('customer/index/resetPassword', array('customer_id' => $customer->getId())); - $this->_addButton('reset_password', array( + if ($customerId) { + $url = $this->getUrl('customer/index/resetPassword', ['customer_id' => $customerId]); + $this->_addButton('reset_password', [ 'label' => __('Reset Password'), 'onclick' => 'setLocation(\'' . $url . '\')', 'class' => 'save', - ), 0); + ], 0); } } + /** + * Retrieve the Url for creating an order. + * + * @return string + */ public function getCreateOrderUrl() { - return $this->getUrl('sales/order_create/start', array('customer_id' => $this->getCustomerId())); + return $this->getUrl('sales/order_create/start', ['customer_id' => $this->getCustomerId()]); } + /** + * Return the customer Id. + * + * @return int|null + */ public function getCustomerId() { - $customer = $this->_coreRegistry->registry('current_customer'); - return $customer ? $customer->getId() : false; + $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + return $customerId; } + /** + * Retrieve the header text, either the name of an existing customer or 'New Customer'. + * + * @return string + */ public function getHeaderText() { - if ($this->_coreRegistry->registry('current_customer')->getId()) { - return $this->escapeHtml($this->_coreRegistry->registry('current_customer')->getName()); + $customerId = $this->getCustomerId(); + if ($customerId) { + $customerData = $this->_customerService->getCustomer($customerId); + return $this->escapeHtml($this->_viewHelper->getCustomerName($customerData)); } else { return __('New Customer'); } } /** - * Prepare form html. Add block for composite product modification interface + * Prepare form Html. Add block for configurable product modification interface. * * @return string */ public function getFormHtml() { $html = parent::getFormHtml(); - $html .= $this->getLayout()->createBlock('Magento\Catalog\Block\Adminhtml\Product\Composite\Configure') + $html .= $this->getLayout() + ->createBlock('Magento\Catalog\Block\Adminhtml\Product\Composite\Configure') ->toHtml(); return $html; } + /** + * Retrieve customer validation Url. + * + * @return string + */ public function getValidationUrl() { - return $this->getUrl('customer/*/validate', array('_current' => true)); + return $this->getUrl('customer/*/validate', ['_current' => true]); } + /** + * Prepare the layout. + * + * @return \Magento\View\Element\AbstractBlock + */ protected function _prepareLayout() { - if (!$this->_coreRegistry->registry('current_customer')->isReadonly()) { - $this->_addButton('save_and_continue', array( - 'label' => __('Save and Continue Edit'), - 'class' => 'save', - 'data_attribute' => array( - 'mage-init' => array( - 'button' => array('event' => 'saveAndContinueEdit', 'target' => '#edit_form'), - ), - ), - ), 10); + $customerId = $this->getCustomerId(); + if (!$customerId || !$this->_customerService->isReadonly($customerId)) { + $this->_addButton('save_and_continue', [ + 'label' => __('Save and Continue Edit'), + 'class' => 'save', + 'data_attribute' => [ + 'mage-init' => [ + 'button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form'], + ], + ], + ], 10); } return parent::_prepareLayout(); } + /** + * Retrieve the save and continue edit Url. + * + * @return string + */ protected function _getSaveAndContinueUrl() { - return $this->getUrl('customer/index/save', array( + return $this->getUrl('customer/index/save', [ '_current' => true, 'back' => 'edit', 'tab' => '{{tab_id}}' - )); + ]); } } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Form.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Form.php index 5659bda5e38..e76629eb866 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Form.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Form.php @@ -18,38 +18,78 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\Customer\Service\V1\CustomerServiceInterface; /** * Adminhtml customer edit form block */ -namespace Magento\Customer\Block\Adminhtml\Edit; - class Form extends \Magento\Backend\Block\Widget\Form\Generic { + /** + * Customer Service. + * + * @var CustomerServiceInterface + */ + protected $_customerService; + + /** + * Constructor + * + * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\Registry $registry + * @param \Magento\Data\FormFactory $formFactory + * @param CustomerServiceInterface $customerService + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Template\Context $context, + \Magento\Registry $registry, + \Magento\Data\FormFactory $formFactory, + CustomerServiceInterface $customerService, + array $data = array() + ) { + $this->_customerService = $customerService; + parent::__construct($context, $registry, $formFactory, $data); + } + + /** + * Prepare the form. + * + * @return \Magento\Backend\Block\Widget\Form + */ protected function _prepareForm() { /** @var \Magento\Data\Form $form */ - $form = $this->_formFactory->create(array( - 'data' => array( - 'id' => 'edit_form', - 'action' => $this->getUrl('customer/*/save'), - 'method' => 'post', - 'enctype' => 'multipart/form-data', - )) + $form = $this->_formFactory->create( + [ + 'data' => [ + 'id' => 'edit_form', + 'action' => $this->getUrl('customer/*/save'), + 'method' => 'post', + 'enctype' => 'multipart/form-data', + ] + ] ); - $customer = $this->_coreRegistry->registry('current_customer'); + $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); - if ($customer->getId()) { - $form->addField('entity_id', 'hidden', array( - 'name' => 'customer_id', - )); - $form->setValues($customer->getData()); + if ($customerId) { + $form->addField( + 'id', + 'hidden', + [ + 'name' => 'customer_id', + ] + ); + $customer = $this->_customerService->getCustomer($customerId); + $form->setValues($customer->getAttributes()) + ->addValues(['customer_id' => $customerId]); } $form->setUseContainer(true); diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/Group.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/Group.php index 714c41f4abe..820f1df1b8d 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/Group.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/Group.php @@ -18,21 +18,20 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Renderer\Attribute; + +use Magento\Customer\Controller\RegistryConstants; + /** * Renderer for customer group ID * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> + * @method \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata getDisableAutoGroupChangeAttribute() + * @method mixed getDisableAutoGroupChangeAttributeValue() */ -namespace Magento\Customer\Block\Adminhtml\Edit\Renderer\Attribute; - class Group extends \Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Element { @@ -43,7 +42,7 @@ class Group * * @var \Magento\Customer\Helper\Address */ - protected $_customerAddress = null; + protected $_addressHelper = null; /** * Core registry @@ -65,7 +64,7 @@ class Group array $data = array() ) { $this->_coreRegistry = $registry; - $this->_customerAddress = $customerAddress; + $this->_addressHelper = $customerAddress; parent::__construct($context, $data); } @@ -86,7 +85,7 @@ class Group */ public function getDisableAutoGroupChangeCheckboxLabel() { - return __($this->getDisableAutoGroupChangeAttribute()->getFrontend()->getLabel()); + return __($this->getDisableAutoGroupChangeAttribute()->getFrontendLabel()); } /** @@ -96,9 +95,8 @@ class Group */ public function getDisableAutoGroupChangeCheckboxState() { - $customer = $this->_coreRegistry->registry('current_customer'); - $checkedByDefault = ($customer && $customer->getId()) - ? false : $this->_customerAddress->getDisableAutoGroupAssignDefaultValue(); + $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + $checkedByDefault = ($customerId) ? false : $this->_addressHelper->getDisableAutoGroupAssignDefaultValue(); $value = $this->getDisableAutoGroupChangeAttributeValue(); $state = ''; diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Newpass.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Newpass.php index d488f79a540..e9da9a65b50 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Newpass.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Newpass.php @@ -46,8 +46,10 @@ class Newpass $html.= '<div class="nested">'; $html.= '<div class="field choice">'; $html.= '<label for="account-send-pass" class="addbefore"><span>'.__('or ').'</span></label>'; - $html.= '<input type="checkbox" id="account-send-pass" name="'.$element->getName().'" value="auto" onclick="setElementDisable(\''.$element->getHtmlId().'\', this.checked)" />'; - $html.= '<label class="label" for="account-send-pass"><span>'.__(' Send auto-generated password').'</span></label>'; + $html.= '<input type="checkbox" id="account-send-pass" name="'.$element->getName(). + '" value="auto" onclick="setElementDisable(\''.$element->getHtmlId().'\', this.checked)" />'; + $html.= '<label class="label" for="account-send-pass"><span>'. + __(' Send auto-generated password').'</span></label>'; $html.= '</div>'."\n"; $html.= '</div>'."\n"; $html.= '</div>'."\n"; diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Region.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Region.php index 1fdb3a0b0fc..ade01f55a9a 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Region.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Region.php @@ -18,19 +18,14 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Renderer; /** * Customer address region field renderer - * - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml\Edit\Renderer; - class Region extends \Magento\Backend\Block\AbstractBlock implements \Magento\Data\Form\Element\Renderer\RendererInterface @@ -59,13 +54,14 @@ class Region * * @param \Magento\Data\Form\Element\AbstractElement $element * @return string + * + * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function render(\Magento\Data\Form\Element\AbstractElement $element) { if ($country = $element->getForm()->getElement('country_id')) { $countryId = $country->getValue(); - } - else { + } else { return $element->getDefaultHtml(); } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Account.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Account.php index a7462de733d..f1c86b21568 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Account.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Account.php @@ -18,27 +18,21 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * Customer account form block - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> - * - * @SuppressWarnings(PHPMD.DepthOfInheritance) - */ namespace Magento\Customer\Block\Adminhtml\Edit\Tab; +use Magento\Customer\Service\V1\CustomerAccountServiceInterface; + /** + * Customer account form block + * * @SuppressWarnings(PHPMD.DepthOfInheritance) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Account extends \Magento\Backend\Block\Widget\Form\Generic +class Account extends GenericMetadata { /** * Disable Auto Group Change Attribute Name @@ -46,9 +40,9 @@ class Account extends \Magento\Backend\Block\Widget\Form\Generic const DISABLE_ATTRIBUTE_NAME = 'disable_auto_group_change'; /** - * @var \Magento\Customer\Model\FormFactory + * @var \Magento\Customer\Model\Metadata\FormFactory */ - protected $_customerFactory; + protected $_customerFormFactory; /** * @var \Magento\Core\Model\System\Store @@ -65,30 +59,64 @@ class Account extends \Magento\Backend\Block\Widget\Form\Generic */ protected $_customerHelper; + /** + * @var \Magento\Customer\Service\V1\CustomerServiceInterface + */ + protected $_customerService; + + /** + * @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface + */ + protected $_customerAccountService; + + /** + * @var \Magento\Customer\Service\V1\CustomerMetadataServiceInterface + */ + protected $_customerMetadataService; + + /** + * @var \Magento\Customer\Service\V1\Dto\CustomerBuilder + */ + protected $_customerBuilder; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory * @param \Magento\Json\EncoderInterface $jsonEncoder - * @param \Magento\Customer\Model\FormFactory $customerFactory + * @param \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory * @param \Magento\Core\Model\System\Store $systemStore * @param \Magento\Customer\Helper\Data $customerHelper + * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService + * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService + * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $customerMetadataService + * @param \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder * @param array $data + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, \Magento\Json\EncoderInterface $jsonEncoder, - \Magento\Customer\Model\FormFactory $customerFactory, + \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory, \Magento\Core\Model\System\Store $systemStore, \Magento\Customer\Helper\Data $customerHelper, + \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, + \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService, + \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $customerMetadataService, + \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder, array $data = array() ) { $this->_customerHelper = $customerHelper; $this->_jsonEncoder = $jsonEncoder; $this->_systemStore = $systemStore; - $this->_customerFactory = $customerFactory; + $this->_customerFormFactory = $customerFormFactory; + $this->_customerService = $customerService; + $this->_customerAccountService = $customerAccountService; + $this->_customerMetadataService = $customerMetadataService; + $this->_customerBuilder = $customerBuilder; parent::__construct($context, $registry, $formFactory, $data); } @@ -96,6 +124,9 @@ class Account extends \Magento\Backend\Block\Widget\Form\Generic * Initialize form * * @return \Magento\Customer\Block\Adminhtml\Edit\Tab\Account + * + * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function initForm() { @@ -108,34 +139,39 @@ class Account extends \Magento\Backend\Block\Widget\Form\Generic 'legend' => __('Account Information') )); - $customer = $this->_coreRegistry->registry('current_customer'); - /** @var $customerForm \Magento\Customer\Model\Form */ - $customerForm = $this->_initCustomerForm($customer); + $customerData = $this->_backendSession->getCustomerData(); + $customerId = isset($customerData['customer_id']) ? $customerData['customer_id'] : false; + $accountData = isset($customerData['account']) ? $customerData['account'] : []; + $customerDto = $this->_customerBuilder->populateWithArray($accountData)->create(); + + $customerForm = $this->_initCustomerForm($customerDto); $attributes = $this->_initCustomerAttributes($customerForm); $this->_setFieldset($attributes, $fieldset, array(self::DISABLE_ATTRIBUTE_NAME)); - $form->getElement('group_id')->setRenderer($this->getLayout() - ->createBlock('Magento\Customer\Block\Adminhtml\Edit\Renderer\Attribute\Group') - ->setDisableAutoGroupChangeAttribute($customerForm->getAttribute(self::DISABLE_ATTRIBUTE_NAME)) - ->setDisableAutoGroupChangeAttributeValue($customer->getData(self::DISABLE_ATTRIBUTE_NAME)) - ); + $form->getElement('group_id') + ->setRenderer( + $this->getLayout() + ->createBlock('Magento\Customer\Block\Adminhtml\Edit\Renderer\Attribute\Group') + ->setDisableAutoGroupChangeAttribute($customerForm->getAttribute(self::DISABLE_ATTRIBUTE_NAME)) + ->setDisableAutoGroupChangeAttributeValue($customerDto->getAttribute(self::DISABLE_ATTRIBUTE_NAME)) + ); - $this->_setCustomerWebsiteId($customer); - $customerStoreId = $this->_getCustomerStoreId($customer); + $customerStoreId = $customerDto->getStoreId(); $prefixElement = $form->getElement('prefix'); if ($prefixElement) { $prefixOptions = $this->_customerHelper->getNamePrefixOptions($customerStoreId); if (!empty($prefixOptions)) { $fieldset->removeField($prefixElement->getId()); - $prefixField = $fieldset->addField($prefixElement->getId(), + $prefixField = $fieldset->addField( + $prefixElement->getId(), 'select', $prefixElement->getData(), $form->getElement('group_id')->getId() ); $prefixField->setValues($prefixOptions); - if ($customer->getId()) { - $prefixField->addElementValues($customer->getPrefix()); + if ($customerId) { + $prefixField->addElementValues($customerDto->getPrefix()); } } } @@ -145,29 +181,33 @@ class Account extends \Magento\Backend\Block\Widget\Form\Generic $suffixOptions = $this->_customerHelper->getNameSuffixOptions($customerStoreId); if (!empty($suffixOptions)) { $fieldset->removeField($suffixElement->getId()); - $suffixField = $fieldset->addField($suffixElement->getId(), + $suffixField = $fieldset->addField( + $suffixElement->getId(), 'select', $suffixElement->getData(), $form->getElement('lastname')->getId() ); $suffixField->setValues($suffixOptions); - if ($customer->getId()) { - $suffixField->addElementValues($customer->getSuffix()); + if ($customerId) { + $suffixField->addElementValues($customerDto->getSuffix()); } } } - if ($customer->getId()) { - $this->_addEditCustomerFormFields($form, $fieldset, $customer); + if ($customerId) { + $accountData = array_merge( + $this->_addEditCustomerFormFields($form, $fieldset, $customerDto), + $accountData + ); } else { $this->_addNewCustomerFormFields($form, $fieldset); - $customer->setData('sendemail', '1'); + $accountData['sendemail'] = '1'; } $this->_disableSendEmailStoreForEmptyWebsite($form); - $this->_handleReadOnlyCustomer($form, $customer); + $this->_handleReadOnlyCustomer($form, $customerId, $attributes); - $form->setValues($customer->getData()); + $form->setValues($accountData); $this->setForm($form); return $this; } @@ -187,19 +227,19 @@ class Account extends \Magento\Backend\Block\Widget\Form\Generic } /** - * Initialize attribute set + * Initialize attribute set. * - * @param \Magento\Customer\Model\Form $customerFor - * @return \Magento\Eav\Model\Entity\Attribute[] + * @param \Magento\Customer\Model\Metadata\Form $customerForm + * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[] */ - protected function _initCustomerAttributes(\Magento\Customer\Model\Form $customerForm) + protected function _initCustomerAttributes(\Magento\Customer\Model\Metadata\Form $customerForm) { $attributes = $customerForm->getAttributes(); - foreach ($attributes as $attribute) { - /* @var $attribute \Magento\Eav\Model\Entity\Attribute */ - $attributeLabel = __($attribute->getFrontend()->getLabel()); - $attribute->setFrontendLabel($attributeLabel); - $attribute->unsIsVisible(); + + foreach ($attributes as $key => $attribute) { + if ($attribute->getAttributeCode() == 'created_at') { + unset($attributes[$key]); + } } return $attributes; } @@ -207,35 +247,30 @@ class Account extends \Magento\Backend\Block\Widget\Form\Generic /** * Initialize customer form * - * @param \Magento\Customer\Model\Customer $customer - * @return \Magento\Customer\Model\Form $customerForm + * @param \Magento\Customer\Service\V1\Dto\Customer $customer + * @return \Magento\Customer\Model\Metadata\Form $customerForm */ - protected function _initCustomerForm(\Magento\Customer\Model\Customer $customer) + protected function _initCustomerForm(\Magento\Customer\Service\V1\Dto\Customer $customer) { - /** @var $customerForm \Magento\Customer\Model\Form */ - $customerForm = $this->_customerFactory->create(); - $customerForm->setEntity($customer) - ->setFormCode('adminhtml_customer') - ->initDefaultValues(); - - return $customerForm; + return $this->_customerFormFactory->create('customer', 'adminhtml_customer', $customer->getAttributes()); } /** * Handle Read-Only customer * * @param \Magento\Data\Form $form - * @param \Magento\Customer\Model\Customer $customer + * @param int $customerId + * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[] $attributes + * @return void */ - protected function _handleReadOnlyCustomer($form, $customer) + protected function _handleReadOnlyCustomer($form, $customerId, $attributes) { - if (!$customer->isReadonly()) { - return; - } - foreach ($customer->getAttributes() as $attribute) { - $element = $form->getElement($attribute->getAttributeCode()); - if ($element) { - $element->setReadonly(true, true); + if ($customerId && $this->_customerService->isReadonly($customerId)) { + foreach ($attributes as $attribute) { + $element = $form->getElement($attribute->getAttributeCode()); + if ($element) { + $element->setReadonly(true, true); + } } } } @@ -336,9 +371,10 @@ class Account extends \Magento\Backend\Block\Widget\Form\Generic * * @param \Magento\Data\Form $form * @param \Magento\Data\Form\Element\Fieldset $fieldset - * @param \Magento\Customer\Model\Customer $customer + * @param \Magento\Customer\Service\V1\Dto\Customer $customerDto + * @returns string[] Values to set on the form */ - protected function _addEditCustomerFormFields($form, $fieldset, $customer) + protected function _addEditCustomerFormFields($form, $fieldset, $customerDto) { $form->getElement('created_in')->setDisabled('disabled'); if (!$this->_storeManager->isSingleStoreMode()) { @@ -350,16 +386,18 @@ class Account extends \Magento\Backend\Block\Widget\Form\Generic $fieldset->removeField('website_id'); } - if ($customer->isReadonly()) { - return; + if ($customerDto->getCustomerId() && $this->_customerService->isReadonly($customerDto->getCustomerId())) { + return []; } + // Prepare customer confirmation control (only for existing customers) - $confirmationKey = $customer->getConfirmation(); - if ($confirmationKey || $customer->isConfirmationRequired()) { - $confirmationAttr = $customer->getAttribute('confirmation'); + $confirmationStatus = $this->_customerAccountService->getConfirmationStatus($customerDto->getCustomerId()); + $confirmationKey = $customerDto->getConfirmation(); + if ($confirmationStatus != CustomerAccountServiceInterface::ACCOUNT_CONFIRMED) { + $confirmationAttr = $this->_customerMetadataService->getCustomerAttributeMetadata('confirmation'); if (!$confirmationKey) { - $confirmationKey = $customer->getRandomConfirmationKey(); + $confirmationKey = $this->getRandomConfirmationKey(); } $element = $fieldset->addField('confirmation', 'select', array( @@ -374,78 +412,24 @@ class Account extends \Magento\Backend\Block\Widget\Form\Generic // Prepare send welcome email checkbox if customer is not confirmed // no need to add it, if website ID is empty - if ($customer->getConfirmation() && $customer->getWebsiteId()) { + if ($customerDto->getConfirmation() && $customerDto->getWebsiteId()) { $fieldset->addField('sendemail', 'checkbox', array( 'name' => 'sendemail', 'label' => __('Send Welcome Email after Confirmation') )); - $customer->setData('sendemail', '1'); + return ['sendemail' => '1']; } } + return []; } /** - * Add Password management fieldset - * - * @param \Magento\Data\Form $form - * @param string $fieldLabel - * @param boolean $isNew whether we set initial password or change existing one - */ - protected function _addPasswordManagementFieldset($form, $fieldLabel, $isNew) - { - // Add password management fieldset - $newFieldset = $form->addFieldset( - 'password_fieldset', - array('legend' => __('Password Management')) - ); - if ($isNew) { - // New customer password for existing customer - $elementId = 'new_password'; - $elementClass = 'validate-new-password'; - } else { - // Password field for newly generated customer - $elementId = 'password'; - $elementClass = 'input-text required-entry validate-password'; - } - $field = $newFieldset->addField($elementId, 'text', - array( - 'label' => __($fieldLabel), - 'name' => $elementId, - 'class' => $elementClass, - 'required' => !$isNew, - ) - ); - $field->setRenderer( - $this->getLayout()->createBlock('Magento\Customer\Block\Adminhtml\Edit\Renderer\Newpass') - ); - } - - /** - * Get Customer Store Id + * Called when account needs confirmation and does not have a confirmation key. * - * @param \Magento\Customer\Model\Customer $customer - * @return int|null + * @return string confirmation key */ - protected function _getCustomerStoreId(\Magento\Customer\Model\Customer $customer) + protected function _getRandomConfirmationKey() { - $customerStoreId = null; - if ($customer->getId()) { - $customerStoreId = $this->_storeManager->getWebsite($customer->getWebsiteId()) - ->getDefaultStore() - ->getId(); - } - return $customerStoreId; - } - - /** - * Set Customer Website Id in Single Store Mode - * - * @param \Magento\Customer\Model\Customer $customer - */ - protected function _setCustomerWebsiteId(\Magento\Customer\Model\Customer $customer) - { - if ($this->_storeManager->isSingleStoreMode()) { - $customer->setWebsiteId($this->_storeManager->getStore(true)->getWebsiteId()); - } + return md5(uniqid()); } } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Addresses.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Addresses.php index 57f2c09a581..96a37ecf83a 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Addresses.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Addresses.php @@ -18,31 +18,28 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\Customer\Service\V1\Dto\Eav\AttributeMetadataBuilder; +use Magento\Customer\Service\V1\Dto\Address; +use Magento\Exception\NoSuchEntityException; + /** * Customer addresses forms * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -namespace Magento\Customer\Block\Adminhtml\Edit\Tab; - -class Addresses extends \Magento\Backend\Block\Widget\Form\Generic +class Addresses extends GenericMetadata { - protected $_template = 'tab/addresses.phtml'; + /** Default street line count */ + const DEFAULT_STREET_LINES_COUNT = 2; - /** - * Adminhtml addresses - * - * @var \Magento\Backend\Helper\Addresses - */ - protected $_adminhtmlAddresses = null; + protected $_template = 'tab/addresses.phtml'; /** * @var \Magento\Json\EncoderInterface @@ -58,24 +55,49 @@ class Addresses extends \Magento\Backend\Block\Widget\Form\Generic * @var \Magento\Customer\Helper\Data */ protected $_customerHelper; - + /** * @var \Magento\Directory\Helper\Data */ protected $_directoryHelper; + + /** @var \Magento\Customer\Helper\Address */ + protected $_addressHelper; + + /** @var \Magento\Customer\Model\Metadata\FormFactory */ + protected $_metadataFormFactory; + + /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */ + protected $_customerService; + + /** @var \Magento\Customer\Service\V1\CustomerMetadataServiceInterface */ + protected $_metadataService; + + /** @var \Magento\Customer\Service\V1\Dto\AddressBuilder */ + protected $_addressBuilder; + + /** @var \Magento\Customer\Service\V1\Dto\CustomerBuilder */ + protected $_customerBuilder; + + /** @var AttributeMetadataBuilder */ + protected $_attributeMetadataBuilder; /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory + * @param \Magento\Core\Model\System\Store $systemStore, * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Json\EncoderInterface $jsonEncoder * @param \Magento\Customer\Model\Renderer\RegionFactory $regionFactory - * @param \Magento\Customer\Model\AddressFactory $addressFactory - * @param \Magento\Customer\Model\FormFactory $customerFactory - * @param \Magento\Core\Model\System\Store $systemStore - * @param \Magento\Backend\Helper\Addresses $adminhtmlAddresses + * @param \Magento\Customer\Model\Metadata\FormFactory $metadataFormFactory * @param \Magento\Customer\Helper\Data $customerHelper + * @param \Magento\Customer\Helper\Address $addressHelper + * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService + * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $metadataService + * @param \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder + * @param \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder + * @param AttributeMetadataBuilder $attributeMetadataBuilder; * @param \Magento\Directory\Helper\Data $directoryHelper * @param array $data * @@ -85,25 +107,33 @@ class Addresses extends \Magento\Backend\Block\Widget\Form\Generic \Magento\Backend\Block\Template\Context $context, \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, + \Magento\Core\Model\System\Store $systemStore, \Magento\Core\Helper\Data $coreData, \Magento\Json\EncoderInterface $jsonEncoder, \Magento\Customer\Model\Renderer\RegionFactory $regionFactory, - \Magento\Customer\Model\AddressFactory $addressFactory, - \Magento\Customer\Model\FormFactory $customerFactory, - \Magento\Core\Model\System\Store $systemStore, - \Magento\Backend\Helper\Addresses $adminhtmlAddresses, + \Magento\Customer\Model\Metadata\FormFactory $metadataFormFactory, \Magento\Customer\Helper\Data $customerHelper, + \Magento\Customer\Helper\Address $addressHelper, + \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, + \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $metadataService, + \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder, + \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder, + AttributeMetadataBuilder $attributeMetadataBuilder, \Magento\Directory\Helper\Data $directoryHelper, - array $data = array() + array $data = [] ) { $this->_customerHelper = $customerHelper; + $this->_addressHelper = $addressHelper; $this->_coreData = $coreData; $this->_jsonEncoder = $jsonEncoder; - $this->_adminhtmlAddresses = $adminhtmlAddresses; $this->_regionFactory = $regionFactory; - $this->_addressFactory = $addressFactory; - $this->_customerFactory = $customerFactory; + $this->_metadataFormFactory = $metadataFormFactory; $this->_systemStore = $systemStore; + $this->_customerService = $customerService; + $this->_metadataService = $metadataService; + $this->_addressBuilder = $addressBuilder; + $this->_customerBuilder = $customerBuilder; + $this->_attributeMetadataBuilder = $attributeMetadataBuilder; $this->_directoryHelper = $directoryHelper; parent::__construct($context, $registry, $formFactory, $data); } @@ -116,28 +146,28 @@ class Addresses extends \Magento\Backend\Block\Widget\Form\Generic protected function _prepareLayout() { $this->addChild('delete_button', 'Magento\Backend\Block\Widget\Button', array( - 'label' => __('Delete Address'), - 'name' => 'delete_address', - 'element_name' => 'delete_address', - 'disabled' => $this->isReadonly(), - 'class' => 'delete' . ($this->isReadonly() ? ' disabled' : '') - )); + 'label' => __('Delete Address'), + 'name' => 'delete_address', + 'element_name' => 'delete_address', + 'disabled' => $this->isReadonly(), + 'class' => 'delete' . ($this->isReadonly() ? ' disabled' : '') + )); $this->addChild('add_address_button', 'Magento\Backend\Block\Widget\Button', array( - 'label' => __('Add New Address'), - 'id' => 'add_address_button', - 'name' => 'add_address_button', - 'element_name' => 'add_address_button', - 'disabled' => $this->isReadonly(), - 'class' => 'add' . ($this->isReadonly() ? ' disabled' : '') - )); + 'label' => __('Add New Address'), + 'id' => 'add_address_button', + 'name' => 'add_address_button', + 'element_name' => 'add_address_button', + 'disabled' => $this->isReadonly(), + 'class' => 'add' . ($this->isReadonly() ? ' disabled' : '') + )); $this->addChild('cancel_button', 'Magento\Backend\Block\Widget\Button', array( - 'label' => __('Cancel'), - 'id' => 'cancel_add_address'.$this->getTemplatePrefix(), - 'name' => 'cancel_address', - 'element_name' => 'cancel_address', - 'class' => 'cancel delete-address' . ($this->isReadonly() ? ' disabled' : ''), - 'disabled' => $this->isReadonly() - )); + 'label' => __('Cancel'), + 'id' => 'cancel_add_address'.$this->getTemplatePrefix(), + 'name' => 'cancel_address', + 'element_name' => 'cancel_address', + 'class' => 'cancel delete-address' . ($this->isReadonly() ? ' disabled' : ''), + 'disabled' => $this->isReadonly() + )); return parent::_prepareLayout(); } @@ -148,8 +178,17 @@ class Addresses extends \Magento\Backend\Block\Widget\Form\Generic */ public function isReadonly() { - $customer = $this->_coreRegistry->registry('current_customer'); - return $customer->isReadonly(); + $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + + if (empty($customerId)) { + return false; + } + + try { + return $this->_customerService->isReadonly($customerId); + } catch (NoSuchEntityException $e) { + return false; + } } public function getDeleteButtonHtml() @@ -160,36 +199,55 @@ class Addresses extends \Magento\Backend\Block\Widget\Form\Generic /** * Initialize form object * - * @return \Magento\Customer\Block\Adminhtml\Edit\Tab\Addresses + * @return $this + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function initForm() { - /* @var $customer \Magento\Customer\Model\Customer */ - $customer = $this->_coreRegistry->registry('current_customer'); + + $customerData = $this->_backendSession->getCustomerData(); /** @var \Magento\Data\Form $form */ $form = $this->_formFactory->create(); $fieldset = $form->addFieldset('address_fieldset', array( - 'legend' => __("Edit Customer's Address")) + 'legend' => __("Edit Customer's Address")) ); - $addressModel = $this->_addressFactory->create(); - $addressModel->setCountryId($this->_coreData->getDefaultCountry($customer->getStore())); - /** @var $addressForm \Magento\Customer\Model\Form */ - $addressForm = $this->_customerFactory->create(); - $addressForm->setFormCode('adminhtml_customer_address') - ->setEntity($addressModel) - ->initDefaultValues(); + $account = $customerData['account']; + $this->_addressBuilder->populateWithArray([]); + if (!empty($account) && isset($account['store_id'])) { + $this->_addressBuilder->setCountryId( + $this->_coreData->getDefaultCountry( + $this->_storeManager->getStore($account['store_id']) + ) + ); + } else { + $this->_addressBuilder->setCountryId($this->_coreData->getDefaultCountry()); + } + $address = $this->_addressBuilder->create(); + + $addressForm = $this->_metadataFormFactory->create( + 'customer_address', + 'adminhtml_customer_address', + $address->getAttributes() + ); $attributes = $addressForm->getAttributes(); if (isset($attributes['street'])) { - $this->_adminhtmlAddresses - ->processStreetAttribute($attributes['street']); + if ($attributes['street']->getMultilineCount() <= 0 ) { + $attributes['street'] = $this->_attributeMetadataBuilder->populate($attributes['street']) + ->setMultilineCount(self::DEFAULT_STREET_LINES_COUNT) + ->create(); + } } - foreach ($attributes as $attribute) { - /* @var $attribute \Magento\Eav\Model\Entity\Attribute */ - $attribute->setFrontendLabel(__($attribute->getFrontend()->getLabel())); - $attribute->unsIsVisible(); + foreach ($attributes as $key => $attribute) { + $attributes[$key] = $this->_attributeMetadataBuilder->populate($attribute) + ->setFrontendLabel(__($attribute->getFrontendLabel())) + ->setVisible(false) + ->create(); } $this->_setFieldset($attributes, $fieldset); @@ -210,7 +268,7 @@ class Addresses extends \Magento\Backend\Block\Widget\Form\Generic } if ($this->isReadonly()) { - foreach ($addressModel->getAttributes() as $attribute) { + foreach ($this->_metadataService->getAllAddressAttributeMetadata() as $attribute) { $element = $form->getElement($attribute->getAttributeCode()); if ($element) { $element->setReadonly(true, true); @@ -219,8 +277,8 @@ class Addresses extends \Magento\Backend\Block\Widget\Form\Generic } $customerStoreId = null; - if ($customer->getId()) { - $customerStoreId = $this->_storeManager->getWebsite($customer->getWebsiteId()) + if (!empty($account) && isset($account['id']) && isset($account['website_id'])) { + $customerStoreId = $this->_storeManager->getWebsite($account['website_id']) ->getDefaultStore() ->getId(); } @@ -253,20 +311,30 @@ class Addresses extends \Magento\Backend\Block\Widget\Form\Generic } } - $addressCollection = $customer->getAddresses(); - $this->assign('customer', $customer); + $this->assign('customer', $this->_customerBuilder->populateWithArray($account)->create()); + $addressCollection = []; + foreach ($customerData['address'] as $key => $addressData) { + $addressCollection[$key] = $this->_addressBuilder->populateWithArray($addressData) + ->create(); + } $this->assign('addressCollection', $addressCollection); - $form->setValues($addressModel->getData()); + $form->setValues($address->getAttributes()); $this->setForm($form); return $this; } + /** + * @return string + */ public function getCancelButtonHtml() { return $this->getChildHtml('cancel_button'); } + /** + * @return string + */ public function getAddNewButtonHtml() { return $this->getChildHtml('add_address_button'); @@ -290,7 +358,7 @@ class Addresses extends \Magento\Backend\Block\Widget\Form\Generic * Add specified values to name prefix element values * * @param string|int|array $values - * @return \Magento\Customer\Block\Adminhtml\Edit\Tab\Addresses + * @return $this */ public function addValuesToNamePrefixElement($values) { @@ -304,7 +372,7 @@ class Addresses extends \Magento\Backend\Block\Widget\Form\Generic * Add specified values to name suffix element values * * @param string|int|array $values - * @return \Magento\Customer\Block\Adminhtml\Edit\Tab\Addresses + * @return $this */ public function addValuesToNameSuffixElement($values) { @@ -383,4 +451,16 @@ class Addresses extends \Magento\Backend\Block\Widget\Form\Generic { return $this->_jsonEncoder->encode($data); } + + /** + * Format the given address to the given type + * + * @param Address $address + * @param string $type + * @return string + */ + public function format(Address $address, $type) + { + return $this->_addressHelper->getFormatTypeRenderer($type)->renderArray($address->getAttributes()); + } } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php index 2cbc5568866..34d2570d343 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php @@ -18,21 +18,18 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** * Adminhtml customer orders grid block - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ namespace Magento\Customer\Block\Adminhtml\Edit\Tab; +use Magento\Customer\Controller\RegistryConstants; +use \Magento\Directory\Model\Currency; + /** * @SuppressWarnings(PHPMD.LongVariable) */ @@ -55,6 +52,11 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended */ protected $_quoteFactory; + /** + * @var string + */ + protected $_parentTemplate; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper @@ -69,7 +71,7 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Data\CollectionFactory $dataCollectionFactory, \Magento\Registry $coreRegistry, - array $data = array() + array $data = [] ) { $this->_dataCollectionFactory = $dataCollectionFactory; $this->_coreRegistry = $coreRegistry; @@ -77,6 +79,9 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended parent::__construct($context, $backendHelper, $data); } + /** + * {@inheritdoc} + */ protected function _construct() { parent::_construct(); @@ -96,14 +101,19 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended parent::_prepareGrid(); } + /** + * Prepare collection + * + * @return \Magento\Backend\Block\Widget\Grid + */ protected function _prepareCollection() { - $customer = $this->_coreRegistry->registry('current_customer'); + $customerId = $this->getCustomerId(); $storeIds = $this->_storeManager->getWebsite($this->getWebsiteId())->getStoreIds(); $quote = $this->_quoteFactory->create() ->setSharedStoreIds($storeIds) - ->loadByCustomer($customer); + ->loadByCustomer($customerId); if ($quote) { $collection = $quote->getItemsCollection(false); @@ -111,7 +121,7 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended $collection = $this->_dataCollectionFactory->create(); } - $collection->addFieldToFilter('parent_item_id', array('null' => true)); + $collection->addFieldToFilter('parent_item_id', ['null' => true]); $this->setCollection($collection); @@ -119,69 +129,76 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended } /** - * @return \Magento\Backend\Block\Widget\Grid\Extended + * {@inheritdoc} */ protected function _prepareColumns() { - $this->addColumn('product_id', array( + $this->addColumn('product_id', [ 'header' => __('ID'), 'index' => 'product_id', 'width' => '100px', - )); + ]); - $this->addColumn('name', array( + $this->addColumn('name', [ 'header' => __('Product'), 'index' => 'name', 'renderer' => 'Magento\Customer\Block\Adminhtml\Edit\Tab\View\Grid\Renderer\Item' - )); + ]); - $this->addColumn('sku', array( + $this->addColumn('sku', [ 'header' => __('SKU'), 'index' => 'sku', 'width' => '100px', - )); + ]); - $this->addColumn('qty', array( + $this->addColumn('qty', [ 'header' => __('Quantity'), 'index' => 'qty', 'type' => 'number', 'width' => '60px', - )); - - $this->addColumn('price', array( - 'header' => __('Price'), - 'index' => 'price', - 'type' => 'currency', - 'currency_code' => (string) $this->_storeConfig->getConfig(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE), - )); - - $this->addColumn('total', array( - 'header' => __('Total'), - 'index' => 'row_total', - 'type' => 'currency', - 'currency_code' => (string) $this->_storeConfig->getConfig(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE), - )); - - $this->addColumn('action', array( + ]); + + $this->addColumn( + 'price', + [ + 'header' => __('Price'), + 'index' => 'price', + 'type' => 'currency', + 'currency_code' => (string)$this->_storeConfig->getConfig(Currency::XML_PATH_CURRENCY_BASE), + ] + ); + + $this->addColumn( + 'total', + [ + 'header' => __('Total'), + 'index' => 'row_total', + 'type' => 'currency', + 'currency_code' => + (string)$this->_storeConfig->getConfig(Currency::XML_PATH_CURRENCY_BASE), + ] + ); + + $this->addColumn('action', [ 'header' => __('Action'), 'index' => 'quote_item_id', 'renderer' => 'Magento\Customer\Block\Adminhtml\Grid\Renderer\Multiaction', 'filter' => false, 'sortable' => false, - 'actions' => array( - array( + 'actions' => [ + [ 'caption' => __('Configure'), 'url' => 'javascript:void(0)', 'process' => 'configurable', 'control_object' => $this->getJsObjectName() . 'cartControl' - ), - array( + ], + [ 'caption' => __('Delete'), 'url' => '#', 'onclick' => 'return ' . $this->getJsObjectName() . 'cartControl.removeItem($item_id);' - ) - ) - )); + ] + ] + ]); return parent::_prepareColumns(); } @@ -189,32 +206,37 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended /** * Gets customer assigned to this block * - * @return \Magento\Customer\Model\Customer + * @return int */ - public function getCustomer() + public function getCustomerId() { - return $this->_coreRegistry->registry('current_customer'); + return $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); } /** - * @return string + * {@inheritdoc} */ public function getGridUrl() { - return $this->getUrl('customer/*/cart', array('_current'=>true, 'website_id' => $this->getWebsiteId())); + return $this->getUrl('customer/*/cart', ['_current'=>true, 'website_id' => $this->getWebsiteId()]); } /** + * Gets grid parent html + * * @return string */ public function getGridParentHtml() { - $templateName = $this->_viewFileSystem->getFilename($this->_parentTemplate, array('_relative' => true)); + $templateName = $this->_viewFileSystem->getFilename($this->_parentTemplate, ['_relative' => true]); return $this->fetchView($templateName); } + /** + * {@inheritdoc} + */ public function getRowUrl($row) { - return $this->getUrl('catalog/product/edit', array('id' => $row->getProductId())); + return $this->getUrl('catalog/product/edit', ['id' => $row->getProductId()]); } } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Carts.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Carts.php index 10b23f93f8a..7c0d6eb8e5d 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Carts.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Carts.php @@ -32,24 +32,28 @@ namespace Magento\Customer\Block\Adminhtml\Edit\Tab; class Carts extends \Magento\Backend\Block\Template { + /** @var \Magento\Customer\Model\Config\Share */ + protected $_shareConfig; + /** - * Core registry - * - * @var \Magento\Registry + * @var \Magento\Customer\Service\V1\Dto\CustomerBuilder */ - protected $_coreRegistry = null; + protected $_customerBuilder; /** - * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Registry $registry - * @param array $data + * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\Customer\Model\Config\Share $shareConfig + * @param \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder + * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Registry $registry, - array $data = array() + \Magento\Customer\Model\Config\Share $shareConfig, + \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder, + array $data = [] ) { - $this->_coreRegistry = $registry; + $this->_shareConfig = $shareConfig; + $this->_customerBuilder = $customerBuilder; parent::__construct($context, $data); } @@ -60,12 +64,15 @@ class Carts extends \Magento\Backend\Block\Template */ protected function _prepareLayout() { - $sharedWebsiteIds = $this->_coreRegistry->registry('current_customer')->getSharedWebsiteIds(); + $sharedWebsiteIds = $this->_shareConfig->getSharedWebsiteIds($this->_getCustomer()->getWebsiteId()); $isShared = count($sharedWebsiteIds) > 1; foreach ($sharedWebsiteIds as $websiteId) { $blockName = 'customer_cart_' . $websiteId; - $block = $this->getLayout()->createBlock('Magento\Customer\Block\Adminhtml\Edit\Tab\Cart', - $blockName, array('data' => array('website_id' => $websiteId))); + $block = $this->getLayout()->createBlock( + 'Magento\Customer\Block\Adminhtml\Edit\Tab\Cart', + $blockName, + ['data' => ['website_id' => $websiteId]] + ); if ($isShared) { $websiteName = $this->_storeManager->getWebsite($websiteId)->getName(); $block->setCartHeader(__('Shopping Cart from %1', $websiteName)); @@ -82,7 +89,16 @@ class Carts extends \Magento\Backend\Block\Template */ protected function _toHtml() { - $this->_eventManager->dispatch('adminhtml_block_html_before', array('block' => $this)); + $this->_eventManager->dispatch('adminhtml_block_html_before', ['block' => $this]); return $this->getChildHtml(); } + + /** + * @return \Magento\Customer\Service\V1\Dto\Customer + */ + protected function _getCustomer() + { + return $this->_customerBuilder + ->populateWithArray($this->_backendSession->getCustomerData()['account'])->create(); + } } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/GenericMetadata.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/GenericMetadata.php new file mode 100644 index 00000000000..57e4ef11471 --- /dev/null +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/GenericMetadata.php @@ -0,0 +1,115 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Block\Adminhtml\Edit\Tab; + +/** + * Generic block that uses customer metatdata attributes. + * + * @SuppressWarnings(PHPMD.DepthOfInheritance) + */ +class GenericMetadata extends \Magento\Backend\Block\Widget\Form\Generic +{ + /** + * Set Fieldset to Form + * + * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[] $attributes attributes that are to be added + * @param \Magento\Data\Form\Element\Fieldset $fieldset + * @param array $exclude attributes that should be skipped + * @return void + */ + protected function _setFieldset($attributes, $fieldset, $exclude = array()) + { + $this->_addElementTypes($fieldset); + + foreach ($attributes as $attribute) { + // Note, ignoring whether its visible or not, + if (($inputType = $attribute->getFrontendInput()) + && !in_array($attribute->getAttributeCode(), $exclude) + && (('media_image' != $inputType) || ($attribute->getAttributeCode() == 'image')) + ) { + + $fieldType = $inputType; + $element = $fieldset->addField( + $attribute->getAttributeCode(), + $fieldType, + array( + 'name' => $attribute->getAttributeCode(), + 'label' => __($attribute->getFrontendLabel()), + 'class' => $attribute->getFrontendClass(), + 'required' => $attribute->isRequired(), + 'note' => $attribute->getNote(), + ) + ); + + $element->setAfterElementHtml($this->_getAdditionalElementHtml($element)); + + $this->_applyTypeSpecificConfigCustomer($inputType, $element, $attribute); + } + } + } + + /** + * Apply configuration specific for different element type + * + * @param string $inputType + * @param \Magento\Data\Form\Element\AbstractElement $element + * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute + * @return void + */ + protected function _applyTypeSpecificConfigCustomer( + $inputType, + $element, + \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute + ) { + switch ($inputType) { + case 'select': + $element->setValues($this->_getAttributeOptionsArray($attribute)); + break; + case 'multiselect': + $element->setValues($this->_getAttributeOptionsArray($attribute)); + $element->setCanBeEmpty(true); + break; + case 'date': + $element->setImage($this->getViewFileUrl('images/grid-cal.gif')); + $element->setDateFormat($this->_localeDate->getDateFormatWithLongYear()); + break; + case 'multiline': + $element->setLineCount($attribute->getMultilineCount()); + break; + default: + break; + } + } + + protected function _getAttributeOptionsArray(\Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute) + { + $options = $attribute->getOptions(); + $result = []; + foreach ($options as $option) { + $result[] = $option->__toArray(); + } + return $result; + } +} diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter.php index 039cc3eb186..f7277ecd06e 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter.php @@ -18,23 +18,21 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab; + +use Magento\Customer\Controller\RegistryConstants; /** * Customer account form block - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml\Edit\Tab; - class Newsletter extends \Magento\Backend\Block\Widget\Form\Generic { + /** + * @var string + */ protected $_template = 'tab/newsletter.phtml'; /** @@ -43,10 +41,18 @@ class Newsletter extends \Magento\Backend\Block\Widget\Form\Generic protected $_subscriberFactory; /** + * @var \Magento\Customer\Service\V1\CustomerServiceInterface + */ + protected $_customerService; + + /** + * Constructor + * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory + * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService * @param array $data */ public function __construct( @@ -54,31 +60,37 @@ class Newsletter extends \Magento\Backend\Block\Widget\Form\Generic \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, + \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, array $data = array() ) { $this->_subscriberFactory = $subscriberFactory; + $this->_customerService = $customerService; parent::__construct($context, $registry, $formFactory, $data); } + /** + * Initialize the form. + * + * @return $this + */ public function initForm() { /** @var \Magento\Data\Form $form */ $form = $this->_formFactory->create(); $form->setHtmlIdPrefix('_newsletter'); - $customer = $this->_coreRegistry->registry('current_customer'); - $subscriber = $this->_subscriberFactory->create()->loadByCustomer($customer); + $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + $subscriber = $this->_subscriberFactory->create()->loadByCustomer($customerId); $this->_coreRegistry->register('subscriber', $subscriber); - $fieldset = $form->addFieldset('base_fieldset', array('legend'=>__('Newsletter Information'))); + $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Newsletter Information')]); - $fieldset->addField('subscription', 'checkbox', - array( - 'label' => __('Subscribed to Newsletter'), - 'name' => 'subscription' - ) + $fieldset->addField('subscription', 'checkbox', [ + 'label' => __('Subscribed to Newsletter'), + 'name' => 'subscription' + ] ); - if ($customer->isReadonly()) { + if ($this->_customerService->isReadonly($customerId)) { $form->getElement('subscription')->setReadonly(true, true); } @@ -86,29 +98,41 @@ class Newsletter extends \Magento\Backend\Block\Widget\Form\Generic $changedDate = $this->getStatusChangedDate(); if ($changedDate) { - $fieldset->addField('change_status_date', 'label', array( - 'label' => $subscriber->isSubscribed() ? __('Last Date Subscribed') : __('Last Date Unsubscribed'), - 'value' => $changedDate, - 'bold' => true - )); + $fieldset->addField('change_status_date', 'label', [ + 'label' => + $subscriber->isSubscribed() ? __('Last Date Subscribed') : __('Last Date Unsubscribed'), + 'value' => $changedDate, + 'bold' => true + ] + ); } $this->setForm($form); return $this; } + /** + * Retrieve the date when the subscriber status changed. + * + * @return null|string + */ public function getStatusChangedDate() { $subscriber = $this->_coreRegistry->registry('subscriber'); - if($subscriber->getChangeStatusAt()) { + if ($subscriber->getChangeStatusAt()) { return $this->formatDate( - $subscriber->getChangeStatusAt(), \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM, true + $subscriber->getChangeStatusAt(), \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, true ); } return null; } + /** + * Prepare the layout. + * + * @return \Magento\View\Element\AbstractBlock + */ protected function _prepareLayout() { $this->setChild('grid', diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid/Filter/Status.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid/Filter/Status.php index f1990f490cd..3bf125cea97 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid/Filter/Status.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid/Filter/Status.php @@ -18,56 +18,54 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\Newsletter\Grid\Filter; + +use Magento\Newsletter\Model\Queue; /** * Adminhtml newsletter subscribers grid website filter - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml\Edit\Tab\Newsletter\Grid\Filter; - class Status extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select { - + /** + * @var array + */ protected static $_statuses; protected function _construct() { - self::$_statuses = array( - null => null, - \Magento\Newsletter\Model\Queue::STATUS_SENT => __('Sent'), - \Magento\Newsletter\Model\Queue::STATUS_CANCEL => __('Cancel'), - \Magento\Newsletter\Model\Queue::STATUS_NEVER => __('Not Sent'), - \Magento\Newsletter\Model\Queue::STATUS_SENDING => __('Sending'), - \Magento\Newsletter\Model\Queue::STATUS_PAUSE => __('Paused'), - ); + self::$_statuses = [ + null => null, + Queue::STATUS_SENT => __('Sent'), + Queue::STATUS_CANCEL => __('Cancel'), + Queue::STATUS_NEVER => __('Not Sent'), + Queue::STATUS_SENDING => __('Sending'), + Queue::STATUS_PAUSE => __('Paused') + ]; parent::_construct(); } + /** + * @return array + */ protected function _getOptions() { - $result = array(); - foreach (self::$_statuses as $code=>$label) { - $result[] = array('value'=>$code, 'label'=>__($label)); + $options = []; + foreach (self::$_statuses as $status => $label) { + $options[] = ['value' => $status, 'label' => __($label)]; } - return $result; + return $options; } + /** + * @return array|null + */ public function getCondition() { - if(is_null($this->getValue())) { - return null; - } - - return array('eq'=>$this->getValue()); + return is_null($this->getValue()) ? null : ['eq' => $this->getValue()]; } - } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid/Renderer/Action.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid/Renderer/Action.php index 8ed79b883cc..eab83324874 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid/Renderer/Action.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid/Renderer/Action.php @@ -18,21 +18,14 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\Newsletter\Grid\Renderer; /** * Adminhtml newsletter queue grid block action item renderer - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml\Edit\Tab\Newsletter\Grid\Renderer; - class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { /** @@ -61,14 +54,14 @@ class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstract $actions = array(); $actions[] = array( - '@' => array( - 'href' => $this->getUrl('newsletter/template/preview', + '@' => array( + 'href' => $this->getUrl('newsletter/template/preview', array( - 'id' => $row->getTemplateId(), - 'subscriber'=> $this->_coreRegistry->registry('subscriber')->getId() + 'id' => $row->getTemplateId(), + 'subscriber' => $this->_coreRegistry->registry('subscriber')->getId() ) ), - 'target'=> '_blank' + 'target' => '_blank' ), '#' => __('View') ); @@ -78,7 +71,7 @@ class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstract protected function _getEscapedValue($value) { - return addcslashes(htmlspecialchars($value),'\\\''); + return addcslashes(htmlspecialchars($value), '\\\''); } protected function _actionsToHtml(array $actions) @@ -91,5 +84,4 @@ class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstract } return implode('<span class="separator"> | </span>', $html); } - } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid/Renderer/Status.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid/Renderer/Status.php index c07f8c638d7..b3bfd152299 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid/Renderer/Status.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid/Renderer/Status.php @@ -18,24 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\Newsletter\Grid\Renderer; /** * Adminhtml newsletter queue grid block status item renderer - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml\Edit\Tab\Newsletter\Grid\Renderer; - class Status extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { - protected static $_statuses; protected function _construct() @@ -55,13 +47,12 @@ class Status extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstract return __($this->getStatus($row->getQueueStatus())); } - public static function getStatus($status) + public static function getStatus($status) { - if(isset(self::$_statuses[$status])) { + if (isset(self::$_statuses[$status])) { return self::$_statuses[$status]; } return __('Unknown'); } - } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php index 48b8c2b8199..2d0e8636a93 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php @@ -18,21 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab; + +use Magento\Customer\Controller\RegistryConstants; /** * Adminhtml customer orders grid block - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml\Edit\Tab; - class Orders extends \Magento\Backend\Block\Widget\Grid\Extended { /** @@ -55,6 +50,8 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended protected $_collectionFactory; /** + * Constructor + * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Sales\Model\Resource\Order\Grid\CollectionFactory $collectionFactory @@ -76,6 +73,9 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended parent::__construct($context, $backendHelper, $data); } + /** + * {@inheritdoc} + */ protected function _construct() { parent::_construct(); @@ -84,6 +84,11 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended $this->setUseAjax(true); } + /** + * Apply various selection filters to prepare the sales order grid collection. + * + * @return \Magento\Backend\Block\Widget\Grid + */ protected function _prepareCollection() { $collection = $this->_collectionFactory->create() @@ -96,73 +101,85 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended ->addFieldToSelect('store_id') ->addFieldToSelect('billing_name') ->addFieldToSelect('shipping_name') - ->addFieldToFilter('customer_id', $this->_coreRegistry->registry('current_customer')->getId()) + ->addFieldToFilter('customer_id', $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID)) ->setIsCustomerMode(true); $this->setCollection($collection); return parent::_prepareCollection(); } + /** + * {@inheritdoc} + */ protected function _prepareColumns() { - $this->addColumn('increment_id', array( + $this->addColumn('increment_id', [ 'header' => __('Order'), 'width' => '100', 'index' => 'increment_id', - )); + ]); - $this->addColumn('created_at', array( + $this->addColumn('created_at', [ 'header' => __('Purchase Date'), 'index' => 'created_at', 'type' => 'datetime', - )); + ]); - $this->addColumn('billing_name', array( + $this->addColumn('billing_name', [ 'header' => __('Bill-to Name'), 'index' => 'billing_name', - )); + ]); - $this->addColumn('shipping_name', array( + $this->addColumn('shipping_name', [ 'header' => __('Ship-to Name'), 'index' => 'shipping_name', - )); + ]); - $this->addColumn('grand_total', array( + $this->addColumn('grand_total', [ 'header' => __('Order Total'), 'index' => 'grand_total', 'type' => 'currency', 'currency' => 'order_currency_code', - )); + ]); if (!$this->_storeManager->isSingleStoreMode()) { - $this->addColumn('store_id', array( + $this->addColumn('store_id', [ 'header' => __('Purchase Point'), 'index' => 'store_id', 'type' => 'store', 'store_view' => true - )); + ]); } if ($this->_salesReorder->isAllow()) { - $this->addColumn('action', array( + $this->addColumn('action', [ 'header' => ' ', 'filter' => false, 'sortable' => false, 'width' => '100px', 'renderer' => 'Magento\Sales\Block\Adminhtml\Reorder\Renderer\Action' - )); + ]); } return parent::_prepareColumns(); } + /** + * Retrieve the Url for a specified sales order row. + * + * @param \Magento\Sales\Model\Order|\Magento\Object $row + * @return string + */ public function getRowUrl($row) { - return $this->getUrl('sales/order/view', array('order_id' => $row->getId())); + return $this->getUrl('sales/order/view', ['order_id' => $row->getId()]); } + /** + * {@inheritdoc} + */ public function getGridUrl() { - return $this->getUrl('customer/*/orders', array('_current' => true)); + return $this->getUrl('customer/*/orders', ['_current' => true]); } } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php index 101e60094dc..b06d2fd0214 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View.php @@ -26,15 +26,21 @@ namespace Magento\Customer\Block\Adminhtml\Edit\Tab; +use Magento\Customer\Controller\RegistryConstants; +use Magento\Customer\Service\V1\CustomerAccountServiceInterface; +use Magento\Exception\NoSuchEntityException; + /** * Customer account form block + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class View extends \Magento\Backend\Block\Template implements \Magento\Backend\Block\Widget\Tab\TabInterface { /** - * @var \Magento\Customer\Model\Customer + * @var \Magento\Customer\Service\V1\Dto\Customer */ protected $_customer; @@ -55,11 +61,35 @@ class View */ protected $_modelVisitor; + /** + * @var \Magento\Customer\Service\V1\CustomerServiceInterface + */ + protected $_customerService; + + /** + * @var CustomerAccountServiceInterface + */ + protected $_accountService; + + /** + * @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface + */ + protected $_addressService; + /** * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface */ protected $_groupService; + /** + * @var \Magento\Customer\Service\V1\Dto\CustomerBuilder + */ + protected $_customerBuilder; + /** + * @var \Magento\Customer\Helper\Address + */ + protected $_addressHelper; + /** * @var \Magento\Log\Model\CustomerFactory */ @@ -72,16 +102,28 @@ class View /** * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService + * @param CustomerAccountServiceInterface $accountService + * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService + * @param \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder + * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Log\Model\CustomerFactory $logFactory * @param \Magento\Registry $registry * @param \Magento\Log\Model\Visitor $modelVisitor * @param \Magento\Stdlib\DateTime $dateTime * @param array $data + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Backend\Block\Template\Context $context, + \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, + CustomerAccountServiceInterface $accountService, + \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService, \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService, + \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder, + \Magento\Customer\Helper\Address $addressHelper, \Magento\Log\Model\CustomerFactory $logFactory, \Magento\Registry $registry, \Magento\Log\Model\Visitor $modelVisitor, @@ -90,23 +132,38 @@ class View ) { $this->_coreRegistry = $registry; $this->_modelVisitor = $modelVisitor; + $this->_customerService = $customerService; + $this->_accountService = $accountService; + $this->_addressService = $addressService; $this->_groupService = $groupService; + $this->_customerBuilder = $customerBuilder; + $this->_addressHelper = $addressHelper; $this->_logFactory = $logFactory; $this->dateTime = $dateTime; parent::__construct($context, $data); } /** - * @return \Magento\Customer\Model\Customer + * @return \Magento\Customer\Service\V1\Dto\Customer */ public function getCustomer() { if (!$this->_customer) { - $this->_customer = $this->_coreRegistry->registry('current_customer'); + $this->_customer = $this->_customerBuilder->populateWithArray( + $this->_backendSession->getCustomerData()['account'] + )->create(); } return $this->_customer; } + /** + * @return string|null + */ + public function getCustomerId() + { + return $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + } + /** * @param int $groupId * @return \Magento\Customer\Service\V1\Dto\CustomerGroup|null @@ -128,7 +185,7 @@ class View { $customer = $this->getCustomer(); - if ($groupId = ($customer->getId() ? $customer->getGroupId() : null)) { + if ($groupId = ($customer->getCustomerId() ? $customer->getGroupId() : null)) { if ($group = $this->getGroup($groupId)) { return $group->getCode(); } @@ -146,7 +203,7 @@ class View { if (!$this->_customerLog) { $this->_customerLog = $this->_logFactory->create() - ->loadByCustomer($this->getCustomer()->getId()); + ->loadByCustomer($this->getCustomerId()); } return $this->_customerLog; } @@ -160,7 +217,7 @@ class View { return $this->formatDate( $this->getCustomer()->getCreatedAt(), - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM, + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, true ); } @@ -170,12 +227,12 @@ class View */ public function getStoreCreateDate() { - $date = $this->_locale->storeDate( + $date = $this->_localeDate->scopeDate( $this->getCustomer()->getStoreId(), - $this->getCustomer()->getCreatedAtTimestamp(), + $this->getCustomer()->getCreatedAt(), true ); - return $this->formatDate($date, \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM, true); + return $this->formatDate($date, \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, true); } /** @@ -184,7 +241,7 @@ class View public function getStoreCreateDateTimezone() { return $this->_storeConfig->getConfig( - \Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_TIMEZONE, + $this->_localeDate->getDefaultTimezonePath(), $this->getCustomer()->getStoreId() ); } @@ -200,7 +257,7 @@ class View if ($date) { return $this->formatDate( $date, - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM, + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, true ); } @@ -214,12 +271,12 @@ class View { $date = $this->getCustomerLog()->getLoginAtTimestamp(); if ($date) { - $date = $this->_locale->storeDate( + $date = $this->_localeDate->storeDate( $this->getCustomer()->getStoreId(), $date, true ); - return $this->formatDate($date, \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM, true); + return $this->formatDate($date, \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, true); } return __('Never'); } @@ -230,7 +287,7 @@ class View public function getStoreLastLoginDateTimezone() { return $this->_storeConfig->getConfig( - \Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_TIMEZONE, + $this->_localeDate->getDefaultTimezonePath(), $this->getCustomer()->getStoreId() ); } @@ -255,14 +312,16 @@ class View */ public function getIsConfirmedStatus() { - $this->getCustomer(); - if (!$this->_customer->getConfirmation()) { - return __('Confirmed'); + $id = $this->getCustomerId(); + switch($this->_accountService->getConfirmationStatus($id)) { + case CustomerAccountServiceInterface::ACCOUNT_CONFIRMED: + return __('Confirmed'); + case CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_REQUIRED: + return __('Confirmation Required'); + case CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_NOT_REQUIRED: + return __('Confirmation Not Required'); } - if ($this->_customer->isConfirmationRequired()) { - return __('Not confirmed, cannot login'); - } - return __('Not confirmed, can login'); + return __('Indeterminate'); } /** @@ -270,7 +329,7 @@ class View */ public function getCreatedInStore() { - return $this->_storeManager->getStore($this->getCustomer()->getStoreId())->getName(); + return $this->_storeManager->getStore($this->getStoreId())->getName(); } /** @@ -283,11 +342,14 @@ class View public function getBillingAddressHtml() { - $address = $this->getCustomer()->getPrimaryBillingAddress(); - if ($address) { - return $address->format('html'); + try { + $address = $this->_addressService->getAddressById($this->getCustomer()->getDefaultBilling()); + } catch (NoSuchEntityException $e) { + return __('The customer does not have default billing address.'); } - return __('The customer does not have default billing address.'); + return $this->_addressHelper->getFormatTypeRenderer('html')->renderArray( + $address->getAttributes() + ); } /** @@ -327,7 +389,7 @@ class View */ public function canShowTab() { - if ($this->_coreRegistry->registry('current_customer')->getId()) { + if ($this->getCustomerId()) { return true; } return false; @@ -338,7 +400,7 @@ class View */ public function isHidden() { - if ($this->_coreRegistry->registry('current_customer')->getId()) { + if ($this->getCustomerId()) { return false; } return true; diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Accordion.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Accordion.php index 8758a1a9f82..ce0d575794c 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Accordion.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Accordion.php @@ -18,21 +18,19 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; + +use Magento\Customer\Service\V1\Dto\Customer; +use Magento\Exception\NoSuchEntityException; +use Magento\Customer\Controller\RegistryConstants; + /** * Adminhtml customer recent orders grid block - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; - class Accordion extends \Magento\Backend\Block\Widget\Accordion { /** @@ -52,11 +50,23 @@ class Accordion extends \Magento\Backend\Block\Widget\Accordion */ protected $_itemsFactory; + /** @var \Magento\Customer\Model\Config\Share */ + protected $_shareConfig; + + /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */ + protected $_customerService; + + /** @var \Magento\Customer\Service\V1\Dto\CustomerBuilder */ + protected $_customerBuilder; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Wishlist\Model\Resource\Item\CollectionFactory $itemsFactory * @param \Magento\Registry $registry + * @param \Magento\Customer\Model\Config\Share $shareConfig + * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService + * @param \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder * @param array $data */ public function __construct( @@ -64,18 +74,25 @@ class Accordion extends \Magento\Backend\Block\Widget\Accordion \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Wishlist\Model\Resource\Item\CollectionFactory $itemsFactory, \Magento\Registry $registry, + \Magento\Customer\Model\Config\Share $shareConfig, + \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, + \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder, array $data = array() ) { $this->_coreRegistry = $registry; $this->_quoteFactory = $quoteFactory; $this->_itemsFactory = $itemsFactory; + $this->_shareConfig = $shareConfig; + $this->_customerService = $customerService; + $this->_customerBuilder = $customerBuilder; parent::__construct($context, $data); } + /** + * {@inheritdoc} + */ protected function _prepareLayout() { - $customer = $this->_coreRegistry->registry('current_customer'); - $this->setId('customerViewAccordion'); $this->addItem('lastOrders', array( @@ -84,19 +101,22 @@ class Accordion extends \Magento\Backend\Block\Widget\Accordion 'content_url' => $this->getUrl('customer/*/lastOrders', array('_current' => true)), )); + $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + $customer = $this->getCustomer($customerId); + $websiteIds = $this->_shareConfig->getSharedWebsiteIds($customer->getWebsiteId()); // add shopping cart block of each website - foreach ($this->_coreRegistry->registry('current_customer')->getSharedWebsiteIds() as $websiteId) { + foreach ($websiteIds as $websiteId) { $website = $this->_storeManager->getWebsite($websiteId); // count cart items $cartItemsCount = $this->_quoteFactory->create() - ->setWebsite($website)->loadByCustomer($customer) + ->setWebsite($website)->loadByCustomer($customerId) ->getItemsCollection(false) ->addFieldToFilter('parent_item_id', array('null' => true)) ->getSize(); // prepare title for cart $title = __('Shopping Cart - %1 item(s)', $cartItemsCount); - if (count($customer->getSharedWebsiteIds()) > 1) { + if (count($websiteIds) > 1) { $title = __('Shopping Cart of %1 - %2 item(s)', $website->getName(), $cartItemsCount); } @@ -104,13 +124,14 @@ class Accordion extends \Magento\Backend\Block\Widget\Accordion $this->addItem('shopingCart' . $websiteId, array( 'title' => $title, 'ajax' => true, - 'content_url' => $this->getUrl('customer/*/viewCart', array('_current' => true, 'website_id' => $websiteId)), + 'content_url' => $this->getUrl('customer/*/viewCart', + array('_current' => true, 'website_id' => $websiteId)), )); } // count wishlist items $wishlistCount = $this->_itemsFactory->create() - ->addCustomerIdFilter($customer->getId()) + ->addCustomerIdFilter($customerId) ->addStoreData() ->getSize(); // add wishlist ajax accordion @@ -120,4 +141,23 @@ class Accordion extends \Magento\Backend\Block\Widget\Accordion 'content_url' => $this->getUrl('customer/*/viewWishlist', array('_current' => true)), )); } + + /** + * Get customer data from session or service. + * + * @param int|null $customerId possible customer ID from DB + * @return Customer + * @throws NoSuchEntityException + */ + protected function getCustomer($customerId) + { + $customerData = $this->_backendSession->getCustomerData(); + if (!empty($customerData['account'])) { + return $this->_customerBuilder->populateWithArray($customerData['account'])->create(); + } elseif ($customerId) { + return $this->_customerService->getCustomer($customerId); + } else { + return new Customer([]); + } + } } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php index 7aabf99eb30..3f98634153d 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php @@ -18,22 +18,17 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\Directory\Model\Currency; /** * Adminhtml customer cart items grid block * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; - -/** * @SuppressWarnings(PHPMD.LongVariable) */ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended @@ -56,6 +51,8 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended protected $_quoteFactory; /** + * Constructor + * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Sales\Model\QuoteFactory $quoteFactory @@ -77,6 +74,9 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended parent::__construct($context, $backendHelper, $data); } + /** + * {@inheritdoc} + */ protected function _construct() { parent::_construct(); @@ -88,6 +88,11 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended $this->setEmptyText(__('There are no items in customer\'s shopping cart at the moment')); } + /** + * Prepare the cart collection. + * + * @return \Magento\Backend\Block\Widget\Grid + */ protected function _prepareCollection() { $quote = $this->_quoteFactory->create(); @@ -96,10 +101,9 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended $quote->setWebsite($this->_storeManager->getWebsite($this->getWebsiteId())); } - /** @var \Magento\Customer\Model\Customer $currentCustomer */ - $currentCustomer = $this->_coreRegistry->registry('current_customer'); - if (!is_null($currentCustomer)) { - $quote->loadByCustomer($currentCustomer->getId()); + $currentCustomerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + if (!empty($currentCustomerId)) { + $quote->loadByCustomer($currentCustomerId); } if ($quote) { @@ -108,60 +112,87 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended $collection = $this->_dataCollectionFactory->create(); } - $collection->addFieldToFilter('parent_item_id', array('null' => true)); + $collection->addFieldToFilter('parent_item_id', ['null' => true]); $this->setCollection($collection); return parent::_prepareCollection(); } + /** + * {@inheritdoc} + */ protected function _prepareColumns() { - $this->addColumn('product_id', array( - 'header' => __('ID'), - 'index' => 'product_id', - 'width' => '100px', - )); - - $this->addColumn('name', array( - 'header' => __('Product'), - 'index' => 'name', - )); - - $this->addColumn('sku', array( - 'header' => __('SKU'), - 'index' => 'sku', - 'width' => '100px', - )); - - $this->addColumn('qty', array( - 'header' => __('Qty'), - 'index' => 'qty', - 'type' => 'number', - 'width' => '60px', - )); - - $this->addColumn('price', array( - 'header' => __('Price'), - 'index' => 'price', - 'type' => 'currency', - 'currency_code' => (string) $this->_storeConfig->getConfig(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE), - )); - - $this->addColumn('total', array( - 'header' => __('Total'), - 'index' => 'row_total', - 'type' => 'currency', - 'currency_code' => (string) $this->_storeConfig->getConfig(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE), - )); + $this->addColumn( + 'product_id', + [ + 'header' => __('ID'), + 'index' => 'product_id', + 'width' => '100px', + ] + ); + + $this->addColumn( + 'name', + [ + 'header' => __('Product'), + 'index' => 'name', + ] + ); + + $this->addColumn( + 'sku', + [ + 'header' => __('SKU'), + 'index' => 'sku', + 'width' => '100px', + ] + ); + + $this->addColumn( + 'qty', + [ + 'header' => __('Qty'), + 'index' => 'qty', + 'type' => 'number', + 'width' => '60px', + ] + ); + + $this->addColumn( + 'price', + [ + 'header' => __('Price'), + 'index' => 'price', + 'type' => 'currency', + 'currency_code' => (string)$this->_storeConfig->getConfig(Currency::XML_PATH_CURRENCY_BASE), + ] + ); + + $this->addColumn( + 'total', + [ + 'header' => __('Total'), + 'index' => 'row_total', + 'type' => 'currency', + 'currency_code' => (string)$this->_storeConfig->getConfig(Currency::XML_PATH_CURRENCY_BASE), + ] + ); return parent::_prepareColumns(); } + /** + * {@inheritdoc} + */ public function getRowUrl($row) { - return $this->getUrl('catalog/product/edit', array('id' => $row->getProductId())); + return $this->getUrl('catalog/product/edit', ['id' => $row->getProductId()]); } + /** + * {@inheritdoc} + */ public function getHeadersVisibility() { return ($this->getCollection()->getSize() >= 0); diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/Item.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/Item.php index c95bcf39bbc..151a602e37f 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/Item.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/Item.php @@ -18,23 +18,15 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View\Grid\Renderer; /** * Adminhtml customers wishlist grid item renderer for name/options cell - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View\Grid\Renderer; - -class Item - extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer +class Item extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { /** * Catalog product configuration @@ -49,6 +41,8 @@ class Item protected $_productConfigPool; /** + * Constructor + * * @param \Magento\Backend\Block\Context $context * @param \Magento\Catalog\Helper\Product\Configuration $productConfig * @param \Magento\Catalog\Helper\Product\ConfigurationPool $productConfigPool @@ -99,10 +93,9 @@ class Item return $this->_productConfigPool->get($helperName); } - /* + /** * Returns product associated with this block * - * @param \Magento\Catalog\Model\Product $product * @return string */ public function getProduct() @@ -126,21 +119,19 @@ class Item /** * Returns formatted option value for an item * - * @param \Magento\Wishlist\Item\Option + * @param \Magento\Wishlist\Model\Item\Option $option * @return array */ protected function getFormattedOptionValue($option) { - $params = array( - 'max_length' => 55 - ); + $params = ['max_length' => 55]; return $this->_productConfig->getFormattedOptionValue($option, $params); } /** * Renders item product name and its configuration * - * @param \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface $item + * @param \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface|\Magento\Object $item * @return string */ public function render(\Magento\Object $item) diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Orders.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Orders.php index f53ebc888fb..998dd402352 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Orders.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Orders.php @@ -18,21 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; + +use Magento\Customer\Controller\RegistryConstants; /** * Adminhtml customer recent orders grid block - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; - class Orders extends \Magento\Backend\Block\Widget\Grid\Extended { /** @@ -48,6 +43,8 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended protected $_collectionFactory; /** + * Constructor + * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Sales\Model\Resource\Order\Grid\CollectionFactory $collectionFactory @@ -66,6 +63,11 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended parent::__construct($context, $backendHelper, $data); } + /** + * Initialize the orders grid. + * + * @return void + */ protected function _construct() { parent::_construct(); @@ -76,6 +78,9 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended $this->setFilterVisibility(false); } + /** + * {@inheritdoc} + */ protected function _preparePage() { $this->getCollection() @@ -83,73 +88,84 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended ->setCurPage(1); } + /** + * {@inheritdoc} + */ protected function _prepareCollection() { $collection = $this->_collectionFactory->create() - ->addFieldToFilter('customer_id', $this->_coreRegistry->registry('current_customer')->getId()) + ->addFieldToFilter('customer_id', $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID)) ->setIsCustomerMode(true); $this->setCollection($collection); return parent::_prepareCollection(); } + /** + * {@inheritdoc} + */ protected function _prepareColumns() { - - $this->addColumn('increment_id', array( + $this->addColumn('increment_id', [ 'header' => __('Order'), 'align' => 'center', 'index' => 'increment_id', 'width' => '100px', - )); + ]); - $this->addColumn('created_at', array( + $this->addColumn('created_at', [ 'header' => __('Purchase Date'), 'index' => 'created_at', 'type' => 'datetime', - )); + ]); - $this->addColumn('billing_name', array( + $this->addColumn('billing_name', [ 'header' => __('Bill-to Name'), 'index' => 'billing_name', - )); + ]); - $this->addColumn('shipping_name', array( + $this->addColumn('shipping_name', [ 'header' => __('Shipped-to Name'), 'index' => 'shipping_name', - )); + ]); - $this->addColumn('grand_total', array( + $this->addColumn('grand_total', [ 'header' => __('Grand Total'), 'index' => 'grand_total', 'type' => 'currency', 'currency' => 'order_currency_code', - )); + ]); if (!$this->_storeManager->isSingleStoreMode()) { - $this->addColumn('store_id', array( + $this->addColumn('store_id', [ 'header' => __('Purchase Point'), 'index' => 'store_id', 'type' => 'store', 'store_view' => true, - )); + ]); } - $this->addColumn('action', array( + $this->addColumn('action', [ 'header' => ' ', 'filter' => false, 'sortable' => false, 'width' => '100px', 'renderer' => 'Magento\Sales\Block\Adminhtml\Reorder\Renderer\Action' - )); + ]); return parent::_prepareColumns(); } + /** + * {@inheritdoc} + */ public function getRowUrl($row) { - return $this->getUrl('sales/order/view', array('order_id' => $row->getId())); + return $this->getUrl('sales/order/view', ['order_id' => $row->getId()]); } + /** + * {@inheritdoc} + */ public function getHeadersVisibility() { return ($this->getCollection()->getSize() >= 0); diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Sales.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Sales.php index e21b631e2b7..12c3451306b 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Sales.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Sales.php @@ -18,24 +18,20 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\Directory\Model\Currency; +use Magento\Sales\Model\Order; /** - * Adminhtml customer view wishlist block - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> + * Adminhtml customer view sales block */ -namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; - class Sales extends \Magento\Backend\Block\Template { - /** * Sales entity collection * @@ -43,13 +39,20 @@ class Sales extends \Magento\Backend\Block\Template */ protected $_collection; + /** + * @var array + */ protected $_groupedCollection; + + /** + * @var int[] + */ protected $_websiteCounts; /** * Currency model * - * @var \Magento\Directory\Model\Currency + * @var Currency */ protected $_currency; @@ -71,6 +74,8 @@ class Sales extends \Magento\Backend\Block\Template protected $_collectionFactory; /** + * Constructor + * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Sales\Model\Resource\Sale\CollectionFactory $collectionFactory @@ -90,42 +95,49 @@ class Sales extends \Magento\Backend\Block\Template parent::__construct($context, $data); } + /** + * Initialize the sales grid. + * + * @return void + */ protected function _construct() { parent::_construct(); $this->setId('customer_view_sales_grid'); } + /** + * Execute before toHtml() code. + * + * @return \Magento\View\Element\AbstractBlock + */ public function _beforeToHtml() { $this->_currency = $this->_currencyFactory->create() - ->load($this->_storeConfig->getConfig(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE)); + ->load($this->_storeConfig->getConfig(Currency::XML_PATH_CURRENCY_BASE)); - $customerId = $this->_coreRegistry->registry('current_customer') - ? $this->_coreRegistry->registry('current_customer')->getId() - : 0; $this->_collection = $this->_collectionFactory->create() - ->setCustomerFilter($customerId) - ->setOrderStateFilter(\Magento\Sales\Model\Order::STATE_CANCELED, true) + ->setCustomerIdFilter((int)$this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID)) + ->setOrderStateFilter(Order::STATE_CANCELED, true) ->load(); - $this->_groupedCollection = array(); + $this->_groupedCollection = []; foreach ($this->_collection as $sale) { if (!is_null($sale->getStoreId())) { - $store = $this->_storeManager->getStore($sale->getStoreId()); - $websiteId = $store->getWebsiteId(); - $groupId = $store->getGroupId(); - $storeId = $store->getId(); + $store = $this->_storeManager->getStore($sale->getStoreId()); + $websiteId = $store->getWebsiteId(); + $groupId = $store->getGroupId(); + $storeId = $store->getId(); $sale->setWebsiteId($store->getWebsiteId()); $sale->setWebsiteName($store->getWebsite()->getName()); $sale->setGroupId($store->getGroupId()); $sale->setGroupName($store->getGroup()->getName()); } else { - $websiteId = 0; - $groupId = 0; - $storeId = 0; + $websiteId = 0; + $groupId = 0; + $storeId = 0; $sale->setStoreName(__('Deleted Stores')); } @@ -139,16 +151,28 @@ class Sales extends \Magento\Backend\Block\Template return parent::_beforeToHtml(); } + /** + * Retrieve the website count for the specified website Id + * + * @param int $websiteId + * @return int + */ public function getWebsiteCount($websiteId) { return isset($this->_websiteCounts[$websiteId]) ? $this->_websiteCounts[$websiteId] : 0; } + /** + * @return array + */ public function getRows() { return $this->_groupedCollection; } + /** + * @return \Magento\Object + */ public function getTotals() { return $this->_collection->getTotals(); diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Wishlist.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Wishlist.php index c5694f36c3a..f2a02926138 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Wishlist.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Wishlist.php @@ -18,36 +18,35 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; + +use Magento\Customer\Controller\RegistryConstants; /** * Adminhtml customer view wishlist block - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; - class Wishlist extends \Magento\Backend\Block\Widget\Grid\Extended { /** - * Core registry + * Core registry. * * @var \Magento\Registry */ protected $_coreRegistry = null; /** + * Wishlist item collection factory. + * * @var \Magento\Wishlist\Model\Resource\Item\CollectionFactory */ protected $_collectionFactory; /** + * Constructor + * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Wishlist\Model\Resource\Item\CollectionFactory $collectionFactory @@ -67,7 +66,7 @@ class Wishlist extends \Magento\Backend\Block\Widget\Grid\Extended } /** - * Initial settings + * Initial settings. * * @return void */ @@ -82,14 +81,14 @@ class Wishlist extends \Magento\Backend\Block\Widget\Grid\Extended } /** - * Prepare collection + * Prepare collection. * * @return \Magento\Customer\Block\Adminhtml\Edit\Tab\View\Wishlist */ protected function _prepareCollection() { $collection = $this->_collectionFactory->create() - ->addCustomerIdFilter($this->_coreRegistry->registry('current_customer')->getId()) + ->addCustomerIdFilter($this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID)) ->addDaysInWishlist() ->addStoreData() ->setInStockFilter(true); @@ -100,47 +99,47 @@ class Wishlist extends \Magento\Backend\Block\Widget\Grid\Extended } /** - * Prepare columns + * Prepare columns. * * @return \Magento\Customer\Block\Adminhtml\Edit\Tab\View\Wishlist */ protected function _prepareColumns() { - $this->addColumn('product_id', array( + $this->addColumn('product_id', [ 'header' => __('ID'), 'index' => 'product_id', 'type' => 'number', 'width' => '100px' - )); + ]); - $this->addColumn('product_name', array( + $this->addColumn('product_name', [ 'header' => __('Product'), 'index' => 'product_name', 'renderer' => 'Magento\Customer\Block\Adminhtml\Edit\Tab\View\Grid\Renderer\Item' - )); + ]); if (!$this->_storeManager->isSingleStoreMode()) { - $this->addColumn('store', array( + $this->addColumn('store', [ 'header' => __('Add Locale'), 'index' => 'store_id', 'type' => 'store', 'width' => '160px', - )); + ]); } - $this->addColumn('added_at', array( + $this->addColumn('added_at', [ 'header' => __('Add Date'), 'index' => 'added_at', 'type' => 'date', 'width' => '140px', - )); + ]); - $this->addColumn('days', array( + $this->addColumn('days', [ 'header' => __('Days in Wish List'), 'index' => 'days_in_wishlist', 'type' => 'number', 'width' => '140px', - )); + ]); return parent::_prepareColumns(); } @@ -149,6 +148,8 @@ class Wishlist extends \Magento\Backend\Block\Widget\Grid\Extended * Get headers visibility * * @return bool + * + * @SuppressWarnings(PHPMD.BooleanGetMethodName) */ public function getHeadersVisibility() { @@ -156,13 +157,10 @@ class Wishlist extends \Magento\Backend\Block\Widget\Grid\Extended } /** - * Get row url - * - * @param \Magento\Wishlist\Model\Item $item - * @return string + * {@inheritdoc} */ public function getRowUrl($row) { - return $this->getUrl('catalog/product/edit', array('id' => $row->getProductId())); + return $this->getUrl('catalog/product/edit', ['id' => $row->getProductId()]); } } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Wishlist/Grid/Renderer/Description.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Wishlist/Grid/Renderer/Description.php index 77b910c81fa..74bbb9c47e5 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Wishlist/Grid/Renderer/Description.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Wishlist/Grid/Renderer/Description.php @@ -18,27 +18,24 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\Wishlist\Grid\Renderer; /** * Adminhtml customers wishlist grid item renderer for item visibility - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml\Edit\Tab\Wishlist\Grid\Renderer; - class Description extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { - + /** + * Render the description of given row. + * + * @param \Magento\Object $row + * @return string + */ public function render(\Magento\Object $row) { return nl2br(htmlspecialchars($row->getData($this->getColumn()->getIndex()))); } - } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tabs.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tabs.php index ff408a82e72..47c9db80c89 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tabs.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tabs.php @@ -18,17 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Edit; + +use Magento\Customer\Controller\RegistryConstants; /** * Admin customer left menu */ -namespace Magento\Customer\Block\Adminhtml\Edit; - class Tabs extends \Magento\Backend\Block\Widget\Tabs { /** @@ -39,6 +38,8 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs protected $_coreRegistry = null; /** + * Constructor + * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Json\EncoderInterface $jsonEncoder * @param \Magento\Backend\Model\Auth\Session $authSession @@ -56,6 +57,9 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs parent::__construct($context, $jsonEncoder, $authSession, $data); } + /** + * {@inheritdoc} + */ protected function _construct() { parent::_construct(); @@ -64,6 +68,9 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs $this->setTitle(__('Customer Information')); } + /** + * {@inheritdoc} + */ protected function _beforeToHtml() { \Magento\Profiler::start('customer/tabs'); @@ -72,7 +79,7 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs 'label' => __('Account Information'), 'content' => $this->getLayout() ->createBlock('Magento\Customer\Block\Adminhtml\Edit\Tab\Account')->initForm()->toHtml(), - 'active' => $this->_coreRegistry->registry('current_customer')->getId() ? false : true + 'active' => $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID) ? false : true )); $this->addTab('addresses', array( @@ -81,10 +88,9 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs ->createBlock('Magento\Customer\Block\Adminhtml\Edit\Tab\Addresses')->initForm()->toHtml(), )); - // load: Orders, Shopping Cart, Wishlist, Product Reviews, Product Tags - with ajax - if ($this->_coreRegistry->registry('current_customer')->getId()) { + if ($this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID)) { if ($this->_authorization->isAllowed('Magento_Sales::actions_view')) { $this->addTab('orders', array( @@ -128,6 +134,11 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs return parent::_beforeToHtml(); } + /** + * Update and set the active tab. + * + * @return void + */ protected function _updateActiveTab() { $tabId = $this->getRequest()->getParam('tab'); diff --git a/app/code/Magento/Customer/Block/Adminhtml/Grid.php b/app/code/Magento/Customer/Block/Adminhtml/Grid.php index 1816d81a345..ec1be3e940e 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Grid.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Grid.php @@ -112,6 +112,11 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended return parent::_prepareCollection(); } + /** + * @return \Magento\Backend\Block\Widget\Grid\Extended + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ protected function _prepareColumns() { $this->addColumn('entity_id', array( diff --git a/app/code/Magento/Customer/Block/Adminhtml/Group/Edit.php b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit.php index 349dd3e0db4..32addd8b982 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Group/Edit.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit.php @@ -18,17 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Group; + +use Magento\Customer\Controller\RegistryConstants; /** * Customer group edit block */ -namespace Magento\Customer\Block\Adminhtml\Group; - class Edit extends \Magento\Backend\Block\Widget\Form\Container { /** @@ -39,11 +38,15 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container protected $_coreRegistry = null; /** + * Customer Group Service + * * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface */ protected $_groupService = null; /** + * Constructor + * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Registry $registry * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService @@ -60,6 +63,11 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container parent::__construct($context, $data); } + /** + * Update Save and Delete buttons. Remove Delete button if group can't be deleted. + * + * @return void + */ protected function _construct() { parent::_construct(); @@ -71,23 +79,33 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container $this->_updateButton('save', 'label', __('Save Customer Group')); $this->_updateButton('delete', 'label', __('Delete Customer Group')); - /** @var \Magento\Customer\Service\V1\Dto\CustomerGroup $group */ - $group = $this->_coreRegistry->registry('current_group'); - if (!$group || !$group->getId() || !$this->_groupService->canDelete($group->getId())) { + $groupId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID); + if (!$groupId || !$this->_groupService->canDelete($groupId)) { $this->_removeButton('delete'); } } + /** + * Retrieve the header text, either editing an existing group or creating a new one. + * + * @return string + */ public function getHeaderText() { - $currentGroup = $this->_coreRegistry->registry('current_group'); - if (!is_null($currentGroup->getId())) { - return __('Edit Customer Group "%1"', $this->escapeHtml($currentGroup->getCustomerGroupCode())); - } else { + $groupId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID); + if (is_null($groupId)) { return __('New Customer Group'); + } else { + $group = $this->_groupService->getGroup($groupId); + return __('Edit Customer Group "%1"', $this->escapeHtml($group->getCode())); } } + /** + * Retrieve CSS classes added to the header. + * + * @return string + */ public function getHeaderCssClass() { return 'icon-head head-customer-groups'; diff --git a/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/Form.php b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/Form.php index 3217b72a543..b684561e040 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/Form.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/Form.php @@ -18,21 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Adminhtml\Group\Edit; + +use Magento\Customer\Controller\RegistryConstants; /** * Adminhtml customer groups edit form - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Adminhtml\Group\Edit; - class Form extends \Magento\Backend\Block\Widget\Form\Generic { /** @@ -40,11 +35,23 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic */ protected $_taxCustomer; + /** + * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface + */ + protected $_groupService; + + /** + * @var \Magento\Customer\Service\V1\Dto\CustomerGroupBuilder + */ + protected $_groupBuilder; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory * @param \Magento\Tax\Model\TaxClass\Source\Customer $taxCustomer + * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService + * @param \Magento\Customer\Service\V1\Dto\CustomerGroupBuilder $groupBuilder * @param array $data */ public function __construct( @@ -52,9 +59,13 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, \Magento\Tax\Model\TaxClass\Source\Customer $taxCustomer, + \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService, + \Magento\Customer\Service\V1\Dto\CustomerGroupBuilder $groupBuilder, array $data = array() ) { $this->_taxCustomer = $taxCustomer; + $this->_groupService = $groupService; + $this->_groupBuilder = $groupBuilder; parent::__construct($context, $registry, $formFactory, $data); } @@ -68,8 +79,12 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic /** @var \Magento\Data\Form $form */ $form = $this->_formFactory->create(); - /** @var \Magento\Customer\Service\V1\Dto\CustomerGroup $customerGroup */ - $customerGroup = $this->_coreRegistry->registry('current_group'); + $groupId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID); + if (is_null($groupId)) { + $customerGroup = $this->_groupBuilder->create(); + } else { + $customerGroup = $this->_groupService->getGroup($groupId); + } $fieldset = $form->addFieldset('base_fieldset', array('legend'=>__('Group Information'))); @@ -87,7 +102,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic ) ); - if ($customerGroup->getId()==0 && $customerGroup->getCode() ) { + if ($customerGroup->getId() == 0 && $customerGroup->getCode()) { $name->setDisabled(true); } @@ -112,17 +127,12 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic ); } - if ( $this->_backendSession->getCustomerGroupData() ) { - $form->addValues($this->_backendSession->getCustomerGroupData()); - $this->_backendSession->setCustomerGroupData(null); - } else { - // TODO: need to figure out how the DTOs can work with forms - $form->addValues([ - 'id' => $customerGroup->getId(), - 'customer_group_code' => $customerGroup->getCode(), - 'tax_class_id' => $customerGroup->getTaxClassId(), - ]); - } + // TODO: need to figure out how the DTOs can work with forms + $form->addValues([ + 'id' => $customerGroup->getId(), + 'customer_group_code' => $customerGroup->getCode(), + 'tax_class_id' => $customerGroup->getTaxClassId(), + ]); $form->setUseContainer(true); $form->setId('edit_form'); diff --git a/app/code/Magento/Customer/Block/Form/Edit.php b/app/code/Magento/Customer/Block/Form/Edit.php old mode 100644 new mode 100755 index 1fa35366a9e..6f8d929e958 --- a/app/code/Magento/Customer/Block/Form/Edit.php +++ b/app/code/Magento/Customer/Block/Form/Edit.php @@ -18,36 +18,91 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Form; + +use Magento\Customer\Service\V1\CustomerServiceInterface; +use Magento\Customer\Service\V1\CustomerAddressServiceInterface; /** * Customer edit form block - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Form; - class Edit extends \Magento\Customer\Block\Account\Dashboard { /** + * Constructor + * * @param \Magento\View\Element\Template\Context $context * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory + * @param CustomerServiceInterface $customerService + * @param CustomerAddressServiceInterface $addressService * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, + CustomerServiceInterface $customerService, + CustomerAddressServiceInterface $addressService, array $data = array() ) { - parent::__construct($context, $customerSession, $subscriberFactory, $data); + parent::__construct( + $context, $customerSession, $subscriberFactory, $customerService, $addressService, $data + ); $this->_isScopePrivate = true; } + + /** + * Retrieve form data + * + * @return array + */ + protected function getFormData() + { + $data = $this->getData('form_data'); + if (is_null($data)) { + $formData = $this->_customerSession->getCustomerFormData(true); + $data = []; + if ($formData) { + $data['data'] = $formData; + $data['customer_data'] = 1; + } + $this->setData('form_data', $data); + } + return $data; + } + + /** + * Restore entity data from session. Entity and form code must be defined for the form. + * + * @param \Magento\Customer\Model\Metadata\Form $form + * @param null $scope + * @return \Magento\Customer\Block\Form\Register + */ + public function restoreSessionData(\Magento\Customer\Model\Metadata\Form $form, $scope = null) + { + $formData = $this->getFormData(); + if (isset($formData['customer_data']) && $formData['customer_data']) { + $request = $form->prepareRequest($formData['data']); + $data = $form->extractData($request, $scope, false); + $form->restoreData($data); + } + + return $this; + } + + /** + * Return whether the form should be opened in an expanded mode showing the change password fields + * + * @return bool + * + * @SuppressWarnings(PHPMD.BooleanGetMethodName) + */ + public function getChangePassword() + { + return $this->_customerSession->getChangePassword(); + } } diff --git a/app/code/Magento/Customer/Block/Form/Register.php b/app/code/Magento/Customer/Block/Form/Register.php index b84f43bca02..01d1efba74c 100644 --- a/app/code/Magento/Customer/Block/Form/Register.php +++ b/app/code/Magento/Customer/Block/Form/Register.php @@ -18,17 +18,14 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Form; /** * Customer register form block */ -namespace Magento\Customer\Block\Form; - class Register extends \Magento\Directory\Block\Data { /** @@ -181,9 +178,9 @@ class Register extends \Magento\Directory\Block\Data } /** - * Newsletter module availability + * Newsletter module availability * - * @return boolean + * @return bool */ public function isNewsletterEnabled() { diff --git a/app/code/Magento/Customer/Block/Newsletter.php b/app/code/Magento/Customer/Block/Newsletter.php index c24826046d5..d6c93ad6b97 100644 --- a/app/code/Magento/Customer/Block/Newsletter.php +++ b/app/code/Magento/Customer/Block/Newsletter.php @@ -18,39 +18,45 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block; +use Magento\Customer\Service\V1\CustomerServiceInterface; +use Magento\Customer\Service\V1\CustomerAddressServiceInterface; /** * Customer front newsletter manage block - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block; - class Newsletter extends \Magento\Customer\Block\Account\Dashboard { + /** + * @var string + */ protected $_template = 'form/newsletter.phtml'; /** + * Constructor + * * @param \Magento\View\Element\Template\Context $context * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory + * @param CustomerServiceInterface $customerService + * @param CustomerAddressServiceInterface $addressService * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, + CustomerServiceInterface $customerService, + CustomerAddressServiceInterface $addressService, array $data = array() ) { - parent::__construct($context, $customerSession, $subscriberFactory, $data); + parent::__construct( + $context, $customerSession, $subscriberFactory, $customerService, $addressService, $data + ); $this->_isScopePrivate = true; } @@ -59,9 +65,13 @@ class Newsletter extends \Magento\Customer\Block\Account\Dashboard return $this->getSubscriptionObject()->isSubscribed(); } + /** + * Return the save action Url. + * + * @return string + */ public function getAction() { return $this->getUrl('*/*/save'); } - } diff --git a/app/code/Magento/Customer/Block/Widget/AbstractWidget.php b/app/code/Magento/Customer/Block/Widget/AbstractWidget.php index bba542057a2..072c8fbadcc 100644 --- a/app/code/Magento/Customer/Block/Widget/AbstractWidget.php +++ b/app/code/Magento/Customer/Block/Widget/AbstractWidget.php @@ -96,7 +96,7 @@ class AbstractWidget extends \Magento\View\Element\Template protected function _getAttribute($attributeCode) { try { - return $this->_attributeMetadata->getAttributeMetadata('customer', $attributeCode); + return $this->_attributeMetadata->getCustomerAttributeMetadata($attributeCode); } catch (\Magento\Exception\NoSuchEntityException $e) { return null; } diff --git a/app/code/Magento/Customer/Block/Widget/Dob.php b/app/code/Magento/Customer/Block/Widget/Dob.php index dd528d21cf0..efe10371703 100644 --- a/app/code/Magento/Customer/Block/Widget/Dob.php +++ b/app/code/Magento/Customer/Block/Widget/Dob.php @@ -88,7 +88,7 @@ class Dob extends \Magento\Customer\Block\Widget\AbstractWidget */ public function getDateFormat() { - return $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + return $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); } /** diff --git a/app/code/Magento/Customer/Block/Widget/Gender.php b/app/code/Magento/Customer/Block/Widget/Gender.php index 673128c50f2..f0bb37091a5 100644 --- a/app/code/Magento/Customer/Block/Widget/Gender.php +++ b/app/code/Magento/Customer/Block/Widget/Gender.php @@ -18,22 +18,20 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Block\Widget; + +use Magento\Customer\Service\V1\CustomerMetadataServiceInterface; +use Magento\Customer\Service\V1\CustomerServiceInterface; +use Magento\Customer\Service\V1\Dto\Customer; +use Magento\Customer\Service\V1\Dto\Eav\Option; /** * Block to render customer's gender attribute - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Block\Widget; - -class Gender extends \Magento\Customer\Block\Widget\AbstractWidget +class Gender extends AbstractWidget { /** * @var \Magento\Customer\Model\Session @@ -41,34 +39,37 @@ class Gender extends \Magento\Customer\Block\Widget\AbstractWidget protected $_customerSession; /** - * @var \Magento\Customer\Model\Resource\Customer + * @var CustomerServiceInterface */ - protected $_customerResource; + protected $_customerService; /** + * Create an instance of the Gender widget + * * @param \Magento\View\Element\Template\Context $context * @param \Magento\Customer\Helper\Address $addressHelper - * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $attributeMetadata + * @param CustomerMetadataServiceInterface $attributeMetadata + * @param CustomerServiceInterface $customerService * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Customer\Model\Resource\Customer $customerResource * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Customer\Helper\Address $addressHelper, - \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $attributeMetadata, + CustomerMetadataServiceInterface $attributeMetadata, + CustomerServiceInterface $customerService, \Magento\Customer\Model\Session $customerSession, - \Magento\Customer\Model\Resource\Customer $customerResource, array $data = array() ) { $this->_customerSession = $customerSession; - $this->_customerResource = $customerResource; - parent::__construct($context, $addressHelper, $attributeMetadata, $data); + $this->_customerService = $customerService; + parent::__construct($context, $addressHelper, $attributeMetadata, $data); $this->_isScopePrivate = true; } /** * Initialize block + * @return void */ public function _construct() { @@ -78,7 +79,6 @@ class Gender extends \Magento\Customer\Block\Widget\AbstractWidget /** * Check if gender attribute enabled in system - * * @return bool */ public function isEnabled() @@ -88,7 +88,6 @@ class Gender extends \Magento\Customer\Block\Widget\AbstractWidget /** * Check if gender attribute marked as required - * * @return bool */ public function isRequired() @@ -97,25 +96,20 @@ class Gender extends \Magento\Customer\Block\Widget\AbstractWidget } /** - * Get current customer from session - * - * @return \Magento\Customer\Model\Customer + * Get current customer from session using the customer service + * @return Customer */ public function getCustomer() { - return $this->_customerSession->getCustomer(); + return $this->_customerService->getCustomer($this->_customerSession->getCustomerId()); } /** - * Returns options from gender source model - * - * @return array + * Returns options from gender attribute + * @return Option[] */ public function getGenderOptions() { - return $this->_customerResource - ->getAttribute('gender') - ->getSource() - ->getAllOptions(); + return $this->_getAttribute('gender')->getOptions(); } } diff --git a/app/code/Magento/Customer/Block/Widget/Name.php b/app/code/Magento/Customer/Block/Widget/Name.php index 3429244ca5b..cb02ffccf6b 100644 --- a/app/code/Magento/Customer/Block/Widget/Name.php +++ b/app/code/Magento/Customer/Block/Widget/Name.php @@ -26,27 +26,37 @@ namespace Magento\Customer\Block\Widget; +use Magento\Customer\Service\V1\CustomerMetadataServiceInterface; use Magento\Customer\Service\V1\Dto\Customer; +use Magento\View\Element\Template\Context; +use Magento\Customer\Helper\Address as AddressHelper; +use Magento\Customer\Helper\Data as CustomerHelper; -class Name extends \Magento\Customer\Block\Widget\AbstractWidget +/** + * Widget for showing customer name. + * + * @method \Magento\Customer\Service\V1\Dto\Customer getObject() + * @method Name setObject(\Magento\Customer\Service\V1\Dto\Customer $customer) + */ +class Name extends AbstractWidget { /** - * @var \Magento\Customer\Helper\Data + * @var CustomerHelper */ protected $_customerHelper; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Customer\Helper\Address $addressHelper - * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $attributeMetadata, - * @param \Magento\Customer\Helper\Data $customerHelper + * @param Context $context + * @param AddressHelper $addressHelper + * @param CustomerMetadataServiceInterface $attributeMetadata + * @param CustomerHelper $customerHelper * @param array $data */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Customer\Helper\Address $addressHelper, - \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $attributeMetadata, - \Magento\Customer\Helper\Data $customerHelper, + Context $context, + AddressHelper $addressHelper, + CustomerMetadataServiceInterface $attributeMetadata, + CustomerHelper $customerHelper, array $data = array() ) { $this->_customerHelper = $customerHelper; @@ -196,6 +206,8 @@ class Name extends \Magento\Customer\Block\Widget\AbstractWidget * * @param string $attributeCode * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata|null + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function _getAttribute($attributeCode) { @@ -206,7 +218,7 @@ class Name extends \Magento\Customer\Block\Widget\AbstractWidget } try { - $attribute = $this->_attributeMetadata->getAttributeMetadata('customer_address', $attributeCode); + $attribute = $this->_attributeMetadata->getAddressAttributeMetadata($attributeCode); } catch (\Magento\Exception\NoSuchEntityException $e) { return null; } @@ -233,6 +245,17 @@ class Name extends \Magento\Customer\Block\Widget\AbstractWidget return $attribute ? __($attribute->getStoreLabel()) : ''; } + /** + * Get string with frontend validation classes for attribute + * + * @param string $attributeCode + * @return string + */ + public function getAttributeValidationClass($attributeCode) + { + return $this->_addressHelper->getAttributeValidationClass($attributeCode); + } + /** * @param string $attributeCode * @return bool diff --git a/app/code/Magento/Customer/Block/Widget/Taxvat.php b/app/code/Magento/Customer/Block/Widget/Taxvat.php index c5ad13a4558..92a9cdc46ed 100644 --- a/app/code/Magento/Customer/Block/Widget/Taxvat.php +++ b/app/code/Magento/Customer/Block/Widget/Taxvat.php @@ -18,58 +18,64 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ namespace Magento\Customer\Block\Widget; -class Taxvat extends \Magento\Customer\Block\Widget\AbstractWidget +/** + * Customer Value Added Tax Widget + * + */ +class Taxvat extends AbstractWidget { /** - * @var \Magento\Customer\Model\Resource\Customer - */ - protected $_customerResource; - - /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Customer\Helper\Address $addressHelper + * Constructor. + * + * @param \Magento\View\Element\Template\Context $context + * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $attributeMetadata - * @param \Magento\Customer\Model\Session $customerSession - * @param array $data + * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Customer\Helper\Address $addressHelper, \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $attributeMetadata, - \Magento\Customer\Model\Session $customerSession, - array $data = array() + array $data = [] ) { - $this->_customerSession = $customerSession; parent::__construct($context, $addressHelper, $attributeMetadata, $data); $this->_isScopePrivate = true; } + /** + * Sets the template + * + * @return void + */ public function _construct() { parent::_construct(); $this->setTemplate('widget/taxvat.phtml'); } + /** + * Get is enabled. + * + * @return bool + */ public function isEnabled() { return $this->_getAttribute('taxvat') ? (bool)$this->_getAttribute('taxvat')->isVisible() : false; } + /** + * Get is required. + * + * @return bool + */ public function isRequired() { return $this->_getAttribute('taxvat') ? (bool)$this->_getAttribute('taxvat')->isRequired() : false; } - - public function getCustomer() - { - return $this->_customerSession->getCustomer(); - } } diff --git a/app/code/Magento/Customer/Controller/Account.php b/app/code/Magento/Customer/Controller/Account.php old mode 100644 new mode 100755 index 4bfe575994c..97d29a4c1f4 --- a/app/code/Magento/Customer/Controller/Account.php +++ b/app/code/Magento/Customer/Controller/Account.php @@ -18,15 +18,13 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Customer\Controller; use Magento\App\RequestInterface; +use Magento\Customer\Service\V1\CustomerServiceInterface; use Magento\Customer\Service\V1\CustomerAccountServiceInterface; use Magento\Customer\Service\V1\CustomerGroupServiceInterface; use Magento\Customer\Service\V1\Dto\Customer; @@ -37,13 +35,17 @@ use Magento\Exception\StateException; /** * Customer account controller + * + * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Account extends \Magento\App\Action\Action { /** * List of actions that are allowed for not authorized users * - * @var array + * @var string[] */ protected $_openActions = array( 'create', @@ -60,124 +62,125 @@ class Account extends \Magento\App\Action\Action 'loginpost' ); - /** - * Core registry - * - * @var \Magento\Registry - */ - protected $_coreRegistry; - - /** - * @var \Magento\Customer\Model\Session - */ + /** @var \Magento\Customer\Model\Session */ protected $_session; - /** - * @var \Magento\UrlFactory - */ - protected $_urlFactory; + /** @var \Magento\Customer\Helper\Address */ + protected $_addressHelper; - /** - * @var \Magento\Customer\Model\CustomerFactory - */ - protected $_customerFactory; + /** @var \Magento\Customer\Helper\Data */ + protected $_customerHelperData; - /** - * @var \Magento\Customer\Model\FormFactory - */ + /** @var \Magento\UrlFactory */ + protected $_urlFactory; + + /** @var \Magento\Customer\Model\Metadata\FormFactory */ protected $_formFactory; - /** - * Magento string lib - * - * @var \Magento\Stdlib\String - */ + /** @var \Magento\Stdlib\String */ protected $string; - /** @var CustomerAccountServiceInterface */ - protected $_customerAccountService; + /** @var \Magento\Core\App\Action\FormKeyValidator */ + protected $_formKeyValidator; - /** @var CustomerGroupV1Interface */ - protected $_groupService; + /** @var \Magento\Newsletter\Model\SubscriberFactory */ + protected $_subscriberFactory; - /** - * @var \Magento\Core\App\Action\FormKeyValidator - */ - protected $_formKeyValidator; + /** @var \Magento\Core\Model\StoreManagerInterface */ + protected $_storeManager; - /** - * @var \Magento\Escaper - */ + /** @var \Magento\Core\Model\Store\Config */ + protected $_storeConfig; + + /** @var \Magento\Core\Helper\Data */ + protected $coreHelperData; + + /** @var \Magento\Escaper */ protected $escaper; - /** - * @var \Magento\Newsletter\Model\SubscriberFactory - */ - protected $_subscriberFactory; + /** @var \Magento\App\State */ + protected $appState; - /** - * @var \Magento\Customer\Service\V1\Dto\RegionBuilder - */ + /** @var CustomerServiceInterface */ + protected $_customerService; + + /** @var CustomerGroupServiceInterface */ + protected $_groupService; + + /** @var CustomerAccountServiceInterface */ + protected $_customerAccountService; + + /** @var \Magento\Customer\Service\V1\Dto\RegionBuilder */ protected $_regionBuilder; - /** - * @var \Magento\Customer\Service\V1\Dto\AddressBuilder - */ + /** @var \Magento\Customer\Service\V1\Dto\AddressBuilder */ protected $_addressBuilder; - /** - * @var \Magento\Customer\Service\V1\Dto\CustomerBuilder - */ + /** @var \Magento\Customer\Service\V1\Dto\CustomerBuilder */ protected $_customerBuilder; /** * @param \Magento\App\Action\Context $context - * @param \Magento\Registry $coreRegistry * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Customer\Helper\Address $addressHelper + * @param \Magento\Customer\Helper\Data $customerHelperData * @param \Magento\UrlFactory $urlFactory - * @param \Magento\Customer\Model\CustomerFactory $customerFactory - * @param \Magento\Customer\Model\FormFactory $formFactory + * @param \Magento\Customer\Model\Metadata\FormFactory $formFactory * @param \Magento\Stdlib\String $string * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\Core\Model\Store\Config $storeConfig + * @param \Magento\Core\Helper\Data $coreHelperData * @param \Magento\Escaper $escaper + * @param \Magento\App\State $appState + * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $customerGroupService * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService * @param \Magento\Customer\Service\V1\Dto\RegionBuilder $regionBuilder * @param \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder * @param \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\App\Action\Context $context, - \Magento\Registry $coreRegistry, \Magento\Customer\Model\Session $customerSession, + \Magento\Customer\Helper\Address $addressHelper, + \Magento\Customer\Helper\Data $customerHelperData, \Magento\UrlFactory $urlFactory, - \Magento\Customer\Model\CustomerFactory $customerFactory, - \Magento\Customer\Model\FormFactory $formFactory, + \Magento\Customer\Model\Metadata\FormFactory $formFactory, \Magento\Stdlib\String $string, \Magento\Core\App\Action\FormKeyValidator $formKeyValidator, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\Core\Model\Store\Config $storeConfig, + \Magento\Core\Helper\Data $coreHelperData, \Magento\Escaper $escaper, + \Magento\App\State $appState, + CustomerServiceInterface $customerService, CustomerGroupServiceInterface $customerGroupService, CustomerAccountServiceInterface $customerAccountService, \Magento\Customer\Service\V1\Dto\RegionBuilder $regionBuilder, \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder, \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder ) { - $this->_storeManager = $storeManager; - $this->_coreRegistry = $coreRegistry; $this->_session = $customerSession; + $this->_addressHelper = $addressHelper; + $this->_customerHelperData = $customerHelperData; $this->_urlFactory = $urlFactory; - $this->_customerFactory = $customerFactory; $this->_formFactory = $formFactory; $this->string = $string; $this->_formKeyValidator = $formKeyValidator; - $this->_customerAccountService = $customerAccountService; - $this->_groupService = $customerGroupService; $this->_subscriberFactory = $subscriberFactory; + $this->_storeManager = $storeManager; + $this->_storeConfig = $storeConfig; + $this->coreHelperData = $coreHelperData; $this->escaper = $escaper; + $this->appState = $appState; + $this->_customerService = $customerService; + $this->_groupService = $customerGroupService; + $this->_customerAccountService = $customerAccountService; $this->_regionBuilder = $regionBuilder; $this->_addressBuilder = $addressBuilder; $this->_customerBuilder = $customerBuilder; @@ -212,7 +215,7 @@ class Account extends \Magento\App\Action\Action */ public function dispatch(RequestInterface $request) { - if (!$this->_objectManager->get('Magento\App\State')->isInstalled()) { + if (!$this->appState->isInstalled()) { parent::dispatch($request); } @@ -263,6 +266,7 @@ class Account extends \Magento\App\Action\Action /** * Login post action + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function loginPostAction() { @@ -281,8 +285,7 @@ class Account extends \Magento\App\Action\Action } catch (AuthenticationException $e) { switch ($e->getCode()) { case AuthenticationException::EMAIL_NOT_CONFIRMED: - $value = $this->_objectManager->get('Magento\Customer\Helper\Data') - ->getEmailConfirmationUrl($login['username']); + $value = $this->_customerHelperData->getEmailConfirmationUrl($login['username']); $message = __( 'This account is not confirmed.' . ' <a href="%1">Click here</a> to resend confirmation email.', @@ -311,11 +314,13 @@ class Account extends \Magento\App\Action\Action /** * Define target URL and redirect customer after logging in + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function _loginPostRedirect() { $lastCustomerId = $this->_getSession()->getLastCustomerId(); - if (isset($lastCustomerId) && $this->_getSession()->isLoggedIn() && $lastCustomerId != $this->_getSession()->getId()) { + if (isset($lastCustomerId) && $this->_getSession()->isLoggedIn() && + $lastCustomerId != $this->_getSession()->getId()) { $this->_getSession()->unsBeforeAuthUrl() ->setLastCustomerId($this->_getSession()->getId()); } @@ -323,15 +328,15 @@ class Account extends \Magento\App\Action\Action || $this->_getSession()->getBeforeAuthUrl() == $this->_storeManager->getStore()->getBaseUrl() ) { // Set default URL to redirect customer to - $this->_getSession()->setBeforeAuthUrl($this->_objectManager->get('Magento\Customer\Helper\Data')->getAccountUrl()); + $this->_getSession()->setBeforeAuthUrl($this->_customerHelperData->getAccountUrl()); // Redirect customer to the last page visited after logging in if ($this->_getSession()->isLoggedIn()) { - if (!$this->_objectManager->get('Magento\Core\Model\Store\Config')->getConfigFlag( + if (!$this->_storeConfig->getConfigFlag( \Magento\Customer\Helper\Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD )) { $referer = $this->getRequest()->getParam(\Magento\Customer\Helper\Data::REFERER_QUERY_PARAM_NAME); if ($referer) { - $referer = $this->_objectManager->get('Magento\Core\Helper\Data')->urlDecode($referer); + $referer = $this->coreHelperData->urlDecode($referer); if ($this->_url->isOwnOriginUrl()) { $this->_getSession()->setBeforeAuthUrl($referer); } @@ -340,10 +345,10 @@ class Account extends \Magento\App\Action\Action $this->_getSession()->setBeforeAuthUrl($this->_getSession()->getAfterAuthUrl(true)); } } else { - $this->_getSession()->setBeforeAuthUrl($this->_objectManager->get('Magento\Customer\Helper\Data')->getLoginUrl()); + $this->_getSession()->setBeforeAuthUrl($this->_customerHelperData->getLoginUrl()); } - } elseif ($this->_getSession()->getBeforeAuthUrl() == $this->_objectManager->get('Magento\Customer\Helper\Data')->getLogoutUrl()) { - $this->_getSession()->setBeforeAuthUrl($this->_objectManager->get('Magento\Customer\Helper\Data')->getDashboardUrl()); + } elseif ($this->_getSession()->getBeforeAuthUrl() == $this->_customerHelperData->getLogoutUrl()) { + $this->_getSession()->setBeforeAuthUrl($this->_customerHelperData->getDashboardUrl()); } else { if (!$this->_getSession()->getAfterAuthUrl()) { $this->_getSession()->setAfterAuthUrl($this->_getSession()->getBeforeAuthUrl()); @@ -394,6 +399,7 @@ class Account extends \Magento\App\Action\Action /** * Create customer account action + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function createPostAction() { @@ -409,32 +415,34 @@ class Account extends \Magento\App\Action\Action } try { - $customer = $this->_extractCustomer(); + $customer = $this->_extractCustomer('customer_account_create'); $address = $this->_extractAddress(); - $result = $this->_customerAccountService->createAccount( + $addresses = is_null($address) ? [] : [$address]; + $password = $this->getRequest()->getParam('password'); + $redirectUrl = $this->_getSession()->getBeforeAuthUrl(); + $customer = $this->_customerAccountService->createAccount( $customer, - is_null($address) ? array() : array($address), - $this->getRequest()->getParam('password'), - $this->_getSession()->getBeforeAuthUrl(), - '' + $addresses, + $password, + $redirectUrl ); - $this->_customerBuilder->populate($customer); - $this->_customerBuilder->setCustomerId($result->getCustomerId()); - $customer = $this->_customerBuilder->create(); if ($this->getRequest()->getParam('is_subscribed', false)) { - $this->_subscriberFactory->create()->updateSubscription($result->getCustomerId(), true); + $this->_subscriberFactory->create()->updateSubscription($customer->getCustomerId(), true); } $this->_eventManager->dispatch('customer_register_success', array('account_controller' => $this, 'customer' => $customer) ); - if ($result->getStatus() == CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION) { - $email = $this->_objectManager->get('Magento\Customer\Helper\Data')->getEmailConfirmationUrl($customer->getEmail()); + $confirmationStatus = $this->_customerAccountService->getConfirmationStatus($customer->getCustomerId()); + if ($confirmationStatus === CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_REQUIRED) { + $email = $this->_customerHelperData->getEmailConfirmationUrl($customer->getEmail()); + // @codingStandardsIgnoreStart $this->messageManager->addSuccess( __('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%1">click here</a>.', $email) ); + // @codingStandardsIgnoreEnd $url = $this->_createUrl()->getUrl('*/*/index', array('_secure' => true)); $this->getResponse()->setRedirect($this->_redirect->success($url)); } else { @@ -445,7 +453,9 @@ class Account extends \Magento\App\Action\Action return; } catch (StateException $e) { $url = $this->_createUrl()->getUrl('customer/account/forgotpassword'); + // @codingStandardsIgnoreStart $message = __('There is already an account with this email address. If you are sure that it is your email address, <a href="%1">click here</a> to get your password and access your account.', $url); + // @codingStandardsIgnoreEnd $this->messageManager->addError($message); } catch (InputException $e) { foreach ($e->getErrors() as $error) { @@ -472,14 +482,11 @@ class Account extends \Magento\App\Action\Action return null; } - $addressForm = $this->_createForm(); - $addressForm->setFormCode('customer_register_address') - ->setEntityType('customer_address'); + $addressForm = $this->_createForm('customer_address', 'customer_register_address'); $allowedAttributes = $addressForm->getAllowedAttributes(); $addressData = []; - /** @var $attribute \Magento\Eav\Model\Attribute */ foreach ($allowedAttributes as $attribute) { $attributeCode = $attribute->getAttributeCode(); $value = $this->getRequest()->getParam($attributeCode); @@ -508,18 +515,20 @@ class Account extends \Magento\App\Action\Action /** * Extract customer entity from request * + * @param string $formCode * @return Customer */ - protected function _extractCustomer() + protected function _extractCustomer($formCode) { - $customerForm = $this->_createForm(); - $customerForm->setFormCode('customer_account_create') - ->setEntityType('customer'); + $customerForm = $this->_createForm('customer', $formCode); $allowedAttributes = $customerForm->getAllowedAttributes(); $isGroupIdEmpty = true; - /** @var $attribute \Magento\Eav\Model\Attribute */ $customerData = []; foreach ($allowedAttributes as $attribute) { + // confirmation in request param is the repeated password, not a confirmation code. + if ($attribute === 'confirmation') { + continue; + } $attributeCode = $attribute->getAttributeCode(); if ($attributeCode == 'group_id') { $isGroupIdEmpty = false; @@ -527,12 +536,13 @@ class Account extends \Magento\App\Action\Action $customerData[$attributeCode] = $this->getRequest()->getParam($attributeCode); } $this->_customerBuilder->populateWithArray($customerData); - $storeId = $this->_storeManager->getStore()->getId(); + $store = $this->_storeManager->getStore(); if ($isGroupIdEmpty) { - $this->_customerBuilder->setGroupId($this->_groupService->getDefaultGroup($storeId)->getId()); + $this->_customerBuilder->setGroupId($this->_groupService->getDefaultGroup($store->getId())->getId()); } - $this->_customerBuilder->setConfirmation($this->getRequest()->getParam('confirmation')); + $this->_customerBuilder->setWebsiteId($store->getWebsiteId()); + $this->_customerBuilder->setStoreId($store->getId()); return $this->_customerBuilder->create(); } @@ -547,7 +557,7 @@ class Account extends \Magento\App\Action\Action $this->_addWelcomeMessage(); $successUrl = $this->_createUrl()->getUrl('*/*/index', array('_secure' => true)); - if (!$this->_objectManager->get('Magento\Core\Model\Store\Config')->getConfigFlag( + if (!$this->_storeConfig->getConfigFlag( \Magento\Customer\Helper\Data::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD ) && $this->_getSession()->getBeforeAuthUrl() @@ -567,21 +577,20 @@ class Account extends \Magento\App\Action\Action ); if ($this->_isVatValidationEnabled()) { // Show corresponding VAT message to customer - $configAddressType = $this->_objectManager->get('Magento\Customer\Helper\Address') - ->getTaxCalculationAddressType(); + $configAddressType = $this->_addressHelper->getTaxCalculationAddressType(); $editAddersUrl = $this->_createUrl()->getUrl('customer/address/edit'); switch ($configAddressType) { - case \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING: - $userPrompt = __( - 'If you are a registered VAT customer, please click <a href="%1">here</a> to enter you shipping address for proper VAT calculation', - $editAddersUrl - ); + case \Magento\Customer\Helper\Address::TYPE_SHIPPING: + // @codingStandardsIgnoreStart + $userPrompt = + __('If you are a registered VAT customer, please click <a href="%1">here</a> to enter you shipping address for proper VAT calculation', $editAddersUrl); + // @codingStandardsIgnoreEnd break; default: - $userPrompt = __( - 'If you are a registered VAT customer, please click <a href="%1">here</a> to enter you billing address for proper VAT calculation', - $editAddersUrl - ); + // @codingStandardsIgnoreStart + $userPrompt = + __('If you are a registered VAT customer, please click <a href="%1">here</a> to enter you billing address for proper VAT calculation', $editAddersUrl); + // @codingStandardsIgnoreEnd break; } $this->messageManager->addSuccess($userPrompt); @@ -592,39 +601,23 @@ class Account extends \Magento\App\Action\Action * load customer by id (try/catch in case if it throws exceptions) * * @param $customerId - * @return \Magento\Customer\Model\Customer + * @return \Magento\Customer\Service\V1\Dto\Customer * @throws \Exception */ protected function _loadCustomerById($customerId) { try { - /** @var \Magento\Customer\Model\Customer $customer */ - $customer = $this->_createCustomer()->load($customerId); - if ((!$customer) || (!$customer->getId())) { - throw new \Exception('Failed to load customer by id.'); - } - } catch (\Exception $e) { + /** @var \Magento\Customer\Service\V1\Dto\Customer $customer */ + $customer = $this->_customerService->getCustomer($customerId); + return $customer; + } catch (NoSuchEntityException $e) { throw new \Exception(__('Wrong customer account specified.')); } - return $customer; - } - - /** - * @param \Magento\Customer\Model\Customer $customer - * @throws \Exception - */ - protected function _activateCustomer($customer) - { - try { - $customer->setConfirmation(null); - $customer->save(); - } catch (\Exception $e) { - throw new \Exception(__('Failed to confirm customer account.')); - } } /** * Confirm customer account by id and confirmation key + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function confirmAction() { @@ -634,7 +627,7 @@ class Account extends \Magento\App\Action\Action } try { $customerId = $this->getRequest()->getParam('id', false); - $key = $this->getRequest()->getParam('key', false); + $key = $this->getRequest()->getParam('key', false); $backUrl = $this->getRequest()->getParam('back_url', false); if (empty($customerId) || empty($key)) { throw new \Exception(__('Bad request.')); @@ -670,33 +663,6 @@ class Account extends \Magento\App\Action\Action return; } - /** - * @param \Magento\Customer\Model\Customer $customer - * @param string $email - */ - protected function _confirmByEmail($customer, $email) - { - try { - $customer->setWebsiteId($this->_storeManager->getStore()->getWebsiteId())->loadByEmail($email); - if (!$customer->getId()) { - throw new \Exception(''); - } - if ($customer->getConfirmation()) { - $customer->sendNewAccountEmail('confirmation', '', $this->_storeManager->getStore()->getId()); - $this->messageManager->addSuccess(__('Please, check your email for confirmation key.')); - } else { - $this->messageManager->addSuccess(__('This email does not require confirmation.')); - } - $this->_getSession()->setUsername($email); - $url = $this->_createUrl()->getUrl('*/*/index', array('_secure' => true)); - $this->getResponse()->setRedirect($this->_redirect->success($url)); - } catch (\Exception $e) { - $this->messageManager->addException($e, __('Wrong email.')); - $url = $this->_createUrl()->getUrl('*/*/*', array('email' => $email, '_secure' => true)); - $this->getResponse()->setRedirect($this->_redirect->error($url)); - } - } - /** * Send confirmation link to specified email */ @@ -716,14 +682,14 @@ class Account extends \Magento\App\Action\Action } catch (StateException $e) { $this->messageManager->addSuccess(__('This email does not require confirmation.')); } catch (\Exception $e) { - $this->messageManager->addException($e, __('Wrong email.')); - $this->getResponse()->setRedirect( - $this->_createUrl()->getUrl( - '*/*/*', - array('email' => $email, '_secure' => true) - ) - ); - return; + $this->messageManager->addException($e, __('Wrong email.')); + $this->getResponse()->setRedirect( + $this->_createUrl()->getUrl( + '*/*/*', + array('email' => $email, '_secure' => true) + ) + ); + return; } $this->_getSession()->setUsername($email); $this->getResponse()->setRedirect($this->_createUrl()->getUrl('*/*/index', array('_secure' => true))); @@ -772,7 +738,11 @@ class Account extends \Magento\App\Action\Action try { $this->_customerAccountService - ->sendPasswordResetLink($email, $this->_storeManager->getStore()->getWebsiteId()); + ->sendPasswordResetLink( + $email, + $this->_storeManager->getStore()->getWebsiteId(), + CustomerAccountServiceInterface::EMAIL_RESET + ); } catch (NoSuchEntityException $e) { // Do nothing, we don't want anyone to use this action to determine which email accounts are registered. } catch (\Exception $exception) { @@ -780,10 +750,12 @@ class Account extends \Magento\App\Action\Action $this->_redirect('*/*/forgotpassword'); return; } - $email = $this->_objectManager->get('Magento\Escaper')->escapeHtml($email); + $email = $this->escaper->escapeHtml($email); + // @codingStandardsIgnoreStart $this->messageManager->addSuccess( __('If there is an account associated with %1 you will receive an email with a link to reset your password.', $email) ); + // @codingStandardsIgnoreEnd $this->_redirect('*/*/'); return; } else { @@ -856,7 +828,8 @@ class Account extends \Magento\App\Action\Action } try { - $this->_customerAccountService->resetPassword($customerId, $password, $resetPasswordToken); + $this->_customerAccountService->validateResetPasswordLinkToken($customerId, $resetPasswordToken); + $this->_customerAccountService->changePassword($customerId, $password); $this->messageManager->addSuccess( __('Your password has been updated.') ); @@ -884,14 +857,16 @@ class Account extends \Magento\App\Action\Action if ($block) { $block->setRefererUrl($this->_redirect->getRefererUrl()); } + $data = $this->_getSession()->getCustomerFormData(true); - $customer = $this->_getSession()->getCustomer(); + $customerId = $this->_getSession()->getCustomerId(); + $customerData = $this->_customerService->getCustomer($customerId)->__toArray(); + if (!empty($data)) { - $customer->addData($data); - } - if ($this->getRequest()->getParam('changepass') == 1) { - $customer->setChangePassword(1); + array_merge($customerData, $data); } + $this->_getSession()->setCustomerDto($this->_customerBuilder->populateWithArray($customerData)->create()); + $this->_getSession()->setChangePassword($this->getRequest()->getParam('changepass') == 1); $this->_view->getLayout()->getBlock('head')->setTitle(__('Account Information')); $this->_view->getLayout()->getBlock('messages')->setEscapeMessageFlag(true); @@ -900,6 +875,7 @@ class Account extends \Magento\App\Action\Action /** * Change customer password action + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function editPostAction() { @@ -909,83 +885,58 @@ class Account extends \Magento\App\Action\Action } if ($this->getRequest()->isPost()) { - /** @var $customer \Magento\Customer\Model\Customer */ - $customer = $this->_getSession()->getCustomer(); - - /** @var $customerForm \Magento\Customer\Model\Form */ - $customerForm = $this->_createForm(); - $customerForm->setFormCode('customer_account_edit') - ->setEntity($customer); - - $customerData = $customerForm->extractData($this->getRequest()); - - $customerForm->compactData($customerData); - $errors = array(); + $customerId = $this->_getSession()->getCustomerId(); + $customer = $this->_extractCustomer('customer_account_edit'); + $this->_customerBuilder->populate($customer); + $this->_customerBuilder->setCustomerId($customerId); + $customer = $this->_customerBuilder->create(); - // If password change was requested then add it to common validation scheme if ($this->getRequest()->getParam('change_password')) { $currPass = $this->getRequest()->getPost('current_password'); $newPass = $this->getRequest()->getPost('password'); $confPass = $this->getRequest()->getPost('confirmation'); - $oldPass = $this->_getSession()->getCustomer()->getPasswordHash(); - if ($this->string->strpos($oldPass, ':')) { - list(, $salt) = explode(':', $oldPass); - } else { - $salt = false; - } - - if ($customer->hashPassword($currPass, $salt) == $oldPass) { - if (strlen($newPass)) { - /** - * Set entered password and its confirmation - they - * will be validated later to match each other and be of right length - */ - $customer->setPassword($newPass); - $customer->setConfirmation($confPass); + if (strlen($newPass)) { + if ($newPass == $confPass) { + try { + $this->_customerAccountService->validatePassword($customerId, $currPass); + $this->_customerAccountService->changePassword($customerId, $newPass); + } catch (AuthenticationException $e) { + $this->messageManager->addError($e->getMessage()); + } catch (\Exception $e) { + $this->messageManager + ->addException($e, __('A problem was encountered trying to change password.')); + } } else { - $errors[] = __('New password field cannot be empty.'); + $this->messageManager->addError(__('Confirm your new password')); } } else { - $errors[] = __('Invalid current password'); + $this->messageManager->addError(__('New password field cannot be empty.')); } } - // Validate account and compose list of errors if any - $customerErrors = $customer->validate(); - if (is_array($customerErrors)) { - $errors = array_merge($errors, $customerErrors); + try { + $this->_customerAccountService->updateAccount($customer); + } catch (AuthenticationException $e) { + $this->messageManager->addError($e->getMessage()); + } catch (InputException $e) { + $this->messageManager->addException($e, __('Invalid input')); + } catch (\Exception $e) { + $this->messageManager + ->addException( + $e, __('Cannot save the customer.') . + $e->getMessage() . '<pre>' . $e->getTraceAsString() . '</pre>'); } - if (!empty($errors)) { + if ($this->messageManager->getMessages()->getCount() > 0) { $this->_getSession()->setCustomerFormData($this->getRequest()->getPost()); - foreach ($errors as $message) { - $this->messageManager->addError($message); - } $this->_redirect('*/*/edit'); return; } - try { - $customer->setConfirmation(null); - $customer->save(); - - if ($this->getRequest()->getParam('change_password')) { - $customer->sendPasswordResetNotificationEmail('reset_frontend'); - } - - $this->_getSession()->setCustomer($customer); - $this->messageManager->addSuccess(__('The account information has been saved.')); - - $this->_redirect('customer/account'); - return; - } catch (\Magento\Core\Exception $e) { - $this->_getSession()->setCustomerFormData($this->getRequest()->getPost()); - $this->messageManager->addError($e->getMessage()); - } catch (\Exception $e) { - $this->_getSession()->setCustomerFormData($this->getRequest()->getPost()); - $this->messageManager->addException($e, __('Cannot save the customer.')); - } + $this->messageManager->addSuccess(__('The account information has been saved.')); + $this->_redirect('customer/account'); + return; } $this->_redirect('*/*/edit'); @@ -999,7 +950,7 @@ class Account extends \Magento\App\Action\Action */ protected function _isVatValidationEnabled($store = null) { - return $this->_objectManager->get('Magento\Customer\Helper\Address')->isVatValidationEnabled($store); + return $this->_addressHelper->isVatValidationEnabled($store); } /** @@ -1011,18 +962,12 @@ class Account extends \Magento\App\Action\Action } /** - * @return \Magento\Customer\Model\Customer - */ - protected function _createCustomer() - { - return $this->_customerFactory->create(); - } - - /** - * @return \Magento\Customer\Model\Form + * @param string $entityType + * @param string $formCode + * @return \Magento\Customer\Model\Metadata\Form */ - protected function _createForm() + protected function _createForm($entityType, $formCode) { - return $this->_formFactory->create(); + return $this->_formFactory->create($entityType, $formCode); } } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php index fcbbd5c3e2b..5ebd0c0806e 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php @@ -38,9 +38,9 @@ class Cart extends \Magento\Backend\App\Action /** * Customer we're working with * - * @var \Magento\Customer\Model\Customer + * @var int id of the customer */ - protected $_customer = null; + protected $_customerId; /** * Quote we're working with @@ -59,24 +59,22 @@ class Cart extends \Magento\Backend\App\Action /** * Loads customer, quote and quote item by request params * - * @return \Magento\Customer\Controller\Adminhtml\Cart\Product\Composite\Cart + * @return $this + * @throws \Magento\Core\Exception */ protected function _initData() { - $customerId = (int) $this->getRequest()->getParam('customer_id'); - if (!$customerId) { + $this->_customerId = (int)$this->getRequest()->getParam('customer_id'); + if (!$this->_customerId) { throw new \Magento\Core\Exception(__('No customer ID defined.')); } - $this->_customer = $this->_objectManager->create('Magento\Customer\Model\Customer') - ->load($customerId); - - $quoteItemId = (int) $this->getRequest()->getParam('id'); - $websiteId = (int) $this->getRequest()->getParam('website_id'); + $quoteItemId = (int)$this->getRequest()->getParam('id'); + $websiteId = (int)$this->getRequest()->getParam('website_id'); $this->_quote = $this->_objectManager->create('Magento\Sales\Model\Quote') ->setWebsite($this->_objectManager->get('Magento\Core\Model\StoreManagerInterface')->getWebsite($websiteId)) - ->loadByCustomer($this->_customer); + ->loadByCustomer($this->_customerId); $this->_quoteItem = $this->_quote->getItemById($quoteItemId); if (!$this->_quoteItem) { @@ -89,7 +87,7 @@ class Cart extends \Magento\Backend\App\Action /** * Ajax handler to response configuration fieldset of composite product in customer's cart * - * @return \Magento\Customer\Controller\Adminhtml\Cart\Product\Composite\Cart + * @return void */ public function configureAction() { @@ -108,7 +106,7 @@ class Cart extends \Magento\Backend\App\Action $configureResult->setProductId($quoteItem->getProductId()); $configureResult->setBuyRequest($quoteItem->getBuyRequest()); $configureResult->setCurrentStoreId($quoteItem->getStoreId()); - $configureResult->setCurrentCustomer($this->_customer); + $configureResult->setCustomerId($this->_customerId); } catch (\Exception $e) { $configureResult->setError(true); $configureResult->setMessage($e->getMessage()); @@ -121,7 +119,7 @@ class Cart extends \Magento\Backend\App\Action /** * IFrame handler for submitted configuration for quote item * - * @return \Magento\Customer\Controller\Adminhtml\Cart\Product\Composite\Cart + * @return void */ public function updateAction() { diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Group.php b/app/code/Magento/Customer/Controller/Adminhtml/Group.php index a863a573415..5c107c5ddc1 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Group.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Group.php @@ -18,15 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Customer\Controller\Adminhtml; +use Magento\Customer\Controller\RegistryConstants; use Magento\Exception\NoSuchEntityException; +use Magento\Customer\Service\V1\CustomerGroupServiceInterface; +use Magento\Customer\Service\V1\Dto\CustomerGroup; +use Magento\Customer\Service\V1\Dto\CustomerGroupBuilder; /** * Customer groups controller @@ -41,26 +42,28 @@ class Group extends \Magento\Backend\App\Action protected $_coreRegistry; /** - * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface + * @var CustomerGroupServiceInterface */ protected $_groupService; /** - * @var \Magento\Customer\Service\V1\Dto\CustomerGroupBuilder + * @var CustomerGroupBuilder */ protected $_customerGroupBuilder; /** + * Initialize Group Controller + * * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Registry $coreRegistry - * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService - * @param \Magento\Customer\Service\V1\Dto\CustomerGroupBuilder $customerGroupBuilder + * @param CustomerGroupServiceInterface $groupService + * @param CustomerGroupBuilder $customerGroupBuilder */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Registry $coreRegistry, - \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService, - \Magento\Customer\Service\V1\Dto\CustomerGroupBuilder $customerGroupBuilder + CustomerGroupServiceInterface $groupService, + CustomerGroupBuilder $customerGroupBuilder ) { $this->_coreRegistry = $coreRegistry; $this->_groupService = $groupService; @@ -68,22 +71,25 @@ class Group extends \Magento\Backend\App\Action parent::__construct($context); } + /** + * Initialize current group and set it in the registry. + * + * @return int + */ protected function _initGroup() { $this->_title->add(__('Customer Groups')); - $currentGroup = null; $groupId = $this->getRequest()->getParam('id'); - if (!is_null($groupId)) { - $currentGroup = $this->_groupService->getGroup($groupId); - } else { - $currentGroup = $this->_customerGroupBuilder->create(); - } - $this->_coreRegistry->register('current_group', $currentGroup); + $this->_coreRegistry->register(RegistryConstants::CURRENT_GROUP_ID, $groupId); + + return $groupId; } /** * Customer groups list. + * + * @return void */ public function indexAction() { @@ -98,34 +104,37 @@ class Group extends \Magento\Backend\App\Action /** * Edit or create customer group. + * + * @return void */ public function newAction() { - $this->_initGroup(); + $groupId = $this->_initGroup(); + $this->_view->loadLayout(); $this->_setActiveMenu('Magento_Customer::customer_group'); $this->_addBreadcrumb(__('Customers'), __('Customers')); $this->_addBreadcrumb(__('Customer Groups'), __('Customer Groups'), $this->getUrl('customer/group')); - /** @var \Magento\Customer\Service\V1\Dto\CustomerGroup $currentGroup */ - $currentGroup = $this->_coreRegistry->registry('current_group'); - - if (!is_null($currentGroup->getId())) { - $this->_addBreadcrumb(__('Edit Group'), __('Edit Customer Groups')); - } else { + if (is_null($groupId)) { $this->_addBreadcrumb(__('New Group'), __('New Customer Groups')); + $this->_title->add(__('New Customer Group')); + } else { + $this->_addBreadcrumb(__('Edit Group'), __('Edit Customer Groups')); + $this->_title->add($this->_groupService->getGroup($groupId)->getCode()); } - $this->_title->add($currentGroup->getId() ? $currentGroup->getCode() : __('New Customer Group')); - - $this->_view->getLayout()->addBlock('Magento\Customer\Block\Adminhtml\Group\Edit', 'group', 'content') - ->setEditMode((bool)$this->_coreRegistry->registry('current_group')->getId()); + $this->_view->getLayout() + ->addBlock('Magento\Customer\Block\Adminhtml\Group\Edit', 'group', 'content') + ->setEditMode((bool)$groupId); $this->_view->renderLayout(); } /** * Edit customer group action. Forward to new action. + * + * @return void */ public function editAction() { @@ -134,11 +143,14 @@ class Group extends \Magento\Backend\App\Action /** * Create or save customer group. + * + * @return void */ public function saveAction() { $taxClass = (int)$this->getRequest()->getParam('tax_class'); + /** @var CustomerGroup $customerGroup */ $customerGroup = null; if ($taxClass) { $id = $this->getRequest()->getParam('id'); @@ -154,17 +166,16 @@ class Group extends \Magento\Backend\App\Action $this->_customerGroupBuilder->setTaxClassId($taxClass); $customerGroup = $this->_customerGroupBuilder->create(); - $this->_groupService->saveGroup($customerGroup); + $id = $this->_groupService->saveGroup($customerGroup); $this->messageManager->addSuccess(__('The customer group has been saved.')); $this->getResponse()->setRedirect($this->getUrl('customer/group')); return; } catch (\Exception $e) { $this->messageManager->addError($e->getMessage()); if ($customerGroup != null) { - $this->_objectManager->get('Magento\Session\SessionManagerInterface') - ->setCustomerGroupData($customerGroup->getData()); + $this->_coreRegistry->register(RegistryConstants::CURRENT_GROUP_ID, $id); } - $this->getResponse()->setRedirect($this->getUrl('customer/group/edit', array('id' => $id))); + $this->getResponse()->setRedirect($this->getUrl('customer/group/edit', ['id' => $id])); return; } } else { @@ -173,39 +184,37 @@ class Group extends \Magento\Backend\App\Action } /** - * Delete customer group action + * Delete customer group. + * + * @return void */ public function deleteAction() { $id = $this->getRequest()->getParam('id'); if ($id) { - /** @var \Magento\Customer\Model\Group $customerGroup */ - $customerGroup = $this->_objectManager->create('Magento\Customer\Model\Group')->load($id); - if (!$customerGroup->getId()) { - $this->messageManager->addError(__('The customer group no longer exists.')); - $this->_redirect('customer/*/'); - return; - } try { $this->_groupService->deleteGroup($id); $this->messageManager->addSuccess(__('The customer group has been deleted.')); $this->getResponse()->setRedirect($this->getUrl('customer/group')); return; } catch (NoSuchEntityException $e) { - $this->_objectManager->get('Magento\Adminhtml\Model\Session') - ->addError(__('The customer group no longer exists.')); - $this->_redirect('adminhtml/*/'); + $this->messageManager->addError(__('The customer group no longer exists.')); + $this->getResponse()->setRedirect($this->getUrl('customer/*/')); return; } catch (\Exception $e) { $this->messageManager->addError($e->getMessage()); - $this->getResponse()->setRedirect($this->getUrl('customer/group/edit', array('id' => $id))); + $this->getResponse()->setRedirect($this->getUrl('customer/group/edit', ['id' => $id])); return; } } - $this->_redirect('customer/group'); } + /** + * Determine if authorized to perform group actions. + * + * @return bool + */ protected function _isAllowed() { return $this->_authorization->isAllowed('Magento_Customer::group'); diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index.php b/app/code/Magento/Customer/Controller/Adminhtml/Index.php old mode 100644 new mode 100755 index 8a937768c28..83060386623 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index.php @@ -26,7 +26,21 @@ namespace Magento\Customer\Controller\Adminhtml; use Magento\App\Action\NotFoundException; +use Magento\Customer\Controller\RegistryConstants; +use Magento\Customer\Service\V1\Dto\Customer; +use Magento\Customer\Service\V1\Dto\CustomerBuilder; +use Magento\Customer\Service\V1\Dto\AddressBuilder; +use Magento\Customer\Service\V1\CustomerServiceInterface; +use Magento\Customer\Service\V1\CustomerAccountServiceInterface; +use Magento\Customer\Service\V1\CustomerAddressServiceInterface; +use Magento\Exception\NoSuchEntityException; +/** + * Class Index + * + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Index extends \Magento\Backend\App\Action { /** @@ -51,26 +65,43 @@ class Index extends \Magento\Backend\App\Action */ protected $_customerFactory = null; + /** @var CustomerBuilder */ + protected $_customerBuilder; + + /** @var AddressBuilder */ + protected $_addressBuilder; /** * @var \Magento\Customer\Model\AddressFactory */ protected $_addressFactory = null; + /** @var \Magento\Newsletter\Model\SubscriberFactory */ + protected $_subscriberFactory; + /** * @var \Magento\Customer\Helper\Data */ protected $_dataHelper = null; /** - * Registry key where current customer DTO stored - * @todo switch to use ID instead and remove after refactoring of all occurrences + * @var \Magento\Customer\Model\Metadata\FormFactory */ - const REGISTRY_CURRENT_CUSTOMER = 'current_customer'; + protected $_formFactory; - /** - * Registry key where current customer ID is stored - */ - const REGISTRY_CURRENT_CUSTOMER_ID = 'current_customer_id'; + /** @var CustomerServiceInterface */ + protected $_customerService; + + /** @var CustomerAddressServiceInterface */ + protected $_addressService; + + /** @var CustomerAccountServiceInterface */ + protected $_accountService; + + /** @var \Magento\Customer\Helper\View */ + protected $_viewHelper; + + /** @var \Magento\Math\Random */ + protected $_random; /** * @param \Magento\Backend\App\Action\Context $context @@ -78,7 +109,18 @@ class Index extends \Magento\Backend\App\Action * @param \Magento\App\Response\Http\FileFactory $fileFactory * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Customer\Model\AddressFactory $addressFactory + * @param \Magento\Customer\Model\Metadata\FormFactory $formFactory + * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory + * @param CustomerBuilder $customerBuilder + * @param AddressBuilder $addressBuilder + * @param CustomerServiceInterface $customerService + * @param CustomerAddressServiceInterface $addressService + * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $accountService + * @param \Magento\Customer\Helper\View $viewHelper * @param \Magento\Customer\Helper\Data $helper + * @param \Magento\Math\Random $random + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Backend\App\Action\Context $context, @@ -86,13 +128,31 @@ class Index extends \Magento\Backend\App\Action \Magento\App\Response\Http\FileFactory $fileFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Customer\Model\AddressFactory $addressFactory, - \Magento\Customer\Helper\Data $helper + \Magento\Customer\Model\Metadata\FormFactory $formFactory, + \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, + CustomerBuilder $customerBuilder, + AddressBuilder $addressBuilder, + CustomerServiceInterface $customerService, + CustomerAddressServiceInterface $addressService, + CustomerAccountServiceInterface $accountService, + \Magento\Customer\Helper\View $viewHelper, + \Magento\Customer\Helper\Data $helper, + \Magento\Math\Random $random ) { $this->_fileFactory = $fileFactory; $this->_coreRegistry = $coreRegistry; $this->_customerFactory = $customerFactory; + $this->_customerBuilder = $customerBuilder; + $this->_addressBuilder = $addressBuilder; $this->_addressFactory = $addressFactory; + $this->_subscriberFactory = $subscriberFactory; $this->_dataHelper = $helper; + $this->_formFactory = $formFactory; + $this->_customerService = $customerService; + $this->_addressService = $addressService; + $this->_accountService = $accountService; + $this->_viewHelper = $viewHelper; + $this->_random = $random; parent::__construct($context); } @@ -100,7 +160,7 @@ class Index extends \Magento\Backend\App\Action * Customer initialization * * @param string $idFieldName - * @return \Magento\Customer\Controller\Adminhtml\Index + * @return string customer id */ protected function _initCustomer($idFieldName = 'id') { @@ -113,8 +173,10 @@ class Index extends \Magento\Backend\App\Action $customer->load($customerId); } - $this->_coreRegistry->register(self::REGISTRY_CURRENT_CUSTOMER, $customer); - return $this; + // TODO: Investigate if any piece of code still relies on this; remove if not. + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER, $customer); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customerId); + return $customerId; } /** @@ -162,69 +224,114 @@ class Index extends \Magento\Backend\App\Action /** * Customer edit action + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function editAction() { - $this->_initCustomer(); + $customerId = $this->_initCustomer(); $this->_view->loadLayout(); $this->_setActiveMenu('Magento_Customer::customer_manage'); - /* @var $customer \Magento\Customer\Model\Customer */ - $customer = $this->_coreRegistry->registry(self::REGISTRY_CURRENT_CUSTOMER); + $customerData = []; + $customerData['account'] = []; + $customerData['address'] = []; + $customer = null; + $isExistingCustomer = (bool)$customerId; + if ($isExistingCustomer) { + try { + $customer = $this->_customerService->getCustomer($customerId); + $customerData['account'] = $customer->getAttributes(); + $customerData['account']['id'] = $customerId; + try { + $addresses = $this->_addressService->getAddresses($customerId); + foreach ($addresses as $address) { + $customerData['address'][$address->getId()] = $address->getAttributes(); + $customerData['address'][$address->getId()]['id'] = $address->getId(); + } + } catch (NoSuchEntityException $e) { + //do nothing + } + } catch (NoSuchEntityException $e) { + $this->messageManager->addException($e, __('An error occurred while editing the customer.')); + $this->_redirect('customer/*/index'); + return; + } + } + $customerData['customer_id'] = $customerId; // set entered data if was error when we do save - $data = $this->_objectManager->get('Magento\Backend\Model\Session')->getCustomerData(true); + $data = $this->_getSession()->getCustomerData(true); // restore data from SESSION - if ($data) { + if ($data && ( + !isset($data['customer_id']) || + (isset($data['customer_id']) && $data['customer_id'] == $customerId) + ) + ) { $request = clone $this->getRequest(); $request->setParams($data); - if (isset($data['account'])) { - /* @var $customerForm \Magento\Customer\Model\Form */ - $customerForm = $this->_objectManager->create('Magento\Customer\Model\Form'); - $customerForm->setEntity($customer) - ->setFormCode('adminhtml_customer') - ->setIsAjaxRequest(true); + if (isset($data['account']) && is_array($data['account'])) { + $customerForm = $this->_formFactory->create( + 'customer', + 'adminhtml_customer', + $customerData['account'], + true + ); $formData = $customerForm->extractData($request, 'account'); - $customerForm->restoreData($formData); + $customerData['account'] = $customerForm->restoreData($formData); + $customer = $this->_customerBuilder->populateWithArray($customerData['account'])->create(); } if (isset($data['address']) && is_array($data['address'])) { - /* @var $addressForm \Magento\Customer\Model\Form */ - $addressForm = $this->_objectManager->create('Magento\Customer\Model\Form'); - $addressForm->setFormCode('adminhtml_customer_address'); - foreach (array_keys($data['address']) as $addressId) { if ($addressId == '_template_') { continue; } - $address = $customer->getAddressItemById($addressId); - if (!$address) { - $address = $this->_objectManager->create('Magento\Customer\Model\Address'); - $address->setId($addressId); - $customer->addAddress($address); + try { + $address = $this->_addressService->getAddressById($addressId); + if (!empty($customerId) && $address->getCustomerId() == $customerId) { + $this->_addressBuilder->populate($address); + } + } catch (NoSuchEntityException $e) { + $this->_addressBuilder->setId($addressId); } - - $requestScope = sprintf('address/%s', $addressId); - $formData = $addressForm->setEntity($address) - ->extractData($request, $requestScope); - $customer->setDefaultBilling( - !empty($data['account']['default_billing']) - && $data['account']['default_billing'] == $addressId + if (!empty($customerId)) { + $this->_addressBuilder->setCustomerId($customerId); + } + $this->_addressBuilder->setDefaultBilling( + !empty($data['account'][Customer::DEFAULT_BILLING]) + && $data['account'][Customer::DEFAULT_BILLING] == $addressId + ); + $this->_addressBuilder->setDefaultShipping( + !empty($data['account'][Customer::DEFAULT_SHIPPING]) + && $data['account'][Customer::DEFAULT_SHIPPING] == $addressId ); - $customer->setDefaultShipping( - !empty($data['account']['default_shipping']) - && $data['account']['default_shipping'] == $addressId + $address = $this->_addressBuilder->create(); + $requestScope = sprintf('address/%s', $addressId); + $addressForm = $this->_formFactory->create( + 'customer_address', + 'adminhtml_customer_address', + $address->getAttributes() ); - $addressForm->restoreData($formData); + $formData = $addressForm->extractData($request, $requestScope); + $customerData['address'][$addressId] = $addressForm->restoreData($formData); + $customerData['address'][$addressId]['id'] = $addressId; } } } - $this->_title->add($customer->getId() ? $customer->getName() : __('New Customer')); + $this->_getSession()->setCustomerData($customerData); + if ($isExistingCustomer) { + $this->_title->add($this->_viewHelper->getCustomerName($customer)); + } else { + $this->_title->add(__('New Customer')); + } /** * Set active menu item */ @@ -247,10 +354,10 @@ class Index extends \Magento\Backend\App\Action public function deleteAction() { $this->_initCustomer(); - $customer = $this->_coreRegistry->registry(self::REGISTRY_CURRENT_CUSTOMER); - if ($customer->getId()) { + $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + if (!empty($customerId)) { try { - $customer->delete(); + $this->_customerService->deleteCustomer($customerId); $this->messageManager->addSuccess( __('You deleted the customer.')); } catch (\Exception $exception){ @@ -262,6 +369,10 @@ class Index extends \Magento\Backend\App\Action /** * Save customer action + * + * @return void + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function saveAction() { @@ -276,49 +387,52 @@ class Index extends \Magento\Backend\App\Action $request = $this->getRequest(); $isExistingCustomer = (bool)$customerId; - /** @var \Magento\Customer\Model\Customer $customer */ - $customer = null; + $customerBuilder = $this->_customerBuilder; if ($isExistingCustomer) { - // load the customer from the db - $customer = $this->_loadCustomerById($customerId); - } else { - // create a new customer - $customer = $this->_customerFactory->create(); - // Need to set proper attribute id or future updates will cause data loss. - $customer->setData('attribute_set_id', 1); - $this->_preparePasswordForSave($customer, $customerData); + $savedCustomerData = $this->_customerService->getCustomer($customerId)->__toArray(); + $customerData = array_merge($savedCustomerData, $customerData); } + unset($customerData[Customer::DEFAULT_BILLING]); + unset($customerData[Customer::DEFAULT_SHIPPING]); + $customerBuilder->populateWithArray($customerData); - // Before save - foreach ($customerData as $property => $value) { - $customer->setDataUsingMethod($property, $value); + $addresses = []; + foreach ($addressesData as $addressData) { + $addresses[] = $this->_addressBuilder->populateWithArray($addressData)->create(); } - $this->_prepareCustomerAddressesForSave($customer, $addressesData); + $this->_eventManager->dispatch('adminhtml_customer_prepare_save', array( - 'customer' => $customer, - 'request' => $request - )); + 'customer' => $customerBuilder, + 'request' => $request + ) + ); + $customer = $customerBuilder->create(); // Save customer - $customer->save(); + if ($isExistingCustomer) { + $this->_accountService->updateAccount($customer, $addresses); + } else { + $customer = $this->_accountService->createAccount($customer, $addresses); + } + + if ($customerData['is_subscribed']) { + $this->_subscriberFactory->create()->updateSubscription($customerId, true); + } // After save $this->_eventManager->dispatch('adminhtml_customer_save_after', array( - 'customer' => $customer, - 'request' => $request - )); - $this->_sendWelcomeEmail($customer, $customerData); - if ($isExistingCustomer) { - $this->_changePassword($customer, $customerData); - } + 'customer' => $customer, + 'request' => $request + ) + ); // Done Saving customer, finish save action - $this->_objectManager->get('Magento\Registry') - ->register(self::REGISTRY_CURRENT_CUSTOMER, $customer); + $customerId = $customer->getCustomerId(); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customerId); + $this->messageManager->addSuccess(__('You saved the customer.')); $returnToEdit = (bool)$this->getRequest()->getParam('back', false); - $customerId = $customer->getId(); } catch (\Magento\Validator\ValidatorException $exception) { $this->_addSessionErrorMessages($exception->getMessages()); $this->_getSession()->setCustomerData($originalRequestData); @@ -331,6 +445,10 @@ class Index extends \Magento\Backend\App\Action $this->_addSessionErrorMessages($messages); $this->_getSession()->setCustomerData($originalRequestData); $returnToEdit = true; + } catch (\Magento\Exception\Exception $exception) { + $this->_addSessionErrorMessages($exception->getMessage()); + $this->_getSession()->setCustomerData($originalRequestData); + $returnToEdit = true; } catch (\Exception $exception) { $this->messageManager->addException($exception, __('An error occurred while saving the customer.')); @@ -350,163 +468,6 @@ class Index extends \Magento\Backend\App\Action } } - /** - * Load customer by its ID - * - * @param int|string $customerId - * @return \Magento\Customer\Model\Customer - * @throws \Magento\Core\Exception - */ - private function _loadCustomerById($customerId) - { - $customer = $this->_customerFactory->create(); - $customer->load($customerId); - if (!$customer->getId()) { - throw new \Magento\Core\Exception(__("The customer with the specified ID not found.")); - } - - return $customer; - } - - /** - * Save customer addresses. - * - * @param \Magento\Customer\Model\Customer $customer - * @param array $addressesData - * @throws \Magento\Core\Exception - */ - private function _prepareCustomerAddressesForSave($customer, array $addressesData) - { - $hasChanges = $customer->hasDataChanges(); - $actualAddressesIds = array(); - foreach ($addressesData as $addressData) { - $addressId = null; - if (array_key_exists('entity_id', $addressData)) { - $addressId = $addressData['entity_id']; - unset($addressData['entity_id']); - } - - if (null !== $addressId) { - $address = $customer->getAddressItemById($addressId); - if (!$address || !$address->getId()) { - throw new \Magento\Core\Exception( - __('The address with the specified ID not found.') - ); - } - } else { - $address = $this->_addressFactory->create(); - $address->setCustomerId($customer->getId()); - // Add customer address into addresses collection - $customer->addAddress($address); - } - $address->addData($addressData); - $hasChanges = $hasChanges || $address->hasDataChanges(); - - // Set post_index for detect default billing and shipping addresses - $address->setPostIndex($addressId); - - $actualAddressesIds[] = $address->getId(); - } - - /** @var \Magento\Customer\Model\Address $address */ - foreach ($customer->getAddressesCollection() as $address) { - if (!in_array($address->getId(), $actualAddressesIds)) { - $address->setData('_deleted', true); - $hasChanges = true; - } - } - $customer->setDataChanges($hasChanges); - } - - /** - * Send welcome email to customer - * - * @param \Magento\Customer\Model\Customer $customer - * @param array $customerData - */ - private function _sendWelcomeEmail($customer, array $customerData) - { - $isSendEmail = !empty($customerData['sendemail']); - - if ($customer->getWebsiteId() - && ($isSendEmail || $this->_isAutogeneratePassword($customerData)) - ) { - $isNewCustomer = !(bool)$customer->getOrigData($customer->getIdFieldName()); - $storeId = $customer->getSendemailStoreId(); - - if ($isNewCustomer) { - $newLinkToken = $this->_dataHelper->generateResetPasswordLinkToken(); - $customer->changeResetPasswordLinkToken($newLinkToken); - $customer->sendNewAccountEmail('registered', '', $storeId); - } elseif (!$customer->getConfirmation()) { - // Confirm not confirmed customer - $customer->sendNewAccountEmail('confirmed', '', $storeId); - } - } - } - - /** - * Check if password should be generated automatically - * - * @param array $customerData - * @return bool - */ - private function _isAutogeneratePassword(array $customerData) - { - return !empty($customerData['autogenerate_password']); - } - - /** - * Change customer password - * - * @param \Magento\Customer\Model\Customer $customer - * @param array $customerData - */ - private function _changePassword($customer, array $customerData) - { - if (!empty($customerData['password']) || $this->_isAutogeneratePassword($customerData)) { - $newPassword = $this->_getCustomerPassword($customer, $customerData); - $customer->changePassword($newPassword); - $customer->sendPasswordReminderEmail(); - } - } - - /** - * Get customer password - * - * @param \Magento\Customer\Model\Customer $customer - * @param array $customerData - * @return string|null - */ - private function _getCustomerPassword($customer, array $customerData) - { - $password = null; - - if ($this->_isAutogeneratePassword($customerData)) { - $password = $customer->generatePassword(); - } elseif (isset($customerData['password'])) { - $password = $customerData['password']; - } - - return $password; - } - - /** - * Set customer password - * - * @param \Magento\Customer\Model\Customer $customer - * @param array $customerData - */ - private function _preparePasswordForSave($customer, array $customerData) - { - $password = $this->_getCustomerPassword($customer, $customerData); - if (!is_null($password)) { - // 'force_confirmed' should be set in admin area only - $customer->setForceConfirmed(true); - $customer->setPassword($password); - } - } - /** * Reset password handler */ @@ -517,26 +478,16 @@ class Index extends \Magento\Backend\App\Action return $this->_redirect('customer/index'); } - /** @var \Magento\Customer\Model\Customer $customer */ - $customer = $this->_objectManager->create('Magento\Customer\Model\Customer'); - $customer->load($customerId); - if (!$customer->getId()) { - return $this->_redirect('customer/index'); - } - try { - $newPasswordToken = $this->_objectManager->get('Magento\Customer\Helper\Data') - ->generateResetPasswordLinkToken(); - $customer->changeResetPasswordLinkToken($newPasswordToken); - $resetUrl = $this->_objectManager->create('Magento\UrlInterface') - ->getUrl('customer/account/createPassword', array( - '_query' => array('id' => $customer->getId(), 'token' => $newPasswordToken), - '_store' => $customer->getStoreId() - ) - ); - $customer->setResetPasswordUrl($resetUrl); - $customer->sendPasswordReminderEmail(); + $customer = $this->_customerService->getCustomer($customerId); + $this->_accountService->sendPasswordResetLink( + $customer->getEmail(), + $customer->getWebsiteId(), + CustomerAccountServiceInterface::EMAIL_REMINDER + ); $this->messageManager->addSuccess(__('Customer will receive an email with a link to reset password.')); + } catch (NoSuchEntityException $exception) { + return $this->_redirect('customer/index'); } catch (\Magento\Core\Exception $exception) { $messages = $exception->getMessages(\Magento\Message\MessageInterface::TYPE_ERROR); if (!count($messages)) { @@ -544,8 +495,10 @@ class Index extends \Magento\Backend\App\Action } $this->_addSessionErrorMessages($messages); } catch (\Exception $exception) { - $this->messageManager->addException($exception, - __('An error occurred while resetting customer password.')); + $this->messageManager->addException( + $exception, + __('An error occurred while resetting customer password.') + ); } $this->_redirect('customer/*/edit', array('id' => $customerId, '_current' => true)); @@ -555,6 +508,9 @@ class Index extends \Magento\Backend\App\Action * Add errors messages to session. * * @param array|string $messages + * @return void + * + * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ protected function _addSessionErrorMessages($messages) { @@ -577,10 +533,9 @@ class Index extends \Magento\Backend\App\Action */ protected function _extractCustomerData() { - $customerData = array(); + $customerData = []; if ($this->getRequest()->getPost('account')) { - $serviceAttributes = array( - 'new_password', 'default_billing', 'default_shipping', 'confirmation', 'sendemail'); + $serviceAttributes = [Customer::DEFAULT_BILLING, Customer::DEFAULT_SHIPPING, 'confirmation', 'sendemail']; /** @var \Magento\Customer\Model\Customer $customerEntity */ $customerEntity = $this->_objectManager->get('Magento\Customer\Model\CustomerFactory')->create(); @@ -591,10 +546,6 @@ class Index extends \Magento\Backend\App\Action ); } - if (!$this->getRequest()->getPost('customer_id')) { - $customerData['new_password'] = 'auto'; - } - $this->_processCustomerPassword($customerData); if ($this->_authorization->isAllowed(null)) { $customerData['is_subscribed'] = $this->getRequest()->getPost('subscription') !== null; } @@ -634,15 +585,15 @@ class Index extends \Magento\Backend\App\Action $addressData = $customerHelper->extractCustomerData( $this->getRequest(), 'adminhtml_customer_address', $addressEntity, array(), $scope, $eavForm); if (is_numeric($addressId)) { - $addressData['entity_id'] = $addressId; + $addressData['id'] = $addressId; } // Set default billing and shipping flags to address - $addressData['is_default_billing'] = isset($customerData['default_billing']) - && $customerData['default_billing'] - && $customerData['default_billing'] == $addressId; - $addressData['is_default_shipping'] = isset($customerData['default_shipping']) - && $customerData['default_shipping'] - && $customerData['default_shipping'] == $addressId; + $addressData[Customer::DEFAULT_BILLING] = isset($customerData[Customer::DEFAULT_BILLING]) + && $customerData[Customer::DEFAULT_BILLING] + && $customerData[Customer::DEFAULT_BILLING] == $addressId; + $addressData[Customer::DEFAULT_SHIPPING] = isset($customerData[Customer::DEFAULT_SHIPPING]) + && $customerData[Customer::DEFAULT_SHIPPING] + && $customerData[Customer::DEFAULT_SHIPPING] == $addressId; $result[] = $addressData; } @@ -651,26 +602,10 @@ class Index extends \Magento\Backend\App\Action return $result; } - /** - * Generate password if auto generated password was requested - * - * @param array $customerData - * @throws \Magento\Core\Exception - */ - protected function _processCustomerPassword(&$customerData) - { - if (!empty($customerData['new_password'])) { - if ($customerData['new_password'] == 'auto') { - $customerData['autogenerate_password'] = true; - } else { - $customerData['password'] = $customerData['new_password']; - } - } - unset($customerData['new_password']); - } - /** * Export customer grid to CSV format + * + * @return \Magento\App\ResponseInterface */ public function exportCsvAction() { @@ -682,6 +617,8 @@ class Index extends \Magento\Backend\App\Action /** * Export customer grid to XML format + * + * @return \Magento\App\ResponseInterface */ public function exportXmlAction() { @@ -716,19 +653,23 @@ class Index extends \Magento\Backend\App\Action public function newsletterAction() { $this->_initCustomer(); + $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); $subscriber = $this->_objectManager->create('Magento\Newsletter\Model\Subscriber') - ->loadByCustomer($this->_coreRegistry->registry(self::REGISTRY_CURRENT_CUSTOMER)); + ->loadByCustomer($customerId); $this->_coreRegistry->register('subscriber', $subscriber); $this->_view->loadLayout()->renderLayout(); } + /** + * Wishlist Action + */ public function wishlistAction() { $this->_initCustomer(); - $customer = $this->_coreRegistry->registry(self::REGISTRY_CURRENT_CUSTOMER); + $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); $itemId = (int)$this->getRequest()->getParam('delete'); - if ($customer->getId() && $itemId) { + if ($customerId && $itemId) { try { $this->_objectManager->create('Magento\Wishlist\Model\Item')->load($itemId) ->delete(); @@ -755,7 +696,7 @@ class Index extends \Magento\Backend\App\Action } /** - * [Handle and then] get a cart grid contents + * Handle and then get cart grid contents * * @return string */ @@ -771,7 +712,7 @@ class Index extends \Magento\Backend\App\Action ->setWebsite( $this->_objectManager->get('Magento\Core\Model\StoreManagerInterface')->getWebsite($websiteId) ) - ->loadByCustomer($this->_coreRegistry->registry(self::REGISTRY_CURRENT_CUSTOMER)); + ->loadByCustomer($this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID)); $item = $quote->getItemById($deleteItemId); if ($item && $item->getId()) { $quote->removeItem($deleteItemId); @@ -817,7 +758,7 @@ class Index extends \Magento\Backend\App\Action $this->_initCustomer(); $this->_view->loadLayout(); $this->_view->getLayout()->getBlock('admin.customer.reviews') - ->setCustomerId($this->_coreRegistry->registry(self::REGISTRY_CURRENT_CUSTOMER)->getId()) + ->setCustomerId($this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID)) ->setUseAjax(true); $this->_view->renderLayout(); } @@ -832,7 +773,7 @@ class Index extends \Magento\Backend\App\Action $customer = $this->_validateCustomer($response); if ($customer) { - $this->_validateCustomerAddress($response, $customer); + $this->_validateCustomerAddress($response); } if ($response->getError()) { @@ -847,7 +788,7 @@ class Index extends \Magento\Backend\App\Action * Customer validation * * @param \Magento\Object $response - * @return \Magento\Customer\Model\Customer|null + * @return Customer|null */ protected function _validateCustomer($response) { @@ -855,33 +796,25 @@ class Index extends \Magento\Backend\App\Action $errors = null; try { - /** @var \Magento\Customer\Model\Customer $customer */ - $customer = $this->_objectManager->create('Magento\Customer\Model\Customer'); - $customerId = $this->getRequest()->getParam('id'); - if ($customerId) { - $customer->load($customerId); - } + /** @var Customer $customer */ + $customer = $this->_customerBuilder->create(); + + $customerForm = $this->_formFactory->create( + 'customer', + 'adminhtml_customer', + $customer->getAttributes(), + true + ); + $customerForm->setInvisibleIgnored(true); - /* @var $customerForm \Magento\Customer\Model\Form */ - $customerForm = $this->_objectManager->get('Magento\Customer\Model\Form'); - $customerForm->setEntity($customer) - ->setFormCode('adminhtml_customer') - ->setIsAjaxRequest(true) - ->ignoreInvisible(false); $data = $customerForm->extractData($this->getRequest(), 'account'); - $accountData = $this->getRequest()->getPost('account'); - $data['password'] = isset($accountData['password']) ? $accountData['password'] : ''; - if (!$customer->getId()) { - $data['password'] = $customer->generatePassword(); - } - $data['confirmation'] = $data['password']; if ($customer->getWebsiteId()) { unset($data['website_id']); } - $customer->addData($data); - $errors = $customer->validate(); + $customer = $this->_customerBuilder->populateWithArray($data)->create(); + $errors = $this->_accountService->validateCustomerData($customer, []); } catch (\Magento\Core\Exception $exception) { /* @var $error \Magento\Message\Error */ foreach ($exception->getMessages(\Magento\Message\MessageInterface::TYPE_ERROR) as $error) { @@ -903,27 +836,23 @@ class Index extends \Magento\Backend\App\Action * Customer address validation. * * @param \Magento\Object $response - * @param \Magento\Customer\Model\Customer $customer */ - protected function _validateCustomerAddress($response, $customer) + protected function _validateCustomerAddress($response) { $addressesData = $this->getRequest()->getParam('address'); if (is_array($addressesData)) { - /* @var $addressForm \Magento\Customer\Model\Form */ - $addressForm = $this->_objectManager->create('Magento\Customer\Model\Form'); - $addressForm->setFormCode('adminhtml_customer_address')->ignoreInvisible(false); foreach (array_keys($addressesData) as $index) { if ($index == '_template_') { continue; } - $address = $customer->getAddressItemById($index); - if (!$address) { - $address = $this->_objectManager->create('Magento\Customer\Model\Address'); - } + + $addressForm = $this->_formFactory->create( + 'customer_address', + 'adminhtml_customer_address' + ); $requestScope = sprintf('address/%s', $index); - $formData = $addressForm->setEntity($address) - ->extractData($this->getRequest(), $requestScope); + $formData = $addressForm->extractData($this->getRequest(), $requestScope); $errors = $addressForm->validateData($formData); if ($errors !== true) { @@ -938,104 +867,124 @@ class Index extends \Magento\Backend\App\Action /** * Customer mass subscribe action + * + * @return void */ public function massSubscribeAction() { - $customersIds = $this->getRequest()->getParam('customer'); - if (!is_array($customersIds)) { - $this->messageManager->addError(__('Please select customer(s).')); - } else { - try { - foreach ($customersIds as $customerId) { - $customer = $this->_objectManager->create('Magento\Customer\Model\Customer')->load($customerId); - $customer->setIsSubscribed(true); - $customer->save(); - } - $this->messageManager->addSuccess(__('A total of %1 record(s) were updated.', count($customersIds))); - } catch (\Exception $exception) { - $this->messageManager->addError($exception->getMessage()); - } + $customerIds = $this->getRequest()->getParam('customer'); + $customersUpdated = $this->actUponMultipleCustomers( + function ($customerId) { + // Verify customer exists + $this->_customerService->getCustomer($customerId); + $this->_subscriberFactory->create()->updateSubscription($customerId, true); + }, + $customerIds + ); + if ($customersUpdated) { + $this->messageManager->addSuccess(__('A total of %1 record(s) were updated.', $customersUpdated)); } $this->_redirect('customer/*/index'); } /** * Customer mass unsubscribe action + * + * @return void */ public function massUnsubscribeAction() { - $customersIds = $this->getRequest()->getParam('customer'); - if (!is_array($customersIds)) { - $this->messageManager->addError(__('Please select customer(s).')); - } else { - try { - foreach ($customersIds as $customerId) { - $customer = $this->_objectManager->create('Magento\Customer\Model\Customer')->load($customerId); - $customer->setIsSubscribed(false); - $customer->save(); - } - $this->messageManager->addSuccess(__('A total of %1 record(s) were updated.', count($customersIds))); - } catch (\Exception $exception) { - $this->messageManager->addError($exception->getMessage()); - } + $customerIds = $this->getRequest()->getParam('customer'); + $customersUpdated = $this->actUponMultipleCustomers( + function ($customerId) { + // Verify customer exists + $this->_customerService->getCustomer($customerId); + $this->_subscriberFactory->create()->updateSubscription($customerId, false); + }, + $customerIds + ); + if ($customersUpdated) { + $this->messageManager->addSuccess(__('A total of %1 record(s) were updated.', $customersUpdated)); } - $this->_redirect('customer/*/index'); } /** * Customer mass delete action + * + * @return void */ public function massDeleteAction() { - $customersIds = $this->getRequest()->getParam('customer'); - if (!is_array($customersIds)) { - $this->messageManager->addError(__('Please select customer(s).')); - } else { - try { - $customer = $this->_objectManager->create('Magento\Customer\Model\Customer'); - foreach ($customersIds as $customerId) { - $customer->reset() - ->load($customerId) - ->delete(); - } - $this->messageManager->addSuccess(__('A total of %1 record(s) were deleted.', count($customersIds))); - } catch (\Exception $exception) { - $this->messageManager->addError($exception->getMessage()); - } + $customerIds = $this->getRequest()->getParam('customer'); + $customersDeleted = $this->actUponMultipleCustomers( + function ($customerId) { + $this->_customerService->deleteCustomer($customerId); + }, + $customerIds + ); + if ($customersDeleted) { + $this->messageManager->addSuccess(__('A total of %1 record(s) were deleted.', $customersDeleted)); } - $this->_redirect('customer/*/index'); } /** * Customer mass assign group action + * + * @return void */ public function massAssignGroupAction() { - $customersIds = $this->getRequest()->getParam('customer'); - if (!is_array($customersIds)) { + $customerIds = $this->getRequest()->getParam('customer'); + $customersUpdated = $this->actUponMultipleCustomers( + function ($customerId) { + // Verify customer exists + $customer = $this->_customerService->getCustomer($customerId); + $this->_customerBuilder->populate($customer); + $customer = $this->_customerBuilder + ->setGroupId($this->getRequest()->getParam('group'))->create(); + $this->_customerService->saveCustomer($customer); + }, + $customerIds + ); + if ($customersUpdated) { + $this->messageManager->addSuccess(__('A total of %1 record(s) were updated.', $customersUpdated)); + } + $this->_redirect('customer/*/index'); + } + + /** + * Helper function that handles mass actions by taking in a callable for handling a single customer action. + * + * @param callable $singleAction A single action callable that takes a customer ID as input + * @param int[] $customerIds Array of customer Ids to perform the action upon + * @return int Number of customers successfully acted upon + */ + protected function actUponMultipleCustomers(callable $singleAction, $customerIds) + { + if (!is_array($customerIds)) { $this->messageManager->addError(__('Please select customer(s).')); - } else { + return 0; + } + $customersUpdated = 0; + foreach ($customerIds as $customerId) { try { - foreach ($customersIds as $customerId) { - $customer = $this->_objectManager->create('Magento\Customer\Model\Customer')->load($customerId); - $customer->setGroupId($this->getRequest()->getParam('group')); - $customer->save(); - } - $this->messageManager->addSuccess(__('A total of %1 record(s) were updated.', count($customersIds))); + $singleAction($customerId); + $customersUpdated++; } catch (\Exception $exception) { $this->messageManager->addError($exception->getMessage()); } } - - $this->_redirect('customer/*/index'); + return $customersUpdated; } /** * Customer view file action * * @throws NotFoundException + * + * @SuppressWarnings(PHPMD.ExitExpression) */ public function viewfileAction() { diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist.php b/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist.php index be3699deaf8..1fcbc019c51 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Wishlist/Product/Composite/Wishlist.php @@ -23,37 +23,32 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Controller\Adminhtml\Wishlist\Product\Composite; /** * Catalog composite product configuration controller - * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Customer\Controller\Adminhtml\Wishlist\Product\Composite; - -class Wishlist - extends \Magento\Backend\App\Action +class Wishlist extends \Magento\Backend\App\Action { - /** - * Wishlist we're working with + /** + * Wishlist we're working with. * * @var \Magento\Wishlist\Model\Wishlist */ protected $_wishlist = null; /** - * Wishlist item we're working with + * Wishlist item we're working with. * * @var \Magento\Wishlist\Model\Wishlist */ protected $_wishlistItem = null; /** - * Loads wishlist and wishlist item + * Loads wishlist and wishlist item. * - * @return \Magento\Customer\Controller\Adminhtml\Wishlist\Product\Composite\Wishlist + * @return $this + * @throws \Magento\Core\Exception */ protected function _initData() { @@ -79,9 +74,9 @@ class Wishlist } /** - * Ajax handler to response configuration fieldset of composite product in customer's wishlist + * Ajax handler to response configuration fieldset of composite product in customer's wishlist. * - * @return \Magento\Customer\Controller\Adminhtml\Wishlist\Product\Composite\Wishlist + * @return void */ public function configureAction() { @@ -105,7 +100,7 @@ class Wishlist } /** - * IFrame handler for submitted configuration for wishlist item + * IFrame handler for submitted configuration for wishlist item. * * @return false */ diff --git a/app/code/Magento/Customer/Service/V1/Dto/Response/CreateCustomerAccountResponseBuilder.php b/app/code/Magento/Customer/Controller/RegistryConstants.php similarity index 62% rename from app/code/Magento/Customer/Service/V1/Dto/Response/CreateCustomerAccountResponseBuilder.php rename to app/code/Magento/Customer/Controller/RegistryConstants.php index 4e5236b66f5..fc7d50480be 100644 --- a/app/code/Magento/Customer/Service/V1/Dto/Response/CreateCustomerAccountResponseBuilder.php +++ b/app/code/Magento/Customer/Controller/RegistryConstants.php @@ -1,7 +1,5 @@ <?php /** - * Class CreateCustomerAccountResponse - * * Magento * * NOTICE OF LICENSE @@ -23,25 +21,27 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Customer\Service\V1\Dto\Response; +namespace Magento\Customer\Controller; -class CreateCustomerAccountResponseBuilder extends \Magento\Service\Entity\AbstractDtoBuilder +/** + * Declarations of core registry keys used by the Customer module + * + */ +class RegistryConstants { /** - * @param int $customerId - * @return CreateCustomerAccountResponseBuilder + * Registry key where current customer DTO stored + * @todo switch to use ID instead and remove after refactoring of all occurrences + */ + const CURRENT_CUSTOMER = 'current_customer'; + + /** + * Registry key where current customer ID is stored */ - public function setCustomerId($customerId) - { - return $this->_set('customer_id', $customerId); - } + const CURRENT_CUSTOMER_ID = 'current_customer_id'; /** - * @param string $status - * @return CreateCustomerAccountResponseBuilder + * Registry key where current CustomerGroup ID is stored */ - public function setStatus($status) - { - return $this->_set('status', $status); - } -} + const CURRENT_GROUP_ID = 'current_group_id'; +} \ No newline at end of file diff --git a/app/code/Magento/Customer/Helper/Address.php b/app/code/Magento/Customer/Helper/Address.php old mode 100644 new mode 100755 index 71f4afb9e5b..6ea21f7b483 --- a/app/code/Magento/Customer/Helper/Address.php +++ b/app/code/Magento/Customer/Helper/Address.php @@ -42,6 +42,12 @@ class Address extends \Magento\App\Helper\AbstractHelper const XML_PATH_VIV_TAX_CALCULATION_ADDRESS_TYPE = 'customer/create_account/tax_calculation_address_type'; const XML_PATH_VAT_FRONTEND_VISIBILITY = 'customer/create_account/vat_frontend_visibility'; + /** + * Possible customer address types + */ + const TYPE_BILLING = 'billing'; + const TYPE_SHIPPING = 'shipping'; + /** * Array of Customer Address Attributes * diff --git a/app/code/Magento/Customer/Helper/Data.php b/app/code/Magento/Customer/Helper/Data.php index c0aeaa3a159..fc4b7bc84de 100644 --- a/app/code/Magento/Customer/Helper/Data.php +++ b/app/code/Magento/Customer/Helper/Data.php @@ -716,7 +716,7 @@ class Data extends \Magento\App\Helper\AbstractHelper $message .= $willChargeTaxMessage; } } else { - $contactUsMessage = sprintf(__('If you believe this is an error, please contact us at %s'), + $contactUsMessage = __('If you believe this is an error, please contact us at %1', $this->_coreStoreConfig->getConfig(self::XML_PATH_SUPPORT_EMAIL)); $message = __('Your Tax ID cannot be validated.') . ' ' diff --git a/app/code/Magento/Customer/Model/Attribute/Data/Postcode.php b/app/code/Magento/Customer/Model/Attribute/Data/Postcode.php index 7b111e71353..84b572c053d 100644 --- a/app/code/Magento/Customer/Model/Attribute/Data/Postcode.php +++ b/app/code/Magento/Customer/Model/Attribute/Data/Postcode.php @@ -52,19 +52,21 @@ class Postcode extends \Magento\Eav\Model\Attribute\Data\Text protected $_directoryData = null; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Logger $logger + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Stdlib\String $stringHelper * @param \Magento\Directory\Helper\Data $directoryData */ public function __construct( - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Logger $logger, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Stdlib\String $stringHelper, \Magento\Directory\Helper\Data $directoryData ) { $this->_directoryData = $directoryData; - parent::__construct($locale, $logger, $stringHelper); + parent::__construct($localeDate, $logger, $localeResolver, $stringHelper); } public function validateValue($value) @@ -76,4 +78,4 @@ class Postcode extends \Magento\Eav\Model\Attribute\Data\Text } return true; } -} \ No newline at end of file +} diff --git a/app/code/Magento/Customer/Model/Config/Share.php b/app/code/Magento/Customer/Model/Config/Share.php index 8afa2d37314..af2b56f1e5e 100644 --- a/app/code/Magento/Customer/Model/Config/Share.php +++ b/app/code/Magento/Customer/Model/Config/Share.php @@ -143,4 +143,23 @@ class Share extends \Magento\Core\Model\Config\Value } return $this; } + + /** + * Returns shared website Ids. + * + * @param int $websiteId the ID to use if website scope is on + * @return int[] + */ + public function getSharedWebsiteIds($websiteId) + { + $ids = []; + if ($this->isWebsiteScope()) { + $ids[] = $websiteId; + } else { + foreach ($this->_storeManager->getWebsites() as $website) { + $ids[] = $website->getId(); + } + } + return $ids; + } } diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index 734c868614d..0092655a9a9 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -499,13 +499,13 @@ class Customer extends \Magento\Core\Model\AbstractModel /** * Hash customer password * - * @param string $password - * @param int $salt - * @return string + * @param string $password + * @param bool|int|string $salt + * @return string */ - public function hashPassword($password, $salt = null) + public function hashPassword($password, $salt = true) { - return $this->_encryptor->getHash($password, !is_null($salt) ? $salt : 2); + return $this->_encryptor->getHash($password, $salt); } /** diff --git a/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php b/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php new file mode 100644 index 00000000000..fdf5f17b878 --- /dev/null +++ b/app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php @@ -0,0 +1,135 @@ +<?php +/** + * Depersonalize customer session data + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Customer + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model\Layout; + +/** + * Class DepersonalizePlugin + */ +class DepersonalizePlugin +{ + /** + * @var \Magento\View\LayoutInterface + */ + protected $layout; + + /** + * @var \Magento\Session\SessionManagerInterface + */ + protected $session; + + /** + * @var \Magento\Customer\Model\Session + */ + protected $customerSession; + + /** + * @var \Magento\Customer\Model\Customer + */ + protected $customer; + + /** + * @var \Magento\Event\Manager + */ + protected $eventManager; + + /** + * @var \Magento\App\RequestInterface + */ + protected $request; + + /** + * @var \Magento\Module\Manager + */ + protected $moduleManager; + + /** + * @var int + */ + protected $customerGroupId; + + /** + * @var string + */ + protected $formKey; + + /** + * @param \Magento\View\LayoutInterface $layout + * @param \Magento\Session\SessionManagerInterface $session + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Customer\Model\CustomerFactory $customerFactory + * @param \Magento\Event\Manager $eventManager + * @param \Magento\App\RequestInterface $request + * @param \Magento\Module\Manager $moduleManager + */ + public function __construct( + \Magento\View\LayoutInterface $layout, + \Magento\Session\SessionManagerInterface $session, + \Magento\Customer\Model\Session $customerSession, + \Magento\Customer\Model\CustomerFactory $customerFactory, + \Magento\Event\Manager $eventManager, + \Magento\App\RequestInterface $request, + \Magento\Module\Manager $moduleManager + ) { + $this->layout = $layout; + $this->session = $session; + $this->customerSession = $customerSession; + $this->customer = $customerFactory->create(); + $this->eventManager = $eventManager; + $this->request = $request; + $this->moduleManager = $moduleManager; + + } + + /** + * After layout generate + * + * @param \Magento\Core\Model\Layout $subject + * @param $result + * @return mixed + */ + public function afterGenerateXml(\Magento\Core\Model\Layout $subject, $result) + { + if ($this->moduleManager->isEnabled('Magento_PageCache') + && !$this->request->isAjax() + && $this->layout->isCacheable() + ) { + $this->customerGroupId = $this->customerSession->getCustomerGroupId(); + $this->formKey = $this->session->getData(\Magento\Data\Form\FormKey::FORM_KEY); + $this->eventManager->dispatch('before_session_write_close'); + session_write_close(); + $this->session->clearStorage(); + $this->customerSession->clearStorage(); + $this->session->setData(\Magento\Data\Form\FormKey::FORM_KEY, $this->formKey); + $this->customerSession->setCustomerGroupId($this->customerGroupId); + $this->customer->setGroupId($this->customerGroupId); + $this->customerSession->setCustomer($this->customer); + } + return $result; + } +} diff --git a/app/code/Magento/Customer/Model/Metadata/ElementFactory.php b/app/code/Magento/Customer/Model/Metadata/ElementFactory.php index 77104698082..f69ff601004 100644 --- a/app/code/Magento/Customer/Model/Metadata/ElementFactory.php +++ b/app/code/Magento/Customer/Model/Metadata/ElementFactory.php @@ -61,8 +61,8 @@ class ElementFactory * Create Form Element * * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute - * @param $value - * @param $entityTypeCode + * @param string|int|bool $value + * @param string $entityTypeCode * @param bool $isAjax * @return \Magento\Customer\Model\Metadata\Form\AbstractData */ diff --git a/app/code/Magento/Customer/Model/Metadata/Form.php b/app/code/Magento/Customer/Model/Metadata/Form.php index a90aac16238..09ff8e2bb31 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form.php +++ b/app/code/Magento/Customer/Model/Metadata/Form.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -71,6 +69,8 @@ class Form protected $_isAjax = false; /** + * Attribute values + * * @var array */ protected $_attributeValues = []; @@ -127,7 +127,7 @@ class Form $ignoreInvisible = self::IGNORE_INVISIBLE, $filterAttributes = [], $isAjax = false - ) { + ) { $this->_eavMetadataService = $eavMetadataService; $this->_elementFactory = $elementFactory; $this->_attributeValues = $attributeValues; @@ -155,6 +155,21 @@ class Form return $this->_attributes; } + /** + * Return attribute instance by code or false + * + * @param string $attributeCode + * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata|false + */ + public function getAttribute($attributeCode) + { + $attributes = $this->getAttributes(); + if (isset($attributes[$attributeCode])) { + return $attributes[$attributeCode]; + } + return false; + } + /** * Retrieve user defined attributes * @@ -196,8 +211,7 @@ class Form { $attributes = $this->getAttributes(); foreach ($attributes as $attributeCode => $attribute) { - if ( - $this->_ignoreInvisible && !$attribute->isVisible() + if ($this->_ignoreInvisible && !$attribute->isVisible() || in_array($attribute->getAttributeCode(), $this->_filterAttributes) ) { unset($attributes[$attributeCode]); @@ -227,10 +241,10 @@ class Form } /** - * Compact data array to current entity + * Compact data array to form attribute values * * @param array $data - * @return array + * @return array attribute values */ public function compactData(array $data) { @@ -240,13 +254,15 @@ class Form if (!isset($data[$attribute->getAttributeCode()])) { $data[$attribute->getAttributeCode()] = false; } + $attributeCode = $attribute->getAttributeCode(); + $this->_attributeValues[$attributeCode] = $dataModel->compactValue($data[$attributeCode]); } - return $data; + return $this->_attributeValues; } /** - * Restore data array from SESSION to current entity + * Restore data array from SESSION to attribute values * * @param array $data * @return array @@ -259,9 +275,10 @@ class Form if (!isset($data[$attribute->getAttributeCode()])) { $data[$attribute->getAttributeCode()] = false; } - $data[$attribute->getAttributeCode()] = $dataModel->restoreValue($data[$attribute->getAttributeCode()]); + $attributeCode = $attribute->getAttributeCode(); + $this->_attributeValues[$attributeCode] = $dataModel->restoreValue($data[$attributeCode]); } - return $data; + return $this->_attributeValues; } /** @@ -341,7 +358,7 @@ class Form public function validateData(array $data) { $validator = $this->_getValidator($data); - if (!$validator->isValid($this->_attributeValues)) { + if (!$validator->isValid(false)) { $messages = array(); foreach ($validator->getMessages() as $errorMessages) { $messages = array_merge($messages, (array)$errorMessages); @@ -366,4 +383,14 @@ class Form } return $result; } + + /** + * Set whether invisible attributes should be ignored. + * + * @param bool $ignoreInvisible + */ + public function setInvisibleIgnored($ignoreInvisible) + { + $this->_ignoreInvisible = $ignoreInvisible; + } } diff --git a/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php b/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php index 36aa6bdefec..bf17293076d 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php @@ -58,16 +58,21 @@ abstract class AbstractData protected $_extractedData = array(); /** - * \Magento\Core\Model\LocaleInterface FORMAT + * Date filter format * * @var string */ protected $_dateFilterFormat; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; + + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; /** * @var \Magento\Logger @@ -80,7 +85,7 @@ abstract class AbstractData protected $_attribute; /** - * @var string + * @var string|int|bool */ protected $_value; @@ -88,22 +93,25 @@ abstract class AbstractData protected $_entityTypeCode; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Logger $logger * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute - * @param string $value - * @param $entityTypeCode + * @param \Magento\Locale\ResolverInterface $localeResolver + * @param string|int|bool $value + * @param string $entityTypeCode * @param bool $isAjax */ public function __construct( - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Logger $logger, \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute, - $value = null, + \Magento\Locale\ResolverInterface $localeResolver, + $value = false, $entityTypeCode, $isAjax = false ) { - $this->_locale = $locale; + $this->_localeDate = $localeDate; + $this->_localeResolver = $localeResolver; $this->_logger = $logger; $this->_attribute = $attribute; $this->_value = $value; @@ -210,7 +218,7 @@ abstract class AbstractData if ($filterCode) { $filterClass = 'Magento\Data\Form\Filter\\' . ucfirst($filterCode); if ($filterCode == 'date') { - $filter = new $filterClass($this->_dateFilterFormat(), $this->_locale->getLocale()); + $filter = new $filterClass($this->_dateFilterFormat(), $this->_localeResolver->getLocale()); } else { $filter = new $filterClass(); } @@ -230,9 +238,9 @@ abstract class AbstractData if (is_null($format)) { // get format if (is_null($this->_dateFilterFormat)) { - $this->_dateFilterFormat = \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT; + $this->_dateFilterFormat = \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT; } - return $this->_locale->getDateFormat($this->_dateFilterFormat); + return $this->_localeDate->getDateFormat($this->_dateFilterFormat); } else if ($format === false) { // reset value $this->_dateFilterFormat = null; @@ -512,14 +520,14 @@ abstract class AbstractData /** * Validate data * - * @param array|string $value + * @param array|string|null $value * @throws \Magento\Core\Exception * @return array|bool */ abstract public function validateValue($value); /** - * Export attribute value to entity model + * Export attribute value * * @param array|string $value * @return array|string|bool @@ -527,7 +535,7 @@ abstract class AbstractData abstract public function compactValue($value); /** - * Restore attribute value from SESSION to entity model + * Restore attribute value from SESSION * * @param array|string $value * @return array|string|bool @@ -535,7 +543,7 @@ abstract class AbstractData abstract public function restoreValue($value); /** - * Return formated attribute value from entity model + * Return formatted attribute value from entity model * * @param string $format * @return string|array diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Date.php b/app/code/Magento/Customer/Model/Metadata/Form/Date.php index c48798b2908..3cead75646a 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/Date.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Date.php @@ -119,13 +119,13 @@ class Date extends AbstractData case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_TEXT: case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_HTML: case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_PDF: - $this->_dateFilterFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM); + $this->_dateFilterFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM); break; } $value = $this->_applyOutputFilter($value); } - $this->_dateFilterFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $this->_dateFilterFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); return $value; } diff --git a/app/code/Magento/Customer/Model/Metadata/Form/File.php b/app/code/Magento/Customer/Model/Metadata/Form/File.php index 85f9f6f1d13..d09c5d081a8 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/File.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/File.php @@ -53,9 +53,10 @@ class File extends AbstractData protected $_fileSystem; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Logger $logger * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute + * @param \Magento\Locale\ResolverInterface $localeResolver * @param null $value * @param $entityTypeCode * @param bool $isAjax @@ -64,9 +65,10 @@ class File extends AbstractData * @param \Magento\App\Filesystem $fileSystem */ public function __construct( - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Logger $logger, \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute, + \Magento\Locale\ResolverInterface $localeResolver, $value = null, $entityTypeCode, $isAjax = false, @@ -74,7 +76,7 @@ class File extends AbstractData \Magento\Core\Model\File\Validator\NotProtectedExtension $fileValidator, \Magento\App\Filesystem $fileSystem ) { - parent::__construct($locale, $logger, $attribute, $value, $entityTypeCode, $isAjax); + parent::__construct($localeDate, $logger, $attribute, $localeResolver, $value, $entityTypeCode, $isAjax); $this->_coreData = $coreData; $this->_fileValidator = $fileValidator; $this->_fileSystem = $fileSystem; diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php b/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php index 99a336e3f1b..a508e2e2a7f 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php @@ -94,8 +94,8 @@ class Multiline extends Text */ public function compactValue($value) { - if (is_array($value)) { - $value = trim(implode("\n", $value)); + if (!is_array($value)) { + $value = [$value]; } return parent::compactValue($value); } diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Text.php b/app/code/Magento/Customer/Model/Metadata/Form/Text.php index e12387dbda6..6531c2b5706 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/Text.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Text.php @@ -33,24 +33,26 @@ class Text extends AbstractData protected $_string; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Logger $logger * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute + * @param \Magento\Locale\ResolverInterface $localeResolver * @param string $value * @param string $entityTypeCode * @param bool $isAjax * @param \Magento\Stdlib\String $stringHelper */ public function __construct( - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Logger $logger, \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute, + \Magento\Locale\ResolverInterface $localeResolver, $value, $entityTypeCode, $isAjax = false, \Magento\Stdlib\String $stringHelper ) { - parent::__construct($locale, $logger, $attribute, $value, $entityTypeCode, $isAjax); + parent::__construct($localeDate, $logger, $attribute, $localeResolver, $value, $entityTypeCode, $isAjax); $this->_string = $stringHelper; } diff --git a/app/code/Magento/Customer/Model/Metadata/FormFactory.php b/app/code/Magento/Customer/Model/Metadata/FormFactory.php index 7550fd21d96..38f8e00d457 100644 --- a/app/code/Magento/Customer/Model/Metadata/FormFactory.php +++ b/app/code/Magento/Customer/Model/Metadata/FormFactory.php @@ -46,19 +46,19 @@ class FormFactory * * @param string $entityType * @param string $formCode - * @param array $attributeValues + * @param array $attributeValues Key is attribute code. + * @param bool $isAjax * @param bool $ignoreInvisible * @param array $filterAttributes - * @param bool $isAjax * @return \Magento\Customer\Model\Metadata\Form */ public function create( $entityType, $formCode, array $attributeValues = [], + $isAjax = false, $ignoreInvisible = Form::IGNORE_INVISIBLE, - $filterAttributes = [], - $isAjax = false + $filterAttributes = [] ) { $params = [ 'entityType' => $entityType, diff --git a/app/code/Magento/Customer/Model/Metadata/Validator.php b/app/code/Magento/Customer/Model/Metadata/Validator.php index bcc4ca8446e..45ef5e6edb1 100644 --- a/app/code/Magento/Customer/Model/Metadata/Validator.php +++ b/app/code/Magento/Customer/Model/Metadata/Validator.php @@ -69,7 +69,7 @@ class Validator extends \Magento\Eav\Model\Validator\Attribute\Data * @param string $entityType * @return bool */ - public function validateData($data, $attributes, $entityType) + public function validateData(array $data, array $attributes, $entityType) { foreach ($attributes as $attribute) { $attributeCode = $attribute->getAttributeCode(); @@ -79,9 +79,7 @@ class Validator extends \Magento\Eav\Model\Validator\Attribute\Data if (!isset($data[$attributeCode])) { $data[$attributeCode] = null; } - $dataModel = $this->_attrDataFactory->create( - $attribute, $data[$attributeCode], $entityType - ); + $dataModel = $this->_attrDataFactory->create($attribute, $data[$attributeCode], $entityType); $dataModel->setExtractedData($data); $value = empty($data[$attributeCode]) && isset($this->_entityData[$attributeCode]) ? $this->_entityData[$attributeCode] diff --git a/app/code/Magento/Customer/Model/Resource/Address.php b/app/code/Magento/Customer/Model/Resource/Address.php index e859e1a0e45..fa240d17e41 100644 --- a/app/code/Magento/Customer/Model/Resource/Address.php +++ b/app/code/Magento/Customer/Model/Resource/Address.php @@ -41,7 +41,7 @@ class Address extends \Magento\Eav\Model\Entity\AbstractEntity * @param \Magento\App\Resource $resource * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Validator\UniversalFactory $universalFactory * @param \Magento\Core\Model\Validator\Factory $validatorFactory @@ -52,7 +52,7 @@ class Address extends \Magento\Eav\Model\Entity\AbstractEntity \Magento\App\Resource $resource, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Validator\UniversalFactory $universalFactory, \Magento\Core\Model\Validator\Factory $validatorFactory, @@ -61,7 +61,7 @@ class Address extends \Magento\Eav\Model\Entity\AbstractEntity ) { $this->_validatorFactory = $validatorFactory; $this->_customerFactory = $customerFactory; - parent::__construct($resource, $eavConfig, $attrSetEntity, $locale, $resourceHelper, $universalFactory, $data); + parent::__construct($resource, $eavConfig, $attrSetEntity, $localeFormat, $resourceHelper, $universalFactory, $data); } /** diff --git a/app/code/Magento/Customer/Model/Resource/Customer.php b/app/code/Magento/Customer/Model/Resource/Customer.php index c38ed0d5abe..81f03044e69 100644 --- a/app/code/Magento/Customer/Model/Resource/Customer.php +++ b/app/code/Magento/Customer/Model/Resource/Customer.php @@ -50,7 +50,7 @@ class Customer extends \Magento\Eav\Model\Entity\AbstractEntity * @param \Magento\App\Resource $resource * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Validator\UniversalFactory $universalFactory * @param \Magento\Core\Model\Store\Config $coreStoreConfig @@ -62,7 +62,7 @@ class Customer extends \Magento\Eav\Model\Entity\AbstractEntity \Magento\App\Resource $resource, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Validator\UniversalFactory $universalFactory, \Magento\Core\Model\Store\Config $coreStoreConfig, @@ -74,7 +74,7 @@ class Customer extends \Magento\Eav\Model\Entity\AbstractEntity $resource, $eavConfig, $attrSetEntity, - $locale, + $localeFormat, $resourceHelper, $universalFactory, $data diff --git a/app/code/Magento/Customer/Model/Session.php b/app/code/Magento/Customer/Model/Session.php old mode 100644 new mode 100755 index 69368520205..9ca5d54b31b --- a/app/code/Magento/Customer/Model/Session.php +++ b/app/code/Magento/Customer/Model/Session.php @@ -84,8 +84,6 @@ class Session extends \Magento\Session\SessionManager */ protected $_customerService; - /** @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface */ - protected $_customerAccountService; /** * @var CustomerFactory */ @@ -107,9 +105,9 @@ class Session extends \Magento\Session\SessionManager protected $_storeManager; /** - * @var \Magento\App\ResponseInterface + * @var \Magento\App\Http\Context */ - protected $response; + protected $_httpContext; /** * @var \Magento\Customer\Service\V1\Dto\Customer @@ -137,10 +135,9 @@ class Session extends \Magento\Session\SessionManager * @param \Magento\Core\Model\Session $session * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Customer\Model\Converter $converter - * @param \Magento\App\ResponseInterface $response + * @param \Magento\App\Http\Context $httpContext + * @param Converter $converter * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService - * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService * @param null $sessionName * @param array $data */ @@ -151,19 +148,18 @@ class Session extends \Magento\Session\SessionManager \Magento\Session\SaveHandlerInterface $saveHandler, \Magento\Session\ValidatorInterface $validator, \Magento\Session\StorageInterface $storage, - \Magento\Customer\Model\Config\Share $configShare, + Config\Share $configShare, \Magento\Core\Helper\Url $coreUrl, \Magento\Customer\Helper\Data $customerData, - \Magento\Customer\Model\Resource\Customer $customerResource, - \Magento\Customer\Model\CustomerFactory $customerFactory, + Resource\Customer $customerResource, + CustomerFactory $customerFactory, \Magento\UrlFactory $urlFactory, \Magento\Core\Model\Session $session, \Magento\Event\ManagerInterface $eventManager, \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\App\Http\Context $httpContext, \Magento\Customer\Model\Converter $converter, - \Magento\App\ResponseInterface $response, \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, - \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService, $sessionName = null, array $data = array() ) { @@ -175,10 +171,9 @@ class Session extends \Magento\Session\SessionManager $this->_urlFactory = $urlFactory; $this->_session = $session; $this->_customerService = $customerService; - $this->_customerAccountService = $customerAccountService; $this->_eventManager = $eventManager; $this->_storeManager = $storeManager; - $this->response = $response; + $this->_httpContext = $httpContext; parent::__construct($request, $sidResolver, $sessionConfig, $saveHandler, $validator, $storage); $this->start($sessionName); $this->_converter = $converter; @@ -204,7 +199,7 @@ class Session extends \Magento\Session\SessionManager public function setCustomerDto(CustomerDto $customer) { $this->_customer = $customer; - $this->response->setVary('customer_group', $customer->getGroupId()); + $this->_httpContext->setValue('customer_group', $customer->getGroupId()); $this->setCustomerId($customer->getCustomerId()); return $this; } @@ -217,12 +212,7 @@ class Session extends \Magento\Session\SessionManager */ public function getCustomerDto() { - /*** XXX: shouldn't this be CustomerDto? ***/ - if ($this->_customer instanceof Customer) { - return $this->_customer; - } - - if ($this->getCustomerId()) { + if (!($this->_customer instanceof CustomerDto) && $this->getCustomerId()) { $this->_customer = $this->_customerService->getCustomer($this->getCustomerId()); } @@ -259,11 +249,12 @@ class Session extends \Magento\Session\SessionManager * * @param Customer $customerModel * @return \Magento\Customer\Model\Session + * @deprecated use setCustomerId() instead */ public function setCustomer(Customer $customerModel) { $this->_customerModel = $customerModel; - $this->response->setVary('customer_group', $customerModel->getGroupId()); + $this->_httpContext->setValue('customer_group', $customerModel->getGroupId()); $this->setCustomerId($customerModel->getId()); if ((!$customerModel->isConfirmationRequired()) && $customerModel->getConfirmation()) { $customerModel->setConfirmation(null)->save(); @@ -313,11 +304,22 @@ class Session extends \Magento\Session\SessionManager return null; } + /** + * Retrieve customer id from current session + * + * @return int|null + */ public function getId() { return $this->getCustomerId(); } + /** + * Set customer id + * + * @param int|null $customerId + * @return \Magento\Customer\Model\Session + */ public function setId($customerId) { return $this->setCustomerId($customerId); @@ -385,24 +387,6 @@ class Session extends \Magento\Session\SessionManager } } - /** - * Customer authorization - * - * @param string $username - * @param string $password - * @return bool - */ - public function login($username, $password) - { - try { - $customer = $this->_customerAccountService->authenticate($username, $password); - $this->setCustomerDtoAsLoggedIn($customer); - return true; - } catch (\Exception $e) { - return false; - } - } - /** * @param Customer $customer * @return \Magento\Customer\Model\Session diff --git a/app/code/Magento/Customer/Service/V1/CustomerAccountService.php b/app/code/Magento/Customer/Service/V1/CustomerAccountService.php old mode 100644 new mode 100755 index 6bc313c8449..af43b3ceea0 --- a/app/code/Magento/Customer/Service/V1/CustomerAccountService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerAccountService.php @@ -35,6 +35,7 @@ use Magento\Exception\AuthenticationException; use Magento\Exception\NoSuchEntityException; use Magento\Exception\StateException; use Magento\Math\Random; +use Magento\UrlInterface; /** * Handle various customer account actions @@ -71,11 +72,6 @@ class CustomerAccountService implements CustomerAccountServiceInterface */ private $_validator; - /** - * @var Dto\Response\CreateCustomerAccountResponseBuilder - */ - private $_createCustomerAccountResponseBuilder; - /** * @var CustomerServiceInterface */ @@ -86,8 +82,10 @@ class CustomerAccountService implements CustomerAccountServiceInterface */ private $_customerAddressService; - /** @var \Magento\ObjectManager */ - protected $_objectManager; + /** + * @var UrlInterface + */ + private $_url; /** * Constructor @@ -98,10 +96,10 @@ class CustomerAccountService implements CustomerAccountServiceInterface * @param Random $mathRandom * @param Converter $converter * @param Validator $validator - * @param Dto\Response\CreateCustomerAccountResponseBuilder $createCustomerAccountResponseBuilder + * @param Dto\CustomerBuilder $customerBuilder * @param CustomerServiceInterface $customerService * @param CustomerAddressServiceInterface $customerAddressService - * @param \Magento\ObjectManager $objectManager + * @param UrlInterface $url * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -112,10 +110,10 @@ class CustomerAccountService implements CustomerAccountServiceInterface Random $mathRandom, Converter $converter, Validator $validator, - Dto\Response\CreateCustomerAccountResponseBuilder $createCustomerAccountResponseBuilder, + Dto\CustomerBuilder $customerBuilder, CustomerServiceInterface $customerService, CustomerAddressServiceInterface $customerAddressService, - \Magento\ObjectManager $objectManager + UrlInterface $url ) { $this->_customerFactory = $customerFactory; $this->_eventManager = $eventManager; @@ -123,17 +121,17 @@ class CustomerAccountService implements CustomerAccountServiceInterface $this->_mathRandom = $mathRandom; $this->_converter = $converter; $this->_validator = $validator; - $this->_createCustomerAccountResponseBuilder = $createCustomerAccountResponseBuilder; + $this->_customerBuilder = $customerBuilder; $this->_customerService = $customerService; $this->_customerAddressService = $customerAddressService; - $this->_objectManager = $objectManager; + $this->_url = $url; } /** * {@inheritdoc} */ - public function sendConfirmation($email) + public function sendConfirmation($email, $redirectUrl = '') { $customer = $this->_customerFactory->create(); $websiteId = $this->_storeManager->getStore()->getWebsiteId(); @@ -142,7 +140,8 @@ class CustomerAccountService implements CustomerAccountServiceInterface throw (new NoSuchEntityException('email', $email))->addField('websiteId', $websiteId); } if ($customer->getConfirmation()) { - $customer->sendNewAccountEmail('confirmation', '', $this->_storeManager->getStore()->getId()); + $customer->sendNewAccountEmail(self::NEW_ACCOUNT_EMAIL_CONFIRMATION, $redirectUrl, + $this->_storeManager->getStore()->getId()); } else { throw new StateException('No confirmation needed.', StateException::INVALID_STATE); } @@ -151,27 +150,42 @@ class CustomerAccountService implements CustomerAccountServiceInterface /** * {@inheritdoc} */ - public function activateAccount($customerId, $key) + public function activateAccount($customerId) { // load customer by id $customer = $this->_converter->getCustomerModel($customerId); // check if customer is inactive - if ($customer->getConfirmation()) { - if ($customer->getConfirmation() !== $key) { - throw new StateException('Invalid confirmation token', StateException::INPUT_MISMATCH); - } - // activate customer - $customer->setConfirmation(null); - $customer->save(); - $customer->sendNewAccountEmail('confirmed', '', $this->_storeManager->getStore()->getId()); - } else { + if (!$customer->getConfirmation()) { throw new StateException('Account already active', StateException::INVALID_STATE); } + // activate customer + $customer->setConfirmation(null); + $customer->save(); + $customer->sendNewAccountEmail(self::NEW_ACCOUNT_EMAIL_CONFIRMED, '', + $this->_storeManager->getStore()->getId()); + return $this->_converter->createCustomerFromModel($customer); } + /** + * {@inheritdoc} + */ + public function validateAccountConfirmationKey($customerId, $confirmationKey) + { + // load customer by id + $customer = $this->_converter->getCustomerModel($customerId); + + // check if customer is inactive + if (!$customer->getConfirmation()) { + throw new StateException('Account already active', StateException::INVALID_STATE); + } elseif ($customer->getConfirmation() !== $confirmationKey) { + throw new StateException('Invalid confirmation token', StateException::INPUT_MISMATCH); + } + return true; + } + /** * {@inheritdoc} */ @@ -200,6 +214,19 @@ class CustomerAccountService implements CustomerAccountServiceInterface return $this->_converter->createCustomerFromModel($customerModel); } + /** + * {@inheritdoc} + */ + public function validatePassword($customerId, $password) + { + $customerModel = $this->_converter->getCustomerModel($customerId); + if (!$customerModel->validatePassword($password)) { + throw new AuthenticationException(__("Password doesn't match for this account."), + AuthenticationException::INVALID_EMAIL_OR_PASSWORD); + } + return true; + } + /** * {@inheritdoc} */ @@ -211,7 +238,7 @@ class CustomerAccountService implements CustomerAccountServiceInterface /** * {@inheritdoc} */ - public function sendPasswordResetLink($email, $websiteId) + public function sendPasswordResetLink($email, $websiteId, $template) { $customer = $this->_customerFactory->create() ->setWebsiteId($websiteId) @@ -222,7 +249,26 @@ class CustomerAccountService implements CustomerAccountServiceInterface } $newPasswordToken = $this->_mathRandom->getUniqueHash(); $customer->changeResetPasswordLinkToken($newPasswordToken); - $customer->sendPasswordResetConfirmationEmail(); + $resetUrl = $this->_url + ->getUrl( + 'customer/account/createPassword', + [ + '_query' => array('id' => $customer->getId(), 'token' => $newPasswordToken), + '_store' => $customer->getStoreId() + ] + ); + + $customer->setResetPasswordUrl($resetUrl); + switch ($template) { + case CustomerAccountServiceInterface::EMAIL_REMINDER: + $customer->sendPasswordReminderEmail(); + break; + case CustomerAccountServiceInterface::EMAIL_RESET: + $customer->sendPasswordResetConfirmationEmail(); + break; + default: + throw new InputException(__('Invalid email type.'), InputException::INVALID_FIELD_VALUE); + } } /** @@ -240,31 +286,49 @@ class CustomerAccountService implements CustomerAccountServiceInterface /** * {@inheritdoc} */ - public function createAccount( - Dto\Customer $customer, - array $addresses, - $password = null, - $confirmationBackUrl = '', - $registeredBackUrl = '', - $storeId = 0 - ) { - $customerId = $customer->getCustomerId(); - if ($customerId) { - $customerModel = $this->_converter->getCustomerModel($customerId); - // We can't pass it through DI because going to get circular dependency - /** @var \Magento\Customer\Helper\Data $customerHelper */ - $customerHelper = $this->_objectManager->get('Magento\Customer\Helper\Data'); - if ($customerHelper->isCustomerInStore($customerModel->getWebsiteId(), $storeId)) { - return $this->_createCustomerAccountResponseBuilder->setCustomerId($customerId) - ->setStatus('') - ->create(); + public function getConfirmationStatus($customerId) + { + $customerModel= $this->_converter->getCustomerModel($customerId); + if (!$customerModel->getConfirmation()) { + return CustomerAccountServiceInterface::ACCOUNT_CONFIRMED; + } + if ($customerModel->isConfirmationRequired()) { + return CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_REQUIRED; + } + return CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_NOT_REQUIRED; + } + + /** + * {@inheritdoc} + */ + public function createAccount(Dto\Customer $customer, array $addresses, $password = null, $redirectUrl = '') + { + // This logic allows an existing customer to be added to a different store. No new account is created. + // The plan is to move this logic into a new method called something like 'registerAccountWithStore' + if ($customer->getCustomerId()) { + $customerModel = $this->_converter->getCustomerModel($customer->getCustomerId()); + if ($customerModel->isInStore($customer->getStoreId())) { + throw new InputException(__('Customer already exists in this store.')); } } + // Make sure we have a storeId to associate this customer with. + if (!$customer->getStoreId()) { + if ($customer->getWebsiteId()) { + $storeId = $this->_storeManager->getWebsite($customer->getWebsiteId())->getDefaultStore()->getId(); + } else { + $storeId = $this->_storeManager->getStore()->getId(); + } + $customer = $this->_customerBuilder->populate($customer) + ->setStoreId($storeId) + ->create(); + } + try { $customerId = $this->_customerService->saveCustomer($customer, $password); } catch (\Magento\Customer\Exception $e) { if ($e->getCode() === CustomerModel::EXCEPTION_EMAIL_EXISTS) { - throw new StateException('Provided email already exists.', StateException::INPUT_MISMATCH); + throw new StateException(__('Customer with the same email already exists in associated website.'), + StateException::INPUT_MISMATCH); } throw $e; } @@ -276,21 +340,52 @@ class CustomerAccountService implements CustomerAccountServiceInterface $newLinkToken = $this->_mathRandom->getUniqueHash(); $customerModel->changeResetPasswordLinkToken($newLinkToken); - if (!$storeId) { - $storeId = $this->_storeManager->getStore()->getId(); - } - if ($customerModel->isConfirmationRequired()) { - $customerModel->sendNewAccountEmail('confirmation', $confirmationBackUrl, $storeId); - return $this->_createCustomerAccountResponseBuilder->setCustomerId($customerId) - ->setStatus(self::ACCOUNT_CONFIRMATION) - ->create(); + $customerModel->sendNewAccountEmail(self::NEW_ACCOUNT_EMAIL_CONFIRMATION, $redirectUrl, + $customer->getStoreId()); } else { - $customerModel->sendNewAccountEmail('registered', $registeredBackUrl, $storeId); - return $this->_createCustomerAccountResponseBuilder->setCustomerId($customerId) - ->setStatus(self::ACCOUNT_REGISTERED) - ->create(); + $customerModel->sendNewAccountEmail(self::NEW_ACCOUNT_EMAIL_REGISTERED, $redirectUrl, + $customer->getStoreId()); } + return $this->_converter->createCustomerFromModel($customerModel); + } + + /** + * {@inheritdoc} + */ + public function updateAccount(Dto\Customer $customer, array $addresses = null) + { + // Making this call first will ensure the customer already exists. + $this->_customerService->getCustomer($customer->getCustomerId()); + $this->_customerService->saveCustomer($customer); + + if ($addresses != null) { + $existingAddresses = $this->_customerAddressService->getAddresses($customer->getCustomerId()); + /** @var Dto\Address[] $deletedAddresses */ + $deletedAddresses = array_udiff($existingAddresses, $addresses, + function (Dto\Address $existing, Dto\Address $replacement) { + return $existing->getId() - $replacement->getId(); + } + ); + foreach ($deletedAddresses as $address) { + $this->_customerAddressService->deleteAddress($address->getId()); + } + $this->_customerAddressService->saveAddresses($customer->getCustomerId(), $addresses); + } + } + + /** + * {@inheritdoc} + */ + public function changePassword($customerId, $newPassword) + { + $customerModel = $this->_converter->getCustomerModel($customerId); + $customerModel->setRpToken(null); + $customerModel->setRpTokenCreatedAt(null); + $customerModel->setPassword($newPassword); + $customerModel->save(); + // FIXME: Are we using the proper template here? + $customerModel->sendPasswordResetNotificationEmail(); } /** @@ -324,12 +419,11 @@ class CustomerAccountService implements CustomerAccountServiceInterface return true; } - /** * Validate the Reset Password Token for a customer. * - * @param $customerId - * @param $resetPasswordLinkToken + * @param int $customerId + * @param string $resetPasswordLinkToken * @return CustomerModel * @throws \Magento\Exception\StateException if token is expired or mismatched * @throws \Magento\Exception\InputException if token or customer id is invalid diff --git a/app/code/Magento/Customer/Service/V1/CustomerAccountServiceInterface.php b/app/code/Magento/Customer/Service/V1/CustomerAccountServiceInterface.php old mode 100644 new mode 100755 index f20a4fd9339..6cc083536c0 --- a/app/code/Magento/Customer/Service/V1/CustomerAccountServiceInterface.php +++ b/app/code/Magento/Customer/Service/V1/CustomerAccountServiceInterface.php @@ -29,7 +29,7 @@ namespace Magento\Customer\Service\V1; */ interface CustomerAccountServiceInterface { - /** account response status */ + /** account response status @deprecated */ const ACCOUNT_CONFIRMATION = "confirmation"; const ACCOUNT_REGISTERED = "registered"; @@ -38,41 +38,67 @@ interface CustomerAccountServiceInterface const NEW_ACCOUNT_EMAIL_CONFIRMED = 'confirmed'; // welcome email, when confirmation is enabled const NEW_ACCOUNT_EMAIL_CONFIRMATION = 'confirmation'; // email with confirmation link + // Constants for confirmation statuses + const ACCOUNT_CONFIRMED = 'account_confirmed'; + const ACCOUNT_CONFIRMATION_REQUIRED = 'account_confirmation_required'; + const ACCOUNT_CONFIRMATION_NOT_REQUIRED = 'account_confirmation_not_required'; + + /** + * Constants for types of emails to send out. + * pdl: + * forgot, remind, reset email templates + */ + const EMAIL_REMINDER = 'email_reminder'; + const EMAIL_RESET = 'email_reset'; + /** * Create Customer Account * * @param Dto\Customer $customer * @param Dto\Address[] $addresses - * @param string $password - * @param string $confirmationBackUrl - * @param string $registeredBackUrl - * @param int $storeId - * @return Dto\Response\CreateCustomerAccountResponse + * @param string $password If null then a random password will be assigned + * @param string $redirectUrl URL fed to welcome email templates. Can be used by templates to, for example, direct + * the customer to a product they were looking at after pressing confirmation link. + * @return Dto\Customer * @throws \Exception If something goes wrong during save * @throws \Magento\Exception\InputException If bad input is provided * @throws \Magento\Exception\StateException If the provided email is already used */ - public function createAccount( - Dto\Customer $customer, - array $addresses, - $password = null, - $confirmationBackUrl = '', - $registeredBackUrl = '', - $storeId = 0 - ); + public function createAccount(Dto\Customer $customer, array $addresses, $password = null, $redirectUrl = ''); + + /** + * Update Customer Account + * + * @param Dto\Customer $customer + * @param Dto\Address[]|null $addresses Full array of addresses to associate with customer, + * or null if no change to addresses + * @return void + */ + public function updateAccount(Dto\Customer $customer, array $addresses = null); /** * Used to activate a customer account using a key that was sent in a confirmation e-mail. * * @param int $customerId - * @param string $key * @return Dto\Customer * @throws \Magento\Exception\NoSuchEntityException If customer doesn't exist * @throws \Magento\Exception\StateException + * StateException::INVALID_STATE_CHANGE if account already active. + */ + public function activateAccount($customerId); + + /** + * Validate an account confirmation key matches expected value for customer + * + * @param int $customerId + * @param string $confirmationKey + * @return true if customer is valid + * @throws \Magento\Exception\NoSuchEntityException If customer doesn't exist + * @throws \Magento\Exception\StateException * StateException::INPUT_MISMATCH if key doesn't match expected. * StateException::INVALID_STATE_CHANGE if account already active. */ - public function activateAccount($customerId, $key); + public function validateAccountConfirmationKey($customerId, $confirmationKey); /** * Login a customer account using username and password @@ -80,19 +106,42 @@ interface CustomerAccountServiceInterface * @param string $username username in plain-text * @param string $password password in plain-text * @return Dto\Customer - * @throws \Magento\Exception\AuthenticationException if unable to authenticate + * @throws \Magento\Exception\AuthenticationException If unable to authenticate */ public function authenticate($username, $password); + /** + * Checks if a given password matches the customer password. + * + * This function can be used instead of authenticate to re-verify that a logged in + * user knows the password for sensitive actions. + * + * @param int $customerId + * @param string $password + * @return true + * @throws \Magento\Exception\AuthenticationException + */ + public function validatePassword($customerId, $password); + + /** + * Change customer password. + * + * @param int $customerId + * @param string $newPassword + * @return void + * @throws \Magento\Exception\NoSuchEntityException If customer with customerId is not found. + */ + public function changePassword($customerId, $newPassword); + /** * Check if password reset token is valid * * @param int $customerId * @param string $resetPasswordLinkToken * @return void - * @throws \Magento\Exception\StateException if token is expired or mismatched - * @throws \Magento\Exception\InputException if token or customer id is invalid - * @throws \Magento\Exception\NoSuchEntityException if customer doesn't exist + * @throws \Magento\Exception\StateException If token is expired or mismatched + * @throws \Magento\Exception\InputException If token or customer id is invalid + * @throws \Magento\Exception\NoSuchEntityException If customer doesn't exist */ public function validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken); @@ -101,10 +150,11 @@ interface CustomerAccountServiceInterface * * @param string $email * @param int $websiteId + * @param string $template Type of email to send. Must be one of the email constants. * @return void * @throws \Magento\Exception\NoSuchEntityException */ - public function sendPasswordResetLink($email, $websiteId); + public function sendPasswordResetLink($email, $websiteId, $template); /** @@ -114,21 +164,32 @@ interface CustomerAccountServiceInterface * @param string $password * @param string $resetToken * @return void - * @throws \Magento\Exception\StateException if token is expired or mismatched - * @throws \Magento\Exception\InputException if token or customer id is invalid - * @throws \Magento\Exception\NoSuchEntityException if customer doesn't exist + * @throws \Magento\Exception\StateException If token is expired or mismatched + * @throws \Magento\Exception\InputException If token or customer id is invalid + * @throws \Magento\Exception\NoSuchEntityException If customer doesn't exist + * @deprecated Use changePassword and validateResetPasswordLinkToken instead */ public function resetPassword($customerId, $password, $resetToken); - /* - * Send Confirmation email + /** + * Gets the account confirmation status + * + * @param int $customerId + * @return string returns one of the account confirmation statuses + */ + public function getConfirmationStatus($customerId); + + /** + * Send Confirmation email. * * @param string $email email address of customer + * @param string $redirectUrl URL fed to welcome email templates. Can be used by templates to, for example, direct + * the customer to a product they were looking at after pressing confirmation link. * @return void - * @throws \Magento\Exception\NoSuchEntityException if no customer found for provided email - * @throws \Magento\Exception\StateException if confirmation is not needed + * @throws \Magento\Exception\NoSuchEntityException If no customer found for provided email + * @throws \Magento\Exception\StateException If confirmation is not needed */ - public function sendConfirmation($email); + public function sendConfirmation($email, $redirectUrl = ''); /** * Validate customer entity @@ -138,5 +199,4 @@ interface CustomerAccountServiceInterface * @return array|bool */ public function validateCustomerData(Dto\Customer $customer, array $attributes); - } diff --git a/app/code/Magento/Customer/Service/V1/CustomerAddressCurrentService.php b/app/code/Magento/Customer/Service/V1/CustomerAddressCurrentService.php new file mode 100644 index 00000000000..a94e815aec7 --- /dev/null +++ b/app/code/Magento/Customer/Service/V1/CustomerAddressCurrentService.php @@ -0,0 +1,81 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Service\V1; + +/** + * Class CustomerAddressCurrentService + */ +class CustomerAddressCurrentService implements \Magento\Customer\Service\V1\CustomerAddressCurrentServiceInterface +{ + /** + * @var CustomerCurrentService + */ + protected $customerCurrentService; + + /** + * @var CustomerAddressService + */ + protected $customerAddressService; + + public function __construct( + \Magento\Customer\Service\V1\CustomerCurrentService $customerCurrentService, + \Magento\Customer\Service\V1\CustomerAddressService $customerAddressService + ) { + $this->customerCurrentService = $customerCurrentService; + $this->customerAddressService = $customerAddressService; + } + + /** + * Returns all addresses for current customer + * + * @return array|Dto\Address[] + */ + public function getCustomerAddresses() + { + return $this->customerAddressService + ->getAddresses($this->customerCurrentService->getCustomerId()); + } + + /** + * Returns default billing address form current customer + * + * @return Dto\Address|null + */ + public function getDefaultBillingAddress() + { + return $this->customerAddressService + ->getDefaultBillingAddress($this->customerCurrentService->getCustomerId()); + } + + /** + * Returns default shipping address for current customer + * + * @return Dto\Address|null + */ + public function getDefaultShippingAddress() + { + return $this->customerAddressService + ->getDefaultShippingAddress($this->customerCurrentService->getCustomerId()); + } +} diff --git a/app/code/Magento/Customer/Service/V1/CustomerAddressCurrentServiceInterface.php b/app/code/Magento/Customer/Service/V1/CustomerAddressCurrentServiceInterface.php new file mode 100644 index 00000000000..2c0c2bc8ddf --- /dev/null +++ b/app/code/Magento/Customer/Service/V1/CustomerAddressCurrentServiceInterface.php @@ -0,0 +1,51 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Service\V1; + +/** + * Interface CustomerAddressCurrentServiceInterface + */ +interface CustomerAddressCurrentServiceInterface +{ + /** + * Returns all addresses for current customer + * + * @return array|Dto\Address[] + */ + public function getCustomerAddresses(); + + /** + * Returns default billing address form current customer + * + * @return Dto\Address|null + */ + public function getDefaultBillingAddress(); + + /** + * Returns default shipping address for current customer + * + * @return Dto\Address|null + */ + public function getDefaultShippingAddress(); +} diff --git a/app/code/Magento/Customer/Service/V1/CustomerAddressService.php b/app/code/Magento/Customer/Service/V1/CustomerAddressService.php index 1fe7991632c..801a754d8ca 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerAddressService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerAddressService.php @@ -36,7 +36,9 @@ use Magento\Customer\Model\Address\Converter as AddressConverter; */ class CustomerAddressService implements CustomerAddressServiceInterface { - /** @var \Magento\Customer\Model\AddressFactory */ + /** + * @var \Magento\Customer\Model\AddressFactory + */ private $_addressFactory; /** @@ -173,7 +175,7 @@ class CustomerAddressService implements CustomerAddressServiceInterface /** * {@inheritdoc} */ - public function saveAddresses($customerId, array $addresses) + public function saveAddresses($customerId, $addresses) { $customerModel = $this->_converter->getCustomerModel($customerId); $addressModels = []; diff --git a/app/code/Magento/Customer/Service/V1/CustomerAddressServiceInterface.php b/app/code/Magento/Customer/Service/V1/CustomerAddressServiceInterface.php old mode 100644 new mode 100755 index bc3a0b34c4e..ab4a51a824f --- a/app/code/Magento/Customer/Service/V1/CustomerAddressServiceInterface.php +++ b/app/code/Magento/Customer/Service/V1/CustomerAddressServiceInterface.php @@ -32,9 +32,9 @@ interface CustomerAddressServiceInterface /** * Retrieve all Customer Addresses * - * @param int $customerId, + * @param int $customerId * @return Dto\Address[] - * @throws \Magento\Exception\NoSuchEntityException if the customer Id is invalid + * @throws \Magento\Exception\NoSuchEntityException If the customer Id is invalid */ public function getAddresses($customerId); @@ -42,8 +42,8 @@ interface CustomerAddressServiceInterface * Retrieve default billing address * * @param int $customerId - * @return Dto\Address - * @throws \Magento\Exception\NoSuchEntityException if the customer Id is invalid + * @return Dto\Address|null + * @throws \Magento\Exception\NoSuchEntityException If the customer Id is invalid */ public function getDefaultBillingAddress($customerId); @@ -51,8 +51,8 @@ interface CustomerAddressServiceInterface * Retrieve default shipping address * * @param int $customerId - * @return Dto\Address - * @throws \Magento\Exception\NoSuchEntityException if the customer Id is invalid + * @return Dto\Address|null + * @throws \Magento\Exception\NoSuchEntityException If the customer Id is invalid */ public function getDefaultShippingAddress($customerId); @@ -69,6 +69,7 @@ interface CustomerAddressServiceInterface * Removes an address by id. * * @param int $addressId + * @return void * @throws \Magento\Exception\NoSuchEntityException If no address can be found for the provided id. */ public function deleteAddress($addressId); @@ -87,11 +88,10 @@ interface CustomerAddressServiceInterface * * @param int $customerId * @param Dto\Address[] $addresses - * @throws \Magento\Exception\InputException if there are validation errors. + * @throws \Magento\Exception\InputException If there are validation errors. * @throws \Magento\Exception\NoSuchEntityException If customer with customerId is not found. - * @throws \Exception if there were issues during the save operation + * @throws \Exception If there were issues during the save operation * @return int[] address ids */ - public function saveAddresses($customerId, array $addresses); - + public function saveAddresses($customerId, $addresses); } diff --git a/app/code/Magento/Customer/Service/V1/CustomerCurrentService.php b/app/code/Magento/Customer/Service/V1/CustomerCurrentService.php new file mode 100644 index 00000000000..3ae5ed6dbc3 --- /dev/null +++ b/app/code/Magento/Customer/Service/V1/CustomerCurrentService.php @@ -0,0 +1,135 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Service\V1; + +/** + * Class CustomerCurrentService + */ +class CustomerCurrentService implements \Magento\Customer\Service\V1\CustomerCurrentServiceInterface +{ + /** + * @var \Magento\Customer\Model\Session + */ + protected $customerSession; + + /** + * @var \Magento\View\LayoutInterface + */ + protected $layout; + + /** + * @var \Magento\Customer\Service\V1\Dto\CustomerBuilder + */ + protected $customerBuilder; + + /** + * @var \Magento\Customer\Service\V1\CustomerService + */ + protected $customerService; + + /** + * @var \Magento\App\RequestInterface + */ + protected $request; + + /** + * @var \Magento\Module\Manager + */ + protected $moduleManager; + + /** + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\View\LayoutInterface $layout + * @param Dto\CustomerBuilder $customerBuilder + * @param CustomerServiceInterface $customerService + * @param \Magento\App\RequestInterface $request + * @param \Magento\Module\Manager $moduleManager + * @param \Magento\App\ViewInterface $view + */ + public function __construct( + \Magento\Customer\Model\Session $customerSession, + \Magento\View\LayoutInterface $layout, + \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder, + \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, + \Magento\App\RequestInterface $request, + \Magento\Module\Manager $moduleManager, + \Magento\App\ViewInterface $view + ) { + $this->customerSession = $customerSession; + $this->layout = $layout; + $this->customerBuilder = $customerBuilder; + $this->customerService = $customerService; + $this->request = $request; + $this->moduleManager = $moduleManager; + $this->view = $view; + } + + /** + * Returns customer Dto with customer group only + * + * @return Dto\Customer + */ + protected function getDepersonalizedCustomer() + { + return $this->customerBuilder->setGroupId($this->customerSession->getCustomerGroupId())->create(); + } + + /** + * Returns customer Dto from service + * + * @return Dto\Customer + */ + protected function getCustomerFromService() + { + return $this->customerService->getCustomer($this->customerSession->getId()); + } + + /** + * Returns current customer according to session and context + * + * @return Dto\Customer + */ + public function getCustomer() + { + if ($this->moduleManager->isEnabled('Magento_PageCache') + && !$this->request->isAjax() + && $this->view->isLayoutLoaded() + && $this->layout->isCacheable() + ) { + return $this->getDepersonalizedCustomer(); + } else { + return $this->getCustomerFromService(); + } + } + + /** + * Returns customer id from session + * + * @return int|null + */ + public function getCustomerId() + { + return $this->customerSession->getId(); + } +} diff --git a/app/code/Magento/Customer/Service/V1/Dto/Response/CreateCustomerAccountResponse.php b/app/code/Magento/Customer/Service/V1/CustomerCurrentServiceInterface.php similarity index 70% rename from app/code/Magento/Customer/Service/V1/Dto/Response/CreateCustomerAccountResponse.php rename to app/code/Magento/Customer/Service/V1/CustomerCurrentServiceInterface.php index e9b88ac826c..9d73f9aa4e9 100644 --- a/app/code/Magento/Customer/Service/V1/Dto/Response/CreateCustomerAccountResponse.php +++ b/app/code/Magento/Customer/Service/V1/CustomerCurrentServiceInterface.php @@ -1,7 +1,5 @@ <?php /** - * Class CreateCustomerAccountResponse - * * Magento * * NOTICE OF LICENSE @@ -23,23 +21,24 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Customer\Service\V1\Dto\Response; +namespace Magento\Customer\Service\V1; -class CreateCustomerAccountResponse extends \Magento\Service\Entity\AbstractDto +/** + * Interface CustomerCurrentServiceInterface + */ +interface CustomerCurrentServiceInterface { /** - * @return int + * Returns current customer according to session and context + * + * @return Dto\Customer */ - public function getCustomerId() - { - return $this->_get('customer_id'); - } + public function getCustomer(); /** - * @return string + * Returns customer id from session + * + * @return int|null */ - public function getStatus() - { - return $this->_get('status'); - } -} + public function getCustomerId(); +} \ No newline at end of file diff --git a/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php b/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php index 56981c4699f..c3e89ee7cf7 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php +++ b/app/code/Magento/Customer/Service/V1/CustomerGroupServiceInterface.php @@ -88,7 +88,7 @@ interface CustomerGroupServiceInterface * @param int $groupId * @throws NoSuchEntityException if $groupId is not found * @throws \Exception if something goes wrong during delete - * @return null + * @return void */ public function deleteGroup($groupId); } diff --git a/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php b/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php index 761313ba763..5c3221bcf76 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php @@ -38,9 +38,6 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface */ private $_eavConfig; - /** @var array Cache of DTOs - entityType => attributeCode => DTO */ - private $_cache; - /** * @var \Magento\Customer\Model\Resource\Form\Attribute\CollectionFactory */ @@ -76,7 +73,6 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface Dto\Eav\AttributeMetadataBuilder $attributeMetadataBuilder ) { $this->_eavConfig = $eavConfig; - $this->_cache = []; $this->_attrFormCollectionFactory = $attrFormCollectionFactory; $this->_storeManager = $storeManager; $this->_optionBuilder = $optionBuilder; @@ -88,16 +84,10 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface */ public function getAttributeMetadata($entityType, $attributeCode) { - $dtoCache = $this->_getEntityCache($entityType); - if (isset($dtoCache[$attributeCode])) { - return $dtoCache[$attributeCode]; - } - /** @var AbstractAttribute $attribute */ $attribute = $this->_eavConfig->getAttribute($entityType, $attributeCode); if ($attribute) { $attributeMetadata = $this->_createMetadataAttribute($attribute); - $dtoCache[$attributeCode] = $attributeMetadata; return $attributeMetadata; } else { throw (new NoSuchEntityException('entityType', $entityType)) @@ -143,6 +133,40 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface return $attributes; } + /** + * @inheritdoc + */ + public function getCustomerAttributeMetadata($attributeCode) + { + return $this->getAttributeMetadata(self::ENTITY_TYPE_CUSTOMER, $attributeCode); + } + + /** + * @inheritdoc + */ + public function getAllCustomerAttributeMetadata() + { + return $this->getAllAttributeSetMetadata(self::ENTITY_TYPE_CUSTOMER, self::ATTRIBUTE_SET_ID_CUSTOMER); + } + + /** + * @inheritdoc + */ + public function getAddressAttributeMetadata($attributeCode) + { + return $this->getAttributeMetadata(self::ENTITY_TYPE_ADDRESS, $attributeCode); + } + + /** + * @inheritdoc + */ + public function getAllAddressAttributeMetadata() + { + return $this->getAllAttributeSetMetadata(self::ENTITY_TYPE_ADDRESS, self::ATTRIBUTE_SET_ID_ADDRESS); + } + + + /** * Load collection with filters applied * @@ -188,6 +212,7 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface ->setOptions($options) ->setFrontendClass($attribute->getFrontend()->getClass()) ->setFrontendLabel($attribute->getFrontendLabel()) + ->setNote($attribute->getNote()) ->setIsSystem($attribute->getIsSystem()) ->setIsUserDefined($attribute->getIsUserDefined()) ->setSortOrder($attribute->getSortOrder()); @@ -195,50 +220,4 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface return $this->_attributeMetadataBuilder->create(); } - /** - * @inheritdoc - */ - public function getCustomerAttributeMetadata($attributeCode) - { - return $this->getAttributeMetadata('customer', $attributeCode); - } - - /** - * @inheritdoc - */ - public function getAllCustomerAttributeMetadata() - { - return $this->getAllAttributeSetMetadata('customer', self::ATTRIBUTE_SET_ID_CUSTOMER); - } - - /** - * @inheritdoc - */ - public function getAddressAttributeMetadata($attributeCode) - { - return $this->getAttributeMetadata('customer_address', $attributeCode); - } - - /** - * @inheritdoc - */ - public function getAllAddressAttributeMetadata() - { - return $this->getAllAttributeSetMetadata('customer_address', self::ATTRIBUTE_SET_ID_ADDRESS); - } - - - /** - * Helper for getting access to an entity types DTO cache. - * - * @param $entityType - * @return \ArrayAccess - */ - private function _getEntityCache($entityType) - { - if (!isset($this->_cache[$entityType])) { - $this->_cache[$entityType] = new \ArrayObject(); - } - return $this->_cache[$entityType]; - } } diff --git a/app/code/Magento/Customer/Service/V1/CustomerService.php b/app/code/Magento/Customer/Service/V1/CustomerService.php index 347fc7727df..fb041beae43 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerService.php @@ -109,6 +109,16 @@ class CustomerService implements CustomerServiceInterface return $customerModel->getId(); } + /** + * {@inheritdoc} + */ + public function deleteCustomer($customerId) + { + $customerModel = $this->_converter->getCustomerModel($customerId); + $customerModel->delete(); + unset($this->_cache[$customerModel->getId()]); + } + /** * Validate customer attribute values. * @@ -170,10 +180,18 @@ class CustomerService implements CustomerServiceInterface /** * {@inheritdoc} */ - public function deleteCustomer($customerId) + public function isReadonly($customerId) { $customerModel = $this->_converter->getCustomerModel($customerId); - $customerModel->delete(); - unset($this->_cache[$customerModel->getId()]); + return $customerModel->isReadonly(); + } + + /** + * {@inheritdoc} + */ + public function isDeleteable($customerId) + { + $customerModel = $this->_converter->getCustomerModel($customerId); + return $customerModel->isDeleteable(); } } diff --git a/app/code/Magento/Customer/Service/V1/CustomerServiceInterface.php b/app/code/Magento/Customer/Service/V1/CustomerServiceInterface.php index 94f80b803f2..bbef6c82a5c 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerServiceInterface.php +++ b/app/code/Magento/Customer/Service/V1/CustomerServiceInterface.php @@ -71,4 +71,24 @@ interface CustomerServiceInterface * @return void */ public function deleteCustomer($customerId); + + /** + * Indicates if the Customer for the provided customerId is restricted to being read only + * for the currently logged in user. + * + * @param int $customerId + * @throws NoSuchEntityException If customer with customerId is not found. + * @return bool + */ + public function isReadonly($customerId); + + /** + * Indicates if the Customer for the currently logged in user as specified by the provided + * customerId can be deleted. + * + * @param int $customerId + * @throws NoSuchEntityException If customer with customerId is not found. + * @return bool + */ + public function isDeleteable($customerId); } diff --git a/app/code/Magento/Customer/Service/V1/Dto/Address.php b/app/code/Magento/Customer/Service/V1/Dto/Address.php index 704447449b7..9910770686c 100644 --- a/app/code/Magento/Customer/Service/V1/Dto/Address.php +++ b/app/code/Magento/Customer/Service/V1/Dto/Address.php @@ -36,6 +36,7 @@ class Address extends \Magento\Service\Entity\AbstractDto implements Eav\EntityI const KEY_CUSTOMER_ID = 'customer_id'; const KEY_REGION = Region::KEY_REGION; const KEY_REGION_ID = Region::KEY_REGION_ID; + const KEY_REGION_CODE = Region::KEY_REGION_CODE; const KEY_STREET = 'street'; const KEY_COMPANY = 'company'; const KEY_TELEPHONE = 'telephone'; @@ -109,6 +110,29 @@ class Address extends \Magento\Service\Entity\AbstractDto implements Eav\EntityI $validData[$attributeCode] = $unvalidatedData[$attributeCode]; } } + + /** This triggers some code in _updateAddressModel in CustomerV1 Service */ + if (!is_null($this->getRegion())) { + $region = $this->getRegion(); + if (!is_null($region->getRegionId())) { + $validData[self::KEY_REGION_ID] = $region->getRegionId(); + } else { + unset($validData[self::KEY_REGION_ID]); + } + if (!is_null($region->getRegion())) { + $validData[self::KEY_REGION] = $region->getRegion(); + } else { + unset($validData[self::KEY_REGION]); + } + if (!is_null($region->getRegionCode())) { + $validData[self::KEY_REGION_CODE] = $region->getRegionCode(); + } else { + unset($validData[self::KEY_REGION_CODE]); + } + } else { + unset($validData[self::KEY_REGION]); + } + return $validData; } @@ -142,7 +166,7 @@ class Address extends \Magento\Service\Entity\AbstractDto implements Eav\EntityI } /** - * @return \string[]|null + * @return string[]|null */ public function getStreet() { diff --git a/app/code/Magento/Customer/Service/V1/Dto/AddressBuilder.php b/app/code/Magento/Customer/Service/V1/Dto/AddressBuilder.php index 5e7461cd37f..5116562a997 100644 --- a/app/code/Magento/Customer/Service/V1/Dto/AddressBuilder.php +++ b/app/code/Magento/Customer/Service/V1/Dto/AddressBuilder.php @@ -29,7 +29,6 @@ use Magento\Service\Entity\AbstractDto; use Magento\Service\Entity\AbstractDtoBuilder; /** - * @method Address create() * @method Address mergeDtoWithArray(AbstractDto $dto, array $data) */ class AddressBuilder extends AbstractDtoBuilder @@ -232,4 +231,14 @@ class AddressBuilder extends AbstractDtoBuilder { return $this->_set(Address::KEY_CUSTOMER_ID, $customerId); } + + /** + * Builds the entity. + * + * @return Address + */ + public function create() + { + return parent::create(); + } } diff --git a/app/code/Magento/Customer/Service/V1/Dto/CustomerBuilder.php b/app/code/Magento/Customer/Service/V1/Dto/CustomerBuilder.php index ed959d6cd80..30d8cc824cb 100644 --- a/app/code/Magento/Customer/Service/V1/Dto/CustomerBuilder.php +++ b/app/code/Magento/Customer/Service/V1/Dto/CustomerBuilder.php @@ -192,4 +192,26 @@ class CustomerBuilder extends \Magento\Service\Entity\AbstractDtoBuilder { return $this->_set(self::RP_TOKEN_CREATED_AT, $rpTokenCreatedAt); } + + /** + * Adding ability to set custom attribute code + * + * @param string $attributeCode + * @param string|int $value + * @return $this + */ + public function setAttribute($attributeCode, $value) + { + return $this->_set($attributeCode, $value); + } + + /** + * Builds the entity. + * + * @return Customer + */ + public function create() + { + return parent::create(); + } } diff --git a/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadata.php b/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadata.php index 5ef55a9a4da..7db4b642e1f 100644 --- a/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadata.php +++ b/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadata.php @@ -45,6 +45,7 @@ class AttributeMetadata extends \Magento\Service\Entity\AbstractDto const SORT_ORDER = 'sort_order'; const FRONTEND_LABEL = 'frontend_label'; const IS_SYSTEM = 'is_system'; + const NOTE = 'note'; /**#@-*/ /** @@ -187,6 +188,16 @@ class AttributeMetadata extends \Magento\Service\Entity\AbstractDto return $this->_get(self::FRONTEND_LABEL); } + /** + * Get the note attribute for the element. + * + * @return string + */ + public function getNote() + { + return $this->_get(self::NOTE); + } + /** * Whether this is a system attribute. * diff --git a/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadataBuilder.php b/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadataBuilder.php index b7e50da8ca2..8b0b1823c37 100644 --- a/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadataBuilder.php +++ b/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadataBuilder.php @@ -37,8 +37,8 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde } /** - * @param $attributeCode - * @return AttributeMetadataBuilder + * @param string $attributeCode + * @return $this */ public function setAttributeCode($attributeCode) { @@ -46,8 +46,8 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde } /** - * @param $frontendInput - * @return AttributeMetadataBuilder + * @param string $frontendInput + * @return $this */ public function setFrontendInput($frontendInput) { @@ -55,8 +55,8 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde } /** - * @param $inputFilter - * @return AttributeMetadataBuilder + * @param string $inputFilter + * @return $this */ public function setInputFilter($inputFilter) { @@ -64,8 +64,8 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde } /** - * @param $storeLabel - * @return AttributeMetadataBuilder + * @param string $storeLabel + * @return $this */ public function setStoreLabel($storeLabel) { @@ -74,7 +74,7 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde /** * @param string $validationRules - * @return AttributeMetadataBuilder + * @return $this */ public function setValidationRules($validationRules) { @@ -83,7 +83,7 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde /** * @param \Magento\Customer\Service\V1\Dto\Eav\Option[] $options - * @return AttributeMetadataBuilder + * @return $this */ public function setOptions($options) { @@ -92,7 +92,7 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde /** * @param boolean $visible - * @return AttributeMetadataBuilder + * @return $this */ public function setVisible($visible) { @@ -101,7 +101,7 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde /** * @param boolean $required - * @return AttributeMetadataBuilder + * @return $this */ public function setRequired($required) { @@ -111,7 +111,7 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde /** * @param int $count - * @return AttributeMetadataBuilder + * @return $this */ public function setMultilineCount($count) { @@ -120,7 +120,7 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde /** * @param string $dataModel - * @return AttributeMetadataBuilder + * @return $this */ public function setDataModel($dataModel) { @@ -128,8 +128,8 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde } /** - * @param $frontendClass - * @return AttributeMetadataBuilder + * @param string $frontendClass + * @return $this */ public function setFrontendClass($frontendClass) { @@ -138,7 +138,7 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde /** * @param bool $isUserDefined - * @return AttributeMetadataBuilder + * @return $this */ public function setIsUserDefined($isUserDefined) { @@ -147,7 +147,7 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde /** * @param int $sortOrder - * @return AttributeMetadataBuilder + * @return $this */ public function setSortOrder($sortOrder) { @@ -156,7 +156,7 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde /** * @param string $frontendLabel - * @return AttributeMetadataBuilder + * @return $this */ public function setFrontendLabel($frontendLabel) { @@ -165,10 +165,19 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde /** * @param bool $isSystem - * @return AttributeMetadataBuilder + * @return $this */ public function setIsSystem($isSystem) { return $this->_set(AttributeMetadata::IS_SYSTEM, $isSystem); } + + /** + * @param string $note + * @return $this + */ + public function setNote($note) + { + return $this->_set(AttributeMetadata::NOTE, $note); + } } diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index af77b9fdd88..1ecbe9710fc 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -34,6 +34,10 @@ type="Magento\Customer\Service\V1\CustomerAccountService" /> <preference for="Magento\Customer\Service\V1\CustomerMetadataServiceInterface" type="Magento\Customer\Service\V1\CustomerMetadataService" /> + <preference for="Magento\Customer\Service\V1\CustomerCurrentServiceInterface" + type="Magento\Customer\Service\V1\CustomerCurrentService" /> + <preference for="Magento\Customer\Service\V1\CustomerAddressCurrentServiceInterface" + type="Magento\Customer\Service\V1\CustomerAddressCurrentService" /> <type name="Magento\Customer\Model\Session"> <arguments> <argument name="configShare" xsi:type="object">Magento\Customer\Model\Config\Share\Proxy</argument> diff --git a/app/code/Magento/Customer/etc/frontend/di.xml b/app/code/Magento/Customer/etc/frontend/di.xml index 1747860ebbe..668e4b059c8 100644 --- a/app/code/Magento/Customer/etc/frontend/di.xml +++ b/app/code/Magento/Customer/etc/frontend/di.xml @@ -36,15 +36,7 @@ </argument> </arguments> </type> - <virtualType name="customerAccountInitSession" type="Magento\Core\App\Action\Plugin\Session"> - <arguments> - <argument name="cookieCheckActions" xsi:type="array"> - <item name="customerLogin" xsi:type="string">loginPost</item> - <item name="customerCreate" xsi:type="string">createpost</item> - </argument> - </arguments> - </virtualType> - <type name="Magento\Customer\Controller\Account"> - <plugin name="sessionInitializer" type="customerAccountInitSession" /> + <type name="Magento\Core\Model\Layout"> + <plugin name="customer-session-stab" type="Magento\Customer\Model\Layout\DepersonalizePlugin" sortOrder="20"/> </type> </config> diff --git a/app/code/Magento/Customer/etc/module.xml b/app/code/Magento/Customer/etc/module.xml index 01dff43e732..60d91680003 100755 --- a/app/code/Magento/Customer/etc/module.xml +++ b/app/code/Magento/Customer/etc/module.xml @@ -45,6 +45,7 @@ <module name="Magento_Review"/> <module name="Magento_Tax"/> <module name="Magento_Service"/> + <module name="Magento_PageCache"/> </depends> </module> </config> diff --git a/app/code/Magento/Customer/i18n/de_DE.csv b/app/code/Magento/Customer/i18n/de_DE.csv index 344eac5c4de..ffc2f13fe3a 100644 --- a/app/code/Magento/Customer/i18n/de_DE.csv +++ b/app/code/Magento/Customer/i18n/de_DE.csv @@ -176,7 +176,7 @@ "If there is an account associated with %s you will receive an email with a link to reset your password.","Wenn ein Konto mit %s verknüpft ist, erhalten Sie eine E-Mail mit einem Link für das Resetten Ihres Passworts." "If you are a registered VAT customer, please click <a href=""%s"">here</a> to enter you billing address for proper VAT calculation","Wenn sie mit ihrer Umsatzsteuer-Identifikationsnummer bei uns registriert sind, klicken sie bitte auf <a href=""%s"">here</a> und geben sie dort ihre Rechnungsanschrift zur korrekten Berechnung der Umsatzsteuer an." "If you are a registered VAT customer, please click <a href=""%s"">here</a> to enter you shipping address for proper VAT calculation","Wenn sie mit ihrer Umsatzsteuer-Identifikationsnummer bei uns registriert sind, klicken sie bitte auf <a href=""%s"">here</a> und geben sie dort ihre Lieferanschrift zur korrekten Berechnung der Umsatzsteuer an." -"If you believe this is an error, please contact us at %s","Sollte ihrer Meinung nach ein Fehler vorliegen, wenden sie sich bitte an uns unter %s" +"If you believe this is an error, please contact us at %1","Sollte ihrer Meinung nach ein Fehler vorliegen, wenden sie sich bitte an uns unter %1" "If you have an account with us, please log in.","Wenn Sie bei uns ein Benutzerkonto besitzen, melden Sie sich bitte an." "Invalid attribute option specified for attribute %s (%s), skipping the record.","Ungültige Option für Attribut %s definiert (%s), Eintrag wird übersprungen." "Invalid attribute set specified, skipping the record.","Ungültiges Attributset definiert, Eintrag wird übersprungen." diff --git a/app/code/Magento/Customer/i18n/en_US.csv b/app/code/Magento/Customer/i18n/en_US.csv index 01e4f152891..5d1ed670f52 100644 --- a/app/code/Magento/Customer/i18n/en_US.csv +++ b/app/code/Magento/Customer/i18n/en_US.csv @@ -176,7 +176,7 @@ "If there is an account associated with %s you will receive an email with a link to reset your password.","If there is an account associated with %s you will receive an email with a link to reset your password." "If you are a registered VAT customer, please click <a href=""%s"">here</a> to enter you billing address for proper VAT calculation","If you are a registered VAT customer, please click <a href=""%s"">here</a> to enter you billing address for proper VAT calculation" "If you are a registered VAT customer, please click <a href=""%s"">here</a> to enter you shipping address for proper VAT calculation","If you are a registered VAT customer, please click <a href=""%s"">here</a> to enter you shipping address for proper VAT calculation" -"If you believe this is an error, please contact us at %s","If you believe this is an error, please contact us at %s" +"If you believe this is an error, please contact us at %1","If you believe this is an error, please contact us at %1" "If you have an account with us, please log in.","If you have an account with us, please log in." "Invalid attribute option specified for attribute %s (%s), skipping the record.","Invalid attribute option specified for attribute %s (%s), skipping the record." "Invalid attribute set specified, skipping the record.","Invalid attribute set specified, skipping the record." diff --git a/app/code/Magento/Customer/i18n/es_ES.csv b/app/code/Magento/Customer/i18n/es_ES.csv index 3cb0ed4b195..90db731c30f 100644 --- a/app/code/Magento/Customer/i18n/es_ES.csv +++ b/app/code/Magento/Customer/i18n/es_ES.csv @@ -176,7 +176,7 @@ "If there is an account associated with %s you will receive an email with a link to reset your password.","Si hay una cuenta asociada con %s recibirás un correo electrónico con un enlace para reiniciar tu contraseña." "If you are a registered VAT customer, please click <a href=""%s"">here</a> to enter you billing address for proper VAT calculation","Si es un cliente registrado de IVA, por favor pulse <a href=""%s"">aquÃ</a> para introducir su dirección de facturación para un cálculo correcto del IVA" "If you are a registered VAT customer, please click <a href=""%s"">here</a> to enter you shipping address for proper VAT calculation","Si es un cliente registrado de IVA, por favor pulse <a href=""%s"">aquÃ</a> para introducir su dirección de envÃo para un cálculo correcto del IVA" -"If you believe this is an error, please contact us at %s","Si cree que es un error, por favor, contacte con nosotros en %s" +"If you believe this is an error, please contact us at %1","Si cree que es un error, por favor, contacte con nosotros en %1" "If you have an account with us, please log in.","Si usted tiene una cuenta con nosotros, por favor ingrese." "Invalid attribute option specified for attribute %s (%s), skipping the record.","Se especificó una opción de atributo no válida para el atributo %s (%s). Se omitirá el registro." "Invalid attribute set specified, skipping the record.","Se especificó un conjunto de atributos no válido. Se omitirá el registro." diff --git a/app/code/Magento/Customer/i18n/fr_FR.csv b/app/code/Magento/Customer/i18n/fr_FR.csv index 1e0b8ec9982..db7052701e8 100644 --- a/app/code/Magento/Customer/i18n/fr_FR.csv +++ b/app/code/Magento/Customer/i18n/fr_FR.csv @@ -176,7 +176,7 @@ "If there is an account associated with %s you will receive an email with a link to reset your password.","S'il y a un compte associé à %s, vous recevrez un courriel contenant un lien pour réinitialiser votre mot de passe." "If you are a registered VAT customer, please click <a href=""%s"">here</a> to enter you billing address for proper VAT calculation","Si vous êtes un client assujetti à la TVA enregistré, veuillez cliquer <a href=""%s"">ici</a> pour saisir votre adresse de facturation afin de calculer la TVA exacte" "If you are a registered VAT customer, please click <a href=""%s"">here</a> to enter you shipping address for proper VAT calculation","Si vous êtes un client assujetti à la TVA enregistré, veuillez cliquer <a href=""%s"">ici</a> pour saisir votre adresse de livraison afin de calculer la TVA exacte" -"If you believe this is an error, please contact us at %s","Si vous pensez qu'il s'agit d'une erreur, veuillez nous contacter au %s" +"If you believe this is an error, please contact us at %1","Si vous pensez qu'il s'agit d'une erreur, veuillez nous contacter au %1" "If you have an account with us, please log in.","Si vous avez un compte chez nous, identifiez-vous." "Invalid attribute option specified for attribute %s (%s), skipping the record.","Option d'attribut invalide spécifiée pour l'attribut %s (%s), enregistrement sauté." "Invalid attribute set specified, skipping the record.","Ensemble d'attributs spécifiés invalide, enregistrement sauté." diff --git a/app/code/Magento/Customer/i18n/nl_NL.csv b/app/code/Magento/Customer/i18n/nl_NL.csv index 1ada79004ea..1fd9221d659 100644 --- a/app/code/Magento/Customer/i18n/nl_NL.csv +++ b/app/code/Magento/Customer/i18n/nl_NL.csv @@ -176,7 +176,7 @@ "If there is an account associated with %s you will receive an email with a link to reset your password.","Als er een rekening geassocieerd is met %s ontvangt u een email met een link om uw wachtwoord te herstellen." "If you are a registered VAT customer, please click <a href=""%s"">here</a> to enter you billing address for proper VAT calculation","Als u een BTW geregistreerde klant bent, klik aub <a href=""%s"">here</a> om uw factuur adres in te voeren voor de juiste BTW berekening" "If you are a registered VAT customer, please click <a href=""%s"">here</a> to enter you shipping address for proper VAT calculation","Als u een BTW geregistreerde klant bent, klik aub <a href=""%s"">here</a> om uw post adres in te voeren voor de juiste BTW berekening" -"If you believe this is an error, please contact us at %s","Als u gelooft dat fit een fout is, contacteer ons dan aub via %s" +"If you believe this is an error, please contact us at %1","Als u gelooft dat fit een fout is, contacteer ons dan aub via %1" "If you have an account with us, please log in.","Als u een account bij ons heeft, logt u dan alstublieft in." "Invalid attribute option specified for attribute %s (%s), skipping the record.","Onjuist attribuut optie gekozen voor attribuut %s (%s), record wordt overgeslagen." "Invalid attribute set specified, skipping the record.","Ongeldige reeks kenmerken gespecificeerd, vermelding wordt overgeslagen" diff --git a/app/code/Magento/Customer/i18n/pt_BR.csv b/app/code/Magento/Customer/i18n/pt_BR.csv index 1a5d01fb5c9..33e8c1c08cc 100644 --- a/app/code/Magento/Customer/i18n/pt_BR.csv +++ b/app/code/Magento/Customer/i18n/pt_BR.csv @@ -176,7 +176,7 @@ "If there is an account associated with %s you will receive an email with a link to reset your password.","Se houver uma conta associada a %s você receberá um email com um link para reconfigurar a sua senha." "If you are a registered VAT customer, please click <a href=""%s"">here</a> to enter you billing address for proper VAT calculation","Se você é um cliente com VAT registrado, por favor, clique em <a href=""%s"">here</a> para inserir o seu endereço de cobrança para cálculo de VAT." "If you are a registered VAT customer, please click <a href=""%s"">here</a> to enter you shipping address for proper VAT calculation","Se você é um cliente com VAT registrado, por favor, clique em <a href=""%s"">here</a> para inserir o seu endereço de envio para cálculo de VAT." -"If you believe this is an error, please contact us at %s","Se você considera isso um erro, entre em contato conosco em %s" +"If you believe this is an error, please contact us at %1","Se você considera isso um erro, entre em contato conosco em %1" "If you have an account with us, please log in.","Se você possui uma conta conosco, por favor, faça seu login" "Invalid attribute option specified for attribute %s (%s), skipping the record.","Opção de atributo inválida para atributo %s (%s). Saltando o registro." "Invalid attribute set specified, skipping the record.","Conjunto especificado de atributo inválido, ignorando o registro." diff --git a/app/code/Magento/Customer/view/adminhtml/edit/tab/account/form/renderer/group.phtml b/app/code/Magento/Customer/view/adminhtml/edit/tab/account/form/renderer/group.phtml index b0564362e22..d754c13582b 100644 --- a/app/code/Magento/Customer/view/adminhtml/edit/tab/account/form/renderer/group.phtml +++ b/app/code/Magento/Customer/view/adminhtml/edit/tab/account/form/renderer/group.phtml @@ -25,6 +25,7 @@ */ ?> <?php +/** @var \Magento\Customer\Block\Adminhtml\Edit\Renderer\Attribute\Group $this */ $_element = $this->getElement(); $_note = $_element->getNote(); $_class = $_element->getFieldsetHtmlClass();?> diff --git a/app/code/Magento/Customer/view/adminhtml/tab/addresses.phtml b/app/code/Magento/Customer/view/adminhtml/tab/addresses.phtml index e14743187ee..42aefe9db85 100644 --- a/app/code/Magento/Customer/view/adminhtml/tab/addresses.phtml +++ b/app/code/Magento/Customer/view/adminhtml/tab/addresses.phtml @@ -85,17 +85,17 @@ <?php endif;?> <address> - <?php echo $_address->format('html') ?> + <?php echo $this->format($_address, 'html') ?> </address> </a> <div class="field field-address-item-billing choice"> - <input type="checkbox" <?php if ($this->isReadonly()):?> disabled="disabled"<?php endif;?> value="<?php echo $_address->getId() ?>" id="address_item_billing<?php echo $_address->getId() ?>" name="account[default_billing]" title="<?php echo __('Set as Default Billing Address') ?>"<?php if($_address->getId()==$customer->getDefaultBilling()): ?> checked="checked"<?php endif; ?> /> + <input type="checkbox" <?php if ($this->isReadonly()):?> disabled="disabled"<?php endif;?> value="<?php echo $_address->getId() ?>" id="address_item_billing<?php echo $_address->getId() ?>" name="account[default_billing]" title="<?php echo __('Set as Default Billing Address') ?>"<?php if($_address->isDefaultBilling()): ?> checked="checked"<?php endif; ?> /> <label class="label" for="address_item_billing<?php echo $_address->getId() ?>"> <span><?php echo __('Default Billing Address') ?></span> </label> </div> <div class="field field-address-item-shipping choice"> - <input type="checkbox" <?php if ($this->isReadonly()):?> disabled="disabled"<?php endif;?> value="<?php echo $_address->getId() ?>" id="address_item_shipping<?php echo $_address->getId() ?>" name="account[default_shipping]" title="<?php echo __('Set as Default Shipping Address') ?>"<?php if($_address->getId()==$customer->getDefaultShipping()): ?> checked="checked"<?php endif; ?> /> + <input type="checkbox" <?php if ($this->isReadonly()):?> disabled="disabled"<?php endif;?> value="<?php echo $_address->getId() ?>" id="address_item_shipping<?php echo $_address->getId() ?>" name="account[default_shipping]" title="<?php echo __('Set as Default Shipping Address') ?>"<?php if($_address->isDefaultShipping()): ?> checked="checked"<?php endif; ?> /> <label class="label" for="address_item_shipping<?php echo $_address->getId() ?>"> <span><?php echo __('Default Shipping Address') ?></span> </label> @@ -164,7 +164,7 @@ <?php foreach ($addressCollection as $_address): ?> <div class="address-item-edit-content" id="form_address_item_<?php echo $_address->getId() ?>" data-item="<?php echo $_address->getId() ?>" style="display:none" data-mage-init='{"observableInputs": {"name": "address_item_<?php echo $_address->getId() ?>"}}'> <?php - $this->getForm()->addValues($_address->getData()) + $this->getForm()->addValues($_address->getAttributes()) ->setHtmlIdPrefix("_item{$_address->getId()}") ->setFieldNameSuffix('address['.$_address->getId().']'); $this->addValuesToNamePrefixElement($_address->getPrefix()) diff --git a/app/code/Magento/Customer/view/adminhtml/tab/cart.phtml b/app/code/Magento/Customer/view/adminhtml/tab/cart.phtml index 6ee5d0dff5c..759ae101af5 100644 --- a/app/code/Magento/Customer/view/adminhtml/tab/cart.phtml +++ b/app/code/Magento/Customer/view/adminhtml/tab/cart.phtml @@ -80,7 +80,7 @@ <?php $params = array( - 'customer_id' => $this->getCustomer()->getId(), + 'customer_id' => $this->getCustomerId(), 'website_id' => $this->getWebsiteId() ); ?> diff --git a/app/code/Magento/Customer/view/frontend/account/link/authorization.phtml b/app/code/Magento/Customer/view/frontend/account/link/authorization.phtml index b40d300c45a..12fd88e6a20 100644 --- a/app/code/Magento/Customer/view/frontend/account/link/authorization.phtml +++ b/app/code/Magento/Customer/view/frontend/account/link/authorization.phtml @@ -22,10 +22,15 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ + +/** @var $this \Magento\Customer\Block\Account\AuthorizationLink */ +$dataPostParam = ''; +if ($this->isLoggedIn()) { + $dataPostParam = sprintf(" data-post='%s'", $this->getPostParams()); +} ?> <li> - <?php /** @var $this \Magento\Customer\Block\Account\AuthorizationLink */?> - <a <?php if ($this->isLoggedIn()) {echo "data-post='" . $this->getPostParams(); } ?>' <?php echo $this->getLinkAttributes(); ?> > + <a <?php echo $this->getLinkAttributes(); ?><?php echo $dataPostParam; ?>> <?php echo $this->escapeHtml($this->getLabel()); ?> </a> -</li> +</li> \ No newline at end of file diff --git a/app/code/Magento/Customer/view/frontend/form/edit.phtml b/app/code/Magento/Customer/view/frontend/form/edit.phtml old mode 100644 new mode 100755 index 96f462a5400..d4a80b7b0e8 --- a/app/code/Magento/Customer/view/frontend/form/edit.phtml +++ b/app/code/Magento/Customer/view/frontend/form/edit.phtml @@ -49,7 +49,7 @@ <?php echo $_gender->setGender($this->getCustomer()->getGender())->toHtml() ?> <?php endif ?> <div class="field choice"> - <input type="checkbox" name="change_password" id="change-password" value="1" title="<?php echo __('Change Password') ?>"<?php if($this->getCustomer()->getChangePassword()==1): ?> checked="checked"<?php endif; ?> class="checkbox"> + <input type="checkbox" name="change_password" id="change-password" value="1" title="<?php echo __('Change Password') ?>"<?php if($this->getChangePassword()): ?> checked="checked"<?php endif; ?> class="checkbox"/> <label class="label" for="change-password"><span><?php echo __('Change Password') ?></span></label> </div> </fieldset> @@ -101,7 +101,7 @@ passwordId: '#password', confirmationId: '#confirmation', passwordContainer: 'fieldset.fieldset.password', - showOnDefault: <?php echo $this->getCustomer()->getChangePassword() ? 'true' : 'false' ?> + showOnDefault: <?php echo $this->getChangePassword() ? 'true' : 'false' ?> }); var dataForm = $('#form-validate'), ignore; <?php if ($_dob->isEnabled()): ?> diff --git a/app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml b/app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml index 3bc8732cff0..4108a87af21 100644 --- a/app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml +++ b/app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml @@ -34,5 +34,12 @@ <container name="form.additional.info" label="invisible" as="form_additional_info"/> <container name="customer.form.register.fields.before" as="form_fields_before" label="Form Fields Before" htmlTag="div" htmlClass="customer-form-before"/> </block> + <block class="Magento\Core\Block\RequireCookie" name="require-cookie" template="Magento_Core::require_cookie.phtml"> + <arguments> + <argument name="triggers" xsi:type="array"> + <item name="registerSubmitButton" xsi:type="string">.action.submit</item> + </argument> + </arguments> + </block> </referenceContainer> </layout> diff --git a/app/code/Magento/Customer/view/frontend/layout/customer_account_login.xml b/app/code/Magento/Customer/view/frontend/layout/customer_account_login.xml index cb929cf5746..3113cb4bd83 100644 --- a/app/code/Magento/Customer/view/frontend/layout/customer_account_login.xml +++ b/app/code/Magento/Customer/view/frontend/layout/customer_account_login.xml @@ -37,5 +37,12 @@ </block> <block class="Magento\Customer\Block\Form\Login" name="customer.new" template="newcustomer.phtml" cacheable="false"/> </container> + <block class="Magento\Core\Block\RequireCookie" name="require-cookie" template="Magento_Core::require_cookie.phtml"> + <arguments> + <argument name="triggers" xsi:type="array"> + <item name="loginButton" xsi:type="string">.action.login</item> + </argument> + </arguments> + </block> </referenceContainer> </layout> diff --git a/app/code/Magento/Customer/view/frontend/layout/default.xml b/app/code/Magento/Customer/view/frontend/layout/default.xml index 54ca9840005..42b657cdfef 100644 --- a/app/code/Magento/Customer/view/frontend/layout/default.xml +++ b/app/code/Magento/Customer/view/frontend/layout/default.xml @@ -25,16 +25,16 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceBlock name="top.links"> - <block class="Magento\Customer\Block\Account\Link" name="my-account-link" cacheable="false"> + <block class="Magento\Customer\Block\Account\Link" name="my-account-link"> <arguments> <argument name="label" xsi:type="string">My Account</argument> </arguments> </block> - <block class="Magento\Customer\Block\Account\RegisterLink" name="register-link" cacheable="false"> + <block class="Magento\Customer\Block\Account\RegisterLink" name="register-link"> <arguments> <argument name="label" xsi:type="string">Register</argument> </arguments> </block> - <block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link" template="account/link/authorization.phtml" cacheable="false"/> + <block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link" template="account/link/authorization.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Customer/view/frontend/widget/gender.phtml b/app/code/Magento/Customer/view/frontend/widget/gender.phtml index b03a5f12923..d6cb55787fe 100644 --- a/app/code/Magento/Customer/view/frontend/widget/gender.phtml +++ b/app/code/Magento/Customer/view/frontend/widget/gender.phtml @@ -30,7 +30,7 @@ <?php $options = $this->getGenderOptions(); ?> <?php $value = $this->getGender();?> <?php foreach ($options as $option):?> - <option value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $value) echo ' selected="selected"' ?>><?php echo $option['label'] ?></option> + <option value="<?php echo $option->getValue() ?>"<?php if ($option->getValue() == $value) echo ' selected="selected"' ?>><?php echo $option->getLabel() ?></option> <?php endforeach;?> </select> </div> diff --git a/app/code/Magento/Customer/view/frontend/widget/name.phtml b/app/code/Magento/Customer/view/frontend/widget/name.phtml index ae0a97705a5..6d4bdacebc6 100644 --- a/app/code/Magento/Customer/view/frontend/widget/name.phtml +++ b/app/code/Magento/Customer/view/frontend/widget/name.phtml @@ -66,12 +66,12 @@ $suffix = $this->showSuffix(); name="<?php echo $this->getFieldName('prefix') ?>" value="<?php echo $this->escapeHtml($this->getObject()->getPrefix()) ?>" title="<?php echo $this->getStoreLabel('prefix') ?>" - class="input-text <?php echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('prefix') ?>" <?php echo $this->getFieldParams() ?> <?php if ($this->isPrefixRequired()) echo ' data-validate="{required:true}"' ?>> + class="input-text <?php echo $this->getAttributeValidationClass('prefix') ?>" <?php echo $this->getFieldParams() ?> <?php if ($this->isPrefixRequired()) echo ' data-validate="{required:true}"' ?>> <?php else: ?> <select id="<?php echo $this->getFieldId('prefix') ?>" name="<?php echo $this->getFieldName('prefix') ?>" title="<?php echo $this->getStoreLabel('prefix') ?>" - class="<?php echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('prefix') ?>" <?php echo $this->getFieldParams() ?> <?php if ($this->isPrefixRequired()) echo ' data-validate="{required:true}"' ?> > + class="<?php echo $this->getAttributeValidationClass('prefix') ?>" <?php echo $this->getFieldParams() ?> <?php if ($this->isPrefixRequired()) echo ' data-validate="{required:true}"' ?> > <?php foreach ($this->getPrefixOptions() as $_option): ?> <option value="<?php echo $_option ?>"<?php if ($this->getObject()->getPrefix() == $_option): ?> selected="selected"<?php endif; ?>> <?php echo __($_option) ?> @@ -92,7 +92,7 @@ $suffix = $this->showSuffix(); name="<?php echo $this->getFieldName('firstname') ?>" value="<?php echo $this->escapeHtml($this->getObject()->getFirstname()) ?>" title="<?php echo $this->getStoreLabel('firstname') ?>" - class="input-text <?php echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('firstname') ?>" <?php echo $this->getFieldParams() ?> <?php if ($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('firstname') == 'required-entry') echo ' data-validate="{required:true}"' ?>> + class="input-text <?php echo $this->getAttributeValidationClass('firstname') ?>" <?php echo $this->getFieldParams() ?> <?php if ($this->getAttributeValidationClass('firstname') == 'required-entry') echo ' data-validate="{required:true}"' ?>> </div> </div> <?php if ($middle): ?> @@ -107,7 +107,7 @@ $suffix = $this->showSuffix(); name="<?php echo $this->getFieldName('middlename') ?>" value="<?php echo $this->escapeHtml($this->getObject()->getMiddlename()) ?>" title="<?php echo $this->getStoreLabel('middlename') ?>" - class="input-text <?php echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('middlename') ?>" <?php echo $this->getFieldParams() ?> <?php echo $isMiddlenameRequired ? ' data-validate="{required:true}"' : '' ?>> + class="input-text <?php echo $this->getAttributeValidationClass('middlename') ?>" <?php echo $this->getFieldParams() ?> <?php echo $isMiddlenameRequired ? ' data-validate="{required:true}"' : '' ?>> </div> </div> <?php endif; ?> @@ -121,7 +121,7 @@ $suffix = $this->showSuffix(); name="<?php echo $this->getFieldName('lastname') ?>" value="<?php echo $this->escapeHtml($this->getObject()->getLastname()) ?>" title="<?php echo $this->getStoreLabel('lastname') ?>" - class="input-text <?php echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('lastname') ?>" <?php echo $this->getFieldParams() ?> <?php if ($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('lastname') == 'required-entry') echo ' data-validate="{required:true}"' ?>> + class="input-text <?php echo $this->getAttributeValidationClass('lastname') ?>" <?php echo $this->getFieldParams() ?> <?php if ($this->getAttributeValidationClass('lastname') == 'required-entry') echo ' data-validate="{required:true}"' ?>> </div> </div> <?php if ($suffix): ?> @@ -136,12 +136,12 @@ $suffix = $this->showSuffix(); name="<?php echo $this->getFieldName('suffix') ?>" value="<?php echo $this->escapeHtml($this->getObject()->getSuffix()) ?>" title="<?php echo $this->getStoreLabel('suffix') ?>" - class="input-text <?php echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('suffix') ?>" <?php echo $this->getFieldParams() ?> <?php if ($this->isSuffixRequired()) echo ' data-validate="{required:true}"' ?>> + class="input-text <?php echo $this->getAttributeValidationClass('suffix') ?>" <?php echo $this->getFieldParams() ?> <?php if ($this->isSuffixRequired()) echo ' data-validate="{required:true}"' ?>> <?php else: ?> <select id="<?php echo $this->getFieldId('suffix') ?>" name="<?php echo $this->getFieldName('suffix') ?>" title="<?php echo $this->getStoreLabel('suffix') ?>" - class="<?php echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('suffix') ?>" <?php echo $this->getFieldParams() ?> <?php if ($this->isSuffixRequired()) echo ' data-validate="{required:true}"' ?>> + class="<?php echo $this->getAttributeValidationClass('suffix') ?>" <?php echo $this->getFieldParams() ?> <?php if ($this->isSuffixRequired()) echo ' data-validate="{required:true}"' ?>> <?php foreach ($this->getSuffixOptions() as $_option): ?> <option value="<?php echo $_option ?>"<?php if ($this->getObject()->getSuffix() == $_option): ?> selected="selected"<?php endif; ?>> <?php echo __($_option) ?> diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Edit.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Edit.php index 6cba0c34a5f..df10b04afe0 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Edit.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Edit.php @@ -169,7 +169,7 @@ class Edit { $sourceChange = $this->_changeFactory->create(); $sourceChange->loadByThemeId($this->_themeContext->getEditableTheme()->getId()); - $dateMessage = $this->_locale + $dateMessage = $this->_localeDate ->date($sourceChange->getChangeTime(), \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT)->toString(); $message = __('Do you want to restore the version saved at %1?', $dateMessage); diff --git a/app/code/Magento/DesignEditor/Model/Plugin/ThemeCopyService.php b/app/code/Magento/DesignEditor/Model/Plugin/ThemeCopyService.php index 97f44b6388e..d773f394497 100644 --- a/app/code/Magento/DesignEditor/Model/Plugin/ThemeCopyService.php +++ b/app/code/Magento/DesignEditor/Model/Plugin/ThemeCopyService.php @@ -23,7 +23,6 @@ */ namespace Magento\DesignEditor\Model\Plugin; -use Magento\Code\Plugin\InvocationChain; class ThemeCopyService { @@ -43,27 +42,31 @@ class ThemeCopyService /** * Copy additional information about theme change time * - * @param array $methodArguments - * @param InvocationChain $invocationChain + * @param \Magento\Theme\Model\CopyService $subject + * @param callable $proceed + * @param \Magento\View\Design\ThemeInterface $source + * @param \Magento\View\Design\ThemeInterface $target + * * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundCopy(array $methodArguments, InvocationChain $invocationChain) - { - $invocationChain->proceed($methodArguments); - - /** @var $sourceTheme \Magento\Core\Model\Theme|null */ - /** @var $targetTheme \Magento\Core\Model\Theme|null */ - list($sourceTheme, $targetTheme) = $methodArguments; - if ($sourceTheme && $targetTheme) { + public function aroundCopy( + \Magento\Theme\Model\CopyService $subject, + \Closure $proceed, + \Magento\View\Design\ThemeInterface $source, + \Magento\View\Design\ThemeInterface $target + ) { + $proceed($source, $target); + if ($source && $target) { /** @var $sourceChange \Magento\DesignEditor\Model\Theme\Change */ $sourceChange = $this->_themeChangeFactory->create(); - $sourceChange->loadByThemeId($sourceTheme->getId()); + $sourceChange->loadByThemeId($source->getId()); /** @var $targetChange \Magento\DesignEditor\Model\Theme\Change */ $targetChange = $this->_themeChangeFactory->create();; - $targetChange->loadByThemeId($targetTheme->getId()); + $targetChange->loadByThemeId($target->getId()); if ($sourceChange->getId()) { - $targetChange->setThemeId($targetTheme->getId()); + $targetChange->setThemeId($target->getId()); $targetChange->setChangeTime($sourceChange->getChangeTime()); $targetChange->save(); } elseif ($targetChange->getId()) { diff --git a/app/code/Magento/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php b/app/code/Magento/Dhl/Block/Adminhtml/Unitofmeasure.php similarity index 77% rename from app/code/Magento/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php rename to app/code/Magento/Dhl/Block/Adminhtml/Unitofmeasure.php index 82e0a76c800..733231d0e9a 100644 --- a/app/code/Magento/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php +++ b/app/code/Magento/Dhl/Block/Adminhtml/Unitofmeasure.php @@ -18,50 +18,42 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Dhl\Block\Adminhtml; /** * Frontend model for DHL shipping methods for documentation - * - * @category Magento - * @package Magento_Usa - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Usa\Block\Adminhtml\Dhl; - class Unitofmeasure extends \Magento\Backend\Block\System\Config\Form\Field { - /** - * Usa data + * Carrier helper * - * @var \Magento\Usa\Helper\Data + * @var \Magento\Shipping\Helper\Carrier */ - protected $_usaData = null; + protected $_carrierHelper; /** - * @var \Magento\Usa\Model\Shipping\Carrier\Dhl\International + * @var \Magento\Dhl\Model\Carrier */ - protected $_shippingDhl; + protected $carrierDhl; /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Usa\Model\Shipping\Carrier\Dhl\International $shippingDhl - * @param \Magento\Usa\Helper\Data $usaData + * @param \Magento\Dhl\Model\Carrier $carrierDhl + * @param \Magento\Shipping\Helper\Carrier $carrierHelper * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Usa\Model\Shipping\Carrier\Dhl\International $shippingDhl, - \Magento\Usa\Helper\Data $usaData, + \Magento\Dhl\Model\Carrier $carrierDhl, + \Magento\Shipping\Helper\Carrier $carrierHelper, array $data = array() ) { - $this->_shippingDhl = $shippingDhl; - $this->_usaData = $usaData; + $this->carrierDhl = $carrierDhl; + $this->_carrierHelper = $carrierHelper; parent::__construct($context, $data); } @@ -74,7 +66,7 @@ class Unitofmeasure extends \Magento\Backend\Block\System\Config\Form\Field { parent::_construct(); - $carrierModel = $this->_shippingDhl; + $carrierModel = $this->carrierDhl; $this->setInch($this->escapeJsQuote($carrierModel->getCode('unit_of_dimension_cut', 'I'))); $this->setCm($this->escapeJsQuote($carrierModel->getCode('unit_of_dimension_cut', 'C'))); @@ -90,14 +82,14 @@ class Unitofmeasure extends \Magento\Backend\Block\System\Config\Form\Field ); $weight = round( - $this->_usaData->convertMeasureWeight( + $this->_carrierHelper->convertMeasureWeight( $kgWeight, \Zend_Measure_Weight::KILOGRAM, \Zend_Measure_Weight::POUND), 3); $this->setDivideOrderWeightNoteLbp( $this->escapeJsQuote(__('This allows breaking total order weight into smaller pieces if it exceeds %1 %2 to ensure accurate calculation of shipping charges.', $weight, 'pounds')) ); - $this->setTemplate('dhl/unitofmeasure.phtml'); + $this->setTemplate('unitofmeasure.phtml'); } /** diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/AbstractDhl.php b/app/code/Magento/Dhl/Model/AbstractDhl.php similarity index 85% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/AbstractDhl.php rename to app/code/Magento/Dhl/Model/AbstractDhl.php index 594959c758c..3d330e912b0 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/AbstractDhl.php +++ b/app/code/Magento/Dhl/Model/AbstractDhl.php @@ -18,15 +18,14 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Dhl\Model; -namespace Magento\Usa\Model\Shipping\Carrier\Dhl; +use Magento\Shipping\Model\Carrier\AbstractCarrierOnline; -abstract class AbstractDhl extends \Magento\Usa\Model\Shipping\Carrier\AbstractCarrier +abstract class AbstractDhl extends AbstractCarrierOnline { /** * Response condition code for service is unavailable at the requested date @@ -46,13 +45,12 @@ abstract class AbstractDhl extends \Magento\Usa\Model\Shipping\Carrier\AbstractC /** * Get shipping date * - * @param bool $domestic * @return string */ - protected function _getShipDate($domestic = true) + protected function _getShipDate() { return $this->_determineShippingDay( - $this->getConfigData($domestic ? 'shipment_days' : 'intl_shipment_days'), + $this->getConfigData('shipment_days'), date(self::REQUEST_DATE_FORMAT) ); } diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International.php b/app/code/Magento/Dhl/Model/Carrier.php similarity index 97% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International.php rename to app/code/Magento/Dhl/Model/Carrier.php index ee3cce06b3e..5d807c8efa4 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -18,15 +18,12 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier\Dhl; +namespace Magento\Dhl\Model; -use Magento\Catalog\Model\Product\Type; use Magento\Sales\Model\Order\Shipment; use Magento\Sales\Model\Quote\Address\RateRequest; use Magento\Sales\Model\Quote\Address\RateResult\Error; @@ -36,8 +33,8 @@ use Magento\Shipping\Model\Rate\Result; /** * DHL International (API v1.4) */ -class International - extends \Magento\Usa\Model\Shipping\Carrier\Dhl\AbstractDhl +class Carrier + extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shipping\Model\Carrier\CarrierInterface { /** @@ -62,7 +59,7 @@ class International /** * Code of the carrier */ - const CODE = 'dhlint'; + const CODE = 'dhl'; /** * Rate request data @@ -88,7 +85,7 @@ class International /** * Countries parameters data * - * @var \Magento\Usa\Model\Simplexml\Element|null + * @var \Magento\Shipping\Model\Simplexml\Element|null */ protected $_countryParams = null; @@ -166,14 +163,14 @@ class International protected $string; /** - * Usa data + * Carrier helper * - * @var \Magento\Usa\Helper\Data + * @var \Magento\Shipping\Helper\Carrier */ - protected $_usaData; + protected $_carrierHelper; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_coreDate; @@ -213,7 +210,7 @@ class International * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory * @param \Magento\Logger\AdapterFactory $logAdapterFactory - * @param \Magento\Usa\Model\Simplexml\ElementFactory $xmlElFactory + * @param \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory * @param \Magento\Shipping\Model\Rate\ResultFactory $rateFactory * @param \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory * @param \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory @@ -223,8 +220,8 @@ class International * @param \Magento\Directory\Model\CountryFactory $countryFactory * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Directory\Helper\Data $directoryData - * @param \Magento\Usa\Helper\Data $usaData - * @param \Magento\Core\Model\Date $coreDate + * @param \Magento\Shipping\Helper\Carrier $carrierHelper + * @param \Magento\Stdlib\DateTime\DateTime $coreDate * @param \Magento\Module\Dir\Reader $configReader * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Stdlib\String $string @@ -238,7 +235,7 @@ class International \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Magento\Logger\AdapterFactory $logAdapterFactory, - \Magento\Usa\Model\Simplexml\ElementFactory $xmlElFactory, + \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateFactory, \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory, @@ -248,8 +245,8 @@ class International \Magento\Directory\Model\CountryFactory $countryFactory, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Directory\Helper\Data $directoryData, - \Magento\Usa\Helper\Data $usaData, - \Magento\Core\Model\Date $coreDate, + \Magento\Shipping\Helper\Carrier $carrierHelper, + \Magento\Stdlib\DateTime\DateTime $coreDate, \Magento\Module\Dir\Reader $configReader, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Stdlib\String $string, @@ -260,7 +257,7 @@ class International array $data = array() ) { $this->modulesDirectory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::MODULES_DIR); - $this->_usaData = $usaData; + $this->_carrierHelper = $carrierHelper; $this->_coreDate = $coreDate; $this->_storeManager = $storeManager; $this->_configReader = $configReader; @@ -689,7 +686,7 @@ class International $countryWeightUnit = $this->getCode('dimensions_variables', $this->_getWeightUnit()); if ($configWeightUnit != $countryWeightUnit) { - $weight = $this->_usaData->convertMeasureWeight( + $weight = $this->_carrierHelper->convertMeasureWeight( round($weight, 3), $configWeightUnit, $countryWeightUnit @@ -710,7 +707,7 @@ class International $fullItems = array(); foreach ($allItems as $item) { - if ($item->getProductType() == Type::TYPE_BUNDLE + if ($item->getProductType() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE && $item->getProduct()->getShipmentType() ) { continue; @@ -731,7 +728,9 @@ class International } $itemWeight = $item->getWeight(); - if ($item->getIsQtyDecimal() && $item->getProductType() != Type::TYPE_BUNDLE) { + if ($item->getIsQtyDecimal() + && $item->getProductType() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE + ) { $stockItem = $item->getProduct()->getStockItem(); if ($stockItem->getIsDecimalDivided()) { if ($stockItem->getEnableQtyIncrements() && $stockItem->getQtyIncrements()) { @@ -761,7 +760,7 @@ class International } if ($changeQty && !$item->getParentItem() && $item->getIsQtyDecimal() - && $item->getProductType() != Type::TYPE_BUNDLE + && $item->getProductType() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE ) { $qty = 1; } @@ -784,10 +783,10 @@ class International /** * Make pieces * - * @param \Magento\Usa\Model\Simplexml\Element $nodeBkgDetails + * @param \Magento\Shipping\Model\Simplexml\Element $nodeBkgDetails * @return void */ - protected function _makePieces(\Magento\Usa\Model\Simplexml\Element $nodeBkgDetails) + protected function _makePieces(\Magento\Shipping\Model\Simplexml\Element $nodeBkgDetails) { $divideOrderWeight = (string)$this->getConfigData('divide_order_weight'); $nodePieces = $nodeBkgDetails->addChild('Pieces', '', ''); @@ -876,7 +875,7 @@ class International $countryDimensionUnit = $this->getCode('dimensions_variables', $this->_getDimensionUnit()); if ($configDimensionUnit != $countryDimensionUnit) { - $dimension = $this->_usaData->convertMeasureDimension( + $dimension = $this->_carrierHelper->convertMeasureDimension( round($dimension, 3), $configDimensionUnit, $countryDimensionUnit @@ -889,7 +888,7 @@ class International /** * Add dimension to piece * - * @param \Magento\Usa\Model\Simplexml\Element $nodePiece + * @param \Magento\Shipping\Model\Simplexml\Element $nodePiece * @return void */ protected function _addDimension($nodePiece) @@ -1239,9 +1238,9 @@ class International protected function getCountryParams($countryCode) { if (empty($this->_countryParams)) { - $usaEtcPath = $this->_configReader->getModuleDir('etc', 'Magento_Usa'); + $etcPath = $this->_configReader->getModuleDir('etc', 'Magento_Dhl'); $countriesXmlPath = $this->modulesDirectory->getRelativePath( - $usaEtcPath . '/dhl/international/countries.xml' + $etcPath . '/countries.xml' ); $countriesXml = $this->modulesDirectory->readFile($countriesXmlPath); $this->_countryParams = $this->_xmlElFactory->create( @@ -1565,7 +1564,7 @@ class International /** * Generation Shipment Details Node according to origin region * - * @param \Magento\Usa\Model\Simplexml\Element $xml + * @param \Magento\Shipping\Model\Simplexml\Element $xml * @param RateRequest $rawRequest * @param string $originRegion * @return void diff --git a/app/code/Magento/Dhl/Model/Plugin/Checkout/Block/Cart/Shipping.php b/app/code/Magento/Dhl/Model/Plugin/Checkout/Block/Cart/Shipping.php new file mode 100644 index 00000000000..7039138327a --- /dev/null +++ b/app/code/Magento/Dhl/Model/Plugin/Checkout/Block/Cart/Shipping.php @@ -0,0 +1,65 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Dhl\Model\Plugin\Checkout\Block\Cart; + +/** + * Checkout cart shipping block plugin + */ +class Shipping +{ + /** + * @var \Magento\Core\Model\Store\Config + */ + protected $_storeConfig; + + /** + * @param \Magento\Core\Model\Store\Config $storeConfig + */ + public function __construct(\Magento\Core\Model\Store\Config $storeConfig) + { + $this->_storeConfig = $storeConfig; + } + + /** + * @param \Magento\Checkout\Block\Cart\Shipping $subject + * @param bool $result + * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterGetStateActive(\Magento\Checkout\Block\Cart\Shipping $subject, $result) + { + return (bool)$result || (bool)$this->_storeConfig->getConfig('carriers/dhl/active'); + } + + /** + * @param \Magento\Checkout\Block\Cart\Shipping $subject + * @param bool $result + * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterGetCityActive(\Magento\Checkout\Block\Cart\Shipping $subject, $result) + { + return (bool)$result || (bool)$this->_storeConfig->getConfig('carriers/dhl/active'); + } +} \ No newline at end of file diff --git a/app/code/Magento/Dhl/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php b/app/code/Magento/Dhl/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php new file mode 100644 index 00000000000..34a2ee8be3d --- /dev/null +++ b/app/code/Magento/Dhl/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php @@ -0,0 +1,59 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Dhl\Model\Plugin\Rma\Block\Adminhtml\Rma\Edit\Tab\General; + +/** + * Checkout cart shipping block plugin + */ +class Shippingmethod +{ + /** + * @var \Magento\Core\Model\Store\Config + */ + protected $_storeConfig; + + /** + * @param \Magento\Core\Model\Store\Config $storeConfig + */ + public function __construct(\Magento\Core\Model\Store\Config $storeConfig) + { + $this->_storeConfig = $storeConfig; + } + + /** + * @param \Magento\Object $subject + * @param bool $result + * @return bool + */ + public function afterCanDisplayCustomValue( + \Magento\Object $subject, + $result + ) { + $carrierCode = $subject->getShipment()->getCarrierCode(); + if (!$carrierCode) { + return (bool)$result || false; + } + return (bool)$result || (bool)$carrierCode == \Magento\Dhl\Model\Carrier::CODE; + } +} \ No newline at end of file diff --git a/app/code/Magento/Usa/Model/Resource/Setup.php b/app/code/Magento/Dhl/Model/Resource/Setup.php similarity index 77% rename from app/code/Magento/Usa/Model/Resource/Setup.php rename to app/code/Magento/Dhl/Model/Resource/Setup.php index e8a7bf7da3b..63b16157c01 100644 --- a/app/code/Magento/Usa/Model/Resource/Setup.php +++ b/app/code/Magento/Dhl/Model/Resource/Setup.php @@ -19,47 +19,41 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Resource; - +namespace Magento\Dhl\Model\Resource; class Setup extends \Magento\Core\Model\Resource\Setup { /** - * Locale model - * - * @var \Magento\Core\Model\Locale + * @var \Magento\Locale\ListsInterface */ - protected $_localeModel; + protected $_localeLists; /** * @param \Magento\Core\Model\Resource\Setup\Context $context * @param string $resourceName * @param string $moduleName - * @param \Magento\Core\Model\Locale $localeModel + * @param \Magento\Locale\ListsInterface $localeLists * @param string $connectionName */ public function __construct( \Magento\Core\Model\Resource\Setup\Context $context, $resourceName, $moduleName, - \Magento\Core\Model\Locale $localeModel, + \Magento\Locale\ListsInterface $localeLists, $connectionName = '' ) { - $this->_localeModel = $localeModel; + $this->_localeLists = $localeLists; parent::__construct($context, $resourceName, $moduleName, $connectionName); } /** - * Get locale - * - * @return \Magento\Core\Model\Locale + * @return \Magento\Locale\ListsInterface */ - public function getLocale() + public function getLocaleLists() { - return $this->_localeModel; + return $this->_localeLists; } -} \ No newline at end of file +} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Contenttype.php b/app/code/Magento/Dhl/Model/Source/Contenttype.php similarity index 75% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Contenttype.php rename to app/code/Magento/Dhl/Model/Source/Contenttype.php index 52ad9663e78..c3d73562dc4 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Contenttype.php +++ b/app/code/Magento/Dhl/Model/Source/Contenttype.php @@ -18,17 +18,13 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source; +namespace Magento\Dhl\Model\Source; /** * Source model for DHL Content Type - * - * @author Magento Core Team <core@magentocommerce.com> */ class Contenttype implements \Magento\Option\ArrayInterface { @@ -39,9 +35,9 @@ class Contenttype implements \Magento\Option\ArrayInterface { return array( array('label' => __('Documents'), - 'value' => \Magento\Usa\Model\Shipping\Carrier\Dhl\International::DHL_CONTENT_TYPE_DOC), + 'value' => \Magento\Dhl\Model\Carrier::DHL_CONTENT_TYPE_DOC), array('label' => __('Non documents'), - 'value' => \Magento\Usa\Model\Shipping\Carrier\Dhl\International::DHL_CONTENT_TYPE_NON_DOC), + 'value' => \Magento\Dhl\Model\Carrier::DHL_CONTENT_TYPE_NON_DOC), ); } } diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/AbstractMethod.php b/app/code/Magento/Dhl/Model/Source/Method/AbstractMethod.php similarity index 79% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/AbstractMethod.php rename to app/code/Magento/Dhl/Model/Source/Method/AbstractMethod.php index d1bcadb8709..9c81dd4f7e0 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/AbstractMethod.php +++ b/app/code/Magento/Dhl/Model/Source/Method/AbstractMethod.php @@ -18,19 +18,15 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method; +namespace Magento\Dhl\Model\Source\Method; /** * Source model for DHL shipping methods - * - * @author Magento Core Team <core@magentocommerce.com> */ -abstract class AbstractMethod extends \Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Generic +abstract class AbstractMethod extends \Magento\Dhl\Model\Source\Method\Generic { /** * Carrier Product Type Indicator @@ -51,8 +47,8 @@ abstract class AbstractMethod extends \Magento\Usa\Model\Shipping\Carrier\Dhl\In */ public function toOptionArray() { - /* @var $carrierModel \Magento\Usa\Model\Shipping\Carrier\Dhl\International */ - $carrierModel = $this->_shippingDhlInt; + /* @var $carrierModel \Magento\Dhl\Model\Carrier */ + $carrierModel = $this->_shippingDhl; $dhlProducts = $carrierModel->getDhlProducts($this->_contentType); $options = array(); diff --git a/app/code/Magento/Dhl/Model/Source/Method/Doc.php b/app/code/Magento/Dhl/Model/Source/Method/Doc.php new file mode 100644 index 00000000000..90dc5a5647b --- /dev/null +++ b/app/code/Magento/Dhl/Model/Source/Method/Doc.php @@ -0,0 +1,38 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Dhl\Model\Source\Method; + +/** + * Source model for DHL shipping methods for documentation + */ +class Doc + extends \Magento\Dhl\Model\Source\Method\AbstractMethod +{ + /** + * Carrier Product Type Indicator + * + * @var string $_contentType + */ + protected $_contentType = \Magento\Dhl\Model\Carrier::DHL_CONTENT_TYPE_DOC; +} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freedoc.php b/app/code/Magento/Dhl/Model/Source/Method/Freedoc.php similarity index 73% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freedoc.php rename to app/code/Magento/Dhl/Model/Source/Method/Freedoc.php index 076334f6a9f..0a583fac066 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freedoc.php +++ b/app/code/Magento/Dhl/Model/Source/Method/Freedoc.php @@ -18,30 +18,23 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Dhl\Model\Source\Method; /** * Source model for DHL shipping methods for documentation - * - * @category Magento - * @package Magento_Usa - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method; - class Freedoc - extends \Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\AbstractMethod + extends \Magento\Dhl\Model\Source\Method\AbstractMethod { /** * Carrier Product Type Indicator * * @var string $_contentType */ - protected $_contentType = \Magento\Usa\Model\Shipping\Carrier\Dhl\International::DHL_CONTENT_TYPE_DOC; + protected $_contentType = \Magento\Dhl\Model\Carrier::DHL_CONTENT_TYPE_DOC; /** * Show 'none' in methods list or not; diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freenondoc.php b/app/code/Magento/Dhl/Model/Source/Method/Freenondoc.php similarity index 73% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freenondoc.php rename to app/code/Magento/Dhl/Model/Source/Method/Freenondoc.php index 1ee3a970557..48dab13eb3c 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Freenondoc.php +++ b/app/code/Magento/Dhl/Model/Source/Method/Freenondoc.php @@ -18,30 +18,23 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Dhl\Model\Source\Method; /** * Source model for DHL shipping methods for documentation - * - * @category Magento - * @package Magento_Usa - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method; - class Freenondoc - extends \Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\AbstractMethod + extends \Magento\Dhl\Model\Source\Method\AbstractMethod { /** * Carrier Product Type Indicator * * @var string $_contentType */ - protected $_contentType = \Magento\Usa\Model\Shipping\Carrier\Dhl\International::DHL_CONTENT_TYPE_NON_DOC; + protected $_contentType = \Magento\Dhl\Model\Carrier::DHL_CONTENT_TYPE_NON_DOC; /** * Show 'none' in methods list or not; diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Generic.php b/app/code/Magento/Dhl/Model/Source/Method/Generic.php similarity index 81% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Generic.php rename to app/code/Magento/Dhl/Model/Source/Method/Generic.php index 6e33b10b2f7..366d6451007 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Generic.php +++ b/app/code/Magento/Dhl/Model/Source/Method/Generic.php @@ -21,27 +21,24 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Dhl\Model\Source\Method; -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\Source; - -class Generic implements \Magento\Option\ArrayInterface +class Generic { /** - * @var \Magento\Usa\Model\Shipping\Carrier\Dhl + * @var \Magento\Dhl\Model\Carrier */ protected $_shippingDhl; /** - * Carrier code - * * @var string */ protected $_code = ''; /** - * @param \Magento\Usa\Model\Shipping\Carrier\Dhl $shippingDhl + * @param \Magento\Dhl\Model\Carrier $shippingDhl */ - public function __construct(\Magento\Usa\Model\Shipping\Carrier\Dhl $shippingDhl) + public function __construct(\Magento\Dhl\Model\Carrier $shippingDhl) { $this->_shippingDhl = $shippingDhl; } diff --git a/app/code/Magento/Dhl/Model/Source/Method/Nondoc.php b/app/code/Magento/Dhl/Model/Source/Method/Nondoc.php new file mode 100644 index 00000000000..de2eee78446 --- /dev/null +++ b/app/code/Magento/Dhl/Model/Source/Method/Nondoc.php @@ -0,0 +1,38 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Dhl\Model\Source\Method; + +/** + * Source model for DHL shipping methods for documentation + */ +class Nondoc + extends \Magento\Dhl\Model\Source\Method\AbstractMethod +{ + /** + * Carrier Product Type Indicator + * + * @var string $_contentType + */ + protected $_contentType = \Magento\Dhl\Model\Carrier::DHL_CONTENT_TYPE_NON_DOC; +} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Size.php b/app/code/Magento/Dhl/Model/Source/Method/Size.php similarity index 84% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Size.php rename to app/code/Magento/Dhl/Model/Source/Method/Size.php index c0e15387cdf..4090d684080 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Size.php +++ b/app/code/Magento/Dhl/Model/Source/Method/Size.php @@ -18,16 +18,15 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Dhl\Model\Source\Method; - -namespace Magento\Usa\Model\Shipping\Carrier\Usps\Source; - -class Size extends \Magento\Usa\Model\Shipping\Carrier\Usps\Source\Generic +/** + * Source model for DHL shipping methods for documentation + */ +class Size extends \Magento\Dhl\Model\Source\Method\Generic { /** * Carrier code diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Method.php b/app/code/Magento/Dhl/Model/Source/Method/Unitofmeasure.php similarity index 81% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Method.php rename to app/code/Magento/Dhl/Model/Source/Method/Unitofmeasure.php index 10c7d5ef69a..73cd48d48d2 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Method.php +++ b/app/code/Magento/Dhl/Model/Source/Method/Unitofmeasure.php @@ -18,21 +18,20 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Dhl\Model\Source\Method; - -namespace Magento\Usa\Model\Shipping\Carrier\Usps\Source; - -class Method extends \Magento\Usa\Model\Shipping\Carrier\Usps\Source\Generic +/** + * Source model for DHL shipping methods for documentation + */ +class Unitofmeasure extends \Magento\Dhl\Model\Source\Method\Generic { /** * Carrier code * * @var string */ - protected $_code = 'method'; + protected $_code = 'unit_of_measure'; } diff --git a/app/code/Magento/Dhl/etc/adminhtml/system.xml b/app/code/Magento/Dhl/etc/adminhtml/system.xml new file mode 100644 index 00000000000..e8234ce861b --- /dev/null +++ b/app/code/Magento/Dhl/etc/adminhtml/system.xml @@ -0,0 +1,175 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <system> + <section id="carriers"> + <group id="dhl" translate="label" type="text" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>DHL</label> + <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled for Checkout</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="gateway_url" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Gateway URL</label> + </field> + <field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Title</label> + </field> + <field id="id" translate="label" type="obscure" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Access ID</label> + <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> + </field> + <field id="password" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Password</label> + <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> + </field> + <field id="account" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Account Number</label> + </field> + <field id="content_type" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Content Type</label> + <source_model>Magento\Dhl\Model\Source\Contenttype</source_model> + </field> + <field id="handling_type" translate="label" type="select" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Calculate Handling Fee</label> + <source_model>Magento\Shipping\Model\Source\HandlingType</source_model> + </field> + <field id="handling_action" translate="label comment" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Handling Applied</label> + <comment>"Per Order" allows a single handling fee for the entire order. "Per Package" allows an individual handling fee for each package.</comment> + <source_model>Magento\Shipping\Model\Source\HandlingAction</source_model> + </field> + <field id="handling_fee" translate="label" type="text" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Handling Fee</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="divide_order_weight" translate="label comment" type="select" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Divide Order Weight</label> + <comment>This allows breaking total order weight into smaller pieces if it exeeds 70 kg to ensure accurate calculation of shipping charges.</comment> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="unit_of_measure" translate="label" type="select" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Weight Unit</label> + <source_model>Magento\Dhl\Model\Source\Method\Unitofmeasure</source_model> + <frontend_model>Magento\Dhl\Block\Adminhtml\Unitofmeasure</frontend_model> + </field> + <field id="size" translate="label" type="select" sortOrder="150" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Size</label> + <source_model>Magento\Dhl\Model\Source\Method\Size</source_model> + </field> + <field id="height" translate="label" type="text" sortOrder="151" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Height</label> + <depends> + <field id="size">1</field> + </depends> + </field> + <field id="depth" translate="label" type="text" sortOrder="152" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Depth</label> + <depends> + <field id="size">1</field> + </depends> + </field> + <field id="width" translate="label" type="text" sortOrder="153" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Width</label> + <depends> + <field id="size">1</field> + </depends> + </field> + <field id="doc_methods" translate="label" type="multiselect" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Allowed Methods</label> + <source_model>Magento\Dhl\Model\Source\Method\Doc</source_model> + <depends> + <field id="content_type">D</field> + </depends> + </field> + <field id="nondoc_methods" translate="label" type="multiselect" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Allowed Methods</label> + <source_model>Magento\Dhl\Model\Source\Method\Nondoc</source_model> + <depends> + <field id="content_type">N</field> + </depends> + </field> + <field id="ready_time" type="text" sortOrder="180" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ready time</label> + <comment>Package ready time after order submission (in hours)</comment> + </field> + <field id="specificerrmsg" translate="label" type="textarea" sortOrder="800" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Displayed Error Message</label> + </field> + <field id="free_method_doc" translate="label" type="select" sortOrder="1200" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Free Method</label> + <frontend_class>free-method</frontend_class> + <source_model>Magento\Dhl\Model\Source\Method\Freedoc</source_model> + <depends> + <field id="content_type">D</field> + </depends> + </field> + <field id="free_method_nondoc" translate="label" type="select" sortOrder="1200" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Free Method</label> + <frontend_class>free-method</frontend_class> + <source_model>Magento\Dhl\Model\Source\Method\Freenondoc</source_model> + <depends> + <field id="content_type">N</field> + </depends> + </field> + <field id="free_shipping_enable" translate="label" type="select" sortOrder="1210" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Free Shipping Amount Threshold</label> + <source_model>Magento\Backend\Model\Config\Source\Enabledisable</source_model> + </field> + <field id="free_shipping_subtotal" translate="label" type="text" sortOrder="1220" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Free Shipping Amount Threshold</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="sallowspecific" translate="label" type="select" sortOrder="1900" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ship to Applicable Countries</label> + <frontend_class>shipping-applicable-country</frontend_class> + <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> + </field> + <field id="specificcountry" translate="label" type="multiselect" sortOrder="1910" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ship to Specific Countries</label> + <source_model>Magento\Directory\Model\Config\Source\Country</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="showmethod" translate="label" type="select" sortOrder="1940" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Show Method if Not Applicable</label> + <frontend_class>shipping-skip-hide</frontend_class> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="sort_order" translate="label" type="text" sortOrder="2000" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Sort Order</label> + </field> + <field id="debug" translate="label" type="select" sortOrder="1950" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Debug</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="active_rma" translate="label" type="select" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled for RMA</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + </group> + </section> + </system> +</config> diff --git a/app/code/Magento/Dhl/etc/config.xml b/app/code/Magento/Dhl/etc/config.xml new file mode 100644 index 00000000000..f0d3b8d0e6e --- /dev/null +++ b/app/code/Magento/Dhl/etc/config.xml @@ -0,0 +1,61 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <default> + <system> + <media_storage_configuration> + <allowed_resources> + <dhl_folder>dhl</dhl_folder> + </allowed_resources> + </media_storage_configuration> + </system> + <carriers> + <dhl> + <model>Magento\Dhl\Model\Carrier</model> + <account /> + <active>0</active> + <title>DHL</title> + <sallowspecific>0</sallowspecific> + <nondoc_methods>1,3,4,8,P,Q,E,F,H,J,M,V,Y</nondoc_methods> + <doc_methods>2,5,6,7,9,B,C,D,U,K,L,G,W,I,N,O,R,S,T,X</doc_methods> + <free_method>G</free_method> + <gateway_url>https://xmlpi-ea.dhl.com/XMLShippingServlet</gateway_url> + <id backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> + <password backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> + <content_type>N</content_type> + <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg> + <divide_order_weight>1</divide_order_weight> + <unit_of_measure>K</unit_of_measure> + <size>R</size> + <handling_type>F</handling_type> + <handling_action>O</handling_action> + <shipment_days>Mon,Tue,Wed,Thu,Fri</shipment_days> + <active_rma>0</active_rma> + <is_online>1</is_online> + </dhl> + </carriers> + </default> +</config> diff --git a/app/code/Magento/Usa/etc/dhl/international/countries.xml b/app/code/Magento/Dhl/etc/countries.xml similarity index 99% rename from app/code/Magento/Usa/etc/dhl/international/countries.xml rename to app/code/Magento/Dhl/etc/countries.xml index 140dba5d46c..602e970be76 100644 --- a/app/code/Magento/Usa/etc/dhl/international/countries.xml +++ b/app/code/Magento/Dhl/etc/countries.xml @@ -19,8 +19,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ diff --git a/app/code/Magento/Dhl/etc/di.xml b/app/code/Magento/Dhl/etc/di.xml new file mode 100644 index 00000000000..24123c90a7f --- /dev/null +++ b/app/code/Magento/Dhl/etc/di.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <type name="Magento\Module\Updater\SetupFactory"> + <arguments> + <argument name="resourceTypes" xsi:type="array"> + <item name="dhl_setup" xsi:type="string">Magento\Dhl\Model\Resource\Setup</item> + </argument> + </arguments> + </type> + <type name="Magento\Checkout\Block\Cart\Shipping"> + <plugin name="checkout_cart_shipping_dhl" type="Magento\Dhl\Model\Plugin\Checkout\Block\Cart\Shipping"/> + </type> + <type name="Magento\Rma\Block\Adminhtml\Rma\Edit\Tab\General\Shippingmethod"> + <plugin name="rma_tab_shippingmethod_dhl" + type="Magento\Dhl\Model\Plugin\Rma\Block\Adminhtml\Rma\Edit\Tab\General\Shippingmethod"/> + </type> +</config> diff --git a/app/code/Magento/Usa/etc/module.xml b/app/code/Magento/Dhl/etc/module.xml old mode 100755 new mode 100644 similarity index 84% rename from app/code/Magento/Usa/etc/module.xml rename to app/code/Magento/Dhl/etc/module.xml index 23a9af0b53c..bdb236dc04f --- a/app/code/Magento/Usa/etc/module.xml +++ b/app/code/Magento/Dhl/etc/module.xml @@ -24,19 +24,15 @@ */ --> <config> - <module name="Magento_Usa" version="1.6.0.3" active="true"> - <sequence> - <module name="Magento_Sales"/> - <module name="Magento_Shipping"/> - </sequence> + <module name="Magento_Dhl" version="2.0.0.0" active="true"> <depends> <module name="Magento_Shipping"/> <module name="Magento_Backend"/> <module name="Magento_Directory"/> <module name="Magento_Core"/> - <module name="Magento_Catalog"/> - <module name="Magento_Paypal"/> <module name="Magento_Sales"/> + <module name="Magento_Checkout"/> + <module name="Magento_Catalog"/> </depends> </module> </config> diff --git a/app/code/Magento/Usa/sql/usa_setup/upgrade-1.6.0.2-1.6.0.3.php b/app/code/Magento/Dhl/sql/dhl_setup/install-2.0.0.0.php similarity index 88% rename from app/code/Magento/Usa/sql/usa_setup/upgrade-1.6.0.2-1.6.0.3.php rename to app/code/Magento/Dhl/sql/dhl_setup/install-2.0.0.0.php index 75bb158b0e5..9c995027e2c 100644 --- a/app/code/Magento/Usa/sql/usa_setup/upgrade-1.6.0.2-1.6.0.3.php +++ b/app/code/Magento/Dhl/sql/dhl_setup/install-2.0.0.0.php @@ -19,12 +19,12 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -$days = $this->getLocale()->getTranslationList('days'); +/** @var \Magento\Dhl\Model\Resource\Setup $this */ +$days = $this->getLocaleLists()->getTranslationList('days'); $days = array_keys($days['format']['wide']); foreach ($days as $key => $value) { @@ -34,8 +34,7 @@ foreach ($days as $key => $value) { $select = $this->getConnection() ->select() ->from($this->getTable('core_config_data'), array('config_id', 'value')) - ->where('path = ?', 'carriers/dhl/shipment_days') - ->orWhere('path = ?', 'carriers/dhl/intl_shipment_days'); + ->where('path = ?', 'carriers/dhl/shipment_days'); foreach ($this->getConnection()->fetchAll($select) as $configRow) { $row = array('value' => implode(',', array_intersect_key($days, array_flip(explode(',', $configRow['value']))))); diff --git a/app/code/Magento/Usa/view/adminhtml/dhl/logo.jpg b/app/code/Magento/Dhl/view/adminhtml/logo.jpg similarity index 100% rename from app/code/Magento/Usa/view/adminhtml/dhl/logo.jpg rename to app/code/Magento/Dhl/view/adminhtml/logo.jpg diff --git a/app/code/Magento/Usa/view/adminhtml/dhl/unitofmeasure.phtml b/app/code/Magento/Dhl/view/adminhtml/unitofmeasure.phtml similarity index 59% rename from app/code/Magento/Usa/view/adminhtml/dhl/unitofmeasure.phtml rename to app/code/Magento/Dhl/view/adminhtml/unitofmeasure.phtml index 79ab48b4fe3..c8869e7615e 100644 --- a/app/code/Magento/Usa/view/adminhtml/dhl/unitofmeasure.phtml +++ b/app/code/Magento/Dhl/view/adminhtml/unitofmeasure.phtml @@ -18,15 +18,13 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> <?php /** - * @var $this \Magento\Usa\Block\Adminhtml\Dhl\Unitofmeasure + * @var $this \Magento\Dhl\Block\Adminhtml\Unitofmeasure */ ?> <script type="text/javascript"> @@ -34,19 +32,19 @@ function changeDimensions() { var dimensionUnit = '(<?php echo $this->getInch(); ?>)'; - var dhlintUnitOfMeasureNote = '<?php echo $this->getDivideOrderWeightNoteLbp(); ?>'; - if ($("carriers_dhlint_unit_of_measure").value == "K") { + var dhlUnitOfMeasureNote = '<?php echo $this->getDivideOrderWeightNoteLbp(); ?>'; + if ($("carriers_dhl_unit_of_measure").value == "K") { dimensionUnit = '(<?php echo $this->getCm(); ?>)'; - dhlintUnitOfMeasureNote = '<?php echo $this->getDivideOrderWeightNoteKg(); ?>'; + dhlUnitOfMeasureNote = '<?php echo $this->getDivideOrderWeightNoteKg(); ?>'; } - $$('[for="carriers_dhlint_height"]')[0].innerHTML = '<?php echo $this->getHeight(); ?> ' + dimensionUnit; - $$('[for="carriers_dhlint_depth"]')[0].innerHTML = '<?php echo $this->getDepth(); ?> ' + dimensionUnit; - $$('[for="carriers_dhlint_width"]')[0].innerHTML = '<?php echo $this->getWidth(); ?> ' + dimensionUnit; + $$('[for="carriers_dhl_height"]')[0].innerHTML = '<?php echo $this->getHeight(); ?> ' + dimensionUnit; + $$('[for="carriers_dhl_depth"]')[0].innerHTML = '<?php echo $this->getDepth(); ?> ' + dimensionUnit; + $$('[for="carriers_dhl_width"]')[0].innerHTML = '<?php echo $this->getWidth(); ?> ' + dimensionUnit; - $('carriers_dhlint_divide_order_weight').next().down().innerHTML = dhlintUnitOfMeasureNote; + $('carriers_dhl_divide_order_weight').next().down().innerHTML = dhlUnitOfMeasureNote; } document.observe("dom:loaded", function() { - $("carriers_dhlint_unit_of_measure").observe("change", changeDimensions); + $("carriers_dhl_unit_of_measure").observe("change", changeDimensions); changeDimensions(); }); //]]> diff --git a/app/code/Magento/Directory/Block/Currency.php b/app/code/Magento/Directory/Block/Currency.php index bdc944644de..238a6406535 100644 --- a/app/code/Magento/Directory/Block/Currency.php +++ b/app/code/Magento/Directory/Block/Currency.php @@ -43,22 +43,30 @@ class Currency extends \Magento\View\Element\Template */ protected $_currencyFactory; + /** + * @var \Magento\LocaleInterface + */ + protected $_locale; + /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Directory\Helper\Url $directoryUrl * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory + * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Directory\Helper\Url $directoryUrl, \Magento\Directory\Model\CurrencyFactory $currencyFactory, + \Magento\Locale\ResolverInterface $localeResolver, array $data = array() ) { $this->_directoryUrl = $directoryUrl; $this->_currencyFactory = $currencyFactory; parent::__construct($context, $data); $this->_isScopePrivate = true; + $this->_locale = $localeResolver->getLocale(); } /** diff --git a/app/code/Magento/Directory/Model/Country.php b/app/code/Magento/Directory/Model/Country.php index 90e3171078d..11a40bfed19 100644 --- a/app/code/Magento/Directory/Model/Country.php +++ b/app/code/Magento/Directory/Model/Country.php @@ -46,9 +46,9 @@ class Country extends \Magento\Core\Model\AbstractModel static public $_format = array(); /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ListsInterface */ - protected $_locale; + protected $_localeLists; /** * @var \Magento\Directory\Model\Country\FormatFactory @@ -63,9 +63,9 @@ class Country extends \Magento\Core\Model\AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\LocaleInterface $locale - * @param \Magento\Directory\Model\Country\FormatFactory $formatFactory - * @param \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory + * @param \Magento\Locale\ListsInterface $localeLists + * @param Country\FormatFactory $formatFactory + * @param Resource\Region\CollectionFactory $regionCollectionFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -73,7 +73,7 @@ class Country extends \Magento\Core\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ListsInterface $localeLists, \Magento\Directory\Model\Country\FormatFactory $formatFactory, \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, @@ -83,7 +83,7 @@ class Country extends \Magento\Core\Model\AbstractModel parent::__construct( $context, $registry, $resource, $resourceCollection, $data ); - $this->_locale = $locale; + $this->_localeLists = $localeLists; $this->_formatFactory = $formatFactory; $this->_regionCollectionFactory = $regionCollectionFactory; } @@ -220,7 +220,7 @@ T: {{telephone}}"; public function getName() { if (!$this->getData('name')) { - $this->setData('name', $this->_locale->getCountryTranslation($this->getId())); + $this->setData('name', $this->_localeLists->getCountryTranslation($this->getId())); } return $this->getData('name'); } diff --git a/app/code/Magento/Directory/Model/Currency.php b/app/code/Magento/Directory/Model/Currency.php index 40af8029602..9b90041eace 100644 --- a/app/code/Magento/Directory/Model/Currency.php +++ b/app/code/Magento/Directory/Model/Currency.php @@ -40,7 +40,7 @@ class Currency extends \Magento\Core\Model\AbstractModel { /** * CONFIG path constants - */ + */ const XML_PATH_CURRENCY_ALLOW = 'currency/options/allow'; const XML_PATH_CURRENCY_DEFAULT = 'currency/options/default'; const XML_PATH_CURRENCY_BASE = 'currency/options/base'; @@ -58,9 +58,9 @@ class Currency extends \Magento\Core\Model\AbstractModel protected $_rates; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\FormatInterface */ - protected $_locale; + protected $_localeFormat; /** * @var \Magento\Core\Model\StoreManagerInterface @@ -77,13 +77,19 @@ class Currency extends \Magento\Core\Model\AbstractModel */ protected $_currencyFilterFactory; + /** + * @var \Magento\Locale\CurrencyInterface + */ + protected $_localeCurrency; + /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Directory\Helper\Data $directoryHelper - * @param \Magento\Directory\Model\Currency\FilterFactory $currencyFilterFactory + * @param Currency\FilterFactory $currencyFilterFactory + * @param \Magento\Locale\CurrencyInterface $localeCurrency * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -91,10 +97,11 @@ class Currency extends \Magento\Core\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\FormatInterface $localeFormat, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Directory\Helper\Data $directoryHelper, \Magento\Directory\Model\Currency\FilterFactory $currencyFilterFactory, + \Magento\Locale\CurrencyInterface $localeCurrency, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -102,10 +109,11 @@ class Currency extends \Magento\Core\Model\AbstractModel parent::__construct( $context, $registry, $resource, $resourceCollection, $data ); - $this->_locale = $locale; + $this->_localeFormat = $localeFormat; $this->_storeManager = $storeManager; $this->_directoryHelper = $directoryHelper; $this->_currencyFilterFactory = $currencyFilterFactory; + $this->_localeCurrency = $localeCurrency; } /** @@ -287,7 +295,7 @@ class Currency extends \Magento\Core\Model\AbstractModel } if ($includeContainer) { return '<span class="price">' . ($addBrackets ? '[' : '') - . $this->formatTxt($price, $options) . ($addBrackets ? ']' : '') . '</span>'; + . $this->formatTxt($price, $options) . ($addBrackets ? ']' : '') . '</span>'; } return $this->formatTxt($price, $options); } @@ -300,7 +308,7 @@ class Currency extends \Magento\Core\Model\AbstractModel public function formatTxt($price, $options = array()) { if (!is_numeric($price)) { - $price = $this->_locale->getNumber($price); + $price = $this->_localeFormat->getNumber($price); } /** * Fix problem with 12 000 000, 1 200 000 @@ -309,7 +317,7 @@ class Currency extends \Magento\Core\Model\AbstractModel * %F - the argument is treated as a float, and presented as a floating-point number (non-locale aware). */ $price = sprintf("%F", $price); - return $this->_locale->currency($this->getCode())->toCurrency($price, $options); + return $this->_localeCurrency->getCurrency($this->getCode())->toCurrency($price, $options); } /** @@ -318,7 +326,7 @@ class Currency extends \Magento\Core\Model\AbstractModel public function getOutputFormat() { $formatted = $this->formatTxt(0); - $number = $this->formatTxt(0, array('display' => \Zend_Currency::NO_SYMBOL)); + $number = $this->formatTxt(0, array('display' => \Magento\Currency::NO_SYMBOL)); return str_replace($number, '%s', $formatted); } diff --git a/app/code/Magento/Directory/Model/Currency/Filter.php b/app/code/Magento/Directory/Model/Currency/Filter.php index ee3157255de..7b4ebfc5d01 100644 --- a/app/code/Magento/Directory/Model/Currency/Filter.php +++ b/app/code/Magento/Directory/Model/Currency/Filter.php @@ -41,14 +41,14 @@ class Filter implements \Zend_Filter_Interface /** * Currency object * - * @var \Zend_Currency + * @var \Magento\CurrencyInterface */ protected $_currency; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\FormatInterface */ - protected $_locale; + protected $_localeFormat; /** * @var \Magento\Core\Model\StoreManagerInterface @@ -56,20 +56,27 @@ class Filter implements \Zend_Filter_Interface protected $_storeManager; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @var \Magento\Locale\CurrencyInterface + */ + protected $_localeCurrency; + + /** + * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\Locale\CurrencyInterface $localeCurrency * @param string $code * @param int $rate */ public function __construct( - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\FormatInterface $localeFormat, \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\Locale\CurrencyInterface $localeCurrency, $code, $rate = 1 ) { - $this->_locale = $locale; + $this->_localeFormat = $localeFormat; $this->_storeManager = $storeManager; - $this->_currency = $this->_locale->currency($code); + $this->_currency = $localeCurrency->getCurrency($code); $this->_rate = $rate; } @@ -92,7 +99,7 @@ class Filter implements \Zend_Filter_Interface */ public function filter($value) { - $value = $this->_locale->getNumber($value); + $value = $this->_localeFormat->getNumber($value); $value = $this->_storeManager->getStore()->roundPrice($this->_rate*$value); $value = sprintf("%f", $value); return $this->_currency->toCurrency($value); diff --git a/app/code/Magento/Directory/Model/Resource/Country/Collection.php b/app/code/Magento/Directory/Model/Resource/Country/Collection.php index 9af35ea6589..6a50e66ab1a 100644 --- a/app/code/Magento/Directory/Model/Resource/Country/Collection.php +++ b/app/code/Magento/Directory/Model/Resource/Country/Collection.php @@ -34,9 +34,9 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Locale model * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ListsInterface */ - protected $_locale; + protected $_localeLists; /** * Core store config @@ -57,15 +57,21 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl */ protected $_arrayUtils; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\Core\Model\EntityFactory $entityFactory * @param \Magento\Logger $logger * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ListsInterface $localeLists * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Directory\Model\Resource\CountryFactory $countryFactory * @param \Magento\Stdlib\ArrayUtils $arrayUtils + * @param \Magento\Locale\ResolverInterface $localeResolver * @param mixed $connection * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource */ @@ -74,16 +80,18 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl \Magento\Logger $logger, \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Event\ManagerInterface $eventManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ListsInterface $localeLists, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Directory\Model\Resource\CountryFactory $countryFactory, \Magento\Stdlib\ArrayUtils $arrayUtils, + \Magento\Locale\ResolverInterface $localeResolver, $connection = null, \Magento\Core\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_coreStoreConfig = $coreStoreConfig; - $this->_locale = $locale; + $this->_localeLists = $localeLists; + $this->_localeResolver = $localeResolver; $this->_countryFactory = $countryFactory; $this->_arrayUtils = $arrayUtils; } @@ -203,12 +211,12 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl $sort = array(); foreach ($options as $data) { - $name = (string)$this->_locale->getCountryTranslation($data['value']); + $name = (string)$this->_localeLists->getCountryTranslation($data['value']); if (!empty($name)) { $sort[$name] = $data['value']; } } - $this->_arrayUtils->ksortMultibyte($sort, $this->_locale->getLocaleCode()); + $this->_arrayUtils->ksortMultibyte($sort, $this->_localeResolver->getLocaleCode()); foreach (array_reverse($this->_foregroundCountries) as $foregroundCountry) { $name = array_search($foregroundCountry, $sort); unset($sort[$name]); diff --git a/app/code/Magento/Directory/Model/Resource/Region.php b/app/code/Magento/Directory/Model/Resource/Region.php index d6d06044238..4400844d4fd 100644 --- a/app/code/Magento/Directory/Model/Resource/Region.php +++ b/app/code/Magento/Directory/Model/Resource/Region.php @@ -39,20 +39,20 @@ class Region extends \Magento\Core\Model\Resource\Db\AbstractDb protected $_regionNameTable; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ResolverInterface */ - protected $_locale; + protected $_localeResolver; /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\LocaleInterface $locale + \Magento\Locale\ResolverInterface $localeResolver ) { parent::__construct($resource); - $this->_locale = $locale; + $this->_localeResolver = $localeResolver; } /** @@ -79,7 +79,7 @@ class Region extends \Magento\Core\Model\Resource\Db\AbstractDb $select = parent::_getLoadSelect($field, $value, $object); $adapter = $this->_getReadAdapter(); - $locale = $this->_locale->getLocaleCode(); + $locale = $this->_localeResolver->getLocaleCode(); $systemLocale = \Magento\Core\Model\App::DISTRO_LOCALE_CODE; $regionField = $adapter->quoteIdentifier($this->getMainTable() . '.' . $this->getIdFieldName()); @@ -116,7 +116,7 @@ class Region extends \Magento\Core\Model\Resource\Db\AbstractDb protected function _loadByCountry($object, $countryId, $value, $field) { $adapter = $this->_getReadAdapter(); - $locale = $this->_locale->getLocaleCode(); + $locale = $this->_localeResolver->getLocaleCode(); $joinCondition = $adapter->quoteInto('rname.region_id = region.region_id AND rname.locale = ?', $locale); $select = $adapter->select() ->from(array('region' => $this->getMainTable())) diff --git a/app/code/Magento/Directory/Model/Resource/Region/Collection.php b/app/code/Magento/Directory/Model/Resource/Region/Collection.php index 717cb18fead..51c468e82a7 100644 --- a/app/code/Magento/Directory/Model/Resource/Region/Collection.php +++ b/app/code/Magento/Directory/Model/Resource/Region/Collection.php @@ -46,16 +46,16 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl protected $_countryTable; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ResolverInterface */ - protected $_locale; + protected $_localeResolver; /** * @param \Magento\Core\Model\EntityFactory $entityFactory * @param \Magento\Logger $logger * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver * @param mixed $connection * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource */ @@ -64,11 +64,11 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl \Magento\Logger $logger, \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Event\ManagerInterface $eventManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ResolverInterface $localeResolver, $connection = null, \Magento\Core\Model\Resource\Db\AbstractDb $resource = null ) { - $this->_locale = $locale; + $this->_localeResolver = $localeResolver; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); } @@ -96,7 +96,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl protected function _initSelect() { parent::_initSelect(); - $locale = $this->_locale->getLocaleCode(); + $locale = $this->_localeResolver->getLocaleCode(); $this->addBindParam(':region_locale', $locale); $this->getSelect()->joinLeft( diff --git a/app/code/Magento/Directory/etc/adminhtml/di.xml b/app/code/Magento/Directory/etc/adminhtml/di.xml index c76602829aa..987960129b6 100644 --- a/app/code/Magento/Directory/etc/adminhtml/di.xml +++ b/app/code/Magento/Directory/etc/adminhtml/di.xml @@ -24,5 +24,4 @@ */ --> <config> - <preference for="Magento\Core\Model\LocaleInterface" type="Magento\Backend\Model\Locale" /> </config> diff --git a/app/code/Magento/Directory/etc/adminhtml/system.xml b/app/code/Magento/Directory/etc/adminhtml/system.xml index 20e592aa784..0950d53fd41 100644 --- a/app/code/Magento/Directory/etc/adminhtml/system.xml +++ b/app/code/Magento/Directory/etc/adminhtml/system.xml @@ -36,7 +36,7 @@ <field id="base" translate="label comment" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> <label>Base Currency</label> <frontend_model>Magento\Directory\Block\Adminhtml\Frontend\Currency\Base</frontend_model> - <source_model>Magento\Backend\Model\Config\Source\Currency</source_model> + <source_model>Magento\Backend\Model\Config\Source\Locale\Currency</source_model> <backend_model>Magento\Backend\Model\Config\Backend\Currency\Base</backend_model> <comment> <![CDATA[Base currency is used for all online payment transactions. If you have more than one store view, the base currency scope is defined by the catalog price scope ("Catalog" > "Price" > "Catalog Price Scope").]]> @@ -44,12 +44,12 @@ </field> <field id="default" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Default Display Currency</label> - <source_model>Magento\Backend\Model\Config\Source\Currency</source_model> + <source_model>Magento\Backend\Model\Config\Source\Locale\Currency</source_model> <backend_model>Magento\Backend\Model\Config\Backend\Currency\DefaultCurrency</backend_model> </field> <field id="allow" translate="label" type="multiselect" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Allowed Currencies</label> - <source_model>Magento\Backend\Model\Config\Source\Currency</source_model> + <source_model>Magento\Backend\Model\Config\Source\Locale\Currency</source_model> <backend_model>Magento\Backend\Model\Config\Backend\Currency\Allow</backend_model> <can_be_empty>1</can_be_empty> </field> diff --git a/app/code/Magento/Downloadable/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Downloadable.php b/app/code/Magento/Downloadable/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Downloadable.php index e20bcb4699b..e1161cb1d93 100644 --- a/app/code/Magento/Downloadable/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Downloadable.php +++ b/app/code/Magento/Downloadable/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Downloadable.php @@ -42,11 +42,16 @@ class Downloadable /** * Prepare product to save * + * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject * @param \Magento\Catalog\Model\Product $product + * * @return \Magento\Catalog\Model\Product + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterInitialize(\Magento\Catalog\Model\Product $product) - { + public function afterInitialize( + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject, + \Magento\Catalog\Model\Product $product + ) { if ($downloadable = $this->request->getPost('downloadable')) { $product->setDownloadableData($downloadable); } diff --git a/app/code/Magento/Downloadable/Helper/Download.php b/app/code/Magento/Downloadable/Helper/Download.php index 05c58c71b37..b5f2da3ac24 100644 --- a/app/code/Magento/Downloadable/Helper/Download.php +++ b/app/code/Magento/Downloadable/Helper/Download.php @@ -117,11 +117,6 @@ class Download extends \Magento\App\Helper\AbstractHelper */ protected $_coreStoreConfig; - /** - * @var \Magento\Core\Model\App - */ - protected $_app; - /** * @var \Magento\App\Filesystem */ @@ -153,7 +148,6 @@ class Download extends \Magento\App\Helper\AbstractHelper $this->_downloadableFile = $downloadableFile; $this->_coreFileStorageDb = $coreFileStorageDb; $this->_coreStoreConfig = $coreStoreConfig; - $this->_app = $context->getApp(); $this->_filesystem = $filesystem; parent::__construct($context); @@ -279,7 +273,7 @@ class Download extends \Magento\App\Helper\AbstractHelper { $handle = $this->_getHandle(); while (true == ($buffer = $handle->read(1024))) { - print $buffer; + echo $buffer; } } diff --git a/app/code/Magento/Downloadable/Model/Product/CartConfiguration/Plugin/Downloadable.php b/app/code/Magento/Downloadable/Model/Product/CartConfiguration/Plugin/Downloadable.php index adf2ca713e1..5d8023e26be 100644 --- a/app/code/Magento/Downloadable/Model/Product/CartConfiguration/Plugin/Downloadable.php +++ b/app/code/Magento/Downloadable/Model/Product/CartConfiguration/Plugin/Downloadable.php @@ -31,19 +31,23 @@ class Downloadable /** * Decide whether product has been configured for cart or not * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\Catalog\Model\Product\CartConfiguration $subject + * @param callable $proceed + * @param \Magento\Catalog\Model\Product $product + * @param array $config + * * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundIsProductConfigured(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - /** @var $product \Magento\Catalog\Model\Product */ - list($product, $config) = $arguments; - + public function aroundIsProductConfigured( + \Magento\Catalog\Model\Product\CartConfiguration $subject, + \Closure $proceed, + \Magento\Catalog\Model\Product $product, + $config + ) { if ($product->getTypeId() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) { return isset($config['links']); } - - return $invocationChain->proceed($arguments); + return $proceed($product, $config); } } diff --git a/app/code/Magento/Downloadable/Model/Product/TypeTransitionManager/Plugin/Downloadable.php b/app/code/Magento/Downloadable/Model/Product/TypeTransitionManager/Plugin/Downloadable.php index 7d1ffbaa3ec..8aea9582fbf 100644 --- a/app/code/Magento/Downloadable/Model/Product/TypeTransitionManager/Plugin/Downloadable.php +++ b/app/code/Magento/Downloadable/Model/Product/TypeTransitionManager/Plugin/Downloadable.php @@ -25,8 +25,7 @@ */ namespace Magento\Downloadable\Model\Product\TypeTransitionManager\Plugin; -use Magento\App\RequestInterface, - Magento\Code\Plugin\InvocationChain; +use Magento\App\RequestInterface; class Downloadable { @@ -49,13 +48,18 @@ class Downloadable /** * Change product type to downloadable if needed * - * @param array $arguments - * @param InvocationChain $invocationChain + * @param \Magento\Catalog\Model\Product\TypeTransitionManager $subject + * @param callable $proceed + * @param \Magento\Catalog\Model\Product $product + * + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundProcessProduct(array $arguments, InvocationChain $invocationChain) - { - /** @var \Magento\Catalog\Model\Product $product */ - $product = $arguments[0]; + public function aroundProcessProduct( + \Magento\Catalog\Model\Product\TypeTransitionManager $subject, + \Closure $proceed, + \Magento\Catalog\Model\Product $product + ) { $isTypeCompatible = in_array($product->getTypeId(), array( \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL, @@ -66,6 +70,6 @@ class Downloadable $product->setTypeId(\Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE); return; } - $invocationChain->proceed($arguments); + $proceed($product); } } diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php index ee86f3edde8..041437d9925 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php @@ -211,7 +211,7 @@ abstract class AbstractMain 'value' => $attributeObject->getDefaultValue(), )); - $dateFormat = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $dateFormat = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); $fieldset->addField('default_value_date', 'date', array( 'name' => 'default_value_date', 'label' => __('Default Value'), diff --git a/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php b/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php index 180eab096ff..6b105965652 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php @@ -81,16 +81,21 @@ abstract class AbstractData protected $_extractedData = array(); /** - * \Magento\Core\Model\LocaleInterface FORMAT + * Date filter format * * @var string */ protected $_dateFilterFormat; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; + + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; /** * @var \Magento\Logger @@ -98,17 +103,18 @@ abstract class AbstractData protected $_logger; /** - * Constructor - * - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Logger $logger + * @param \Magento\Locale\ResolverInterface $localeResolver */ public function __construct( - \Magento\Core\Model\LocaleInterface $locale, - \Magento\Logger $logger + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Logger $logger, + \Magento\Locale\ResolverInterface $localeResolver ) { - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_logger = $logger; + $this->_localeResolver = $localeResolver; } /** @@ -247,7 +253,7 @@ abstract class AbstractData if ($filterCode) { $filterClass = 'Magento\Data\Form\Filter\\' . ucfirst($filterCode); if ($filterCode == 'date') { - $filter = new $filterClass($this->_dateFilterFormat(), $this->_locale->getLocale()); + $filter = new $filterClass($this->_dateFilterFormat(), $this->_localeResolver->getLocale()); } else { $filter = new $filterClass(); } @@ -267,9 +273,9 @@ abstract class AbstractData if (is_null($format)) { // get format if (is_null($this->_dateFilterFormat)) { - $this->_dateFilterFormat = \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT; + $this->_dateFilterFormat = \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT; } - return $this->_locale->getDateFormat($this->_dateFilterFormat); + return $this->_localeDate->getDateFormat($this->_dateFilterFormat); } else if ($format === false) { // reset value $this->_dateFilterFormat = null; diff --git a/app/code/Magento/Eav/Model/Attribute/Data/Date.php b/app/code/Magento/Eav/Model/Attribute/Data/Date.php index f5dbf83cbb1..1c349f317d2 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/Date.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/Date.php @@ -142,13 +142,13 @@ class Date extends \Magento\Eav\Model\Attribute\Data\AbstractData case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT: case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_HTML: case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_PDF: - $this->_dateFilterFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM); + $this->_dateFilterFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM); break; } $value = $this->_applyOutputFilter($value); } - $this->_dateFilterFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $this->_dateFilterFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); return $value; } diff --git a/app/code/Magento/Eav/Model/Attribute/Data/File.php b/app/code/Magento/Eav/Model/Attribute/Data/File.php index 3dc2d16b2cf..8414737b1c9 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/File.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/File.php @@ -61,20 +61,22 @@ class File extends \Magento\Eav\Model\Attribute\Data\AbstractData protected $_directory; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Logger $logger + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Core\Model\File\Validator\NotProtectedExtension $fileValidator * @param \Magento\App\Filesystem $filesystem */ public function __construct( - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Logger $logger, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Core\Helper\Data $coreData, \Magento\Core\Model\File\Validator\NotProtectedExtension $fileValidator, \Magento\App\Filesystem $filesystem ) { - parent::__construct($locale, $logger); + parent::__construct($localeDate, $logger, $localeResolver); $this->_coreData = $coreData; $this->_fileValidator = $fileValidator; $this->_directory = $filesystem->getDirectoryWrite(\Magento\App\Filesystem::MEDIA_DIR); diff --git a/app/code/Magento/Eav/Model/Attribute/Data/Text.php b/app/code/Magento/Eav/Model/Attribute/Data/Text.php index 967bc8ab4ab..a059a2c9a44 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/Text.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/Text.php @@ -42,16 +42,18 @@ class Text extends \Magento\Eav\Model\Attribute\Data\AbstractData protected $_string; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Logger $logger + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Stdlib\String $stringHelper */ public function __construct( - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Logger $logger, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Stdlib\String $stringHelper ) { - parent::__construct($locale, $logger); + parent::__construct($localeDate, $logger, $localeResolver); $this->_string = $stringHelper; } diff --git a/app/code/Magento/Eav/Model/Entity.php b/app/code/Magento/Eav/Model/Entity.php index 92f7ef815fc..a27f0cf7dfc 100644 --- a/app/code/Magento/Eav/Model/Entity.php +++ b/app/code/Magento/Eav/Model/Entity.php @@ -46,7 +46,7 @@ class Entity extends \Magento\Eav\Model\Entity\AbstractEntity * @param \Magento\App\Resource $resource * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Validator\UniversalFactory $universalFactory * @param array $data @@ -55,7 +55,7 @@ class Entity extends \Magento\Eav\Model\Entity\AbstractEntity \Magento\App\Resource $resource, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Validator\UniversalFactory $universalFactory, $data = array() @@ -64,7 +64,7 @@ class Entity extends \Magento\Eav\Model\Entity\AbstractEntity $resource, $eavConfig, $attrSetEntity, - $locale, + $localeFormat, $resourceHelper, $universalFactory, $data diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php index a2b7a1400e9..a35573d0825 100644 --- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php +++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php @@ -201,9 +201,9 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou protected $_attrSetEntity; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\FormatInterface */ - protected $_locale; + protected $_localeFormat; /** * @var \Magento\Eav\Model\Resource\Helper @@ -219,7 +219,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * @param \Magento\App\Resource $resource * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Validator\UniversalFactory $universalFactory * @param array $data @@ -228,7 +228,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou \Magento\App\Resource $resource, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Validator\UniversalFactory $universalFactory, $data = array() @@ -236,7 +236,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou $this->_eavConfig = $eavConfig; $this->_resource = $resource; $this->_attrSetEntity = $attrSetEntity; - $this->_locale = $locale; + $this->_localeFormat = $localeFormat; $this->_resourceHelper = $resourceHelper; $this->_universalFactory = $universalFactory; parent::__construct(); @@ -978,7 +978,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou } else { $value = $object->getData($attribute->getAttributeCode()); if ($attribute->getBackend()->getType() == 'datetime') { - $date = new \Zend_Date($value, \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT); + $date = new \Magento\Stdlib\DateTime\Date($value, \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT); $value = $date->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); } $bind = array( @@ -1374,7 +1374,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou } if ($fieldProp['DATA_TYPE'] == 'decimal') { - $value = $this->_locale->getNumber($value); + $value = $this->_localeFormat->getNumber($value); } return $value; @@ -1569,7 +1569,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou if (($type == 'int' || $type == 'decimal' || $type == 'datetime') && $value === '') { $value = null; } else if ($type == 'decimal') { - $value = $this->_locale->getNumber($value); + $value = $this->_localeFormat->getNumber($value); } $backendTable = $attribute->getBackendTable(); if (!isset(self::$_attributeBackendTables[$backendTable])) { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute.php b/app/code/Magento/Eav/Model/Entity/Attribute.php index 5f203ea9e7c..5921948051a 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute.php @@ -36,7 +36,9 @@ use Magento\Eav\Exception; * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute +class Attribute + extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute + implements \Magento\Object\IdentityInterface { /** * Prefix of model events names @@ -64,15 +66,20 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute protected $_cacheTag = 'EAV_ATTRIBUTE'; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @var \Magento\Catalog\Model\ProductFactory */ protected $_catalogProductFactory; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry @@ -82,8 +89,9 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Helper $resourceHelper * @param \Magento\Validator\UniversalFactory $universalFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Catalog\Model\ProductFactory $catalogProductFactory + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -97,8 +105,9 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Eav\Model\Resource\Helper $resourceHelper, \Magento\Validator\UniversalFactory $universalFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Catalog\Model\ProductFactory $catalogProductFactory, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -116,7 +125,8 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $resourceCollection, $data ); - $this->_locale = $locale; + $this->_localeDate = $localeDate; + $this->_localeResolver = $localeResolver; $this->_catalogProductFactory = $catalogProductFactory; } @@ -227,14 +237,14 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute if ($this->getBackendType() == 'decimal' && $hasDefaultValue) { if (!\Zend_Locale_Format::isNumber($defaultValue, - array('locale' => $this->_locale->getLocaleCode())) + array('locale' => $this->_localeResolver->getLocaleCode())) ) { throw new Exception(__('Invalid default decimal value')); } try { $filter = new \Zend_Filter_LocalizedToNormalized( - array('locale' => $this->_locale->getLocaleCode()) + array('locale' => $this->_localeResolver->getLocaleCode()) ); $this->setDefaultValue($filter->filter($defaultValue)); } catch (\Exception $e) { @@ -253,9 +263,9 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute // save default date value as timestamp if ($hasDefaultValue) { - $format = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $format = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); try { - $defaultValue = $this->_locale->date($defaultValue, $format, null, false)->toValue(); + $defaultValue = $this->_localeDate->date($defaultValue, $format, null, false)->toValue(); $this->setDefaultValue($defaultValue); } catch (\Exception $e) { throw new Exception(__('Invalid default date')); @@ -425,4 +435,14 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute : 0.0; return $groupSortWeight + $sortWeight; } + + /** + * Get identities + * + * @return array + */ + public function getIdentities() + { + return array(self::CACHE_TAG . '_' . $this->getId()); + } } diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php index 95a87ce0ed5..40ec4d76fce 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php @@ -30,19 +30,19 @@ use Magento\Eav\Exception as EavException; class Datetime extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @param \Magento\Logger $logger - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate */ public function __construct( \Magento\Logger $logger, - \Magento\Core\Model\LocaleInterface $locale + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate ) { - $this->_locale = $locale; + $this->_localeDate = $localeDate; parent::__construct($logger); } @@ -94,18 +94,18 @@ class Datetime extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacke } // unix timestamp given - simply instantiate date object if (preg_match('/^[0-9]+$/', $date)) { - $date = new \Zend_Date((int)$date); + $date = new \Magento\Stdlib\DateTime\Date((int)$date); } // international format else if (preg_match('#^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}:\d{2})?$#', $date)) { - $zendDate = new \Zend_Date(); + $zendDate = new \Magento\Stdlib\DateTime\Date(); $date = $zendDate->setIso($date); } // parse this date in current locale, do not apply GMT offset else { - $date = $this->_locale->date( + $date = $this->_localeDate->date( $date, - $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT), + $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT), null, false ); diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php index 1b04760dc80..6ccebe464ef 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php @@ -28,20 +28,20 @@ namespace Magento\Eav\Model\Entity\Attribute\Frontend; class Datetime extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend { /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @param \Magento\Eav\Model\Entity\Attribute\Source\BooleanFactory $attrBooleanFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate */ function __construct( \Magento\Eav\Model\Entity\Attribute\Source\BooleanFactory $attrBooleanFactory, - \Magento\Core\Model\LocaleInterface $locale + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate ) { parent::__construct($attrBooleanFactory); - $this->_locale = $locale; + $this->_localeDate = $localeDate; } /** @@ -54,15 +54,15 @@ class Datetime extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFron { $data = ''; $value = parent::getValue($object); - $format = $this->_locale->getDateFormat( - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM + $format = $this->_localeDate->getDateFormat( + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM ); if ($value) { try { - $data = $this->_locale->date($value, \Zend_Date::ISO_8601, null, false)->toString($format); + $data = $this->_localeDate->date($value, \Zend_Date::ISO_8601, null, false)->toString($format); } catch (\Exception $e) { - $data = $this->_locale->date($value, null, null, false)->toString($format); + $data = $this->_localeDate->date($value, null, null, false)->toString($format); } } diff --git a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php index c3676831f03..41431ee0883 100644 --- a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php +++ b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php @@ -372,7 +372,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db $this->getSelect()->where($conditionSql, null, \Magento\DB\Select::TYPE_CONDITION); } else { throw new \Magento\Core\Exception( - __('Invalid attribute identifier for filter (' . get_class($attribute) . ')') + __('Invalid attribute identifier for filter (%1)', get_class($attribute)) ); } diff --git a/app/code/Magento/Eav/Model/Entity/Type.php b/app/code/Magento/Eav/Model/Entity/Type.php index 1645cd88521..b46b0aef9ff 100644 --- a/app/code/Magento/Eav/Model/Entity/Type.php +++ b/app/code/Magento/Eav/Model/Entity/Type.php @@ -232,35 +232,40 @@ class Type extends \Magento\Core\Model\AbstractModel // Start transaction to run SELECT ... FOR UPDATE $this->_getResource()->beginTransaction(); - $entityStoreConfig = $this->_storeFactory->create() - ->loadByEntityStore($this->getId(), $storeId); - - if (!$entityStoreConfig->getId()) { - $entityStoreConfig - ->setEntityTypeId($this->getId()) - ->setStoreId($storeId) - ->setIncrementPrefix($storeId) - ->save(); - } + try { + $entityStoreConfig = $this->_storeFactory->create() + ->loadByEntityStore($this->getId(), $storeId); + + if (!$entityStoreConfig->getId()) { + $entityStoreConfig + ->setEntityTypeId($this->getId()) + ->setStoreId($storeId) + ->setIncrementPrefix($storeId) + ->save(); + } + + $incrementInstance = $this->_universalFactory->create($this->getIncrementModel()) + ->setPrefix($entityStoreConfig->getIncrementPrefix()) + ->setPadLength($this->getIncrementPadLength()) + ->setPadChar($this->getIncrementPadChar()) + ->setLastId($entityStoreConfig->getIncrementLastId()) + ->setEntityTypeId($entityStoreConfig->getEntityTypeId()) + ->setStoreId($entityStoreConfig->getStoreId()); - $incrementInstance = $this->_universalFactory->create($this->getIncrementModel()) - ->setPrefix($entityStoreConfig->getIncrementPrefix()) - ->setPadLength($this->getIncrementPadLength()) - ->setPadChar($this->getIncrementPadChar()) - ->setLastId($entityStoreConfig->getIncrementLastId()) - ->setEntityTypeId($entityStoreConfig->getEntityTypeId()) - ->setStoreId($entityStoreConfig->getStoreId()); - - /** - * do read lock on eav/entity_store to solve potential timing issues - * (most probably already done by beginTransaction of entity save) - */ - $incrementId = $incrementInstance->getNextId(); - $entityStoreConfig->setIncrementLastId($incrementId); - $entityStoreConfig->save(); - - // Commit increment_last_id changes - $this->_getResource()->commit(); + /** + * do read lock on eav/entity_store to solve potential timing issues + * (most probably already done by beginTransaction of entity save) + */ + $incrementId = $incrementInstance->getNextId(); + $entityStoreConfig->setIncrementLastId($incrementId); + $entityStoreConfig->save(); + + // Commit increment_last_id changes + $this->_getResource()->commit(); + } catch (\Exception $exception) { + $this->_getResource()->rollBack(); + throw $exception; + } return $incrementId; } diff --git a/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php b/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php index 7d07797f55a..e0d4561657a 100644 --- a/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php +++ b/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php @@ -143,7 +143,7 @@ class Template extends \Magento\Backend\App\Action ->setTemplateCode($request->getParam('template_code')) ->setTemplateText($request->getParam('template_text')) ->setTemplateStyles($request->getParam('template_styles')) - ->setModifiedAt($this->_objectManager->get('Magento\Core\Model\Date')->gmtDate()) + ->setModifiedAt($this->_objectManager->get('Magento\Stdlib\DateTime\DateTime')->gmtDate()) ->setOrigTemplateCode($request->getParam('orig_template_code')) ->setOrigTemplateVariables($request->getParam('orig_template_variables')); diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Fedex.php b/app/code/Magento/Fedex/Model/Carrier.php similarity index 99% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Fedex.php rename to app/code/Magento/Fedex/Model/Carrier.php index 17391a17bd1..a625f9067bc 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Fedex.php +++ b/app/code/Magento/Fedex/Model/Carrier.php @@ -19,13 +19,13 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier; +namespace Magento\Fedex\Model; use Magento\Sales\Model\Quote\Address\RateRequest; +use Magento\Shipping\Model\Carrier\AbstractCarrierOnline; use Magento\Shipping\Model\Rate\Result; /** @@ -33,9 +33,7 @@ use Magento\Shipping\Model\Rate\Result; * * @author Magento Core Team <core@magentocommerce.com> */ -class Fedex - extends \Magento\Usa\Model\Shipping\Carrier\AbstractCarrier - implements \Magento\Shipping\Model\Carrier\CarrierInterface +class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\Carrier\CarrierInterface { /** @@ -134,7 +132,7 @@ class Fedex * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory * @param \Magento\Logger\AdapterFactory $logAdapterFactory - * @param \Magento\Usa\Model\Simplexml\ElementFactory $xmlElFactory + * @param \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory * @param \Magento\Shipping\Model\Rate\ResultFactory $rateFactory * @param \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory * @param \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory @@ -156,7 +154,7 @@ class Fedex \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Magento\Logger\AdapterFactory $logAdapterFactory, - \Magento\Usa\Model\Simplexml\ElementFactory $xmlElFactory, + \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateFactory, \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory, @@ -190,7 +188,7 @@ class Fedex $directoryData, $data ); - $wsdlBasePath = $configReader->getModuleDir('etc', 'Magento_Usa') . '/wsdl/FedEx/'; + $wsdlBasePath = $configReader->getModuleDir('etc', 'Magento_Fedex') . '/wsdl/'; $this->_shipServiceWsdl = $wsdlBasePath . 'ShipService_v10.wsdl'; $this->_rateServiceWsdl = $wsdlBasePath . 'RateService_v10.wsdl'; $this->_trackServiceWsdl = $wsdlBasePath . 'TrackService_v5.wsdl'; @@ -786,7 +784,7 @@ class Fedex * Parse XML string and return XML document object or false * * @param string $xmlContent - * @return \Magento\Usa\Model\Simplexml\Element|bool + * @return \Magento\Shipping\Model\Simplexml\Element|bool * @throws \Exception */ protected function _parseXml($xmlContent) diff --git a/app/code/Magento/Fedex/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php b/app/code/Magento/Fedex/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php new file mode 100644 index 00000000000..f251f352c2a --- /dev/null +++ b/app/code/Magento/Fedex/Model/Plugin/Rma/Block/Adminhtml/Rma/Edit/Tab/General/Shippingmethod.php @@ -0,0 +1,59 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Fedex\Model\Plugin\Rma\Block\Adminhtml\Rma\Edit\Tab\General; + +/** + * Checkout cart shipping block plugin + */ +class Shippingmethod +{ + /** + * @var \Magento\Core\Model\Store\Config + */ + protected $_storeConfig; + + /** + * @param \Magento\Core\Model\Store\Config $storeConfig + */ + public function __construct(\Magento\Core\Model\Store\Config $storeConfig) + { + $this->_storeConfig = $storeConfig; + } + + /** + * @param \Magento\Object $subject + * @param bool $result + * @return bool + */ + public function afterCanDisplayCustomValue( + \Magento\Object $subject, + $result + ) { + $carrierCode = $subject->getShipment()->getCarrierCode(); + if (!$carrierCode) { + return (bool)$result || false; + } + return (bool)$result || (bool)$carrierCode == \Magento\Fedex\Model\Carrier::CODE; + } +} \ No newline at end of file diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Dropoff.php b/app/code/Magento/Fedex/Model/Source/Dropoff.php similarity index 85% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Dropoff.php rename to app/code/Magento/Fedex/Model/Source/Dropoff.php index 1bbeb16d8e9..3c1e78046a7 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Dropoff.php +++ b/app/code/Magento/Fedex/Model/Source/Dropoff.php @@ -19,7 +19,6 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -28,12 +27,11 @@ * Fedex dropoff source implementation * * @category Magento - * @package Magento_Usa * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Usa\Model\Shipping\Carrier\Fedex\Source; +namespace Magento\Fedex\Model\Source; -class Dropoff extends \Magento\Usa\Model\Shipping\Carrier\Fedex\Source\Generic +class Dropoff extends \Magento\Fedex\Model\Source\Generic { /** * Carrier code diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Freemethod.php b/app/code/Magento/Fedex/Model/Source/Freemethod.php similarity index 87% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Freemethod.php rename to app/code/Magento/Fedex/Model/Source/Freemethod.php index b4affd0381a..62083c137e4 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Freemethod.php +++ b/app/code/Magento/Fedex/Model/Source/Freemethod.php @@ -19,21 +19,19 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier\Fedex\Source; +namespace Magento\Fedex\Model\Source; /** * Fedex freemethod source implementation * * @category Magento - * @package Magento_Usa * @author Magento Core Team <core@magentocommerce.com> */ class Freemethod - extends \Magento\Usa\Model\Shipping\Carrier\Fedex\Source\Method + extends \Magento\Fedex\Model\Source\Method { /** * {@inheritdoc} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Generic.php b/app/code/Magento/Fedex/Model/Source/Generic.php similarity index 85% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Generic.php rename to app/code/Magento/Fedex/Model/Source/Generic.php index 595a32f6ff2..3f63baf44b1 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Generic.php +++ b/app/code/Magento/Fedex/Model/Source/Generic.php @@ -22,12 +22,12 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier\Fedex\Source; +namespace Magento\Fedex\Model\Source; class Generic implements \Magento\Option\ArrayInterface { /** - * @var \Magento\Usa\Model\Shipping\Carrier\Fedex + * @var \Magento\Fedex\Model\Carrier */ protected $_shippingFedex; @@ -39,9 +39,9 @@ class Generic implements \Magento\Option\ArrayInterface protected $_code = ''; /** - * @param \Magento\Usa\Model\Shipping\Carrier\Fedex $shippingFedex + * @param \Magento\Fedex\Model\Carrier $shippingFedex */ - public function __construct(\Magento\Usa\Model\Shipping\Carrier\Fedex $shippingFedex) + public function __construct(\Magento\Fedex\Model\Carrier $shippingFedex) { $this->_shippingFedex = $shippingFedex; } diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Method.php b/app/code/Magento/Fedex/Model/Source/Method.php similarity index 85% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Method.php rename to app/code/Magento/Fedex/Model/Source/Method.php index d86dc059673..68b6f6c1078 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Method.php +++ b/app/code/Magento/Fedex/Model/Source/Method.php @@ -19,7 +19,6 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -28,12 +27,11 @@ * Fedex method source implementation * * @category Magento - * @package Magento_Usa * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Usa\Model\Shipping\Carrier\Fedex\Source; +namespace Magento\Fedex\Model\Source; -class Method extends \Magento\Usa\Model\Shipping\Carrier\Fedex\Source\Generic +class Method extends \Magento\Fedex\Model\Source\Generic { /** * Carrier code diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Packaging.php b/app/code/Magento/Fedex/Model/Source/Packaging.php similarity index 85% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Packaging.php rename to app/code/Magento/Fedex/Model/Source/Packaging.php index 46277443008..6051a696a81 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Fedex/Source/Packaging.php +++ b/app/code/Magento/Fedex/Model/Source/Packaging.php @@ -19,7 +19,6 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -28,12 +27,11 @@ * Fedex packaging source implementation * * @category Magento - * @package Magento_Usa * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Usa\Model\Shipping\Carrier\Fedex\Source; +namespace Magento\Fedex\Model\Source; -class Packaging extends \Magento\Usa\Model\Shipping\Carrier\Fedex\Source\Generic +class Packaging extends \Magento\Fedex\Model\Source\Generic { /** * Carrier code diff --git a/app/code/Magento/Fedex/etc/adminhtml/system.xml b/app/code/Magento/Fedex/etc/adminhtml/system.xml new file mode 100644 index 00000000000..a6bf2f47e8f --- /dev/null +++ b/app/code/Magento/Fedex/etc/adminhtml/system.xml @@ -0,0 +1,145 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <system> + <section id="carriers"> + <group id="fedex" translate="label" type="text" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>FedEx</label> + <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled for Checkout</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Title</label> + </field> + <field id="account" translate="label comment" type="obscure" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Account ID</label> + <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> + <comment>Please make sure to use only digits here. No dashes are allowed.</comment> + </field> + <field id="meter_number" translate="label" type="obscure" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Meter Number</label> + <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> + </field> + <field id="key" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Key</label> + <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> + </field> + <field id="password" translate="label" type="obscure" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Password</label> + <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> + </field> + <field id="sandbox_mode" translate="label" type="select" sortOrder="75" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Sandbox Mode</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="shipment_requesttype" translate="label" type="select" sortOrder="77" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Packages Request Type</label> + <source_model>Magento\Shipping\Model\Config\Source\Online\Requesttype</source_model> + </field> + <field id="packaging" translate="label" type="select" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Packaging</label> + <source_model>Magento\Fedex\Model\Source\Packaging</source_model> + </field> + <field id="dropoff" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Dropoff</label> + <source_model>Magento\Fedex\Model\Source\Dropoff</source_model> + </field> + <field id="max_package_weight" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="handling_type" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Calculate Handling Fee</label> + <source_model>Magento\Shipping\Model\Source\HandlingType</source_model> + </field> + <field id="handling_action" translate="label" type="select" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Handling Applied</label> + <source_model>Magento\Shipping\Model\Source\HandlingAction</source_model> + </field> + <field id="handling_fee" translate="label" type="text" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Handling Fee</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="residence_delivery" translate="label" type="select" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Residential Delivery</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="allowed_methods" translate="label" type="multiselect" sortOrder="150" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Allowed Methods</label> + <source_model>Magento\Fedex\Model\Source\Method</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="smartpost_hubid" translate="label comment" type="text" sortOrder="155" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Hub ID</label> + <comment>The field is applicable if the Smart Post method is selected.</comment> + </field> + <field id="free_method" translate="label" type="select" sortOrder="160" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Free Method</label> + <frontend_class>free-method</frontend_class> + <source_model>Magento\Fedex\Model\Source\Freemethod</source_model> + </field> + <field id="free_shipping_enable" translate="label" type="select" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Free Shipping Amount Threshold</label> + <source_model>Magento\Backend\Model\Config\Source\Enabledisable</source_model> + </field> + <field id="free_shipping_subtotal" translate="label" type="text" sortOrder="180" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Free Shipping Amount Threshold</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="specificerrmsg" translate="label" type="textarea" sortOrder="190" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Displayed Error Message</label> + </field> + <field id="sallowspecific" translate="label" type="select" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ship to Applicable Countries</label> + <frontend_class>shipping-applicable-country</frontend_class> + <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> + </field> + <field id="specificcountry" translate="label" type="multiselect" sortOrder="210" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ship to Specific Countries</label> + <source_model>Magento\Directory\Model\Config\Source\Country</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="debug" translate="label" type="select" sortOrder="220" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Debug</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="showmethod" translate="label" type="select" sortOrder="230" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Show Method if Not Applicable</label> + <frontend_class>shipping-skip-hide</frontend_class> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="sort_order" translate="label" type="text" sortOrder="240" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Sort Order</label> + </field> + <field id="active_rma" translate="label" type="select" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled for RMA</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + </group> + </section> + </system> +</config> diff --git a/app/code/Magento/Fedex/etc/config.xml b/app/code/Magento/Fedex/etc/config.xml new file mode 100644 index 00000000000..55098b37332 --- /dev/null +++ b/app/code/Magento/Fedex/etc/config.xml @@ -0,0 +1,56 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <default> + <carriers> + <fedex> + <account backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> + <meter_number backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> + <key backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> + <password backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> + <sandbox_mode>0</sandbox_mode> + <shipment_requesttype>0</shipment_requesttype> + <active>0</active> + <sallowspecific>0</sallowspecific> + <allowed_methods>EUROPE_FIRST_INTERNATIONAL_PRIORITY,FEDEX_1_DAY_FREIGHT,FEDEX_2_DAY_FREIGHT,FEDEX_2_DAY,FEDEX_2_DAY_AM,FEDEX_3_DAY_FREIGHT,FEDEX_EXPRESS_SAVER,FEDEX_GROUND,FIRST_OVERNIGHT,GROUND_HOME_DELIVERY,INTERNATIONAL_ECONOMY,INTERNATIONAL_ECONOMY_FREIGHT,INTERNATIONAL_FIRST,INTERNATIONAL_GROUND,INTERNATIONAL_PRIORITY,INTERNATIONAL_PRIORITY_FREIGHT,PRIORITY_OVERNIGHT,SMART_POST,STANDARD_OVERNIGHT,FEDEX_FREIGHT,FEDEX_NATIONAL_FREIGHT</allowed_methods> + <cutoff_cost /> + <dropoff>REGULAR_PICKUP</dropoff> + <free_method>FEDEX_GROUND</free_method> + <handling>0</handling> + <model>Magento\Fedex\Model\Carrier</model> + <packaging>YOUR_PACKAGING</packaging> + <title>Federal Express</title> + <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg> + <max_package_weight>150</max_package_weight> + <handling_type>F</handling_type> + <handling_action>O</handling_action> + <active_rma>0</active_rma> + <is_online>1</is_online> + </fedex> + </carriers> + </default> +</config> diff --git a/app/code/Magento/Fedex/etc/di.xml b/app/code/Magento/Fedex/etc/di.xml new file mode 100644 index 00000000000..f0d56def09f --- /dev/null +++ b/app/code/Magento/Fedex/etc/di.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <type name="Magento\Module\Updater\SetupFactory"> + <arguments> + <argument name="resourceTypes" xsi:type="array"> + <item name="fedex_setup" xsi:type="string">Magento\Core\Model\Resource\Setup</item> + </argument> + </arguments> + </type> + <type name="Magento\Rma\Block\Adminhtml\Rma\Edit\Tab\General\Shippingmethod"> + <plugin name="rma_tab_shippingmethod_fedex" + type="Magento\Fedex\Model\Plugin\Rma\Block\Adminhtml\Rma\Edit\Tab\General\Shippingmethod"/> + </type> +</config> diff --git a/app/code/Magento/Fedex/etc/module.xml b/app/code/Magento/Fedex/etc/module.xml new file mode 100644 index 00000000000..cfab469316a --- /dev/null +++ b/app/code/Magento/Fedex/etc/module.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <module name="Magento_Fedex" version="2.0.0.0" active="true"> + <depends> + <module name="Magento_Shipping"/> + <module name="Magento_Directory"/> + <module name="Magento_Core"/> + <module name="Magento_Catalog"/> + <module name="Magento_Sales"/> + </depends> + </module> +</config> diff --git a/app/code/Magento/Usa/etc/wsdl/FedEx/RateService_v10.wsdl b/app/code/Magento/Fedex/etc/wsdl/RateService_v10.wsdl similarity index 100% rename from app/code/Magento/Usa/etc/wsdl/FedEx/RateService_v10.wsdl rename to app/code/Magento/Fedex/etc/wsdl/RateService_v10.wsdl diff --git a/app/code/Magento/Usa/etc/wsdl/FedEx/RateService_v9.wsdl b/app/code/Magento/Fedex/etc/wsdl/RateService_v9.wsdl similarity index 100% rename from app/code/Magento/Usa/etc/wsdl/FedEx/RateService_v9.wsdl rename to app/code/Magento/Fedex/etc/wsdl/RateService_v9.wsdl diff --git a/app/code/Magento/Usa/etc/wsdl/FedEx/ShipService_v10.wsdl b/app/code/Magento/Fedex/etc/wsdl/ShipService_v10.wsdl similarity index 100% rename from app/code/Magento/Usa/etc/wsdl/FedEx/ShipService_v10.wsdl rename to app/code/Magento/Fedex/etc/wsdl/ShipService_v10.wsdl diff --git a/app/code/Magento/Usa/etc/wsdl/FedEx/ShipService_v9.wsdl b/app/code/Magento/Fedex/etc/wsdl/ShipService_v9.wsdl similarity index 100% rename from app/code/Magento/Usa/etc/wsdl/FedEx/ShipService_v9.wsdl rename to app/code/Magento/Fedex/etc/wsdl/ShipService_v9.wsdl diff --git a/app/code/Magento/Usa/etc/wsdl/FedEx/TrackService_v5.wsdl b/app/code/Magento/Fedex/etc/wsdl/TrackService_v5.wsdl similarity index 100% rename from app/code/Magento/Usa/etc/wsdl/FedEx/TrackService_v5.wsdl rename to app/code/Magento/Fedex/etc/wsdl/TrackService_v5.wsdl diff --git a/app/code/Magento/Usa/sql/usa_setup/upgrade-1.6.0.0-1.6.0.1.php b/app/code/Magento/Fedex/sql/fedex_setup/install-2.0.0.0.php similarity index 98% rename from app/code/Magento/Usa/sql/usa_setup/upgrade-1.6.0.0-1.6.0.1.php rename to app/code/Magento/Fedex/sql/fedex_setup/install-2.0.0.0.php index 660b9a39a3a..764b8a535ab 100644 --- a/app/code/Magento/Usa/sql/usa_setup/upgrade-1.6.0.0-1.6.0.1.php +++ b/app/code/Magento/Fedex/sql/fedex_setup/install-2.0.0.0.php @@ -19,11 +19,11 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +/** @var \Magento\Core\Model\Resource\Setup $this */ $codes = array( 'method' => array( 'EUROPEFIRSTINTERNATIONALPRIORITY' => 'EUROPE_FIRST_INTERNATIONAL_PRIORITY', diff --git a/app/code/Magento/GiftMessage/Block/Message/Multishipping/Plugin/ItemsBox.php b/app/code/Magento/GiftMessage/Block/Message/Multishipping/Plugin/ItemsBox.php index 05163ed7ced..ae6540a8683 100644 --- a/app/code/Magento/GiftMessage/Block/Message/Multishipping/Plugin/ItemsBox.php +++ b/app/code/Magento/GiftMessage/Block/Message/Multishipping/Plugin/ItemsBox.php @@ -24,7 +24,6 @@ namespace Magento\GiftMessage\Block\Message\Multishipping\Plugin; -use Magento\Code\Plugin\InvocationChain; /** * Multishipping items box plugin @@ -51,13 +50,19 @@ class ItemsBox /** * Get items box message text for multishipping * - * @param array $arguments - * @param InvocationChain $invocationChain + * @param \Magento\Multishipping\Block\Checkout\Shipping $subject + * @param callable $proceed + * @param \Magento\Object $addressEntity + * * @return string + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundGetItemsBoxTextAfter(array $arguments, InvocationChain $invocationChain) - { - $itemsBoxText = $invocationChain->proceed($arguments); - return $itemsBoxText . $this->helper->getInline('multishipping_address', $arguments[0]); + public function aroundGetItemsBoxTextAfter( + \Magento\Multishipping\Block\Checkout\Shipping $subject, + \Closure $proceed, + \Magento\Object $addressEntity + ) { + $itemsBoxText = $proceed($addressEntity); + return $itemsBoxText . $this->helper->getInline('multishipping_address', $addressEntity); } } diff --git a/app/code/Magento/GiftMessage/Helper/Message.php b/app/code/Magento/GiftMessage/Helper/Message.php index 18a1cbc38f7..0741794cc4b 100644 --- a/app/code/Magento/GiftMessage/Helper/Message.php +++ b/app/code/Magento/GiftMessage/Helper/Message.php @@ -76,7 +76,6 @@ class Message extends \Magento\Core\Helper\Data * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Locale $locale * @param \Magento\App\State $appState * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\View\LayoutFactory $layoutFactory @@ -88,7 +87,6 @@ class Message extends \Magento\Core\Helper\Data \Magento\App\Helper\Context $context, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Locale $locale, \Magento\App\State $appState, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\View\LayoutFactory $layoutFactory, @@ -104,7 +102,6 @@ class Message extends \Magento\Core\Helper\Data $context, $coreStoreConfig, $storeManager, - $locale, $appState, $dbCompatibleMode ); diff --git a/app/code/Magento/GiftMessage/Model/Plugin/QuoteItem.php b/app/code/Magento/GiftMessage/Model/Plugin/QuoteItem.php index 7e7c4fe43d2..edddbc80874 100644 --- a/app/code/Magento/GiftMessage/Model/Plugin/QuoteItem.php +++ b/app/code/Magento/GiftMessage/Model/Plugin/QuoteItem.php @@ -40,23 +40,27 @@ class QuoteItem } /** - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\Sales\Model\Convert\Quote $subject + * @param callable $proceed + * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item + * * @return \Magento\Sales\Model\Order\Item|mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundItemToOrderItem(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { + public function aroundItemToOrderItem( + \Magento\Sales\Model\Convert\Quote $subject, + \Closure $proceed, + \Magento\Sales\Model\Quote\Item\AbstractItem $item + ) { /** @var $orderItem \Magento\Sales\Model\Order\Item */ - $orderItem = $invocationChain->proceed($arguments); - $quoteItem = reset($arguments); - + $orderItem = $proceed($item); $isAvailable = $this->_helper->isMessagesAvailable( 'item', - $quoteItem, - $quoteItem->getStoreId() + $item, + $item->getStoreId() ); - $orderItem->setGiftMessageId($quoteItem->getGiftMessageId()); + $orderItem->setGiftMessageId($item->getGiftMessageId()); $orderItem->setGiftMessageAvailable($isAvailable); return $orderItem; } diff --git a/app/code/Magento/GiftMessage/etc/module.xml b/app/code/Magento/GiftMessage/etc/module.xml index 26d9067e917..e816a3dcc67 100644 --- a/app/code/Magento/GiftMessage/etc/module.xml +++ b/app/code/Magento/GiftMessage/etc/module.xml @@ -31,6 +31,7 @@ </sequence> <depends> <module name="Magento_Catalog"/> + <module name="Magento_Multishipping"/> <module name="Magento_Sales"/> <module name="Magento_Backend"/> <module name="Magento_Core"/> diff --git a/app/code/Magento/GoogleAdwords/Model/Config/Source/Language.php b/app/code/Magento/GoogleAdwords/Model/Config/Source/Language.php index 486ec5e0f1d..774432d3972 100644 --- a/app/code/Magento/GoogleAdwords/Model/Config/Source/Language.php +++ b/app/code/Magento/GoogleAdwords/Model/Config/Source/Language.php @@ -31,7 +31,7 @@ namespace Magento\GoogleAdwords\Model\Config\Source; class Language implements \Magento\Option\ArrayInterface { /** - * @var \Zend_Locale + * @var \Magento\LocaleInterface */ protected $_locale; @@ -48,17 +48,17 @@ class Language implements \Magento\Option\ArrayInterface /** * Constructor * - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\GoogleAdwords\Helper\Data $helper * @param \Magento\GoogleAdwords\Model\Filter\UppercaseTitle $uppercaseFilter */ public function __construct( - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\GoogleAdwords\Helper\Data $helper, \Magento\GoogleAdwords\Model\Filter\UppercaseTitle $uppercaseFilter ) { $this->_helper = $helper; - $this->_locale = $locale->getLocale(); + $this->_locale = $localeResolver->getLocale(); $this->_uppercaseFilter = $uppercaseFilter; } diff --git a/app/code/Magento/GoogleCheckout/Controller/Redirect.php b/app/code/Magento/GoogleCheckout/Controller/Redirect.php index bd89956fd35..fe9c888c50f 100644 --- a/app/code/Magento/GoogleCheckout/Controller/Redirect.php +++ b/app/code/Magento/GoogleCheckout/Controller/Redirect.php @@ -32,6 +32,7 @@ namespace Magento\GoogleCheckout\Controller; class Redirect extends \Magento\App\Action\Action + implements \Magento\Checkout\Controller\Express\RedirectLoginInterface { /** * Send request to Google Checkout and return Response Api @@ -62,16 +63,6 @@ class Redirect extends \Magento\App\Action\Action ->setChangedFlag(false); $storeQuote->save(); - /* - * Set payment method to google checkout, so all price rules will work out this case - * and will use right sales rules - */ - if ($quote->isVirtual()) { - $quote->getBillingAddress()->setPaymentMethod('googlecheckout'); - } else { - $quote->getShippingAddress()->setPaymentMethod('googlecheckout'); - } - $quote->collectTotals()->save(); if (!$api->getError()) { @@ -176,16 +167,38 @@ class Redirect extends \Magento\App\Action\Action } /** - * Redirect to login page + * Returns before_auth_url redirect parameter for customer session + * @return null */ - public function redirectLogin() + public function getCustomerBeforeAuthUrl() { - $this->_actionFlag->set('', 'no-dispatch', true); - $this->getResponse()->setRedirect( - $this->_objectManager->get('Magento\Core\Helper\Url')->addRequestParam( - $this->_objectManager->get('Magento\Customer\Helper\Data')->getLoginUrl(), - array('context' => 'checkout') - ) - ); + return; + } + + /** + * Returns a list of action flags [flag_key] => boolean + * @return array + */ + public function getActionFlagList() + { + return array(); + } + + /** + * Returns login url parameter for redirect + * @return string + */ + public function getLoginUrl() + { + return $this->_objectManager->get('Magento\Customer\Helper\Data')->getLoginUrl(); + } + + /** + * Returns action name which requires redirect + * @return string + */ + public function getRedirectActionName() + { + return 'checkout'; } } diff --git a/app/code/Magento/GoogleCheckout/Model/Api/Xml/Callback.php b/app/code/Magento/GoogleCheckout/Model/Api/Xml/Callback.php index 16660063452..8bf81936c5c 100644 --- a/app/code/Magento/GoogleCheckout/Model/Api/Xml/Callback.php +++ b/app/code/Magento/GoogleCheckout/Model/Api/Xml/Callback.php @@ -185,11 +185,7 @@ class Callback extends \Magento\GoogleCheckout\Model\Api\Xml\AbstractXml $quote = $this->objectManager->create('Magento\Sales\Model\Quote') ->setStoreId($storeId) ->load($quoteId); - if ($quote->isVirtual()) { - $quote->getBillingAddress()->setPaymentMethod('googlecheckout'); - } else { - $quote->getShippingAddress()->setPaymentMethod('googlecheckout'); - } + return $quote; } @@ -858,7 +854,7 @@ class Callback extends \Magento\GoogleCheckout\Model\Api\Xml\AbstractXml $payment->setAmountAuthorized($this->getData('root/authorization-amount/VALUE')); $expDate = $this->getData('root/authorization-expiration-date/VALUE'); - $expDate = new \Zend_Date($expDate); + $expDate = new \Magento\Stdlib\DateTime\Date($expDate); $msg = __('Google Authorization:'); $msg .= '<br />' . __('Amount: %1', '<strong>' . $this->_formatAmount($payment->getAmountAuthorized()) . '</strong>'); @@ -867,11 +863,11 @@ class Callback extends \Magento\GoogleCheckout\Model\Api\Xml\AbstractXml $order->addStatusToHistory($order->getStatus(), $msg); $order->setPaymentAuthorizationAmount($payment->getAmountAuthorized()); - $timestamp = $this->objectManager->create('Magento\Core\Model\Date')->gmtTimestamp( + $timestamp = $this->objectManager->create('Magento\Stdlib\DateTime\DateTime')->gmtTimestamp( $this->getData('root/authorization-expiration-date/VALUE') ); $order->setPaymentAuthorizationExpiration( - $timestamp ? $timestamp : $this->objectManager->create('Magento\Core\Model\Date')->gmtTimestamp() + $timestamp ? $timestamp : $this->objectManager->create('Magento\Stdlib\DateTime\DateTime')->gmtTimestamp() ); $order->save(); diff --git a/app/code/Magento/GoogleCheckout/Model/Api/Xml/Checkout.php b/app/code/Magento/GoogleCheckout/Model/Api/Xml/Checkout.php index 599e97d05a3..9ef8be655e9 100644 --- a/app/code/Magento/GoogleCheckout/Model/Api/Xml/Checkout.php +++ b/app/code/Magento/GoogleCheckout/Model/Api/Xml/Checkout.php @@ -33,6 +33,8 @@ */ namespace Magento\GoogleCheckout\Model\Api\Xml; +use Magento\Shipping\Model\Carrier\AbstractCarrierOnline; + class Checkout extends \Magento\GoogleCheckout\Model\Api\Xml\AbstractXml { /** @@ -853,7 +855,7 @@ EOT; <tax-areas> EOT; - if ($rate['country'] === \Magento\Usa\Model\Shipping\Carrier\AbstractCarrier::USA_COUNTRY_ID) { + if ($rate['country'] === AbstractCarrierOnline::USA_COUNTRY_ID) { if (!empty($rate['postcode']) && $rate['postcode'] !== '*') { $rate['postcode'] = $this->_googleCheckoutData ->zipRangeToZipPattern($rate['postcode']); diff --git a/app/code/Magento/GoogleCheckout/Model/Payment.php b/app/code/Magento/GoogleCheckout/Model/Payment.php index d7c5dfd8bef..609fb268c1c 100644 --- a/app/code/Magento/GoogleCheckout/Model/Payment.php +++ b/app/code/Magento/GoogleCheckout/Model/Payment.php @@ -58,7 +58,7 @@ class Payment extends \Magento\Payment\Model\Method\AbstractMethod protected $urlFactory; /** - * @var \Magento\Core\Model\DateFactory + * @var \Magento\Stdlib\DateTime\DateTimeFactory */ protected $dateFactory; @@ -67,7 +67,7 @@ class Payment extends \Magento\Payment\Model\Method\AbstractMethod \Magento\Payment\Helper\Data $paymentData, \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, \Magento\Logger\AdapterFactory $logAdapterFactory, - \Magento\Core\Model\DateFactory $dateFactory, + \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory, \Magento\UrlFactory $urlFactory, \Magento\GoogleCheckout\Model\ApiFactory $apiFactory, array $data = array() diff --git a/app/code/Magento/GoogleCheckout/etc/module.xml b/app/code/Magento/GoogleCheckout/etc/module.xml index b15e145dbee..411d1748af2 100755 --- a/app/code/Magento/GoogleCheckout/etc/module.xml +++ b/app/code/Magento/GoogleCheckout/etc/module.xml @@ -28,12 +28,10 @@ <sequence> <module name="Magento_Sales"/> <module name="Magento_Payment"/> - <module name="Magento_Usa"/> </sequence> <depends> <module name="Magento_Sales"/> <module name="Magento_Payment"/> - <module name="Magento_Usa"/> <module name="Magento_Core"/> <module name="Magento_Checkout"/> <module name="Magento_Customer"/> diff --git a/app/code/Magento/GoogleOptimizer/Block/Code/Category.php b/app/code/Magento/GoogleOptimizer/Block/Code/Category.php index 7b715386d12..d22156d8e17 100644 --- a/app/code/Magento/GoogleOptimizer/Block/Code/Category.php +++ b/app/code/Magento/GoogleOptimizer/Block/Code/Category.php @@ -25,10 +25,20 @@ */ namespace Magento\GoogleOptimizer\Block\Code; -class Category extends \Magento\GoogleOptimizer\Block\AbstractCode +class Category extends \Magento\GoogleOptimizer\Block\AbstractCode implements \Magento\View\Block\IdentityInterface { /** - * @var Entity name in registry + * @var string Entity name in registry */ protected $_registryName = 'current_category'; + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + return $this->_getEntity()->getIdentities(); + } } diff --git a/app/code/Magento/GoogleOptimizer/Block/Code/Product.php b/app/code/Magento/GoogleOptimizer/Block/Code/Product.php index bb8cd541f3b..446cb0f0140 100644 --- a/app/code/Magento/GoogleOptimizer/Block/Code/Product.php +++ b/app/code/Magento/GoogleOptimizer/Block/Code/Product.php @@ -25,10 +25,20 @@ */ namespace Magento\GoogleOptimizer\Block\Code; -class Product extends \Magento\GoogleOptimizer\Block\AbstractCode +class Product extends \Magento\GoogleOptimizer\Block\AbstractCode implements \Magento\View\Block\IdentityInterface { /** - * @var Entity name in registry + * @var Product name in registry */ protected $_registryName = 'current_product'; + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + return $this->_getEntity()->getIdentities(); + } } diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/DefaultAttribute.php b/app/code/Magento/GoogleShopping/Model/Attribute/DefaultAttribute.php index cce5bf6fc20..23d25006dc0 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/DefaultAttribute.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/DefaultAttribute.php @@ -90,7 +90,7 @@ class DefaultAttribute extends \Magento\GoogleShopping\Model\Attribute if (empty($value) || !\Zend_Date::isDate($value, \Zend_Date::ISO_8601)) { return null; } - $date = new \Zend_Date($value, \Zend_Date::ISO_8601); + $date = new \Magento\Stdlib\DateTime\Date($value, \Zend_Date::ISO_8601); $value = $date->toString(\Zend_Date::ATOM); } else { $value = $productAttribute->getFrontend()->getValue($product); diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/SalePriceEffectiveDate.php b/app/code/Magento/GoogleShopping/Model/Attribute/SalePriceEffectiveDate.php index b8f8ce8dca3..bfb01307de5 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/SalePriceEffectiveDate.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/SalePriceEffectiveDate.php @@ -52,10 +52,10 @@ class SalePriceEffectiveDate extends \Magento\GoogleShopping\Model\Attribute\Def $from = $to = null; if (!empty($fromValue) && \Zend_Date::isDate($fromValue, \Zend_Date::ATOM)) { - $from = new \Zend_Date($fromValue, \Zend_Date::ATOM); + $from = new \Magento\Stdlib\DateTime\Date($fromValue, \Zend_Date::ATOM); } if (!empty($toValue) && \Zend_Date::isDate($toValue, \Zend_Date::ATOM)) { - $to = new \Zend_Date($toValue, \Zend_Date::ATOM); + $to = new \Magento\Stdlib\DateTime\Date($toValue, \Zend_Date::ATOM); } $dateString = null; @@ -71,7 +71,7 @@ class SalePriceEffectiveDate extends \Magento\GoogleShopping\Model\Attribute\Def // if we have only "to" date, use "now" date for "from" if (is_null($from) && !is_null($to)) { - $from = new \Zend_Date(); + $from = new \Magento\Stdlib\DateTime\Date(); // if "now" date is earlier than "to" date if ($from->isEarlier($to)) { $dateString = $from->toString(\Zend_Date::ATOM) . '/' . $to->toString(\Zend_Date::ATOM); diff --git a/app/code/Magento/GoogleShopping/Model/Service/Item.php b/app/code/Magento/GoogleShopping/Model/Service/Item.php index 3baca8e8ca6..722acf3c887 100644 --- a/app/code/Magento/GoogleShopping/Model/Service/Item.php +++ b/app/code/Magento/GoogleShopping/Model/Service/Item.php @@ -42,7 +42,7 @@ class Item extends \Magento\GoogleShopping\Model\Service /** * Date * - * @var \Magento\Core\Model\Date|null + * @var \Magento\Stdlib\DateTime\DateTime|null */ protected $_date; @@ -51,7 +51,7 @@ class Item extends \Magento\GoogleShopping\Model\Service * @param \Magento\Registry $coreRegistry * @param \Magento\GoogleShopping\Model\Config $config * @param \Magento\Gdata\Gshopping\ContentFactory $contentFactory - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\GoogleShopping\Helper\Data $gsData * @param array $data */ @@ -60,7 +60,7 @@ class Item extends \Magento\GoogleShopping\Model\Service \Magento\Registry $coreRegistry, \Magento\GoogleShopping\Model\Config $config, \Magento\Gdata\Gshopping\ContentFactory $contentFactory, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\GoogleShopping\Helper\Data $gsData, array $data = array() ) { diff --git a/app/code/Magento/GroupedProduct/Block/Adminhtml/Order/Create/Sidebar.php b/app/code/Magento/GroupedProduct/Block/Adminhtml/Order/Create/Sidebar.php index ab3b73c2896..1c97087e2cc 100644 --- a/app/code/Magento/GroupedProduct/Block/Adminhtml/Order/Create/Sidebar.php +++ b/app/code/Magento/GroupedProduct/Block/Adminhtml/Order/Create/Sidebar.php @@ -29,35 +29,42 @@ class Sidebar /** * Get item qty * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain - * @return mixed|string + * @param \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject + * @param callable $proceed + * @param \Magento\Object $item + * + * @return string + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundGetItemQty(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - /** @var \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface $item */ - $item = $arguments[0]; + public function aroundGetItemQty( + \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject, + \Closure $proceed, + \Magento\Object $item + ) { if ($item->getProduct()->getTypeId() == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) { return ''; } - return $invocationChain->proceed($arguments); + return $proceed($item); } /** * Check whether product configuration is required before adding to order * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain - * @return bool|mixed + * @param \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject + * @param callable $proceed + * @param string $productType + * + * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundIsConfigurationRequired( - array $arguments, - \Magento\Code\Plugin\InvocationChain $invocationChain + \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject, + \Closure $proceed, + $productType ) { - $typeId = $arguments[0]; - if ($typeId == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) { + if ($productType == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) { return true; } - return $invocationChain->proceed($arguments); + return $proceed($productType); } } diff --git a/app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php b/app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php index 023ff092d1c..318c3cc855e 100644 --- a/app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php +++ b/app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php @@ -29,7 +29,7 @@ use Magento\Catalog\Model\Config\Source\Product\Thumbnail as ThumbnailSource; /** * Shopping cart item render block */ -class Grouped extends \Magento\Checkout\Block\Cart\Item\Renderer +class Grouped extends \Magento\Checkout\Block\Cart\Item\Renderer implements \Magento\View\Block\IdentityInterface { /** * Path in config to the setting which defines if parent or child product should be used to generate a thumbnail. @@ -98,4 +98,18 @@ class Grouped extends \Magento\Checkout\Block\Cart\Item\Renderer } return $product; } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + $identities = parent::getIdentities(); + if ($this->getItem()) { + $identities = array_merge($identities, $this->getGroupedProduct()->getIdentities()); + } + return $identities; + } } diff --git a/app/code/Magento/GroupedProduct/Block/Stockqty/Type/Grouped.php b/app/code/Magento/GroupedProduct/Block/Stockqty/Type/Grouped.php index 1c66ad885e6..a69bd7d7b43 100644 --- a/app/code/Magento/GroupedProduct/Block/Stockqty/Type/Grouped.php +++ b/app/code/Magento/GroupedProduct/Block/Stockqty/Type/Grouped.php @@ -27,6 +27,7 @@ namespace Magento\GroupedProduct\Block\Stockqty\Type; class Grouped extends \Magento\CatalogInventory\Block\Stockqty\Composite + implements \Magento\View\Block\IdentityInterface { /** * Retrieve child products @@ -37,4 +38,18 @@ class Grouped extends \Magento\CatalogInventory\Block\Stockqty\Composite { return $this->getProduct()->getTypeInstance()->getAssociatedProducts($this->getProduct()); } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + $identities = array(); + foreach ($this->getChildProducts() as $item) { + $identities = array_merge($identities, $item->getIdentities()); + } + return $identities; + } } diff --git a/app/code/Magento/GroupedProduct/Controller/Adminhtml/Product/Initialization/Helper/ProductLinks/Plugin/Grouped.php b/app/code/Magento/GroupedProduct/Controller/Adminhtml/Product/Initialization/Helper/ProductLinks/Plugin/Grouped.php index a02edc6ad23..5319c02c2a9 100644 --- a/app/code/Magento/GroupedProduct/Controller/Adminhtml/Product/Initialization/Helper/ProductLinks/Plugin/Grouped.php +++ b/app/code/Magento/GroupedProduct/Controller/Adminhtml/Product/Initialization/Helper/ProductLinks/Plugin/Grouped.php @@ -42,11 +42,16 @@ class Grouped /** * Initialize grouped product links * + * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\ProductLinks $subject * @param \Magento\Catalog\Model\Product $product + * * @return \Magento\Catalog\Model\Product + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterInitializeLinks(\Magento\Catalog\Model\Product $product) - { + public function afterInitializeLinks( + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\ProductLinks $subject, + \Magento\Catalog\Model\Product $product + ) { $links = $this->request->getPost('links'); if (isset($links['grouped']) && !$product->getGroupedReadonly()) { diff --git a/app/code/Magento/GroupedProduct/Helper/Product/Configuration/Plugin/Grouped.php b/app/code/Magento/GroupedProduct/Helper/Product/Configuration/Plugin/Grouped.php index abab75e6fb1..982aeaf12e6 100644 --- a/app/code/Magento/GroupedProduct/Helper/Product/Configuration/Plugin/Grouped.php +++ b/app/code/Magento/GroupedProduct/Helper/Product/Configuration/Plugin/Grouped.php @@ -29,14 +29,18 @@ class Grouped /** * Retrieves grouped product options list * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain - * @return mixed + * @param \Magento\Catalog\Helper\Product\Configuration $subject + * @param callable $proceed + * @param \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface $item + * + * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundGetOptions(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - /** @var \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface $item */ - $item = $arguments['item']; + public function aroundGetOptions( + \Magento\Catalog\Helper\Product\Configuration $subject, + \Closure $proceed, + \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface $item + ) { $product = $item->getProduct(); $typeId = $product->getTypeId(); if ($typeId == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) { @@ -56,7 +60,7 @@ class Grouped } } - $options = array_merge($options, $invocationChain->proceed($arguments)); + $options = array_merge($options, $proceed($item)); $isUnConfigured = true; foreach ($options as &$option) { if ($option['value']) { @@ -66,6 +70,6 @@ class Grouped } return $isUnConfigured ? array() : $options; } - return $invocationChain->proceed($arguments); + return $proceed($item); } } diff --git a/app/code/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/Grouped.php b/app/code/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/Grouped.php index 986a14ac09a..983d60d887e 100644 --- a/app/code/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/Grouped.php @@ -31,18 +31,24 @@ class Grouped /** * Decide whether product has been configured for cart or not * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\Catalog\Model\Product\CartConfiguration $subject + * @param callable $proceed + * @param \Magento\Catalog\Model\Product $product + * @param array $config + * * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundIsProductConfigured(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - list($product, $config) = $arguments; - + public function aroundIsProductConfigured( + \Magento\Catalog\Model\Product\CartConfiguration $subject, + \Closure $proceed, + \Magento\Catalog\Model\Product $product, + $config + ) { if ($product->getTypeId() == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) { return isset($config['super_group']); } - return $invocationChain->proceed($arguments); + return $proceed($product, $config); } } diff --git a/app/code/Magento/GroupedProduct/Model/Product/Type/Plugin.php b/app/code/Magento/GroupedProduct/Model/Product/Type/Plugin.php index a77bf06d464..acd25673ac5 100644 --- a/app/code/Magento/GroupedProduct/Model/Product/Type/Plugin.php +++ b/app/code/Magento/GroupedProduct/Model/Product/Type/Plugin.php @@ -45,10 +45,13 @@ class Plugin /** * Remove grouped product from list of visible product types * + * @param \Magento\Catalog\Model\Product\Type $subject * @param array $result + * * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterGetOptionArray($result) + public function afterGetOptionArray(\Magento\Catalog\Model\Product\Type $subject, array $result) { if (!$this->moduleManager->isOutputEnabled('Magento_GroupedProduct')) { unset($result[Grouped::TYPE_CODE]); diff --git a/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php b/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php index bae0ea2b2d9..9bb36618899 100644 --- a/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php +++ b/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php @@ -64,7 +64,7 @@ class AssociatedProductsCollection * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Registry $coreRegistry @@ -89,7 +89,7 @@ class AssociatedProductsCollection \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\Resource\Url $catalogUrl, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Stdlib\DateTime $dateTime, \Magento\Registry $coreRegistry, @@ -114,7 +114,7 @@ class AssociatedProductsCollection $coreStoreConfig, $productOptionFactory, $catalogUrl, - $locale, + $localeDate, $customerSession, $dateTime, $connection diff --git a/app/code/Magento/GroupedProduct/Model/Sales/AdminOrder/Product/Quote/Plugin/Initializer.php b/app/code/Magento/GroupedProduct/Model/Sales/AdminOrder/Product/Quote/Plugin/Initializer.php index 1b1138dc502..34a9b834327 100644 --- a/app/code/Magento/GroupedProduct/Model/Sales/AdminOrder/Product/Quote/Plugin/Initializer.php +++ b/app/code/Magento/GroupedProduct/Model/Sales/AdminOrder/Product/Quote/Plugin/Initializer.php @@ -36,20 +36,23 @@ use Magento\GroupedProduct\Model\Product\Type\Grouped; class Initializer { /** - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param \Magento\Sales\Model\AdminOrder\Product\Quote\Initializer $subject + * @param callable $proceed + * @param \Magento\Sales\Model\Quote $quote + * @param \Magento\Catalog\Model\Product $product + * @param \Magento\Object $config + * * @return \Magento\Sales\Model\Quote\Item|string + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundInit(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - /** @var \Magento\Sales\Model\Quote $quote */ - $quote = $arguments[0]; - /** @var \Magento\Catalog\Model\Product $product */ - $product = $arguments[1]; - /** @var \Magento\Object $config */ - $config = $arguments[2]; - - $item = $invocationChain->proceed($arguments); + public function aroundInit( + \Magento\Sales\Model\AdminOrder\Product\Quote\Initializer $subject, + \Closure $proceed, + \Magento\Sales\Model\Quote $quote, + \Magento\Catalog\Model\Product $product, + \Magento\Object $config + ) { + $item = $proceed($quote, $product, $config); if (is_string($item) && $product->getTypeId() != Grouped::TYPE_CODE) { $item = $quote->addProductAdvanced( diff --git a/app/code/Magento/GroupedProduct/etc/di.xml b/app/code/Magento/GroupedProduct/etc/di.xml index 98d6c5a6f1c..e626c8ac6b7 100644 --- a/app/code/Magento/GroupedProduct/etc/di.xml +++ b/app/code/Magento/GroupedProduct/etc/di.xml @@ -65,4 +65,7 @@ <type name="Magento\Catalog\Model\Product\CartConfiguration"> <plugin name="isProductConfigured" type="Magento\GroupedProduct\Model\Product\Cart\Configuration\Plugin\Grouped" /> </type> + <type name="Magento\Catalog\Helper\Product\Configuration"> + <plugin name="grouped_options" type="Magento\GroupedProduct\Helper\Product\Configuration\Plugin\Grouped"/> + </type> </config> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_item_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_item_renderers.xml index f65500e2488..edeb53ba3a7 100644 --- a/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_item_renderers.xml +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_item_renderers.xml @@ -25,6 +25,6 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceBlock name="checkout.cart.item.renderers"> - <block class="Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped" as="grouped" template="Magento_Checkout::cart/item/default.phtml" cacheable="false"/> + <block class="Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped" as="grouped" template="Magento_Checkout::cart/item/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml index db5296ad4db..78e8298c208 100644 --- a/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml @@ -25,6 +25,6 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceBlock name="checkout.cart.sidebar.item.renderers"> - <block class="Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped" as="grouped" template="Magento_Checkout::cart/sidebar/default.phtml" cacheable="false"/> + <block class="Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped" as="grouped" template="Magento_Checkout::cart/sidebar/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_onepage_review_item_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_onepage_review_item_renderers.xml index 9a0eac833d5..f31ab1236fd 100644 --- a/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_onepage_review_item_renderers.xml +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_onepage_review_item_renderers.xml @@ -25,6 +25,6 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceBlock name="checkout.onepage.review.item.renderers"> - <block class="Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped" as="grouped" template="Magento_Checkout::onepage/review/item.phtml" cacheable="false"/> + <block class="Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped" as="grouped" template="Magento_Checkout::onepage/review/item.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php b/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php index 54d5044f8e8..f2c141d3976 100644 --- a/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php +++ b/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php @@ -99,7 +99,7 @@ class Filter extends \Magento\Backend\Block\Widget\Grid\Extended 'name' => $this->getFilterElementName($attribute->getAttributeCode()) . '[]', 'id' => $this->getFilterElementId($attribute->getAttributeCode()), 'class' => 'input-text input-text-range-date', - 'date_format' => $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT), + 'date_format' => $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT), 'image' => $this->getViewFileUrl('images/grid-cal.gif') ); /** @var $selectBlock \Magento\View\Element\Html\Date */ diff --git a/app/code/Magento/ImportExport/Helper/Data.php b/app/code/Magento/ImportExport/Helper/Data.php index a428ae7fb4c..455659a121a 100644 --- a/app/code/Magento/ImportExport/Helper/Data.php +++ b/app/code/Magento/ImportExport/Helper/Data.php @@ -50,7 +50,6 @@ class Data extends \Magento\Core\Helper\Data * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Locale $locale * @param \Magento\App\State $appState * @param \Magento\File\Size $fileSize * @param bool $dbCompatibleMode @@ -59,7 +58,6 @@ class Data extends \Magento\Core\Helper\Data \Magento\App\Helper\Context $context, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Locale $locale, \Magento\App\State $appState, \Magento\File\Size $fileSize, $dbCompatibleMode = true @@ -69,7 +67,6 @@ class Data extends \Magento\Core\Helper\Data $context, $coreStoreConfig, $storeManager, - $locale, $appState, $dbCompatibleMode ); diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php index e1f89b4160b..e256f25da20 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php @@ -71,16 +71,16 @@ abstract class AbstractEav protected $_permanentAttributes = array(); /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Eav\Model\Config $eavConfig * @param array $data */ @@ -89,11 +89,11 @@ abstract class AbstractEav \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Eav\Model\Config $eavConfig, array $data = array() ) { - $this->_locale = $locale; + $this->_localeDate = $localeDate; parent::__construct($coreStoreConfig, $storeManager, $collectionFactory, $resourceColFactory, $data); if (isset($data['entity_type_id'])) { @@ -199,11 +199,11 @@ abstract class AbstractEav $to = array_shift($exportFilter[$attributeCode]); if (is_scalar($from) && !empty($from)) { - $date = $this->_locale->date($from, null, null, false)->toString('MM/dd/YYYY'); + $date = $this->_localeDate->date($from, null, null, false)->toString('MM/dd/YYYY'); $collection->addAttributeToFilter($attributeCode, array('from' => $date, 'date' => true)); } if (is_scalar($to) && !empty($to)) { - $date = $this->_locale->date($to, null, null, false)->toString('MM/dd/YYYY'); + $date = $this->_localeDate->date($to, null, null, false)->toString('MM/dd/YYYY'); $collection->addAttributeToFilter($attributeCode, array('to' => $date, 'date' => true)); } } diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php index 9c0a0c0e7f5..f8be44a0cff 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php @@ -157,9 +157,9 @@ abstract class AbstractEntity protected $_writer; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @var \Magento\Core\Model\StoreManagerInterface @@ -167,18 +167,18 @@ abstract class AbstractEntity protected $_storeManager; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Eav\Model\Config $config * @param \Magento\App\Resource $resource * @param \Magento\Core\Model\StoreManagerInterface $storeManager */ public function __construct( - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Eav\Model\Config $config, \Magento\App\Resource $resource, \Magento\Core\Model\StoreManagerInterface $storeManager ) { - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_storeManager = $storeManager; $entityCode = $this->getEntityTypeCode(); $this->_entityTypeId = $config->getEntityType($entityCode)->getEntityTypeId(); @@ -291,11 +291,11 @@ abstract class AbstractEntity $to = array_shift($exportFilter[$attrCode]); if (is_scalar($from) && !empty($from)) { - $date = $this->_locale->date($from, null, null, false)->toString('MM/dd/YYYY'); + $date = $this->_localeDate->date($from, null, null, false)->toString('MM/dd/YYYY'); $collection->addAttributeToFilter($attrCode, array('from' => $date, 'date' => true)); } if (is_scalar($to) && !empty($to)) { - $date = $this->_locale->date($to, null, null, false)->toString('MM/dd/YYYY'); + $date = $this->_localeDate->date($to, null, null, false)->toString('MM/dd/YYYY'); $collection->addAttributeToFilter($attrCode, array('to' => $date, 'date' => true)); } } diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer.php b/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer.php index 6a5c0fe1349..42fc4f6130d 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer.php @@ -104,7 +104,7 @@ class Customer * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Customer\Model\Resource\Customer\CollectionFactory $customerColFactory * @param array $data @@ -114,13 +114,13 @@ class Customer \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Eav\Model\Config $eavConfig, \Magento\Customer\Model\Resource\Customer\CollectionFactory $customerColFactory, array $data = array() ) { parent::__construct( - $coreStoreConfig, $storeManager, $collectionFactory, $resourceColFactory, $locale, $eavConfig, $data + $coreStoreConfig, $storeManager, $collectionFactory, $resourceColFactory, $localeDate, $eavConfig, $data ); $this->_customerCollection = isset($data['customer_collection']) ? $data['customer_collection'] diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer/Address.php b/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer/Address.php index 5af383d2744..0fae19ff6ec 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer/Address.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer/Address.php @@ -127,7 +127,7 @@ class Address * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Customer\Model\Resource\Customer\CollectionFactory $customerColFactory * @param \Magento\ImportExport\Model\Export\Entity\Eav\CustomerFactory $eavCustomerFactory @@ -139,7 +139,7 @@ class Address \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Eav\Model\Config $eavConfig, \Magento\Customer\Model\Resource\Customer\CollectionFactory $customerColFactory, \Magento\ImportExport\Model\Export\Entity\Eav\CustomerFactory $eavCustomerFactory, @@ -151,7 +151,7 @@ class Address $storeManager, $collectionFactory, $resourceColFactory, - $locale, + $localeDate, $eavConfig, $data ); diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/Product.php b/app/code/Magento/ImportExport/Model/Export/Entity/Product.php index 1475244aa55..6d44a9820e8 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/Product.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/Product.php @@ -210,7 +210,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity protected $rowCustomizer; /** - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Eav\Model\Config $config * @param \Magento\App\Resource $resource * @param \Magento\Core\Model\StoreManagerInterface $storeManager @@ -228,7 +228,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity * @param \Magento\ImportExport\Model\Export\RowCustomizerInterface $rowCustomizer */ public function __construct( - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Eav\Model\Config $config, \Magento\App\Resource $resource, \Magento\Core\Model\StoreManagerInterface $storeManager, @@ -259,7 +259,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity $this->_linkTypeProvider = $linkTypeProvider; $this->rowCustomizer = $rowCustomizer; - parent::__construct($locale, $config, $resource, $storeManager); + parent::__construct($localeDate, $config, $resource, $storeManager); $this->_initTypeModels() ->_initAttributes() diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/Product.php b/app/code/Magento/ImportExport/Model/Import/Entity/Product.php index da14db92302..4273c936c15 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/Product.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/Product.php @@ -388,9 +388,9 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity protected $_stockItemFactory; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @var \Magento\Stdlib\DateTime @@ -428,7 +428,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity * @param \Magento\App\Filesystem $filesystem * @param \Magento\CatalogInventory\Model\Resource\Stock\ItemFactory $stockResItemFac * @param \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Logger $logger * @param array $data @@ -459,7 +459,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity \Magento\App\Filesystem $filesystem, \Magento\CatalogInventory\Model\Resource\Stock\ItemFactory $stockResItemFac, \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Logger $logger, array $data = array() @@ -481,7 +481,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity $this->_mediaDirectory = $filesystem->getDirectoryWrite(\Magento\App\Filesystem::MEDIA_DIR); $this->_stockResItemFac = $stockResItemFac; $this->_stockItemFactory = $stockItemFactory; - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->dateTime = $dateTime; $this->_logger = $logger; parent::__construct( @@ -1652,7 +1652,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity if ($this->_catalogInventoryData->isQty($this->_newSku[$rowData[self::COL_SKU]]['type_id'])) { if ($stockItem->verifyNotification()) { - $stockItem->setLowStockDate($this->_locale + $stockItem->setLowStockDate($this->_localeDate ->date(null, null, null, false) ->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT) ); diff --git a/app/code/Magento/Indexer/Model/Indexer.php b/app/code/Magento/Indexer/Model/Indexer.php index 1e55c57d28b..f0bf79839be 100644 --- a/app/code/Magento/Indexer/Model/Indexer.php +++ b/app/code/Magento/Indexer/Model/Indexer.php @@ -270,8 +270,8 @@ class Indexer extends \Magento\Object implements IndexerInterface if (!$this->getState()->getUpdated()) { return $this->getView()->getUpdated(); } - $indexerUpdatedDate = new \Zend_Date($this->getState()->getUpdated()); - $viewUpdatedDate = new \Zend_Date($this->getView()->getUpdated()); + $indexerUpdatedDate = new \Magento\Stdlib\DateTime\Date($this->getState()->getUpdated()); + $viewUpdatedDate = new \Magento\Stdlib\DateTime\Date($this->getView()->getUpdated()); if ($viewUpdatedDate->compare($indexerUpdatedDate) == 1) { return $this->getView()->getUpdated(); } diff --git a/app/code/Magento/Install/App/Action/Plugin/Design.php b/app/code/Magento/Install/App/Action/Plugin/Design.php index aa032b9d0d3..70c2de620d5 100644 --- a/app/code/Magento/Install/App/Action/Plugin/Design.php +++ b/app/code/Magento/Install/App/Action/Plugin/Design.php @@ -23,6 +23,7 @@ */ namespace Magento\Install\App\Action\Plugin; +use Magento\App\RequestInterface; class Design { @@ -75,10 +76,13 @@ class Design /** * Initialize design * - * @param array $arguments - * @return array + * @param \Magento\Install\Controller\Action $subject + * @param RequestInterface $request + * + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeDispatch(array $arguments = array()) + public function beforeDispatch(\Magento\Install\Controller\Action $subject, RequestInterface $request) { $areaCode = $this->_layout->getArea(); $area = $this->_app->getArea($areaCode); @@ -91,6 +95,5 @@ class Design $area->detectDesign($this->_request); $area->load(\Magento\Core\Model\App\Area::PART_TRANSLATE); - return $arguments; } } diff --git a/app/code/Magento/Install/App/Action/Plugin/Dir.php b/app/code/Magento/Install/App/Action/Plugin/Dir.php index 1551dc5e0bc..eac3e28407d 100644 --- a/app/code/Magento/Install/App/Action/Plugin/Dir.php +++ b/app/code/Magento/Install/App/Action/Plugin/Dir.php @@ -69,10 +69,13 @@ class Dir /** * Clear temporary directories * - * @param array $arguments - * @return array + * @param \Magento\Install\Controller\Index $subject + * @param \Magento\App\RequestInterface $request + * + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeDispatch($arguments) + public function beforeDispatch(\Magento\Install\Controller\Index $subject, \Magento\App\RequestInterface $request) { if (!$this->appState->isInstalled()) { foreach ($this->varDirectory->read() as $dir) { @@ -85,6 +88,5 @@ class Dir } } } - return $arguments; } -} \ No newline at end of file +} diff --git a/app/code/Magento/Install/App/Console.php b/app/code/Magento/Install/App/Console.php index 3d53c3a0a93..8bad7c7c952 100644 --- a/app/code/Magento/Install/App/Console.php +++ b/app/code/Magento/Install/App/Console.php @@ -164,13 +164,18 @@ class Console implements \Magento\LauncherInterface $installer = $this->_installerFactory->create(array('installArgs' => $this->_arguments)); if (isset($this->_arguments['show_locales'])) { - $this->_output->export($installer->getAvailableLocales()); + $this->_output->readableOutput($this->_output->prepareArray($installer->getAvailableLocales())); } elseif (isset($this->_arguments['show_currencies'])) { - $this->_output->export($installer->getAvailableCurrencies()); + $this->_output->readableOutput($this->_output->prepareArray($installer->getAvailableCurrencies())); } elseif (isset($this->_arguments['show_timezones'])) { - $this->_output->export($installer->getAvailableTimezones()); + $this->_output->readableOutput($this->_output->prepareArray($installer->getAvailableTimezones())); } elseif (isset($this->_arguments['show_install_options'])) { - $this->_output->export($installer->getAvailableInstallOptions()); + $this->_output->readableOutput(PHP_EOL . 'Required parameters:'); + $this->_output->readableOutput($this->_output->alignArrayKeys($installer->getRequiredParams())); + $this->_output->readableOutput(PHP_EOL . 'Optional parameters:'); + $this->_output->readableOutput($this->_output->alignArrayKeys($installer->getOptionalParams())); + $this->_output->readableOutput(PHP_EOL . 'Flag values are considered positive if set to 1, y, true or yes.' + . 'Any other value is considered as negative.' . PHP_EOL); } else { $this->_handleInstall($installer); } diff --git a/app/code/Magento/Install/App/Output.php b/app/code/Magento/Install/App/Output.php index 83533db9873..991bb714bb7 100644 --- a/app/code/Magento/Install/App/Output.php +++ b/app/code/Magento/Install/App/Output.php @@ -26,14 +26,67 @@ namespace Magento\Install\App; class Output { /** - * Export variable + * Make array keys aligned to the longest * - * @param mixed $var - * @return void + * @param array $data + * @return array + */ + public function alignArrayKeys(array $data) + { + $formattedData = array(); + $length = max(array_map('strlen', array_keys($data))); + foreach($data as $key => $value) { + $formattedData[str_pad($key, $length, ' ', STR_PAD_RIGHT)] = $value; + } + return $formattedData; + + } + + /** + * Process an array to $key => $value format + * and adapt keys to pretty output + * + * @param array $rawData + * @return array + */ + public function prepareArray(array $rawData) + { + $keyValData = array(); + + // transform data to key => value format + foreach ($rawData as $item) { + $keyValData[$item['value']] = $item['label']; + } + + return $this->alignArrayKeys($keyValData); + } + + /** + * Make output human readable + * + * @param $var */ - public function export($var) + public function readableOutput($var) { - var_export($var); + switch(true) { + case is_array($var): + $eol = ''; + foreach($var as $key => $value) { + if (is_array($value) || !is_scalar($value)) { + echo $eol . $key . ' => ' . var_export($value, true); + } else { + echo $eol . $key . ' -- ' . $value; + } + $eol = PHP_EOL; + } + echo PHP_EOL; + break; + case is_scalar($var): + echo $var . PHP_EOL; + break; + default: + var_export($var); + } } /** diff --git a/app/code/Magento/Install/Block/Locale.php b/app/code/Magento/Install/Block/Locale.php index 54e9cd9f0d6..5703289d9c6 100644 --- a/app/code/Magento/Install/Block/Locale.php +++ b/app/code/Magento/Install/Block/Locale.php @@ -49,6 +49,47 @@ class Locale extends \Magento\Install\Block\AbstractBlock */ protected $_localeCode; + /** + * @var \Magento\Locale\CurrencyInterface + */ + protected $_localeCurrency; + + /** + * @var \Magento\Locale\ListsInterface + */ + protected $_localeLists; + + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + + /** + * @param \Magento\View\Element\Template\Context $context + * @param \Magento\Install\Model\Installer $installer + * @param \Magento\Install\Model\Wizard $installWizard + * @param \Magento\Session\Generic $session + * @param \Magento\Locale\CurrencyInterface $localeCurrency + * @param \Magento\Locale\ListsInterface $localeLists + * @param \Magento\Locale\ResolverInterface $localeResolver + * @param array $data + */ + public function __construct( + \Magento\View\Element\Template\Context $context, + \Magento\Install\Model\Installer $installer, + \Magento\Install\Model\Wizard $installWizard, + \Magento\Session\Generic $session, + \Magento\Locale\CurrencyInterface $localeCurrency, + \Magento\Locale\ListsInterface $localeLists, + \Magento\Locale\ResolverInterface $localeResolver, + array $data = array() + ) { + $this->_localeLists = $localeLists; + parent::__construct($context, $installer, $installWizard, $session, $data); + $this->_localeCurrency = $localeCurrency; + $this->_localeResolver = $localeResolver; + } + /** * Set locale code * @@ -74,13 +115,13 @@ class Locale extends \Magento\Install\Block\AbstractBlock /** * Retrieve locale object * - * @return \Zend_Locale + * @return \Magento\LocaleInterface */ public function getLocale() { $locale = $this->getData('locale'); if (null === $locale) { - $locale = $this->_locale->setLocaleCode( + $locale = $this->_localeResolver->setLocaleCode( $this->getLocaleCode() )->getLocale(); $this->setData('locale', $locale); @@ -121,7 +162,7 @@ class Locale extends \Magento\Install\Block\AbstractBlock ->setTitle(__('Locale')) ->setClass('required-entry') ->setValue($this->getLocale()->__toString()) - ->setOptions($this->_locale->getTranslatedOptionLocales()) + ->setOptions($this->_localeLists->getTranslatedOptionLocales()) ->getHtml(); return $html; } @@ -139,7 +180,7 @@ class Locale extends \Magento\Install\Block\AbstractBlock ->setTitle(__('Time Zone')) ->setClass('required-entry') ->setValue($this->getTimezone()) - ->setOptions($this->_locale->getOptionTimezones()) + ->setOptions($this->_localeLists->getOptionTimezones()) ->getHtml(); return $html; } @@ -153,8 +194,8 @@ class Locale extends \Magento\Install\Block\AbstractBlock { $timezone = $this->_session->getTimezone() ? $this->_session->getTimezone() - : $this->_locale->getTimezone(); - if ($timezone == \Magento\Core\Model\LocaleInterface::DEFAULT_TIMEZONE) { + : $this->_localeDate->getDefaultTimezone(); + if ($timezone == \Magento\Stdlib\DateTime\TimezoneInterface::DEFAULT_TIMEZONE) { $timezone = 'America/Los_Angeles'; } return $timezone; @@ -173,7 +214,7 @@ class Locale extends \Magento\Install\Block\AbstractBlock ->setTitle(__('Default Currency')) ->setClass('required-entry') ->setValue($this->getCurrency()) - ->setOptions($this->_locale->getOptionCurrencies()) + ->setOptions($this->_localeLists->getOptionCurrencies()) ->getHtml(); return $html; } @@ -187,7 +228,7 @@ class Locale extends \Magento\Install\Block\AbstractBlock { return $this->_session->getCurrency() ? $this->_session->getCurrency() - : $this->_locale->getCurrency(); + : $this->_localeCurrency->getDefaultCurrency(); } /** diff --git a/app/code/Magento/Install/Model/Installer.php b/app/code/Magento/Install/Model/Installer.php index efdf1abdf6d..a6d067a8316 100644 --- a/app/code/Magento/Install/Model/Installer.php +++ b/app/code/Magento/Install/Model/Installer.php @@ -145,7 +145,9 @@ class Installer extends \Magento\Object */ protected $_session; - /** @var \Magento\App\Resource */ + /** + * @var \Magento\App\Resource + */ protected $_resource; /** @@ -165,6 +167,31 @@ class Installer extends \Magento\Object */ protected $_arguments; + /** + * @var \Magento\Module\ModuleListInterface + */ + protected $moduleList; + + /** + * @var \Magento\Module\DependencyManagerInterface + */ + protected $dependencyManager; + + /** + * @var \Magento\Message\ManagerInterface + */ + protected $messageManager; + + /** + * @var \Magento\Stdlib\DateTime\TimezoneInterface + */ + protected $_localeDate; + + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\App\ReinitableConfigInterface $config * @param \Magento\Module\UpdaterInterface $dbUpdater @@ -185,6 +212,11 @@ class Installer extends \Magento\Object * @param \Magento\Encryption\EncryptorInterface $encryptor * @param \Magento\Math\Random $mathRandom * @param \Magento\App\Resource $resource + * @param \Magento\Module\ModuleListInterface $moduleList + * @param \Magento\Module\DependencyManagerInterface $dependencyManager + * @param \Magento\Message\ManagerInterface $messageManager + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate + * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data */ public function __construct( @@ -207,6 +239,11 @@ class Installer extends \Magento\Object \Magento\Encryption\EncryptorInterface $encryptor, \Magento\Math\Random $mathRandom, \Magento\App\Resource $resource, + \Magento\Module\ModuleListInterface $moduleList, + \Magento\Module\DependencyManagerInterface $dependencyManager, + \Magento\Message\ManagerInterface $messageManager, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Locale\ResolverInterface $localeResolver, array $data = array() ) { $this->_dbUpdater = $dbUpdater; @@ -217,7 +254,6 @@ class Installer extends \Magento\Object $this->_setupFactory = $setupFactory; $this->_encryptor = $encryptor; $this->mathRandom = $mathRandom; - parent::__construct($data); $this->_arguments = $arguments; $this->_app = $app; $this->_appState = $appState; @@ -229,6 +265,12 @@ class Installer extends \Magento\Object $this->_installerConfig = $installerConfig; $this->_session = $session; $this->_resource = $resource; + $this->moduleList = $moduleList; + $this->dependencyManager = $dependencyManager; + $this->messageManager = $messageManager; + $this->_localeDate = $localeDate; + $this->_localeResolver = $localeResolver; + parent::__construct($data); } /** @@ -291,6 +333,7 @@ class Installer extends \Magento\Object public function checkServer() { try { + $this->checkExtensionsLoaded(); $this->_filesystem->install(); $result = true; } catch (\Exception $e) { @@ -314,6 +357,23 @@ class Installer extends \Magento\Object return $status; } + /** + * Check all necessary extensions are loaded and available + * + * @throws \Exception + */ + protected function checkExtensionsLoaded() + { + try { + foreach ($this->moduleList->getModules() as $moduleData) { + $this->dependencyManager->checkModuleDependencies($moduleData); + } + } catch (\Exception $exception) { + $this->messageManager->addError($exception->getMessage()); + throw new \Exception($exception->getMessage()); + } + } + /** * Installation config data * @@ -389,11 +449,12 @@ class Installer extends \Magento\Object */ $locale = $this->getDataModel()->getLocaleData(); if (!empty($locale['locale'])) { - $setupModel->setConfigData(\Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_LOCALE, + $setupModel->setConfigData($this->_localeResolver->getDefaultLocalePath(), $locale['locale']); } if (!empty($locale['timezone'])) { - $setupModel->setConfigData(\Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_TIMEZONE, + $setupModel->setConfigData( + $this->_localeDate->getDefaultTimezonePath(), $locale['timezone']); } if (!empty($locale['currency'])) { diff --git a/app/code/Magento/Install/Model/Installer/Console.php b/app/code/Magento/Install/Model/Installer/Console.php index 1bdcbb71ef5..f3dc3529544 100644 --- a/app/code/Magento/Install/Model/Installer/Console.php +++ b/app/code/Magento/Install/Model/Installer/Console.php @@ -43,35 +43,51 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller * * @var array */ - protected $_installOptions = array( - 'license_agreement_accepted' => array('required' => 1), - 'locale' => array('required' => 1), - 'timezone' => array('required' => 1), - 'default_currency' => array('required' => 1), - 'db_model' => array('required' => 0), - 'db_host' => array('required' => 1), - 'db_name' => array('required' => 1), - 'db_user' => array('required' => 1), - 'db_pass' => array('required' => 0), - 'db_prefix' => array('required' => 0), - 'url' => array('required' => 1), - 'skip_url_validation' => array('required' => 0), - 'use_rewrites' => array('required' => 1), - 'use_secure' => array('required' => 1), - 'secure_base_url' => array('required' => 1), - 'use_secure_admin' => array('required' => 1), - 'admin_lastname' => array('required' => 1), - 'admin_firstname' => array('required' => 1), - 'admin_email' => array('required' => 1), - 'admin_username' => array('required' => 1), - 'admin_password' => array('required' => 1), - 'admin_no_form_key' => array('required' => 0), - 'encryption_key' => array('required' => 0), - 'session_save' => array('required' => 0), - 'backend_frontname' => array('required' => 0), - 'enable_charts' => array('required' => 0), - 'order_increment_prefix' => array('required' => 0), - 'cleanup_database' => array('required' => 0), + protected $installParameters = array(); + + /** + * Required parameters with descriptions + * + * @var array + */ + protected $requiredParameters = array( + 'license_agreement_accepted' => 'Accept licence. See LICENSE*.txt. Flag value.', + 'locale' => 'Locale to use. Run with --show_locales for full list', + 'timezone' => 'Time zone to use. Run with --show_timezones for full list', + 'default_currency' => 'Default currency. Run with --show_currencies for full list', + 'db_host' => 'IP or name of your DB host', + 'db_name' => 'Database name', + 'db_user' => 'Database user name', + 'url' => 'Instance URL. For example, "http://myinstance.com"', + 'use_rewrites' => 'Use web server rewrites. Flag value', + 'use_secure' => 'Use https(ssl) protocol. Flag value', + 'secure_base_url' => 'Full secure URL if use_secure enabled. For example "https://myinstance.com"', + 'use_secure_admin' => 'Use secure protocol for backend. Flag value', + 'admin_lastname' => 'Admin user last name', + 'admin_firstname' => 'Admin user first name', + 'admin_email' => 'Admin email', + 'admin_username' => 'Admin login', + 'admin_password' => 'Admin password', + ); + + /** + * Optional parameters with descriptions + * + * @var array + */ + protected $optionalParameters = array( + 'db_model' => 'DB driver. "mysql4" is default and the only supported now', + 'db_pass' => 'DB password. Empty by default', + 'db_prefix' => 'Use prefix for tables of this installation. Empty by default', + 'skip_url_validation' => 'Skip URL validation on installation. Flag value. Validate by default', + 'admin_no_form_key' => + 'Disable the form key protection on the back-end. Flag value. Enabled by default', + 'encryption_key' => 'Key to encrypt sensitive data. Auto-generated if empty', + 'session_save' => 'Where session data will be stored. "files"(default) or "db"', + 'backend_frontname' => 'Backend URL path. "backend" by default', + 'enable_charts' => 'Enable charts on backend dashboard. Flag value. Enabled by default', + 'order_increment_prefix' => 'Order number prefix. Empty by default.', + 'cleanup_database' => 'Clean up database before installation. Flag value. Disabled by default', ); /** @@ -115,11 +131,11 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller protected $_appState; /** - * Locale model + * Locale Lists * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ListsInterface */ - protected $_locale; + protected $_localeLists; /** * Magento Object Manager @@ -135,7 +151,7 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller * @param \Magento\App\Filesystem $filesystem * @param \Magento\Install\Model\Installer\Data $installerData * @param \Magento\App\State $appState - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ListsInterface $localeLists * @param \Magento\ObjectManager $objectManager */ public function __construct( @@ -145,7 +161,7 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller \Magento\App\Filesystem $filesystem, \Magento\Install\Model\Installer\Data $installerData, \Magento\App\State $appState, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ListsInterface $localeLists, \Magento\ObjectManager $objectManager ) { parent::__construct($installer); @@ -155,8 +171,9 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller $this->_installerData = $installerData; $this->_installer->setDataModel($this->_installerData); $this->_appState = $appState; - $this->_locale = $locale; + $this->_localeLists = $localeLists; $this->_objectManager = $objectManager; + $this->installParameters = array_keys($this->requiredParameters + $this->optionalParameters); } /** @@ -170,9 +187,9 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller /** * Check required options */ - foreach ($this->_installOptions as $optionName => $optionInfo) { - if (isset($optionInfo['required']) && $optionInfo['required'] && !isset($options[$optionName])) { - $this->addError("ERROR: installation option '$optionName' is required."); + foreach (array_keys($this->requiredParameters) as $optionName) { + if (!isset($options[$optionName])) { + $this->addError("ERROR: installation parameter '$optionName' is required."); } } @@ -191,7 +208,7 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller } $result = array(); - foreach ($this->_installOptions as $optionName => $optionInfo) { + foreach ($this->installParameters as $optionName) { $result[$optionName] = isset($options[$optionName]) ? $options[$optionName] : ''; } @@ -421,7 +438,7 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller */ public function getAvailableLocales() { - return $this->_locale->getOptionLocales(); + return $this->_localeLists->getOptionLocales(); } /** @@ -431,7 +448,7 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller */ public function getAvailableCurrencies() { - return $this->_locale->getOptionCurrencies(); + return $this->_localeLists->getOptionCurrencies(); } /** @@ -441,20 +458,26 @@ class Console extends \Magento\Install\Model\Installer\AbstractInstaller */ public function getAvailableTimezones() { - return $this->_locale->getOptionTimezones(); + return $this->_localeLists->getOptionTimezones(); } /** - * Retrieve available installation options + * Retrieve required installation params * * @return array */ - public function getAvailableInstallOptions() + public function getRequiredParams() { - $result = array(); - foreach ($this->_installOptions as $optionName => $optionInfo) { - $result[$optionName] = ($optionInfo['required'] ? 'required' : 'optional'); - } - return $result; + + return $this->requiredParameters; + } + + /** + * Get optional installation parameters + * @return array + */ + public function getOptionalParams() + { + return $this->optionalParameters; } } diff --git a/app/code/Magento/Integration/Model/Oauth/Nonce/Generator.php b/app/code/Magento/Integration/Model/Oauth/Nonce/Generator.php index fd2e8d823e8..ae65aa33f6a 100644 --- a/app/code/Magento/Integration/Model/Oauth/Nonce/Generator.php +++ b/app/code/Magento/Integration/Model/Oauth/Nonce/Generator.php @@ -45,7 +45,7 @@ class Generator implements NonceGeneratorInterface protected $_nonceLength; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -57,13 +57,13 @@ class Generator implements NonceGeneratorInterface /** * @param \Magento\Oauth\Helper\Oauth $oauthHelper * @param \Magento\Integration\Model\Oauth\Nonce\Factory $nonceFactory - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param int $nonceLength - Length of the generated nonce */ public function __construct( \Magento\Oauth\Helper\Oauth $oauthHelper, \Magento\Integration\Model\Oauth\Nonce\Factory $nonceFactory, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, $nonceLength = \Magento\Oauth\Helper\Oauth::LENGTH_NONCE ) { $this->_oauthHelper = $oauthHelper; diff --git a/app/code/Magento/Integration/Model/Oauth/Token/Provider.php b/app/code/Magento/Integration/Model/Oauth/Token/Provider.php index 0fea2d6c0f0..ffff18b9b4a 100644 --- a/app/code/Magento/Integration/Model/Oauth/Token/Provider.php +++ b/app/code/Magento/Integration/Model/Oauth/Token/Provider.php @@ -45,7 +45,7 @@ class Provider implements TokenProviderInterface protected $_dataHelper; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -53,13 +53,13 @@ class Provider implements TokenProviderInterface * @param \Magento\Integration\Model\Oauth\Consumer\Factory $consumerFactory * @param \Magento\Integration\Model\Oauth\Token\Factory $tokenFactory * @param \Magento\Integration\Helper\Oauth\Data $dataHelper - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date */ public function __construct( \Magento\Integration\Model\Oauth\Consumer\Factory $consumerFactory, \Magento\Integration\Model\Oauth\Token\Factory $tokenFactory, \Magento\Integration\Helper\Oauth\Data $dataHelper, - \Magento\Core\Model\Date $date + \Magento\Stdlib\DateTime\DateTime $date ) { $this->_consumerFactory = $consumerFactory; $this->_tokenFactory = $tokenFactory; diff --git a/app/code/Magento/Integration/etc/di.xml b/app/code/Magento/Integration/etc/di.xml index 5b2d1459a48..bccd1f118ad 100644 --- a/app/code/Magento/Integration/etc/di.xml +++ b/app/code/Magento/Integration/etc/di.xml @@ -31,12 +31,12 @@ <preference for="Magento\Oauth\TokenProviderInterface" type="Magento\Integration\Model\Oauth\Token\Provider"/> <type name="Magento\Integration\Model\Oauth\Nonce\Generator"> <arguments> - <argument name="date" xsi:type="object">Magento\Core\Model\Date\Proxy</argument> + <argument name="date" xsi:type="object">Magento\Stdlib\DateTime\DateTime\Proxy</argument> </arguments> </type> <type name="Magento\Integration\Model\Oauth\Token\Provider"> <arguments> - <argument name="date" xsi:type="object">Magento\Core\Model\Date\Proxy</argument> + <argument name="date" xsi:type="object">Magento\Stdlib\DateTime\DateTime\Proxy</argument> </arguments> </type> </config> diff --git a/app/code/Magento/Log/Model/Resource/Log.php b/app/code/Magento/Log/Model/Resource/Log.php index b6fd9c6a8cf..f8852fa332e 100644 --- a/app/code/Magento/Log/Model/Resource/Log.php +++ b/app/code/Magento/Log/Model/Resource/Log.php @@ -42,7 +42,7 @@ class Log extends \Magento\Core\Model\Resource\Db\AbstractDb protected $_eventManager = null; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -53,13 +53,13 @@ class Log extends \Magento\Core\Model\Resource\Db\AbstractDb /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Stdlib\DateTime $dateTime */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\Event\ManagerInterface $eventManager, \Magento\Stdlib\DateTime $dateTime ) { diff --git a/app/code/Magento/Log/Model/Resource/Visitor.php b/app/code/Magento/Log/Model/Resource/Visitor.php index 0a3a6b27ed2..9a4387b330d 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor.php +++ b/app/code/Magento/Log/Model/Resource/Visitor.php @@ -39,7 +39,7 @@ class Visitor extends \Magento\Core\Model\Resource\Db\AbstractDb protected $string; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -50,13 +50,13 @@ class Visitor extends \Magento\Core\Model\Resource\Db\AbstractDb /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Stdlib\String $string */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Stdlib\String $string ) { diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Online.php b/app/code/Magento/Log/Model/Resource/Visitor/Online.php index 66c836c0ee9..8f05807beef 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor/Online.php +++ b/app/code/Magento/Log/Model/Resource/Visitor/Online.php @@ -35,15 +35,15 @@ namespace Magento\Log\Model\Resource\Visitor; class Online extends \Magento\Core\Model\Resource\Db\AbstractDb { /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date */ - public function __construct(\Magento\App\Resource $resource, \Magento\Core\Model\Date $date) + public function __construct(\Magento\App\Resource $resource, \Magento\Stdlib\DateTime\DateTime $date) { $this->_date = $date; parent::__construct($resource); diff --git a/app/code/Magento/Log/Model/Visitor.php b/app/code/Magento/Log/Model/Visitor.php index 86c56dc64c0..61c06acafa1 100644 --- a/app/code/Magento/Log/Model/Visitor.php +++ b/app/code/Magento/Log/Model/Visitor.php @@ -113,6 +113,11 @@ class Visitor extends \Magento\Core\Model\AbstractModel */ protected $dateTime; + /** + * @var \Magento\Module\Manager + */ + protected $moduleManager; + /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry @@ -126,9 +131,10 @@ class Visitor extends \Magento\Core\Model\AbstractModel * @param \Magento\HTTP\PhpEnvironment\RemoteAddress $remoteAddress * @param \Magento\HTTP\PhpEnvironment\ServerAddress $serverAddress * @param \Magento\Stdlib\DateTime $dateTime + * @param \Magento\Module\Manager $moduleManager * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection - * @param string[] $ignoredUserAgents + * @param array $ignoredUserAgents * @param array $ignores * @param array $data */ @@ -145,6 +151,7 @@ class Visitor extends \Magento\Core\Model\AbstractModel \Magento\HTTP\PhpEnvironment\RemoteAddress $remoteAddress, \Magento\HTTP\PhpEnvironment\ServerAddress $serverAddress, \Magento\Stdlib\DateTime $dateTime, + \Magento\Module\Manager $moduleManager, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $ignoredUserAgents = array(), @@ -162,6 +169,7 @@ class Visitor extends \Magento\Core\Model\AbstractModel $this->_remoteAddress = $remoteAddress; $this->_serverAddress = $serverAddress; $this->dateTime = $dateTime; + $this->moduleManager = $moduleManager; parent::__construct($context, $registry, $resource, $resourceCollection, $data); $this->_ignores = $ignores; @@ -181,6 +189,9 @@ class Visitor extends \Magento\Core\Model\AbstractModel $this->_skipRequestLogging = true; } } + if ($this->moduleManager->isEnabled('Magento_PageCache')) { + $this->_skipRequestLogging = true; + } } /** diff --git a/app/code/Magento/Log/etc/module.xml b/app/code/Magento/Log/etc/module.xml index 5a11ddf352b..5becf658880 100755 --- a/app/code/Magento/Log/etc/module.xml +++ b/app/code/Magento/Log/etc/module.xml @@ -32,6 +32,7 @@ <depends> <module name="Magento_Core"/> <module name="Magento_Customer"/> + <module name="Magento_PageCache"/> <module name="Magento_Sales"/> <module name="Magento_Backend"/> </depends> diff --git a/app/code/Magento/Multishipping/Controller/Checkout.php b/app/code/Magento/Multishipping/Controller/Checkout.php index a43b59692db..8ad8e793eac 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout.php +++ b/app/code/Magento/Multishipping/Controller/Checkout.php @@ -33,6 +33,7 @@ use Magento\Customer\Service\V1\CustomerMetadataServiceInterface as CustomerMeta * Multishipping checkout controller */ class Checkout extends \Magento\Checkout\Controller\Action + implements \Magento\Checkout\Controller\Express\RedirectLoginInterface { /** * @param \Magento\App\Action\Context $context @@ -380,7 +381,6 @@ class Checkout extends \Magento\Checkout\Controller\Action } $this->_getState()->setActiveStep(State::STEP_BILLING); - $this->_view->loadLayout(); $this->_view->getLayout()->initMessages(); $this->_view->renderLayout(); @@ -525,23 +525,39 @@ class Checkout extends \Magento\Checkout\Controller\Action } /** - * Redirect to login page - * + * Returns before_auth_url redirect parameter for customer session + * @return string */ - public function redirectLogin() + public function getCustomerBeforeAuthUrl() { - $this->_actionFlag->set('', 'no-dispatch', true); - $url = $this->_objectManager->create('Magento\UrlInterface') + return $this->_objectManager->create('Magento\UrlInterface') ->getUrl('*/*', array('_secure' => true)); - $this->_objectManager->get('Magento\Customer\Model\Session')->setBeforeAuthUrl($url); + } - $this->getResponse()->setRedirect( - $this->_objectManager->get('Magento\Core\Helper\Url')->addRequestParam( - $this->_getHelper()->getMSLoginUrl(), - array('context' => 'checkout') - ) - ); + /** + * Returns a list of action flags [flag_key] => boolean + * @return array + */ + public function getActionFlagList() + { + return array('redirectLogin' => true); + } - $this->_actionFlag->set('', 'redirectLogin', true); + /** + * Returns login url parameter for redirect + * @return string + */ + public function getLoginUrl() + { + return $this->_getHelper()->getMSLoginUrl(); + } + + /** + * Returns action name which requires redirect + * @return string + */ + public function getRedirectActionName() + { + return 'index'; } } diff --git a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_billing.xml b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_billing.xml index 99c75c94652..444bd6e0fdc 100644 --- a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_billing.xml +++ b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_billing.xml @@ -32,10 +32,6 @@ </referenceBlock> <referenceContainer name="content"> <block class="Magento\Multishipping\Block\Checkout\Billing" name="checkout_billing" template="checkout/billing.phtml" cacheable="false"> - <action method="setMethodFormTemplate"> - <argument name="method" xsi:type="string">purchaseorder</argument> - <argument name="template" xsi:type="string">Magento_Payment::form/purchaseorder.phtml</argument> - </action> <container name="payment_methods_before" label="Payment Methods Before"/> <container name="payment_methods_after" label="Payment Methods After"/> </block> diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit/Form.php b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit/Form.php index d214d1ba6f8..db18b71f5a0 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit/Form.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit/Form.php @@ -93,8 +93,8 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic 'class' => 'fieldset-wide' )); - $dateFormat = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM); - $timeFormat = $this->_locale->getTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM); + $dateFormat = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM); + $timeFormat = $this->_localeDate->getTimeFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM); if ($queue->getQueueStatus() == \Magento\Newsletter\Model\Queue::STATUS_NEVER) { $fieldset->addField('date', 'date', array( @@ -149,7 +149,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic if ($queue->getQueueStartAt()) { $form->getElement('date')->setValue( - $this->_locale->date($queue->getQueueStartAt(), \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT) + $this->_localeDate->date($queue->getQueueStartAt(), \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT) ); } diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue.php index fb3e2497230..3b8ee46e3c8 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue.php @@ -139,7 +139,7 @@ class Queue extends \Magento\Backend\App\Action return; } - $queue->setQueueStartAt($this->_objectManager->get('Magento\Core\Model\Date')->gmtDate()) + $queue->setQueueStartAt($this->_objectManager->get('Magento\Stdlib\DateTime\DateTime')->gmtDate()) ->setQueueStatus(\Magento\Newsletter\Model\Queue::STATUS_SENDING) ->save(); } diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Template.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Template.php index 3f8e37a187a..360e8a330e8 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Template.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Template.php @@ -199,7 +199,7 @@ class Template extends \Magento\Backend\App\Action ->setTemplateSenderName($request->getParam('sender_name')) ->setTemplateText($request->getParam('text')) ->setTemplateStyles($request->getParam('styles')) - ->setModifiedAt($this->_objectManager->get('Magento\Core\Model\Date')->gmtDate()); + ->setModifiedAt($this->_objectManager->get('Magento\Stdlib\DateTime\DateTime')->gmtDate()); if (!$template->getId()) { $template->setTemplateType(\Magento\Newsletter\Model\Template::TYPE_HTML); diff --git a/app/code/Magento/Newsletter/Model/Queue.php b/app/code/Magento/Newsletter/Model/Queue.php index 1e29e9e94cb..8b7fdc7efe0 100644 --- a/app/code/Magento/Newsletter/Model/Queue.php +++ b/app/code/Magento/Newsletter/Model/Queue.php @@ -98,16 +98,14 @@ class Queue extends \Magento\Core\Model\Template /** * Date * - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; /** - * Locale - * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * Problem factory @@ -135,8 +133,8 @@ class Queue extends \Magento\Core\Model\Template * @param \Magento\Core\Model\App\Emulation $appEmulation * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Newsletter\Model\Template\Filter $templateFilter - * @param \Magento\Core\Model\LocaleInterface $locale - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Newsletter\Model\TemplateFactory $templateFactory * @param \Magento\Newsletter\Model\ProblemFactory $problemFactory * @param \Magento\Newsletter\Model\Resource\Subscriber\CollectionFactory $subscriberCollectionFactory @@ -150,8 +148,8 @@ class Queue extends \Magento\Core\Model\Template \Magento\Core\Model\App\Emulation $appEmulation, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Newsletter\Model\Template\Filter $templateFilter, - \Magento\Core\Model\LocaleInterface $locale, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\Newsletter\Model\TemplateFactory $templateFactory, \Magento\Newsletter\Model\ProblemFactory $problemFactory, \Magento\Newsletter\Model\Resource\Subscriber\CollectionFactory $subscriberCollectionFactory, @@ -161,7 +159,7 @@ class Queue extends \Magento\Core\Model\Template parent::__construct($context, $design, $registry, $appEmulation, $storeManager, $data); $this->_templateFilter = $templateFilter; $this->_date = $date; - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_templateFactory = $templateFactory; $this->_problemFactory = $problemFactory; $this->_subscribersCollection = $subscriberCollectionFactory->create(); @@ -200,8 +198,8 @@ class Queue extends \Magento\Core\Model\Template if (is_null($startAt) || $startAt == '') { $this->setQueueStartAt(null); } else { - $format = $this->_locale->getDateTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM); - $time = $this->_locale->date($startAt, $format)->getTimestamp(); + $format = $this->_localeDate->getDateTimeFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM); + $time = $this->_localeDate->date($startAt, $format)->getTimestamp(); $this->setQueueStartAt($this->_date->gmtDate(null, $time)); } return $this; diff --git a/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php index 56917891583..8170952bde9 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php +++ b/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php @@ -51,7 +51,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Date * - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -60,7 +60,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Logger $logger * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param null|\Zend_Db_Adapter_Abstract $connection * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource */ @@ -69,7 +69,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl \Magento\Logger $logger, \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Event\ManagerInterface $eventManager, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, $connection = null, \Magento\Core\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/Newsletter/Model/Resource/Subscriber.php b/app/code/Magento/Newsletter/Model/Resource/Subscriber.php index 82daf384d7f..f34e30f43bb 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Resource/Subscriber.php @@ -65,7 +65,7 @@ class Subscriber extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Date * - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -78,12 +78,12 @@ class Subscriber extends \Magento\Core\Model\Resource\Db\AbstractDb * Construct * * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Math\Random $mathRandom */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\Math\Random $mathRandom ) { $this->_date = $date; diff --git a/app/code/Magento/Newsletter/Model/Resource/Template.php b/app/code/Magento/Newsletter/Model/Resource/Template.php index 472589fc865..040e9d8e0a2 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Template.php +++ b/app/code/Magento/Newsletter/Model/Resource/Template.php @@ -37,15 +37,15 @@ class Template extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Date * - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date */ - public function __construct(\Magento\App\Resource $resource, \Magento\Core\Model\Date $date) + public function __construct(\Magento\App\Resource $resource, \Magento\Stdlib\DateTime\DateTime $date) { parent::__construct($resource); $this->_date = $date; diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index e35dc1cae0e..12e70609048 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Newsletter * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -42,10 +40,8 @@ namespace Magento\Newsletter\Model; * @method $this setSubscriberStatus(int $value) * @method string getSubscriberConfirmCode() * @method $this setSubscriberConfirmCode(string $value) - * - * @category Magento - * @package Magento_Newsletter - * @author Magento Core Team <core@magentocommerce.com> + * @method int getSubscriberId() + * @method Subscriber setSubscriberId(int $value) */ class Subscriber extends \Magento\Core\Model\AbstractModel { @@ -197,7 +193,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel * Alias for setSubscriberId() * * @param int $value - * @return \Magento\Object + * @return $this */ public function setId($value) { @@ -225,7 +221,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel } /** - * Returns Insubscribe url + * Returns Unsubscribe url * * @return string */ @@ -308,7 +304,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel */ public function setIsStatusChanged($value) { - $this->_isStatusChanged = (boolean)$value; + $this->_isStatusChanged = (boolean) $value; return $this; } @@ -336,7 +332,6 @@ class Subscriber extends \Magento\Core\Model\AbstractModel return false; } - /** * Load subscriber data from resource model by email * @@ -350,13 +345,15 @@ class Subscriber extends \Magento\Core\Model\AbstractModel } /** - * Load subscriber info by customer + * Load subscriber info by customerId * - * @param \Magento\Customer\Model\Customer $customer + * @param int $customerId * @return $this */ - public function loadByCustomer(\Magento\Customer\Model\Customer $customer) + public function loadByCustomer($customerId) { + /** @var \Magento\Customer\Model\Customer $customer */ + $customer = $this->_customerFactory->create()->load($customerId); $data = $this->getResource()->loadByCustomer($customer); $this->addData($data); if (!empty($data) && $customer->getId() && !$this->getCustomerId()) { @@ -431,8 +428,10 @@ class Subscriber extends \Magento\Core\Model\AbstractModel } if ($isSubscribeOwnEmail) { - $this->setStoreId($this->_customerSession->getCustomer()->getStoreId()); - $this->setCustomerId($this->_customerSession->getCustomerId()); + /** @var \Magento\Customer\Model\Customer $customer */ + $customer = $this->_customerFactory->create()->load($this->_customerSession->getCustomerId()); + $this->setStoreId($customer->getStoreId()); + $this->setCustomerId($customer->getId()); } else { $this->setStoreId($this->_storeManager->getStore()->getId()); $this->setCustomerId(0); @@ -468,8 +467,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel throw new \Magento\Core\Exception(__('This is an invalid subscription confirmation code.')); } - $this->setSubscriberStatus(self::STATUS_UNSUBSCRIBED) - ->save(); + $this->setSubscriberStatus(self::STATUS_UNSUBSCRIBED)->save(); $this->sendUnsubscriptionEmail(); return $this; } @@ -500,7 +498,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel */ public function subscribeCustomer($customer) { - $this->loadByCustomer($customer); + $this->loadByCustomer($customer->getId()); if ($customer->getImportMode()) { $this->setImportMode(true); diff --git a/app/code/Magento/Newsletter/view/frontend/layout/default.xml b/app/code/Magento/Newsletter/view/frontend/layout/default.xml index bcf28a3dbf8..175bb8ba8bb 100644 --- a/app/code/Magento/Newsletter/view/frontend/layout/default.xml +++ b/app/code/Magento/Newsletter/view/frontend/layout/default.xml @@ -25,6 +25,6 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceContainer name="footer"> - <block class="Magento\Newsletter\Block\Subscribe" name="form.subscribe" as="subscribe" before="-" template="subscribe.phtml" cacheable="false"/> + <block class="Magento\Newsletter\Block\Subscribe" name="form.subscribe" as="subscribe" before="-" template="subscribe.phtml"/> </referenceContainer> </layout> diff --git a/app/code/Magento/Payment/Block/Form/Banktransfer.php b/app/code/Magento/OfflinePayments/Block/Form/Banktransfer.php similarity index 94% rename from app/code/Magento/Payment/Block/Form/Banktransfer.php rename to app/code/Magento/OfflinePayments/Block/Form/Banktransfer.php index e12fc3ef2f2..7cadb98ada7 100644 --- a/app/code/Magento/Payment/Block/Form/Banktransfer.php +++ b/app/code/Magento/OfflinePayments/Block/Form/Banktransfer.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Payment * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Block\Form; +namespace Magento\OfflinePayments\Block\Form; /** * Block for Bank Transfer payment method form diff --git a/app/code/Magento/Payment/Block/Form/Cashondelivery.php b/app/code/Magento/OfflinePayments/Block/Form/Cashondelivery.php similarity index 94% rename from app/code/Magento/Payment/Block/Form/Cashondelivery.php rename to app/code/Magento/OfflinePayments/Block/Form/Cashondelivery.php index fc5c20fff30..7ad274e5fd3 100644 --- a/app/code/Magento/Payment/Block/Form/Cashondelivery.php +++ b/app/code/Magento/OfflinePayments/Block/Form/Cashondelivery.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Payment * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Block\Form; +namespace Magento\OfflinePayments\Block\Form; /** * Block for Cash On Delivery payment method form diff --git a/app/code/Magento/Payment/Block/Form/Ccsave.php b/app/code/Magento/OfflinePayments/Block/Form/Ccsave.php similarity index 86% rename from app/code/Magento/Payment/Block/Form/Ccsave.php rename to app/code/Magento/OfflinePayments/Block/Form/Ccsave.php index 5b2b992c6b9..804d8fa7079 100644 --- a/app/code/Magento/Payment/Block/Form/Ccsave.php +++ b/app/code/Magento/OfflinePayments/Block/Form/Ccsave.php @@ -18,20 +18,17 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Payment * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Block\Form; +namespace Magento\OfflinePayments\Block\Form; class Ccsave extends \Magento\Payment\Block\Form\Cc { - /** * Cc save template * * @var string */ - protected $_template = 'Magento_Payment::form/ccsave.phtml'; + protected $_template = 'Magento_OfflinePayments::form/ccsave.phtml'; } diff --git a/app/code/Magento/Payment/Block/Form/Checkmo.php b/app/code/Magento/OfflinePayments/Block/Form/Checkmo.php similarity index 86% rename from app/code/Magento/Payment/Block/Form/Checkmo.php rename to app/code/Magento/OfflinePayments/Block/Form/Checkmo.php index 6ab9151e758..2a9f05d4189 100644 --- a/app/code/Magento/Payment/Block/Form/Checkmo.php +++ b/app/code/Magento/OfflinePayments/Block/Form/Checkmo.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Payment * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Block\Form; +namespace Magento\OfflinePayments\Block\Form; class Checkmo extends \Magento\Payment\Block\Form { @@ -32,5 +30,5 @@ class Checkmo extends \Magento\Payment\Block\Form * * @var string */ - protected $_template = 'Magento_Payment::form/checkmo.phtml'; + protected $_template = 'Magento_OfflinePayments::form/checkmo.phtml'; } diff --git a/app/code/Magento/Payment/Block/Form/Purchaseorder.php b/app/code/Magento/OfflinePayments/Block/Form/Purchaseorder.php similarity index 86% rename from app/code/Magento/Payment/Block/Form/Purchaseorder.php rename to app/code/Magento/OfflinePayments/Block/Form/Purchaseorder.php index c4ea6c98329..67377991806 100644 --- a/app/code/Magento/Payment/Block/Form/Purchaseorder.php +++ b/app/code/Magento/OfflinePayments/Block/Form/Purchaseorder.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Payment * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Block\Form; +namespace Magento\OfflinePayments\Block\Form; class Purchaseorder extends \Magento\Payment\Block\Form { @@ -32,6 +30,5 @@ class Purchaseorder extends \Magento\Payment\Block\Form * * @var string */ - protected $_template = 'Magento_Payment::form/purchaseorder.phtml'; - + protected $_template = 'Magento_OfflinePayments::form/purchaseorder.phtml'; } diff --git a/app/code/Magento/Payment/Block/Info/Ccsave.php b/app/code/Magento/OfflinePayments/Block/Info/Ccsave.php similarity index 95% rename from app/code/Magento/Payment/Block/Info/Ccsave.php rename to app/code/Magento/OfflinePayments/Block/Info/Ccsave.php index bc180c2d6c0..aad0d19a111 100644 --- a/app/code/Magento/Payment/Block/Info/Ccsave.php +++ b/app/code/Magento/OfflinePayments/Block/Info/Ccsave.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Payment * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Block\Info; +namespace Magento\OfflinePayments\Block\Info; class Ccsave extends \Magento\Payment\Block\Info\Cc { diff --git a/app/code/Magento/Payment/Block/Info/Checkmo.php b/app/code/Magento/OfflinePayments/Block/Info/Checkmo.php similarity index 91% rename from app/code/Magento/Payment/Block/Info/Checkmo.php rename to app/code/Magento/OfflinePayments/Block/Info/Checkmo.php index 51c4f19d32d..d4a561cc0ea 100644 --- a/app/code/Magento/Payment/Block/Info/Checkmo.php +++ b/app/code/Magento/OfflinePayments/Block/Info/Checkmo.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Payment * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Block\Info; +namespace Magento\OfflinePayments\Block\Info; class Checkmo extends \Magento\Payment\Block\Info { @@ -41,7 +39,7 @@ class Checkmo extends \Magento\Payment\Block\Info /** * @var string */ - protected $_template = 'Magento_Payment::info/checkmo.phtml'; + protected $_template = 'Magento_OfflinePayments::info/checkmo.phtml'; /** * Enter description here... @@ -92,7 +90,7 @@ class Checkmo extends \Magento\Payment\Block\Info */ public function toPdf() { - $this->setTemplate('Magento_Payment::info/pdf/checkmo.phtml'); + $this->setTemplate('Magento_OfflinePayments::info/pdf/checkmo.phtml'); return $this->toHtml(); } diff --git a/app/code/Magento/Payment/Block/Info/Purchaseorder.php b/app/code/Magento/OfflinePayments/Block/Info/Purchaseorder.php similarity index 82% rename from app/code/Magento/Payment/Block/Info/Purchaseorder.php rename to app/code/Magento/OfflinePayments/Block/Info/Purchaseorder.php index 9f614668c4a..85a29b0e5d5 100644 --- a/app/code/Magento/Payment/Block/Info/Purchaseorder.php +++ b/app/code/Magento/OfflinePayments/Block/Info/Purchaseorder.php @@ -18,26 +18,24 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Payment * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Block\Info; +namespace Magento\OfflinePayments\Block\Info; class Purchaseorder extends \Magento\Payment\Block\Info { /** * @var string */ - protected $_template = 'Magento_Payment::info/purchaseorder.phtml'; + protected $_template = 'Magento_OfflinePayments::info/purchaseorder.phtml'; /** * @return string */ public function toPdf() { - $this->setTemplate('Magento_Payment::info/pdf/purchaseorder.phtml'); + $this->setTemplate('Magento_OfflinePayments::info/pdf/purchaseorder.phtml'); return $this->toHtml(); } } diff --git a/app/code/Magento/Payment/Model/Method/Banktransfer.php b/app/code/Magento/OfflinePayments/Model/Banktransfer.php similarity index 90% rename from app/code/Magento/Payment/Model/Method/Banktransfer.php rename to app/code/Magento/OfflinePayments/Model/Banktransfer.php index b326c76dddc..51bd8d40e96 100644 --- a/app/code/Magento/Payment/Model/Method/Banktransfer.php +++ b/app/code/Magento/OfflinePayments/Model/Banktransfer.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Payment * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Model\Method; +namespace Magento\OfflinePayments\Model; /** * Bank Transfer payment method model @@ -44,7 +42,7 @@ class Banktransfer extends \Magento\Payment\Model\Method\AbstractMethod * * @var string */ - protected $_formBlockType = 'Magento\Payment\Block\Form\Banktransfer'; + protected $_formBlockType = 'Magento\OfflinePayments\Block\Form\Banktransfer'; /** * Instructions block path diff --git a/app/code/Magento/Payment/Model/Method/Cashondelivery.php b/app/code/Magento/OfflinePayments/Model/Cashondelivery.php similarity index 90% rename from app/code/Magento/Payment/Model/Method/Cashondelivery.php rename to app/code/Magento/OfflinePayments/Model/Cashondelivery.php index 70a536dff2d..74aefeb7a11 100644 --- a/app/code/Magento/Payment/Model/Method/Cashondelivery.php +++ b/app/code/Magento/OfflinePayments/Model/Cashondelivery.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Payment * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Model\Method; +namespace Magento\OfflinePayments\Model; /** * Cash on delivery payment method model @@ -43,7 +41,7 @@ class Cashondelivery extends \Magento\Payment\Model\Method\AbstractMethod * * @var string */ - protected $_formBlockType = 'Magento\Payment\Block\Form\Cashondelivery'; + protected $_formBlockType = 'Magento\OfflinePayments\Block\Form\Cashondelivery'; /** * Info instructions block path diff --git a/app/code/Magento/Payment/Model/Method/Ccsave.php b/app/code/Magento/OfflinePayments/Model/Ccsave.php similarity index 83% rename from app/code/Magento/Payment/Model/Method/Ccsave.php rename to app/code/Magento/OfflinePayments/Model/Ccsave.php index 4e76d6b1475..a29c054d2e1 100644 --- a/app/code/Magento/Payment/Model/Method/Ccsave.php +++ b/app/code/Magento/OfflinePayments/Model/Ccsave.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Payment * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Model\Method; +namespace Magento\OfflinePayments\Model; class Ccsave extends \Magento\Payment\Model\Method\Cc { @@ -40,10 +38,10 @@ class Ccsave extends \Magento\Payment\Model\Method\Cc /** * @var string */ - protected $_formBlockType = 'Magento\Payment\Block\Form\Ccsave'; + protected $_formBlockType = 'Magento\OfflinePayments\Block\Form\Ccsave'; /** * @var string */ - protected $_infoBlockType = 'Magento\Payment\Block\Info\Ccsave'; + protected $_infoBlockType = 'Magento\OfflinePayments\Block\Info\Ccsave'; } diff --git a/app/code/Magento/Payment/Model/Method/Checkmo.php b/app/code/Magento/OfflinePayments/Model/Checkmo.php similarity index 89% rename from app/code/Magento/Payment/Model/Method/Checkmo.php rename to app/code/Magento/OfflinePayments/Model/Checkmo.php index 33923f07059..a2f56b0a77c 100644 --- a/app/code/Magento/Payment/Model/Method/Checkmo.php +++ b/app/code/Magento/OfflinePayments/Model/Checkmo.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Payment * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Model\Method; +namespace Magento\OfflinePayments\Model; class Checkmo extends \Magento\Payment\Model\Method\AbstractMethod { @@ -35,12 +33,12 @@ class Checkmo extends \Magento\Payment\Model\Method\AbstractMethod /** * @var string */ - protected $_formBlockType = 'Magento\Payment\Block\Form\Checkmo'; + protected $_formBlockType = 'Magento\OfflinePayments\Block\Form\Checkmo'; /** * @var string */ - protected $_infoBlockType = 'Magento\Payment\Block\Info\Checkmo'; + protected $_infoBlockType = 'Magento\OfflinePayments\Block\Info\Checkmo'; /** * Assign data to info model instance diff --git a/app/code/Magento/OfflinePayments/Model/Observer.php b/app/code/Magento/OfflinePayments/Model/Observer.php new file mode 100644 index 00000000000..b001af1fccd --- /dev/null +++ b/app/code/Magento/OfflinePayments/Model/Observer.php @@ -0,0 +1,47 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * OfflinePayments Observer + */ +namespace Magento\OfflinePayments\Model; + +class Observer +{ + /** + * Sets current instructions for bank transfer account + * + * @param \Magento\Event\Observer $observer + * @return void + */ + public function beforeOrderPaymentSave(\Magento\Event\Observer $observer) + { + /** @var \Magento\Sales\Model\Order\Payment $payment */ + $payment = $observer->getEvent()->getPayment(); + $banktransfer = \Magento\OfflinePayments\Model\Banktransfer::PAYMENT_METHOD_BANKTRANSFER_CODE; + if($payment->getMethod() === $banktransfer) { + $payment->setAdditionalInformation('instructions', $payment->getMethodInstance()->getInstructions()); + } + } +} diff --git a/app/code/Magento/Payment/Model/Method/Purchaseorder.php b/app/code/Magento/OfflinePayments/Model/Purchaseorder.php similarity index 85% rename from app/code/Magento/Payment/Model/Method/Purchaseorder.php rename to app/code/Magento/OfflinePayments/Model/Purchaseorder.php index c7fa1394c2e..d3cdd0ac480 100644 --- a/app/code/Magento/Payment/Model/Method/Purchaseorder.php +++ b/app/code/Magento/OfflinePayments/Model/Purchaseorder.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Payment * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Model\Method; +namespace Magento\OfflinePayments\Model; class Purchaseorder extends \Magento\Payment\Model\Method\AbstractMethod { @@ -35,12 +33,12 @@ class Purchaseorder extends \Magento\Payment\Model\Method\AbstractMethod /** * @var string */ - protected $_formBlockType = 'Magento\Payment\Block\Form\Purchaseorder'; + protected $_formBlockType = 'Magento\OfflinePayments\Block\Form\Purchaseorder'; /** * @var string */ - protected $_infoBlockType = 'Magento\Payment\Block\Info\Purchaseorder'; + protected $_infoBlockType = 'Magento\OfflinePayments\Block\Info\Purchaseorder'; /** * Assign data to info model instance diff --git a/app/code/Magento/OfflinePayments/etc/adminhtml/system.xml b/app/code/Magento/OfflinePayments/etc/adminhtml/system.xml new file mode 100644 index 00000000000..02bd8f9775d --- /dev/null +++ b/app/code/Magento/OfflinePayments/etc/adminhtml/system.xml @@ -0,0 +1,274 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <system> + <section id="payment" translate="label" type="text" sortOrder="400" showInDefault="1" showInWebsite="1" showInStore="1"> + <group id="ccsave" translate="label" type="text" sortOrder="27" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Saved CC</label> + <field id="active" translate="label comment" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled</label> + <comment>Enabling this method will store credit card information in the database, which may increase your security or compliance requirements.</comment> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="cctypes" translate="label" type="multiselect" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Credit Card Types</label> + <source_model>Magento\Payment\Model\Config\Source\Cctype</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="order_status" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>New Order Status</label> + <source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model> + </field> + <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Sort Order</label> + <frontend_class>validate-number</frontend_class> + </field> + <field id="title" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Title</label> + </field> + <field id="useccv" translate="label" type="select" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Request Card Security Code</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="centinel" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>3D Secure Card Validation</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="centinel_is_mode_strict" translate="label comment" type="select" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Severe 3D Secure Card Validation</label> + <comment>Severe validation removes chargeback liability on merchant.</comment> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + <depends> + <field id="centinel">1</field> + </depends> + </field> + <field id="centinel_api_url" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Centinel API URL</label> + <comment>A value is required for live mode. Refer to your CardinalCommerce agreement.</comment> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + <depends> + <field id="centinel">1</field> + </depends> + </field> + <field id="allowspecific" translate="label" type="allowspecific" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Payment from Applicable Countries</label> + <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> + </field> + <field id="specificcountry" translate="label" type="multiselect" sortOrder="51" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Payment from Specific Countries</label> + <source_model>Magento\Directory\Model\Config\Source\Country</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="min_order_total" translate="label" type="text" sortOrder="98" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Minimum Order Total</label> + </field> + <field id="max_order_total" translate="label" type="text" sortOrder="99" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Maximum Order Total</label> + </field> + <field id="model"></field> + </group> + <group id="checkmo" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Check / Money Order</label> + <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="order_status" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>New Order Status</label> + <source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model> + </field> + <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Sort Order</label> + <frontend_class>validate-number</frontend_class> + </field> + <field id="title" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Title</label> + </field> + <field id="allowspecific" translate="label" type="allowspecific" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Payment from Applicable Countries</label> + <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> + </field> + <field id="specificcountry" translate="label" type="multiselect" sortOrder="51" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Payment from Specific Countries</label> + <source_model>Magento\Directory\Model\Config\Source\Country</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="payable_to" translate="label" sortOrder="61" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Make Check Payable to</label> + </field> + <field id="mailing_address" translate="label" type="textarea" sortOrder="62" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Send Check to</label> + </field> + <field id="min_order_total" translate="label" type="text" sortOrder="98" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Minimum Order Total</label> + </field> + <field id="max_order_total" translate="label" type="text" sortOrder="99" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Maximum Order Total</label> + </field> + <field id="model"></field> + </group> + <group id="purchaseorder" translate="label" type="text" sortOrder="32" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Purchase Order</label> + <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="order_status" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>New Order Status</label> + <source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model> + </field> + <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Sort Order</label> + <frontend_class>validate-number</frontend_class> + </field> + <field id="title" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Title</label> + </field> + <field id="allowspecific" translate="label" type="allowspecific" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Payment from Applicable Countries</label> + <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> + </field> + <field id="specificcountry" translate="label" type="multiselect" sortOrder="51" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Payment from Specific Countries</label> + <source_model>Magento\Directory\Model\Config\Source\Country</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="min_order_total" translate="label" type="text" sortOrder="98" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Minimum Order Total</label> + </field> + <field id="max_order_total" translate="label" type="text" sortOrder="99" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Maximum Order Total</label> + </field> + <field id="model"></field> + </group> + <group id="banktransfer" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Bank Transfer Payment</label> + <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="title" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Title</label> + </field> + <field id="order_status" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>New Order Status</label> + <source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model> + </field> + <field id="allowspecific" translate="label" type="allowspecific" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Payment from Applicable Countries</label> + <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> + </field> + <field id="specificcountry" translate="label" type="multiselect" sortOrder="51" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Payment from Specific Countries</label> + <source_model>Magento\Directory\Model\Config\Source\Country</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="instructions" translate="label" type="textarea" sortOrder="62" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Instructions</label> + </field> + <field id="min_order_total" translate="label" type="text" sortOrder="98" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Minimum Order Total</label> + </field> + <field id="max_order_total" translate="label" type="text" sortOrder="99" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Maximum Order Total</label> + </field> + <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Sort Order</label> + </field> + </group> + <group id="cashondelivery" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Cash On Delivery Payment</label> + <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="title" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Title</label> + </field> + <field id="order_status" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>New Order Status</label> + <source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model> + </field> + <field id="allowspecific" translate="label" type="allowspecific" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Payment from Applicable Countries</label> + <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> + </field> + <field id="specificcountry" translate="label" type="multiselect" sortOrder="51" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Payment from Specific Countries</label> + <source_model>Magento\Directory\Model\Config\Source\Country</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="instructions" translate="label" type="textarea" sortOrder="62" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Instructions</label> + </field> + <field id="min_order_total" translate="label" type="text" sortOrder="98" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Minimum Order Total</label> + </field> + <field id="max_order_total" translate="label" type="text" sortOrder="99" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Maximum Order Total</label> + </field> + <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Sort Order</label> + </field> + </group> + <group id="free" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Zero Subtotal Checkout</label> + <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="order_status" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>New Order Status</label> + <source_model>Magento\Sales\Model\Config\Source\Order\Status\Newprocessing</source_model> + </field> + <field id="payment_action" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Automatically Invoice All Items</label> + <source_model>Magento\Payment\Model\Source\Invoice</source_model> + <depends> + <field id="order_status" separator=",">processing,processed_ogone</field> + </depends> + </field> + <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Sort Order</label> + <frontend_class>validate-number</frontend_class> + </field> + <field id="title" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Title</label> + </field> + <field id="allowspecific" translate="label" type="allowspecific" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Payment from Applicable Countries</label> + <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> + </field> + <field id="specificcountry" translate="label" type="multiselect" sortOrder="51" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Payment from Specific Countries</label> + <source_model>Magento\Directory\Model\Config\Source\Country</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="model"></field> + </group> + </section> + </system> +</config> diff --git a/app/code/Magento/OfflinePayments/etc/config.xml b/app/code/Magento/OfflinePayments/etc/config.xml new file mode 100644 index 00000000000..15594e040fa --- /dev/null +++ b/app/code/Magento/OfflinePayments/etc/config.xml @@ -0,0 +1,72 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <default> + <payment> + <ccsave> + <active>0</active> + <cctypes>AE,VI,MC,DI</cctypes> + <model>Magento\OfflinePayments\Model\Ccsave</model> + <order_status>pending</order_status> + <title>Credit Card (saved)</title> + <allowspecific>0</allowspecific> + <group>offline</group> + </ccsave> + <checkmo> + <active>1</active> + <model>Magento\OfflinePayments\Model\Checkmo</model> + <order_status>pending</order_status> + <title>Check / Money order</title> + <allowspecific>0</allowspecific> + <group>offline</group> + </checkmo> + <purchaseorder> + <active>0</active> + <model>Magento\OfflinePayments\Model\Purchaseorder</model> + <order_status>pending</order_status> + <title>Purchase Order</title> + <allowspecific>0</allowspecific> + <group>offline</group> + </purchaseorder> + <banktransfer> + <active>0</active> + <model>Magento\OfflinePayments\Model\Banktransfer</model> + <order_status>pending</order_status> + <title>Bank Transfer Payment</title> + <allowspecific>0</allowspecific> + <group>offline</group> + </banktransfer> + <cashondelivery> + <active>0</active> + <model>Magento\OfflinePayments\Model\Cashondelivery</model> + <order_status>pending</order_status> + <title>Cash On Delivery</title> + <allowspecific>0</allowspecific> + <group>offline</group> + </cashondelivery> + </payment> + </default> +</config> diff --git a/app/code/Magento/OfflinePayments/etc/events.xml b/app/code/Magento/OfflinePayments/etc/events.xml new file mode 100644 index 00000000000..d61709202fa --- /dev/null +++ b/app/code/Magento/OfflinePayments/etc/events.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <event name="sales_order_payment_save_before"> + <observer name="payment_before_save" instance="Magento\OfflinePayments\Model\Observer" method="beforeOrderPaymentSave" /> + </event> +</config> diff --git a/app/code/Magento/OfflinePayments/etc/module.xml b/app/code/Magento/OfflinePayments/etc/module.xml new file mode 100644 index 00000000000..240de3b1f42 --- /dev/null +++ b/app/code/Magento/OfflinePayments/etc/module.xml @@ -0,0 +1,37 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <module name="Magento_OfflinePayments" version="1.6.0.0" active="true"> + <sequence> + <module name="Magento_Core"/> + <module name="Magento_Catalog"/> + </sequence> + <depends> + <module name="Magento_Payment"/> + <module name="Magento_Checkout"/> + </depends> + </module> +</config> diff --git a/app/code/Magento/OfflinePayments/etc/payment.xml b/app/code/Magento/OfflinePayments/etc/payment.xml new file mode 100644 index 00000000000..642e8e8f963 --- /dev/null +++ b/app/code/Magento/OfflinePayments/etc/payment.xml @@ -0,0 +1,59 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<payment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../Magento/Payment/etc/payment.xsd"> + <groups> + <group id="offline"> + <label>Offline Payment Methods</label> + </group> + </groups> + <methods> + <method name="banktransfer"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="cashondelivery"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="ccsave"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="checkmo"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="purchaseorder"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="free"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + </methods> +</payment> diff --git a/app/code/Magento/Payment/view/adminhtml/form/banktransfer.phtml b/app/code/Magento/OfflinePayments/view/adminhtml/form/banktransfer.phtml similarity index 100% rename from app/code/Magento/Payment/view/adminhtml/form/banktransfer.phtml rename to app/code/Magento/OfflinePayments/view/adminhtml/form/banktransfer.phtml diff --git a/app/code/Magento/Payment/view/adminhtml/form/cashondelivery.phtml b/app/code/Magento/OfflinePayments/view/adminhtml/form/cashondelivery.phtml similarity index 100% rename from app/code/Magento/Payment/view/adminhtml/form/cashondelivery.phtml rename to app/code/Magento/OfflinePayments/view/adminhtml/form/cashondelivery.phtml diff --git a/app/code/Magento/Payment/view/adminhtml/form/ccsave.phtml b/app/code/Magento/OfflinePayments/view/adminhtml/form/ccsave.phtml similarity index 100% rename from app/code/Magento/Payment/view/adminhtml/form/ccsave.phtml rename to app/code/Magento/OfflinePayments/view/adminhtml/form/ccsave.phtml diff --git a/app/code/Magento/Payment/view/adminhtml/form/checkmo.phtml b/app/code/Magento/OfflinePayments/view/adminhtml/form/checkmo.phtml similarity index 100% rename from app/code/Magento/Payment/view/adminhtml/form/checkmo.phtml rename to app/code/Magento/OfflinePayments/view/adminhtml/form/checkmo.phtml diff --git a/app/code/Magento/Payment/view/adminhtml/form/purchaseorder.phtml b/app/code/Magento/OfflinePayments/view/adminhtml/form/purchaseorder.phtml similarity index 100% rename from app/code/Magento/Payment/view/adminhtml/form/purchaseorder.phtml rename to app/code/Magento/OfflinePayments/view/adminhtml/form/purchaseorder.phtml diff --git a/app/code/Magento/Payment/view/adminhtml/info/checkmo.phtml b/app/code/Magento/OfflinePayments/view/adminhtml/info/checkmo.phtml similarity index 100% rename from app/code/Magento/Payment/view/adminhtml/info/checkmo.phtml rename to app/code/Magento/OfflinePayments/view/adminhtml/info/checkmo.phtml diff --git a/app/code/Magento/Payment/view/adminhtml/info/pdf/checkmo.phtml b/app/code/Magento/OfflinePayments/view/adminhtml/info/pdf/checkmo.phtml similarity index 100% rename from app/code/Magento/Payment/view/adminhtml/info/pdf/checkmo.phtml rename to app/code/Magento/OfflinePayments/view/adminhtml/info/pdf/checkmo.phtml diff --git a/app/code/Magento/Payment/view/adminhtml/info/pdf/purchaseorder.phtml b/app/code/Magento/OfflinePayments/view/adminhtml/info/pdf/purchaseorder.phtml similarity index 100% rename from app/code/Magento/Payment/view/adminhtml/info/pdf/purchaseorder.phtml rename to app/code/Magento/OfflinePayments/view/adminhtml/info/pdf/purchaseorder.phtml diff --git a/app/code/Magento/Payment/view/adminhtml/info/purchaseorder.phtml b/app/code/Magento/OfflinePayments/view/adminhtml/info/purchaseorder.phtml similarity index 100% rename from app/code/Magento/Payment/view/adminhtml/info/purchaseorder.phtml rename to app/code/Magento/OfflinePayments/view/adminhtml/info/purchaseorder.phtml diff --git a/app/code/Magento/Payment/view/frontend/form/banktransfer.phtml b/app/code/Magento/OfflinePayments/view/frontend/form/banktransfer.phtml similarity index 100% rename from app/code/Magento/Payment/view/frontend/form/banktransfer.phtml rename to app/code/Magento/OfflinePayments/view/frontend/form/banktransfer.phtml diff --git a/app/code/Magento/Payment/view/frontend/form/cashondelivery.phtml b/app/code/Magento/OfflinePayments/view/frontend/form/cashondelivery.phtml similarity index 100% rename from app/code/Magento/Payment/view/frontend/form/cashondelivery.phtml rename to app/code/Magento/OfflinePayments/view/frontend/form/cashondelivery.phtml diff --git a/app/code/Magento/Payment/view/frontend/form/ccsave.phtml b/app/code/Magento/OfflinePayments/view/frontend/form/ccsave.phtml similarity index 100% rename from app/code/Magento/Payment/view/frontend/form/ccsave.phtml rename to app/code/Magento/OfflinePayments/view/frontend/form/ccsave.phtml diff --git a/app/code/Magento/Payment/view/frontend/form/checkmo.phtml b/app/code/Magento/OfflinePayments/view/frontend/form/checkmo.phtml similarity index 100% rename from app/code/Magento/Payment/view/frontend/form/checkmo.phtml rename to app/code/Magento/OfflinePayments/view/frontend/form/checkmo.phtml diff --git a/app/code/Magento/Payment/view/frontend/form/purchaseorder.phtml b/app/code/Magento/OfflinePayments/view/frontend/form/purchaseorder.phtml similarity index 100% rename from app/code/Magento/Payment/view/frontend/form/purchaseorder.phtml rename to app/code/Magento/OfflinePayments/view/frontend/form/purchaseorder.phtml diff --git a/app/code/Magento/Payment/view/frontend/info/checkmo.phtml b/app/code/Magento/OfflinePayments/view/frontend/info/checkmo.phtml similarity index 100% rename from app/code/Magento/Payment/view/frontend/info/checkmo.phtml rename to app/code/Magento/OfflinePayments/view/frontend/info/checkmo.phtml diff --git a/app/code/Magento/Payment/view/frontend/info/purchaseorder.phtml b/app/code/Magento/OfflinePayments/view/frontend/info/purchaseorder.phtml similarity index 100% rename from app/code/Magento/Payment/view/frontend/info/purchaseorder.phtml rename to app/code/Magento/OfflinePayments/view/frontend/info/purchaseorder.phtml diff --git a/app/code/Magento/Shipping/Block/Adminhtml/Carrier/Tablerate/Grid.php b/app/code/Magento/OfflineShipping/Block/Adminhtml/Carrier/Tablerate/Grid.php similarity index 86% rename from app/code/Magento/Shipping/Block/Adminhtml/Carrier/Tablerate/Grid.php rename to app/code/Magento/OfflineShipping/Block/Adminhtml/Carrier/Tablerate/Grid.php index b68a81fcc43..6629478778a 100644 --- a/app/code/Magento/Shipping/Block/Adminhtml/Carrier/Tablerate/Grid.php +++ b/app/code/Magento/OfflineShipping/Block/Adminhtml/Carrier/Tablerate/Grid.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Shipping * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Shipping\Block\Adminhtml\Carrier\Tablerate; +namespace Magento\OfflineShipping\Block\Adminhtml\Carrier\Tablerate; /** * Shipping carrier table rate grid block @@ -48,27 +46,27 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended protected $_conditionName; /** - * @var \Magento\Shipping\Model\Carrier\Tablerate + * @var \Magento\OfflineShipping\Model\Carrier\Tablerate */ protected $_tablerate; /** - * @var \Magento\Shipping\Model\Resource\Carrier\Tablerate\CollectionFactory + * @var \Magento\OfflineShipping\Model\Resource\Carrier\Tablerate\CollectionFactory */ protected $_collectionFactory; /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper - * @param \Magento\Shipping\Model\Resource\Carrier\Tablerate\CollectionFactory $collectionFactory - * @param \Magento\Shipping\Model\Carrier\Tablerate $tablerate + * @param \Magento\OfflineShipping\Model\Resource\Carrier\Tablerate\CollectionFactory $collectionFactory + * @param \Magento\OfflineShipping\Model\Carrier\Tablerate $tablerate * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, - \Magento\Shipping\Model\Resource\Carrier\Tablerate\CollectionFactory $collectionFactory, - \Magento\Shipping\Model\Carrier\Tablerate $tablerate, + \Magento\OfflineShipping\Model\Resource\Carrier\Tablerate\CollectionFactory $collectionFactory, + \Magento\OfflineShipping\Model\Carrier\Tablerate $tablerate, array $data = array() ) { $this->_collectionFactory = $collectionFactory; @@ -138,11 +136,11 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * Prepare shipping table rate collection * - * @return \Magento\Shipping\Block\Adminhtml\Carrier\Tablerate\Grid + * @return \Magento\OfflineShipping\Block\Adminhtml\Carrier\Tablerate\Grid */ protected function _prepareCollection() { - /** @var $collection \Magento\Shipping\Model\Resource\Carrier\Tablerate\Collection */ + /** @var $collection \Magento\OfflineShipping\Model\Resource\Carrier\Tablerate\Collection */ $collection = $this->_collectionFactory->create(); $collection->setConditionFilter($this->getConditionName()) ->setWebsiteFilter($this->getWebsiteId()); diff --git a/app/code/Magento/Backend/Block/System/Config/Form/Field/Export.php b/app/code/Magento/OfflineShipping/Block/Adminhtml/Form/Field/Export.php similarity index 87% rename from app/code/Magento/Backend/Block/System/Config/Form/Field/Export.php rename to app/code/Magento/OfflineShipping/Block/Adminhtml/Form/Field/Export.php index 08724b5b555..d2c221d360a 100644 --- a/app/code/Magento/Backend/Block/System/Config/Form/Field/Export.php +++ b/app/code/Magento/OfflineShipping/Block/Adminhtml/Form/Field/Export.php @@ -18,26 +18,24 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Backend * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Backend\Block\System\Config\Form\Field; +namespace Magento\OfflineShipping\Block\Adminhtml\Form\Field; /** * Export CSV button for shipping table rates * * @category Magento - * @package Magento_Backend + * @package Magento_OfflineShipping * @author Magento Core Team <core@magentocommerce.com> */ class Export extends \Magento\Data\Form\Element\AbstractElement { /** - * @var \Magento\Backend\Helper\Data + * @var \Magento\Backend\Model\UrlInterface */ - protected $_helper; + protected $_backendUrl; /** * @param \Magento\Data\Form\Element\Factory $factoryElement @@ -50,11 +48,11 @@ class Export extends \Magento\Data\Form\Element\AbstractElement \Magento\Data\Form\Element\Factory $factoryElement, \Magento\Data\Form\Element\CollectionFactory $factoryCollection, \Magento\Escaper $escaper, - \Magento\Backend\Helper\Data $helper, + \Magento\Backend\Model\UrlInterface $backendUrl, array $data = array() ) { - $this->_helper = $helper; parent::__construct($factoryElement, $factoryCollection, $escaper, $data); + $this->_backendUrl = $backendUrl; } /** @@ -72,7 +70,7 @@ class Export extends \Magento\Data\Form\Element\AbstractElement 'website' => $buttonBlock->getRequest()->getParam('website') ); - $url = $this->_helper->getUrl("*/*/exportTablerates", $params); + $url = $this->_backendUrl->getUrl("*/*/exportTablerates", $params); $data = array( 'label' => __('Export CSV'), 'onclick' => "setLocation('" . $url diff --git a/app/code/Magento/Backend/Block/System/Config/Form/Field/Import.php b/app/code/Magento/OfflineShipping/Block/Adminhtml/Form/Field/Import.php similarity index 93% rename from app/code/Magento/Backend/Block/System/Config/Form/Field/Import.php rename to app/code/Magento/OfflineShipping/Block/Adminhtml/Form/Field/Import.php index b569cc095e3..fc5dae68f33 100644 --- a/app/code/Magento/Backend/Block/System/Config/Form/Field/Import.php +++ b/app/code/Magento/OfflineShipping/Block/Adminhtml/Form/Field/Import.php @@ -18,18 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Backend * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Backend\Block\System\Config\Form\Field; +namespace Magento\OfflineShipping\Block\Adminhtml\Form\Field; /** * Custom import CSV file field for shipping table rates * * @category Magento - * @package Magento_Backend + * @package Magento_OfflineShipping * @author Magento Core Team <core@magentocommerce.com> */ class Import extends \Magento\Data\Form\Element\AbstractElement @@ -71,5 +69,4 @@ EndHTML; return $html; } - } diff --git a/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config.php b/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config.php new file mode 100644 index 00000000000..815d38d55a9 --- /dev/null +++ b/app/code/Magento/OfflineShipping/Controller/Adminhtml/System/Config.php @@ -0,0 +1,82 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\OfflineShipping\Controller\Adminhtml\System; + +use Magento\App\ResponseInterface; +use Magento\Backend\Controller\Adminhtml\System\AbstractConfig; + +/** + * System Configuration controller + */ +class Config extends AbstractConfig +{ + /** + * @var \Magento\App\Response\Http\FileFactory + */ + protected $_fileFactory; + + /** + * @var \Magento\Core\Model\StoreManagerInterface + */ + protected $_storeManager; + + /** + * @param \Magento\Backend\App\Action\Context $context + * @param \Magento\Backend\Model\Config\Structure $configStructure + * @param \Magento\App\Response\Http\FileFactory $fileFactory + * @param \Magento\Core\Model\StoreManagerInterface $storeManager + */ + public function __construct( + \Magento\Backend\App\Action\Context $context, + \Magento\Backend\Model\Config\Structure $configStructure, + \Magento\App\Response\Http\FileFactory $fileFactory, + \Magento\Core\Model\StoreManagerInterface $storeManager + ) { + $this->_storeManager = $storeManager; + $this->_fileFactory = $fileFactory; + parent::__construct($context, $configStructure); + } + + /** + * Export shipping table rates in csv format + * + * @return ResponseInterface + */ + public function exportTableratesAction() + { + $fileName = 'tablerates.csv'; + /** @var $gridBlock \Magento\OfflineShipping\Block\Adminhtml\Carrier\Tablerate\Grid */ + $gridBlock = $this->_view->getLayout() + ->createBlock('Magento\OfflineShipping\Block\Adminhtml\Carrier\Tablerate\Grid'); + $website = $this->_storeManager->getWebsite($this->getRequest()->getParam('website')); + if ($this->getRequest()->getParam('conditionName')) { + $conditionName = $this->getRequest()->getParam('conditionName'); + } else { + $conditionName = $website->getConfig('carriers/tablerate/condition_name'); + } + $gridBlock->setWebsiteId($website->getId())->setConditionName($conditionName); + $content = $gridBlock->getCsvFile(); + return $this->_fileFactory->create($fileName, $content, \Magento\App\Filesystem::VAR_DIR); + } +} diff --git a/app/code/Magento/Shipping/Model/Carrier/Flatrate.php b/app/code/Magento/OfflineShipping/Model/Carrier/Flatrate.php similarity index 96% rename from app/code/Magento/Shipping/Model/Carrier/Flatrate.php rename to app/code/Magento/OfflineShipping/Model/Carrier/Flatrate.php index 3cea194f4c1..63616b238ae 100644 --- a/app/code/Magento/Shipping/Model/Carrier/Flatrate.php +++ b/app/code/Magento/OfflineShipping/Model/Carrier/Flatrate.php @@ -18,19 +18,15 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Shipping * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Shipping\Model\Carrier; +namespace Magento\OfflineShipping\Model\Carrier; use Magento\Shipping\Model\Rate\Result; /** * Flat rate shipping model - * - * @author Magento Core Team <core@magentocommerce.com> */ class Flatrate extends \Magento\Shipping\Model\Carrier\AbstractCarrier diff --git a/app/code/Magento/Shipping/Model/Carrier/Freeshipping.php b/app/code/Magento/OfflineShipping/Model/Carrier/Freeshipping.php similarity index 94% rename from app/code/Magento/Shipping/Model/Carrier/Freeshipping.php rename to app/code/Magento/OfflineShipping/Model/Carrier/Freeshipping.php index 344a64c78fe..06a9d8df818 100644 --- a/app/code/Magento/Shipping/Model/Carrier/Freeshipping.php +++ b/app/code/Magento/OfflineShipping/Model/Carrier/Freeshipping.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Shipping * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -29,10 +27,10 @@ * Free shipping model * * @category Magento - * @package Magento_Shipping - * @author Magento Core Team <core@magentocommerce.com> + * @package Magento_OfflineShipping + * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Shipping\Model\Carrier; +namespace Magento\OfflineShipping\Model\Carrier; class Freeshipping extends \Magento\Shipping\Model\Carrier\AbstractCarrier @@ -148,7 +146,7 @@ class Freeshipping */ public function getAllowedMethods() { - return array('freeshipping'=>$this->getConfigData('name')); + return array('freeshipping' => $this->getConfigData('name')); } } diff --git a/app/code/Magento/Shipping/Model/Carrier/Pickup.php b/app/code/Magento/OfflineShipping/Model/Carrier/Pickup.php similarity index 97% rename from app/code/Magento/Shipping/Model/Carrier/Pickup.php rename to app/code/Magento/OfflineShipping/Model/Carrier/Pickup.php index 01b843db44a..7e834a40570 100644 --- a/app/code/Magento/Shipping/Model/Carrier/Pickup.php +++ b/app/code/Magento/OfflineShipping/Model/Carrier/Pickup.php @@ -18,14 +18,12 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Shipping * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Shipping\Model\Carrier; +namespace Magento\OfflineShipping\Model\Carrier; class Pickup extends \Magento\Shipping\Model\Carrier\AbstractCarrier diff --git a/app/code/Magento/Shipping/Model/Carrier/Tablerate.php b/app/code/Magento/OfflineShipping/Model/Carrier/Tablerate.php similarity index 96% rename from app/code/Magento/Shipping/Model/Carrier/Tablerate.php rename to app/code/Magento/OfflineShipping/Model/Carrier/Tablerate.php index 636f35432d1..2aef44a1696 100644 --- a/app/code/Magento/Shipping/Model/Carrier/Tablerate.php +++ b/app/code/Magento/OfflineShipping/Model/Carrier/Tablerate.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Shipping * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Shipping\Model\Carrier; +namespace Magento\OfflineShipping\Model\Carrier; class Tablerate extends \Magento\Shipping\Model\Carrier\AbstractCarrier @@ -60,7 +58,7 @@ class Tablerate protected $_resultMethodFactory; /** - * @var \Magento\Shipping\Model\Resource\Carrier\TablerateFactory + * @var \Magento\OfflineShipping\Model\Resource\Carrier\TablerateFactory */ protected $_tablerateFactory; @@ -70,7 +68,7 @@ class Tablerate * @param \Magento\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory * @param \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $resultMethodFactory - * @param \Magento\Shipping\Model\Resource\Carrier\TablerateFactory $tablerateFactory + * @param \Magento\OfflineShipping\Model\Resource\Carrier\TablerateFactory $tablerateFactory * @param array $data */ public function __construct( @@ -79,7 +77,7 @@ class Tablerate \Magento\Logger\AdapterFactory $logAdapterFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory, \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $resultMethodFactory, - \Magento\Shipping\Model\Resource\Carrier\TablerateFactory $tablerateFactory, + \Magento\OfflineShipping\Model\Resource\Carrier\TablerateFactory $tablerateFactory, array $data = array() ) { $this->_rateResultFactory = $rateResultFactory; diff --git a/app/code/Magento/Shipping/Model/Config/Backend/Tablerate.php b/app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php similarity index 86% rename from app/code/Magento/Shipping/Model/Config/Backend/Tablerate.php rename to app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php index 243232767d0..00a4105295d 100644 --- a/app/code/Magento/Shipping/Model/Config/Backend/Tablerate.php +++ b/app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Shipping * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Shipping\Model\Config\Backend; +namespace Magento\OfflineShipping\Model\Config\Backend; use Magento\Core\Model\AbstractModel; @@ -35,7 +33,7 @@ use Magento\Core\Model\AbstractModel; class Tablerate extends \Magento\Core\Model\Config\Value { /** - * @var \Magento\Shipping\Model\Resource\Carrier\TablerateFactory + * @var \Magento\OfflineShipping\Model\Resource\Carrier\TablerateFactory */ protected $_tablerateFactory; @@ -44,7 +42,7 @@ class Tablerate extends \Magento\Core\Model\Config\Value * @param \Magento\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config - * @param \Magento\Shipping\Model\Resource\Carrier\TablerateFactory $tablerateFactory + * @param \Magento\OfflineShipping\Model\Resource\Carrier\TablerateFactory $tablerateFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -54,7 +52,7 @@ class Tablerate extends \Magento\Core\Model\Config\Value \Magento\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, - \Magento\Shipping\Model\Resource\Carrier\TablerateFactory $tablerateFactory, + \Magento\OfflineShipping\Model\Resource\Carrier\TablerateFactory $tablerateFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Shipping/Model/Config/Source/Flatrate.php b/app/code/Magento/OfflineShipping/Model/Config/Source/Flatrate.php similarity index 92% rename from app/code/Magento/Shipping/Model/Config/Source/Flatrate.php rename to app/code/Magento/OfflineShipping/Model/Config/Source/Flatrate.php index b8f20ba036c..7ea6e11f08b 100644 --- a/app/code/Magento/Shipping/Model/Config/Source/Flatrate.php +++ b/app/code/Magento/OfflineShipping/Model/Config/Source/Flatrate.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Shipping * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Shipping\Model\Config\Source; +namespace Magento\OfflineShipping\Model\Config\Source; class Flatrate implements \Magento\Option\ArrayInterface { diff --git a/app/code/Magento/Shipping/Model/Config/Source/Tablerate.php b/app/code/Magento/OfflineShipping/Model/Config/Source/Tablerate.php similarity index 76% rename from app/code/Magento/Shipping/Model/Config/Source/Tablerate.php rename to app/code/Magento/OfflineShipping/Model/Config/Source/Tablerate.php index b8baf119b6d..ad1876ac27e 100644 --- a/app/code/Magento/Shipping/Model/Config/Source/Tablerate.php +++ b/app/code/Magento/OfflineShipping/Model/Config/Source/Tablerate.php @@ -18,26 +18,24 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Shipping * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Shipping\Model\Config\Source; +namespace Magento\OfflineShipping\Model\Config\Source; class Tablerate implements \Magento\Option\ArrayInterface { /** - * @var \Magento\Shipping\Model\Carrier\Tablerate + * @var \Magento\OfflineShipping\Model\Carrier\Tablerate */ protected $_carrierTablerate; /** - * @param \Magento\Shipping\Model\Carrier\Tablerate $carrierTablerate + * @param \Magento\OfflineShipping\Model\Carrier\Tablerate $carrierTablerate */ - public function __construct(\Magento\Shipping\Model\Carrier\Tablerate $carrierTablerate) + public function __construct(\Magento\OfflineShipping\Model\Carrier\Tablerate $carrierTablerate) { $this->_carrierTablerate = $carrierTablerate; } @@ -48,8 +46,8 @@ class Tablerate implements \Magento\Option\ArrayInterface public function toOptionArray() { $arr = array(); - foreach ($this->_carrierTablerate->getCode('condition_name') as $k=>$v) { - $arr[] = array('value'=>$k, 'label'=>$v); + foreach ($this->_carrierTablerate->getCode('condition_name') as $k => $v) { + $arr[] = array('value' => $k, 'label' => $v); } return $arr; } diff --git a/app/code/Magento/OfflineShipping/Model/Observer/SalesRule/ActionsTab.php b/app/code/Magento/OfflineShipping/Model/Observer/SalesRule/ActionsTab.php new file mode 100644 index 00000000000..8428f33ec09 --- /dev/null +++ b/app/code/Magento/OfflineShipping/Model/Observer/SalesRule/ActionsTab.php @@ -0,0 +1,56 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Checkout cart shipping block plugin + * + * @category Magento + * @package Magento_OfflineShipping + * @author Magento Core Team <core@magentocommerce.com> + */ +namespace Magento\OfflineShipping\Model\Observer\SalesRule; + +class ActionsTab +{ + public function prepareForm($observer) + { + /** @var \Magento\Data\Form $form */ + $form = $observer->getForm(); + foreach ($form->getElements() as $element) { + /** @var \Magento\Data\Form\Element\AbstractElement $element */ + if ($element->getId() == 'action_fieldset') { + $element->addField('simple_free_shipping', 'select', array( + 'label' => __('Free Shipping'), + 'title' => __('Free Shipping'), + 'name' => 'simple_free_shipping', + 'options' => array( + 0 => __('No'), + \Magento\OfflineShipping\Model\SalesRule\Rule::FREE_SHIPPING_ITEM => __('For matching items only'), + \Magento\OfflineShipping\Model\SalesRule\Rule::FREE_SHIPPING_ADDRESS => __('For shipment with matching items'), + ), + )); + } + } + } +} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Nondoc.php b/app/code/Magento/OfflineShipping/Model/Plugin/Checkout/Block/Cart/Shipping.php similarity index 55% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Nondoc.php rename to app/code/Magento/OfflineShipping/Model/Plugin/Checkout/Block/Cart/Shipping.php index dbd0c51137a..4055b7adca2 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Nondoc.php +++ b/app/code/Magento/OfflineShipping/Model/Plugin/Checkout/Block/Cart/Shipping.php @@ -18,28 +18,42 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** - * Source model for DHL shipping methods for documentation + * Checkout cart shipping block plugin * * @category Magento - * @package Magento_Usa + * @package Magento_OfflineShipping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method; +namespace Magento\OfflineShipping\Model\Plugin\Checkout\Block\Cart; -class Nondoc - extends \Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\AbstractMethod +class Shipping { /** - * Carrier Product Type Indicator - * - * @var string $_contentType + * @var \Magento\Core\Model\Store\Config */ - protected $_contentType = \Magento\Usa\Model\Shipping\Carrier\Dhl\International::DHL_CONTENT_TYPE_NON_DOC; + protected $_storeConfig; + + /** + * @param \Magento\Core\Model\Store\Config $storeConfig + */ + public function __construct(\Magento\Core\Model\Store\Config $storeConfig) + { + $this->_storeConfig = $storeConfig; + } + + /** + * @param \Magento\Checkout\Block\Cart\Shipping $subject + * @param bool $result + * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterGetStateActive(\Magento\Checkout\Block\Cart\Shipping $subject, $result) + { + return (bool)$result || (bool)$this->_storeConfig->getConfig('carriers/tablerate/active'); + } } diff --git a/app/code/Magento/SalesRule/Model/Quote/Freeshipping.php b/app/code/Magento/OfflineShipping/Model/Quote/Freeshipping.php similarity index 86% rename from app/code/Magento/SalesRule/Model/Quote/Freeshipping.php rename to app/code/Magento/OfflineShipping/Model/Quote/Freeshipping.php index 0e121537242..9dfb8d912d0 100644 --- a/app/code/Magento/SalesRule/Model/Quote/Freeshipping.php +++ b/app/code/Magento/OfflineShipping/Model/Quote/Freeshipping.php @@ -24,15 +24,15 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - -namespace Magento\SalesRule\Model\Quote; +namespace Magento\OfflineShipping\Model\Quote; +use Magento\Sales\Model\Quote\Address; class Freeshipping extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal { /** * Discount calculation object * - * @var \Magento\SalesRule\Model\Validator + * @var \Magento\OfflineShipping\Model\SalesRule\Calculator */ protected $_calculator; @@ -43,24 +43,24 @@ class Freeshipping extends \Magento\Sales\Model\Quote\Address\Total\AbstractTota /** * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\SalesRule\Model\Validator $validator + * @param \Magento\OfflineShipping\Model\SalesRule\Calculator $calculator */ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\SalesRule\Model\Validator $validator + \Magento\OfflineShipping\Model\SalesRule\Calculator $calculator ) { $this->setCode('discount'); - $this->_calculator = $validator; $this->_storeManager = $storeManager; + $this->_calculator = $calculator; } /** * Collect information about free shipping for all address items * * @param \Magento\Sales\Model\Quote\Address $address - * @return \Magento\SalesRule\Model\Quote\Freeshipping + * @return \Magento\OfflineShipping\Model\Quote\Freeshipping */ - public function collect(\Magento\Sales\Model\Quote\Address $address) + public function collect(Address $address) { parent::collect($address); $quote = $address->getQuote(); @@ -113,11 +113,10 @@ class Freeshipping extends \Magento\Sales\Model\Quote\Address\Total\AbstractTota * By default we not present such information * * @param \Magento\Sales\Model\Quote\Address $address - * @return \Magento\SalesRule\Model\Quote\Freeshipping + * @return \Magento\OfflineShipping\Model\Quote\Freeshipping */ - public function fetch(\Magento\Sales\Model\Quote\Address $address) + public function fetch(Address $address) { return $this; } - } diff --git a/app/code/Magento/Shipping/Model/Resource/Carrier/Tablerate.php b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php similarity index 96% rename from app/code/Magento/Shipping/Model/Resource/Carrier/Tablerate.php rename to app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php index 92c32c7d01d..6ee6184de2b 100644 --- a/app/code/Magento/Shipping/Model/Resource/Carrier/Tablerate.php +++ b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Shipping * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -28,10 +26,10 @@ * Shipping table rates * * @category Magento - * @package Magento_Shipping + * @package Magento_OfflineShipping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Shipping\Model\Resource\Carrier; +namespace Magento\OfflineShipping\Model\Resource\Carrier; class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb { @@ -115,7 +113,7 @@ class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb protected $_storeManager; /** - * @var \Magento\Shipping\Model\Carrier\Tablerate + * @var \Magento\OfflineShipping\Model\Carrier\Tablerate */ protected $_carrierTablerate; @@ -141,7 +139,7 @@ class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb * @param \Magento\Logger $logger * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Shipping\Model\Carrier\Tablerate $carrierTablerate + * @param \Magento\OfflineShipping\Model\Carrier\Tablerate $carrierTablerate * @param \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory * @param \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory * @param \Magento\App\Filesystem $filesystem @@ -151,7 +149,7 @@ class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb \Magento\Logger $logger, \Magento\App\ConfigInterface $coreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Shipping\Model\Carrier\Tablerate $carrierTablerate, + \Magento\OfflineShipping\Model\Carrier\Tablerate $carrierTablerate, \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory, \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory, \Magento\App\Filesystem $filesystem @@ -251,7 +249,7 @@ class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param \Magento\Object $object * @throws \Magento\Core\Exception - * @return \Magento\Shipping\Model\Resource\Carrier\Tablerate + * @return \Magento\OfflineShipping\Model\Resource\Carrier\Tablerate * @todo: this method should be refactored as soon as updated design will be provided * @see https://wiki.corp.x.com/display/MCOMS/Magento+Filesystem+Decisions */ @@ -347,7 +345,7 @@ class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Load directory countries * - * @return \Magento\Shipping\Model\Resource\Carrier\Tablerate + * @return \Magento\OfflineShipping\Model\Resource\Carrier\Tablerate */ protected function _loadDirectoryCountries() { @@ -371,7 +369,7 @@ class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Load directory regions * - * @return \Magento\Shipping\Model\Resource\Carrier\Tablerate + * @return \Magento\OfflineShipping\Model\Resource\Carrier\Tablerate */ protected function _loadDirectoryRegions() { @@ -493,7 +491,7 @@ class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb * Save import data batch * * @param array $data - * @return \Magento\Shipping\Model\Resource\Carrier\Tablerate + * @return \Magento\OfflineShipping\Model\Resource\Carrier\Tablerate */ protected function _saveImportData(array $data) { diff --git a/app/code/Magento/Shipping/Model/Resource/Carrier/Tablerate/Collection.php b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate/Collection.php similarity index 87% rename from app/code/Magento/Shipping/Model/Resource/Carrier/Tablerate/Collection.php rename to app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate/Collection.php index e6d15b552c6..ac2e74d5d1d 100644 --- a/app/code/Magento/Shipping/Model/Resource/Carrier/Tablerate/Collection.php +++ b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate/Collection.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Shipping * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Shipping\Model\Resource\Carrier\Tablerate; +namespace Magento\OfflineShipping\Model\Resource\Carrier\Tablerate; /** * Shipping table rates collection @@ -53,7 +51,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl */ protected function _construct() { - $this->_init('Magento\Shipping\Model\Carrier\Tablerate', 'Magento\Shipping\Model\Resource\Carrier\Tablerate'); + $this->_init('Magento\OfflineShipping\Model\Carrier\Tablerate', 'Magento\OfflineShipping\Model\Resource\Carrier\Tablerate'); $this->_countryTable = $this->getTable('directory_country'); $this->_regionTable = $this->getTable('directory_country_region'); } @@ -87,7 +85,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Add website filter to collection * * @param int $websiteId - * @return \Magento\Shipping\Model\Resource\Carrier\Tablerate\Collection + * @return \Magento\OfflineShipping\Model\Resource\Carrier\Tablerate\Collection */ public function setWebsiteFilter($websiteId) { @@ -98,7 +96,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Add condition name (code) filter to collection * * @param string $conditionName - * @return \Magento\Shipping\Model\Resource\Carrier\Tablerate\Collection + * @return \Magento\OfflineShipping\Model\Resource\Carrier\Tablerate\Collection */ public function setConditionFilter($conditionName) { @@ -109,7 +107,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Add country filter to collection * * @param string $countryId - * @return \Magento\Shipping\Model\Resource\Carrier\Tablerate\Collection + * @return \Magento\OfflineShipping\Model\Resource\Carrier\Tablerate\Collection */ public function setCountryFilter($countryId) { diff --git a/app/code/Magento/OfflineShipping/Model/SalesRule/Calculator.php b/app/code/Magento/OfflineShipping/Model/SalesRule/Calculator.php new file mode 100644 index 00000000000..ab26e3d0ce4 --- /dev/null +++ b/app/code/Magento/OfflineShipping/Model/SalesRule/Calculator.php @@ -0,0 +1,75 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + + +/** + * Shopping Cart Rule data model + * + * @category Magento + * @package Magento_OfflineShipping + * @author Magento Core Team <core@magentocommerce.com> + */ +namespace Magento\OfflineShipping\Model\SalesRule; + +class Calculator extends \Magento\SalesRule\Model\Validator +{ + /** + * Quote item free shipping ability check + * This process not affect information about applied rules, coupon code etc. + * This information will be added during discount amounts processing + * + * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item + * @return \Magento\OfflineShipping\Model\SalesRule\Calculator + */ + public function processFreeShipping(\Magento\Sales\Model\Quote\Item\AbstractItem $item) + { + $address = $item->getAddress(); + $item->setFreeShipping(false); + + foreach ($this->_getRules() as $rule) { + /* @var $rule \Magento\SalesRule\Model\Rule */ + if (!$this->_canProcessRule($rule, $address)) { + continue; + } + + if (!$rule->getActions()->validate($item)) { + continue; + } + + switch ($rule->getSimpleFreeShipping()) { + case \Magento\OfflineShipping\Model\SalesRule\Rule::FREE_SHIPPING_ITEM: + $item->setFreeShipping($rule->getDiscountQty() ? $rule->getDiscountQty() : true); + break; + + case \Magento\OfflineShipping\Model\SalesRule\Rule::FREE_SHIPPING_ADDRESS: + $address->setFreeShipping(true); + break; + } + if ($rule->getStopRulesProcessing()) { + break; + } + } + return $this; + } +} diff --git a/app/code/Magento/OfflineShipping/Model/SalesRule/Rule.php b/app/code/Magento/OfflineShipping/Model/SalesRule/Rule.php new file mode 100644 index 00000000000..2cd107a04f6 --- /dev/null +++ b/app/code/Magento/OfflineShipping/Model/SalesRule/Rule.php @@ -0,0 +1,45 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Shopping Cart Rule data model + * + * @category Magento + * @package Magento_OfflineShipping + * @author Magento Core Team <core@magentocommerce.com> + */ +namespace Magento\OfflineShipping\Model\SalesRule; + +class Rule +{ + /** + * Free Shipping option "For matching items only" + */ + const FREE_SHIPPING_ITEM = 1; + + /** + * Free Shipping option "For shipment with matching items" + */ + const FREE_SHIPPING_ADDRESS = 2; +} diff --git a/app/code/Magento/OfflineShipping/etc/adminhtml/events.xml b/app/code/Magento/OfflineShipping/etc/adminhtml/events.xml new file mode 100644 index 00000000000..84cb7247f83 --- /dev/null +++ b/app/code/Magento/OfflineShipping/etc/adminhtml/events.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <event name="adminhtml_block_salesrule_actions_prepareform"> + <observer name="offlineshipping_salesrule" instance="Magento\OfflineShipping\Model\Observer\SalesRule\ActionsTab" method="prepareForm" /> + </event> +</config> diff --git a/app/code/Magento/PageCache/etc/di.xml b/app/code/Magento/OfflineShipping/etc/adminhtml/routes.xml similarity index 84% rename from app/code/Magento/PageCache/etc/di.xml rename to app/code/Magento/OfflineShipping/etc/adminhtml/routes.xml index 6dba77137b4..5e90c6e986a 100644 --- a/app/code/Magento/PageCache/etc/di.xml +++ b/app/code/Magento/OfflineShipping/etc/adminhtml/routes.xml @@ -24,7 +24,9 @@ */ --> <config> - <type name="Magento\App\FrontControllerInterface"> - <plugin name="front-controller-head" type="Magento\PageCache\Model\App\FrontController\HeaderPlugin"/> - </type> + <router id="admin"> + <route id="adminhtml"> + <module name="Magento_OfflineShipping" before="Magento_Backend" /> + </route> + </router> </config> diff --git a/app/code/Magento/OfflineShipping/etc/adminhtml/system.xml b/app/code/Magento/OfflineShipping/etc/adminhtml/system.xml new file mode 100644 index 00000000000..1aee003d6ef --- /dev/null +++ b/app/code/Magento/OfflineShipping/etc/adminhtml/system.xml @@ -0,0 +1,174 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <system> + <section id="carriers" translate="label" type="text" sortOrder="320" showInDefault="1" showInWebsite="1" showInStore="1"> + <group id="flatrate" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Flat Rate</label> + <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="name" translate="label" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Method Name</label> + </field> + <field id="price" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Price</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="handling_type" translate="label" type="select" sortOrder="7" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Calculate Handling Fee</label> + <source_model>Magento\Shipping\Model\Source\HandlingType</source_model> + </field> + <field id="handling_fee" translate="label" type="text" sortOrder="8" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Handling Fee</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Sort Order</label> + </field> + <field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Title</label> + </field> + <field id="type" translate="label" type="select" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Type</label> + <source_model>Magento\OfflineShipping\Model\Config\Source\Flatrate</source_model> + </field> + <field id="sallowspecific" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ship to Applicable Countries</label> + <frontend_class>shipping-applicable-country</frontend_class> + <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> + </field> + <field id="specificcountry" translate="label" type="multiselect" sortOrder="91" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ship to Specific Countries</label> + <source_model>Magento\Directory\Model\Config\Source\Country</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="showmethod" translate="label" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Show Method if Not Applicable</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="specificerrmsg" translate="label" type="textarea" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Displayed Error Message</label> + </field> + </group> + <group id="tablerate" translate="label" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Table Rates</label> + <field id="handling_type" translate="label" type="select" sortOrder="7" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Calculate Handling Fee</label> + <source_model>Magento\Shipping\Model\Source\HandlingType</source_model> + </field> + <field id="handling_fee" translate="label" type="text" sortOrder="8" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Handling Fee</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="condition_name" translate="label" type="select" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Condition</label> + <source_model>Magento\OfflineShipping\Model\Config\Source\Tablerate</source_model> + </field> + <field id="include_virtual_price" translate="label" type="select" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Include Virtual Products in Price Calculation</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="export" translate="label" type="Magento\OfflineShipping\Block\Adminhtml\Form\Field\Export" sortOrder="5" showInDefault="0" showInWebsite="1" showInStore="0"> + <label>Export</label> + </field> + <field id="import" translate="label" type="Magento\OfflineShipping\Block\Adminhtml\Form\Field\Import" sortOrder="6" showInDefault="0" showInWebsite="1" showInStore="0"> + <label>Import</label> + <backend_model>Magento\OfflineShipping\Model\Config\Backend\Tablerate</backend_model> + </field> + <field id="name" translate="label" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Method Name</label> + </field> + <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Sort Order</label> + </field> + <field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Title</label> + </field> + <field id="sallowspecific" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ship to Applicable Countries</label> + <frontend_class>shipping-applicable-country</frontend_class> + <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> + </field> + <field id="specificcountry" translate="label" type="multiselect" sortOrder="91" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ship to Specific Countries</label> + <source_model>Magento\Directory\Model\Config\Source\Country</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="showmethod" translate="label" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Show Method if Not Applicable</label> + <frontend_class>shipping-skip-hide</frontend_class> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="specificerrmsg" translate="label" type="textarea" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Displayed Error Message</label> + </field> + </group> + <group id="freeshipping" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Free Shipping</label> + <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="free_shipping_subtotal" translate="label" type="text" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Minimum Order Amount</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="name" translate="label" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Method Name</label> + </field> + <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Sort Order</label> + </field> + <field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Title</label> + </field> + <field id="sallowspecific" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ship to Applicable Countries</label> + <frontend_class>shipping-applicable-country</frontend_class> + <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> + </field> + <field id="specificcountry" translate="label" type="multiselect" sortOrder="91" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ship to Specific Countries</label> + <source_model>Magento\Directory\Model\Config\Source\Country</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="showmethod" translate="label" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Show Method if Not Applicable</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="specificerrmsg" translate="label" type="textarea" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Displayed Error Message</label> + </field> + </group> + </section> + </system> +</config> diff --git a/app/code/Magento/OfflineShipping/etc/config.xml b/app/code/Magento/OfflineShipping/etc/config.xml new file mode 100644 index 00000000000..1f043f73329 --- /dev/null +++ b/app/code/Magento/OfflineShipping/etc/config.xml @@ -0,0 +1,62 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <default> + <carriers> + <flatrate> + <active>0</active> + <sallowspecific>0</sallowspecific> + <model>Magento\OfflineShipping\Model\Carrier\Flatrate</model> + <name>Fixed</name> + <price>5.00</price> + <title>Flat Rate</title> + <type>I</type> + <specificerrmsg>This shipping method is not available. To use this shipping method, please contact us.</specificerrmsg> + <handling_type>F</handling_type> + </flatrate> + <tablerate> + <active>0</active> + <sallowspecific>0</sallowspecific> + <condition_name>package_weight</condition_name> + <include_virtual_price>1</include_virtual_price> + <model>Magento\OfflineShipping\Model\Carrier\Tablerate</model> + <name>Table Rate</name> + <title>Best Way</title> + <specificerrmsg>This shipping method is not available. To use this shipping method, please contact us.</specificerrmsg> + <handling_type>F</handling_type> + </tablerate> + <freeshipping> + <active>0</active> + <sallowspecific>0</sallowspecific> + <cutoff_cost>50</cutoff_cost> + <model>Magento\OfflineShipping\Model\Carrier\Freeshipping</model> + <name>Free</name> + <title>Free Shipping</title> + <specificerrmsg>This shipping method is not available. To use this shipping method, please contact us.</specificerrmsg> + </freeshipping> + </carriers> + </default> +</config> diff --git a/app/code/Magento/Usa/etc/di.xml b/app/code/Magento/OfflineShipping/etc/di.xml similarity index 79% rename from app/code/Magento/Usa/etc/di.xml rename to app/code/Magento/OfflineShipping/etc/di.xml index f341e4f61a5..6400cdb6718 100644 --- a/app/code/Magento/Usa/etc/di.xml +++ b/app/code/Magento/OfflineShipping/etc/di.xml @@ -27,8 +27,11 @@ <type name="Magento\Module\Updater\SetupFactory"> <arguments> <argument name="resourceTypes" xsi:type="array"> - <item name="usa_setup" xsi:type="string">Magento\Usa\Model\Resource\Setup</item> + <item name="offlineshipping_setup" xsi:type="string">Magento\Core\Model\Resource\Setup</item> </argument> </arguments> </type> + <type name="Magento\Checkout\Block\Cart\Shipping"> + <plugin name="checkout_cart_shipping_plugin" type="Magento\OfflineShipping\Model\Plugin\Checkout\Block\Cart\Shipping"/> + </type> </config> diff --git a/app/code/Magento/OfflineShipping/etc/fieldset.xml b/app/code/Magento/OfflineShipping/etc/fieldset.xml new file mode 100644 index 00000000000..fa316095f3f --- /dev/null +++ b/app/code/Magento/OfflineShipping/etc/fieldset.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../lib/Magento/Object/etc/fieldset.xsd"> + <scope id="global"> + <fieldset id="sales_convert_quote_item"> + <field name="free_shipping"> + <aspect name="to_order_item" /> + </field> + </fieldset> + <fieldset id="sales_convert_order_item"> + <field name="free_shipping"> + <aspect name="to_quote_item" /> + </field> + </fieldset> + </scope> +</config> diff --git a/app/code/Magento/OfflineShipping/etc/module.xml b/app/code/Magento/OfflineShipping/etc/module.xml new file mode 100644 index 00000000000..08a9f96c787 --- /dev/null +++ b/app/code/Magento/OfflineShipping/etc/module.xml @@ -0,0 +1,44 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <module name="Magento_OfflineShipping" version="2.0.0.0" active="true"> + <sequence> + <module name="Magento_Core"/> + <module name="Magento_Sales"/> + <module name="Magento_SalesRule"/> + </sequence> + <depends> + <module name="Magento_Core"/> + <module name="Magento_Backend"/> + <module name="Magento_Shipping"/> + <module name="Magento_Catalog"/> + <module name="Magento_Sales"/> + <module name="Magento_SalesRule"/> + <module name="Magento_Directory"/> + <module name="Magento_Checkout"/> + </depends> + </module> +</config> diff --git a/app/code/Magento/OfflineShipping/etc/sales.xml b/app/code/Magento/OfflineShipping/etc/sales.xml new file mode 100644 index 00000000000..d705846c2c5 --- /dev/null +++ b/app/code/Magento/OfflineShipping/etc/sales.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <section name="quote"> + <group name="totals"> + <item name="freeshipping" instance="Magento\OfflineShipping\Model\Quote\Freeshipping" sort_order="150"/> + </group> + </section> +</config> diff --git a/app/code/Magento/Shipping/sql/shipping_setup/install-1.6.0.0.php b/app/code/Magento/OfflineShipping/sql/offlineshipping_setup/install-2.0.0.0.php similarity index 65% rename from app/code/Magento/Shipping/sql/shipping_setup/install-1.6.0.0.php rename to app/code/Magento/OfflineShipping/sql/offlineshipping_setup/install-2.0.0.0.php index 4197c46f9fd..c3b4cbbe911 100644 --- a/app/code/Magento/Shipping/sql/shipping_setup/install-1.6.0.0.php +++ b/app/code/Magento/OfflineShipping/sql/offlineshipping_setup/install-2.0.0.0.php @@ -18,14 +18,12 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Shipping * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -$installer = $this; /** @var $installer \Magento\Core\Model\Resource\Setup */ +$installer = $this; $installer->startSetup(); @@ -39,41 +37,70 @@ $table = $installer->getConnection() 'unsigned' => true, 'nullable' => false, 'primary' => true, - ), 'Primary key') + ), 'Primary key') ->addColumn('website_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array( 'nullable' => false, 'default' => '0', - ), 'Website Id') + ), 'Website Id') ->addColumn('dest_country_id', \Magento\DB\Ddl\Table::TYPE_TEXT, 4, array( 'nullable' => false, 'default' => '0', - ), 'Destination coutry ISO/2 or ISO/3 code') + ), 'Destination coutry ISO/2 or ISO/3 code') ->addColumn('dest_region_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array( 'nullable' => false, 'default' => '0', - ), 'Destination Region Id') + ), 'Destination Region Id') ->addColumn('dest_zip', \Magento\DB\Ddl\Table::TYPE_TEXT, 10, array( 'nullable' => false, 'default' => '*', - ), 'Destination Post Code (Zip)') + ), 'Destination Post Code (Zip)') ->addColumn('condition_name', \Magento\DB\Ddl\Table::TYPE_TEXT, 20, array( 'nullable' => false, - ), 'Rate Condition name') + ), 'Rate Condition name') ->addColumn('condition_value', \Magento\DB\Ddl\Table::TYPE_DECIMAL, '12,4', array( 'nullable' => false, 'default' => '0.0000', - ), 'Rate condition value') + ), 'Rate condition value') ->addColumn('price', \Magento\DB\Ddl\Table::TYPE_DECIMAL, '12,4', array( 'nullable' => false, 'default' => '0.0000', - ), 'Price') + ), 'Price') ->addColumn('cost', \Magento\DB\Ddl\Table::TYPE_DECIMAL, '12,4', array( 'nullable' => false, 'default' => '0.0000', - ), 'Cost') + ), 'Cost') ->addIndex($installer->getIdxName('shipping_tablerate', array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip', 'condition_name', 'condition_value'), \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE), array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip', 'condition_name', 'condition_value'), array('type' => \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE)) ->setComment('Shipping Tablerate'); $installer->getConnection()->createTable($table); +$installer->getConnection() + ->addColumn($installer->getTable('salesrule'), 'simple_free_shipping', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + ), 'Simple Free Shipping'); +$installer->getConnection() + ->addColumn($installer->getTable('sales_flat_order_item'), 'free_shipping', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + ), 'Free Shipping'); +$installer->getConnection() + ->addColumn($installer->getTable('sales_flat_quote_address'), 'free_shipping', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + ), 'Free Shipping'); +$installer->getConnection() + ->addColumn($installer->getTable('sales_flat_quote_item'), 'free_shipping', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + ), 'Free Shipping'); +$installer->getConnection() + ->addColumn($installer->getTable('sales_flat_quote_address_item'), 'free_shipping', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array( + 'unsigned' => true, + ), 'Free Shipping'); + $installer->endSetup(); diff --git a/app/code/Magento/Ogone/Model/Api.php b/app/code/Magento/Ogone/Model/Api.php index a043d7d48ca..ac5fdde3a9a 100644 --- a/app/code/Magento/Ogone/Model/Api.php +++ b/app/code/Magento/Ogone/Model/Api.php @@ -215,9 +215,9 @@ class Api extends \Magento\Payment\Model\Method\AbstractMethod protected $_storeManager; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ResolverInterface */ - protected $_locale; + protected $_localeResolver; /** * @param \Magento\Event\ManagerInterface $eventManager @@ -225,7 +225,7 @@ class Api extends \Magento\Payment\Model\Method\AbstractMethod * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\UrlInterface $urlBuilder * @param \Magento\Stdlib\String $string * @param \Magento\Ogone\Model\Config $config @@ -237,14 +237,14 @@ class Api extends \Magento\Payment\Model\Method\AbstractMethod \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Logger\AdapterFactory $logAdapterFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\UrlInterface $urlBuilder, \Magento\Stdlib\String $string, \Magento\Ogone\Model\Config $config, array $data = array() ) { $this->_storeManager = $storeManager; - $this->_locale = $locale; + $this->_localeResolver = $localeResolver; $this->_urlBuilder = $urlBuilder; $this->string = $string; $this->_config = $config; @@ -311,7 +311,7 @@ class Api extends \Magento\Payment\Model\Method\AbstractMethod $formFields['orderID'] = $order->getIncrementId(); $formFields['amount'] = round($order->getBaseGrandTotal()*100); $formFields['currency'] = $this->_storeManager->getStore()->getBaseCurrencyCode(); - $formFields['language'] = $this->_locale->getLocaleCode(); + $formFields['language'] = $this->_localeResolver->getLocaleCode(); $formFields['CN'] = $this->_translate($billingAddress->getFirstname().' '.$billingAddress->getLastname()); $formFields['EMAIL'] = $order->getCustomerEmail(); diff --git a/app/code/Magento/Ogone/Model/Config.php b/app/code/Magento/Ogone/Model/Config.php index 84a1eb5b5bc..1eca365edb1 100644 --- a/app/code/Magento/Ogone/Model/Config.php +++ b/app/code/Magento/Ogone/Model/Config.php @@ -46,7 +46,7 @@ class Config extends \Magento\Payment\Model\Config * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Payment\Model\Method\Factory $paymentMethodFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ListsInterface $localeLists * @param \Magento\Config\DataInterface $dataStorage * @param \Magento\UrlInterface $urlBuilder * @param \Magento\Encryption\EncryptorInterface $encryptor @@ -55,12 +55,12 @@ class Config extends \Magento\Payment\Model\Config \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\App\ConfigInterface $coreConfig, \Magento\Payment\Model\Method\Factory $paymentMethodFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ListsInterface $localeLists, \Magento\Config\DataInterface $dataStorage, \Magento\UrlInterface $urlBuilder, \Magento\Encryption\EncryptorInterface $encryptor ) { - parent::__construct($coreStoreConfig, $coreConfig, $paymentMethodFactory, $locale, $dataStorage); + parent::__construct($coreStoreConfig, $coreConfig, $paymentMethodFactory, $localeLists, $dataStorage); $this->_urlBuilder = $urlBuilder; $this->_encryptor = $encryptor; } diff --git a/app/code/Magento/PageCache/Block/Javascript.php b/app/code/Magento/PageCache/Block/Javascript.php index 1472c169e93..a095341f0f8 100644 --- a/app/code/Magento/PageCache/Block/Javascript.php +++ b/app/code/Magento/PageCache/Block/Javascript.php @@ -32,6 +32,28 @@ namespace Magento\PageCache\Block; */ class Javascript extends \Magento\View\Element\Template { + /** + * @var \Magento\PageCache\Helper\Data + */ + protected $helper; + + /** + * Constructor + * + * @param \Magento\View\Element\Template\Context $context + * @param \Magento\PageCache\Helper\Data $helper + * @param array $data + */ + public function __construct( + \Magento\View\Element\Template\Context $context, + \Magento\PageCache\Helper\Data $helper, + array $data = array() + ) { + $this->helper = $helper; + parent::__construct($context, $data); + } + + /** * Retrieve script options encoded to json * @@ -41,8 +63,8 @@ class Javascript extends \Magento\View\Element\Template { $params = array( 'url' => $this->getUrl('page_cache/block/render/'), - 'handles' => $this->getLayout()->getUpdate()->getHandles(), - 'versionCookieName' => \Magento\PageCache\Model\Version::COOKIE_NAME + 'handles' => $this->helper->getActualHandles(), + 'versionCookieName' => \Magento\App\PageCache\Version::COOKIE_NAME ); return json_encode($params); } diff --git a/app/code/Magento/PageCache/Controller/Block.php b/app/code/Magento/PageCache/Controller/Block.php index 0e06632dedb..08ef6263973 100644 --- a/app/code/Magento/PageCache/Controller/Block.php +++ b/app/code/Magento/PageCache/Controller/Block.php @@ -25,8 +25,6 @@ */ namespace Magento\PageCache\Controller; -use Magento\PageCache\Helper\Data; - class Block extends \Magento\App\Action\Action { /** @@ -40,12 +38,53 @@ class Block extends \Magento\App\Action\Action $this->_forward('noroute'); return; } - $blocks = $this->getRequest()->getParam('blocks', array()); - $handles = $this->getRequest()->getParam('handles', array()); + + $blocks = $this->_getBlocks(); + $data = []; + foreach ($blocks as $blockName => $blockInstance) { + $data[$blockName] = $blockInstance->toHtml(); + } + + $this->getResponse()->setPrivateHeaders(\Magento\PageCache\Helper\Data::PRIVATE_MAX_AGE_CACHE); + $this->getResponse()->appendBody(json_encode($data)); + } + + /** + * Returns block content as part of ESI request from Varnish + */ + public function esiAction() + { + $response = $this->getResponse(); + $blocks = $this->_getBlocks(); + $html = ''; + $ttl = 0; + + if (!empty($blocks)){ + $blockInstance = array_shift($blocks); + $html = $blockInstance->toHtml(); + $ttl = $blockInstance->getTtl(); + } + + $response->appendBody($html); + $response->setPublicHeaders($ttl); + } + + /** + * Get blocks from layout by handles + * + * @return array [\Element\BlockInterface] + */ + protected function _getBlocks() + { + $blocks = $this->getRequest()->getParam('blocks', ''); + $handles = $this->getRequest()->getParam('handles', ''); if (!$handles || !$blocks) { - return; + return []; } + $blocks = json_decode($blocks); + $handles = json_decode($handles); + $this->_view->loadLayout($handles); $data = array(); @@ -53,12 +92,10 @@ class Block extends \Magento\App\Action\Action foreach ($blocks as $blockName) { $blockInstance = $layout->getBlock($blockName); if (is_object($blockInstance)) { - $data[$blockName] = $blockInstance->toHtml(); + $data[$blockName] = $blockInstance; } } - $layout->setIsPrivate(); - - $this->getResponse()->appendBody(json_encode($data)); + return $data; } } diff --git a/app/code/Magento/PageCache/Helper/Data.php b/app/code/Magento/PageCache/Helper/Data.php index 77d610b6f3b..05b5882cb55 100644 --- a/app/code/Magento/PageCache/Helper/Data.php +++ b/app/code/Magento/PageCache/Helper/Data.php @@ -29,18 +29,57 @@ * * @category Magento * @package Magento_PageCache - * @author Magento Core Team <core@magentocommerce.com> */ namespace Magento\PageCache\Helper; /** - * Class Data - * @package Magento\PageCache\Helper + * Helper for Page Cache module */ class Data extends \Magento\App\Helper\AbstractHelper { + /** + * Constructor + * + * @param \Magento\Theme\Model\Layout\Config $config + * @param \Magento\App\View $view + */ + public function __construct( + \Magento\Theme\Model\Layout\Config $config, + \Magento\App\View $view + ) { + $this->view = $view; + $this->config = $config; + } + /** * Private caching time one year */ const PRIVATE_MAX_AGE_CACHE = 31536000; + + /** + * Retrieve url + * + * @param string $route + * @param array $params + * @return string + */ + public function getUrl($route, array $params = array()) + { + return $this->_getUrl($route, $params); + } + + /** + * Get handles applied for current page + * + * @return array + */ + public function getActualHandles() + { + $handlesPage = $this->view->getLayout()->getUpdate()->getHandles(); + $handlesConfig = $this->config->getPageLayoutHandles(); + $appliedHandles = array_intersect($handlesPage, $handlesConfig); + $resultHandles = array_merge(['default'], array_values($appliedHandles)); + + return $resultHandles; + } } diff --git a/app/code/Magento/PageCache/Model/App/FrontController/CachePlugin.php b/app/code/Magento/PageCache/Model/App/FrontController/CachePlugin.php new file mode 100644 index 00000000000..9fc36f7c937 --- /dev/null +++ b/app/code/Magento/PageCache/Model/App/FrontController/CachePlugin.php @@ -0,0 +1,84 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\PageCache\Model\App\FrontController; + +/** + * Plugin for processing builtin cache + */ +class CachePlugin +{ + /** + * @var \Magento\App\ConfigInterface + */ + protected $config; + + /** + * @var \Magento\App\PageCache\Version + */ + protected $version; + + /** + * @var \Magento\App\PageCache\Kernel + */ + protected $kernel; + + /** + * @param \Magento\PageCache\Model\Config $config + * @param \Magento\App\PageCache\Version $version + * @param \Magento\App\PageCache\Kernel $kernel + */ + public function __construct( + \Magento\PageCache\Model\Config $config, + \Magento\App\PageCache\Version $version, + \Magento\App\PageCache\Kernel $kernel + ) { + $this->config = $config; + $this->version = $version; + $this->kernel = $kernel; + } + + /** + * @param \Magento\App\FrontControllerInterface $subject + * @param \Closure $proceed + * @param \Magento\App\RequestInterface $request + * @return false|\Magento\App\Response\Http + */ + public function aroundDispatch( + \Magento\App\FrontControllerInterface $subject, + \Closure $proceed, + \Magento\App\RequestInterface $request + ) { + $this->version->process(); + if ($this->config->getType() == \Magento\PageCache\Model\Config::BUILT_IN) { + $response = $this->kernel->load(); + if ($response === false) { + $response = $proceed($request); + $this->kernel->process($response); + } + } else { + $response = $proceed($request); + } + return $response; + } +} diff --git a/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php b/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php deleted file mode 100644 index 99dc23b1fba..00000000000 --- a/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\PageCache\Model\App\FrontController; - -use Magento\PageCache\Helper\Data; - -/** - * Class HeadPlugin - */ -class HeaderPlugin -{ - /** - * @var \Magento\Core\Model\Layout - */ - protected $layout; - - /** - * @var \Magento\App\ConfigInterface - */ - protected $config; - - /** - * @var \Magento\PageCache\Model\Version - */ - protected $version; - - /** - * Constructor - * - * @param \Magento\Core\Model\Layout $layout - * @param \Magento\App\ConfigInterface $config - * @param \Magento\PageCache\Model\Version $version - */ - public function __construct( - \Magento\Core\Model\Layout $layout, - \Magento\App\ConfigInterface $config, - \Magento\PageCache\Model\Version $version - ) { - $this->layout = $layout; - $this->config = $config; - $this->version = $version; - } - - /** - * Modify response after dispatch - * - * @param \Magento\App\Response\Http $response - * @return \Magento\App\Response\Http - */ - public function afterDispatch(\Magento\App\Response\Http $response) - { - if ($this->layout->isPrivate()) { - $this->setPrivateHeaders($response); - return $response; - } - if ($this->layout->isCacheable()) { - $this->setPublicHeaders($response); - } else { - $this->setNocacheHeaders($response); - } - $this->version->process(); - return $response; - } - - /** - * @param \Magento\App\Response\Http $response - */ - protected function setPublicHeaders(\Magento\App\Response\Http $response) - { - $maxAge = $this->config->getValue(\Magento\PageCache\Model\Config::XML_PAGECACHE_TTL); - $response->setHeader('pragma', 'cache', true); - $response->setHeader('cache-control', 'public, max-age=' . $maxAge . ', s-maxage=' . $maxAge, true); - $response->setHeader('expires', gmdate('D, d M Y H:i:s T', strtotime('+' . $maxAge . ' seconds')), true); - } - - /** - * @param \Magento\App\Response\Http $response - */ - protected function setNocacheHeaders(\Magento\App\Response\Http $response) - { - $response->setHeader('pragma', 'no-cache', true); - $response->setHeader('cache-control', 'no-store, no-cache, must-revalidate, max-age=0', true); - $response->setHeader('expires', gmdate('D, d M Y H:i:s T', strtotime('-1 year')), true); - } - - /** - * Set header parameters for private cache - * - * @param \Magento\App\Response\Http $response - */ - protected function setPrivateHeaders(\Magento\App\Response\Http $response) - { - $maxAge = Data::PRIVATE_MAX_AGE_CACHE; - $response->setHeader('pragma', 'cache', true); - $response->setHeader('cache-control', 'private, max-age=' . $maxAge, true); - $response->setHeader('expires', gmdate('D, d M Y H:i:s T', strtotime('+' . $maxAge . ' seconds')), true); - } -} diff --git a/app/code/Magento/PageCache/Model/Config.php b/app/code/Magento/PageCache/Model/Config.php index 47a065085b4..a10e371460c 100644 --- a/app/code/Magento/PageCache/Model/Config.php +++ b/app/code/Magento/PageCache/Model/Config.php @@ -44,10 +44,18 @@ use Magento\App\Filesystem; */ class Config { + /**#@+ + * Cache types + */ + const BUILT_IN = 0; + const VARNISH = 1; + /**#@-*/ + /**#@+ * XML path to Varnish settings */ const XML_PAGECACHE_TTL = 'system/full_page_cache/ttl'; + const XML_PAGECACHE_TYPE = 'system/full_page_cache/caching_application'; const XML_VARNISH_PAGECACHE_ACCESS_LIST = 'system/full_page_cache/varnish/access_list'; const XML_VARNISH_PAGECACHE_BACKEND_PORT = 'system/full_page_cache/varnish/backend_port'; const XML_VARNISH_PAGECACHE_BACKEND_HOST = 'system/full_page_cache/varnish/backend_host'; @@ -84,6 +92,16 @@ class Config $this->_config = $config; } + /** + * Return currently selected cache type: built in or varnish + * + * @return int + */ + public function getType() + { + return $this->_config->getValue(self::XML_PAGECACHE_TYPE); + } + /** * Return generated varnish.vcl configuration file * diff --git a/app/code/Magento/PageCache/Model/Layout/LayoutPlugin.php b/app/code/Magento/PageCache/Model/Layout/LayoutPlugin.php new file mode 100644 index 00000000000..caa123bb33b --- /dev/null +++ b/app/code/Magento/PageCache/Model/Layout/LayoutPlugin.php @@ -0,0 +1,102 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\PageCache\Model\Layout; +use Magento\TestFramework\Inspection\Exception; + +/** + * Class LayoutPlugin + */ +class LayoutPlugin +{ + /** + * @var \Magento\Core\Model\Layout + */ + protected $layout; + + /** + * @var \Magento\App\ConfigInterface + */ + protected $config; + + /** + * @var \Magento\App\ResponseInterface + */ + protected $response; + + /** + * Constructor + * + * @param \Magento\Core\Model\Layout $layout + * @param \Magento\App\ResponseInterface $response + * @param \Magento\App\ConfigInterface $config + */ + public function __construct( + \Magento\Core\Model\Layout $layout, + \Magento\App\ResponseInterface $response, + \Magento\App\ConfigInterface $config + ) { + $this->layout = $layout; + $this->response = $response; + $this->config = $config; + } + + /** + * Set appropriate Cache-Control headers + * We have to set public headers in order to tell Varnish and Builtin app that page should be cached + * + * @param \Magento\Core\Model\Layout $subject + * @param $result + * @return mixed + */ + public function afterGenerateXml(\Magento\Core\Model\Layout $subject, $result) + { + if ($this->layout->isCacheable()) { + $maxAge = $this->config->getValue(\Magento\PageCache\Model\Config::XML_PAGECACHE_TTL); + $this->response->setPublicHeaders($maxAge); + } + return $result; + } + + /** + * Retrieve all identities from blocks for further cache invalidation + * + * @param \Magento\Core\Model\Layout $subject + * @param $result + * @return mixed + */ + public function afterGetOutput(\Magento\Core\Model\Layout $subject, $result) + { + if ($this->layout->isCacheable()) { + $tags = array(); + foreach($this->layout->getAllBlocks() as $block) { + if ($block instanceof \Magento\View\Block\IdentityInterface) { + $tags = array_merge($tags, $block->getIdentities()); + } + } + $tags = array_unique($tags); + $this->response->setHeader('X-Magento-Tags', implode(',', $tags)); + } + return $result; + } +} diff --git a/app/code/Magento/PageCache/Model/Observer.php b/app/code/Magento/PageCache/Model/Observer.php index f4c13b1d53c..4178cb8efe1 100644 --- a/app/code/Magento/PageCache/Model/Observer.php +++ b/app/code/Magento/PageCache/Model/Observer.php @@ -28,10 +28,43 @@ namespace Magento\PageCache\Model; /** * Class Observer - * @package Magento\PageCache\Model */ class Observer { + /** + * Application config object + * + * @var \Magento\PageCache\Model\Config + */ + protected $_config; + + /** + * @var \Magento\App\PageCache\Cache + */ + protected $_cache; + + /** + * @var \Magento\PageCache\Helper\Data + */ + protected $_helper; + + /** + * Constructor + * + * @param \Magento\PageCache\Model\Config $config + * @param \Magento\App\PageCache\Cache $cache + * @param \Magento\PageCache\Helper\Data $helper + */ + public function __construct( + \Magento\PageCache\Model\Config $config, + \Magento\App\PageCache\Cache $cache, + \Magento\PageCache\Helper\Data $helper + ){ + $this->_config = $config; + $this->_cache = $cache; + $this->_helper = $helper; + } + /** * Add comment cache containers to private blocks * Blocks are wrapped only if page is cacheable @@ -41,17 +74,75 @@ class Observer */ public function processLayoutRenderElement(\Magento\Event\Observer $observer) { + $event = $observer->getEvent(); /** @var \Magento\Core\Model\Layout $layout */ - $layout = $observer->getEvent()->getLayout(); + $layout = $event->getLayout(); if ($layout->isCacheable()) { - $name = $observer->getEvent()->getElementName(); + $name = $event->getElementName(); $block = $layout->getBlock($name); - if ($block instanceof \Magento\View\Element\AbstractBlock && $block->isScopePrivate()) { - $transport = $observer->getEvent()->getTransport(); + $transport = $event->getTransport(); + if ($block instanceof \Magento\View\Element\AbstractBlock) { + $blockTtl = $block->getTtl(); + $varnishIsEnabledFlag = $this->_config->getType() == \Magento\PageCache\Model\Config::VARNISH; $output = $transport->getData('output'); - $html = sprintf('<!-- BLOCK %1$s -->%2$s<!-- /BLOCK %1$s -->', $block->getNameInLayout(), $output); - $transport->setData('output', $html); + if ($varnishIsEnabledFlag && isset($blockTtl)) { + $output = $this->_wrapEsi($block); + } elseif ($block->isScopePrivate()) { + $output = sprintf( + '<!-- BLOCK %1$s -->%2$s<!-- /BLOCK %1$s -->', + $block->getNameInLayout(), + $output + ); + } + $transport->setData('output', $output); } } } + + /** + * Replace the output of the block, containing ttl attribute, with ESI tag + * + * @param \Magento\View\Element\AbstractBlock $block + * @return string + */ + protected function _wrapEsi( + \Magento\View\Element\AbstractBlock $block + ) { + $url = $block->getUrl( + 'page_cache/block/esi', + [ + 'blocks' => json_encode([$block->getNameInLayout()]), + 'handles' => json_encode($this->_helper->getActualHandles()) + ] + ); + return sprintf('<esi:include src="%s" />', $url); + } + + /** + * If Built-In caching is enabled it collects array of tags + * of incoming object and asks to clean cache. + * + * @param \Magento\Event\Observer $observer + */ + public function invalidateCache(\Magento\Event\Observer $observer) + { + $object = $observer->getEvent()->getObject(); + if($object instanceof \Magento\Object\IdentityInterface) { + if($this->_config->getType() == \Magento\PageCache\Model\Config::BUILT_IN) { + $this->_cache->clean($object->getIdentities()); + } + } + } + + /** + * Flash Built-In cache + * + * @param \Magento\Event\Observer $observer + */ + public function flushAllCache(\Magento\Event\Observer $observer) + { + if($this->_config->getType() == \Magento\PageCache\Model\Config::BUILT_IN) { + $this->_cache->clean(); + } + } } diff --git a/app/code/Magento/PageCache/Model/System/Config/Source/Application.php b/app/code/Magento/PageCache/Model/System/Config/Source/Application.php index a0b015305af..dc1abdc90a2 100644 --- a/app/code/Magento/PageCache/Model/System/Config/Source/Application.php +++ b/app/code/Magento/PageCache/Model/System/Config/Source/Application.php @@ -44,8 +44,8 @@ class Application implements \Magento\Option\ArrayInterface public function toOptionArray() { return array( - array('value' => 0, 'label'=>__('Built-in Application')), - array('value' => 1, 'label'=>__('Varnish Caching')), + array('value' => \Magento\PageCache\Model\Config::BUILT_IN, 'label'=>__('Built-in Application')), + array('value' => \Magento\PageCache\Model\Config::VARNISH, 'label'=>__('Varnish Caching')), ); } @@ -57,8 +57,8 @@ class Application implements \Magento\Option\ArrayInterface public function toArray() { return array( - 0 => __('Built-in Application'), - 1 => __('Varnish Caching'), + \Magento\PageCache\Model\Config::BUILT_IN => __('Built-in Application'), + \Magento\PageCache\Model\Config::VARNISH => __('Varnish Caching'), ); } } diff --git a/app/code/Magento/PageCache/etc/config.xml b/app/code/Magento/PageCache/etc/config.xml index a0523c924f0..a77ec04e0dc 100644 --- a/app/code/Magento/PageCache/etc/config.xml +++ b/app/code/Magento/PageCache/etc/config.xml @@ -28,13 +28,11 @@ <config> <default> <system> - <headers> - <public-max-age>0</public-max-age> - </headers> <full_page_cache> <varnish> <path>Magento/PageCache/etc/varnish.vcl</path> </varnish> + <ttl>120</ttl> <default> <access_list>localhost</access_list> <backend_host>localhost</backend_host> diff --git a/app/code/Magento/PageCache/etc/events.xml b/app/code/Magento/PageCache/etc/events.xml index 2de56ec9f5f..efe5a82b9e6 100644 --- a/app/code/Magento/PageCache/etc/events.xml +++ b/app/code/Magento/PageCache/etc/events.xml @@ -27,4 +27,10 @@ <event name="core_layout_render_element"> <observer name="pagecache" instance="Magento\PageCache\Model\Observer" method="processLayoutRenderElement" /> </event> + <event name="clean_cache_by_tags"> + <observer name="invalidate_builtin" instance="Magento\PageCache\Model\Observer" method="invalidateCache" /> + </event> + <event name="adminhtml_cache_flush_system"> + <observer name="flush_all_pagecache" instance="Magento\PageCache\Model\Observer" method="flushAllCache" /> + </event> </config> diff --git a/app/code/Magento/PageCache/etc/frontend/di.xml b/app/code/Magento/PageCache/etc/frontend/di.xml new file mode 100644 index 00000000000..dd020b423ff --- /dev/null +++ b/app/code/Magento/PageCache/etc/frontend/di.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <type name="Magento\App\FrontControllerInterface"> + <plugin name="front-controller-cache" type="Magento\PageCache\Model\App\FrontController\CachePlugin"/> + </type> + <type name="Magento\Core\Model\Layout"> + <plugin name="layout-model-caching-unique-name" type="Magento\PageCache\Model\Layout\LayoutPlugin"/> + </type> +</config> diff --git a/app/code/Magento/PageCache/view/frontend/js/page-cache.js b/app/code/Magento/PageCache/view/frontend/js/page-cache.js index a6a2b0ce9b7..164916b0ba1 100644 --- a/app/code/Magento/PageCache/view/frontend/js/page-cache.js +++ b/app/code/Magento/PageCache/view/frontend/js/page-cache.js @@ -106,8 +106,8 @@ for (var i = 0; i < placeholders.length; i++) { data.blocks.push(placeholders[i].name); } - data.blocks.sort(); - data.handles.sort(); + data.blocks = JSON.stringify(data.blocks.sort()); + data.handles = JSON.stringify(data.handles); $.ajax({ url: this.options.url, data: data, diff --git a/app/code/Magento/Payment/Block/Form.php b/app/code/Magento/Payment/Block/Form.php index e5072b40920..f1e3cb155c9 100644 --- a/app/code/Magento/Payment/Block/Form.php +++ b/app/code/Magento/Payment/Block/Form.php @@ -33,14 +33,14 @@ class Form extends \Magento\View\Element\Template /** * Retrieve payment method model * - * @return \Magento\Payment\Model\Method\AbstractMethod + * @return \Magento\Payment\Model\MethodInterface * @throws \Magento\Core\Exception */ public function getMethod() { $method = $this->getData('method'); - if (!($method instanceof \Magento\Payment\Model\Method\AbstractMethod)) { + if (!($method instanceof \Magento\Payment\Model\MethodInterface)) { throw new \Magento\Core\Exception(__('We cannot retrieve the payment method model object.')); } return $method; diff --git a/app/code/Magento/Payment/Block/Form/Container.php b/app/code/Magento/Payment/Block/Form/Container.php index ae1ff93ed96..0b9ba4959f7 100644 --- a/app/code/Magento/Payment/Block/Form/Container.php +++ b/app/code/Magento/Payment/Block/Form/Container.php @@ -79,7 +79,7 @@ class Container extends \Magento\View\Element\Template /** * Check payment method model * - * @param AbstractMethod $method + * @param \Magento\Payment\Model\MethodInterface $method * @return bool */ protected function _canUseMethod($method) @@ -95,7 +95,7 @@ class Container extends \Magento\View\Element\Template * * Redeclare this method in child classes for declaring method info instance * - * @param AbstractMethod $method + * @param \Magento\Payment\Model\MethodInterface $method * @return $this */ protected function _assignMethod($method) diff --git a/app/code/Magento/Payment/Block/Info.php b/app/code/Magento/Payment/Block/Info.php index f063fa85749..28de765b456 100644 --- a/app/code/Magento/Payment/Block/Info.php +++ b/app/code/Magento/Payment/Block/Info.php @@ -60,7 +60,7 @@ class Info extends \Magento\View\Element\Template /** * Retrieve payment method model * - * @return \Magento\Payment\Model\Method\AbstractMethod + * @return \Magento\Payment\Model\MethodInterface */ public function getMethod() { diff --git a/app/code/Magento/Payment/Block/Info/Cc.php b/app/code/Magento/Payment/Block/Info/Cc.php index 0fad0f8685f..b9437a84f40 100644 --- a/app/code/Magento/Payment/Block/Info/Cc.php +++ b/app/code/Magento/Payment/Block/Info/Cc.php @@ -92,11 +92,11 @@ class Cc extends \Magento\Payment\Block\Info /** * Retrieve CC expiration date * - * @return \Zend_Date + * @return \Magento\Stdlib\DateTime\Date */ public function getCcExpDate() { - $date = $this->_locale->date(0); + $date = $this->_localeDate->date(0); $date->setYear($this->getInfo()->getCcExpYear()); $date->setMonth($this->getInfo()->getCcExpMonth()); return $date; diff --git a/app/code/Magento/Payment/Helper/Data.php b/app/code/Magento/Payment/Helper/Data.php index a261b151667..f41c383465c 100644 --- a/app/code/Magento/Payment/Helper/Data.php +++ b/app/code/Magento/Payment/Helper/Data.php @@ -25,7 +25,6 @@ namespace Magento\Payment\Helper; use Magento\Sales\Model\Quote; use Magento\Core\Model\Store; -use Magento\Payment\Model\Method\AbstractMethod; use Magento\Payment\Block\Form; use Magento\Payment\Model\Info; use Magento\View\Element\Template; @@ -118,7 +117,7 @@ class Data extends \Magento\App\Helper\AbstractHelper * Retrieve method model object * * @param string $code - * @return AbstractMethod|false + * @return \Magento\Payment\Model\MethodInterface|false */ public function getMethodInstance($code) { @@ -180,10 +179,10 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Retrieve payment method form html * - * @param AbstractMethod $method + * @param \Magento\Payment\Model\MethodInterface $method * @return Form */ - public function getMethodFormBlock(AbstractMethod $method) + public function getMethodFormBlock(\Magento\Payment\Model\MethodInterface $method) { $block = false; $blockType = $method->getFormBlockType(); diff --git a/app/code/Magento/Payment/Model/Config.php b/app/code/Magento/Payment/Model/Config.php index 4e9ee420fbd..578e63ebfdd 100644 --- a/app/code/Magento/Payment/Model/Config.php +++ b/app/code/Magento/Payment/Model/Config.php @@ -55,9 +55,9 @@ class Config /** * Locale model * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ListsInterface */ - protected $_locale; + protected $_localeLists; /** * Payment method factory @@ -72,21 +72,21 @@ class Config * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Payment\Model\Method\Factory $paymentMethodFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ListsInterface $localeLists * @param \Magento\Config\DataInterface $dataStorage */ public function __construct( \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\App\ConfigInterface $coreConfig, \Magento\Payment\Model\Method\Factory $paymentMethodFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ListsInterface $localeLists, \Magento\Config\DataInterface $dataStorage ) { $this->_coreStoreConfig = $coreStoreConfig; $this->_dataStorage = $dataStorage; $this->_coreConfig = $coreConfig; $this->_methodFactory = $paymentMethodFactory; - $this->_locale = $locale; + $this->_localeLists = $localeLists; } /** @@ -135,7 +135,7 @@ class Config * @param string $code * @param string $config * @param null|string|bool|int|Store $store - * @return AbstractMethod + * @return \Magento\Payment\Model\MethodInterface */ protected function _getMethod($code, $config, $store = null) { @@ -200,7 +200,7 @@ class Config */ public function getMonths() { - $data = $this->_locale->getTranslationList('month'); + $data = $this->_localeLists->getTranslationList('month'); foreach ($data as $key => $value) { $monthNum = ($key < 10) ? '0'.$key : $key; $data[$key] = $monthNum . ' - ' . $value; diff --git a/app/code/Magento/Payment/Model/Info.php b/app/code/Magento/Payment/Model/Info.php index e32334b5087..e551ee04958 100644 --- a/app/code/Magento/Payment/Model/Info.php +++ b/app/code/Magento/Payment/Model/Info.php @@ -97,7 +97,7 @@ class Info extends \Magento\Core\Model\AbstractModel /** * Retrieve payment method model object * - * @return \Magento\Payment\Model\Method\AbstractMethod + * @return \Magento\Payment\Model\MethodInterface * @throws \Magento\Core\Exception */ public function getMethodInstance() diff --git a/app/code/Magento/Payment/Model/Method/AbstractMethod.php b/app/code/Magento/Payment/Model/Method/AbstractMethod.php index 73b16b98802..04d775c6b9f 100644 --- a/app/code/Magento/Payment/Model/Method/AbstractMethod.php +++ b/app/code/Magento/Payment/Model/Method/AbstractMethod.php @@ -28,7 +28,7 @@ use Magento\Sales\Model\Order\Payment; /** * Payment method abstract model */ -abstract class AbstractMethod extends \Magento\Object +abstract class AbstractMethod extends \Magento\Object implements \Magento\Payment\Model\MethodInterface { const ACTION_ORDER = 'order'; const ACTION_AUTHORIZE = 'authorize'; diff --git a/app/code/Magento/Payment/Model/Method/Cc.php b/app/code/Magento/Payment/Model/Method/Cc.php index 89e220d11c9..d409eb097e7 100644 --- a/app/code/Magento/Payment/Model/Method/Cc.php +++ b/app/code/Magento/Payment/Model/Method/Cc.php @@ -48,11 +48,9 @@ class Cc extends \Magento\Payment\Model\Method\AbstractMethod protected $_moduleList; /** - * Locale model - * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * Centinel service model @@ -75,7 +73,7 @@ class Cc extends \Magento\Payment\Model\Method\AbstractMethod * @param \Magento\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Logger $logger * @param \Magento\Module\ModuleListInterface $moduleList - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService * @param array $data */ @@ -86,14 +84,14 @@ class Cc extends \Magento\Payment\Model\Method\AbstractMethod \Magento\Logger\AdapterFactory $logAdapterFactory, \Magento\Logger $logger, \Magento\Module\ModuleListInterface $moduleList, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, array $data = array() ) { parent::__construct($eventManager, $paymentData, $coreStoreConfig, $logAdapterFactory, $data); $this->_moduleList = $moduleList; $this->_logger = $logger; - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_centinelService = $centinelService; } @@ -278,7 +276,7 @@ class Cc extends \Magento\Payment\Model\Method\AbstractMethod */ protected function _validateExpDate($expYear, $expMonth) { - $date = $this->_locale->date(); + $date = $this->_localeDate->date(); if (!$expYear || !$expMonth || ($date->compareYear($expYear) == 1) || ($date->compareYear($expYear) == 0 && ($date->compareMonth($expMonth) == 1)) ) { diff --git a/app/code/Magento/Payment/Model/Method/Factory.php b/app/code/Magento/Payment/Model/Method/Factory.php index b67ffc9abd8..fc4007aad6a 100644 --- a/app/code/Magento/Payment/Model/Method/Factory.php +++ b/app/code/Magento/Payment/Model/Method/Factory.php @@ -50,14 +50,14 @@ class Factory * * @param string $className * @param array $data - * @return \Magento\Payment\Model\Method\AbstractMethod + * @return \Magento\Payment\Model\MethodInterface * @throws \Magento\Core\Exception */ public function create($className, $data = array()) { $method = $this->_objectManager->create($className, $data); - if (!($method instanceof \Magento\Payment\Model\Method\AbstractMethod)) { - throw new \Magento\Core\Exception(sprintf("%s class doesn't extend \Magento\Payment\Model\Method\AbstractMethod", + if (!($method instanceof \Magento\Payment\Model\MethodInterface)) { + throw new \Magento\Core\Exception(sprintf("%s class doesn't implement \Magento\Payment\Model\MethodInterface", $className)); } return $method; diff --git a/app/code/Magento/Payment/Model/MethodInterface.php b/app/code/Magento/Payment/Model/MethodInterface.php new file mode 100644 index 00000000000..32f56e4493e --- /dev/null +++ b/app/code/Magento/Payment/Model/MethodInterface.php @@ -0,0 +1,52 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Payment interface + */ +namespace Magento\Payment\Model; + +interface MethodInterface +{ + /** + * Retrieve payment method code + * + * @return string + */ + public function getCode(); + + /** + * Retrieve block type for method form generation + * + * @return string + */ + public function getFormBlockType(); + + /** + * Retrieve payment method title + * + * @return string + */ + public function getTitle(); +} diff --git a/app/code/Magento/Payment/Model/Observer.php b/app/code/Magento/Payment/Model/Observer.php index 4d6ce7a61df..e8bd339aa81 100644 --- a/app/code/Magento/Payment/Model/Observer.php +++ b/app/code/Magento/Payment/Model/Observer.php @@ -91,22 +91,6 @@ class Observer return $this; } - /** - * Sets current instructions for bank transfer account - * - * @param \Magento\Event\Observer $observer - * @return void - */ - public function beforeOrderPaymentSave(\Magento\Event\Observer $observer) - { - /** @var \Magento\Sales\Model\Order\Payment $payment */ - $payment = $observer->getEvent()->getPayment(); - if($payment->getMethod() === \Magento\Payment\Model\Method\Banktransfer::PAYMENT_METHOD_BANKTRANSFER_CODE) { - $payment->setAdditionalInformation('instructions', - $payment->getMethodInstance()->getInstructions()); - } - } - /** * @param \Magento\Event\Observer $observer * @return void diff --git a/app/code/Magento/Payment/etc/adminhtml/system.xml b/app/code/Magento/Payment/etc/adminhtml/system.xml index 51f5b9e71e5..027b29128b1 100644 --- a/app/code/Magento/Payment/etc/adminhtml/system.xml +++ b/app/code/Magento/Payment/etc/adminhtml/system.xml @@ -31,249 +31,6 @@ <label>Payment Methods</label> <tab>sales</tab> <resource>Magento_Payment::payment</resource> - <group id="ccsave" translate="label" type="text" sortOrder="27" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Saved CC</label> - <field id="active" translate="label comment" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enabled</label> - <comment>Enabling this method will store credit card information in the database, which may increase your security or compliance requirements.</comment> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="cctypes" translate="label" type="multiselect" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Credit Card Types</label> - <source_model>Magento\Payment\Model\Config\Source\Cctype</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="order_status" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>New Order Status</label> - <source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model> - </field> - <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sort Order</label> - <frontend_class>validate-number</frontend_class> - </field> - <field id="title" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Title</label> - </field> - <field id="useccv" translate="label" type="select" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Request Card Security Code</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="centinel" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>3D Secure Card Validation</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="centinel_is_mode_strict" translate="label comment" type="select" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Severe 3D Secure Card Validation</label> - <comment>Severe validation removes chargeback liability on merchant.</comment> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - <depends> - <field id="centinel">1</field> - </depends> - </field> - <field id="centinel_api_url" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Centinel API URL</label> - <comment>A value is required for live mode. Refer to your CardinalCommerce agreement.</comment> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - <depends> - <field id="centinel">1</field> - </depends> - </field> - <field id="allowspecific" translate="label" type="allowspecific" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Payment from Applicable Countries</label> - <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> - </field> - <field id="specificcountry" translate="label" type="multiselect" sortOrder="51" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Payment from Specific Countries</label> - <source_model>Magento\Directory\Model\Config\Source\Country</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="min_order_total" translate="label" type="text" sortOrder="98" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Minimum Order Total</label> - </field> - <field id="max_order_total" translate="label" type="text" sortOrder="99" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Maximum Order Total</label> - </field> - <field id="model"></field> - </group> - <group id="checkmo" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Check / Money Order</label> - <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enabled</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="order_status" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>New Order Status</label> - <source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model> - </field> - <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sort Order</label> - <frontend_class>validate-number</frontend_class> - </field> - <field id="title" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Title</label> - </field> - <field id="allowspecific" translate="label" type="allowspecific" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Payment from Applicable Countries</label> - <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> - </field> - <field id="specificcountry" translate="label" type="multiselect" sortOrder="51" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Payment from Specific Countries</label> - <source_model>Magento\Directory\Model\Config\Source\Country</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="payable_to" translate="label" sortOrder="61" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Make Check Payable to</label> - </field> - <field id="mailing_address" translate="label" type="textarea" sortOrder="62" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Send Check to</label> - </field> - <field id="min_order_total" translate="label" type="text" sortOrder="98" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Minimum Order Total</label> - </field> - <field id="max_order_total" translate="label" type="text" sortOrder="99" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Maximum Order Total</label> - </field> - <field id="model"></field> - </group> - <group id="free" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Zero Subtotal Checkout</label> - <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enabled</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="order_status" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>New Order Status</label> - <source_model>Magento\Sales\Model\Config\Source\Order\Status\Newprocessing</source_model> - </field> - <field id="payment_action" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Automatically Invoice All Items</label> - <source_model>Magento\Payment\Model\Source\Invoice</source_model> - <depends> - <field id="order_status" separator=",">processing,processed_ogone</field> - </depends> - </field> - <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sort Order</label> - <frontend_class>validate-number</frontend_class> - </field> - <field id="title" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Title</label> - </field> - <field id="allowspecific" translate="label" type="allowspecific" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Payment from Applicable Countries</label> - <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> - </field> - <field id="specificcountry" translate="label" type="multiselect" sortOrder="51" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Payment from Specific Countries</label> - <source_model>Magento\Directory\Model\Config\Source\Country</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="model"></field> - </group> - <group id="purchaseorder" translate="label" type="text" sortOrder="32" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Purchase Order</label> - <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enabled</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="order_status" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>New Order Status</label> - <source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model> - </field> - <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sort Order</label> - <frontend_class>validate-number</frontend_class> - </field> - <field id="title" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Title</label> - </field> - <field id="allowspecific" translate="label" type="allowspecific" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Payment from Applicable Countries</label> - <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> - </field> - <field id="specificcountry" translate="label" type="multiselect" sortOrder="51" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Payment from Specific Countries</label> - <source_model>Magento\Directory\Model\Config\Source\Country</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="min_order_total" translate="label" type="text" sortOrder="98" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Minimum Order Total</label> - </field> - <field id="max_order_total" translate="label" type="text" sortOrder="99" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Maximum Order Total</label> - </field> - <field id="model"></field> - </group> - <group id="banktransfer" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Bank Transfer Payment</label> - <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enabled</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="title" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Title</label> - </field> - <field id="order_status" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>New Order Status</label> - <source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model> - </field> - <field id="allowspecific" translate="label" type="allowspecific" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Payment from Applicable Countries</label> - <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> - </field> - <field id="specificcountry" translate="label" type="multiselect" sortOrder="51" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Payment from Specific Countries</label> - <source_model>Magento\Directory\Model\Config\Source\Country</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="instructions" translate="label" type="textarea" sortOrder="62" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Instructions</label> - </field> - <field id="min_order_total" translate="label" type="text" sortOrder="98" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Minimum Order Total</label> - </field> - <field id="max_order_total" translate="label" type="text" sortOrder="99" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Maximum Order Total</label> - </field> - <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sort Order</label> - </field> - </group> - <group id="cashondelivery" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Cash On Delivery Payment</label> - <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enabled</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="title" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Title</label> - </field> - <field id="order_status" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>New Order Status</label> - <source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model> - </field> - <field id="allowspecific" translate="label" type="allowspecific" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Payment from Applicable Countries</label> - <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> - </field> - <field id="specificcountry" translate="label" type="multiselect" sortOrder="51" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Payment from Specific Countries</label> - <source_model>Magento\Directory\Model\Config\Source\Country</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="instructions" translate="label" type="textarea" sortOrder="62" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Instructions</label> - </field> - <field id="min_order_total" translate="label" type="text" sortOrder="98" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Minimum Order Total</label> - </field> - <field id="max_order_total" translate="label" type="text" sortOrder="99" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Maximum Order Total</label> - </field> - <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sort Order</label> - </field> - </group> </section> </system> </config> diff --git a/app/code/Magento/Payment/etc/config.xml b/app/code/Magento/Payment/etc/config.xml index a0ea4cf3377..5357d8a602d 100644 --- a/app/code/Magento/Payment/etc/config.xml +++ b/app/code/Magento/Payment/etc/config.xml @@ -28,23 +28,6 @@ <config> <default> <payment> - <ccsave> - <active>0</active> - <cctypes>AE,VI,MC,DI</cctypes> - <model>Magento\Payment\Model\Method\Ccsave</model> - <order_status>pending</order_status> - <title>Credit Card (saved)</title> - <allowspecific>0</allowspecific> - <group>offline</group> - </ccsave> - <checkmo> - <active>1</active> - <model>Magento\Payment\Model\Method\Checkmo</model> - <order_status>pending</order_status> - <title>Check / Money order</title> - <allowspecific>0</allowspecific> - <group>offline</group> - </checkmo> <free> <active>1</active> <model>Magento\Payment\Model\Method\Free</model> @@ -54,30 +37,6 @@ <sort_order>1</sort_order> <group>offline</group> </free> - <purchaseorder> - <active>0</active> - <model>Magento\Payment\Model\Method\Purchaseorder</model> - <order_status>pending</order_status> - <title>Purchase Order</title> - <allowspecific>0</allowspecific> - <group>offline</group> - </purchaseorder> - <banktransfer> - <active>0</active> - <model>Magento\Payment\Model\Method\Banktransfer</model> - <order_status>pending</order_status> - <title>Bank Transfer Payment</title> - <allowspecific>0</allowspecific> - <group>offline</group> - </banktransfer> - <cashondelivery> - <active>0</active> - <model>Magento\Payment\Model\Method\Cashondelivery</model> - <order_status>pending</order_status> - <title>Cash On Delivery</title> - <allowspecific>0</allowspecific> - <group>offline</group> - </cashondelivery> </payment> </default> </config> diff --git a/app/code/Magento/Payment/etc/events.xml b/app/code/Magento/Payment/etc/events.xml index 1dc12dccf36..f68d42467bd 100644 --- a/app/code/Magento/Payment/etc/events.xml +++ b/app/code/Magento/Payment/etc/events.xml @@ -27,9 +27,6 @@ <event name="sales_order_save_before"> <observer name="payment_sales_order_save_before" instance="Magento\Payment\Model\Observer" method="salesOrderBeforeSave" /> </event> - <event name="sales_order_payment_save_before"> - <observer name="payment_before_save" instance="Magento\Payment\Model\Observer" method="beforeOrderPaymentSave" /> - </event> <event name="sales_order_status_unassign"> <observer name="sales_order_status_update" instance="Magento\Payment\Model\Observer" method="updateOrderStatusForPaymentMethods" /> </event> diff --git a/app/code/Magento/Payment/etc/module.xml b/app/code/Magento/Payment/etc/module.xml index 32167e3ad08..9d31ccf7d5e 100755 --- a/app/code/Magento/Payment/etc/module.xml +++ b/app/code/Magento/Payment/etc/module.xml @@ -33,8 +33,8 @@ <module name="Magento_Core"/> <module name="Magento_Sales"/> <module name="Magento_Centinel"/> - <module name="Magento_Checkout"/> <module name="Magento_RecurringProfile"/> + <module name="Magento_Checkout"/> </depends> </module> </config> diff --git a/app/code/Magento/Payment/etc/payment.xml b/app/code/Magento/Payment/etc/payment.xml index 48ff0e969d0..17e35469997 100644 --- a/app/code/Magento/Payment/etc/payment.xml +++ b/app/code/Magento/Payment/etc/payment.xml @@ -53,35 +53,4 @@ <label>Other</label> </type> </credit_cards> - <groups> - <group id="offline"> - <label>Offline Payment Methods</label> - </group> - </groups> - <methods> - <method name="banktransfer"> - <allow_multiple_address>1</allow_multiple_address> - <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> - </method> - <method name="cashondelivery"> - <allow_multiple_address>1</allow_multiple_address> - <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> - </method> - <method name="ccsave"> - <allow_multiple_address>1</allow_multiple_address> - <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> - </method> - <method name="checkmo"> - <allow_multiple_address>1</allow_multiple_address> - <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> - </method> - <method name="free"> - <allow_multiple_address>1</allow_multiple_address> - <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> - </method> - <method name="purchaseorder"> - <allow_multiple_address>1</allow_multiple_address> - <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> - </method> - </methods> </payment> diff --git a/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/Grid.php b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/Grid.php index a308753a1b8..c210a0ba62b 100644 --- a/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/Grid.php +++ b/app/code/Magento/Paypal/Block/Adminhtml/Billing/Agreement/Grid.php @@ -156,15 +156,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended 'column_css_class' => 'col-last-name' )); - $this->addColumn('method_code', array( - 'header' => __('Payment Method'), - 'index' => 'method_code', - 'type' => 'options', - 'options' => $this->_helper->getAllBillingAgreementMethods(), - 'header_css_class' => 'col-payment', - 'column_css_class' => 'col-payment' - )); - $this->addColumn('reference_id', array( 'header' => __('Reference ID'), 'index' => 'reference_id', diff --git a/app/code/Magento/Paypal/Block/Adminhtml/Settlement/Details/Form.php b/app/code/Magento/Paypal/Block/Adminhtml/Settlement/Details/Form.php index 7f350911fa9..337b69553ea 100644 --- a/app/code/Magento/Paypal/Block/Adminhtml/Settlement/Details/Form.php +++ b/app/code/Magento/Paypal/Block/Adminhtml/Settlement/Details/Form.php @@ -35,11 +35,17 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic */ protected $_settlement; + /** + * @var \Magento\Locale\CurrencyInterface + */ + protected $_localeCurrency; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory * @param \Magento\Paypal\Model\Report\Settlement $settlement + * @param \Magento\Locale\CurrencyInterface $localeCurrency * @param array $data */ public function __construct( @@ -47,9 +53,11 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, \Magento\Paypal\Model\Report\Settlement $settlement, + \Magento\Locale\CurrencyInterface $localeCurrency, array $data = array() ) { $this->_settlement = $settlement; + $this->_localeCurrency = $localeCurrency; parent::__construct($context, $registry, $formFactory, $data); } @@ -89,7 +97,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic 'label' => $this->_settlement->getFieldLabel('transaction_initiation_date'), 'value' => $this->formatDate( $model->getData('transaction_initiation_date'), - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM, + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, true ) ), @@ -97,7 +105,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic 'label' => $this->_settlement->getFieldLabel('transaction_completion_date'), 'value' => $this->formatDate( $model->getData('transaction_completion_date'), - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM, + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, true ) ), @@ -107,7 +115,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic ), 'gross_transaction_amount' => array( 'label' => $this->_settlement->getFieldLabel('gross_transaction_amount'), - 'value' => $this->_locale->currency($model->getData('gross_transaction_currency')) + 'value' => $this->_localeCurrency->getCurrency($model->getData('gross_transaction_currency')) ->toCurrency($model->getData('gross_transaction_amount')) ), ), @@ -121,7 +129,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic ), 'fee_amount' => array( 'label' => $this->_settlement->getFieldLabel('fee_amount'), - 'value' => $this->_locale->currency($model->getData('fee_currency')) + 'value' => $this->_localeCurrency->getCurrency($model->getData('fee_currency')) ->toCurrency($model->getData('fee_amount')) ), ), diff --git a/app/code/Magento/Paypal/Block/Express/Form.php b/app/code/Magento/Paypal/Block/Express/Form.php index 1ae0f7cf99b..0ad4a553bb1 100644 --- a/app/code/Magento/Paypal/Block/Express/Form.php +++ b/app/code/Magento/Paypal/Block/Express/Form.php @@ -52,6 +52,7 @@ class Form extends \Magento\Paypal\Block\Standard\Form /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Paypal\Model\ConfigFactory $paypalConfigFactory + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Paypal\Helper\Data $paypalData * @param \Magento\Customer\Model\Session $customerSession * @param array $data @@ -59,13 +60,14 @@ class Form extends \Magento\Paypal\Block\Standard\Form public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Paypal\Model\ConfigFactory $paypalConfigFactory, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Paypal\Helper\Data $paypalData, \Magento\Customer\Model\Session $customerSession, array $data = array() ) { $this->_paypalData = $paypalData; $this->_customerSession = $customerSession; - parent::__construct($context, $paypalConfigFactory, $data); + parent::__construct($context, $paypalConfigFactory, $localeResolver, $data); $this->_isScopePrivate = true; } diff --git a/app/code/Magento/Paypal/Block/Express/Shortcut.php b/app/code/Magento/Paypal/Block/Express/Shortcut.php index b914787ad4f..46fd053eda4 100644 --- a/app/code/Magento/Paypal/Block/Express/Shortcut.php +++ b/app/code/Magento/Paypal/Block/Express/Shortcut.php @@ -111,6 +111,11 @@ class Shortcut extends \Magento\View\Element\Template implements CatalogBlock\Sh */ protected $productTypeConfig; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Paypal\Helper\Data $paypalData @@ -121,6 +126,7 @@ class Shortcut extends \Magento\View\Element\Template implements CatalogBlock\Sh * @param \Magento\Paypal\Model\Express\Checkout\Factory $checkoutFactory * @param \Magento\Math\Random $mathRandom * @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Checkout\Model\Session $checkoutSession * @param array $data */ @@ -134,6 +140,7 @@ class Shortcut extends \Magento\View\Element\Template implements CatalogBlock\Sh \Magento\Paypal\Model\Express\Checkout\Factory $checkoutFactory, \Magento\Math\Random $mathRandom, \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Checkout\Model\Session $checkoutSession = null, array $data = array() ) { @@ -146,6 +153,7 @@ class Shortcut extends \Magento\View\Element\Template implements CatalogBlock\Sh $this->_checkoutFactory = $checkoutFactory; $this->mathRandom = $mathRandom; $this->productTypeConfig = $productTypeConfig; + $this->_localeResolver = $localeResolver; parent::__construct($context, $data); $this->_isScopePrivate = true; } @@ -201,7 +209,9 @@ class Shortcut extends \Magento\View\Element\Template implements CatalogBlock\Sh // use static image if in catalog if ($isInCatalog || null === $quote) { - $this->setImageUrl($config->getExpressCheckoutShortcutImageUrl($this->_locale->getLocaleCode())); + $this->setImageUrl($config->getExpressCheckoutShortcutImageUrl( + $this->_localeResolver->getLocaleCode()) + ); } else { $parameters = array( 'params' => array( diff --git a/app/code/Magento/Paypal/Block/Logo.php b/app/code/Magento/Paypal/Block/Logo.php index de277eecf30..dbd5a29858e 100644 --- a/app/code/Magento/Paypal/Block/Logo.php +++ b/app/code/Magento/Paypal/Block/Logo.php @@ -36,17 +36,25 @@ class Logo extends \Magento\View\Element\Template */ protected $_paypalConfig; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Paypal\Model\Config $paypalConfig + * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Paypal\Model\Config $paypalConfig, + \Magento\Locale\ResolverInterface $localeResolver, array $data = array() ) { $this->_paypalConfig = $paypalConfig; + $this->_localeResolver = $localeResolver; parent::__construct($context, $data); } @@ -57,7 +65,7 @@ class Logo extends \Magento\View\Element\Template */ public function getAboutPaypalPageUrl() { - return $this->_getConfig()->getPaymentMarkWhatIsPaypalUrl($this->_locale); + return $this->_getConfig()->getPaymentMarkWhatIsPaypalUrl($this->_localeResolver); } /** @@ -78,7 +86,9 @@ class Logo extends \Magento\View\Element\Template protected function _toHtml() { $type = $this->getLogoType(); // assigned in layout etc. - $logoUrl = $this->_getConfig()->getAdditionalOptionsLogoUrl($this->_locale->getLocaleCode(), $type); + $logoUrl = $this->_getConfig()->getAdditionalOptionsLogoUrl( + $this->_localeResolver->getLocaleCode(), $type + ); if (!$logoUrl) { return ''; } diff --git a/app/code/Magento/Paypal/Block/Standard/Form.php b/app/code/Magento/Paypal/Block/Standard/Form.php index d40bf40ef34..b6e2a190f93 100644 --- a/app/code/Magento/Paypal/Block/Standard/Form.php +++ b/app/code/Magento/Paypal/Block/Standard/Form.php @@ -48,17 +48,25 @@ class Form extends \Magento\Payment\Block\Form */ protected $_paypalConfigFactory; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Paypal\Model\ConfigFactory $paypalConfigFactory + * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Paypal\Model\ConfigFactory $paypalConfigFactory, + \Magento\Locale\ResolverInterface $localeResolver, array $data = array() ) { $this->_paypalConfigFactory = $paypalConfigFactory; + $this->_localeResolver = $localeResolver; parent::__construct($context, $data); } @@ -73,8 +81,12 @@ class Form extends \Magento\Payment\Block\Form /** @var $mark \Magento\View\Element\Template */ $mark = $this->_layout->createBlock('Magento\View\Element\Template'); $mark->setTemplate('Magento_Paypal::payment/mark.phtml') - ->setPaymentAcceptanceMarkHref($this->_config->getPaymentMarkWhatIsPaypalUrl($this->_locale)) - ->setPaymentAcceptanceMarkSrc($this->_config->getPaymentMarkImageUrl($this->_locale->getLocaleCode())); + ->setPaymentAcceptanceMarkHref( + $this->_config->getPaymentMarkWhatIsPaypalUrl($this->_localeResolver) + ) + ->setPaymentAcceptanceMarkSrc( + $this->_config->getPaymentMarkImageUrl($this->_localeResolver->getLocaleCode()) + ); // known issue: code above will render only static mark image $this->setTemplate('Magento_Paypal::payment/redirect.phtml') ->setRedirectMessage( diff --git a/app/code/Magento/Paypal/Controller/Express/AbstractExpress.php b/app/code/Magento/Paypal/Controller/Express/AbstractExpress.php index 867ef9aa716..2764c48d50b 100644 --- a/app/code/Magento/Paypal/Controller/Express/AbstractExpress.php +++ b/app/code/Magento/Paypal/Controller/Express/AbstractExpress.php @@ -29,6 +29,7 @@ namespace Magento\Paypal\Controller\Express; * Abstract Express Checkout Controller */ abstract class AbstractExpress extends \Magento\App\Action\Action + implements \Magento\Checkout\Controller\Express\RedirectLoginInterface { /** * @var \Magento\Paypal\Model\Express\Checkout @@ -547,18 +548,38 @@ abstract class AbstractExpress extends \Magento\App\Action\Action } /** - * Redirect to login page - * - * @return void + * Returns before_auth_url redirect parameter for customer session + * @return null + */ + public function getCustomerBeforeAuthUrl() + { + return; + } + + /** + * Returns a list of action flags [flag_key] => boolean + * @return array + */ + public function getActionFlagList() + { + return array(); + } + + /** + * Returns login url parameter for redirect + * @return string + */ + public function getLoginUrl() + { + return $this->_objectManager->get('Magento\Customer\Helper\Data')->getLoginUrl(); + } + + /** + * Returns action name which requires redirect + * @return string */ - public function redirectLogin() + public function getRedirectActionName() { - $this->_actionFlag->set('', 'no-dispatch', true); - $this->getResponse()->setRedirect( - $this->_objectManager->get('Magento\Core\Helper\Url')->addRequestParam( - $this->_objectManager->get('Magento\Customer\Helper\Data')->getLoginUrl(), - array('context' => 'checkout') - ) - ); + return 'start'; } } diff --git a/app/code/Magento/Paypal/Controller/Hostedpro.php b/app/code/Magento/Paypal/Controller/Hostedpro.php index b37bbb9b73a..05a3b03e4b6 100644 --- a/app/code/Magento/Paypal/Controller/Hostedpro.php +++ b/app/code/Magento/Paypal/Controller/Hostedpro.php @@ -32,6 +32,21 @@ namespace Magento\Paypal\Controller; */ class Hostedpro extends \Magento\App\Action\Action { + /** + * @var \Magento\Checkout\Model\Session + */ + protected $_session; + + /** + * @param \Magento\App\Action\Context $context + * @param \Magento\Checkout\Model\Session $session + */ + public function __construct(\Magento\App\Action\Context $context, \Magento\Checkout\Model\Session $session) + { + parent::__construct($context); + $this->_session = $session; + } + /** * When a customer return to website from gateway. * @@ -72,7 +87,7 @@ class Hostedpro extends \Magento\App\Action\Action $gotoSection = false; $helper = $this->_objectManager->get('Magento\Paypal\Helper\Checkout'); $helper->cancelCurrentOrder($errorMsg); - if ($helper->restoreQuote()) { + if ($this->_session->restoreQuote()) { $gotoSection = 'payment'; } diff --git a/app/code/Magento/Paypal/Controller/Payflow.php b/app/code/Magento/Paypal/Controller/Payflow.php index 95fef0c34cf..da5a6dba334 100644 --- a/app/code/Magento/Paypal/Controller/Payflow.php +++ b/app/code/Magento/Paypal/Controller/Payflow.php @@ -46,18 +46,24 @@ class Payflow extends \Magento\App\Action\Action /** * @var \Magento\Paypal\Model\PayflowlinkFactory */ - protected $_payflowlinkFactory; + protected $_payflowModelFactory; /** * @var \Magento\Paypal\Helper\Checkout */ protected $_checkoutHelper; + /** + * Redirect block name + * @var string + */ + protected $_redirectBlockName = 'payflow.link.iframe'; + /** * @param \Magento\App\Action\Context $context * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Sales\Model\OrderFactory $orderFactory - * @param \Magento\Paypal\Model\PayflowlinkFactory $payflowlinkFactory + * @param \Magento\Paypal\Model\PayflowlinkFactory $payflowModelFactory * @param \Magento\Paypal\Helper\Checkout $checkoutHelper * @param \Magento\Logger $logger */ @@ -65,14 +71,14 @@ class Payflow extends \Magento\App\Action\Action \Magento\App\Action\Context $context, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Sales\Model\OrderFactory $orderFactory, - \Magento\Paypal\Model\PayflowlinkFactory $payflowlinkFactory, + \Magento\Paypal\Model\PayflowlinkFactory $payflowModelFactory, \Magento\Paypal\Helper\Checkout $checkoutHelper, \Magento\Logger $logger ) { $this->_checkoutSession = $checkoutSession; $this->_orderFactory = $orderFactory; $this->_logger = $logger; - $this->_payflowlinkFactory = $payflowlinkFactory; + $this->_payflowModelFactory = $payflowModelFactory; $this->_checkoutHelper = $checkoutHelper; parent::__construct($context); } @@ -86,7 +92,7 @@ class Payflow extends \Magento\App\Action\Action { $this->_view->loadLayout(false); $gotoSection = $this->_cancelPayment(); - $redirectBlock = $this->_view->getLayout()->getBlock('payflow.link.iframe'); + $redirectBlock = $this->_view->getLayout()->getBlock($this->_redirectBlockName); $redirectBlock->setGotoSection($gotoSection); $this->_view->renderLayout(); } @@ -99,7 +105,7 @@ class Payflow extends \Magento\App\Action\Action public function returnUrlAction() { $this->_view->loadLayout(false); - $redirectBlock = $this->_view->getLayout()->getBlock('payflow.link.iframe'); + $redirectBlock = $this->_view->getLayout()->getBlock($this->_redirectBlockName); if ($this->_checkoutSession->getLastRealOrderId()) { $order = $this->_orderFactory->create()->loadByIncrementId($this->_checkoutSession->getLastRealOrderId()); @@ -131,6 +137,7 @@ class Payflow extends \Magento\App\Action\Action public function formAction() { $this->_view->loadLayout(false)->renderLayout(); + $layout = $this->_view->getLayout(); } /** @@ -143,7 +150,7 @@ class Payflow extends \Magento\App\Action\Action $data = $this->getRequest()->getPost(); if (isset($data['INVNUM'])) { /** @var $paymentModel \Magento\Paypal\Model\Payflowlink */ - $paymentModel = $this->_payflowlinkFactory->create(); + $paymentModel = $this->_payflowModelFactory->create(); try { $paymentModel->process($data); } catch (\Exception $e) { @@ -162,7 +169,7 @@ class Payflow extends \Magento\App\Action\Action { $gotoSection = false; $this->_checkoutHelper->cancelCurrentOrder($errorMsg); - if ($this->_checkoutHelper->restoreQuote()) { + if ($this->_checkoutSession->restoreQuote()) { //Redirect to payment step $gotoSection = 'payment'; } diff --git a/app/code/Magento/Paypal/Controller/Payflowadvanced.php b/app/code/Magento/Paypal/Controller/Payflowadvanced.php index 4bdc62a481d..144ce723fbf 100644 --- a/app/code/Magento/Paypal/Controller/Payflowadvanced.php +++ b/app/code/Magento/Paypal/Controller/Payflowadvanced.php @@ -26,164 +26,11 @@ namespace Magento\Paypal\Controller; /** * Payflow Advanced Checkout Controller */ -class Payflowadvanced extends \Magento\Paypal\Controller\Express\AbstractExpress +class Payflowadvanced extends \Magento\Paypal\Controller\Payflow { /** - * Config mode type - * + * Redirect block name * @var string */ - protected $_configType = 'Magento\Paypal\Model\Config'; - - /** - * Config method type - * - * @var string - */ - protected $_configMethod = \Magento\Paypal\Model\Config::METHOD_PAYFLOWADVANCED; - - /** - * Checkout mode type - * - * @var string - */ - protected $_checkoutType = 'Magento\Paypal\Model\Payflowadvanced'; - - /** - * @var \Magento\Logger - */ - protected $_logger; - - /** - * @var \Magento\Paypal\Helper\Checkout - */ - protected $_checkoutHelper; - - /** - * @param \Magento\App\Action\Context $context - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Sales\Model\QuoteFactory $quoteFactory - * @param \Magento\Checkout\Model\Session $checkoutSession - * @param \Magento\Sales\Model\OrderFactory $orderFactory - * @param \Magento\Paypal\Model\Express\Checkout\Factory $checkoutFactory - * @param \Magento\Session\Generic $paypalSession - * @param \Magento\Paypal\Helper\Checkout $checkoutHelper - * @param \Magento\Logger $logger - */ - public function __construct( - \Magento\App\Action\Context $context, - \Magento\Customer\Model\Session $customerSession, - \Magento\Sales\Model\QuoteFactory $quoteFactory, - \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Sales\Model\OrderFactory $orderFactory, - \Magento\Paypal\Model\Express\Checkout\Factory $checkoutFactory, - \Magento\Session\Generic $paypalSession, - \Magento\Paypal\Helper\Checkout $checkoutHelper, - \Magento\Logger $logger - ) { - $this->_logger = $logger; - $this->_checkoutHelper = $checkoutHelper; - parent::__construct( - $context, - $customerSession, - $quoteFactory, - $checkoutSession, - $orderFactory, - $checkoutFactory, - $paypalSession - ); - } - - /** - * When a customer cancel payment from payflow gateway. - * - * @return void - */ - public function cancelPaymentAction() - { - $this->_view->loadLayout(false); - $gotoSection = $this->_cancelPayment(); - $redirectBlock = $this->_view->getLayout()->getBlock('payflow.advanced.iframe'); - $redirectBlock->setGotoSection($gotoSection); - $this->_view->renderLayout(); - } - - /** - * When a customer return to website from payflow gateway. - * - * @return void - */ - public function returnUrlAction() - { - $this->_view->loadLayout(false); - $redirectBlock = $this->_view->getLayout()->getBlock('payflow.advanced.iframe');; - - if ($this->_checkoutSession->getLastRealOrderId()) { - $order = $this->_orderFactory->create()->loadByIncrementId($this->_checkoutSession->getLastRealOrderId()); - - if ($order && $order->getIncrementId() == $this->_checkoutSession->getLastRealOrderId()) { - $allowedOrderStates = array( - \Magento\Sales\Model\Order::STATE_PROCESSING, - \Magento\Sales\Model\Order::STATE_COMPLETE - ); - if (in_array($order->getState(), $allowedOrderStates)) { - $this->_checkoutSession->unsLastRealOrderId(); - $redirectBlock->setGotoSuccessPage(true); - } else { - $gotoSection = $this->_cancelPayment(strval($this->getRequest()->getParam('RESPMSG'))); - $redirectBlock->setGotoSection($gotoSection); - $redirectBlock->setErrorMsg(__('Your payment has been declined. Please try again.')); - } - } - } - - $this->_view->renderLayout(); - } - - /** - * Submit transaction to Payflow getaway into iframe - * - * @return void - */ - public function formAction() - { - $this->_view->loadLayout(false)->renderLayout(); - $html = $this->_view->getLayout()->getBlock('payflow.advanced.iframe')->toHtml(); - $this->getResponse()->setBody($html); - } - - /** - * Get response from PayPal by silent post method - * - * @return void - */ - public function silentPostAction() - { - $data = $this->getRequest()->getPost(); - if (isset($data['INVNUM'])) { - /** @var $paymentModel \Magento\Paypal\Model\Payflowadvanced */ - $paymentModel = $this->_checkoutFactory->create($this->_checkoutType); - try { - $paymentModel->process($data); - } catch (\Exception $e) { - $this->_logger->logException($e); - } - } - } - - /** - * Cancel order, return quote to customer - * - * @param string $errorMsg - * @return false|string - */ - protected function _cancelPayment($errorMsg = '') - { - $gotoSection = false; - $this->_checkoutHelper->cancelCurrentOrder($errorMsg); - if ($this->_checkoutHelper->restoreQuote()) { - $gotoSection = 'payment'; - } - return $gotoSection; - } + protected $_redirectBlockName = 'payflow.advanced.iframe'; } diff --git a/app/code/Magento/Paypal/Controller/Standard.php b/app/code/Magento/Paypal/Controller/Standard.php index a7433d36844..f492127b5f6 100644 --- a/app/code/Magento/Paypal/Controller/Standard.php +++ b/app/code/Magento/Paypal/Controller/Standard.php @@ -95,22 +95,18 @@ class Standard extends \Magento\App\Action\Action */ public function cancelAction() { + /** @var \Magento\Checkout\Model\Session $session */ $session = $this->_objectManager->get('Magento\Checkout\Model\Session'); $session->setQuoteId($session->getPaypalStandardQuoteId(true)); if ($session->getLastRealOrderId()) { + /** @var \Magento\Sales\Model\Order $order */ $order = $this->_objectManager->create('Magento\Sales\Model\Order') ->loadByIncrementId($session->getLastRealOrderId()); if ($order->getId()) { - $this->_objectManager->get('Magento\Event\ManagerInterface')->dispatch( - 'paypal_payment_cancel', - array( - 'order' => $order, - 'quote' => $session->getQuote() - )); $order->cancel()->save(); } - $this->_objectManager->get('Magento\Paypal\Helper\Checkout')->restoreQuote(); + $session->restoreQuote(); } $this->_redirect('checkout/cart'); } @@ -128,6 +124,6 @@ class Standard extends \Magento\App\Action\Action $session = $this->_objectManager->get('Magento\Checkout\Model\Session'); $session->setQuoteId($session->getPaypalStandardQuoteId(true)); $session->getQuote()->setIsActive(false)->save(); - $this->_redirect('checkout/onepage/success', array('_secure'=>true)); + $this->_redirect('checkout/onepage/success', array('_secure' => true)); } } diff --git a/app/code/Magento/Paypal/Helper/Checkout.php b/app/code/Magento/Paypal/Helper/Checkout.php index dea834f620e..474335c2d85 100644 --- a/app/code/Magento/Paypal/Helper/Checkout.php +++ b/app/code/Magento/Paypal/Helper/Checkout.php @@ -50,28 +50,6 @@ class Checkout $this->_quoteFactory = $quoteFactory; } - /** - * Restore last active quote based on checkout session - * - * @return bool True if quote restored successfully, false otherwise - */ - public function restoreQuote() - { - $order = $this->_session->getLastRealOrder(); - if ($order->getId()) { - $quote = $this->_quoteFactory->create()->load($order->getQuoteId()); - if ($quote->getId()) { - $quote->setIsActive(1) - ->setReservedOrderId(null) - ->save(); - $this->_session->replaceQuote($quote) - ->unsLastRealOrderId(); - return true; - } - } - return false; - } - /** * Cancel last placed order with specified comment message * diff --git a/app/code/Magento/Paypal/Helper/Data.php b/app/code/Magento/Paypal/Helper/Data.php index 57404b969fd..a93b4a9e382 100644 --- a/app/code/Magento/Paypal/Helper/Data.php +++ b/app/code/Magento/Paypal/Helper/Data.php @@ -37,13 +37,6 @@ class Data extends \Magento\App\Helper\AbstractHelper */ protected static $_shouldAskToCreateBillingAgreement = null; - /** - * Core data - * - * @var \Magento\Core\Helper\Data - */ - protected $_coreData; - /** * @var \Magento\Payment\Helper\Data */ @@ -56,17 +49,14 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * @param \Magento\App\Helper\Context $context - * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory */ public function __construct( \Magento\App\Helper\Context $context, - \Magento\Core\Helper\Data $coreData, \Magento\Payment\Helper\Data $paymentData, \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory ) { - $this->_coreData = $coreData; $this->_paymentData = $paymentData; $this->_agreementFactory = $agreementFactory; parent::__construct($context); @@ -110,27 +100,6 @@ class Data extends \Magento\App\Helper\AbstractHelper return $result; } - /** - * Retrieve all billing agreement methods (code and label) - * - * @return array - */ - public function getAllBillingAgreementMethods() - { - $result = array(); - $interface = 'Magento\Paypal\Model\Billing\Agreement\MethodInterface'; - foreach ($this->_paymentData->getPaymentMethods() as $code => $data) { - if (!isset($data['model'])) { - continue; - } - $method = $data['model']; - if (in_array($interface, class_implements($method))) { - $result[$code] = $data['title']; - } - } - return $result; - } - /** * Check whether payment method can manage billing agreements or not * @@ -141,27 +110,4 @@ class Data extends \Magento\App\Helper\AbstractHelper { return ($methodInstance instanceof MethodInterface); } - - /** - * Return backend config for element like JSON - * - * @param \Magento\Data\Form\Element\AbstractElement $element - * @return string - */ - public function getElementBackendConfig(\Magento\Data\Form\Element\AbstractElement $element) - { - $config = $element->getFieldConfig(); - if (!array_key_exists('backend_congif', $config)) { - return false; - } - - $config = $config['backend_congif']; - if (isset($config['enable_for_countries'])) { - $config['enable_for_countries'] = explode(',', str_replace(' ', '', $config['enable_for_countries'])); - } - if (isset($config['disable_for_countries'])) { - $config['disable_for_countries'] = explode(',', str_replace(' ', '', $config['disable_for_countries'])); - } - return $this->_coreData->jsonEncode($config); - } } diff --git a/app/code/Magento/Paypal/Model/Api/AbstractApi.php b/app/code/Magento/Paypal/Model/Api/AbstractApi.php index 3fe5c60b787..ec0dd342e9c 100644 --- a/app/code/Magento/Paypal/Model/Api/AbstractApi.php +++ b/app/code/Magento/Paypal/Model/Api/AbstractApi.php @@ -115,9 +115,9 @@ abstract class AbstractApi extends \Magento\Object protected $_logger; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ResolverInterface */ - protected $_locale; + protected $_localeResolver; /** * @var \Magento\Directory\Model\RegionFactory @@ -137,7 +137,7 @@ abstract class AbstractApi extends \Magento\Object * * @param \Magento\Customer\Helper\Address $customerAddress * @param \Magento\Logger $logger - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param \Magento\Logger\AdapterFactory $logAdapterFactory * @param array $data @@ -145,14 +145,14 @@ abstract class AbstractApi extends \Magento\Object public function __construct( \Magento\Customer\Helper\Address $customerAddress, \Magento\Logger $logger, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Logger\AdapterFactory $logAdapterFactory, array $data = array() ) { $this->_customerAddress = $customerAddress; $this->_logger = $logger; - $this->_locale = $locale; + $this->_localeResolver = $localeResolver; $this->_regionFactory = $regionFactory; $this->_logAdapterFactory = $logAdapterFactory; parent::__construct($data); @@ -364,7 +364,7 @@ abstract class AbstractApi extends \Magento\Object */ public function getLocaleCode() { - return $this->_locale->getLocaleCode(); + return $this->_localeResolver->getLocaleCode(); } /** diff --git a/app/code/Magento/Paypal/Model/Api/Nvp.php b/app/code/Magento/Paypal/Model/Api/Nvp.php index fc37bfa8a29..e39eb63f01c 100644 --- a/app/code/Magento/Paypal/Model/Api/Nvp.php +++ b/app/code/Magento/Paypal/Model/Api/Nvp.php @@ -683,7 +683,7 @@ class Nvp extends \Magento\Paypal\Model\Api\AbstractApi /** * @param \Magento\Customer\Helper\Address $customerAddress * @param \Magento\Logger $logger - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param \Magento\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Directory\Model\CountryFactory $countryFactory @@ -692,7 +692,7 @@ class Nvp extends \Magento\Paypal\Model\Api\AbstractApi public function __construct( \Magento\Customer\Helper\Address $customerAddress, \Magento\Logger $logger, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Logger\AdapterFactory $logAdapterFactory, \Magento\Directory\Model\CountryFactory $countryFactory, @@ -700,7 +700,7 @@ class Nvp extends \Magento\Paypal\Model\Api\AbstractApi ) { $this->_countryFactory = $countryFactory; parent::__construct( - $customerAddress, $logger, $locale, $regionFactory, $logAdapterFactory, $data + $customerAddress, $logger, $localeResolver, $regionFactory, $logAdapterFactory, $data ); } diff --git a/app/code/Magento/Paypal/Model/Api/PayflowNvp.php b/app/code/Magento/Paypal/Model/Api/PayflowNvp.php index a7de05470d2..8e15f96f5c9 100644 --- a/app/code/Magento/Paypal/Model/Api/PayflowNvp.php +++ b/app/code/Magento/Paypal/Model/Api/PayflowNvp.php @@ -386,7 +386,7 @@ class PayflowNvp extends \Magento\Paypal\Model\Api\Nvp /** * @param \Magento\Customer\Helper\Address $customerAddress * @param \Magento\Logger $logger - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param \Magento\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Directory\Model\CountryFactory $countryFactory @@ -396,7 +396,7 @@ class PayflowNvp extends \Magento\Paypal\Model\Api\Nvp public function __construct( \Magento\Customer\Helper\Address $customerAddress, \Magento\Logger $logger, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Logger\AdapterFactory $logAdapterFactory, \Magento\Directory\Model\CountryFactory $countryFactory, @@ -407,7 +407,7 @@ class PayflowNvp extends \Magento\Paypal\Model\Api\Nvp parent::__construct( $customerAddress, $logger, - $locale, + $localeResolver, $regionFactory, $logAdapterFactory, $countryFactory, diff --git a/app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php b/app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php index 06afe734e67..e5a8e3f98e9 100644 --- a/app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php +++ b/app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php @@ -31,7 +31,7 @@ abstract class AbstractAgreement extends \Magento\Core\Model\AbstractModel /** * Payment method instance * - * @var \Magento\Payment\Model\Method\AbstractMethod + * @var \Magento\Payment\Model\MethodInterface */ protected $_paymentMethodInstance = null; @@ -92,7 +92,7 @@ abstract class AbstractAgreement extends \Magento\Core\Model\AbstractModel /** * Retrieve payment method instance * - * @return \Magento\Payment\Model\Method\AbstractMethod + * @return \Magento\Payment\Model\MethodInterface */ public function getPaymentMethodInstance() { diff --git a/app/code/Magento/Paypal/Model/Billing/Agreement.php b/app/code/Magento/Paypal/Model/Billing/Agreement.php index 8940d7bd247..b0e1100bd47 100644 --- a/app/code/Magento/Paypal/Model/Billing/Agreement.php +++ b/app/code/Magento/Paypal/Model/Billing/Agreement.php @@ -65,7 +65,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\AbstractAgreement protected $_billingAgreementFactory; /** - * @var \Magento\Core\Model\DateFactory + * @var \Magento\Stdlib\DateTime\DateTimeFactory */ protected $_dateFactory; @@ -74,7 +74,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\AbstractAgreement * @param \Magento\Registry $registry * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementFactory - * @param \Magento\Core\Model\DateFactory $dateFactory + * @param \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -84,7 +84,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\AbstractAgreement \Magento\Registry $registry, \Magento\Payment\Helper\Data $paymentData, \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementFactory, - \Magento\Core\Model\DateFactory $dateFactory, + \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Paypal/Model/Config.php b/app/code/Magento/Paypal/Model/Config.php index 3947d8af57f..dc15ddfff5f 100644 --- a/app/code/Magento/Paypal/Model/Config.php +++ b/app/code/Magento/Paypal/Model/Config.php @@ -308,12 +308,12 @@ class Config /** * Method code setter * - * @param string|\Magento\Payment\Model\Method\AbstractMethod $method + * @param string|\Magento\Payment\Model\MethodInterface $method * @return $this */ public function setMethod($method) { - if ($method instanceof \Magento\Payment\Model\Method\AbstractMethod) { + if ($method instanceof \Magento\Payment\Model\MethodInterface) { $this->_methodCode = $method->getCode(); } elseif (is_string($method)) { $this->_methodCode = $method; @@ -745,10 +745,10 @@ class Config * Get "What Is PayPal" localized URL * Supposed to be used with "mark" as popup window * - * @param \Magento\Core\Model\LocaleInterface|null $locale + * @param \Magento\Locale\ResolverInterface $locale * @return string */ - public function getPaymentMarkWhatIsPaypalUrl(\Magento\Core\Model\LocaleInterface $locale = null) + public function getPaymentMarkWhatIsPaypalUrl(\Magento\Locale\ResolverInterface $locale = null) { $countryCode = 'US'; if (null !== $locale) { diff --git a/app/code/Magento/Paypal/Model/Direct.php b/app/code/Magento/Paypal/Model/Direct.php index 865ab76d76e..44f303d2fb5 100644 --- a/app/code/Magento/Paypal/Model/Direct.php +++ b/app/code/Magento/Paypal/Model/Direct.php @@ -170,7 +170,7 @@ class Direct extends \Magento\Payment\Model\Method\Cc * @param \Magento\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Logger $logger * @param \Magento\Module\ModuleListInterface $moduleList - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService * @param \Magento\Paypal\Model\Method\ProTypeFactory $proTypeFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager @@ -188,7 +188,7 @@ class Direct extends \Magento\Payment\Model\Method\Cc \Magento\Logger\AdapterFactory $logAdapterFactory, \Magento\Logger $logger, \Magento\Module\ModuleListInterface $moduleList, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, \Magento\Paypal\Model\Method\ProTypeFactory $proTypeFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, @@ -204,7 +204,7 @@ class Direct extends \Magento\Payment\Model\Method\Cc $logAdapterFactory, $logger, $moduleList, - $locale, + $localeDate, $centinelService, $data ); diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index 6f4090499c3..b2c4ddcb639 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -184,9 +184,9 @@ class Checkout protected $_logger; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ResolverInterface */ - protected $_locale; + protected $_localeResolver; /** * @var \Magento\Paypal\Model\Info @@ -257,7 +257,7 @@ class Checkout * @param \Magento\Checkout\Helper\Data $checkoutData * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\App\Cache\Type\Config $configCacheType - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Paypal\Model\Info $paypalInfo * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\UrlInterface $coreUrl @@ -280,7 +280,7 @@ class Checkout \Magento\Checkout\Helper\Data $checkoutData, \Magento\Customer\Model\Session $customerSession, \Magento\App\Cache\Type\Config $configCacheType, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Paypal\Model\Info $paypalInfo, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\UrlInterface $coreUrl, @@ -301,7 +301,7 @@ class Checkout $this->_customerSession = $customerSession; $this->_configCacheType = $configCacheType; $this->_logger = $logger; - $this->_locale = $locale; + $this->_localeResolver = $localeResolver; $this->_paypalInfo = $paypalInfo; $this->_storeManager = $storeManager; $this->_coreUrl = $coreUrl; @@ -358,7 +358,7 @@ class Checkout } return $this->_config->getExpressCheckoutShortcutImageUrl( - $this->_locale->getLocaleCode(), + $this->_localeResolver->getLocaleCode(), $this->_quote->getBaseGrandTotal(), $pal ); diff --git a/app/code/Magento/Paypal/Model/Hostedpro.php b/app/code/Magento/Paypal/Model/Hostedpro.php index 3b80c9d6c08..7553fd61e65 100644 --- a/app/code/Magento/Paypal/Model/Hostedpro.php +++ b/app/code/Magento/Paypal/Model/Hostedpro.php @@ -95,7 +95,7 @@ class Hostedpro extends \Magento\Paypal\Model\Direct * @param \Magento\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Logger $logger * @param \Magento\Module\ModuleListInterface $moduleList - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService * @param \Magento\Paypal\Model\Method\ProTypeFactory $proTypeFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager @@ -114,7 +114,7 @@ class Hostedpro extends \Magento\Paypal\Model\Direct \Magento\Logger\AdapterFactory $logAdapterFactory, \Magento\Logger $logger, \Magento\Module\ModuleListInterface $moduleList, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, \Magento\Paypal\Model\Method\ProTypeFactory $proTypeFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, @@ -132,7 +132,7 @@ class Hostedpro extends \Magento\Paypal\Model\Direct $logAdapterFactory, $logger, $moduleList, - $locale, + $localeDate, $centinelService, $proTypeFactory, $storeManager, diff --git a/app/code/Magento/Paypal/Model/Payflowlink.php b/app/code/Magento/Paypal/Model/Payflowlink.php index 42f1ddeb442..7c9d9cccd3f 100644 --- a/app/code/Magento/Paypal/Model/Payflowlink.php +++ b/app/code/Magento/Paypal/Model/Payflowlink.php @@ -153,7 +153,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro * @param \Magento\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Logger $logger * @param \Magento\Module\ModuleListInterface $moduleList - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Paypal\Model\ConfigFactory $configFactory @@ -174,7 +174,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro \Magento\Logger\AdapterFactory $logAdapterFactory, \Magento\Logger $logger, \Magento\Module\ModuleListInterface $moduleList, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Paypal\Model\ConfigFactory $configFactory, @@ -198,7 +198,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro $logAdapterFactory, $logger, $moduleList, - $locale, + $localeDate, $centinelService, $storeManager, $configFactory, diff --git a/app/code/Magento/Paypal/Model/Payflowpro.php b/app/code/Magento/Paypal/Model/Payflowpro.php index 8d4105934fe..46722d45fb5 100644 --- a/app/code/Magento/Paypal/Model/Payflowpro.php +++ b/app/code/Magento/Paypal/Model/Payflowpro.php @@ -207,7 +207,7 @@ class Payflowpro extends \Magento\Payment\Model\Method\Cc * @param \Magento\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Logger $logger * @param \Magento\Module\ModuleListInterface $moduleList - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Paypal\Model\ConfigFactory $configFactory @@ -223,7 +223,7 @@ class Payflowpro extends \Magento\Payment\Model\Method\Cc \Magento\Logger\AdapterFactory $logAdapterFactory, \Magento\Logger $logger, \Magento\Module\ModuleListInterface $moduleList, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Paypal\Model\ConfigFactory $configFactory, @@ -240,7 +240,7 @@ class Payflowpro extends \Magento\Payment\Model\Method\Cc $logAdapterFactory, $logger, $moduleList, - $locale, + $localeDate, $centinelService, $data ); diff --git a/app/code/Magento/Paypal/Model/Payment/Transaction.php b/app/code/Magento/Paypal/Model/Payment/Transaction.php index e68cadca693..a3db92c4598 100644 --- a/app/code/Magento/Paypal/Model/Payment/Transaction.php +++ b/app/code/Magento/Paypal/Model/Payment/Transaction.php @@ -66,14 +66,14 @@ class Transaction extends \Magento\Core\Model\AbstractModel protected $_orderWebsiteId; /** - * @var \Magento\Core\Model\DateFactory + * @var \Magento\Stdlib\DateTime\DateTimeFactory */ protected $_dateFactory; /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\DateFactory $dateFactory + * @param \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -81,7 +81,7 @@ class Transaction extends \Magento\Core\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\DateFactory $dateFactory, + \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Paypal/Model/Report/Settlement.php b/app/code/Magento/Paypal/Model/Report/Settlement.php index 23c45f5d5bf..d6ecbc6b485 100644 --- a/app/code/Magento/Paypal/Model/Report/Settlement.php +++ b/app/code/Magento/Paypal/Model/Report/Settlement.php @@ -248,7 +248,7 @@ class Settlement extends \Magento\Core\Model\AbstractModel // Set last modified date, this value will be overwritten during parsing if (isset($attributes['mtime'])) { - $lastModified = new \Zend_Date($attributes['mtime']); + $lastModified = new \Magento\Stdlib\DateTime\Date($attributes['mtime']); $this->setReportLastModified( $lastModified->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT) ); @@ -320,7 +320,7 @@ class Settlement extends \Magento\Core\Model\AbstractModel $lineType = $line[0]; switch($lineType) { case 'RH': // Report header. - $lastModified = new \Zend_Date($line[1]); + $lastModified = new \Magento\Stdlib\DateTime\Date($line[1]); $this->setReportLastModified($lastModified->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT)); //$this->setAccountId($columns[2]); -- probably we'll just take that from the section header... break; diff --git a/app/code/Magento/Paypal/Model/Resource/Cert.php b/app/code/Magento/Paypal/Model/Resource/Cert.php index 6d2537c6e7c..950d0e88c26 100644 --- a/app/code/Magento/Paypal/Model/Resource/Cert.php +++ b/app/code/Magento/Paypal/Model/Resource/Cert.php @@ -31,7 +31,7 @@ namespace Magento\Paypal\Model\Resource; class Cert extends \Magento\Core\Model\Resource\Db\AbstractDb { /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_coreDate; @@ -42,12 +42,12 @@ class Cert extends \Magento\Core\Model\Resource\Db\AbstractDb /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\Date $coreDate + * @param \Magento\Stdlib\DateTime\DateTime $coreDate * @param \Magento\Stdlib\DateTime $dateTime */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\Date $coreDate, + \Magento\Stdlib\DateTime\DateTime $coreDate, \Magento\Stdlib\DateTime $dateTime ) { $this->_coreDate = $coreDate; diff --git a/app/code/Magento/Paypal/Model/Resource/Report/Settlement.php b/app/code/Magento/Paypal/Model/Resource/Report/Settlement.php index c7e25320d76..191cfd08982 100644 --- a/app/code/Magento/Paypal/Model/Resource/Report/Settlement.php +++ b/app/code/Magento/Paypal/Model/Resource/Report/Settlement.php @@ -38,15 +38,15 @@ class Settlement extends \Magento\Core\Model\Resource\Db\AbstractDb protected $_rowsTable; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_coreDate; /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\Date $coreDate + * @param \Magento\Stdlib\DateTime\DateTime $coreDate */ - public function __construct(\Magento\App\Resource $resource, \Magento\Core\Model\Date $coreDate) + public function __construct(\Magento\App\Resource $resource, \Magento\Stdlib\DateTime\DateTime $coreDate) { $this->_coreDate = $coreDate; parent::__construct($resource); @@ -85,10 +85,10 @@ class Settlement extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Converting dates */ - $completionDate = new \Zend_Date($rows[$key]['transaction_completion_date']); + $completionDate = new \Magento\Stdlib\DateTime\Date($rows[$key]['transaction_completion_date']); $rows[$key]['transaction_completion_date'] = $this->_coreDate ->date(null, $completionDate->getTimestamp()); - $initiationDate = new \Zend_Date($rows[$key]['transaction_initiation_date']); + $initiationDate = new \Magento\Stdlib\DateTime\Date($rows[$key]['transaction_initiation_date']); $rows[$key]['transaction_initiation_date'] = $this->_coreDate ->date(null, $initiationDate->getTimestamp()); /* diff --git a/app/code/Magento/Paypal/etc/di.xml b/app/code/Magento/Paypal/etc/di.xml index 27d6855019b..7a848fa712b 100644 --- a/app/code/Magento/Paypal/etc/di.xml +++ b/app/code/Magento/Paypal/etc/di.xml @@ -31,4 +31,14 @@ </argument> </arguments> </type> + <virtualType name="Magento\Paypal\Model\PayflowadvancedFactory" type="Magento\Paypal\Model\PayflowlinkFactory"> + <arguments> + <argument name="instanceName" xsi:type="string">Magento\Paypal\Model\Payflowadvanced</argument> + </arguments> + </virtualType> + <type name="Magento\Paypal\Controller\Payflowadvanced"> + <arguments> + <argument name="payflowModelFactory" xsi:type="object">Magento\Paypal\Model\PayflowadvancedFactory</argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Paypal/view/frontend/js/opcheckout.js b/app/code/Magento/Paypal/view/frontend/js/opcheckout.js new file mode 100644 index 00000000000..b92f15c8a54 --- /dev/null +++ b/app/code/Magento/Paypal/view/frontend/js/opcheckout.js @@ -0,0 +1,46 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +/*jshint browser:true jquery:true*/ +(function ($, window) { + "use strict"; + $.widget('mage.opcheckoutPaypalIframe', $.mage.opcheckout, { + options: { + review: { + submitContainer: '#checkout-review-submit' + } + }, + + _create: function() { + var events = {}; + events['contentUpdated' + this.options.review.container] = function() { + var paypalIframe = this.element.find(this.options.review.container) + .find('[data-container="paypal-iframe"]'); + if (paypalIframe.length) { + paypalIframe.show(); + $(this.options.review.submitContainer).hide(); + } + }; + this._on(events); + } + }); +})(jQuery, window); diff --git a/app/code/Magento/Paypal/view/frontend/layout/checkout_onepage_index.xml b/app/code/Magento/Paypal/view/frontend/layout/checkout_onepage_index.xml new file mode 100644 index 00000000000..276658cf8cb --- /dev/null +++ b/app/code/Magento/Paypal/view/frontend/layout/checkout_onepage_index.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceContainer name="content"> + <block class="Magento\View\Element\Template" name="checkout.onepage.paypal.js" after="checkout.onepage" template="Magento_Paypal::onepage.phtml"/> + </referenceContainer> +</layout> diff --git a/app/code/Magento/Paypal/view/frontend/onepage.phtml b/app/code/Magento/Paypal/view/frontend/onepage.phtml new file mode 100644 index 00000000000..937f731c16e --- /dev/null +++ b/app/code/Magento/Paypal/view/frontend/onepage.phtml @@ -0,0 +1,37 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +?> +<script type="text/javascript"> + (function($) { + head.js( + "<?php echo $this->getViewFileUrl('Magento_Paypal::js/opcheckout.js')?>", + function() { + $('#checkoutSteps') + .accordion({ + activeSelector: '#opc-<?php echo $this->getActiveStep() ?>' + }).opcheckoutPaypalIframe(); + } + ); + })(jQuery); +</script> diff --git a/app/code/Magento/Persistent/Controller/Index.php b/app/code/Magento/Persistent/Controller/Index.php index 135f8b2f347..6d1ce25c31d 100644 --- a/app/code/Magento/Persistent/Controller/Index.php +++ b/app/code/Magento/Persistent/Controller/Index.php @@ -155,7 +155,6 @@ class Index extends \Magento\App\Action\Action /** * Add appropriate session message and redirect to shopping cart - * used for google checkout and paypal express checkout * * @return void */ diff --git a/app/code/Magento/Persistent/Helper/Data.php b/app/code/Magento/Persistent/Helper/Data.php index b764a90f033..b08cde4220f 100644 --- a/app/code/Magento/Persistent/Helper/Data.php +++ b/app/code/Magento/Persistent/Helper/Data.php @@ -80,7 +80,6 @@ class Data extends \Magento\Core\Helper\Data * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Locale $locale * @param \Magento\App\State $appState * @param \Magento\Core\Helper\Url $coreUrl * @param \Magento\Checkout\Helper\Data $checkoutData @@ -93,7 +92,6 @@ class Data extends \Magento\Core\Helper\Data \Magento\App\Helper\Context $context, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Locale $locale, \Magento\App\State $appState, \Magento\Core\Helper\Url $coreUrl, \Magento\Checkout\Helper\Data $checkoutData, @@ -112,7 +110,6 @@ class Data extends \Magento\Core\Helper\Data $context, $coreStoreConfig, $storeManager, - $locale, $appState, $dbCompatibleMode ); diff --git a/app/code/Magento/Persistent/Helper/Session.php b/app/code/Magento/Persistent/Helper/Session.php index 320f89ba776..07f7f2a9223 100644 --- a/app/code/Magento/Persistent/Helper/Session.php +++ b/app/code/Magento/Persistent/Helper/Session.php @@ -83,7 +83,6 @@ class Session extends \Magento\Core\Helper\Data * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Locale $locale * @param \Magento\App\State $appState * @param Data $persistentData * @param \Magento\Checkout\Model\Session $checkoutSession @@ -95,7 +94,6 @@ class Session extends \Magento\Core\Helper\Data \Magento\App\Helper\Context $context, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Locale $locale, \Magento\App\State $appState, \Magento\Persistent\Helper\Data $persistentData, \Magento\Checkout\Model\Session $checkoutSession, @@ -111,7 +109,6 @@ class Session extends \Magento\Core\Helper\Data $context, $coreStoreConfig, $storeManager, - $locale, $appState, $dbCompatibleMode ); diff --git a/app/code/Magento/Persistent/Model/Observer.php b/app/code/Magento/Persistent/Model/Observer.php index c612083c82f..3c637209b35 100644 --- a/app/code/Magento/Persistent/Model/Observer.php +++ b/app/code/Magento/Persistent/Model/Observer.php @@ -140,6 +140,11 @@ class Observer */ protected $messageManager; + /** + * @var \Magento\Checkout\Helper\ExpressRedirect + */ + protected $_expressRedirectHelper; + /** * Construct * @@ -158,6 +163,7 @@ class Observer * @param \Magento\View\LayoutInterface $layout * @param \Magento\Escaper $escaper * @param \Magento\Message\ManagerInterface $messageManager + * @param \Magento\Checkout\Helper\ExpressRedirect $expressRedirectHelper * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -176,7 +182,8 @@ class Observer \Magento\App\RequestInterface $requestHttp, \Magento\View\LayoutInterface $layout, \Magento\Escaper $escaper, - \Magento\Message\ManagerInterface $messageManager + \Magento\Message\ManagerInterface $messageManager, + \Magento\Checkout\Helper\ExpressRedirect $expressRedirectHelper ) { $this->_eventManager = $eventManager; $this->_persistentSession = $persistentSession; @@ -193,6 +200,7 @@ class Observer $this->_layout = $layout; $this->_escaper = $escaper; $this->messageManager = $messageManager; + $this->_expressRedirectHelper = $expressRedirectHelper; } /** @@ -471,29 +479,30 @@ class Observer } /** - * Prevent express checkout with Google checkout and PayPal Express checkout + * Prevent express checkout * * @param \Magento\Event\Observer $observer * @return void */ - public function preventExpressCheckout($observer) + public function preventExpressCheckout(\Magento\Event\Observer $observer) { if (!$this->_isLoggedOut()) { return; } - /** @var $controllerAction \Magento\App\Action\Action */ + /** @var $controllerAction \Magento\Checkout\Controller\Express\RedirectLoginInterface*/ $controllerAction = $observer->getEvent()->getControllerAction(); - if (method_exists($controllerAction, 'redirectLogin')) { - $this->messageManager->addNotice(__('To check out, please log in using your email address.')); - $controllerAction->redirectLogin(); - if ($controllerAction instanceof \Magento\GoogleCheckout\Controller\Redirect - || $controllerAction instanceof \Magento\Paypal\Controller\Express\AbstractExpress - ) { - $this->_customerSession - ->setBeforeAuthUrl($this->_url->getUrl('persistent/index/expressCheckout')); - } + if (!$controllerAction + || !$controllerAction instanceof \Magento\Checkout\Controller\Express\RedirectLoginInterface + || $controllerAction->getRedirectActionName() != $controllerAction->getRequest()->getActionName() + ) { + return; } + + $this->messageManager->addNotice(__('To check out, please log in using your email address.')); + $customerBeforeAuthUrl = $this->_url->getUrl('persistent/index/expressCheckout'); + + $this->_expressRedirectHelper->redirectLogin($controllerAction, $customerBeforeAuthUrl); } /** diff --git a/app/code/Magento/Persistent/etc/frontend/events.xml b/app/code/Magento/Persistent/etc/frontend/events.xml index 926499b7bc9..42fad18cee2 100644 --- a/app/code/Magento/Persistent/etc/frontend/events.xml +++ b/app/code/Magento/Persistent/etc/frontend/events.xml @@ -48,6 +48,7 @@ <observer name="persistent_session" instance="Magento\Persistent\Model\Observer\Session" method="renewCookie" /> <observer name="persistent_quote" instance="Magento\Persistent\Model\Observer" method="checkExpirePersistentQuote" /> <observer name="persistent_customer" instance="Magento\Persistent\Model\Observer" method="emulateCustomer" /> + <observer name="persistent_checkout" instance="Magento\Persistent\Model\Observer" method="preventExpressCheckout" /> </event> <event name="checkout_allow_guest"> <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="disableGuestCheckout" /> @@ -73,18 +74,6 @@ <event name="customer_register_success"> <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="removePersistentCookie" /> </event> - <event name="controller_action_predispatch_paypal_express_start"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="preventExpressCheckout" /> - </event> - <event name="controller_action_predispatch_paypal_payflowexpress_start"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="preventExpressCheckout" /> - </event> - <event name="controller_action_predispatch_googlecheckout_redirect_checkout"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="preventExpressCheckout" /> - </event> - <event name="controller_action_predispatch_multishipping_checkout_index"> - <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="preventExpressCheckout" /> - </event> <event name="render_block"> <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="applyBlockPersistentData" /> </event> diff --git a/app/code/Magento/Persistent/etc/module.xml b/app/code/Magento/Persistent/etc/module.xml old mode 100755 new mode 100644 index e441ac659a0..a7bf80f8050 --- a/app/code/Magento/Persistent/etc/module.xml +++ b/app/code/Magento/Persistent/etc/module.xml @@ -32,8 +32,6 @@ <module name="Magento_Checkout"/> <module name="Magento_Core"/> <module name="Magento_Customer"/> - <module name="Magento_GoogleCheckout"/> - <module name="Magento_Paypal"/> <module name="Magento_Sales"/> <module name="Magento_Cron"/> </depends> diff --git a/app/code/Magento/ProductAlert/Model/Observer.php b/app/code/Magento/ProductAlert/Model/Observer.php index 4c029e65954..7c975c83a47 100644 --- a/app/code/Magento/ProductAlert/Model/Observer.php +++ b/app/code/Magento/ProductAlert/Model/Observer.php @@ -112,7 +112,7 @@ class Observer protected $_productFactory; /** - * @var \Magento\Core\Model\DateFactory + * @var \Magento\Stdlib\DateTime\DateTimeFactory */ protected $_dateFactory; @@ -143,7 +143,7 @@ class Observer * @param \Magento\ProductAlert\Model\Resource\Price\CollectionFactory $priceColFactory * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Core\Model\DateFactory $dateFactory + * @param \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory * @param \Magento\ProductAlert\Model\Resource\Stock\CollectionFactory $stockColFactory * @param \Magento\TranslateInterface $translate * @param \Magento\Mail\Template\TransportBuilder $transportBuilder @@ -156,7 +156,7 @@ class Observer \Magento\ProductAlert\Model\Resource\Price\CollectionFactory $priceColFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Core\Model\DateFactory $dateFactory, + \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory, \Magento\ProductAlert\Model\Resource\Stock\CollectionFactory $stockColFactory, \Magento\TranslateInterface $translate, \Magento\Mail\Template\TransportBuilder $transportBuilder, diff --git a/app/code/Magento/ProductAlert/Model/Resource/Price.php b/app/code/Magento/ProductAlert/Model/Resource/Price.php index fe116f9801a..a562819104c 100644 --- a/app/code/Magento/ProductAlert/Model/Resource/Price.php +++ b/app/code/Magento/ProductAlert/Model/Resource/Price.php @@ -32,17 +32,17 @@ namespace Magento\ProductAlert\Model\Resource; class Price extends \Magento\ProductAlert\Model\Resource\AbstractResource { /** - * @var \Magento\Core\Model\DateFactory + * @var \Magento\Stdlib\DateTime\DateTimeFactory */ protected $_dateFactory; /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\DateFactory $dateFactory + * @param \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\DateFactory $dateFactory + \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory ) { $this->_dateFactory = $dateFactory; parent::__construct($resource); diff --git a/app/code/Magento/ProductAlert/Model/Resource/Stock.php b/app/code/Magento/ProductAlert/Model/Resource/Stock.php index af59d24e1e8..d98e8342dcd 100644 --- a/app/code/Magento/ProductAlert/Model/Resource/Stock.php +++ b/app/code/Magento/ProductAlert/Model/Resource/Stock.php @@ -32,17 +32,17 @@ namespace Magento\ProductAlert\Model\Resource; class Stock extends \Magento\ProductAlert\Model\Resource\AbstractResource { /** - * @var \Magento\Core\Model\DateFactory + * @var \Magento\Stdlib\DateTime\DateTimeFactory */ protected $_dateFactory; /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\DateFactory $dateFactory + * @param \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\DateFactory $dateFactory + \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory ) { $this->_dateFactory = $dateFactory; parent::__construct($resource); diff --git a/app/code/Magento/RecurringProfile/Block/Adminhtml/Customer/Edit/Tab/RecurringProfile.php b/app/code/Magento/RecurringProfile/Block/Adminhtml/Customer/Edit/Tab/RecurringProfile.php index 1e0a9d3bacf..e8ee4443408 100644 --- a/app/code/Magento/RecurringProfile/Block/Adminhtml/Customer/Edit/Tab/RecurringProfile.php +++ b/app/code/Magento/RecurringProfile/Block/Adminhtml/Customer/Edit/Tab/RecurringProfile.php @@ -27,7 +27,8 @@ */ namespace Magento\RecurringProfile\Block\Adminhtml\Customer\Edit\Tab; -use Magento\Customer\Controller\Adminhtml\Index as CustomerController; +use Magento\Customer\Controller\RegistryConstants; + class RecurringProfile extends \Magento\RecurringProfile\Block\Adminhtml\Profile\Grid implements \Magento\Backend\Block\Widget\Tab\TabInterface @@ -66,13 +67,13 @@ class RecurringProfile ) { $this->_coreRegistry = $coreRegistry; - // @todo remove usage of REGISTRY_CURRENT_CUSTOMER in advantage of REGISTRY_CURRENT_CUSTOMER_ID - $currentCustomer = $this->_coreRegistry->registry(CustomerController::REGISTRY_CURRENT_CUSTOMER); + // @todo remove usage of CURRENT_CUSTOMER in advantage of CURRENT_CUSTOMER_ID + $currentCustomer = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER); if ($currentCustomer) { $this->_currentCustomerId = $currentCustomer->getId(); } else { $this->_currentCustomerId = $this->_coreRegistry->registry( - CustomerController::REGISTRY_CURRENT_CUSTOMER_ID + RegistryConstants::CURRENT_CUSTOMER_ID ); } diff --git a/app/code/Magento/RecurringProfile/Block/Catalog/Product/View/Profile.php b/app/code/Magento/RecurringProfile/Block/Catalog/Product/View/Profile.php index ee7809e0ad2..d26c84d6080 100644 --- a/app/code/Magento/RecurringProfile/Block/Catalog/Product/View/Profile.php +++ b/app/code/Magento/RecurringProfile/Block/Catalog/Product/View/Profile.php @@ -99,8 +99,12 @@ class Profile extends \Magento\View\Element\Template ->setName(\Magento\RecurringProfile\Model\RecurringProfile::BUY_REQUEST_START_DATETIME) ->setClass('datetime-picker input-text') ->setImage($this->getViewFileUrl('Magento_Core::calendar.gif')) - ->setDateFormat($this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT)) - ->setTimeFormat($this->_locale->getTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT)); + ->setDateFormat($this->_localeDate->getDateFormat( + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT + )) + ->setTimeFormat($this->_localeDate->getTimeFormat( + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT + )); return $calendar->getHtml(); } return ''; diff --git a/app/code/Magento/RecurringProfile/Block/Plugin/Payment.php b/app/code/Magento/RecurringProfile/Block/Plugin/Payment.php index 114efdf8768..e8b2e26fca6 100644 --- a/app/code/Magento/RecurringProfile/Block/Plugin/Payment.php +++ b/app/code/Magento/RecurringProfile/Block/Plugin/Payment.php @@ -49,13 +49,16 @@ class Payment /** * Add hasRecurringItems option * + * @param \Magento\Checkout\Block\Onepage\Payment $subject * @param array $result + * * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterGetOptions(array $result) + public function afterGetOptions(\Magento\Checkout\Block\Onepage\Payment $subject, array $result) { $quote = $this->session->getQuote(); $result['hasRecurringItems'] = $quote && $this->filter->hasRecurringItems($quote); return $result; } -} \ No newline at end of file +} diff --git a/app/code/Magento/RecurringProfile/Controller/Adminhtml/RecurringProfile.php b/app/code/Magento/RecurringProfile/Controller/Adminhtml/RecurringProfile.php index ae2a81317f9..cc5d7edb731 100644 --- a/app/code/Magento/RecurringProfile/Controller/Adminhtml/RecurringProfile.php +++ b/app/code/Magento/RecurringProfile/Controller/Adminhtml/RecurringProfile.php @@ -31,7 +31,7 @@ namespace Magento\RecurringProfile\Controller\Adminhtml; use Magento\App\Action\NotFoundException; use Magento\Core\Exception as CoreException; -use Magento\Customer\Controller\Adminhtml\Index as CustomerController; +use Magento\Customer\Controller\RegistryConstants; class RecurringProfile extends \Magento\Backend\App\Action { @@ -224,7 +224,7 @@ class RecurringProfile extends \Magento\Backend\App\Action $customerId = (int)$this->getRequest()->getParam(self::PARAM_CUSTOMER_ID); if ($customerId) { - $this->_coreRegistry->register(CustomerController::REGISTRY_CURRENT_CUSTOMER_ID, $customerId); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customerId); } $this->_view->loadLayout(false); diff --git a/app/code/Magento/RecurringProfile/Model/Observer.php b/app/code/Magento/RecurringProfile/Model/Observer.php index 2d5254bad3a..33b0d698787 100644 --- a/app/code/Magento/RecurringProfile/Model/Observer.php +++ b/app/code/Magento/RecurringProfile/Model/Observer.php @@ -29,13 +29,6 @@ namespace Magento\RecurringProfile\Model; */ class Observer { - /** - * Locale model - * - * @var \Magento\Core\Model\LocaleInterface - */ - protected $_locale; - /** * Store manager * @@ -71,16 +64,14 @@ class Observer protected $_quoteImporter; /** - * @param \Magento\Core\Model\LocaleInterface $locale * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\RecurringProfile\Model\RecurringProfileFactory $recurringProfileFactory + * @param RecurringProfileFactory $recurringProfileFactory * @param \Magento\View\Element\BlockFactory $blockFactory * @param \Magento\RecurringProfile\Block\Fields $fields * @param \Magento\Checkout\Model\Session $checkoutSession * @param QuoteImporter $quoteImporter */ public function __construct( - \Magento\Core\Model\LocaleInterface $locale, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\RecurringProfile\Model\RecurringProfileFactory $recurringProfileFactory, \Magento\View\Element\BlockFactory $blockFactory, @@ -88,7 +79,6 @@ class Observer \Magento\Checkout\Model\Session $checkoutSession, \Magento\RecurringProfile\Model\QuoteImporter $quoteImporter ) { - $this->_locale = $locale; $this->_storeManager = $storeManager; $this->_recurringProfileFactory = $recurringProfileFactory; $this->_blockFactory = $blockFactory; @@ -114,7 +104,7 @@ class Observer } /** @var \Magento\RecurringProfile\Model\RecurringProfile $profile */ - $profile = $this->_recurringProfileFactory->create(['locale' => $this->_locale]); + $profile = $this->_recurringProfileFactory->create(); $profile->setStore($this->_storeManager->getStore()) ->importBuyRequest($buyRequest) ->importProduct($product); diff --git a/app/code/Magento/RecurringProfile/Model/Profile.php b/app/code/Magento/RecurringProfile/Model/Profile.php index edd3462e72b..a8462179c44 100644 --- a/app/code/Magento/RecurringProfile/Model/Profile.php +++ b/app/code/Magento/RecurringProfile/Model/Profile.php @@ -140,7 +140,8 @@ class Profile extends \Magento\RecurringProfile\Model\RecurringProfile * @param \Magento\Payment\Helper\Data $paymentData * @param PeriodUnits $periodUnits * @param \Magento\RecurringProfile\Block\Fields $fields - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\Order\AddressFactory $addressFactory * @param \Magento\Sales\Model\Order\PaymentFactory $paymentFactory @@ -158,7 +159,8 @@ class Profile extends \Magento\RecurringProfile\Model\RecurringProfile \Magento\Payment\Helper\Data $paymentData, \Magento\RecurringProfile\Model\PeriodUnits $periodUnits, \Magento\RecurringProfile\Block\Fields $fields, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\Order\AddressFactory $addressFactory, \Magento\Sales\Model\Order\PaymentFactory $paymentFactory, @@ -181,7 +183,8 @@ class Profile extends \Magento\RecurringProfile\Model\RecurringProfile $paymentData, $periodUnits, $fields, - $locale, + $localeDate, + $localeResolver, $resource, $resourceCollection, $data diff --git a/app/code/Magento/RecurringProfile/Model/RecurringProfile.php b/app/code/Magento/RecurringProfile/Model/RecurringProfile.php index a9367259a96..9dd7d54c635 100644 --- a/app/code/Magento/RecurringProfile/Model/RecurringProfile.php +++ b/app/code/Magento/RecurringProfile/Model/RecurringProfile.php @@ -47,7 +47,7 @@ class RecurringProfile extends \Magento\Core\Model\AbstractModel /** * - * @var \Magento\Payment\Model\Method\AbstractMethod + * @var \Magento\Payment\Model\MethodInterface */ protected $_methodInstance = null; @@ -83,9 +83,14 @@ class RecurringProfile extends \Magento\Core\Model\AbstractModel protected $_fields; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; + + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; /** * @param \Magento\Model\Context $context @@ -93,10 +98,13 @@ class RecurringProfile extends \Magento\Core\Model\AbstractModel * @param \Magento\Payment\Helper\Data $paymentData * @param PeriodUnits $periodUnits * @param \Magento\RecurringProfile\Block\Fields $fields - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Model\Context $context, @@ -104,7 +112,8 @@ class RecurringProfile extends \Magento\Core\Model\AbstractModel \Magento\Payment\Helper\Data $paymentData, \Magento\RecurringProfile\Model\PeriodUnits $periodUnits, \Magento\RecurringProfile\Block\Fields $fields, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -113,7 +122,8 @@ class RecurringProfile extends \Magento\Core\Model\AbstractModel parent::__construct($context, $registry, $resource, $resourceCollection, $data); $this->_periodUnits = $periodUnits; $this->_fields = $fields; - $this->_locale = $locale; + $this->_localeDate = $localeDate; + $this->_localeResolver = $localeResolver; } /** @@ -220,11 +230,11 @@ class RecurringProfile extends \Magento\Core\Model\AbstractModel /** * Setter for payment method instance * - * @param \Magento\Payment\Model\Method\AbstractMethod $object + * @param \Magento\Payment\Model\MethodInterface $object * @return \Magento\RecurringProfile\Model\RecurringProfile * @throws \Exception */ - public function setMethodInstance(\Magento\Payment\Model\Method\AbstractMethod $object) + public function setMethodInstance(\Magento\Payment\Model\MethodInterface $object) { if ($object instanceof \Magento\Payment\Model\Recurring\Profile\MethodInterface) { $this->_methodInstance = $object; @@ -247,15 +257,17 @@ class RecurringProfile extends \Magento\Core\Model\AbstractModel { $startDate = $buyRequest->getData(self::BUY_REQUEST_START_DATETIME); if ($startDate) { - if (!$this->_locale || !$this->_store) { + if (!$this->_localeDate || !$this->_store) { throw new \Exception('Locale and store instances must be set for this operation.'); } - $dateFormat = $this->_locale->getDateTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); - $localeCode = $this->_locale->getLocaleCode(); + $dateFormat = $this->_localeDate->getDateTimeFormat( + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT + ); + $localeCode = $this->_localeResolver->getLocaleCode(); if (!\Zend_Date::isDate($startDate, $dateFormat, $localeCode)) { throw new \Magento\Core\Exception(__('The recurring profile start date has invalid format.')); } - $utcTime = $this->_locale->utcDate($this->_store, $startDate, true, $dateFormat) + $utcTime = $this->_localeDate->utcDate($this->_store, $startDate, true, $dateFormat) ->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); $this->setStartDatetime($utcTime)->setImportedStartDatetime($startDate); } @@ -286,7 +298,7 @@ class RecurringProfile extends \Magento\Core\Model\AbstractModel $options = unserialize($options->getValue()); if (is_array($options)) { if (isset($options['start_datetime'])) { - $startDatetime = new \Zend_Date($options['start_datetime'], + $startDatetime = new \Magento\Stdlib\DateTime\Date($options['start_datetime'], \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); $this->setNearestStartDatetime($startDatetime); } @@ -324,15 +336,15 @@ class RecurringProfile extends \Magento\Core\Model\AbstractModel /** * Determine nearest possible profile start date * - * @param \Zend_Date $minAllowed + * @param \Magento\Stdlib\DateTime\DateInterface $minAllowed * @return \Magento\RecurringProfile\Model\RecurringProfile */ - protected function setNearestStartDatetime(\Zend_Date $minAllowed = null) + protected function setNearestStartDatetime(\Magento\Stdlib\DateTime\DateInterface $minAllowed = null) { // TODO: implement proper logic with invoking payment method instance $date = $minAllowed; if (!$date || $date->getTimestamp() < time()) { - $date = new \Zend_Date(time()); + $date = new \Magento\Stdlib\DateTime\Date(time()); } $this->setStartDatetime($date->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT)); return $this; @@ -346,12 +358,12 @@ class RecurringProfile extends \Magento\Core\Model\AbstractModel public function exportStartDatetime() { $datetime = $this->getStartDatetime(); - if (!$datetime || !$this->_locale || !$this->_store) { + if (!$datetime || !$this->_localeDate || !$this->_store) { return ''; } - $date = $this->_locale->storeDate($this->_store, strtotime($datetime), true); + $date = $this->_localeDate->scopeDate($this->_store, strtotime($datetime), true); return $date->toString( - $this->_locale->getDateTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT) + $this->_localeDate->getDateTimeFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT) ); } @@ -445,7 +457,9 @@ class RecurringProfile extends \Magento\Core\Model\AbstractModel // automatically determine start date, if not set if ($this->getStartDatetime()) { - $date = new \Zend_Date($this->getStartDatetime(), \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); + $date = new \Magento\Stdlib\DateTime\Date( + $this->getStartDatetime(), \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT + ); $this->setNearestStartDatetime($date); } else { $this->setNearestStartDatetime(); @@ -457,7 +471,7 @@ class RecurringProfile extends \Magento\Core\Model\AbstractModel /** * Return payment method instance * - * @return \Magento\Payment\Model\Method\AbstractMethod + * @return \Magento\Payment\Model\MethodInterface */ protected function getMethodInstance() { diff --git a/app/code/Magento/RecurringProfile/etc/frontend/events.xml b/app/code/Magento/RecurringProfile/etc/frontend/events.xml index 78d849fb7c7..612b7d64d29 100644 --- a/app/code/Magento/RecurringProfile/etc/frontend/events.xml +++ b/app/code/Magento/RecurringProfile/etc/frontend/events.xml @@ -24,7 +24,7 @@ */ --> <config> - <event name="catalog_product_type_prepare_cart_options"> + <event name="catalog_product_type_prepare_full_options"> <observer name="recurring_profile_prepare_options" instance="Magento\RecurringProfile\Model\Observer" method="prepareProductRecurringProfileOptions" /> </event> </config> diff --git a/app/code/Magento/Reports/Block/Adminhtml/Config/Form/Field/YtdStart.php b/app/code/Magento/Reports/Block/Adminhtml/Config/Form/Field/YtdStart.php index 5e2f21d66c0..1a28c58b133 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Config/Form/Field/YtdStart.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Config/Form/Field/YtdStart.php @@ -42,7 +42,7 @@ class YtdStart extends \Magento\Backend\Block\System\Config\Form\Field { $_months = array(); for ($i = 1; $i <= 12; $i++) { - $_months[$i] = $this->_locale->date(mktime(null, null, null, $i)) + $_months[$i] = $this->_localeDate->date(mktime(null, null, null, $i)) ->get(\Zend_Date::MONTH_NAME); } diff --git a/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php b/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php index 686b0a902cc..35a1553cb07 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php @@ -140,7 +140,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic $form->setHtmlIdPrefix($htmlIdPrefix); $fieldset = $form->addFieldset('base_fieldset', array('legend'=>__('Filter'))); - $dateFormat = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $dateFormat = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); $fieldset->addField('store_ids', 'hidden', array( 'name' => 'store_ids' diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid.php index 7e59e14fad9..c07797ea24f 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid.php @@ -112,14 +112,14 @@ class Grid extends \Magento\Backend\Block\Widget\Grid if (!isset($data['report_from'])) { // getting all reports from 2001 year - $date = new \Zend_Date(mktime(0, 0, 0, 1, 1, 2001)); - $data['report_from'] = $date->toString($this->_locale->getDateFormat('short')); + $date = new \Magento\Stdlib\DateTime\Date(mktime(0, 0, 0, 1, 1, 2001)); + $data['report_from'] = $date->toString($this->_localeDate->getDateFormat('short')); } if (!isset($data['report_to'])) { // getting all reports from 2001 year - $date = new \Zend_Date(); - $data['report_to'] = $date->toString($this->_locale->getDateFormat('short')); + $date = new \Magento\Stdlib\DateTime\Date(); + $data['report_to'] = $date->toString($this->_localeDate->getDateFormat('short')); } $this->_setFilterValues($data); @@ -139,8 +139,8 @@ class Grid extends \Magento\Backend\Block\Widget\Grid * Validate from and to date */ try { - $from = $this->_locale->date($this->getFilter('report_from'), \Zend_Date::DATE_SHORT, null, false); - $to = $this->_locale->date($this->getFilter('report_to'), \Zend_Date::DATE_SHORT, null, false); + $from = $this->_localeDate->date($this->getFilter('report_from'), \Zend_Date::DATE_SHORT, null, false); + $to = $this->_localeDate->date($this->getFilter('report_to'), \Zend_Date::DATE_SHORT, null, false); $collection->setInterval($from, $to); } @@ -291,7 +291,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid */ public function getDateFormat() { - return $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + return $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); } /** diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php index dd167bac503..e526ea2b002 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php @@ -50,7 +50,7 @@ class Currency $data = floatval($data) * $this->_getRate($row); $data = sprintf("%f", $data); - $data = $this->_locale->currency($currency_code)->toCurrency($data); + $data = $this->_localeCurrency->getCurrency($currency_code)->toCurrency($data); return $data; } } diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Grid/Column/Renderer/Date.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Grid/Column/Renderer/Date.php index 43f26eeefc9..3d0b3763b0f 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Grid/Column/Renderer/Date.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Grid/Column/Renderer/Date.php @@ -31,6 +31,20 @@ namespace Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer; class Date extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Date { + /** + * @param \Magento\Backend\Block\Context $context + * @param \Magento\Locale\ResolverInterface $localeResolver + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Context $context, + \Magento\Locale\ResolverInterface $localeResolver, + array $data = array() + ) { + parent::__construct($context, $data); + $this->_localeResolver = $localeResolver; + } + /** * Retrieve date format * @@ -42,7 +56,7 @@ class Date if (!$format) { if (is_null(self::$_format)) { try { - $localeCode = $this->_locale->getLocaleCode(); + $localeCode = $this->_localeResolver->getLocaleCode(); $localeData = new \Zend_Locale_Data; switch ($this->getColumn()->getPeriodType()) { case 'month' : @@ -54,8 +68,8 @@ class Date break; default: - self::$_format = $this->_locale->getDateFormat( - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM + self::$_format = $this->_localeDate->getDateFormat( + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM ); break; } @@ -93,13 +107,13 @@ class Date $format = $this->_getFormat(); try { $data = ($this->getColumn()->getGmtoffset()) - ? $this->_locale->date($data, $dateFormat)->toString($format) - : $this->_locale->date($data, \Zend_Date::ISO_8601, null, false)->toString($format); + ? $this->_localeDate->date($data, $dateFormat)->toString($format) + : $this->_localeDate->date($data, \Zend_Date::ISO_8601, null, false)->toString($format); } catch (\Exception $e) { $data = ($this->getColumn()->getTimezone()) - ? $this->_locale->date($data, $dateFormat)->toString($format) - : $this->_locale->date($data, $dateFormat, null, false)->toString($format); + ? $this->_localeDate->date($data, $dateFormat)->toString($format) + : $this->_localeDate->date($data, $dateFormat, null, false)->toString($format); } return $data; } diff --git a/app/code/Magento/Reports/Block/Product/Viewed.php b/app/code/Magento/Reports/Block/Product/Viewed.php index c905ee8b5e2..627a84538fe 100644 --- a/app/code/Magento/Reports/Block/Product/Viewed.php +++ b/app/code/Magento/Reports/Block/Product/Viewed.php @@ -30,7 +30,7 @@ namespace Magento\Reports\Block\Product; * * @author Magento Core Team <core@magentocommerce.com> */ -class Viewed extends \Magento\Reports\Block\Product\AbstractProduct +class Viewed extends \Magento\Reports\Block\Product\AbstractProduct implements \Magento\View\Block\IdentityInterface { const XML_PATH_RECENTLY_VIEWED_COUNT = 'catalog/recently_products/viewed_count'; @@ -82,4 +82,18 @@ class Viewed extends \Magento\Reports\Block\Product\AbstractProduct $this->setRecentlyViewedProducts($this->getItemsCollection()); return parent::_toHtml(); } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + $identities = array(); + foreach ($this->getItemsCollection() as $item) { + $identities = array_merge($identities, $item->getIdentities()); + } + return $identities; + } } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php index ab78ce3bbba..588a44fb96f 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php @@ -42,19 +42,19 @@ abstract class AbstractReport extends \Magento\Backend\App\Action protected $_fileFactory; /** - * @var \Magento\Core\Filter\Date + * @var \Magento\Stdlib\DateTime\Filter\Date */ protected $_dateFilter; /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\App\Response\Http\FileFactory $fileFactory - * @param \Magento\Core\Filter\Date $dateFilter + * @param \Magento\Stdlib\DateTime\Filter\Date $dateFilter */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\App\Response\Http\FileFactory $fileFactory, - \Magento\Core\Filter\Date $dateFilter + \Magento\Stdlib\DateTime\Filter\Date $dateFilter ) { parent::__construct($context); $this->_fileFactory = $fileFactory; @@ -139,11 +139,15 @@ abstract class AbstractReport extends \Magento\Backend\App\Action protected function _showLastExecutionTime($flagCode, $refreshCode) { $flag = $this->_objectManager->create('Magento\Reports\Model\Flag')->setReportFlagCode($flagCode)->loadSelf(); - $updatedAt = ($flag->hasData()) - ? $this->_objectManager->get('Magento\Core\Model\LocaleInterface')->storeDate( - 0, new \Zend_Date($flag->getLastUpdate(), \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT), true - ) - : 'undefined'; + $updatedAt = 'undefined'; + if ($flag->hasData()) { + $date = new \Magento\Stdlib\DateTime\Date( + $flag->getLastUpdate(), + \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT + ); + $updatedAt = $this->_objectManager->get('Magento\Stdlib\DateTime\TimezoneInterface') + ->storeDate(0, $date, true); + } $refreshStatsLink = $this->getUrl('reports/report_statistics'); $directRefreshLink = $this->getUrl('reports/report_statistics/refreshRecent', array('code' => $refreshCode)); diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php index 81ab1acf65c..4f23c1e2ba1 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php @@ -46,15 +46,15 @@ class Statistics extends \Magento\Backend\App\Action protected $_adminSession = null; /** - * @var \Magento\Core\Filter\Date + * @var \Magento\Stdlib\DateTime\Filter\Date */ protected $_dateFilter; /** * @param \Magento\Backend\App\Action\Context $context - * @param \Magento\Core\Filter\Date $dateFilter + * @param \Magento\Stdlib\DateTime\Filter\Date $dateFilter */ - public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Core\Filter\Date $dateFilter) + public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Stdlib\DateTime\Filter\Date $dateFilter) { $this->_dateFilter = $dateFilter; parent::__construct($context); @@ -154,7 +154,8 @@ class Statistics extends \Magento\Backend\App\Action { try { $collectionsNames = $this->_getCollectionNames(); - $currentDate = $this->_objectManager->get('Magento\Core\Model\LocaleInterface')->date(); + /** @var \Magento\Stdlib\DateTime\DateInterface $currentDate */ + $currentDate = $this->_objectManager->get('Magento\Stdlib\DateTime\TimezoneInterface')->date(); $date = $currentDate->subHour(25); foreach ($collectionsNames as $collectionName) { $this->_objectManager->create($collectionName)->aggregate($date); diff --git a/app/code/Magento/Reports/Helper/Data.php b/app/code/Magento/Reports/Helper/Data.php index 652eba4e87a..9a20f4267e8 100644 --- a/app/code/Magento/Reports/Helper/Data.php +++ b/app/code/Magento/Reports/Helper/Data.php @@ -70,21 +70,21 @@ class Data extends \Magento\App\Helper\AbstractHelper return $intervals; } - $start = new \Zend_Date($from, \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT); + $start = new \Magento\Stdlib\DateTime\Date($from, \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT); if ($period == self::REPORT_PERIOD_TYPE_DAY) { $dateStart = $start; } if ($period == self::REPORT_PERIOD_TYPE_MONTH) { - $dateStart = new \Zend_Date(date("Y-m", $start->getTimestamp()), DateTime::DATE_INTERNAL_FORMAT); + $dateStart = new \Magento\Stdlib\DateTime\Date(date("Y-m", $start->getTimestamp()), DateTime::DATE_INTERNAL_FORMAT); } if ($period == self::REPORT_PERIOD_TYPE_YEAR) { - $dateStart = new \Zend_Date(date("Y", $start->getTimestamp()), DateTime::DATE_INTERNAL_FORMAT); + $dateStart = new \Magento\Stdlib\DateTime\Date(date("Y", $start->getTimestamp()), DateTime::DATE_INTERNAL_FORMAT); } - $dateEnd = new \Zend_Date($to, DateTime::DATE_INTERNAL_FORMAT); + $dateEnd = new \Magento\Stdlib\DateTime\Date($to, DateTime::DATE_INTERNAL_FORMAT); while ($dateStart->compare($dateEnd) <= 0) { switch ($period) { diff --git a/app/code/Magento/Reports/Model/DateFactory.php b/app/code/Magento/Reports/Model/DateFactory.php index 8c016998060..45804dcd6a5 100644 --- a/app/code/Magento/Reports/Model/DateFactory.php +++ b/app/code/Magento/Reports/Model/DateFactory.php @@ -27,15 +27,15 @@ namespace Magento\Reports\Model; class DateFactory { /** - * @param string|integer|\Zend_Date|array $date OPTIONAL Date value or value of date part to set + * @param string|integer|\Magento\Stdlib\DateTime\DateInterface|array $date OPTIONAL Date value or value of date part to set * ,depending on $part. If null the actual time is set * @param string $part OPTIONAL Defines the input format of $date * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input - * @return \Zend_Date + * @return \Magento\Stdlib\DateTime\Date */ public function create($date = null, $part = null, $locale = null) { - return new \Zend_Date($date, $part, $locale); + return new \Magento\Stdlib\DateTime\Date($date, $part, $locale); } } diff --git a/app/code/Magento/Reports/Model/Event.php b/app/code/Magento/Reports/Model/Event.php index fd00071254a..1cfbe598e79 100644 --- a/app/code/Magento/Reports/Model/Event.php +++ b/app/code/Magento/Reports/Model/Event.php @@ -57,7 +57,7 @@ class Event extends \Magento\Core\Model\AbstractModel const EVENT_WISHLIST_SHARE = 6; /** - * @var \Magento\Core\Model\DateFactory + * @var \Magento\Stdlib\DateTime\DateTimeFactory */ protected $_dateFactory; @@ -69,7 +69,7 @@ class Event extends \Magento\Core\Model\AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\DateFactory $dateFactory + * @param \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory * @param \Magento\Reports\Model\Event\TypeFactory $eventTypeFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -78,7 +78,7 @@ class Event extends \Magento\Core\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\DateFactory $dateFactory, + \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory, \Magento\Reports\Model\Event\TypeFactory $eventTypeFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Reports/Model/Plugin/Log.php b/app/code/Magento/Reports/Model/Plugin/Log.php index cf92bbb705c..32997671ba0 100644 --- a/app/code/Magento/Reports/Model/Plugin/Log.php +++ b/app/code/Magento/Reports/Model/Plugin/Log.php @@ -60,12 +60,15 @@ class Log /** * Clean events by old visitors after plugin for clean method * + * @param \Magento\Log\Model\Resource\Log $subject * @param \Magento\Log\Model\Resource\Log $logResourceModel + * * @return \Magento\Log\Model\Resource\Log + * @SuppressWarnings(PHPMD.UnusedFormalParameter) * * @see Global Log Clean Settings */ - public function afterClean($logResourceModel) + public function afterClean(\Magento\Log\Model\Resource\Log $subject, $logResourceModel) { $this->_reportEvent->clean(); $this->_comparedProductIdx->clean(); diff --git a/app/code/Magento/Reports/Model/Resource/Order/Collection.php b/app/code/Magento/Reports/Model/Resource/Order/Collection.php index 1bf8d45b10b..8132e0b3b30 100644 --- a/app/code/Magento/Reports/Model/Resource/Order/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Order/Collection.php @@ -61,9 +61,9 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection protected $_storeManager; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @var \Magento\Sales\Model\Order\Config @@ -83,7 +83,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * @param \Magento\Core\Model\Resource\Helper $coreResourceHelper * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Sales\Model\Order\Config $orderConfig * @param \Magento\Sales\Model\Resource\Report\OrderFactory $reportOrderFactory * @param mixed $connection @@ -99,7 +99,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection \Magento\Core\Model\Resource\Helper $coreResourceHelper, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Sales\Model\Order\Config $orderConfig, \Magento\Sales\Model\Resource\Report\OrderFactory $reportOrderFactory, $connection = null, @@ -116,7 +116,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection ); $this->_coreStoreConfig = $coreStoreConfig; $this->_storeManager = $storeManager; - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_orderConfig = $orderConfig; $this->_reportOrderFactory = $reportOrderFactory; } @@ -373,7 +373,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection protected function _getTZRangeExpressionForAttribute($range, $attribute, $tzFrom = '+00:00', $tzTo = null) { if (null == $tzTo) { - $tzTo = $this->_locale->storeDate()->toString(\Zend_Date::GMT_DIFF_SEP); + $tzTo = $this->_localeDate->scopeDate()->toString(\Zend_Date::GMT_DIFF_SEP); } $adapter = $this->getConnection(); $expression = $this->_getRangeExpression($range); @@ -394,7 +394,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection */ public function getDateRange($range, $customStart, $customEnd, $returnObjects = false) { - $dateEnd = $this->_locale->date(); + $dateEnd = $this->_localeDate->date(); $dateStart = clone $dateEnd; // go to the end of a day @@ -409,7 +409,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection switch ($range) { case '24h': - $dateEnd = $this->_locale->date(); + $dateEnd = $this->_localeDate->date(); $dateEnd->addHour(1); $dateStart = clone $dateEnd; $dateStart->subDay(1); diff --git a/app/code/Magento/Reports/Model/Resource/Product/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Collection.php index 14bd60dd018..c39c965a2ca 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Collection.php @@ -92,7 +92,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Catalog\Model\Resource\Product $product @@ -118,7 +118,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\Resource\Url $catalogUrl, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Stdlib\DateTime $dateTime, \Magento\Catalog\Model\Resource\Product $product, @@ -145,7 +145,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $coreStoreConfig, $productOptionFactory, $catalogUrl, - $locale, + $localeDate, $customerSession, $dateTime, $connection diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php b/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php index 0a8f4cc9410..d674cd57769 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php @@ -65,7 +65,7 @@ abstract class AbstractCollection * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Log\Model\Visitor $logVisitor @@ -89,7 +89,7 @@ abstract class AbstractCollection \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\Resource\Url $catalogUrl, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Stdlib\DateTime $dateTime, \Magento\Log\Model\Visitor $logVisitor, @@ -111,7 +111,7 @@ abstract class AbstractCollection $coreStoreConfig, $productOptionFactory, $catalogUrl, - $locale, + $localeDate, $customerSession, $dateTime, $connection diff --git a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php index 264726a6f31..3e2f202b1ea 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php @@ -78,7 +78,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Catalog\Model\Resource\Product $product @@ -106,7 +106,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\Resource\Url $catalogUrl, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Stdlib\DateTime $dateTime, \Magento\Catalog\Model\Resource\Product $product, @@ -132,7 +132,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection $coreStoreConfig, $productOptionFactory, $catalogUrl, - $locale, + $localeDate, $customerSession, $dateTime, $product, diff --git a/app/code/Magento/Reports/Model/Resource/Refresh/Collection.php b/app/code/Magento/Reports/Model/Resource/Refresh/Collection.php index 44d3aded3ac..6d3ffb141b9 100644 --- a/app/code/Magento/Reports/Model/Resource/Refresh/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Refresh/Collection.php @@ -37,9 +37,9 @@ namespace Magento\Reports\Model\Resource\Refresh; class Collection extends \Magento\Data\Collection { /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @var \Magento\Reports\Model\FlagFactory @@ -48,16 +48,16 @@ class Collection extends \Magento\Data\Collection /** * @param \Magento\Core\Model\EntityFactory $entityFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Reports\Model\FlagFactory $reportsFlagFactory ) { parent::__construct($entityFactory); - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_reportsFlagFactory = $reportsFlagFactory; } @@ -65,7 +65,7 @@ class Collection extends \Magento\Data\Collection * Get if updated * * @param string $reportCode - * @return string|\Zend_Date + * @return string|\Magento\Stdlib\DateTime\DateInterface */ protected function _getUpdatedAt($reportCode) { @@ -74,8 +74,8 @@ class Collection extends \Magento\Data\Collection ->setReportFlagCode($reportCode) ->loadSelf(); return ($flag->hasData()) - ? $this->_locale - ->storeDate(0, new \Zend_Date($flag->getLastUpdate(), \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT), true) + ? $this->_localeDate + ->scopeDate(0, new \Magento\Stdlib\DateTime\Date($flag->getLastUpdate(), \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT), true) : ''; } diff --git a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php index a85ffdfb5b8..cfdbef3b4bf 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php +++ b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php @@ -49,9 +49,9 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb protected $_logger; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @var \Magento\Reports\Model\FlagFactory @@ -61,7 +61,7 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb /** * @param \Magento\App\Resource $resource * @param \Magento\Logger $logger - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator @@ -69,14 +69,14 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb public function __construct( \Magento\App\Resource $resource, \Magento\Logger $logger, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Reports\Model\FlagFactory $reportsFlagFactory, \Magento\Stdlib\DateTime $dateTime, \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator ) { parent::__construct($resource); $this->_logger = $logger; - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_reportsFlagFactory = $reportsFlagFactory; $this->dateTime = $dateTime; $this->timezoneValidator = $timezoneValidator; @@ -393,7 +393,7 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb } $periods = $this->_getTZOffsetTransitions( - $this->_locale->storeDate($store)->toString(\Zend_Date::TIMEZONE_NAME), $from, $to + $this->_localeDate->scopeDate($store)->toString(\Zend_Date::TIMEZONE_NAME), $from, $to ); if (empty($periods)) { return $column; @@ -431,17 +431,17 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb $tzTransitions = array(); try { if (!empty($from)) { - $from = new \Zend_Date($from, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); + $from = new \Magento\Stdlib\DateTime\Date($from, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); $from = $from->getTimestamp(); } - $to = new \Zend_Date($to, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); + $to = new \Magento\Stdlib\DateTime\Date($to, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); $nextPeriod = $this->_getWriteAdapter()->formatDate($to->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT)); $to = $to->getTimestamp(); $dtz = new \DateTimeZone($timezone); $transitions = $dtz->getTransitions(); - $dateTimeObject = new \Zend_Date('c'); + $dateTimeObject = new \Magento\Stdlib\DateTime\Date('c'); for ($i = count($transitions) - 1; $i >= 0; $i--) { $tr = $transitions[$i]; @@ -476,21 +476,21 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb */ protected function _getStoreTimezoneUtcOffset($store = null) { - return $this->_locale->storeDate($store)->toString(\Zend_Date::GMT_DIFF_SEP); + return $this->_localeDate->scopeDate($store)->toString(\Zend_Date::GMT_DIFF_SEP); } /** * Retrieve date in UTC timezone * * @param mixed $date - * @return null|\Zend_Date + * @return null|\Magento\Stdlib\DateTime\DateInterface */ protected function _dateToUtc($date) { if ($date === null) { return null; } - $dateUtc = new \Zend_Date($date); + $dateUtc = new \Magento\Stdlib\DateTime\Date($date); $dateUtc->setTimezone('Etc/UTC'); return $dateUtc; } diff --git a/app/code/Magento/Reports/Model/Resource/Report/Collection.php b/app/code/Magento/Reports/Model/Resource/Report/Collection.php index 6cb15dd1b90..f876fed04c6 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Collection.php @@ -98,9 +98,9 @@ class Collection extends \Magento\Data\Collection protected $_dateFactory; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @var \Magento\Reports\Model\Resource\Report\Collection\Factory @@ -109,18 +109,18 @@ class Collection extends \Magento\Data\Collection /** * @param \Magento\Core\Model\EntityFactory $entityFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Reports\Model\DateFactory $dateFactory * @param \Magento\Reports\Model\Resource\Report\Collection\Factory $collectionFactory */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Reports\Model\DateFactory $dateFactory, \Magento\Reports\Model\Resource\Report\Collection\Factory $collectionFactory ) { $this->_dateFactory = $dateFactory; - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_collectionFactory = $collectionFactory; parent::__construct($entityFactory); } @@ -195,13 +195,13 @@ class Collection extends \Magento\Data\Collection /** * Get interval for a day * - * @param \Zend_Date $dateStart + * @param \Magento\Stdlib\DateTime\DateInterface $dateStart * @return array */ - protected function _getDayInterval(\Zend_Date $dateStart) + protected function _getDayInterval(\Magento\Stdlib\DateTime\DateInterface $dateStart) { $interval = array( - 'period' => $dateStart->toString($this->_locale->getDateFormat()), + 'period' => $dateStart->toString($this->_localeDate->getDateFormat()), 'start' => $dateStart->toString('yyyy-MM-dd HH:mm:ss'), 'end' => $dateStart->toString('yyyy-MM-dd 23:59:59') ); @@ -211,13 +211,15 @@ class Collection extends \Magento\Data\Collection /** * Get interval for a month * - * @param \Zend_Date $dateStart - * @param \Zend_Date $dateEnd + * @param \Magento\Stdlib\DateTime\DateInterface $dateStart + * @param \Magento\Stdlib\DateTime\DateInterface $dateEnd * @param bool $firstInterval * @return array */ - protected function _getMonthInterval(\Zend_Date $dateStart, \Zend_Date $dateEnd, $firstInterval) - { + protected function _getMonthInterval( + \Magento\Stdlib\DateTime\DateInterface $dateStart, + \Magento\Stdlib\DateTime\DateInterface $dateEnd, $firstInterval + ) { $interval = array(); $interval['period'] = $dateStart->toString('MM/yyyy'); if ($firstInterval) { @@ -246,13 +248,16 @@ class Collection extends \Magento\Data\Collection /** * Get Interval for a year * - * @param \Zend_Date $dateStart - * @param \Zend_Date $dateEnd + * @param \Magento\Stdlib\DateTime\DateInterface $dateStart + * @param \Magento\Stdlib\DateTime\DateInterface $dateEnd * @param bool $firstInterval * @return array */ - protected function _getYearInterval(\Zend_Date $dateStart, \Zend_Date $dateEnd, $firstInterval) - { + protected function _getYearInterval( + \Magento\Stdlib\DateTime\DateInterface $dateStart, + \Magento\Stdlib\DateTime\DateInterface $dateEnd, + $firstInterval + ) { $interval = array(); $interval['period'] = $dateStart->toString('yyyy'); $interval['start'] = ($firstInterval) ? $dateStart->toString('yyyy-MM-dd 00:00:00') @@ -391,7 +396,7 @@ class Collection extends \Magento\Data\Collection */ public function timeShift($datetime) { - return $this->_locale + return $this->_localeDate ->utcDate(null, $datetime, true, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT) ->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); } diff --git a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php index 4bdb317bf65..280a1cd7a61 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php @@ -64,7 +64,7 @@ class Viewed extends \Magento\Sales\Model\Resource\Report\AbstractReport /** * @param \Magento\App\Resource $resource * @param \Magento\Logger $logger - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator @@ -74,14 +74,14 @@ class Viewed extends \Magento\Sales\Model\Resource\Report\AbstractReport public function __construct( \Magento\App\Resource $resource, \Magento\Logger $logger, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Reports\Model\FlagFactory $reportsFlagFactory, \Magento\Stdlib\DateTime $dateTime, \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator, \Magento\Catalog\Model\Resource\Product $productResource, \Magento\Reports\Model\Resource\HelperFactory $helperFactory ) { - parent::__construct($resource, $logger, $locale, $reportsFlagFactory, $dateTime, $timezoneValidator); + parent::__construct($resource, $logger, $localeDate, $reportsFlagFactory, $dateTime, $timezoneValidator); $this->_productResource = $productResource; $this->_helperFactory = $helperFactory; } diff --git a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed/Collection.php b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed/Collection.php index 8cadfde86f3..1c1292970e1 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed/Collection.php @@ -229,8 +229,8 @@ class Collection // apply date boundaries (before calling $this->_applyDateRangeFilter()) $dtFormat = \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT; - $periodFrom = (!is_null($this->_from) ? new \Zend_Date($this->_from, $dtFormat) : null); - $periodTo = (!is_null($this->_to) ? new \Zend_Date($this->_to, $dtFormat) : null); + $periodFrom = (!is_null($this->_from) ? new \Magento\Stdlib\DateTime\Date($this->_from, $dtFormat) : null); + $periodTo = (!is_null($this->_to) ? new \Magento\Stdlib\DateTime\Date($this->_to, $dtFormat) : null); if ('year' == $this->_period) { if ($periodFrom) { diff --git a/app/code/Magento/Review/Block/Customer/ListCustomer.php b/app/code/Magento/Review/Block/Customer/ListCustomer.php index 4b53de6a2c4..376f00ec0fb 100644 --- a/app/code/Magento/Review/Block/Customer/ListCustomer.php +++ b/app/code/Magento/Review/Block/Customer/ListCustomer.php @@ -18,19 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Review * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ namespace Magento\Review\Block\Customer; +use Magento\Customer\Service\V1\CustomerServiceInterface; +use Magento\Customer\Service\V1\CustomerAddressServiceInterface; + /** * Customer Reviews list block - * - * @category Magento - * @package Magento_Review - * @author Magento Core Team <core@magentocommerce.com> */ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard { @@ -52,6 +49,8 @@ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard * @param \Magento\View\Element\Template\Context $context * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory + * @param CustomerServiceInterface $customerService + * @param CustomerAddressServiceInterface $addressService * @param \Magento\Review\Model\Resource\Review\Product\CollectionFactory $collectionFactory * @param array $data */ @@ -59,11 +58,15 @@ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard \Magento\View\Element\Template\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, + CustomerServiceInterface $customerService, + CustomerAddressServiceInterface $addressService, \Magento\Review\Model\Resource\Review\Product\CollectionFactory $collectionFactory, array $data = array() ) { $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $customerSession, $subscriberFactory, $data); + parent::__construct( + $context, $customerSession, $subscriberFactory, $customerService, $addressService, $data + ); $this->_isScopePrivate = true; } @@ -167,7 +170,7 @@ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard */ public function dateFormat($date) { - return $this->formatDate($date, \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + return $this->formatDate($date, \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); } /** diff --git a/app/code/Magento/Review/Block/Customer/Recent.php b/app/code/Magento/Review/Block/Customer/Recent.php index f7721415f54..2d8688c2224 100644 --- a/app/code/Magento/Review/Block/Customer/Recent.php +++ b/app/code/Magento/Review/Block/Customer/Recent.php @@ -175,7 +175,7 @@ class Recent extends \Magento\View\Element\Template */ public function dateFormat($date) { - return $this->formatDate($date, \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + return $this->formatDate($date, \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); } /** diff --git a/app/code/Magento/Review/Block/Customer/View.php b/app/code/Magento/Review/Block/Customer/View.php index d9e408a2139..5e993021f8d 100644 --- a/app/code/Magento/Review/Block/Customer/View.php +++ b/app/code/Magento/Review/Block/Customer/View.php @@ -251,7 +251,7 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct */ public function dateFormat($date) { - return $this->formatDate($date, \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_LONG); + return $this->formatDate($date, \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_LONG); } /** diff --git a/app/code/Magento/Review/Block/Product/View.php b/app/code/Magento/Review/Block/Product/View.php index bf121539a1c..b428a83610c 100644 --- a/app/code/Magento/Review/Block/Product/View.php +++ b/app/code/Magento/Review/Block/Product/View.php @@ -69,6 +69,7 @@ class View extends \Magento\Catalog\Block\Product\View * @param \Magento\Stdlib\String $string * @param \Magento\Catalog\Helper\Product $productHelper * @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig + * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Review\Model\Resource\Review\CollectionFactory $collectionFactory * @param array $data * @param array $priceBlockTypes @@ -94,6 +95,7 @@ class View extends \Magento\Catalog\Block\Product\View \Magento\Stdlib\String $string, \Magento\Catalog\Helper\Product $productHelper, \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig, + \Magento\Locale\FormatInterface $localeFormat, \Magento\Review\Model\Resource\Review\CollectionFactory $collectionFactory, array $data = array(), array $priceBlockTypes = array() @@ -118,6 +120,7 @@ class View extends \Magento\Catalog\Block\Product\View $string, $productHelper, $productTypeConfig, + $localeFormat, $data, $priceBlockTypes ); diff --git a/app/code/Magento/Review/Block/View.php b/app/code/Magento/Review/Block/View.php index 14e51e6c2e3..6d442ad386f 100644 --- a/app/code/Magento/Review/Block/View.php +++ b/app/code/Magento/Review/Block/View.php @@ -207,6 +207,6 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct */ public function dateFormat($date) { - return $this->formatDate($date, \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_LONG); + return $this->formatDate($date, \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_LONG); } } diff --git a/app/code/Magento/Review/Model/Resource/Review.php b/app/code/Magento/Review/Model/Resource/Review.php index db0f70b1ead..91b14d6e38d 100644 --- a/app/code/Magento/Review/Model/Resource/Review.php +++ b/app/code/Magento/Review/Model/Resource/Review.php @@ -88,7 +88,7 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Core date model * - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -115,14 +115,14 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb /** * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Rating\Model\RatingFactory $ratingFactory * @param \Magento\Rating\Model\Resource\Rating\Option $ratingOptions */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Rating\Model\RatingFactory $ratingFactory, \Magento\Rating\Model\Resource\Rating\Option $ratingOptions diff --git a/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php index bdcbf6ecfa3..b0f34936feb 100644 --- a/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php @@ -92,7 +92,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Rating\Model\RatingFactory $ratingFactory @@ -117,7 +117,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\Resource\Url $catalogUrl, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Stdlib\DateTime $dateTime, \Magento\Rating\Model\RatingFactory $ratingFactory, @@ -142,7 +142,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $coreStoreConfig, $productOptionFactory, $catalogUrl, - $locale, + $localeDate, $customerSession, $dateTime, $connection diff --git a/app/code/Magento/Review/etc/frontend/di.xml b/app/code/Magento/Review/etc/frontend/di.xml index 2c24dc7e6b7..f63e418c0b7 100644 --- a/app/code/Magento/Review/etc/frontend/di.xml +++ b/app/code/Magento/Review/etc/frontend/di.xml @@ -41,7 +41,6 @@ </arguments> </type> <type name="Magento\Review\Controller\Product"> - <plugin name="sessionInitializer" type="reviewProductInitSession" /> <arguments> <argument name="reviewSession" xsi:type="object">Magento\Review\Model\Session</argument> </arguments> @@ -53,11 +52,4 @@ </argument> </arguments> </type> - <virtualType name="reviewProductInitSession" type="Magento\Core\App\Action\Plugin\Session"> - <arguments> - <argument name="cookieCheckActions" xsi:type="array"> - <item name="productReviewPost" xsi:type="string">post</item> - </argument> - </arguments> - </virtualType> </config> diff --git a/app/code/Magento/Review/view/frontend/layout/catalog_product_view.xml b/app/code/Magento/Review/view/frontend/layout/catalog_product_view.xml new file mode 100644 index 00000000000..ed07ea7712b --- /dev/null +++ b/app/code/Magento/Review/view/frontend/layout/catalog_product_view.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceContainer name="content"> + <block class="Magento\Core\Block\RequireCookie" name="require-cookie" template="Magento_Core::require_cookie.phtml"> + <arguments> + <argument name="triggers" xsi:type="array"> + <item name="submitReviewButton" xsi:type="string">.review .action.submit</item> + </argument> + </arguments> + </block> + </referenceContainer> +</layout> diff --git a/app/code/Magento/Rss/App/Action/Plugin/Authentication.php b/app/code/Magento/Rss/App/Action/Plugin/Authentication.php index 8cd80cb51b8..d8891d96f6e 100644 --- a/app/code/Magento/Rss/App/Action/Plugin/Authentication.php +++ b/app/code/Magento/Rss/App/Action/Plugin/Authentication.php @@ -25,6 +25,10 @@ */ namespace Magento\Rss\App\Action\Plugin; +use Magento\App\RequestInterface; +use Magento\App\ResponseInterface; +use Magento\Backend\App\AbstractAction; + class Authentication extends \Magento\Backend\App\Action\Plugin\Authentication { /** @@ -57,7 +61,7 @@ class Authentication extends \Magento\Backend\App\Action\Plugin\Authentication /** * @param \Magento\Backend\Model\Auth $auth * @param \Magento\Backend\Model\UrlInterface $url - * @param \Magento\App\ResponseInterface $response + * @param ResponseInterface $response * @param \Magento\App\ActionFlag $actionFlag * @param \Magento\Message\ManagerInterface $messageManager * @param \Magento\HTTP\Authentication $httpAuthentication @@ -67,7 +71,7 @@ class Authentication extends \Magento\Backend\App\Action\Plugin\Authentication public function __construct( \Magento\Backend\Model\Auth $auth, \Magento\Backend\Model\UrlInterface $url, - \Magento\App\ResponseInterface $response, + ResponseInterface $response, \Magento\App\ActionFlag $actionFlag, \Magento\Message\ManagerInterface $messageManager, \Magento\HTTP\Authentication $httpAuthentication, @@ -83,21 +87,24 @@ class Authentication extends \Magento\Backend\App\Action\Plugin\Authentication /** * Replace standard admin login form with HTTP Basic authentication * - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain - * @return mixed + * @param AbstractAction $subject + * @param callable $proceed + * @param RequestInterface $request + * @return ResponseInterface + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundDispatch(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - /** @var \Magento\App\RequestInterface $request */ - $request = $arguments[0]; + public function aroundDispatch( + AbstractAction $subject, + \Closure $proceed, + RequestInterface $request + ) { $resource = isset($this->_aclResources[$request->getControllerName()]) ? (isset($this->_aclResources[$request->getControllerName()][$request->getActionName()]) ? $this->_aclResources[$request->getControllerName()][$request->getActionName()] : $this->_aclResources[$request->getControllerName()]) : null; if (!$resource) { - return parent::aroundDispatch($arguments, $invocationChain); + return parent::aroundDispatch($subject, $proceed, $request); } $session = $this->_auth->getAuthStorage(); @@ -118,6 +125,6 @@ class Authentication extends \Magento\Backend\App\Action\Plugin\Authentication return $this->_response; } - return parent::aroundDispatch($arguments, $invocationChain); + return parent::aroundDispatch($subject, $proceed, $request); } } diff --git a/app/code/Magento/Rss/Block/AbstractBlock.php b/app/code/Magento/Rss/Block/AbstractBlock.php index b4672438161..1d6afb3715d 100644 --- a/app/code/Magento/Rss/Block/AbstractBlock.php +++ b/app/code/Magento/Rss/Block/AbstractBlock.php @@ -23,7 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Rss\Block; class AbstractBlock extends \Magento\View\Element\Template @@ -70,7 +69,7 @@ class AbstractBlock extends \Magento\View\Element\Template protected function _getCustomerGroupId() { $customerGroupId = (int) $this->getRequest()->getParam('cid'); - if($customerGroupId == null) { + if ($customerGroupId == null) { $customerGroupId = $this->_customerSession->getCustomerGroupId(); } return $customerGroupId; diff --git a/app/code/Magento/Rss/Block/Catalog/AbstractCatalog.php b/app/code/Magento/Rss/Block/Catalog/AbstractCatalog.php index cf0e59c185a..b70066aa600 100644 --- a/app/code/Magento/Rss/Block/Catalog/AbstractCatalog.php +++ b/app/code/Magento/Rss/Block/Catalog/AbstractCatalog.php @@ -23,7 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Rss\Block\Catalog; class AbstractCatalog extends \Magento\Rss\Block\AbstractBlock diff --git a/app/code/Magento/Rss/Block/Catalog/Category.php b/app/code/Magento/Rss/Block/Catalog/Category.php index d0d1d6d46b3..fd5c99f0b99 100644 --- a/app/code/Magento/Rss/Block/Catalog/Category.php +++ b/app/code/Magento/Rss/Block/Catalog/Category.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Block\Catalog; /** * Review form block */ -namespace Magento\Rss\Block\Catalog; - class Category extends \Magento\Rss\Block\Catalog\AbstractCatalog { /** @@ -94,6 +93,9 @@ class Category extends \Magento\Rss\Block\Catalog\AbstractCatalog parent::__construct($context, $customerSession, $catalogData, $data); } + /** + * @return void + */ protected function _construct() { /* @@ -107,6 +109,9 @@ class Category extends \Magento\Rss\Block\Catalog\AbstractCatalog $this->setCacheLifetime(600); } + /** + * @return string + */ protected function _toHtml() { $categoryId = $this->getRequest()->getParam('cid'); @@ -134,7 +139,7 @@ class Category extends \Magento\Rss\Block\Catalog\AbstractCatalog $_collection->addAttributeToSelect('url_key') ->addAttributeToSelect('name') ->addAttributeToSelect('is_anchor') - ->addAttributeToFilter('is_active',1) + ->addAttributeToFilter('is_active', 1) ->addIdFilter($category->getChildren()) ->load() ; @@ -151,7 +156,7 @@ class Category extends \Magento\Rss\Block\Catalog\AbstractCatalog */ $_productCollection = $currentCategory ->getProductCollection() - ->addAttributeToSort('updated_at','desc') + ->addAttributeToSort('updated_at', 'desc') ->setVisibility($this->_visibility->getVisibleInCatalogIds()) ->setCurPage(1) ->setPageSize(50) @@ -173,6 +178,7 @@ class Category extends \Magento\Rss\Block\Catalog\AbstractCatalog * Preparing data and adding to rss object * * @param array $args + * @return void */ public function addNewItemXmlCallback($args) { @@ -194,7 +200,7 @@ class Category extends \Magento\Rss\Block\Catalog\AbstractCatalog . '<td style="text-decoration:none;">' . $product->getDescription(); if ($product->getAllowedPriceInRss()) { - $description.= $this->getPriceHtml($product,true); + $description.= $this->getPriceHtml($product, true); } $description .= '</td></tr></table>'; diff --git a/app/code/Magento/Rss/Block/Catalog/NewCatalog.php b/app/code/Magento/Rss/Block/Catalog/NewCatalog.php index b1d21d4c519..60ca0ab12ea 100644 --- a/app/code/Magento/Rss/Block/Catalog/NewCatalog.php +++ b/app/code/Magento/Rss/Block/Catalog/NewCatalog.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Block\Catalog; /** * Review form block */ -namespace Magento\Rss\Block\Catalog; - class NewCatalog extends \Magento\Rss\Block\Catalog\AbstractCatalog { /** @@ -86,6 +85,9 @@ class NewCatalog extends \Magento\Rss\Block\Catalog\AbstractCatalog parent::__construct($context, $customerSession, $catalogData, $data); } + /** + * @return string + */ protected function _toHtml() { $storeId = $this->_getStoreId(); @@ -105,11 +107,11 @@ class NewCatalog extends \Magento\Rss\Block\Catalog\AbstractCatalog /** @var $product \Magento\Catalog\Model\Product */ $product = $this->_productFactory->create(); - $todayStartOfDayDate = $this->_locale->date() + $todayStartOfDayDate = $this->_localeDate->date() ->setTime('00:00:00') ->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); - $todayEndOfDayDate = $this->_locale->date() + $todayEndOfDayDate = $this->_localeDate->date() ->setTime('23:59:59') ->toString(\Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); @@ -131,7 +133,7 @@ class NewCatalog extends \Magento\Rss\Block\Catalog\AbstractCatalog array('attribute' => 'news_to_date', 'is' => new \Zend_Db_Expr('not null')) ) ) - ->addAttributeToSort('news_from_date','desc') + ->addAttributeToSort('news_from_date', 'desc') ->addAttributeToSelect(array('name', 'short_description', 'description'), 'inner') ->addAttributeToSelect( array( @@ -161,6 +163,7 @@ class NewCatalog extends \Magento\Rss\Block\Catalog\AbstractCatalog * Preparing data and adding to rss object * * @param array $args + * @return void */ public function addNewItemXmlCallback($args) { diff --git a/app/code/Magento/Rss/Block/Catalog/NotifyStock.php b/app/code/Magento/Rss/Block/Catalog/NotifyStock.php index 6019d053850..3786194ea2d 100644 --- a/app/code/Magento/Rss/Block/Catalog/NotifyStock.php +++ b/app/code/Magento/Rss/Block/Catalog/NotifyStock.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Block\Catalog; /** * Catalog low stock RSS block */ -namespace Magento\Rss\Block\Catalog; - class NotifyStock extends \Magento\Backend\Block\AbstractBlock { /** diff --git a/app/code/Magento/Rss/Block/Catalog/Review.php b/app/code/Magento/Rss/Block/Catalog/Review.php index f5690044357..1c00fd8b5ea 100644 --- a/app/code/Magento/Rss/Block/Catalog/Review.php +++ b/app/code/Magento/Rss/Block/Catalog/Review.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Block\Catalog; /** * Review form block */ -namespace Magento\Rss\Block\Catalog; - class Review extends \Magento\Backend\Block\AbstractBlock { /** @@ -114,7 +113,7 @@ class Review extends \Magento\Backend\Block\AbstractBlock * Format single RSS element * * @param array $args - * @return null + * @return void */ public function addReviewItemXmlCallback($args) { diff --git a/app/code/Magento/Rss/Block/Catalog/Salesrule.php b/app/code/Magento/Rss/Block/Catalog/Salesrule.php index 499394e7309..c0df3c835e6 100644 --- a/app/code/Magento/Rss/Block/Catalog/Salesrule.php +++ b/app/code/Magento/Rss/Block/Catalog/Salesrule.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Block\Catalog; /** * Review form block */ -namespace Magento\Rss\Block\Catalog; - class Salesrule extends \Magento\Rss\Block\AbstractBlock { /** @@ -60,6 +59,9 @@ class Salesrule extends \Magento\Rss\Block\AbstractBlock parent::__construct($context, $customerSession, $data); } + /** + * @return void + */ protected function _construct() { /* @@ -100,7 +102,7 @@ class Salesrule extends \Magento\Rss\Block\AbstractBlock $collection = $this->_collectionFactory->create(); $collection->addWebsiteGroupDateFilter($websiteId, $customerGroup, $now) ->addFieldToFilter('is_rss', 1) - ->setOrder('from_date','desc'); + ->setOrder('from_date', 'desc'); $collection->load(); /** @var $ruleModel \Magento\SalesRule\Model\Rule */ diff --git a/app/code/Magento/Rss/Block/Catalog/Special.php b/app/code/Magento/Rss/Block/Catalog/Special.php index 9278ff04d37..b51de3ddfac 100644 --- a/app/code/Magento/Rss/Block/Catalog/Special.php +++ b/app/code/Magento/Rss/Block/Catalog/Special.php @@ -23,18 +23,17 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Block\Catalog; /** * Review form block */ -namespace Magento\Rss\Block\Catalog; - class Special extends \Magento\Rss\Block\Catalog\AbstractCatalog { /** - * \Zend_Date object for date comparsions + * \Magento\Stdlib\DateTime\DateInterface object for date comparsions * - * @var \Zend_Date + * @var \Magento\Stdlib\DateTime\Date */ protected static $_currentDate = null; @@ -101,6 +100,9 @@ class Special extends \Magento\Rss\Block\Catalog\AbstractCatalog parent::__construct($context, $customerSession, $catalogData, $data); } + /** + * @return void + */ protected function _construct() { /* @@ -110,6 +112,9 @@ class Special extends \Magento\Rss\Block\Catalog\AbstractCatalog $this->setCacheLifetime(600); } + /** + * @return string + */ protected function _toHtml() { //store id is store view id @@ -183,7 +188,7 @@ class Special extends \Magento\Rss\Block\Catalog\AbstractCatalog if ($result['use_special']) { $special = '<br />' . __('Special Expires On: %1', $this->formatDate($result['special_to_date'], - \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM)); + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM)); } $html .= sprintf('<p>%s %s%s</p>', __('Price: %1', $this->_coreData->currency($result['price'])), @@ -209,11 +214,12 @@ class Special extends \Magento\Rss\Block\Catalog\AbstractCatalog * Preparing data and adding to rss object * * @param array $args + * @return void */ public function addSpecialXmlCallback($args) { if (!isset(self::$_currentDate)) { - self::$_currentDate = new \Zend_Date(); + self::$_currentDate = new \Magento\Stdlib\DateTime\Date(); } // dispatch event to determine whether the product will eventually get to the result @@ -241,13 +247,12 @@ class Special extends \Magento\Rss\Block\Catalog\AbstractCatalog $args['results'][] = $row; } - /** * Function for comparing two items in collection * - * @param $a - * @param $b - * @return boolean + * @param array $a + * @param array $b + * @return bool */ public function sortByStartDate($a, $b) { diff --git a/app/code/Magento/Rss/Block/ListBlock.php b/app/code/Magento/Rss/Block/ListBlock.php index b488abdd6b1..8c3dae9853c 100644 --- a/app/code/Magento/Rss/Block/ListBlock.php +++ b/app/code/Magento/Rss/Block/ListBlock.php @@ -23,16 +23,18 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Block; /** * Review form block */ -namespace Magento\Rss\Block; - class ListBlock extends \Magento\View\Element\Template { const XML_PATH_RSS_METHODS = 'rss'; + /** + * @var array + */ protected $_rssFeeds = array(); /** @@ -66,7 +68,7 @@ class ListBlock extends \Magento\View\Element\Template /** * Add Link elements to head * - * @return \Magento\Rss\Block\ListBlock + * @return $this */ protected function _prepareLayout() { @@ -83,7 +85,7 @@ class ListBlock extends \Magento\View\Element\Template /** * Retrieve rss feeds * - * @return array + * @return bool|array */ public function getRssFeeds() { @@ -97,7 +99,7 @@ class ListBlock extends \Magento\View\Element\Template * @param string $label * @param array $param * @param bool $customerGroup - * @return \Magento\App\Helper\AbstractHelper + * @return $this */ public function addRssFeed($url, $label, $param = array(), $customerGroup = false) { @@ -114,16 +116,31 @@ class ListBlock extends \Magento\View\Element\Template return $this; } + /** + * Rest rss feed + * + * @return void + */ public function resetRssFeed() { $this->_rssFeeds = array(); } + /** + * Get current store id + * + * @return int + */ public function getCurrentStoreId() { return $this->_storeManager->getStore()->getId(); } + /** + * Get current customer group id + * + * @return int + */ public function getCurrentCustomerGroupId() { return $this->_customerSession->getCustomerGroupId(); @@ -134,7 +151,7 @@ class ListBlock extends \Magento\View\Element\Template * * array structure: * - * @return array + * @return array */ public function getRssCatalogFeeds() { @@ -143,6 +160,11 @@ class ListBlock extends \Magento\View\Element\Template return $this->getRssFeeds(); } + /** + * Get rss misc feeds + * + * @return array|bool + */ public function getRssMiscFeeds() { $this->resetRssFeed(); @@ -152,6 +174,11 @@ class ListBlock extends \Magento\View\Element\Template return $this->getRssFeeds(); } + /** + * New product rss feed + * + * @return void + */ public function newProductRssFeed() { $path = self::XML_PATH_RSS_METHODS . '/catalog/new'; @@ -160,6 +187,11 @@ class ListBlock extends \Magento\View\Element\Template } } + /** + * Special product rss feed + * + * @return void + */ public function specialProductRssFeed() { $path = self::XML_PATH_RSS_METHODS . '/catalog/special'; @@ -168,6 +200,11 @@ class ListBlock extends \Magento\View\Element\Template } } + /** + * Sales rule product rss feed + * + * @return void + */ public function salesRuleProductRssFeed() { $path = self::XML_PATH_RSS_METHODS . '/catalog/salesrule'; @@ -176,6 +213,11 @@ class ListBlock extends \Magento\View\Element\Template } } + /** + * Categories rss feed + * + * @return void + */ public function categoriesRssFeed() { $path = self::XML_PATH_RSS_METHODS . '/catalog/category'; diff --git a/app/code/Magento/Rss/Block/Order/Details.php b/app/code/Magento/Rss/Block/Order/Details.php index 131bc5fc088..ce06d3a65db 100644 --- a/app/code/Magento/Rss/Block/Order/Details.php +++ b/app/code/Magento/Rss/Block/Order/Details.php @@ -23,11 +23,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Rss\Block\Order; class Details extends \Magento\View\Element\Template { - + /** + * @var string + */ protected $_template = 'order/details.phtml'; } diff --git a/app/code/Magento/Rss/Block/Order/NewOrder.php b/app/code/Magento/Rss/Block/Order/NewOrder.php index 0a58fce5c0e..8c23974473a 100644 --- a/app/code/Magento/Rss/Block/Order/NewOrder.php +++ b/app/code/Magento/Rss/Block/Order/NewOrder.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Block\Order; /** * Review form block */ -namespace Magento\Rss\Block\Order; - class NewOrder extends \Magento\Backend\Block\AbstractBlock { /** @@ -74,6 +73,9 @@ class NewOrder extends \Magento\Backend\Block\AbstractBlock parent::__construct($context, $data); } + /** + * @return string + */ protected function _toHtml() { /** @var $order \Magento\Sales\Model\Order */ @@ -106,6 +108,9 @@ class NewOrder extends \Magento\Backend\Block\AbstractBlock return $rssObj->createRssXml(); } + /** + * @param array $args + */ public function addNewOrderXmlCallback($args) { /** @var $rssObj \Magento\Rss\Model\Rss */ diff --git a/app/code/Magento/Rss/Block/Order/Status.php b/app/code/Magento/Rss/Block/Order/Status.php index 20b0a880d40..b579c57aea2 100644 --- a/app/code/Magento/Rss/Block/Order/Status.php +++ b/app/code/Magento/Rss/Block/Order/Status.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Block\Order; /** * Review form block */ -namespace Magento\Rss\Block\Order; - class Status extends \Magento\View\Element\Template { /** @@ -68,6 +67,9 @@ class Status extends \Magento\View\Element\Template parent::__construct($context, $data); } + /** + * @return void + */ protected function _construct() { /* @@ -77,6 +79,9 @@ class Status extends \Magento\View\Element\Template $this->setCacheLifetime(600); } + /** + * @return string + */ protected function _toHtml() { /** @var $rssObj \Magento\Rss\Model\Rss */ @@ -101,13 +106,13 @@ class Status extends \Magento\View\Element\Template $urlAppend = 'view'; $type = $result['entity_type_code']; if ($type && $type != 'order') { - $urlAppend = $type; + $urlAppend = $type; } $type = __(ucwords($type)); $title = __('Details for %1 #%2', $type, $result['increment_id']); $description = '<p>' - . __('Notified Date: %1<br/>',$this->formatDate($result['created_at'])) - . __('Comment: %1<br/>',$result['comment']) + . __('Notified Date: %1<br/>', $this->formatDate($result['created_at'])) + . __('Comment: %1<br/>', $result['comment']) . '</p>'; $url = $this->_urlBuilder->getUrl('sales/order/' . $urlAppend, array('order_id' => $order->getId())); $rssObj->_addEntry(array( @@ -118,7 +123,7 @@ class Status extends \Magento\View\Element\Template } } $title = __('Order #%1 created at %2', $order->getIncrementId(), $this->formatDate($order->getCreatedAt())); - $url = $this->_urlBuilder->getUrl('sales/order/view',array('order_id' => $order->getId())); + $url = $this->_urlBuilder->getUrl('sales/order/view', array('order_id' => $order->getId())); $description = '<p>' . __('Current Status: %1<br/>', $order->getStatusLabel()) . __('Total: %1<br/>', $order->formatPrice($order->getGrandTotal())) diff --git a/app/code/Magento/Rss/Block/Wishlist.php b/app/code/Magento/Rss/Block/Wishlist.php index 3ae79b55fe6..2aa8313d749 100644 --- a/app/code/Magento/Rss/Block/Wishlist.php +++ b/app/code/Magento/Rss/Block/Wishlist.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Block; /** * Customer Shared Wishlist Rss Block @@ -31,8 +32,6 @@ * @package Magento_Rss * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Rss\Block; - class Wishlist extends \Magento\Wishlist\Block\AbstractBlock { /** @@ -295,6 +294,7 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock * @param string $type Catalog Product Type * @param string $block Block Type * @param string $template Template + * @return void */ public function addPriceBlockType($type, $block = '', $template = '') { diff --git a/app/code/Magento/Rss/Controller/Adminhtml/Authenticate.php b/app/code/Magento/Rss/Controller/Adminhtml/Authenticate.php index c025c09eccb..9bcf3643a7e 100644 --- a/app/code/Magento/Rss/Controller/Adminhtml/Authenticate.php +++ b/app/code/Magento/Rss/Controller/Adminhtml/Authenticate.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Controller\Adminhtml; /** * RSS Controller with HTTP Basic authentication */ -namespace Magento\Rss\Controller\Adminhtml; - use Magento\Backend\App\Action; class Authenticate extends \Magento\Backend\App\Action diff --git a/app/code/Magento/Rss/Controller/Adminhtml/Catalog.php b/app/code/Magento/Rss/Controller/Adminhtml/Catalog.php index 662371d7a49..4a0131096de 100644 --- a/app/code/Magento/Rss/Controller/Adminhtml/Catalog.php +++ b/app/code/Magento/Rss/Controller/Adminhtml/Catalog.php @@ -23,16 +23,17 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Controller\Adminhtml; /** * RSS Controller for Catalog feeds in Admin */ -namespace Magento\Rss\Controller\Adminhtml; - class Catalog extends \Magento\Rss\Controller\Adminhtml\Authenticate { /** * Notify stock action + * + * @return void */ public function notifystockAction() { @@ -43,6 +44,8 @@ class Catalog extends \Magento\Rss\Controller\Adminhtml\Authenticate /** * Review action + * + * @return void */ public function reviewAction() { diff --git a/app/code/Magento/Rss/Controller/Adminhtml/Order.php b/app/code/Magento/Rss/Controller/Adminhtml/Order.php index b7ea284fd1b..79671c822e5 100644 --- a/app/code/Magento/Rss/Controller/Adminhtml/Order.php +++ b/app/code/Magento/Rss/Controller/Adminhtml/Order.php @@ -23,16 +23,17 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Controller\Adminhtml; /** * RSS Controller for Orders feed in Admin */ -namespace Magento\Rss\Controller\Adminhtml; - class Order extends \Magento\Rss\Controller\Adminhtml\Authenticate { /** * New orders action + * + * @return void */ public function newAction() { diff --git a/app/code/Magento/Rss/Controller/Catalog.php b/app/code/Magento/Rss/Controller/Catalog.php index 585b33b6f12..e6698ea578b 100644 --- a/app/code/Magento/Rss/Controller/Catalog.php +++ b/app/code/Magento/Rss/Controller/Catalog.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Controller; /** * RSS Controller for Catalog feeds */ -namespace Magento\Rss\Controller; - class Catalog extends \Magento\App\Action\Action { /** @@ -48,21 +47,33 @@ class Catalog extends \Magento\App\Action\Action parent::__construct($context); } + /** + * @return void + */ public function newAction() { $this->_genericAction('new'); } + /** + * @return void + */ public function specialAction() { $this->_genericAction('special'); } + /** + * @return void + */ public function salesruleAction() { $this->_genericAction('salesrule'); } + /** + * @return void + */ public function categoryAction() { $this->_genericAction('category'); @@ -72,6 +83,7 @@ class Catalog extends \Magento\App\Action\Action * Render or forward to "no route" action if this type of RSS is disabled * * @param string $code + * @return void */ protected function _genericAction($code) { @@ -95,6 +107,8 @@ class Catalog extends \Magento\App\Action\Action /** * Render as XML-document using layout handle without inheriting any other handles + * + * @return void */ protected function _render() { diff --git a/app/code/Magento/Rss/Controller/Index.php b/app/code/Magento/Rss/Controller/Index.php index a16b09b5366..63e920e528a 100644 --- a/app/code/Magento/Rss/Controller/Index.php +++ b/app/code/Magento/Rss/Controller/Index.php @@ -23,7 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Rss\Controller; use Magento\App\Action\NotFoundException; @@ -64,6 +63,7 @@ class Index extends \Magento\App\Action\Action /** * Index action * + * @return void * @throws NotFoundException */ public function indexAction() @@ -78,6 +78,8 @@ class Index extends \Magento\App\Action\Action /** * Display feed not found message + * + * @return void */ public function nofeedAction() { @@ -92,7 +94,7 @@ class Index extends \Magento\App\Action\Action * Wishlist rss feed action * Show all public wishlists and private wishlists that belong to current user * - * @return mixed + * @return void */ public function wishlistAction() { diff --git a/app/code/Magento/Rss/Controller/Order.php b/app/code/Magento/Rss/Controller/Order.php index fbe27825a11..9e62399da23 100644 --- a/app/code/Magento/Rss/Controller/Order.php +++ b/app/code/Magento/Rss/Controller/Order.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Controller; /** * RSS Controller for Order feed */ -namespace Magento\Rss\Controller; - class Order extends \Magento\App\Action\Action { /** @@ -52,6 +51,8 @@ class Order extends \Magento\App\Action\Action /** * Order status action + * + * @return void */ public function statusAction() { diff --git a/app/code/Magento/Rss/Helper/Order.php b/app/code/Magento/Rss/Helper/Order.php index 812df4ccbc3..43f72958e0d 100644 --- a/app/code/Magento/Rss/Helper/Order.php +++ b/app/code/Magento/Rss/Helper/Order.php @@ -23,14 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Helper; /** * Default rss helper * * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Rss\Helper; - class Order extends \Magento\App\Helper\AbstractHelper { /** diff --git a/app/code/Magento/Rss/Model/Resource/Order.php b/app/code/Magento/Rss/Model/Resource/Order.php index dc19738b3ff..f76afaadda1 100644 --- a/app/code/Magento/Rss/Model/Resource/Order.php +++ b/app/code/Magento/Rss/Model/Resource/Order.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Rss\Model\Resource; /** * Order Rss Resource Model @@ -32,8 +32,6 @@ * @package Magento_Rss * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Rss\Model\Resource; - class Order { /** @@ -93,7 +91,7 @@ class Order $select = $read->select() ->from(array('orders' => $res->getTableName('sales_flat_order')), array('increment_id')) - ->join(array('t' => $commentSelect),'t.entity_id = orders.entity_id') + ->join(array('t' => $commentSelect), 't.entity_id = orders.entity_id') ->order('orders.created_at desc'); return $read->fetchAll($select); diff --git a/app/code/Magento/Rss/Model/Rss.php b/app/code/Magento/Rss/Model/Rss.php index 9362c25cd8d..cfd8139894d 100644 --- a/app/code/Magento/Rss/Model/Rss.php +++ b/app/code/Magento/Rss/Model/Rss.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Rss\Model; /** * Auth session model @@ -32,42 +32,61 @@ * @package Magento_Rss * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Rss\Model; - class Rss { + /** + * @var array + */ protected $_feedArray = array(); + /** + * @param array $data + * @return $this + */ public function _addHeader($data = array()) { $this->_feedArray = $data; return $this; } + /** + * @param array $entries + * @return $this + */ public function _addEntries($entries) { $this->_feedArray['entries'] = $entries; return $this; } + /** + * @param array $entry + * @return $this + */ public function _addEntry($entry) { $this->_feedArray['entries'][] = $entry; return $this; } + /** + * @return array + */ public function getFeedArray() { return $this->_feedArray; } + /** + * @return string + */ public function createRssXml() { try { $rssFeedFromArray = \Zend_Feed::importArray($this->getFeedArray(), 'rss'); return $rssFeedFromArray->saveXML(); } catch (\Exception $e) { - return __('Error in processing xml. %1',$e->getMessage()); + return __('Error in processing xml. %1', $e->getMessage()); } } } diff --git a/app/code/Magento/Rss/Model/System/Config/Backend/Links.php b/app/code/Magento/Rss/Model/System/Config/Backend/Links.php index 014c2f9d8d9..17aa62d2a90 100644 --- a/app/code/Magento/Rss/Model/System/Config/Backend/Links.php +++ b/app/code/Magento/Rss/Model/System/Config/Backend/Links.php @@ -23,13 +23,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Rss\Model\System\Config\Backend; /** * Cache cleaner backend model * */ -namespace Magento\Rss\Model\System\Config\Backend; - class Links extends \Magento\Core\Model\Config\Value { /** @@ -64,6 +63,7 @@ class Links extends \Magento\Core\Model\Config\Value /** * Invalidate cache type, when value was changed * + * @return void */ protected function _afterSave() { diff --git a/app/code/Magento/Rule/Model/AbstractModel.php b/app/code/Magento/Rule/Model/AbstractModel.php index 13a27aed067..4fc9436ac58 100644 --- a/app/code/Magento/Rule/Model/AbstractModel.php +++ b/app/code/Magento/Rule/Model/AbstractModel.php @@ -88,15 +88,15 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel protected $_formFactory; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -105,13 +105,13 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { $this->_formFactory = $formFactory; - $this->_locale = $locale; + $this->_localeDate = $localeDate; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -341,7 +341,7 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel * Convert dates into \Zend_Date */ if (in_array($key, array('from_date', 'to_date')) && $value) { - $value = $this->_locale->date( + $value = $this->_localeDate->date( $value, \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT, null, @@ -383,8 +383,8 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel } if ($fromDate && $toDate) { - $fromDate = new \Zend_Date($fromDate, \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT); - $toDate = new \Zend_Date($toDate, \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT); + $fromDate = new \Magento\Stdlib\DateTime\Date($fromDate, \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT); + $toDate = new \Magento\Stdlib\DateTime\Date($toDate, \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT); if ($fromDate->compare($toDate) === 1) { $result[] = __('End Date must follow Start Date.'); diff --git a/app/code/Magento/Rule/Model/Condition/AbstractCondition.php b/app/code/Magento/Rule/Model/Condition/AbstractCondition.php index 773dfb07d1b..3921f3fb41e 100644 --- a/app/code/Magento/Rule/Model/Condition/AbstractCondition.php +++ b/app/code/Magento/Rule/Model/Condition/AbstractCondition.php @@ -68,9 +68,9 @@ abstract class AbstractCondition extends \Magento\Object implements ConditionInt protected $_viewUrl; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @var \Magento\View\LayoutInterface @@ -84,7 +84,7 @@ abstract class AbstractCondition extends \Magento\Object implements ConditionInt public function __construct(Context $context, array $data = array()) { $this->_viewUrl = $context->getViewUrl(); - $this->_locale = $context->getLocale(); + $this->_localeDate = $context->getLocaleDate(); $this->_layout = $context->getLayout(); parent::__construct($data); @@ -366,7 +366,7 @@ abstract class AbstractCondition extends \Magento\Object implements ConditionInt if ($this->getInputType() == 'date' && !$this->getIsValueParsed()) { // date format intentionally hard-coded $this->setValue( - $this->_locale->date($this->getData('value'), + $this->_localeDate->date($this->getData('value'), \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT, null, false)->toString(\Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT) ); $this->setIsValueParsed(true); diff --git a/app/code/Magento/Rule/Model/Condition/Context.php b/app/code/Magento/Rule/Model/Condition/Context.php index 459fd3cadee..b049a01fbc1 100644 --- a/app/code/Magento/Rule/Model/Condition/Context.php +++ b/app/code/Magento/Rule/Model/Condition/Context.php @@ -36,9 +36,9 @@ class Context implements \Magento\ObjectManager\ContextInterface protected $_viewUrl; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @var \Magento\View\LayoutInterface @@ -57,20 +57,20 @@ class Context implements \Magento\ObjectManager\ContextInterface /** * @param \Magento\View\Url $viewUrl - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\View\LayoutInterface $layout * @param \Magento\Rule\Model\ConditionFactory $conditionFactory * @param \Magento\Logger $logger */ public function __construct( \Magento\View\Url $viewUrl, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\View\LayoutInterface $layout, \Magento\Rule\Model\ConditionFactory $conditionFactory, \Magento\Logger $logger ) { $this->_viewUrl = $viewUrl; - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_layout = $layout; $this->_conditionFactory = $conditionFactory; $this->_logger = $logger; @@ -85,11 +85,11 @@ class Context implements \Magento\ObjectManager\ContextInterface } /** - * @return \Magento\Core\Model\LocaleInterface + * @return \Magento\Stdlib\DateTime\TimezoneInterface */ - public function getLocale() + public function getLocaleDate() { - return $this->_locale; + return $this->_localeDate; } /** diff --git a/app/code/Magento/Rule/Model/Condition/Product/AbstractProduct.php b/app/code/Magento/Rule/Model/Condition/Product/AbstractProduct.php index 24f0f1817b3..d2efc8c2d56 100644 --- a/app/code/Magento/Rule/Model/Condition/Product/AbstractProduct.php +++ b/app/code/Magento/Rule/Model/Condition/Product/AbstractProduct.php @@ -87,6 +87,11 @@ abstract class AbstractProduct extends \Magento\Rule\Model\Condition\AbstractCon */ protected $_attrSetCollection; + /** + * @var \Magento\Locale\FormatInterface + */ + protected $_localeFormat; + /** * @param \Magento\Rule\Model\Condition\Context $context * @param \Magento\Backend\Helper\Data $backendData @@ -94,6 +99,7 @@ abstract class AbstractProduct extends \Magento\Rule\Model\Condition\AbstractCon * @param \Magento\Catalog\Model\Product $product * @param \Magento\Catalog\Model\Resource\Product $productResource * @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\Collection $attrSetCollection + * @param \Magento\Locale\FormatInterface $localeFormat * @param array $data */ public function __construct( @@ -103,6 +109,7 @@ abstract class AbstractProduct extends \Magento\Rule\Model\Condition\AbstractCon \Magento\Catalog\Model\Product $product, \Magento\Catalog\Model\Resource\Product $productResource, \Magento\Eav\Model\Resource\Entity\Attribute\Set\Collection $attrSetCollection, + \Magento\Locale\FormatInterface $localeFormat, array $data = array() ) { $this->_backendData = $backendData; @@ -110,6 +117,7 @@ abstract class AbstractProduct extends \Magento\Rule\Model\Condition\AbstractCon $this->_product = $product; $this->_productResource = $productResource; $this->_attrSetCollection = $attrSetCollection; + $this->_localeFormat = $localeFormat; parent::__construct($context, $data); } @@ -481,17 +489,17 @@ abstract class AbstractProduct extends \Magento\Rule\Model\Condition\AbstractCon $tmp = array(); foreach (explode(',', $arr['value']) as $value) { - $tmp[] = $this->_locale->getNumber($value); + $tmp[] = $this->_localeFormat->getNumber($value); } $arr['value'] = implode(',', $tmp); } else { - $arr['value'] = $this->_locale->getNumber($arr['value']); + $arr['value'] = $this->_localeFormat->getNumber($arr['value']); } } else { $arr['value'] = false; } $arr['is_value_parsed'] = isset($arr['is_value_parsed']) - ? $this->_locale->getNumber($arr['is_value_parsed']) : false; + ? $this->_localeFormat->getNumber($arr['is_value_parsed']) : false; } return parent::loadArray($arr); diff --git a/app/code/Magento/Rule/Model/Rule.php b/app/code/Magento/Rule/Model/Rule.php index 5188c6a3045..e6b521573f0 100644 --- a/app/code/Magento/Rule/Model/Rule.php +++ b/app/code/Magento/Rule/Model/Rule.php @@ -51,7 +51,7 @@ class Rule extends AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Rule\Model\Condition\CombineFactory $conditionsFactory * @param \Magento\Rule\Model\Action\CollectionFactory $actionsFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource @@ -62,7 +62,7 @@ class Rule extends AbstractModel \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Rule\Model\Condition\CombineFactory $conditionsFactory, \Magento\Rule\Model\Action\CollectionFactory $actionsFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, @@ -71,7 +71,7 @@ class Rule extends AbstractModel ) { $this->_conditionsFactory = $conditionsFactory; $this->_actionsFactory = $actionsFactory; - parent::__construct($context, $registry, $formFactory, $locale, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $formFactory, $localeDate, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php index 108d088b1e3..4867b83b2b4 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php @@ -59,7 +59,7 @@ class Form extends \Magento\Payment\Block\Form\Container /** * Check payment method model * - * @param \Magento\Payment\Model\Method\AbstractMethod|null $method + * @param \Magento\Payment\Model\MethodInterface|null $method * @return bool */ protected function _canUseMethod($method) diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Data.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Data.php index 1cc1391f1eb..ca97bb8c03e 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Data.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Data.php @@ -40,11 +40,17 @@ class Data extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate */ protected $_currencyFactory; + /** + * @var \Magento\Locale\CurrencyInterface + */ + protected $_localeCurrency; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory + * @param \Magento\Locale\CurrencyInterface $localeCurrency * @param array $data */ public function __construct( @@ -52,9 +58,11 @@ class Data extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, \Magento\Directory\Model\CurrencyFactory $currencyFactory, + \Magento\Locale\CurrencyInterface $localeCurrency, array $data = array() ) { $this->_currencyFactory = $currencyFactory; + $this->_localeCurrency = $localeCurrency; parent::__construct($context, $sessionQuote, $orderCreate, $data); } @@ -89,7 +97,7 @@ class Data extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate */ public function getCurrencyName($code) { - return $this->_locale->currency($code)->getName(); + return $this->_localeCurrency->getCurrency($code)->getName(); } /** @@ -100,7 +108,7 @@ class Data extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate */ public function getCurrencySymbol($code) { - $currency = $this->_locale->currency($code); + $currency = $this->_localeCurrency->getCurrency($code); return $currency->getSymbol() ? $currency->getSymbol() : $currency->getShortName(); } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php index ff8ca293bcc..ef5cb081ee1 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php @@ -38,6 +38,11 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate /** @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface */ protected $_addressService; + /** + * @var \Magento\Locale\CurrencyInterface + */ + protected $_localeCurrency; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Json\EncoderInterface $jsonEncoder @@ -45,6 +50,7 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate * @param \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService + * @param \Magento\Locale\CurrencyInterface $localeCurrency * @param array $data */ public function __construct( @@ -54,11 +60,13 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate \Magento\Json\EncoderInterface $jsonEncoder, \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory, \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService, + \Magento\Locale\CurrencyInterface $localeCurrency, array $data = array() ) { $this->_jsonEncoder = $jsonEncoder; $this->_customerFormFactory = $customerFormFactory; $this->_addressService = $addressService; + $this->_localeCurrency = $localeCurrency; parent::__construct($context, $sessionQuote, $orderCreate, $data); } @@ -136,7 +144,7 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate } if (!is_null($this->getStoreId())) { $data['store_id'] = $this->getStoreId(); - $currency = $this->_locale->currency($this->getStore()->getCurrentCurrencyCode()); + $currency = $this->_localeCurrency->getCurrency($this->getStore()->getCurrentCurrencyCode()); $symbol = $currency->getSymbol() ? $currency->getSymbol() : $currency->getShortName(); $data['currency_symbol'] = $symbol; $data['shipping_method_reseted'] = !(bool)$this->getQuote()->getShippingAddress()->getShippingMethod(); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php index 8b028e58fe9..7d3f61e5183 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php @@ -200,7 +200,7 @@ abstract class AbstractForm } $element->setValues($options); } else if ($inputType == 'date') { - $format = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $format = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); $element->setImage($this->getViewFileUrl('images/grid-cal.gif')); $element->setDateFormat($format); } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php index a4329f46693..0bc445603a2 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php @@ -162,8 +162,8 @@ class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractF protected function _prepareForm() { $fieldset = $this->_form->addFieldset('main', array( - 'no_container' => true - )); + 'no_container' => true + )); $addressForm = $this->_customerFormFactory->create( 'customer_address', diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php index 50237f6a034..84a9b9d91d0 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php @@ -216,7 +216,7 @@ class History * * @param string $label * @param bool $notified - * @param \Zend_Date $created + * @param \Magento\Stdlib\DateTime\DateInterface $created * @param string $comment * @return array */ @@ -323,7 +323,7 @@ class History $createdAtA = $a['created_at']; $createdAtB = $b['created_at']; - /** @var $createdAta \Zend_Date */ + /** @var $createdAta \Magento\Stdlib\DateTime\DateInterface */ if ($createdAtA->getTimestamp() == $createdAtB->getTimestamp()) { return 0; } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Transactions/Detail.php b/app/code/Magento/Sales/Block/Adminhtml/Transactions/Detail.php index ac8669142fb..97034af2cef 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Transactions/Detail.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Transactions/Detail.php @@ -101,7 +101,7 @@ class Detail extends \Magento\Backend\Block\Widget\Container */ public function getHeaderText() { - return __("Transaction # %1 | %2", $this->_txn->getTxnId(), $this->formatDate($this->_txn->getCreatedAt(), \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM, true)); + return __("Transaction # %1 | %2", $this->_txn->getTxnId(), $this->formatDate($this->_txn->getCreatedAt(), \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, true)); } protected function _toHtml() @@ -129,7 +129,7 @@ class Detail extends \Magento\Backend\Block\Widget\Container ); $createdAt = (strtotime($this->_txn->getCreatedAt())) - ? $this->formatDate($this->_txn->getCreatedAt(), \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM, true) + ? $this->formatDate($this->_txn->getCreatedAt(), \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, true) : __('N/A'); $this->setCreatedAtHtml($this->escapeHtml($createdAt)); diff --git a/app/code/Magento/Sales/Block/Reorder/Sidebar.php b/app/code/Magento/Sales/Block/Reorder/Sidebar.php index feef9f90c6c..11b826c736e 100644 --- a/app/code/Magento/Sales/Block/Reorder/Sidebar.php +++ b/app/code/Magento/Sales/Block/Reorder/Sidebar.php @@ -29,7 +29,7 @@ */ namespace Magento\Sales\Block\Reorder; -class Sidebar extends \Magento\View\Element\Template +class Sidebar extends \Magento\View\Element\Template implements \Magento\View\Block\IdentityInterface { /** * @var string @@ -158,8 +158,10 @@ class Sidebar extends \Magento\View\Element\Template */ public function getLastOrder() { - foreach ($this->getOrders() as $order) { - return $order; + if ($this->getOrders()) { + foreach ($this->getOrders() as $order) { + return $order; + } } return false; } @@ -173,4 +175,18 @@ class Sidebar extends \Magento\View\Element\Template { return $this->_customerSession->isLoggedIn() || $this->getCustomerId() ? parent::_toHtml() : ''; } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + $identities = array(); + foreach ($this->getItems() as $item) { + $identities = array_merge($identities, $item->getProduct()->getIdentities()); + } + return $identities; + } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo.php b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo.php index b87a90e317c..2bd6af27dd8 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo.php @@ -126,7 +126,7 @@ class AbstractCreditmemo extends \Magento\Backend\App\Action $pages = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Creditmemo')->getPdf($invoices); $pdf->pages = array_merge($pdf->pages, $pages->pages); } - $date = $this->_objectManager->get('Magento\Core\Model\Date')->date('Y-m-d_H-i-s'); + $date = $this->_objectManager->get('Magento\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s'); return $this->_fileFactory->create( 'creditmemo' . $date . '.pdf', @@ -147,7 +147,7 @@ class AbstractCreditmemo extends \Magento\Backend\App\Action if ($creditmemo) { $pdf = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Creditmemo') ->getPdf(array($creditmemo)); - $date = $this->_objectManager->get('Magento\Core\Model\Date')->date('Y-m-d_H-i-s'); + $date = $this->_objectManager->get('Magento\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s'); return $this->_fileFactory->create( 'creditmemo' . $date . '.pdf', $pdf->render(), diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice.php b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice.php index 2aa4d18f581..14da6057a87 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice.php @@ -129,7 +129,7 @@ class AbstractInvoice $invoice = $this->_objectManager->create('Magento\Sales\Model\Order\Invoice')->load($invoiceId); if ($invoice) { $pdf = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Invoice')->getPdf(array($invoice)); - $date = $this->_objectManager->get('Magento\Core\Model\Date')->date('Y-m-d_H-i-s'); + $date = $this->_objectManager->get('Magento\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s'); return $this->_fileFactory->create( 'invoice' . $date . '.pdf', $pdf->render(), @@ -156,7 +156,7 @@ class AbstractInvoice $pages = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Invoice')->getPdf($invoices); $pdf->pages = array_merge ($pdf->pages, $pages->pages); } - $date = $this->_objectManager->get('Magento\Core\Model\Date')->date('Y-m-d_H-i-s'); + $date = $this->_objectManager->get('Magento\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s'); return $this->_fileFactory->create( 'invoice' . $date . '.pdf', diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order.php b/app/code/Magento/Sales/Controller/Adminhtml/Order.php index 266afe31a68..f4c16afd27a 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order.php @@ -527,7 +527,7 @@ class Order extends \Magento\Backend\App\Action } if ($flag) { return $this->_fileFactory->create( - 'invoice' . $this->_objectManager->get('Magento\Core\Model\Date')->date('Y-m-d_H-i-s') . '.pdf', + 'invoice' . $this->_objectManager->get('Magento\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s') . '.pdf', $pdf->render(), \Magento\App\Filesystem::VAR_DIR, 'application/pdf' @@ -566,7 +566,7 @@ class Order extends \Magento\Backend\App\Action } if ($flag) { return $this->_fileFactory->create( - 'packingslip' . $this->_objectManager->get('Magento\Core\Model\Date')->date('Y-m-d_H-i-s') . '.pdf', + 'packingslip' . $this->_objectManager->get('Magento\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s') . '.pdf', $pdf->render(), \Magento\App\Filesystem::VAR_DIR, 'application/pdf' @@ -605,7 +605,7 @@ class Order extends \Magento\Backend\App\Action } if ($flag) { return $this->_fileFactory->create( - 'creditmemo' . $this->_objectManager->get('Magento\Core\Model\Date')->date('Y-m-d_H-i-s') . '.pdf', + 'creditmemo' . $this->_objectManager->get('Magento\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s') . '.pdf', $pdf->render(), \Magento\App\Filesystem::VAR_DIR, 'application/pdf' @@ -670,7 +670,7 @@ class Order extends \Magento\Backend\App\Action } if ($flag) { return $this->_fileFactory->create( - 'docs' . $this->_objectManager->get('Magento\Core\Model\Date')->date('Y-m-d_H-i-s') . '.pdf', + 'docs' . $this->_objectManager->get('Magento\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s') . '.pdf', $pdf->render(), \Magento\App\Filesystem::VAR_DIR, 'application/pdf' diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment.php b/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment.php index f17d5d24517..a44255dbc09 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment.php @@ -101,7 +101,7 @@ class AbstractShipment extends \Magento\Backend\App\Action $pages = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Shipment')->getPdf($shipments); $pdf->pages = array_merge($pdf->pages, $pages->pages); } - $date = $this->_objectManager->get('Magento\Core\Model\Date')->date('Y-m-d_H-i-s'); + $date = $this->_objectManager->get('Magento\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s'); return $this->_fileFactory->create( 'packingslip' . $date . '.pdf', $pdf->render(), @@ -120,7 +120,7 @@ class AbstractShipment extends \Magento\Backend\App\Action if ($shipment) { $pdf = $this->_objectManager->create('Magento\Sales\Model\Order\Pdf\Shipment') ->getPdf(array($shipment)); - $date = $this->_objectManager->get('Magento\Core\Model\Date')->date('Y-m-d_H-i-s'); + $date = $this->_objectManager->get('Magento\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s'); return $this->_fileFactory->create( 'packingslip' . $date . '.pdf', $pdf->render(), diff --git a/app/code/Magento/Sales/Controller/Guest.php b/app/code/Magento/Sales/Controller/Guest.php index 683ff8f75cd..1862bcae165 100644 --- a/app/code/Magento/Sales/Controller/Guest.php +++ b/app/code/Magento/Sales/Controller/Guest.php @@ -39,7 +39,9 @@ class Guest extends \Magento\Sales\Controller\AbstractController */ protected function _loadValidOrder($orderId = null) { - return $this->_objectManager->get('Magento\Sales\Helper\Guest')->loadValidOrder(); + return $this->_objectManager->get('Magento\Sales\Helper\Guest')->loadValidOrder( + $this->_request, $this->_response + ); } /** diff --git a/app/code/Magento/Sales/Helper/Guest.php b/app/code/Magento/Sales/Helper/Guest.php index 6bb48e376c7..b0a15079f30 100644 --- a/app/code/Magento/Sales/Helper/Guest.php +++ b/app/code/Magento/Sales/Helper/Guest.php @@ -71,7 +71,6 @@ class Guest extends \Magento\Core\Helper\Data * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Locale $locale * @param \Magento\App\State $appState * @param \Magento\Registry $coreRegistry * @param \Magento\Customer\Model\Session $customerSession @@ -85,7 +84,6 @@ class Guest extends \Magento\Core\Helper\Data \Magento\App\Helper\Context $context, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Locale $locale, \Magento\App\State $appState, \Magento\Registry $coreRegistry, \Magento\Customer\Model\Session $customerSession, @@ -105,7 +103,6 @@ class Guest extends \Magento\Core\Helper\Data $context, $coreStoreConfig, $storeManager, - $locale, $appState, $dbCompatibleMode ); @@ -116,21 +113,21 @@ class Guest extends \Magento\Core\Helper\Data * * @return bool|null */ - public function loadValidOrder() + public function loadValidOrder(\Magento\App\RequestInterface $request, \Magento\App\ResponseInterface $response) { if ($this->_customerSession->isLoggedIn()) { - $this->_app->getResponse()->setRedirect($this->_urlBuilder->getUrl('sales/order/history')); + $response->setRedirect($this->_urlBuilder->getUrl('sales/order/history')); return false; } - $post = $this->_app->getRequest()->getPost(); + $post = $request->getPost(); $errors = false; /** @var $order \Magento\Sales\Model\Order */ $order = $this->_orderFactory->create(); if (empty($post) && !$this->_coreCookie->get($this->_cookieName)) { - $this->_app->getResponse()->setRedirect($this->_urlBuilder->getUrl('sales/guest/form')); + $response->setRedirect($this->_urlBuilder->getUrl('sales/guest/form')); return false; } elseif (!empty($post) && isset($post['oar_order_id']) && isset($post['oar_type'])) { $type = $post['oar_type']; @@ -185,7 +182,7 @@ class Guest extends \Magento\Core\Helper\Data } $this->messageManager->addError(__('You entered incorrect data. Please try again.')); - $this->_app->getResponse()->setRedirect($this->_urlBuilder->getUrl('sales/guest/form')); + $response->setRedirect($this->_urlBuilder->getUrl('sales/guest/form')); return false; } diff --git a/app/code/Magento/Sales/Helper/Reorder.php b/app/code/Magento/Sales/Helper/Reorder.php index 5a2649e9cff..817e407ea55 100644 --- a/app/code/Magento/Sales/Helper/Reorder.php +++ b/app/code/Magento/Sales/Helper/Reorder.php @@ -42,7 +42,6 @@ class Reorder extends \Magento\Core\Helper\Data * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Locale $locale * @param \Magento\App\State $appState * @param \Magento\Customer\Model\Session $customerSession * @param bool $dbCompatibleMode @@ -51,7 +50,6 @@ class Reorder extends \Magento\Core\Helper\Data \Magento\App\Helper\Context $context, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Locale $locale, \Magento\App\State $appState, \Magento\Customer\Model\Session $customerSession, $dbCompatibleMode = true @@ -61,7 +59,6 @@ class Reorder extends \Magento\Core\Helper\Data $context, $coreStoreConfig, $storeManager, - $locale, $appState, $dbCompatibleMode ); diff --git a/app/code/Magento/Sales/Model/AbstractModel.php b/app/code/Magento/Sales/Model/AbstractModel.php index 2e27caed334..5b0b911b74f 100644 --- a/app/code/Magento/Sales/Model/AbstractModel.php +++ b/app/code/Magento/Sales/Model/AbstractModel.php @@ -33,9 +33,9 @@ namespace Magento\Sales\Model; abstract class AbstractModel extends \Magento\Core\Model\AbstractModel { /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_coreLocale; + protected $_localeDate; /** * @var \Magento\Stdlib\DateTime @@ -45,7 +45,7 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\LocaleInterface $coreLocale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -54,7 +54,7 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $coreLocale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, @@ -63,7 +63,7 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel parent::__construct( $context, $registry, $resource, $resourceCollection, $data ); - $this->_coreLocale = $coreLocale; + $this->_localeDate = $localeDate; $this->dateTime = $dateTime; } @@ -91,11 +91,11 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel /** * Get object created at date affected current active store timezone * - * @return \Zend_Date + * @return \Magento\Stdlib\DateTime\Date */ public function getCreatedAtDate() { - return $this->_coreLocale->date( + return $this->_localeDate->date( $this->dateTime->toTimestamp($this->getCreatedAt()), null, null, @@ -106,11 +106,11 @@ abstract class AbstractModel extends \Magento\Core\Model\AbstractModel /** * Get object created at date affected with object store timezone * - * @return \Zend_Date + * @return \Magento\Stdlib\DateTime\Date */ public function getCreatedAtStoreDate() { - return $this->_coreLocale->storeDate( + return $this->_localeDate->scopeDate( $this->getStore(), $this->dateTime->toTimestamp($this->getCreatedAt()), true diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php index 8d26da9a9a4..fb4cf0c51c8 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/Create.php +++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php @@ -1129,7 +1129,7 @@ class Create extends \Magento\Object implements \Magento\Checkout\Model\Cart\Car */ protected function _parseCustomPrice($price) { - $price = $this->_objectManager->get('Magento\Core\Model\LocaleInterface')->getNumber($price); + $price = $this->_objectManager->get('Magento\Locale\FormatInterface')->getNumber($price); $price = $price > 0 ? $price : 0; return $price; } @@ -1156,6 +1156,7 @@ class Create extends \Magento\Object implements \Magento\Checkout\Model\Cart\Car \Magento\Customer\Service\V1\CustomerMetadataServiceInterface::ENTITY_TYPE_CUSTOMER, 'adminhtml_checkout', $customerDto->getAttributes(), + false, CustomerForm::DONT_IGNORE_INVISIBLE ); @@ -1186,9 +1187,9 @@ class Create extends \Magento\Object implements \Magento\Checkout\Model\Cart\Car CustomerMetadataServiceInterface::ENTITY_TYPE_ADDRESS, 'adminhtml_customer_address', $data, + $isAjax, CustomerForm::DONT_IGNORE_INVISIBLE, - [], - $isAjax + [] ); // prepare request diff --git a/app/code/Magento/Sales/Model/Observer.php b/app/code/Magento/Sales/Model/Observer.php index 46274ea5828..6f011568d36 100644 --- a/app/code/Magento/Sales/Model/Observer.php +++ b/app/code/Magento/Sales/Model/Observer.php @@ -77,9 +77,9 @@ class Observer protected $_quoteCollectionFactory; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_coreLocale; + protected $_localeDate; /** * @var Resource\Report\OrderFactory @@ -101,6 +101,11 @@ class Observer */ protected $_bestsellersFactory; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Customer\Helper\Data $customerData @@ -108,11 +113,12 @@ class Observer * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Core\Model\Store\Config $storeConfig * @param \Magento\Sales\Model\Resource\Quote\CollectionFactory $quoteFactory - * @param \Magento\Core\Model\LocaleInterface $coreLocale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param Resource\Report\OrderFactory $orderFactory * @param Resource\Report\InvoicedFactory $invoicedFactory * @param Resource\Report\RefundedFactory $refundedFactory * @param Resource\Report\BestsellersFactory $bestsellersFactory + * @param \Magento\Locale\ResolverInterface $localeResolver */ public function __construct( \Magento\Event\ManagerInterface $eventManager, @@ -121,11 +127,12 @@ class Observer \Magento\Catalog\Helper\Data $catalogData, \Magento\Core\Model\Store\Config $storeConfig, \Magento\Sales\Model\Resource\Quote\CollectionFactory $quoteFactory, - \Magento\Core\Model\LocaleInterface $coreLocale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Sales\Model\Resource\Report\OrderFactory $orderFactory, \Magento\Sales\Model\Resource\Report\InvoicedFactory $invoicedFactory, \Magento\Sales\Model\Resource\Report\RefundedFactory $refundedFactory, - \Magento\Sales\Model\Resource\Report\BestsellersFactory $bestsellersFactory + \Magento\Sales\Model\Resource\Report\BestsellersFactory $bestsellersFactory, + \Magento\Locale\ResolverInterface $localeResolver ) { $this->_eventManager = $eventManager; $this->_customerData = $customerData; @@ -133,11 +140,12 @@ class Observer $this->_catalogData = $catalogData; $this->_storeConfig = $storeConfig; $this->_quoteCollectionFactory = $quoteFactory; - $this->_coreLocale = $coreLocale; + $this->_localeDate = $localeDate; $this->_orderFactory = $orderFactory; $this->_invoicedFactory = $invoicedFactory; $this->_refundedFactory = $refundedFactory; $this->_bestsellersFactory = $bestsellersFactory; + $this->_localeResolver = $localeResolver; } /** @@ -200,11 +208,11 @@ class Observer */ public function aggregateSalesReportOrderData($schedule) { - $this->_coreLocale->emulate(0); - $currentDate = $this->_coreLocale->date(); + $this->_localeResolver->emulate(0); + $currentDate = $this->_localeDate->date(); $date = $currentDate->subHour(25); $this->_orderFactory->create()->aggregate($date); - $this->_coreLocale->revert(); + $this->_localeResolver->revert(); return $this; } @@ -216,11 +224,11 @@ class Observer */ public function aggregateSalesReportInvoicedData($schedule) { - $this->_coreLocale->emulate(0); - $currentDate = $this->_coreLocale->date(); + $this->_localeResolver->emulate(0); + $currentDate = $this->_localeDate->date(); $date = $currentDate->subHour(25); $this->_invoicedFactory->create()->aggregate($date); - $this->_coreLocale->revert(); + $this->_localeResolver->revert(); return $this; } @@ -232,11 +240,11 @@ class Observer */ public function aggregateSalesReportRefundedData($schedule) { - $this->_coreLocale->emulate(0); - $currentDate = $this->_coreLocale->date(); + $this->_localeResolver->emulate(0); + $currentDate = $this->_localeDate->date(); $date = $currentDate->subHour(25); $this->_refundedFactory->create()->aggregate($date); - $this->_coreLocale->revert(); + $this->_localeResolver->revert(); return $this; } @@ -248,11 +256,11 @@ class Observer */ public function aggregateSalesReportBestsellersData($schedule) { - $this->_coreLocale->emulate(0); - $currentDate = $this->_coreLocale->date(); + $this->_localeResolver->emulate(0); + $currentDate = $this->_localeDate->date(); $date = $currentDate->subHour(25); $this->_bestsellersFactory->create()->aggregate($date); - $this->_coreLocale->revert(); + $this->_localeResolver->revert(); return $this; } diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index e26a15effe5..09e63673f81 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -519,7 +519,7 @@ class Order extends \Magento\Sales\Model\AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\LocaleInterface $coreLocale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Sales\Helper\Data $salesData @@ -550,7 +550,7 @@ class Order extends \Magento\Sales\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $coreLocale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Payment\Helper\Data $paymentData, \Magento\Sales\Helper\Data $salesData, @@ -600,7 +600,7 @@ class Order extends \Magento\Sales\Model\AbstractModel $this->_shipmentCollectionFactory = $shipmentCollectionFactory; $this->_memoCollectionFactory = $memoCollectionFactory; $this->_trackCollectionFactory = $trackCollectionFactory; - parent::__construct($context, $registry, $coreLocale, $dateTime, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $localeDate, $dateTime, $resource, $resourceCollection, $data); } /** @@ -1177,7 +1177,7 @@ class Order extends \Magento\Sales\Model\AbstractModel * @throws \Magento\Core\Exception */ protected function _setState($state, $status = false, $comment = '', - $isCustomerNotified = null, $shouldProtectState = false + $isCustomerNotified = null, $shouldProtectState = false ) { // attempt to set the specified state if ($shouldProtectState) { @@ -2236,7 +2236,7 @@ class Order extends \Magento\Sales\Model\AbstractModel */ public function getCreatedAtFormated($format) { - return $this->_coreLocale->formatDate($this->getCreatedAtStoreDate(), $format, true); + return $this->_localeDate->formatDate($this->getCreatedAtStoreDate(), $format, true); } /** @@ -2332,7 +2332,7 @@ class Order extends \Magento\Sales\Model\AbstractModel * In case of "0" grand total order checking ForcedCanCreditmemo flag */ elseif (floatval($this->getTotalRefunded()) || (!$this->getTotalRefunded() - && $this->hasForcedCanCreditmemo()) + && $this->hasForcedCanCreditmemo()) ) { if ($this->getState() !== self::STATE_CLOSED) { $this->_setState(self::STATE_CLOSED, true, '', $userNotification); diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Creditmemo.php index 760e63c9f18..1c713207675 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo.php @@ -229,17 +229,17 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\LocaleInterface $coreLocale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Sales\Helper\Data $salesData * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig - * @param \Magento\Sales\Model\Order\Creditmemo\Config $creditmemoConfig + * @param Creditmemo\Config $creditmemoConfig * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\Resource\Order\Creditmemo\Item\CollectionFactory $cmItemCollectionFactory * @param \Magento\Math\CalculatorFactory $calculatorFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Sales\Model\Order\Creditmemo\CommentFactory $commentFactory + * @param Creditmemo\CommentFactory $commentFactory * @param \Magento\Sales\Model\Resource\Order\Creditmemo\Comment\CollectionFactory $commentCollectionFactory * @param \Magento\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Core\Model\Resource\AbstractResource $resource @@ -249,7 +249,7 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $coreLocale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Payment\Helper\Data $paymentData, \Magento\Sales\Helper\Data $salesData, @@ -277,7 +277,7 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel $this->_commentFactory = $commentFactory; $this->_commentCollectionFactory = $commentCollectionFactory; $this->_transportBuilder = $transportBuilder; - parent::__construct($context, $registry, $coreLocale, $dateTime, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $localeDate, $dateTime, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php index e2cb433ace7..61a8993901a 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php @@ -57,7 +57,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\LocaleInterface $coreLocale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Core\Model\Resource\AbstractResource $resource @@ -67,7 +67,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $coreLocale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Core\Model\Resource\AbstractResource $resource = null, @@ -75,7 +75,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel array $data = array() ) { parent::__construct( - $context, $registry, $coreLocale, $dateTime, $resource, $resourceCollection, $data + $context, $registry, $localeDate, $dateTime, $resource, $resourceCollection, $data ); $this->_storeManager = $storeManager; } diff --git a/app/code/Magento/Sales/Model/Order/Invoice.php b/app/code/Magento/Sales/Model/Order/Invoice.php index dfe122079f1..7d46551d081 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Invoice.php @@ -235,17 +235,17 @@ class Invoice extends \Magento\Sales\Model\AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\LocaleInterface $coreLocale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Sales\Helper\Data $salesData * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig - * @param \Magento\Sales\Model\Order\Invoice\Config $invoiceConfig + * @param Invoice\Config $invoiceConfig * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\Resource\OrderFactory $orderResourceFactory * @param \Magento\Math\CalculatorFactory $calculatorFactory * @param \Magento\Sales\Model\Resource\Order\Invoice\Item\CollectionFactory $invoiceItemCollectionFactory - * @param \Magento\Sales\Model\Order\Invoice\CommentFactory $invoiceCommentFactory + * @param Invoice\CommentFactory $invoiceCommentFactory * @param \Magento\Sales\Model\Resource\Order\Invoice\Comment\CollectionFactory $commentCollectionFactory * @param \Magento\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Core\Model\Resource\AbstractResource $resource @@ -255,7 +255,7 @@ class Invoice extends \Magento\Sales\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $coreLocale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Payment\Helper\Data $paymentData, \Magento\Sales\Helper\Data $salesData, @@ -283,7 +283,7 @@ class Invoice extends \Magento\Sales\Model\AbstractModel $this->_invoiceCommentFactory = $invoiceCommentFactory; $this->_commentCollectionFactory = $commentCollectionFactory; $this->_transportBuilder = $transportBuilder; - parent::__construct($context, $registry, $coreLocale, $dateTime, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $localeDate, $dateTime, $resource, $resourceCollection, $data); } /** @@ -408,8 +408,8 @@ class Invoice extends \Magento\Sales\Model\AbstractModel public function canCapture() { return $this->getState() != self::STATE_CANCELED - && $this->getState() != self::STATE_PAID - && $this->getOrder()->getPayment()->canCapture(); + && $this->getState() != self::STATE_PAID + && $this->getOrder()->getPayment()->canCapture(); } /** diff --git a/app/code/Magento/Sales/Model/Order/Invoice/Comment.php b/app/code/Magento/Sales/Model/Order/Invoice/Comment.php index 64628808750..4465d71fe80 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Invoice/Comment.php @@ -57,7 +57,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\LocaleInterface $coreLocale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Core\Model\Resource\AbstractResource $resource @@ -67,7 +67,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $coreLocale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Core\Model\Resource\AbstractResource $resource = null, @@ -75,7 +75,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel array $data = array() ) { parent::__construct( - $context, $registry, $coreLocale, $dateTime, $resource, $resourceCollection, $data + $context, $registry, $localeDate, $dateTime, $resource, $resourceCollection, $data ); $this->_storeManager = $storeManager; } diff --git a/app/code/Magento/Sales/Model/Order/Payment/Transaction.php b/app/code/Magento/Sales/Model/Order/Payment/Transaction.php index 1b06c6758f8..704c1d7a6df 100644 --- a/app/code/Magento/Sales/Model/Order/Payment/Transaction.php +++ b/app/code/Magento/Sales/Model/Order/Payment/Transaction.php @@ -156,7 +156,7 @@ class Transaction extends \Magento\Core\Model\AbstractModel protected $_orderFactory; /** - * @var \Magento\Core\Model\DateFactory + * @var \Magento\Stdlib\DateTime\DateTimeFactory */ protected $_dateFactory; @@ -165,7 +165,7 @@ class Transaction extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\Sales\Model\Order\PaymentFactory $paymentFactory * @param \Magento\Sales\Model\OrderFactory $orderFactory - * @param \Magento\Core\Model\DateFactory $dateFactory + * @param \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -175,7 +175,7 @@ class Transaction extends \Magento\Core\Model\AbstractModel \Magento\Registry $registry, \Magento\Sales\Model\Order\PaymentFactory $paymentFactory, \Magento\Sales\Model\OrderFactory $orderFactory, - \Magento\Core\Model\DateFactory $dateFactory, + \Magento\Stdlib\DateTime\DateTimeFactory $dateFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php b/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php index cfab231cff5..47769467b2d 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php @@ -82,9 +82,9 @@ abstract class AbstractPdf extends \Magento\Object protected $string; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $locale; + protected $_localeDate; /** * Core store config @@ -131,7 +131,7 @@ abstract class AbstractPdf extends \Magento\Object * @param \Magento\Sales\Model\Order\Pdf\Config $pdfConfig * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -145,11 +145,11 @@ abstract class AbstractPdf extends \Magento\Object \Magento\Sales\Model\Order\Pdf\Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, array $data = array() ) { $this->_paymentData = $paymentData; - $this->locale = $locale; + $this->_localeDate = $localeDate; $this->string = $string; $this->_coreStoreConfig = $coreStoreConfig; $this->_translate = $translate; @@ -375,7 +375,7 @@ abstract class AbstractPdf extends \Magento\Object ); } $page->drawText( - __('Order Date: ') . $this->locale->formatDate( + __('Order Date: ') . $this->_localeDate->formatDate( $order->getCreatedAtStoreDate(), 'medium', false ), 35, diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php index e73d35fae95..e5f0c9ae19e 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php @@ -36,6 +36,11 @@ class Creditmemo extends \Magento\Sales\Model\Order\Pdf\AbstractPdf */ protected $_storeManager; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Stdlib\String $string @@ -45,8 +50,9 @@ class Creditmemo extends \Magento\Sales\Model\Order\Pdf\AbstractPdf * @param \Magento\Sales\Model\Order\Pdf\Config $pdfConfig * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -60,11 +66,13 @@ class Creditmemo extends \Magento\Sales\Model\Order\Pdf\AbstractPdf \Magento\Sales\Model\Order\Pdf\Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\Locale\ResolverInterface $localeResolver, array $data = array() ) { $this->_storeManager = $storeManager; + $this->_localeResolver = $localeResolver; parent::__construct( $paymentData, $string, @@ -74,7 +82,7 @@ class Creditmemo extends \Magento\Sales\Model\Order\Pdf\AbstractPdf $pdfConfig, $pdfTotalFactory, $pdfItemsFactory, - $locale, + $localeDate, $data ); } @@ -169,7 +177,7 @@ class Creditmemo extends \Magento\Sales\Model\Order\Pdf\AbstractPdf foreach ($creditmemos as $creditmemo) { if ($creditmemo->getStoreId()) { - $this->locale->emulate($creditmemo->getStoreId()); + $this->_localeResolver->emulate($creditmemo->getStoreId()); $this->_storeManager->setCurrentStore($creditmemo->getStoreId()); } $page = $this->newPage(); @@ -207,7 +215,7 @@ class Creditmemo extends \Magento\Sales\Model\Order\Pdf\AbstractPdf } $this->_afterGetPdf(); if ($creditmemo->getStoreId()) { - $this->locale->revert(); + $this->_localeResolver->revert(); } return $pdf; } diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php b/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php index e1b5979419a..ca7bbf9f29e 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php @@ -36,6 +36,11 @@ class Invoice extends \Magento\Sales\Model\Order\Pdf\AbstractPdf */ protected $_storeManager; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Stdlib\String $string @@ -45,8 +50,9 @@ class Invoice extends \Magento\Sales\Model\Order\Pdf\AbstractPdf * @param \Magento\Sales\Model\Order\Pdf\Config $pdfConfig * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -60,11 +66,13 @@ class Invoice extends \Magento\Sales\Model\Order\Pdf\AbstractPdf \Magento\Sales\Model\Order\Pdf\Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\Locale\ResolverInterface $localeResolver, array $data = array() ) { $this->_storeManager = $storeManager; + $this->_localeResolver = $localeResolver; parent::__construct( $paymentData, $string, @@ -74,7 +82,7 @@ class Invoice extends \Magento\Sales\Model\Order\Pdf\AbstractPdf $pdfConfig, $pdfTotalFactory, $pdfItemsFactory, - $locale, + $localeDate, $data ); } @@ -160,7 +168,7 @@ class Invoice extends \Magento\Sales\Model\Order\Pdf\AbstractPdf foreach ($invoices as $invoice) { if ($invoice->getStoreId()) { - $this->locale->emulate($invoice->getStoreId()); + $this->_localeResolver->emulate($invoice->getStoreId()); $this->_storeManager->setCurrentStore($invoice->getStoreId()); } $page = $this->newPage(); @@ -193,7 +201,7 @@ class Invoice extends \Magento\Sales\Model\Order\Pdf\AbstractPdf /* Add totals */ $this->insertTotals($page, $invoice); if ($invoice->getStoreId()) { - $this->locale->revert(); + $this->_localeResolver->revert(); } } $this->_afterGetPdf(); diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php b/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php index afb01044d65..fb7bd6672ad 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php @@ -36,6 +36,11 @@ class Shipment extends \Magento\Sales\Model\Order\Pdf\AbstractPdf */ protected $_storeManager; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Stdlib\String $string @@ -45,8 +50,9 @@ class Shipment extends \Magento\Sales\Model\Order\Pdf\AbstractPdf * @param \Magento\Sales\Model\Order\Pdf\Config $pdfConfig * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -60,11 +66,13 @@ class Shipment extends \Magento\Sales\Model\Order\Pdf\AbstractPdf \Magento\Sales\Model\Order\Pdf\Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\Locale\ResolverInterface $localeResolver, array $data = array() ) { $this->_storeManager = $storeManager; + $this->_localeResolver = $localeResolver; parent::__construct( $paymentData, $string, @@ -74,7 +82,7 @@ class Shipment extends \Magento\Sales\Model\Order\Pdf\AbstractPdf $pdfConfig, $pdfTotalFactory, $pdfItemsFactory, - $locale, + $localeDate, $data ); } @@ -140,7 +148,7 @@ class Shipment extends \Magento\Sales\Model\Order\Pdf\AbstractPdf $this->_setFontBold($style, 10); foreach ($shipments as $shipment) { if ($shipment->getStoreId()) { - $this->locale->emulate($shipment->getStoreId()); + $this->_localeResolver->emulate($shipment->getStoreId()); $this->_storeManager->setCurrentStore($shipment->getStoreId()); } $page = $this->newPage(); @@ -173,7 +181,7 @@ class Shipment extends \Magento\Sales\Model\Order\Pdf\AbstractPdf } $this->_afterGetPdf(); if ($shipment->getStoreId()) { - $this->locale->revert(); + $this->_localeResolver->revert(); } return $pdf; } diff --git a/app/code/Magento/Sales/Model/Order/Shipment.php b/app/code/Magento/Sales/Model/Order/Shipment.php index e85d02519d4..38b2eac63d7 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment.php @@ -154,7 +154,7 @@ class Shipment extends \Magento\Sales\Model\AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\LocaleInterface $coreLocale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Sales\Helper\Data $salesData @@ -162,7 +162,7 @@ class Shipment extends \Magento\Sales\Model\AbstractModel * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\Resource\Order\Shipment\Item\CollectionFactory $shipmentItemCollectionFactory * @param \Magento\Sales\Model\Resource\Order\Shipment\Track\CollectionFactory $trackCollectionFactory - * @param \Magento\Sales\Model\Order\Shipment\CommentFactory $commentFactory + * @param Shipment\CommentFactory $commentFactory * @param \Magento\Sales\Model\Resource\Order\Shipment\Comment\CollectionFactory $commentCollectionFactory * @param \Magento\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Core\Model\Resource\AbstractResource $resource @@ -172,7 +172,7 @@ class Shipment extends \Magento\Sales\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $coreLocale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Payment\Helper\Data $paymentData, \Magento\Sales\Helper\Data $salesData, @@ -196,7 +196,7 @@ class Shipment extends \Magento\Sales\Model\AbstractModel $this->_commentFactory = $commentFactory; $this->_commentCollectionFactory = $commentCollectionFactory; $this->_transportBuilder = $transportBuilder; - parent::__construct($context, $registry, $coreLocale, $dateTime, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $localeDate, $dateTime, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Comment.php b/app/code/Magento/Sales/Model/Order/Shipment/Comment.php index 310baef559d..138fc94e514 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Comment.php @@ -57,7 +57,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\LocaleInterface $coreLocale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Core\Model\Resource\AbstractResource $resource @@ -67,7 +67,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $coreLocale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Core\Model\Resource\AbstractResource $resource = null, @@ -77,7 +77,7 @@ class Comment extends \Magento\Sales\Model\AbstractModel parent::__construct( $context, $registry, - $coreLocale, + $localeDate, $dateTime, $resource, $resourceCollection, diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Track.php b/app/code/Magento/Sales/Model/Order/Shipment/Track.php index fc03636c548..c73f71ca64c 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Track.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Track.php @@ -77,7 +77,7 @@ class Track extends \Magento\Sales\Model\AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\LocaleInterface $coreLocale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory @@ -88,7 +88,7 @@ class Track extends \Magento\Sales\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $coreLocale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory, @@ -99,7 +99,7 @@ class Track extends \Magento\Sales\Model\AbstractModel parent::__construct( $context, $registry, - $coreLocale, + $localeDate, $dateTime, $resource, $resourceCollection, diff --git a/app/code/Magento/Sales/Model/Order/Status/History.php b/app/code/Magento/Sales/Model/Order/Status/History.php index b595e72ca1a..34d426ebcd9 100644 --- a/app/code/Magento/Sales/Model/Order/Status/History.php +++ b/app/code/Magento/Sales/Model/Order/Status/History.php @@ -65,7 +65,7 @@ class History extends \Magento\Sales\Model\AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\LocaleInterface $coreLocale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Core\Model\Resource\AbstractResource $resource @@ -75,7 +75,7 @@ class History extends \Magento\Sales\Model\AbstractModel public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $coreLocale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Core\Model\Resource\AbstractResource $resource = null, @@ -85,7 +85,7 @@ class History extends \Magento\Sales\Model\AbstractModel parent::__construct( $context, $registry, - $coreLocale, + $localeDate, $dateTime, $resource, $resourceCollection, diff --git a/app/code/Magento/Sales/Model/Quote/Address/RateRequest.php b/app/code/Magento/Sales/Model/Quote/Address/RateRequest.php index b00b16de2b3..1cec3e7b29d 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/RateRequest.php +++ b/app/code/Magento/Sales/Model/Quote/Address/RateRequest.php @@ -48,12 +48,10 @@ namespace Magento\Sales\Model\Quote\Address; * - table (shiptable) * - condition_name: package_weight * - limit - * - carrier: ups - * - method: 3dp - * - ups - * - pickup: CC - * - container: CP - * - address: RES + * - carrier: carrier code + * - method: carrier method + * - shipping carrier + * - specific carrier fields * * @method int getStoreId() * @method \Magento\Sales\Model\Quote\Address\RateRequest setStoreId(int $value) diff --git a/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php b/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php index 9013941b8ab..f141d0fe185 100644 --- a/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php +++ b/app/code/Magento/Sales/Model/Quote/Address/RateResult/Method.php @@ -25,12 +25,12 @@ namespace Magento\Sales\Model\Quote\Address\RateResult; /** * Fields: - * - carrier: ups - * - carrierTitle: United Parcel Service - * - method: 2day - * - methodTitle: UPS 2nd Day Priority - * - price: $9.40 (cost+handling) - * - cost: $8.00 + * - carrier: carrier code + * - carrierTitle: carrier title + * - method: carrier method + * - methodTitle: method title + * - price: cost+handling + * - cost: cost */ class Method extends AbstractResult { diff --git a/app/code/Magento/Sales/Model/Quote/Item.php b/app/code/Magento/Sales/Model/Quote/Item.php index 03d7a137fef..ad4610fcd50 100644 --- a/app/code/Magento/Sales/Model/Quote/Item.php +++ b/app/code/Magento/Sales/Model/Quote/Item.php @@ -191,9 +191,9 @@ class Item extends \Magento\Sales\Model\Quote\Item\AbstractItem protected $_errorInfos; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\FormatInterface */ - protected $_locale; + protected $_localeFormat; /** * @var \Magento\Sales\Model\Quote\Item\OptionFactory @@ -205,7 +205,7 @@ class Item extends \Magento\Sales\Model\Quote\Item\AbstractItem * @param \Magento\Registry $registry * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Sales\Model\Status\ListFactory $statusListFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Sales\Model\Quote\Item\OptionFactory $itemOptionFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -218,14 +218,14 @@ class Item extends \Magento\Sales\Model\Quote\Item\AbstractItem \Magento\Registry $registry, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Sales\Model\Status\ListFactory $statusListFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\FormatInterface $localeFormat, \Magento\Sales\Model\Quote\Item\OptionFactory $itemOptionFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { $this->_errorInfos = $statusListFactory->create(); - $this->_locale = $locale; + $this->_localeFormat = $localeFormat; $this->_itemOptionFactory = $itemOptionFactory; parent::__construct($context, $registry, $productFactory, $resource, $resourceCollection, $data); } @@ -302,7 +302,7 @@ class Item extends \Magento\Sales\Model\Quote\Item\AbstractItem */ protected function _prepareQty($qty) { - $qty = $this->_locale->getNumber($qty); + $qty = $this->_localeFormat->getNumber($qty); $qty = ($qty > 0) ? $qty : 1; return $qty; } diff --git a/app/code/Magento/Sales/Model/Quote/Payment.php b/app/code/Magento/Sales/Model/Quote/Payment.php index e5218206925..dc03acc06ff 100644 --- a/app/code/Magento/Sales/Model/Quote/Payment.php +++ b/app/code/Magento/Sales/Model/Quote/Payment.php @@ -195,7 +195,7 @@ class Payment extends \Magento\Payment\Model\Info /** * Retrieve payment method model object * - * @return \Magento\Payment\Model\Method\AbstractMethod + * @return \Magento\Payment\Model\MethodInterface */ public function getMethodInstance() { diff --git a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php index db35ab7b836..5e02fb00fa9 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php @@ -57,7 +57,7 @@ class Bestsellers extends \Magento\Sales\Model\Resource\Report\AbstractReport /** * @param \Magento\App\Resource $resource * @param \Magento\Logger $logger - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator @@ -68,7 +68,7 @@ class Bestsellers extends \Magento\Sales\Model\Resource\Report\AbstractReport public function __construct( \Magento\App\Resource $resource, \Magento\Logger $logger, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Reports\Model\FlagFactory $reportsFlagFactory, \Magento\Stdlib\DateTime $dateTime, \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator, @@ -76,7 +76,7 @@ class Bestsellers extends \Magento\Sales\Model\Resource\Report\AbstractReport \Magento\Sales\Model\Resource\Helper $salesResourceHelper, array $ignoredProductTypes = array() ) { - parent::__construct($resource, $logger, $locale, $reportsFlagFactory, $dateTime, $timezoneValidator); + parent::__construct($resource, $logger, $localeDate, $reportsFlagFactory, $dateTime, $timezoneValidator); $this->_productResource = $productResource; $this->_salesResourceHelper = $salesResourceHelper; $this->ignoredProductTypes = array_merge($this->ignoredProductTypes, $ignoredProductTypes); diff --git a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers/Collection.php b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers/Collection.php index 76fdd348e17..d7ae88a47f7 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers/Collection.php @@ -233,8 +233,8 @@ class Collection // apply date boundaries (before calling $this->_applyDateRangeFilter()) $dtFormat = \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT; - $periodFrom = (!is_null($this->_from) ? new \Zend_Date($this->_from, $dtFormat) : null); - $periodTo = (!is_null($this->_to) ? new \Zend_Date($this->_to, $dtFormat) : null); + $periodFrom = (!is_null($this->_from) ? new \Magento\Stdlib\DateTime\Date($this->_from, $dtFormat) : null); + $periodTo = (!is_null($this->_to) ? new \Magento\Stdlib\DateTime\Date($this->_to, $dtFormat) : null); if ('year' == $this->_period) { if ($periodFrom) { diff --git a/app/code/Magento/Sales/Model/Resource/Report/Order.php b/app/code/Magento/Sales/Model/Resource/Report/Order.php index d2188ac9cf4..f4b62b43c43 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Order.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Order.php @@ -44,7 +44,7 @@ class Order extends \Magento\Sales\Model\Resource\Report\AbstractReport /** * @param \Magento\App\Resource $resource * @param \Magento\Logger $logger - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator @@ -54,7 +54,7 @@ class Order extends \Magento\Sales\Model\Resource\Report\AbstractReport public function __construct( \Magento\App\Resource $resource, \Magento\Logger $logger, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Reports\Model\FlagFactory $reportsFlagFactory, \Magento\Stdlib\DateTime $dateTime, \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator, @@ -62,7 +62,7 @@ class Order extends \Magento\Sales\Model\Resource\Report\AbstractReport \Magento\Sales\Model\Resource\Report\Order\UpdatedatFactory $updateDatFactory ) { - parent::__construct($resource, $logger, $locale, $reportsFlagFactory, $dateTime, $timezoneValidator); + parent::__construct($resource, $logger, $localeDate, $reportsFlagFactory, $dateTime, $timezoneValidator); $this->_createDatFactory = $createDatFactory; $this->_updateDatFactory = $updateDatFactory; } diff --git a/app/code/Magento/Sales/Model/Resource/Sale/Collection.php b/app/code/Magento/Sales/Model/Resource/Sale/Collection.php index 7db5eaf18c9..7eaec2925d8 100644 --- a/app/code/Magento/Sales/Model/Resource/Sale/Collection.php +++ b/app/code/Magento/Sales/Model/Resource/Sale/Collection.php @@ -18,17 +18,14 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Sales * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Sales\Model\Resource\Sale; /** * Sales Collection */ -namespace Magento\Sales\Model\Resource\Sale; - class Collection extends \Magento\Data\Collection\Db { /** @@ -44,6 +41,8 @@ class Collection extends \Magento\Data\Collection\Db ); /** + * Customer Id + * * @var int */ protected $_customerId; @@ -102,12 +101,12 @@ class Collection extends \Magento\Data\Collection\Db } /** - * Set filter by customer + * Set filter by customer Id * * @param int $customerId - * @return \Magento\Sales\Model\Resource\Sale\Collection + * @return $this */ - public function setCustomerFilter($customerId) + public function setCustomerIdFilter($customerId) { $this->_customerId = (int)$customerId; return $this; @@ -217,7 +216,7 @@ class Collection extends \Magento\Data\Collection\Db ->setWebsiteId($this->_storeManager->getStore($storeId)->getWebsiteId()) ->setAvgNormalized($v['avgsale'] * $v['num_orders']); $this->_items[$storeId] = $storeObject; - foreach ($this->_totals as $key => $value) { + foreach (array_keys($this->_totals) as $key) { $this->_totals[$key] += $storeObject->getData($key); } } diff --git a/app/code/Magento/Sales/Model/Service/Quote.php b/app/code/Magento/Sales/Model/Service/Quote.php index 32bc1f1bad1..fa45929ba10 100644 --- a/app/code/Magento/Sales/Model/Service/Quote.php +++ b/app/code/Magento/Sales/Model/Service/Quote.php @@ -241,21 +241,30 @@ class Quote /** * We can use configuration data for declare new order status */ - $this->_eventManager->dispatch('checkout_type_onepage_save_order', array( - 'order' => $order, - 'quote' => $quote - )); - $this->_eventManager->dispatch('sales_model_service_quote_submit_before', array( - 'order' => $order, - 'quote' => $quote - )); + $this->_eventManager->dispatch( + 'checkout_type_onepage_save_order', + array( + 'order' => $order, + 'quote' => $quote + ) + ); + $this->_eventManager->dispatch( + 'sales_model_service_quote_submit_before', + array( + 'order' => $order, + 'quote' => $quote + ) + ); try { $transaction->save(); $this->_inactivateQuote(); - $this->_eventManager->dispatch('sales_model_service_quote_submit_success', array( - 'order' => $order, - 'quote' => $quote - )); + $this->_eventManager->dispatch( + 'sales_model_service_quote_submit_success', + array( + 'order' => $order, + 'quote' => $quote + ) + ); } catch (\Exception $e) { if (!$this->_customerSession->isLoggedIn()) { // reset customer ID's on exception, because customer not saved @@ -270,16 +279,22 @@ class Quote $item->setItemId(null); } - $this->_eventManager->dispatch('sales_model_service_quote_submit_failure', array( + $this->_eventManager->dispatch( + 'sales_model_service_quote_submit_failure', + array( 'order' => $order, 'quote' => $quote - )); + ) + ); throw $e; } - $this->_eventManager->dispatch('sales_model_service_quote_submit_after', array( + $this->_eventManager->dispatch( + 'sales_model_service_quote_submit_after', + array( 'order' => $order, 'quote' => $quote - )); + ) + ); $this->_order = $order; return $order; } @@ -328,13 +343,16 @@ class Quote foreach ($addresses as $address) { if ($address->isDefaultBilling()) { $quote->getBillingAddress()->setCustomerAddressData($address); - } else if ($address->isDefaultShipping()) { - $quote->getShippingAddress()->setCustomerAddressData($address); + } else { + if ($address->isDefaultShipping()) { + $quote->getShippingAddress()->setCustomerAddressData($address); + } } } if ($quote->getShippingAddress() && $quote->getShippingAddress()->getSameAsBilling()) { $quote->getShippingAddress()->setCustomerAddressData( - $quote->getBillingAddress()->getCustomerAddressData()); + $quote->getBillingAddress()->getCustomerAddressData() + ); } } @@ -356,7 +374,8 @@ class Quote $order->setShippingAddress($this->_convertor->addressToOrderAddress($quote->getShippingAddress())); if ($quote->getShippingAddress()->getCustomerAddressData()) { $order->getShippingAddress()->setCustomerAddressData( - $quote->getShippingAddress()->getCustomerAddressData()); + $quote->getShippingAddress()->getCustomerAddressData() + ); } } $order->setPayment($this->_convertor->paymentToOrderPayment($quote->getPayment())); @@ -385,21 +404,30 @@ class Quote /** * We can use configuration data for declare new order status */ - $this->_eventManager->dispatch('checkout_type_onepage_save_order', array( - 'order' => $order, - 'quote' => $quote - )); - $this->_eventManager->dispatch('sales_model_service_quote_submit_before', array( - 'order' => $order, - 'quote' => $quote - )); + $this->_eventManager->dispatch( + 'checkout_type_onepage_save_order', + array( + 'order' => $order, + 'quote' => $quote + ) + ); + $this->_eventManager->dispatch( + 'sales_model_service_quote_submit_before', + array( + 'order' => $order, + 'quote' => $quote + ) + ); try { $transaction->save(); $this->_inactivateQuote(); - $this->_eventManager->dispatch('sales_model_service_quote_submit_success', array( - 'order' => $order, - 'quote' => $quote - )); + $this->_eventManager->dispatch( + 'sales_model_service_quote_submit_success', + array( + 'order' => $order, + 'quote' => $quote + ) + ); } catch (\Exception $e) { if ($originalCustomerDto) { //Restore original customer data if existing customer was updated $this->_customerService->saveCustomer($originalCustomerDto); @@ -418,16 +446,22 @@ class Quote $item->setItemId(null); } - $this->_eventManager->dispatch('sales_model_service_quote_submit_failure', array( - 'order' => $order, - 'quote' => $quote - )); + $this->_eventManager->dispatch( + 'sales_model_service_quote_submit_failure', + array( + 'order' => $order, + 'quote' => $quote + ) + ); throw $e; } - $this->_eventManager->dispatch('sales_model_service_quote_submit_after', array( - 'order' => $order, - 'quote' => $quote - )); + $this->_eventManager->dispatch( + 'sales_model_service_quote_submit_after', + array( + 'order' => $order, + 'quote' => $quote + ) + ); $this->_order = $order; return $order; } @@ -503,16 +537,6 @@ class Quote return $this->_order; } - /** - * Get response when CustomerAccountService was invoked to create a new customer account - * - * @return CreateCustomerAccountResponse - */ - public function getCreateCustomerResponse() - { - return $this->_createCustomerResponse; - } - /** * Inactivate quote * @@ -542,8 +566,8 @@ class Quote __('Please check the shipping address information. %1', implode(' ', $addressValidation)) ); } - $method= $address->getShippingMethod(); - $rate = $address->getShippingRateByCode($method); + $method = $address->getShippingMethod(); + $rate = $address->getShippingRateByCode($method); if (!$this->getQuote()->isVirtual() && (!$method || !$rate)) { throw new \Magento\Core\Exception(__('Please specify a shipping method.')); } diff --git a/app/code/Magento/Sales/etc/adminhtml/events.xml b/app/code/Magento/Sales/etc/adminhtml/events.xml index 14208c0c533..15081733d43 100644 --- a/app/code/Magento/Sales/etc/adminhtml/events.xml +++ b/app/code/Magento/Sales/etc/adminhtml/events.xml @@ -36,9 +36,6 @@ <event name="catalog_product_save_after"> <observer name="sales_quote" instance="Magento\Sales\Model\Observer\Backend\CatalogProductQuote" method="catalogProductSaveAfter" /> </event> - <event name="payment_method_is_active"> - <observer name="sales_billing_agreement" instance="Magento\Sales\Model\Observer\Backend\BillingAgreement" method="dispatch" /> - </event> <event name="catalog_product_status_update"> <observer name="sales_quote" instance="Magento\Sales\Model\Observer\Backend\CatalogProductQuote" method="catalogProductStatusUpdate" /> </event> diff --git a/app/code/Magento/Sales/etc/fieldset.xml b/app/code/Magento/Sales/etc/fieldset.xml index 237b770b2af..c2e1b6b716e 100644 --- a/app/code/Magento/Sales/etc/fieldset.xml +++ b/app/code/Magento/Sales/etc/fieldset.xml @@ -502,9 +502,6 @@ <field name="is_nominal"> <aspect name="to_order_item" /> </field> - <field name="free_shipping"> - <aspect name="to_order_item" /> - </field> </fieldset> <fieldset id="sales_convert_order"> <field name="customer_id"> @@ -808,9 +805,6 @@ <aspect name="to_cm_item" /> <aspect name="to_quote_item" /> </field> - <field name="free_shipping"> - <aspect name="to_quote_item" /> - </field> </fieldset> <fieldset id="customer_account"> <field name="id"> diff --git a/app/code/Magento/Sales/sql/sales_setup/install-1.6.0.0.php b/app/code/Magento/Sales/sql/sales_setup/install-1.6.0.0.php index 6c6e88adb29..1575fb94d1c 100644 --- a/app/code/Magento/Sales/sql/sales_setup/install-1.6.0.0.php +++ b/app/code/Magento/Sales/sql/sales_setup/install-1.6.0.0.php @@ -587,11 +587,6 @@ $table = $installer->getConnection() ), 'Applied Rule Ids') ->addColumn('additional_data', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array( ), 'Additional Data') - ->addColumn('free_shipping', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Free Shipping') ->addColumn('is_qty_decimal', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( 'unsigned' => true, ), 'Is Qty Decimal') @@ -1989,11 +1984,6 @@ $table = $installer->getConnection() 'nullable' => false, 'default' => '0', ), 'Same As Billing') - ->addColumn('free_shipping', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Free Shipping') ->addColumn('collect_shipping_rates', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( 'unsigned' => true, 'nullable' => false, @@ -2138,11 +2128,6 @@ $table = $installer->getConnection() ), 'Applied Rule Ids') ->addColumn('additional_data', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array( ), 'Additional Data') - ->addColumn('free_shipping', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Free Shipping') ->addColumn('is_qty_decimal', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( 'unsigned' => true, ), 'Is Qty Decimal') @@ -2330,9 +2315,6 @@ $table = $installer->getConnection() ), 'Name') ->addColumn('description', \Magento\DB\Ddl\Table::TYPE_TEXT, '64k', array( ), 'Description') - ->addColumn('free_shipping', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array( - 'unsigned' => true, - ), 'Free Shipping') ->addColumn('is_qty_decimal', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array( 'unsigned' => true, ), 'Is Qty Decimal') diff --git a/app/code/Magento/Sales/view/frontend/layout/default.xml b/app/code/Magento/Sales/view/frontend/layout/default.xml index 2f8fce07421..f84fadfdb49 100644 --- a/app/code/Magento/Sales/view/frontend/layout/default.xml +++ b/app/code/Magento/Sales/view/frontend/layout/default.xml @@ -25,10 +25,10 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceContainer name="right"> - <block class="Magento\Sales\Block\Reorder\Sidebar" name="sale.reorder.sidebar" as="reorder" template="reorder/sidebar.phtml" cacheable="false"/> + <block class="Magento\Sales\Block\Reorder\Sidebar" name="sale.reorder.sidebar" as="reorder" template="reorder/sidebar.phtml"/> </referenceContainer> <referenceBlock name="footer_links"> - <block class="Magento\Sales\Block\Guest\Link" name="sales-guest-form-link" cacheable="false"> + <block class="Magento\Sales\Block\Guest\Link" name="sales-guest-form-link"> <arguments> <argument name="label" xsi:type="string">Orders and Returns</argument> <argument name="path" xsi:type="string">sales/guest/form</argument> diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote.php index 9a65ba428e4..400af05a167 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Block\Adminhtml\Promo; /** * Catalog price rules @@ -32,11 +33,13 @@ * @package Magento_Adminhtml * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\SalesRule\Block\Adminhtml\Promo; - class Quote extends \Magento\Backend\Block\Widget\Grid\Container { + /** + * Constructor + * + * @return void + */ protected function _construct() { $this->_controller = 'promo_quote'; diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit.php index ec9ee97ec9a..d879f175f34 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit.php @@ -23,13 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote; /** * Shopping cart rule edit form block */ - -namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote; - class Edit extends \Magento\Backend\Block\Widget\Form\Container { /** @@ -57,6 +55,8 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container * Initialize form * Add standard buttons * Add "Save and Continue" button + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Form.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Form.php index 391e952a04c..36f8e81ba79 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Form.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Form.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit; /** * description @@ -32,17 +33,25 @@ * @package Magento_Adminhtml * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit; - class Form extends \Magento\Backend\Block\Widget\Form\Generic { + /** + * Constructor + * + * @return void + */ protected function _construct() { parent::_construct(); $this->setId('promo_quote_form'); $this->setTitle(__('Rule Information')); } - + + /** + * Prepare form before rendering HTML + * + * @return $this + */ protected function _prepareForm() { /** @var \Magento\Data\Form $form */ diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Actions.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Actions.php index b1725fcc90a..350810a790d 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Actions.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Actions.php @@ -23,7 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab; class Actions @@ -72,9 +71,7 @@ class Actions } /** - * Prepare content for tab - * - * @return string + * {@inheritdoc} */ public function getTabLabel() { @@ -82,9 +79,7 @@ class Actions } /** - * Prepare title for tab - * - * @return string + * {@inheritdoc} */ public function getTabTitle() { @@ -92,9 +87,7 @@ class Actions } /** - * Returns status flag about this tab can be showen or not - * - * @return true + * {@inheritdoc} */ public function canShowTab() { @@ -102,15 +95,18 @@ class Actions } /** - * Returns status flag about this tab hidden or not - * - * @return true + * {@inheritdoc} */ public function isHidden() { return false; } + /** + * Prepare form before rendering HTML + * + * @return $this + */ protected function _prepareForm() { $model = $this->_coreRegistry->registry('current_promo_quote_rule'); @@ -159,17 +155,6 @@ class Actions 'values' => $this->_sourceYesno->toOptionArray(), )); - $fieldset->addField('simple_free_shipping', 'select', array( - 'label' => __('Free Shipping'), - 'title' => __('Free Shipping'), - 'name' => 'simple_free_shipping', - 'options' => array( - 0 => __('No'), - \Magento\SalesRule\Model\Rule::FREE_SHIPPING_ITEM => __('For matching items only'), - \Magento\SalesRule\Model\Rule::FREE_SHIPPING_ADDRESS => __('For shipment with matching items'), - ), - )); - $fieldset->addField('stop_rules_processing', 'select', array( 'label' => __('Stop Further Rules Processing'), 'title' => __('Stop Further Rules Processing'), diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Conditions.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Conditions.php index 8bebe422b71..8df7387c316 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Conditions.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Conditions.php @@ -23,7 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab; class Conditions @@ -64,9 +63,7 @@ class Conditions } /** - * Prepare content for tab - * - * @return string + * {@inheritdoc} */ public function getTabLabel() { @@ -74,9 +71,7 @@ class Conditions } /** - * Prepare title for tab - * - * @return string + * {@inheritdoc} */ public function getTabTitle() { @@ -84,9 +79,7 @@ class Conditions } /** - * Returns status flag about this tab can be showen or not - * - * @return true + * {@inheritdoc} */ public function canShowTab() { @@ -94,15 +87,18 @@ class Conditions } /** - * Returns status flag about this tab hidden or not - * - * @return true + * {@inheritdoc} */ public function isHidden() { return false; } + /** + * Prepare form before rendering HTML + * + * @return $this + */ protected function _prepareForm() { $model = $this->_coreRegistry->registry('current_promo_quote_rule'); diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons.php index 47369de617b..936e9071d53 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab; /** * "Manage Coupons Codes" Tab @@ -31,8 +32,6 @@ * @package Magento_Adminhtml * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab; - class Coupons extends \Magento\Backend\Block\Text\ListText implements \Magento\Backend\Block\Widget\Tab\TabInterface @@ -45,8 +44,8 @@ class Coupons protected $_coreRegistry = null; /** - * @param \Magento\Registry $registry * @param \Magento\View\Element\Context $context + * @param \Magento\Registry $registry * @param array $data */ public function __construct( @@ -59,9 +58,7 @@ class Coupons } /** - * Prepare content for tab - * - * @return string + * {@inheritdoc} */ public function getTabLabel() { @@ -69,9 +66,7 @@ class Coupons } /** - * Prepare title for tab - * - * @return string + * {@inheritdoc} */ public function getTabTitle() { @@ -79,9 +74,7 @@ class Coupons } /** - * Returns status flag about this tab can be shown or not - * - * @return bool + * {@inheritdoc} */ public function canShowTab() { @@ -89,9 +82,7 @@ class Coupons } /** - * Returns status flag about this tab hidden or not - * - * @return bool + * {@inheritdoc} */ public function isHidden() { diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Form.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Form.php index 7c4f41896ea..113d8485510 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Form.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Form.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons; /** * Coupons generation parameters form @@ -32,8 +32,6 @@ * @package Magento_Adminhtml * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons; - class Form extends \Magento\Backend\Block\Widget\Form\Generic { @@ -65,7 +63,7 @@ class Form /** * Prepare coupon codes generation parameters form * - * @return \Magento\Backend\Block\Widget\Form + * @return $this */ protected function _prepareForm() { diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid.php index 55fba8af09f..5550741178b 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons; /** * Coupon codes grid @@ -32,8 +32,6 @@ * @package Magento_Adminhtml * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons; - class Grid extends \Magento\Backend\Block\Widget\Grid\Extended { /** @@ -69,6 +67,8 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * Constructor + * + * @return void */ protected function _construct() { @@ -80,7 +80,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * Prepare collection for grid * - * @return \Magento\Backend\Block\Widget\Grid\Extended + * @return $this */ protected function _prepareCollection() { @@ -101,7 +101,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * Define grid columns * - * @return \Magento\Backend\Block\Widget\Grid\Extended + * @return $this */ protected function _prepareColumns() { @@ -148,7 +148,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * Configure grid mass actions * - * @return \Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Grid + * @return $this */ protected function _prepareMassaction() { diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid/Column/Renderer/Used.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid/Column/Renderer/Used.php index e7239e2baa6..9dc12f1cb3c 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid/Column/Renderer/Used.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid/Column/Renderer/Used.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Grid\Column\Renderer; /** * Coupon codes grid "Used" column renderer @@ -31,11 +32,13 @@ * @package Magento_Adminhtml * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Grid\Column\Renderer; - class Used extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Text { + /** + * @param \Magento\Object $row + * @return string + */ public function render(\Magento\Object $row) { $value = (int)$row->getData($this->getColumn()->getIndex()); diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Labels.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Labels.php index efff445a745..5784bc9829f 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Labels.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Labels.php @@ -23,7 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab; class Labels @@ -31,9 +30,7 @@ class Labels implements \Magento\Backend\Block\Widget\Tab\TabInterface { /** - * Prepare content for tab - * - * @return string + * {@inheritdoc} */ public function getTabLabel() { @@ -41,9 +38,7 @@ class Labels } /** - * Prepare title for tab - * - * @return string + * {@inheritdoc} */ public function getTabTitle() { @@ -51,9 +46,7 @@ class Labels } /** - * Returns status flag about this tab can be showen or not - * - * @return bool + * {@inheritdoc} */ public function canShowTab() { @@ -61,15 +54,18 @@ class Labels } /** - * Returns status flag about this tab hidden or not - * - * @return bool + * {@inheritdoc} */ public function isHidden() { return false; } + /** + * Prepare form before rendering HTML + * + * @return $this + */ protected function _prepareForm() { $rule = $rule = $this->_coreRegistry->registry('current_promo_quote_rule'); @@ -109,7 +105,7 @@ class Labels * * @param \Magento\Data\Form $form * @param array $labels - * @return \Magento\Data\Form\Element\Fieldset mixed + * @return \Magento\Data\Form\Element\Fieldset */ protected function _createStoreSpecificFieldset($form, $labels) { diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Main.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Main.php index 111f2fd2e44..67e3d81210d 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Main.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Main.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab; /** * Shopping Cart Price Rule General Information Tab @@ -31,8 +32,6 @@ * @package Magento_Adminhtml * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab; - class Main extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface @@ -77,9 +76,7 @@ class Main } /** - * Prepare content for tab - * - * @return string + * {@inheritdoc} */ public function getTabLabel() { @@ -87,9 +84,7 @@ class Main } /** - * Prepare title for tab - * - * @return string + * {@inheritdoc} */ public function getTabTitle() { @@ -97,9 +92,7 @@ class Main } /** - * Returns status flag about this tab can be showed or not - * - * @return true + * {@inheritdoc} */ public function canShowTab() { @@ -107,15 +100,18 @@ class Main } /** - * Returns status flag about this tab hidden or not - * - * @return true + * {@inheritdoc} */ public function isHidden() { return false; } + /** + * Prepare form before rendering HTML + * + * @return $this + */ protected function _prepareForm() { $model = $this->_coreRegistry->registry('current_promo_quote_rule'); @@ -244,7 +240,7 @@ class Main 'label' => __('Uses per Customer'), )); - $dateFormat = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + $dateFormat = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); $fieldset->addField('from_date', 'date', array( 'name' => 'from_date', 'label' => __('From Date'), diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Main/Renderer/Checkbox.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Main/Renderer/Checkbox.php index b1e0e26c15e..15b9e7c8ca0 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Main/Renderer/Checkbox.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Main/Renderer/Checkbox.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Main\Renderer; /** * Renderer for specific checkbox that is used on Rule Information tab in Shopping cart price rules @@ -31,8 +32,6 @@ * @package Magento_Adminhtml * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Main\Renderer; - class Checkbox extends \Magento\Backend\Block\AbstractBlock implements \Magento\Data\Form\Element\Renderer\RendererInterface diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tabs.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tabs.php index 375d8b1949a..7da82b64b7d 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tabs.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tabs.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit; /** * description @@ -32,11 +33,13 @@ * @package Magento_Adminhtml * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit; - class Tabs extends \Magento\Backend\Block\Widget\Tabs { - + /** + * Constructor + * + * @return void + */ protected function _construct() { parent::_construct(); diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Widget/Chooser.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Widget/Chooser.php index 6bca308be0b..b0580555382 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Widget/Chooser.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Widget/Chooser.php @@ -48,6 +48,8 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended /** * Block constructor, prepare grid params + * + * @return void */ protected function _construct() { @@ -60,7 +62,7 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended /** * Prepare rules collection * - * @return Chooser + * @return $this */ protected function _prepareCollection() { @@ -127,7 +129,7 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended /** * Prepare columns for rules grid * - * @return Chooser + * @return $this */ protected function _prepareColumns() { diff --git a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote.php b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote.php index 38e4b7b5192..fccc421427d 100644 --- a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote.php +++ b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote.php @@ -23,7 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\SalesRule\Controller\Adminhtml\Promo; class Quote extends \Magento\Backend\App\Action @@ -41,7 +40,7 @@ class Quote extends \Magento\Backend\App\Action protected $_fileFactory; /** - * @var \Magento\Core\Filter\Date + * @var \Magento\Stdlib\DateTime\Filter\Date */ protected $_dateFilter; @@ -49,13 +48,13 @@ class Quote extends \Magento\Backend\App\Action * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Registry $coreRegistry * @param \Magento\App\Response\Http\FileFactory $fileFactory - * @param \Magento\Core\Filter\Date $dateFilter + * @param \Magento\Stdlib\DateTime\Filter\Date $dateFilter */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Registry $coreRegistry, \Magento\App\Response\Http\FileFactory $fileFactory, - \Magento\Core\Filter\Date $dateFilter + \Magento\Stdlib\DateTime\Filter\Date $dateFilter ) { parent::__construct($context); $this->_coreRegistry = $coreRegistry; @@ -63,6 +62,11 @@ class Quote extends \Magento\Backend\App\Action $this->_dateFilter = $dateFilter; } + /** + * Initiate rule + * + * @return void + */ protected function _initRule() { $this->_title->add(__('Cart Price Rules')); @@ -79,6 +83,11 @@ class Quote extends \Magento\Backend\App\Action } } + /** + * Initiate action + * + * @return this + */ protected function _initAction() { $this->_view->loadLayout(); @@ -88,6 +97,11 @@ class Quote extends \Magento\Backend\App\Action return $this; } + /** + * Index action + * + * @return void + */ public function indexAction() { $this->_title->add(__('Cart Price Rules')); @@ -97,11 +111,21 @@ class Quote extends \Magento\Backend\App\Action $this->_view->renderLayout(); } + /** + * New promo quote action + * + * @return void + */ public function newAction() { $this->_forward('edit'); } + /** + * Promo quote edit action + * + * @return void + */ public function editAction() { $id = $this->getRequest()->getParam('id'); @@ -145,6 +169,7 @@ class Quote extends \Magento\Backend\App\Action /** * Promo quote save action * + * @return void */ public function saveAction() { @@ -230,6 +255,11 @@ class Quote extends \Magento\Backend\App\Action $this->_redirect('sales_rule/*/'); } + /** + * Delete promo quote action + * + * @return void + */ public function deleteAction() { $id = $this->getRequest()->getParam('id'); @@ -255,6 +285,11 @@ class Quote extends \Magento\Backend\App\Action $this->_redirect('sales_rule/*/'); } + /** + * New condition html action + * + * @return void + */ public function newConditionHtmlAction() { $id = $this->getRequest()->getParam('id'); @@ -279,6 +314,11 @@ class Quote extends \Magento\Backend\App\Action $this->getResponse()->setBody($html); } + /** + * New action html action + * + * @return void + */ public function newActionHtmlAction() { $id = $this->getRequest()->getParam('id'); @@ -303,6 +343,11 @@ class Quote extends \Magento\Backend\App\Action $this->getResponse()->setBody($html); } + /** + * Apply rules action + * + * @return void + */ public function applyRulesAction() { $this->_initAction(); @@ -311,6 +356,8 @@ class Quote extends \Magento\Backend\App\Action /** * Coupon codes grid + * + * @return void */ public function couponsGridAction() { @@ -362,6 +409,8 @@ class Quote extends \Magento\Backend\App\Action /** * Coupons mass delete action + * + * @return void */ public function couponsMassDeleteAction() { @@ -387,6 +436,8 @@ class Quote extends \Magento\Backend\App\Action /** * Generate Coupons action + * + * @return void */ public function generateAction() { @@ -434,6 +485,8 @@ class Quote extends \Magento\Backend\App\Action /** * Chooser source action + * + * @return void */ public function chooserAction() { @@ -448,7 +501,8 @@ class Quote extends \Magento\Backend\App\Action /** * Returns result of current user permission check on resource and privilege - * @return boolean + * + * @return bool */ protected function _isAllowed() { diff --git a/app/code/Magento/SalesRule/Exception.php b/app/code/Magento/SalesRule/Exception.php index 12e9048e3d4..2ca08fb2dbd 100644 --- a/app/code/Magento/SalesRule/Exception.php +++ b/app/code/Magento/SalesRule/Exception.php @@ -23,8 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - namespace Magento\SalesRule; class Exception extends \Zend_Exception diff --git a/app/code/Magento/SalesRule/Helper/Coupon.php b/app/code/Magento/SalesRule/Helper/Coupon.php index 12b747e7dc6..662013bf8b8 100644 --- a/app/code/Magento/SalesRule/Helper/Coupon.php +++ b/app/code/Magento/SalesRule/Helper/Coupon.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Helper; /** * Helper for coupon codes creating and managing @@ -31,8 +32,6 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Helper; - class Coupon extends \Magento\App\Helper\AbstractHelper { /** diff --git a/app/code/Magento/SalesRule/Helper/Data.php b/app/code/Magento/SalesRule/Helper/Data.php index 6bdb8cbe601..5c3f4e989b1 100644 --- a/app/code/Magento/SalesRule/Helper/Data.php +++ b/app/code/Magento/SalesRule/Helper/Data.php @@ -23,23 +23,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Helper; +use Magento\Sales\Model\Quote\Item\AbstractItem; /** * SalesRule data helper */ -namespace Magento\SalesRule\Helper; - class Data extends \Magento\App\Helper\AbstractHelper { /** * Set store and base price which will be used during discount calculation to item object * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item - * @param float $basePrice - * @param float $price - * @return \Magento\SalesRule\Helper\Data + * @param AbstractItem $item + * @param float $basePrice + * @param float $price + * @return $this */ - public function setItemDiscountPrices(\Magento\Sales\Model\Quote\Item\AbstractItem $item, $basePrice, $price) + public function setItemDiscountPrices(AbstractItem $item, $basePrice, $price) { $item->setDiscountCalculationPrice($price); $item->setBaseDiscountCalculationPrice($basePrice); @@ -49,12 +49,12 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Add additional amounts to discount calculation prices * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item - * @param float $basePrice - * @param float $price - * @return \Magento\SalesRule\Helper\Data + * @param AbstractItem $item + * @param float $basePrice + * @param float $price + * @return $this */ - public function addItemDiscountPrices(\Magento\Sales\Model\Quote\Item\AbstractItem $item, $basePrice, $price) + public function addItemDiscountPrices(AbstractItem $item, $basePrice, $price) { $discountPrice = $item->getDiscountCalculationPrice(); $baseDiscountPrice = $item->getBaseDiscountCalculationPrice(); diff --git a/app/code/Magento/SalesRule/Model/Coupon.php b/app/code/Magento/SalesRule/Model/Coupon.php index 248a12c4824..23cf86b4a12 100644 --- a/app/code/Magento/SalesRule/Model/Coupon.php +++ b/app/code/Magento/SalesRule/Model/Coupon.php @@ -23,7 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\SalesRule\Model; /** @@ -57,6 +56,11 @@ class Coupon extends \Magento\Core\Model\AbstractModel */ protected $_rule; + /** + * Constructor + * + * @return void + */ protected function _construct() { parent::_construct(); @@ -66,7 +70,7 @@ class Coupon extends \Magento\Core\Model\AbstractModel /** * Processing object before save data * - * @return \Magento\Core\Model\AbstractModel + * @return $this */ protected function _beforeSave() { @@ -79,8 +83,8 @@ class Coupon extends \Magento\Core\Model\AbstractModel /** * Set rule instance * - * @param \Magento\SalesRule\Model\Rule - * @return \Magento\SalesRule\Model\Coupon + * @param \Magento\SalesRule\Model\Rule $rule + * @return $this */ public function setRule(\Magento\SalesRule\Model\Rule $rule) { @@ -92,7 +96,7 @@ class Coupon extends \Magento\Core\Model\AbstractModel * Load primary coupon for specified rule * * @param \Magento\SalesRule\Model\Rule|int $rule - * @return \Magento\SalesRule\Model\Coupon + * @return $this */ public function loadPrimaryByRule($rule) { @@ -104,7 +108,7 @@ class Coupon extends \Magento\Core\Model\AbstractModel * Load Shopping Cart Price Rule by coupon code * * @param string $couponCode - * @return \Magento\SalesRule\Model\Coupon + * @return $this */ public function loadByCode($couponCode) { diff --git a/app/code/Magento/SalesRule/Model/Coupon/Codegenerator.php b/app/code/Magento/SalesRule/Model/Coupon/Codegenerator.php index 655284aed66..86c9ef5d0e1 100644 --- a/app/code/Magento/SalesRule/Model/Coupon/Codegenerator.php +++ b/app/code/Magento/SalesRule/Model/Coupon/Codegenerator.php @@ -23,8 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - namespace Magento\SalesRule\Model\Coupon; class Codegenerator extends \Magento\Object diff --git a/app/code/Magento/SalesRule/Model/Coupon/Massgenerator.php b/app/code/Magento/SalesRule/Model/Coupon/Massgenerator.php index bae822660e9..d981e5b6987 100644 --- a/app/code/Magento/SalesRule/Model/Coupon/Massgenerator.php +++ b/app/code/Magento/SalesRule/Model/Coupon/Massgenerator.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\SalesRule\Model\Coupon; /** * SalesRule Mass Coupon Generator @@ -34,8 +34,6 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\Coupon; - class Massgenerator extends \Magento\Core\Model\AbstractModel implements \Magento\SalesRule\Model\Coupon\CodegeneratorInterface { @@ -59,7 +57,7 @@ class Massgenerator extends \Magento\Core\Model\AbstractModel protected $_salesRuleCoupon = null; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -78,7 +76,7 @@ class Massgenerator extends \Magento\Core\Model\AbstractModel * @param \Magento\Registry $registry * @param \Magento\SalesRule\Helper\Coupon $salesRuleCoupon * @param \Magento\SalesRule\Model\CouponFactory $couponFactory - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -89,7 +87,7 @@ class Massgenerator extends \Magento\Core\Model\AbstractModel \Magento\Registry $registry, \Magento\SalesRule\Helper\Coupon $salesRuleCoupon, \Magento\SalesRule\Model\CouponFactory $couponFactory, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, @@ -104,6 +102,8 @@ class Massgenerator extends \Magento\Core\Model\AbstractModel /** * Initialize resource + * + * @return void */ protected function _construct() { @@ -161,7 +161,7 @@ class Massgenerator extends \Magento\Core\Model\AbstractModel * Generate Coupons Pool * * @throws \Magento\Core\Exception - * @return \Magento\SalesRule\Model\Coupon\Massgenerator + * @return $this */ public function generatePool() { diff --git a/app/code/Magento/SalesRule/Model/Observer.php b/app/code/Magento/SalesRule/Model/Observer.php index 76ee50e3cd0..3996c4c8123 100644 --- a/app/code/Magento/SalesRule/Model/Observer.php +++ b/app/code/Magento/SalesRule/Model/Observer.php @@ -23,9 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\SalesRule\Model; +use Magento\Cron\Model\Schedule; +use Magento\Event\Observer as EventObserver; + class Observer { /** @@ -54,9 +56,9 @@ class Observer protected $_reportRule; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ResolverInterface */ - protected $_locale; + protected $_localeResolver; /** * @var \Magento\SalesRule\Model\Resource\Rule\CollectionFactory @@ -68,15 +70,21 @@ class Observer */ protected $messageManager; + /** + * @var \Magento\Stdlib\DateTime\TimezoneInterface + */ + protected $_localeDate; + /** * @param \Magento\SalesRule\Model\RuleFactory $ruleFactory * @param \Magento\SalesRule\Model\Rule\CustomerFactory $ruleCustomerFactory * @param \Magento\SalesRule\Model\Coupon $coupon * @param \Magento\SalesRule\Model\Resource\Coupon\Usage $couponUsage * @param \Magento\SalesRule\Model\Resource\Report\Rule $reportRule - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\SalesRule\Model\Resource\Rule\CollectionFactory $collectionFactory * @param \Magento\Message\ManagerInterface $messageManager + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate */ public function __construct( \Magento\SalesRule\Model\RuleFactory $ruleFactory, @@ -84,22 +92,23 @@ class Observer \Magento\SalesRule\Model\Coupon $coupon, \Magento\SalesRule\Model\Resource\Coupon\Usage $couponUsage, \Magento\SalesRule\Model\Resource\Report\Rule $reportRule, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\SalesRule\Model\Resource\Rule\CollectionFactory $collectionFactory, - \Magento\Message\ManagerInterface $messageManager + \Magento\Message\ManagerInterface $messageManager, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate ) { $this->_ruleFactory = $ruleFactory; $this->_ruleCustomerFactory = $ruleCustomerFactory; $this->_coupon = $coupon; $this->_couponUsage = $couponUsage; $this->_reportRule = $reportRule; - $this->_locale = $locale; + $this->_localeResolver = $localeResolver; $this->_collectionFactory = $collectionFactory; $this->messageManager = $messageManager; } /** - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer * @return $this */ public function salesOrderAfterPlace($observer) @@ -160,16 +169,16 @@ class Observer /** * Refresh sales coupons report statistics for last day * - * @param \Magento\Cron\Model\Schedule $schedule - * @return \Magento\SalesRule\Model\Observer + * @param Schedule $schedule + * @return $this */ public function aggregateSalesReportCouponsData($schedule) { - $this->_locale->emulate(0); - $currentDate = $this->_locale->date(); + $this->_localeResolver->emulate(0); + $currentDate = $this->_localeDate->date(); $date = $currentDate->subHour(25); $this->_reportRule->aggregate($date); - $this->_locale->revert(); + $this->_localeResolver->revert(); return $this; } @@ -178,7 +187,7 @@ class Observer * If rules were found they will be set to inactive and notice will be add to admin session * * @param string $attributeCode - * @return \Magento\SalesRule\Model\Observer + * @return $this */ protected function _checkSalesRulesAvailability($attributeCode) { @@ -233,10 +242,10 @@ class Observer /** * After save attribute if it is not used for promo rules already check rules for containing this attribute * - * @param \Magento\Event\Observer $observer - * @return \Magento\SalesRule\Model\Observer + * @param EventObserver $observer + * @return $this */ - public function catalogAttributeSaveAfter(\Magento\Event\Observer $observer) + public function catalogAttributeSaveAfter(EventObserver $observer) { $attribute = $observer->getEvent()->getAttribute(); if ($attribute->dataHasChangedFor('is_used_for_promo_rules') && !$attribute->getIsUsedForPromoRules()) { @@ -250,10 +259,10 @@ class Observer * After delete attribute check rules that contains deleted attribute * If rules was found they will seted to inactive and added notice to admin session * - * @param \Magento\Event\Observer $observer - * @return \Magento\SalesRule\Model\Observer + * @param EventObserver $observer + * @return $this */ - public function catalogAttributeDeleteAfter(\Magento\Event\Observer $observer) + public function catalogAttributeDeleteAfter(EventObserver $observer) { $attribute = $observer->getEvent()->getAttribute(); if ($attribute->getIsUsedForPromoRules()) { @@ -266,8 +275,8 @@ class Observer /** * Add coupon's rule name to order data * - * @param \Magento\Event\Observer $observer - * @return \Magento\SalesRule\Model\Observer + * @param EventObserver $observer + * @return $this */ public function addSalesRuleNameToOrder($observer) { diff --git a/app/code/Magento/SalesRule/Model/Plugin/QuoteConfigProductAttributes.php b/app/code/Magento/SalesRule/Model/Plugin/QuoteConfigProductAttributes.php index 1dd8bd5abc0..94376423efa 100644 --- a/app/code/Magento/SalesRule/Model/Plugin/QuoteConfigProductAttributes.php +++ b/app/code/Magento/SalesRule/Model/Plugin/QuoteConfigProductAttributes.php @@ -23,26 +23,36 @@ */ namespace Magento\SalesRule\Model\Plugin; +use Magento\Core\Model\StoreManagerInterface; +use Magento\Customer\Model\Session; +use Magento\SalesRule\Model\Resource\Rule; + class QuoteConfigProductAttributes { - /** @var \Magento\SalesRule\Model\Resource\Rule */ + /** + * @var Rule + */ protected $_ruleResource; - /** @var \Magento\Customer\Model\Session */ + /** + * @var Session + */ protected $_customerSession; - /** @var \Magento\Core\Model\StoreManagerInterface */ + /** + * @var StoreManagerInterface + */ protected $_storeManager; /** - * @param \Magento\SalesRule\Model\Resource\Rule $ruleResource - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param Rule $ruleResource + * @param Session $customerSession + * @param StoreManagerInterface $storeManager */ public function __construct( - \Magento\SalesRule\Model\Resource\Rule $ruleResource, - \Magento\Customer\Model\Session $customerSession, - \Magento\Core\Model\StoreManagerInterface $storeManager + Rule $ruleResource, + Session $customerSession, + StoreManagerInterface $storeManager ) { $this->_ruleResource = $ruleResource; $this->_customerSession = $customerSession; @@ -52,10 +62,13 @@ class QuoteConfigProductAttributes /** * Append sales rule product attribute keys to select by quote item collection * + * @param \Magento\Sales\Model\Quote\Config $subject * @param array $attributeKeys + * * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterGetProductAttributes(array $attributeKeys) + public function afterGetProductAttributes(\Magento\Sales\Model\Quote\Config $subject, array $attributeKeys) { $attributes = $this->_ruleResource->getActiveAttributes( $this->_storeManager->getWebsite()->getId(), diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php index 9e3d5bd6ad4..292beedd76c 100644 --- a/app/code/Magento/SalesRule/Model/Quote/Discount.php +++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php @@ -23,10 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - namespace Magento\SalesRule\Model\Quote; +use Magento\Sales\Model\Quote\Address; +use Magento\Sales\Model\Quote\Item\AbstractItem; + class Discount extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal { /** @@ -67,10 +68,10 @@ class Discount extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal /** * Collect address discount amount * - * @param \Magento\Sales\Model\Quote\Address $address - * @return \Magento\SalesRule\Model\Quote\Discount + * @param Address $address + * @return $this */ - public function collect(\Magento\Sales\Model\Quote\Address $address) + public function collect(Address $address) { parent::collect($address); $quote = $address->getQuote(); @@ -150,8 +151,8 @@ class Discount extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal /** * Aggregate item discount information to address data and related properties * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item - * @return \Magento\SalesRule\Model\Quote\Discount + * @param AbstractItem $item + * @return $this */ protected function _aggregateItemDiscount($item) { @@ -163,8 +164,8 @@ class Discount extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal /** * Recalculate child discount. Separate discount between children * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $child - * @return \Magento\SalesRule\Model\Quote\Discount + * @param AbstractItem $child + * @return $this */ protected function _recalculateChildDiscount($child) { @@ -181,10 +182,10 @@ class Discount extends \Magento\Sales\Model\Quote\Address\Total\AbstractTotal /** * Add discount total information to address * - * @param \Magento\Sales\Model\Quote\Address $address - * @return \Magento\SalesRule\Model\Quote\Discount + * @param Address $address + * @return $this */ - public function fetch(\Magento\Sales\Model\Quote\Address $address) + public function fetch(Address $address) { $amount = $address->getDiscountAmount(); diff --git a/app/code/Magento/SalesRule/Model/Quote/Nominal/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Nominal/Discount.php index e1812d9525b..043b7d82f59 100644 --- a/app/code/Magento/SalesRule/Model/Quote/Nominal/Discount.php +++ b/app/code/Magento/SalesRule/Model/Quote/Nominal/Discount.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Model\Quote\Nominal; /** * Nominal discount total */ -namespace Magento\SalesRule\Model\Quote\Nominal; - class Discount extends \Magento\SalesRule\Model\Quote\Discount { /** diff --git a/app/code/Magento/SalesRule/Model/Resource/Coupon.php b/app/code/Magento/SalesRule/Model/Resource/Coupon.php index 9ca679160a7..c0082afc6c5 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Coupon.php +++ b/app/code/Magento/SalesRule/Model/Resource/Coupon.php @@ -23,8 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Model\Resource; - +use Magento\Core\Model\AbstractModel; /** * SalesRule Resource Coupon * @@ -32,12 +33,12 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\Resource; - class Coupon extends \Magento\Core\Model\Resource\Db\AbstractDb { /** * Constructor adds unique fields + * + * @return void */ protected function _construct() { @@ -51,10 +52,10 @@ class Coupon extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Perform actions before object save * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Core\Model\Resource\Db\AbstractDb + * @param AbstractModel $object + * @return $this */ - public function _beforeSave(\Magento\Core\Model\AbstractModel $object) + public function _beforeSave(AbstractModel $object) { if (!$object->getExpirationDate()) { $object->setExpirationDate(null); @@ -74,7 +75,7 @@ class Coupon extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param \Magento\SalesRule\Model\Coupon $object * @param \Magento\SalesRule\Model\Rule|int $rule - * @return unknown + * @return bool */ public function loadPrimaryByRule(\Magento\SalesRule\Model\Coupon $object, $rule) { @@ -125,7 +126,7 @@ class Coupon extends \Magento\Core\Model\Resource\Db\AbstractDb * Update auto generated Specific Coupon if it's rule changed * * @param \Magento\SalesRule\Model\Rule $rule - * @return \Magento\SalesRule\Model\Resource\Coupon + * @return $this */ public function updateSpecificCoupons(\Magento\SalesRule\Model\Rule $rule) { @@ -142,8 +143,8 @@ class Coupon extends \Magento\Core\Model\Resource\Db\AbstractDb $updateArray['usage_per_customer'] = $rule->getUsesPerCustomer(); } - $ruleNewDate = new \Zend_Date($rule->getToDate()); - $ruleOldDate = new \Zend_Date($rule->getOrigData('to_date')); + $ruleNewDate = new \Magento\Stdlib\DateTime\Date($rule->getToDate()); + $ruleOldDate = new \Magento\Stdlib\DateTime\Date($rule->getOrigData('to_date')); if ($ruleNewDate->compare($ruleOldDate)) { $updateArray['expiration_date'] = $rule->getToDate(); diff --git a/app/code/Magento/SalesRule/Model/Resource/Coupon/Collection.php b/app/code/Magento/SalesRule/Model/Resource/Coupon/Collection.php index 3980b26aa81..866b2b5395b 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Coupon/Collection.php +++ b/app/code/Magento/SalesRule/Model/Resource/Coupon/Collection.php @@ -23,7 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Model\Resource\Coupon; +use Magento\Core\Model\Resource\Db\Collection\AbstractCollection; +use Magento\Backend\Block\Widget\Grid\Column; +use Magento\SalesRule\Model\Rule; /** * SalesRule Model Resource Coupon_Collection @@ -32,13 +36,12 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\Resource\Coupon; - -class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +class Collection extends AbstractCollection { /** * Constructor * + * @return void */ protected function _construct() { @@ -49,13 +52,12 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add rule to filter * - * @param \Magento\SalesRule\Model\Rule|int $rule - * - * @return \Magento\SalesRule\Model\Resource\Coupon\Collection + * @param Rule|int $rule + * @return $this */ public function addRuleToFilter($rule) { - if ($rule instanceof \Magento\SalesRule\Model\Rule) { + if ($rule instanceof Rule) { $ruleId = $rule->getId(); } else { $ruleId = (int)$rule; @@ -70,8 +72,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Add rule IDs to filter * * @param array $ruleIds - * - * @return \Magento\SalesRule\Model\Resource\Coupon\Collection + * @return $this */ public function addRuleIdsToFilter(array $ruleIds) { @@ -82,7 +83,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Filter collection to be filled with auto-generated coupons only * - * @return \Magento\SalesRule\Model\Resource\Coupon\Collection + * @return $this */ public function addGeneratedCouponsFilter() { @@ -93,8 +94,9 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Callback function that filters collection by field "Used" from grid * - * @param \Magento\Core\Model\Resource\Db\Collection\AbstractCollection $collection - * @param \Magento\Backend\Block\Widget\Grid\Column $column + * @param AbstractCollection $collection + * @param Column $column + * @return void */ public function addIsUsedFilterCallback($collection, $column) { diff --git a/app/code/Magento/SalesRule/Model/Resource/Coupon/Usage.php b/app/code/Magento/SalesRule/Model/Resource/Coupon/Usage.php index 9d66aba97af..67fd5df522e 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Coupon/Usage.php +++ b/app/code/Magento/SalesRule/Model/Resource/Coupon/Usage.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\SalesRule\Model\Resource\Coupon; /** * SalesRule Model Resource Coupon_Usage @@ -32,13 +32,12 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\Resource\Coupon; - class Usage extends \Magento\Core\Model\Resource\Db\AbstractDb { /** * Constructor * + * @return void */ protected function _construct() { @@ -48,9 +47,9 @@ class Usage extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Increment times_used counter * - * - * @param unknown_type $customerId - * @param unknown_type $couponId + * @param int $customerId + * @param mixed $couponId + * @return void */ public function updateCustomerCouponTimesUsed($customerId, $couponId) { @@ -88,11 +87,10 @@ class Usage extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Load an object by customer_id & coupon_id * - * * @param \Magento\Object $object - * @param unknown_type $customerId - * @param unknown_type $couponId - * @return \Magento\SalesRule\Model\Resource\Coupon\Usage + * @param int $customerId + * @param mixed $couponId + * @return $this */ public function loadByCustomerCoupon(\Magento\Object $object, $customerId, $couponId) { diff --git a/app/code/Magento/SalesRule/Model/Resource/Report/Collection.php b/app/code/Magento/SalesRule/Model/Resource/Report/Collection.php index fb93fd1d3f8..fb936f4bce9 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Report/Collection.php +++ b/app/code/Magento/SalesRule/Model/Resource/Report/Collection.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\SalesRule\Model\Resource\Report; /** * Sales report coupons collection @@ -32,8 +32,6 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\Resource\Report; - class Collection extends \Magento\Sales\Model\Resource\Report\Collection\AbstractCollection { /** @@ -51,14 +49,14 @@ class Collection extends \Magento\Sales\Model\Resource\Report\Collection\Abstrac protected $_aggregationTable = 'coupon_aggregated'; /** - * array of columns that should be aggregated + * Array of columns that should be aggregated * * @var array */ protected $_selectedColumns = array(); /** - * array where rules ids stored + * Array where rules ids stored * * @var array */ @@ -88,7 +86,7 @@ class Collection extends \Magento\Sales\Model\Resource\Report\Collection\Abstrac } /** - * collect columns for collection + * Collect columns for collection * * @return array */ @@ -135,7 +133,7 @@ class Collection extends \Magento\Sales\Model\Resource\Report\Collection\Abstrac /** * Add selected data * - * @return \Magento\SalesRule\Model\Resource\Report\Collection + * @return $this */ protected function _initSelect() { @@ -156,7 +154,7 @@ class Collection extends \Magento\Sales\Model\Resource\Report\Collection\Abstrac * Add filtering by rules ids * * @param array $rulesList - * @return \Magento\SalesRule\Model\Resource\Report\Collection + * @return $this */ public function addRuleFilter($rulesList) { @@ -167,7 +165,7 @@ class Collection extends \Magento\Sales\Model\Resource\Report\Collection\Abstrac /** * Apply filtering by rules ids * - * @return \Magento\SalesRule\Model\Resource\Report\Collection + * @return $this */ protected function _applyRulesFilter() { diff --git a/app/code/Magento/SalesRule/Model/Resource/Report/Rule.php b/app/code/Magento/SalesRule/Model/Resource/Report/Rule.php index da90300040b..a753dfc0b77 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Report/Rule.php +++ b/app/code/Magento/SalesRule/Model/Resource/Report/Rule.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\SalesRule\Model\Resource\Report; /** * Rule report resource model @@ -32,8 +32,6 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\Resource\Report; - class Rule extends \Magento\Reports\Model\Resource\Report\AbstractReport { /** @@ -49,7 +47,7 @@ class Rule extends \Magento\Reports\Model\Resource\Report\AbstractReport /** * @param \Magento\App\Resource $resource * @param \Magento\Logger $logger - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator @@ -59,14 +57,14 @@ class Rule extends \Magento\Reports\Model\Resource\Report\AbstractReport public function __construct( \Magento\App\Resource $resource, \Magento\Logger $logger, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Reports\Model\FlagFactory $reportsFlagFactory, \Magento\Stdlib\DateTime $dateTime, \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator, \Magento\SalesRule\Model\Resource\Report\Rule\CreatedatFactory $createdatFactory, \Magento\SalesRule\Model\Resource\Report\Rule\UpdatedatFactory $updatedatFactory ) { - parent::__construct($resource, $logger, $locale, $reportsFlagFactory, $dateTime, $timezoneValidator); + parent::__construct($resource, $logger, $localeDate, $reportsFlagFactory, $dateTime, $timezoneValidator); $this->_createdatFactory = $createdatFactory; $this->_updatedatFactory = $updatedatFactory; } @@ -74,6 +72,7 @@ class Rule extends \Magento\Reports\Model\Resource\Report\AbstractReport /** * Resource Report Rule constructor * + * @return void */ protected function _construct() { @@ -83,9 +82,9 @@ class Rule extends \Magento\Reports\Model\Resource\Report\AbstractReport /** * Aggregate Coupons data * - * @param mixed $from - * @param mixed $to - * @return \Magento\SalesRule\Model\Resource\Report\Rule + * @param mixed|null $from + * @param mixed|null $to + * @return $this */ public function aggregate($from = null, $to = null) { diff --git a/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Createdat.php b/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Createdat.php index ea29657d4f0..73154658bfd 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Createdat.php +++ b/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Createdat.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\SalesRule\Model\Resource\Report\Rule; /** * Rule report resource model with aggregation by created at @@ -32,13 +32,12 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\Resource\Report\Rule; - class Createdat extends \Magento\Reports\Model\Resource\Report\AbstractReport { /** * Resource Report Rule constructor * + * @return void */ protected function _construct() { @@ -48,9 +47,9 @@ class Createdat extends \Magento\Reports\Model\Resource\Report\AbstractReport /** * Aggregate Coupons data by order created at * - * @param mixed $from - * @param mixed $to - * @return \Magento\SalesRule\Model\Resource\Report\Rule\Createdat + * @param mixed|null $from + * @param mixed|null $to + * @return $this */ public function aggregate($from = null, $to = null) { @@ -64,7 +63,7 @@ class Createdat extends \Magento\Reports\Model\Resource\Report\AbstractReport * @param string $aggregationField * @param mixed $from * @param mixed $to - * @return \Magento\SalesRule\Model\Resource\Report\Rule\Createdat + * @return $this */ protected function _aggregateByOrder($aggregationField, $from, $to) { diff --git a/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Updatedat.php b/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Updatedat.php index 746b7ad395e..28f33eee5fd 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Updatedat.php +++ b/app/code/Magento/SalesRule/Model/Resource/Report/Rule/Updatedat.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\SalesRule\Model\Resource\Report\Rule; /** * Rule report resource model with aggregation by updated at @@ -32,13 +32,12 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\Resource\Report\Rule; - class Updatedat extends \Magento\SalesRule\Model\Resource\Report\Rule\Createdat { /** * Resource Report Rule constructor * + * @return void */ protected function _construct() { @@ -48,9 +47,9 @@ class Updatedat extends \Magento\SalesRule\Model\Resource\Report\Rule\Createdat /** * Aggregate Coupons data by order updated at * - * @param mixed $from - * @param mixed $to - * @return \Magento\SalesRule\Model\Resource\Report\Rule\Updatedat + * @param mixed|null $from + * @param mixed|null $to + * @return $this */ public function aggregate($from = null, $to = null) { diff --git a/app/code/Magento/SalesRule/Model/Resource/Report/Updatedat/Collection.php b/app/code/Magento/SalesRule/Model/Resource/Report/Updatedat/Collection.php index 7c72ec5edf6..af467616fe6 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Report/Updatedat/Collection.php +++ b/app/code/Magento/SalesRule/Model/Resource/Report/Updatedat/Collection.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\SalesRule\Model\Resource\Report\Updatedat; /** * Sales report coupons collection @@ -32,8 +32,6 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\Resource\Report\Updatedat; - class Collection extends \Magento\SalesRule\Model\Resource\Report\Collection { diff --git a/app/code/Magento/SalesRule/Model/Resource/Rule.php b/app/code/Magento/SalesRule/Model/Resource/Rule.php index 15b148131ee..5239bdac91a 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Rule.php +++ b/app/code/Magento/SalesRule/Model/Resource/Rule.php @@ -23,9 +23,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\SalesRule\Model\Resource; +use Magento\Core\Model\AbstractModel; + /** * Sales Rule resource model */ @@ -64,7 +65,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource /** * @param \Magento\App\Resource $resource * @param \Magento\Stdlib\String $string - * @param Coupon $resourceCoupon + * @param \Magento\SalesRule\Model\Resource\Coupon $resourceCoupon */ public function __construct( \Magento\App\Resource $resource, @@ -78,6 +79,8 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource /** * Initialize main table and table id field + * + * @return void */ protected function _construct() { @@ -87,11 +90,10 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource /** * Add customer group ids and website ids to rule data after load * - * @param \Magento\Core\Model\AbstractModel $object - * - * @return \Magento\SalesRule\Model\Resource\Rule + * @param AbstractModel $object + * @return $this */ - protected function _afterLoad(\Magento\Core\Model\AbstractModel $object) + protected function _afterLoad(AbstractModel $object) { $object->setData('customer_group_ids', (array)$this->getCustomerGroupIds($object->getId())); $object->setData('website_ids', (array)$this->getWebsiteIds($object->getId())); @@ -103,11 +105,10 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource /** * Prepare sales rule's discount quantity * - * @param \Magento\Core\Model\AbstractModel $object - * - * @return \Magento\SalesRule\Model\Resource\Rule + * @param AbstractModel $object + * @return $this */ - public function _beforeSave(\Magento\Core\Model\AbstractModel $object) + public function _beforeSave(AbstractModel $object) { if (!$object->getDiscountQty()) { $object->setDiscountQty(new \Zend_Db_Expr('NULL')); @@ -122,11 +123,10 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * Save rule's associated store labels. * Save product attributes used in rule. * - * @param \Magento\Core\Model\AbstractModel $object - * - * @return \Magento\SalesRule\Model\Resource\Rule + * @param AbstractModel $object + * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(AbstractModel $object) { if ($object->hasStoreLabels()) { $this->saveStoreLabels($object->getId(), $object->getStoreLabels()); @@ -169,7 +169,6 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * * @param \Magento\SalesRule\Model\Rule $rule * @param int $customerId - * * @return string */ public function getCustomerUses($rule, $customerId) @@ -187,7 +186,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * @param int $ruleId * @param array $labels * @throws \Exception - * @return \Magento\SalesRule\Model\Resource\Rule + * @return $this */ public function saveStoreLabels($ruleId, $labels) { @@ -263,8 +262,8 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource /** * Return codes of all product attributes currently used in promo rules for specified customer group and website * - * @param unknown_type $websiteId - * @param unknown_type $customerGroupId + * @param mixed $websiteId + * @param int $customerGroupId * @return mixed */ public function getActiveAttributes($websiteId, $customerGroupId) @@ -282,7 +281,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * * @param \Magento\SalesRule\Model\Rule $rule * @param mixed $attributes - * @return \Magento\SalesRule\Model\Resource\Rule + * @return $this */ public function setActualProductAttributes($rule, $attributes) { @@ -323,7 +322,6 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * Collect all product attributes used in serialized rule's action or condition * * @param string $serializedString - * * @return array */ public function getProductAttributes($serializedString) diff --git a/app/code/Magento/SalesRule/Model/Resource/Rule/Collection.php b/app/code/Magento/SalesRule/Model/Resource/Rule/Collection.php index 842b37aae9d..36858825620 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Rule/Collection.php +++ b/app/code/Magento/SalesRule/Model/Resource/Rule/Collection.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\SalesRule\Model\Resource\Rule; /** * Sales Rules resource collection model @@ -32,8 +32,6 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\Resource\Rule; - class Collection extends \Magento\Rule\Model\Resource\Rule\Collection\AbstractCollection { /** @@ -55,7 +53,7 @@ class Collection extends \Magento\Rule\Model\Resource\Rule\Collection\AbstractCo ); /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -64,7 +62,7 @@ class Collection extends \Magento\Rule\Model\Resource\Rule\Collection\AbstractCo * @param \Magento\Logger $logger * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param mixed $connection * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource */ @@ -73,7 +71,7 @@ class Collection extends \Magento\Rule\Model\Resource\Rule\Collection\AbstractCo \Magento\Logger $logger, \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Event\ManagerInterface $eventManager, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, $connection = null, \Magento\Core\Model\Resource\Db\AbstractDb $resource = null ) { @@ -83,6 +81,8 @@ class Collection extends \Magento\Rule\Model\Resource\Rule\Collection\AbstractCo /** * Set resource model and determine field mapping + * + * @return void */ protected function _construct() { @@ -100,8 +100,7 @@ class Collection extends \Magento\Rule\Model\Resource\Rule\Collection\AbstractCo * @param string $couponCode * @param string|null $now * @use $this->addWebsiteGroupDateFilter() - * - * @return \Magento\SalesRule\Model\Resource\Rule\Collection + * @return $this */ public function setValidationFilter($websiteId, $customerGroupId, $couponCode = '', $now = null) { @@ -160,8 +159,7 @@ class Collection extends \Magento\Rule\Model\Resource\Rule\Collection\AbstractCo * @param int $customerGroupId * @param string|null $now * @use $this->addWebsiteFilter() - * - * @return \Magento\SalesRule\Model\Resource\Rule\Collection + * @return $this */ public function addWebsiteGroupDateFilter($websiteId, $customerGroupId, $now = null) { @@ -199,7 +197,7 @@ class Collection extends \Magento\Rule\Model\Resource\Rule\Collection\AbstractCo /** * Add primary coupon to collection * - * @return \Magento\SalesRule\Model\Resource\Rule\Collection + * @return $this */ public function _initSelect() { @@ -217,8 +215,7 @@ class Collection extends \Magento\Rule\Model\Resource\Rule\Collection\AbstractCo * Find product attribute in conditions or actions * * @param string $attributeCode - * - * @return \Magento\SalesRule\Model\Resource\Rule\Collection + * @return $this */ public function addAttributeInConditionFilter($attributeCode) { @@ -236,7 +233,7 @@ class Collection extends \Magento\Rule\Model\Resource\Rule\Collection\AbstractCo /** * Excludes price rules with generated specific coupon codes from collection * - * @return \Magento\SalesRule\Model\Resource\Rule\Collection + * @return $this */ public function addAllowedSalesRulesFilter() { diff --git a/app/code/Magento/SalesRule/Model/Resource/Rule/Customer.php b/app/code/Magento/SalesRule/Model/Resource/Rule/Customer.php index fbfe50b38e3..5e45950775c 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Rule/Customer.php +++ b/app/code/Magento/SalesRule/Model/Resource/Rule/Customer.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\SalesRule\Model\Resource\Rule; /** * SalesRule Rule Customer Model Resource @@ -32,13 +32,12 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\Resource\Rule; - class Customer extends \Magento\Core\Model\Resource\Db\AbstractDb { /** - * constructor + * Constructor * + * @return void */ protected function _construct() { @@ -51,7 +50,7 @@ class Customer extends \Magento\Core\Model\Resource\Db\AbstractDb * @param \Magento\SalesRule\Model\Rule\Customer $rule * @param int $customerId * @param int $ruleId - * @return \Magento\SalesRule\Model\Resource\Rule\Customer + * @return $this */ public function loadByCustomerRule($rule, $customerId, $ruleId) { diff --git a/app/code/Magento/SalesRule/Model/Resource/Rule/Customer/Collection.php b/app/code/Magento/SalesRule/Model/Resource/Rule/Customer/Collection.php index cdffc901c08..b56263f4905 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Rule/Customer/Collection.php +++ b/app/code/Magento/SalesRule/Model/Resource/Rule/Customer/Collection.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\SalesRule\Model\Resource\Rule\Customer; /** * SalesRule Model Resource Rule Customer_Collection @@ -32,13 +32,12 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\Resource\Rule\Customer; - class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection { /** * Collection constructor * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/SalesRule/Model/Resource/Rule/Quote/Collection.php b/app/code/Magento/SalesRule/Model/Resource/Rule/Quote/Collection.php index 7defd26b6ca..9115c1a9856 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Rule/Quote/Collection.php +++ b/app/code/Magento/SalesRule/Model/Resource/Rule/Quote/Collection.php @@ -30,7 +30,7 @@ class Collection extends \Magento\SalesRule\Model\Resource\Rule\Collection /** * Add websites for load * - * @return \Magento\SalesRule\Model\Resource\Rule\Quote\Collection + * @return $this */ public function _initSelect() @@ -39,5 +39,4 @@ class Collection extends \Magento\SalesRule\Model\Resource\Rule\Collection $this->addWebsitesToResult(); return $this; } - } diff --git a/app/code/Magento/SalesRule/Model/Resource/Setup.php b/app/code/Magento/SalesRule/Model/Resource/Setup.php index dd2511d15a3..9bbdb3e962f 100644 --- a/app/code/Magento/SalesRule/Model/Resource/Setup.php +++ b/app/code/Magento/SalesRule/Model/Resource/Setup.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Model\Resource; /** * Resource setup model */ -namespace Magento\SalesRule\Model\Resource; - class Setup extends \Magento\Sales\Model\Resource\Setup { /** diff --git a/app/code/Magento/SalesRule/Model/Rule.php b/app/code/Magento/SalesRule/Model/Rule.php index 7e399929555..ed31a372d7f 100644 --- a/app/code/Magento/SalesRule/Model/Rule.php +++ b/app/code/Magento/SalesRule/Model/Rule.php @@ -23,9 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\SalesRule\Model; +use Magento\Sales\Model\Quote\Address; /** * Shopping Cart Rule data model * @@ -66,8 +66,6 @@ namespace Magento\SalesRule\Model; * @method \Magento\SalesRule\Model\Rule setDiscountQty(float $value) * @method int getDiscountStep() * @method \Magento\SalesRule\Model\Rule setDiscountStep(int $value) - * @method int getSimpleFreeShipping() - * @method \Magento\SalesRule\Model\Rule setSimpleFreeShipping(int $value) * @method int getApplyToShipping() * @method \Magento\SalesRule\Model\Rule setApplyToShipping(int $value) * @method int getTimesUsed() @@ -87,16 +85,6 @@ namespace Magento\SalesRule\Model; */ class Rule extends \Magento\Rule\Model\AbstractModel { - /** - * Free Shipping option "For matching items only" - */ - const FREE_SHIPPING_ITEM = 1; - - /** - * Free Shipping option "For shipment with matching items" - */ - const FREE_SHIPPING_ADDRESS = 2; - /** * Coupon types */ @@ -140,9 +128,8 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Contain sores labels * - * @deprecated after 1.6.2.0 - * * @var array + * @deprecated after 1.6.2.0 */ protected $_labels = array(); @@ -156,7 +143,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Rule's subordinate coupons * - * @var array of \Magento\SalesRule\Model\Coupon + * @var \Magento\SalesRule\Model\Coupon[] */ protected $_coupons; @@ -208,7 +195,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\SalesRule\Model\CouponFactory $couponFactory * @param \Magento\SalesRule\Model\Coupon\CodegeneratorFactory $codegenFactory * @param \Magento\SalesRule\Model\Rule\Condition\CombineFactory $condCombineFactory @@ -223,7 +210,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\SalesRule\Model\CouponFactory $couponFactory, \Magento\SalesRule\Model\Coupon\CodegeneratorFactory $codegenFactory, \Magento\SalesRule\Model\Rule\Condition\CombineFactory $condCombineFactory, @@ -240,11 +227,13 @@ class Rule extends \Magento\Rule\Model\AbstractModel $this->_condProdCombineF = $condProdCombineF; $this->_couponCollection = $couponCollection; $this->_storeManager = $storeManager; - parent::__construct($context, $registry, $formFactory, $locale, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $formFactory, $localeDate, $resource, $resourceCollection, $data); } /** * Set resource model and Id field name + * + * @return void */ protected function _construct() { @@ -256,7 +245,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Set coupon code and uses per coupon * - * @return \Magento\SalesRule\Model\Rule + * @return $this */ protected function _afterLoad() { @@ -270,7 +259,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Save/delete coupon * - * @return \Magento\SalesRule\Model\Rule + * @return $this */ protected function _afterSave() { @@ -298,8 +287,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel * Set store labels if applicable. * * @param array $data - * - * @return \Magento\SalesRule\Model\Rule + * @return $this */ public function loadPost(array $data) { @@ -348,7 +336,8 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Set code generator instance for auto generated coupons * - * @param \Magento\SalesRule\Model\Coupon\CodegeneratorInterface + * @param \Magento\SalesRule\Model\Coupon\CodegeneratorInterface $codeGenerator + * @return void */ public function setCouponCodeGenerator(\Magento\SalesRule\Model\Coupon\CodegeneratorInterface $codeGenerator) { @@ -388,7 +377,6 @@ class Rule extends \Magento\Rule\Model\AbstractModel * Get Rule label by specified store * * @param \Magento\Core\Model\Store|int|bool|null $store - * * @return string|bool */ public function getStoreLabel($store = null) @@ -423,7 +411,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Retrieve subordinate coupons * - * @return array of \Magento\SalesRule\Model\Coupon + * @return \Magento\SalesRule\Model\Coupon[] */ public function getCoupons() { @@ -518,8 +506,8 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Check cached validation result for specific address * - * @param \Magento\Sales\Model\Quote\Address $address - * @return bool + * @param Address $address + * @return bool */ public function hasIsValidForAddress($address) { @@ -530,9 +518,9 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Set validation result for specific address to results cache * - * @param \Magento\Sales\Model\Quote\Address $address - * @param bool $validationResult - * @return \Magento\SalesRule\Model\Rule + * @param Address $address + * @param bool $validationResult + * @return $this */ public function setIsValidForAddress($address, $validationResult) { @@ -544,8 +532,8 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Get cached validation result for specific address * - * @param \Magento\Sales\Model\Quote\Address $address - * @return bool + * @param Address $address + * @return bool */ public function getIsValidForAddress($address) { @@ -556,28 +544,22 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Return id for address * - * @param \Magento\Sales\Model\Quote\Address $address - * @return string + * @param Address $address + * @return string */ private function _getAddressId($address) { - if($address instanceof \Magento\Sales\Model\Quote\Address) { + if($address instanceof Address) { return $address->getId(); } return $address; } - - - - /** * Collect all product attributes used in serialized rule's action or condition * - * @deprecated after 1.6.2.0 use \Magento\SalesRule\Model\Resource\Rule::getProductAttributes() instead - * * @param string $serializedString - * * @return array + * @deprecated after 1.6.2.0 use \Magento\SalesRule\Model\Resource\Rule::getProductAttributes() instead */ protected function _getUsedAttributes($serializedString) { @@ -585,11 +567,9 @@ class Rule extends \Magento\Rule\Model\AbstractModel } /** - * @deprecated after 1.6.2.0 - * * @param string $format - * * @return string + * @deprecated after 1.6.2.0 */ public function toString($format='') { @@ -599,8 +579,6 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Returns rule as an array for admin interface * - * @deprecated after 1.6.2.0 - * * @param array $arrAttributes * * Output example: @@ -611,6 +589,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel * ) * * @return array + * @deprecated after 1.6.2.0 */ public function toArray(array $arrAttributes = array()) { diff --git a/app/code/Magento/SalesRule/Model/Rule/Action/Collection.php b/app/code/Magento/SalesRule/Model/Rule/Action/Collection.php index 16977d0731b..6e5cadbcfa1 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Action/Collection.php +++ b/app/code/Magento/SalesRule/Model/Rule/Action/Collection.php @@ -23,8 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - namespace Magento\SalesRule\Model\Rule\Action; class Collection extends \Magento\Rule\Model\Action\Collection diff --git a/app/code/Magento/SalesRule/Model/Rule/Action/Product.php b/app/code/Magento/SalesRule/Model/Rule/Action/Product.php index f3579e1e0ac..08e59f080d3 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Action/Product.php +++ b/app/code/Magento/SalesRule/Model/Rule/Action/Product.php @@ -23,12 +23,15 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - namespace Magento\SalesRule\Model\Rule\Action; class Product extends \Magento\Rule\Model\Action\AbstractAction { + /** + * Load attribute options + * + * @return $this + */ public function loadAttributeOptions() { $this->setAttributeOption(array( @@ -37,6 +40,11 @@ class Product extends \Magento\Rule\Model\Action\AbstractAction return $this; } + /** + * Load operator options + * + * @return $this + */ public function loadOperatorOptions() { $this->setOperatorOption(array( @@ -48,6 +56,11 @@ class Product extends \Magento\Rule\Model\Action\AbstractAction return $this; } + /** + * Return html + * + * @return string + */ public function asHtml() { $html = $this->getTypeElement()->getHtml().__("Update product's %1 %2: %3", $this->getAttributeElement()->getHtml(), $this->getOperatorElement()->getHtml(), $this->getValueElement()->getHtml()); diff --git a/app/code/Magento/SalesRule/Model/Rule/Condition/Address.php b/app/code/Magento/SalesRule/Model/Rule/Condition/Address.php index 12c9952fdab..d72eaf0f959 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Condition/Address.php +++ b/app/code/Magento/SalesRule/Model/Rule/Condition/Address.php @@ -23,8 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - namespace Magento\SalesRule\Model\Rule\Condition; class Address extends \Magento\Rule\Model\Condition\AbstractCondition @@ -73,6 +71,8 @@ class Address extends \Magento\Rule\Model\Condition\AbstractCondition } /** + * Load attribute options + * * @return $this */ public function loadAttributeOptions() @@ -94,6 +94,11 @@ class Address extends \Magento\Rule\Model\Condition\AbstractCondition return $this; } + /** + * Get attribute element + * + * @return $this + */ public function getAttributeElement() { $element = parent::getAttributeElement(); @@ -102,6 +107,8 @@ class Address extends \Magento\Rule\Model\Condition\AbstractCondition } /** + * Get input type + * * @return string */ public function getInputType() @@ -117,6 +124,8 @@ class Address extends \Magento\Rule\Model\Condition\AbstractCondition } /** + * Get value element type + * * @return string */ public function getValueElementType() @@ -129,6 +138,8 @@ class Address extends \Magento\Rule\Model\Condition\AbstractCondition } /** + * Get value select options + * * @return array|mixed */ public function getValueSelectOptions() diff --git a/app/code/Magento/SalesRule/Model/Rule/Condition/Combine.php b/app/code/Magento/SalesRule/Model/Rule/Condition/Combine.php index d8932592e3c..9ea439102f7 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Condition/Combine.php +++ b/app/code/Magento/SalesRule/Model/Rule/Condition/Combine.php @@ -23,8 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - namespace Magento\SalesRule\Model\Rule\Condition; class Combine extends \Magento\Rule\Model\Condition\Combine @@ -60,6 +58,8 @@ class Combine extends \Magento\Rule\Model\Condition\Combine } /** + * Get new child select options + * * @return array */ public function getNewChildSelectOptions() diff --git a/app/code/Magento/SalesRule/Model/Rule/Condition/Product.php b/app/code/Magento/SalesRule/Model/Rule/Condition/Product.php index 833b95913ce..e929f07b37e 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Condition/Product.php +++ b/app/code/Magento/SalesRule/Model/Rule/Condition/Product.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\SalesRule\Model\Rule\Condition; /** * Product rule condition data model @@ -32,8 +32,6 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\Rule\Condition; - class Product extends \Magento\Rule\Model\Condition\Product\AbstractProduct { /** @@ -48,6 +46,7 @@ class Product extends \Magento\Rule\Model\Condition\Product\AbstractProduct * @param \Magento\Catalog\Model\Product $product * @param \Magento\Catalog\Model\Resource\Product $productResource * @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\Collection $attrSetCollection + * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param array $data */ @@ -58,10 +57,13 @@ class Product extends \Magento\Rule\Model\Condition\Product\AbstractProduct \Magento\Catalog\Model\Product $product, \Magento\Catalog\Model\Resource\Product $productResource, \Magento\Eav\Model\Resource\Entity\Attribute\Set\Collection $attrSetCollection, + \Magento\Locale\FormatInterface $localeFormat, \Magento\Catalog\Model\ProductFactory $productFactory, array $data = array() ) { - parent::__construct($context, $backendData, $config, $product, $productResource, $attrSetCollection, $data); + parent::__construct( + $context, $backendData, $config, $product, $productResource, $attrSetCollection, $localeFormat, $data + ); $this->_productFactory = $productFactory; } @@ -69,6 +71,7 @@ class Product extends \Magento\Rule\Model\Condition\Product\AbstractProduct * Add special attributes * * @param array $attributes + * @return void */ protected function _addSpecialAttributes(array &$attributes) { @@ -82,7 +85,6 @@ class Product extends \Magento\Rule\Model\Condition\Product\AbstractProduct * Validate Product Rule Condition * * @param \Magento\Object $object - * * @return bool */ public function validate(\Magento\Object $object) diff --git a/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Combine.php b/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Combine.php index fa2f648259c..09c073a5602 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Combine.php +++ b/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Combine.php @@ -23,10 +23,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - namespace Magento\SalesRule\Model\Rule\Condition\Product; +use Magento\Catalog\Model\Resource\Product\Collection; + class Combine extends \Magento\Rule\Model\Condition\Combine { /** @@ -50,6 +50,8 @@ class Combine extends \Magento\Rule\Model\Condition\Combine } /** + * Get new child select options + * * @return array */ public function getNewChildSelectOptions() @@ -84,7 +86,9 @@ class Combine extends \Magento\Rule\Model\Condition\Combine } /** - * @param $productCollection + * Collect validated attributes + * + * @param Collection $productCollection * @return $this */ public function collectValidatedAttributes($productCollection) diff --git a/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Found.php b/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Found.php index c5b0359be9d..4b109fa21b1 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Found.php +++ b/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Found.php @@ -23,8 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - namespace Magento\SalesRule\Model\Rule\Condition\Product; class Found @@ -47,7 +45,7 @@ class Found /** * Load value options * - * @return \Magento\SalesRule\Model\Rule\Condition\Product\Found + * @return $this */ public function loadValueOptions() { @@ -59,6 +57,8 @@ class Found } /** + * Return as html + * * @return string */ public function asHtml() @@ -75,10 +75,10 @@ class Found } /** - * validate + * Validate * * @param \Magento\Object $object Quote - * @return boolean + * @return bool */ public function validate(\Magento\Object $object) { diff --git a/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php b/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php index 827597b88e0..120cc7b3a0c 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php +++ b/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php @@ -23,8 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - namespace Magento\SalesRule\Model\Rule\Condition\Product; class Subselect @@ -46,6 +44,8 @@ class Subselect } /** + * Load array + * * @param array $arr * @param string $key * @return $this @@ -59,6 +59,8 @@ class Subselect } /** + * Return as xml + * * @param string $containerKey * @param string $itemKey * @return string @@ -72,6 +74,8 @@ class Subselect } /** + * Load attribute options + * * @return $this */ public function loadAttributeOptions() @@ -84,6 +88,8 @@ class Subselect } /** + * Load value options + * * @return $this */ public function loadValueOptions() @@ -92,6 +98,8 @@ class Subselect } /** + * Load operator options + * * @return $this */ public function loadOperatorOptions() @@ -110,6 +118,8 @@ class Subselect } /** + * Get value element type + * * @return string */ public function getValueElementType() @@ -118,6 +128,8 @@ class Subselect } /** + * Return as html + * * @return string */ public function asHtml() @@ -136,10 +148,10 @@ class Subselect } /** - * validate + * Validate * * @param \Magento\Object $object Quote - * @return boolean + * @return bool */ public function validate(\Magento\Object $object) { diff --git a/app/code/Magento/SalesRule/Model/Rule/Customer.php b/app/code/Magento/SalesRule/Model/Rule/Customer.php index 5897ed76955..c518d47ec5e 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Customer.php +++ b/app/code/Magento/SalesRule/Model/Rule/Customer.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\SalesRule\Model\Rule; /** * SalesRule Rule Customer Model @@ -41,16 +41,26 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\Rule; - class Customer extends \Magento\Core\Model\AbstractModel { + /** + * Constructor + * + * @return void + */ protected function _construct() { parent::_construct(); $this->_init('Magento\SalesRule\Model\Resource\Rule\Customer'); } - + + /** + * Load by customer rule + * + * @param int $customerId + * @param int $ruleId + * @return $this + */ public function loadByCustomerRule($customerId, $ruleId) { $this->_getResource()->loadByCustomerRule($this, $customerId, $ruleId); diff --git a/app/code/Magento/SalesRule/Model/System/Config/Source/Coupon/Format.php b/app/code/Magento/SalesRule/Model/System/Config/Source/Coupon/Format.php index 00255b04768..3a00f956b5f 100644 --- a/app/code/Magento/SalesRule/Model/System/Config/Source/Coupon/Format.php +++ b/app/code/Magento/SalesRule/Model/System/Config/Source/Coupon/Format.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\SalesRule\Model\System\Config\Source\Coupon; /** * Options for Code Format Field in Auto Generated Specific Coupon Codes configuration section @@ -31,8 +32,6 @@ * @package Magento_SalesRule * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\SalesRule\Model\System\Config\Source\Coupon; - class Format implements \Magento\Option\ArrayInterface { /** @@ -52,9 +51,7 @@ class Format implements \Magento\Option\ArrayInterface } /** - * Options getter - * - * @return array + * {@inheritdoc} */ public function toOptionArray() { diff --git a/app/code/Magento/SalesRule/Model/Validator.php b/app/code/Magento/SalesRule/Model/Validator.php index 9a36d3423fc..f8ee095e64c 100644 --- a/app/code/Magento/SalesRule/Model/Validator.php +++ b/app/code/Magento/SalesRule/Model/Validator.php @@ -23,9 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\SalesRule\Model; +use Magento\Sales\Model\Quote\Item\AbstractItem; +use Magento\Sales\Model\Quote\Address; + /** * SalesRule Validator Model * @@ -47,8 +49,14 @@ class Validator extends \Magento\Core\Model\AbstractModel */ protected $_rules; + /** + * @var array + */ protected $_roundingDeltas = array(); + /** + * @var array + */ protected $_baseRoundingDeltas = array(); /** @@ -60,7 +68,8 @@ class Validator extends \Magento\Core\Model\AbstractModel protected $_isFirstTimeResetRun = true; /** - * Information about item totals for rules. + * Information about item totals for rules + * * @var array */ protected $_rulesItemTotals = array(); @@ -75,7 +84,7 @@ class Validator extends \Magento\Core\Model\AbstractModel /** * Tax data * - * @var \Magento\Tax\Helper\Data + * @var \Magento\Tax\Helper\Data|null */ protected $_taxData = null; @@ -150,10 +159,10 @@ class Validator extends \Magento\Core\Model\AbstractModel * Init process load collection of rules for specific website, * customer group and coupon code * - * @param int $websiteId - * @param int $customerGroupId - * @param string $couponCode - * @return \Magento\SalesRule\Model\Validator + * @param int $websiteId + * @param int $customerGroupId + * @param string $couponCode + * @return $this */ public function init($websiteId, $customerGroupId, $couponCode) { @@ -184,9 +193,9 @@ class Validator extends \Magento\Core\Model\AbstractModel /** * Check if rule can be applied for specific address/quote/customer * - * @param \Magento\SalesRule\Model\Rule $rule - * @param \Magento\Sales\Model\Quote\Address $address - * @return bool + * @param \Magento\SalesRule\Model\Rule $rule + * @param Address $address + * @return bool */ protected function _canProcessRule($rule, $address) { @@ -260,8 +269,8 @@ class Validator extends \Magento\Core\Model\AbstractModel /** * Set skip actions validation flag * - * @param boolean $flag - * @return \Magento\SalesRule\Model\Validator + * @param bool $flag + * @return $this */ public function setSkipActionsValidation($flag) { @@ -272,10 +281,10 @@ class Validator extends \Magento\Core\Model\AbstractModel /** * Can apply rules check * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item - * @return bool + * @param AbstractItem $item + * @return bool */ - public function canApplyRules(\Magento\Sales\Model\Quote\Item\AbstractItem $item) + public function canApplyRules(AbstractItem $item) { $address = $item->getAddress(); foreach ($this->_getRules() as $rule) { @@ -287,52 +296,13 @@ class Validator extends \Magento\Core\Model\AbstractModel return true; } - /** - * Quote item free shipping ability check - * This process not affect information about applied rules, coupon code etc. - * This information will be added during discount amounts processing - * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item - * @return \Magento\SalesRule\Model\Validator - */ - public function processFreeShipping(\Magento\Sales\Model\Quote\Item\AbstractItem $item) - { - $address = $item->getAddress(); - $item->setFreeShipping(false); - - foreach ($this->_getRules() as $rule) { - /* @var $rule \Magento\SalesRule\Model\Rule */ - if (!$this->_canProcessRule($rule, $address)) { - continue; - } - - if (!$rule->getActions()->validate($item)) { - continue; - } - - switch ($rule->getSimpleFreeShipping()) { - case \Magento\SalesRule\Model\Rule::FREE_SHIPPING_ITEM: - $item->setFreeShipping($rule->getDiscountQty() ? $rule->getDiscountQty() : true); - break; - - case \Magento\SalesRule\Model\Rule::FREE_SHIPPING_ADDRESS: - $address->setFreeShipping(true); - break; - } - if ($rule->getStopRulesProcessing()) { - break; - } - } - return $this; - } - /** * Reset quote and address applied rules * - * @param \Magento\Sales\Model\Quote\Address $address - * @return \Magento\SalesRule\Model\Validator + * @param Address $address + * @return $this */ - public function reset(\Magento\Sales\Model\Quote\Address $address) + public function reset(Address $address) { if ($this->_isFirstTimeResetRun) { $address->setAppliedRuleIds(''); @@ -346,10 +316,10 @@ class Validator extends \Magento\Core\Model\AbstractModel /** * Quote item discount calculation process * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item - * @return \Magento\SalesRule\Model\Validator + * @param AbstractItem $item + * @return $this */ - public function process(\Magento\Sales\Model\Quote\Item\AbstractItem $item) + public function process(AbstractItem $item) { $item->setDiscountAmount(0); $item->setBaseDiscountAmount(0); @@ -369,10 +339,10 @@ class Validator extends \Magento\Core\Model\AbstractModel /** * Apply discounts to shipping amount * - * @param \Magento\Sales\Model\Quote\Address $address - * @return \Magento\SalesRule\Model\Validator + * @param Address $address + * @return $this */ - public function processShippingAmount(\Magento\Sales\Model\Quote\Address $address) + public function processShippingAmount(Address $address) { $shippingAmount = $address->getShippingAmountForDiscount(); if ($shippingAmount!==null) { @@ -384,7 +354,7 @@ class Validator extends \Magento\Core\Model\AbstractModel $quote = $address->getQuote(); $appliedRuleIds = array(); foreach ($this->_getRules() as $rule) { - /* @var $rule \Magento\SalesRule\Model\Rule */ + /* @var \Magento\SalesRule\Model\Rule $rule */ if (!$rule->getApplyToShipping() || !$this->_canProcessRule($rule, $address)) { continue; } @@ -483,10 +453,10 @@ class Validator extends \Magento\Core\Model\AbstractModel * Calculate quote totals for each rule and save results * * @param mixed $items - * @param \Magento\Sales\Model\Quote\Address $address - * @return \Magento\SalesRule\Model\Validator + * @param Address $address + * @return $this */ - public function initTotals($items, \Magento\Sales\Model\Quote\Address $address) + public function initTotals($items, Address $address) { $address->setCartFixedRules(array()); @@ -531,10 +501,9 @@ class Validator extends \Magento\Core\Model\AbstractModel /** * Set coupon code to address if $rule contains validated coupon * - * @param \Magento\Sales\Model\Quote\Address $address - * @param \Magento\SalesRule\Model\Rule $rule - * - * @return \Magento\SalesRule\Model\Validator + * @param Address $address + * @param \Magento\SalesRule\Model\Rule $rule + * @return $this */ protected function _maintainAddressCouponCode($address, $rule) { @@ -552,9 +521,9 @@ class Validator extends \Magento\Core\Model\AbstractModel /** * Add rule discount description label to address object * - * @param \Magento\Sales\Model\Quote\Address $address - * @param \Magento\SalesRule\Model\Rule $rule - * @return \Magento\SalesRule\Model\Validator + * @param Address $address + * @param \Magento\SalesRule\Model\Rule $rule + * @return $this */ protected function _addDiscountDescription($address, $rule) { @@ -579,7 +548,7 @@ class Validator extends \Magento\Core\Model\AbstractModel /** * Return item price * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item + * @param AbstractItem $item * @return float */ public function getItemPrice($item) @@ -592,7 +561,7 @@ class Validator extends \Magento\Core\Model\AbstractModel /** * Return item original price * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item + * @param AbstractItem $item * @return float */ public function getItemOriginalPrice($item) @@ -603,7 +572,7 @@ class Validator extends \Magento\Core\Model\AbstractModel /** * Return item base price * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item + * @param AbstractItem $item * @return float */ public function getItemBasePrice($item) @@ -615,7 +584,7 @@ class Validator extends \Magento\Core\Model\AbstractModel /** * Return item base original price * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item + * @param AbstractItem $item * @return float */ public function getItemBaseOriginalPrice($item) @@ -626,7 +595,7 @@ class Validator extends \Magento\Core\Model\AbstractModel /** * Return discount item qty * - * @param \Magento\Sales\Model\Quote\Item\AbstractItem $item + * @param AbstractItem $item * @param \Magento\SalesRule\Model\Rule $rule * @return int */ @@ -640,9 +609,9 @@ class Validator extends \Magento\Core\Model\AbstractModel /** * Convert address discount description array to string * - * @param \Magento\Sales\Model\Quote\Address $address + * @param Address $address * @param string $separator - * @return \Magento\SalesRule\Model\Validator + * @return $this */ public function prepareDescription($address, $separator=', ') { diff --git a/app/code/Magento/SalesRule/etc/module.xml b/app/code/Magento/SalesRule/etc/module.xml index d3c447efbf9..01bfba68f2e 100755 --- a/app/code/Magento/SalesRule/etc/module.xml +++ b/app/code/Magento/SalesRule/etc/module.xml @@ -45,6 +45,7 @@ <module name="Magento_Reports"/> <module name="Magento_CatalogRule"/> <module name="Magento_Widget"/> + <module name="Magento_Cron"/> </depends> </module> </config> diff --git a/app/code/Magento/SalesRule/etc/sales.xml b/app/code/Magento/SalesRule/etc/sales.xml index b1f4f59c4eb..721f65e4471 100644 --- a/app/code/Magento/SalesRule/etc/sales.xml +++ b/app/code/Magento/SalesRule/etc/sales.xml @@ -26,7 +26,6 @@ <config> <section name="quote"> <group name="totals"> - <item name="freeshipping" instance="Magento\SalesRule\Model\Quote\Freeshipping" sort_order="150"/> <item name="discount" instance="Magento\SalesRule\Model\Quote\Discount" sort_order="400"/> </group> <group name="nominal_totals"> diff --git a/app/code/Magento/SalesRule/sql/salesrule_setup/install-1.6.0.0.php b/app/code/Magento/SalesRule/sql/salesrule_setup/install-1.6.0.0.php index 8c6b07d00f7..31212c50d03 100644 --- a/app/code/Magento/SalesRule/sql/salesrule_setup/install-1.6.0.0.php +++ b/app/code/Magento/SalesRule/sql/salesrule_setup/install-1.6.0.0.php @@ -89,11 +89,6 @@ $table = $installer->getConnection() 'unsigned' => true, 'nullable' => false, ), 'Discount Step') - ->addColumn('simple_free_shipping', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Simple Free Shipping') ->addColumn('apply_to_shipping', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( 'unsigned' => true, 'nullable' => false, diff --git a/app/code/Magento/Shipping/Block/Adminhtml/Order/Packaging.php b/app/code/Magento/Shipping/Block/Adminhtml/Order/Packaging.php index 155d0f3968a..b829a93d360 100644 --- a/app/code/Magento/Shipping/Block/Adminhtml/Order/Packaging.php +++ b/app/code/Magento/Shipping/Block/Adminhtml/Order/Packaging.php @@ -29,7 +29,9 @@ namespace Magento\Shipping\Block\Adminhtml\Order; class Packaging extends \Magento\Backend\Block\Template { /** - * @var \Magento\Usa\Model\Shipping\Carrier\Usps\Source\Size + * Source size model + * + * @var \Magento\Shipping\Model\Carrier\Source\GenericInterface */ protected $_sourceSizeModel; @@ -53,7 +55,7 @@ class Packaging extends \Magento\Backend\Block\Template /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Json\EncoderInterface $jsonEncoder - * @param \Magento\Usa\Model\Shipping\Carrier\Usps\Source\Size $sourceSizeModel + * @param \Magento\Shipping\Model\Carrier\Source\GenericInterface $sourceSizeModel * @param \Magento\Registry $coreRegistry * @param \Magento\Shipping\Model\CarrierFactory $carrierFactory * @param array $data @@ -61,7 +63,7 @@ class Packaging extends \Magento\Backend\Block\Template public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Json\EncoderInterface $jsonEncoder, - \Magento\Usa\Model\Shipping\Carrier\Usps\Source\Size $sourceSizeModel, + \Magento\Shipping\Model\Carrier\Source\GenericInterface $sourceSizeModel, \Magento\Registry $coreRegistry, \Magento\Shipping\Model\CarrierFactory $carrierFactory, array $data = array() @@ -332,6 +334,16 @@ class Packaging extends \Magento\Backend\Block\Template return $carrier->isGirthAllowed($this->getShipment()->getOrder()->getShippingAddress()->getCountryId()); } + /** + * Is display girth value + * + * @return bool + */ + public function isDisplayGirthValue() + { + return false; + } + /** * Return content types of package * @@ -405,9 +417,9 @@ class Packaging extends \Magento\Backend\Block\Template } /** - * Get Usps source size model + * Get source size model * - * @return \Magento\Usa\Model\Shipping\Carrier\Usps\Source\Size + * @return \Magento\Shipping\Model\Carrier\Source\GenericInterface */ public function getSourceSizeModel() { diff --git a/app/code/Magento/Shipping/Block/Tracking/Popup.php b/app/code/Magento/Shipping/Block/Tracking/Popup.php index cb45869b565..0d598dfa3d3 100644 --- a/app/code/Magento/Shipping/Block/Tracking/Popup.php +++ b/app/code/Magento/Shipping/Block/Tracking/Popup.php @@ -81,8 +81,8 @@ class Popup extends \Magento\View\Element\Template */ public function formatDeliveryDate($date) { - $format = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM); - return $this->_locale->date(strtotime($date), \Zend_Date::TIMESTAMP, null, false) + $format = $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM); + return $this->_localeDate->date(strtotime($date), \Zend_Date::TIMESTAMP, null, false) ->toString($format); } @@ -99,8 +99,8 @@ class Popup extends \Magento\View\Element\Template $time = $date . ' ' . $time; } - $format = $this->_locale->getTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); - return $this->_locale->date(strtotime($time), \Zend_Date::TIMESTAMP, null, false) + $format = $this->_localeDate->getTimeFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); + return $this->_localeDate->date(strtotime($time), \Zend_Date::TIMESTAMP, null, false) ->toString($format); } diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment.php index e9a4b36fa45..93e6d8990bc 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment.php @@ -614,7 +614,7 @@ class Shipment extends \Magento\Sales\Controller\Adminhtml\Shipment\AbstractShip if ($shipment) { $pdf = $this->_objectManager->create('Magento\Shipping\Model\Order\Pdf\Packaging')->getPdf($shipment); return $this->_fileFactory->create( - 'packingslip' . $this->_objectManager->get('Magento\Core\Model\Date')->date('Y-m-d_H-i-s') . '.pdf', + 'packingslip' . $this->_objectManager->get('Magento\Stdlib\DateTime\DateTime')->date('Y-m-d_H-i-s') . '.pdf', $pdf->render(), \Magento\App\Filesystem::VAR_DIR, 'application/pdf' @@ -720,6 +720,7 @@ class Shipment extends \Magento\Sales\Controller\Adminhtml\Shipment\AbstractShip /** @var \Magento\Filesystem\Directory\Write $directory */ $directory = $this->_objectManager->get('Magento\App\Filesystem') ->getDirectoryWrite(\Magento\App\Filesystem::TMP_DIR); + $directory->create(); $image = imagecreatefromstring($imageString); if (!$image) { return false; diff --git a/app/code/Magento/Usa/Helper/Data.php b/app/code/Magento/Shipping/Helper/Carrier.php similarity index 59% rename from app/code/Magento/Usa/Helper/Data.php rename to app/code/Magento/Shipping/Helper/Carrier.php index 4697ebd993a..7a41728b667 100644 --- a/app/code/Magento/Usa/Helper/Data.php +++ b/app/code/Magento/Shipping/Helper/Carrier.php @@ -18,35 +18,82 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Helper; + +namespace Magento\Shipping\Helper; /** - * Usa data helper - * - * @author Magento Core Team <core@magentocommerce.com> + * Carrier helper */ -class Data extends \Magento\App\Helper\AbstractHelper +class Carrier extends \Magento\App\Helper\AbstractHelper { + /** + * Carriers root xml path + */ + const XML_PATH_CARRIERS_ROOT = 'carriers'; + /** * Locale interface * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ResolverInterface $localeResolver */ - protected $_locale; + protected $localeResolver; + + /** + * Store config + * + * @var \Magento\Core\Model\Store\ConfigInterface + */ + protected $storeConfig; /** * @param \Magento\App\Helper\Context $context - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\ResolverInterface $localeResolver + * @param \Magento\Core\Model\Store\ConfigInterface $storeConfig + */ + public function __construct( + \Magento\App\Helper\Context $context, + \Magento\Locale\ResolverInterface $localeResolver, + \Magento\Core\Model\Store\ConfigInterface $storeConfig + ) { + $this->localeResolver = $localeResolver; + $this->storeConfig = $storeConfig; + parent::__construct($context); + } + + /** + * Get online shipping carrier codes + * + * @param int|\Magento\Core\Model\Store|null $store + * @return array */ - public function __construct(\Magento\App\Helper\Context $context, \Magento\Core\Model\LocaleInterface $locale) + public function getOnlineCarrierCodes($store = null) { - $this->_locale = $locale; - parent::__construct($context); + $carriersCodes = array(); + foreach ($this->storeConfig->getConfig(self::XML_PATH_CARRIERS_ROOT, $store) as $carrierCode => $carrier) { + if (isset($carrier['is_online']) && $carrier['is_online']) { + $carriersCodes[] = $carrierCode; + } + } + return $carriersCodes; + } + + /** + * Get shipping carrier config value + * + * @param string $carrierCode + * @param string $configPath + * @param null $store + * @return string + */ + public function getCarrierConfigValue($carrierCode, $configPath, $store = null) + { + return $this->storeConfig->getConfig( + sprintf('%s/%s/%s', self::XML_PATH_CARRIERS_ROOT, $carrierCode , $configPath), + $store + ); } /** @@ -60,7 +107,7 @@ class Data extends \Magento\App\Helper\AbstractHelper public function convertMeasureWeight($value, $sourceWeightMeasure, $toWeightMeasure) { if ($value) { - $locale = $this->_locale->getLocale(); + $locale = $this->localeResolver->getLocale(); $unitWeight = new \Zend_Measure_Weight($value, $sourceWeightMeasure, $locale); $unitWeight->setType($toWeightMeasure); return $unitWeight->getValue(); @@ -79,7 +126,7 @@ class Data extends \Magento\App\Helper\AbstractHelper public function convertMeasureDimension($value, $sourceDimensionMeasure, $toDimensionMeasure) { if ($value) { - $locale = $this->_locale->getLocale(); + $locale = $this->localeResolver->getLocale(); $unitDimension = new \Zend_Measure_Length($value, $sourceDimensionMeasure, $locale); $unitDimension->setType($toDimensionMeasure); return $unitDimension->getValue(); @@ -118,39 +165,4 @@ class Data extends \Magento\App\Helper\AbstractHelper } return ''; } - - /** - * Define if we need girth parameter in the package window - * - * @param string $shippingMethod - * @return bool - */ - public function displayGirthValue($shippingMethod) - { - if (in_array($shippingMethod, array( - 'usps_0_FCLE', // First-Class Mail Large Envelope - 'usps_1', // Priority Mail - 'usps_2', // Priority Mail Express Hold For Pickup - 'usps_3', // Priority Mail Express - 'usps_4', // Standard Post - 'usps_6', // Media Mail - 'usps_INT_1', // Priority Mail Express International - 'usps_INT_2', // Priority Mail International - 'usps_INT_4', // Global Express Guaranteed (GXG) - 'usps_INT_7', // Global Express Guaranteed Non-Document Non-Rectangular - 'usps_INT_8', // Priority Mail International Flat Rate Envelope - 'usps_INT_9', // Priority Mail International Medium Flat Rate Box - 'usps_INT_10', // Priority Mail Express International Flat Rate Envelope - 'usps_INT_11', // Priority Mail International Large Flat Rate Box - 'usps_INT_12', // USPS GXG Envelopes - 'usps_INT_14', // First-Class Mail International Large Envelope - 'usps_INT_16', // Priority Mail International Small Flat Rate Box - 'usps_INT_20', // Priority Mail International Small Flat Rate Envelope - 'usps_INT_26', // Priority Mail Express International Flat Rate Boxes - ))) { - return true; - } else { - return false; - } - } } diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/AbstractCarrier.php b/app/code/Magento/Shipping/Model/Carrier/AbstractCarrierOnline.php similarity index 97% rename from app/code/Magento/Usa/Model/Shipping/Carrier/AbstractCarrier.php rename to app/code/Magento/Shipping/Model/Carrier/AbstractCarrierOnline.php index 1038fce4b40..c39c924ed3b 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/AbstractCarrier.php +++ b/app/code/Magento/Shipping/Model/Carrier/AbstractCarrierOnline.php @@ -18,12 +18,11 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier; + +namespace Magento\Shipping\Model\Carrier; use Magento\Core\Exception; use Magento\Sales\Model\Quote\Address\RateRequest; @@ -31,11 +30,10 @@ use Magento\Sales\Model\Quote\Address\RateResult\Error; use Magento\Shipping\Model\Shipment\Request; /** - * Abstract USA shipping carrier model + * Abstract online shipping carrier model */ -abstract class AbstractCarrier extends \Magento\Shipping\Model\Carrier\AbstractCarrier +abstract class AbstractCarrierOnline extends AbstractCarrier { - const USA_COUNTRY_ID = 'US'; const PUERTORICO_COUNTRY_ID = 'PR'; const GUAM_COUNTRY_ID = 'GU'; @@ -63,7 +61,7 @@ abstract class AbstractCarrier extends \Magento\Shipping\Model\Carrier\AbstractC protected $_directoryData = null; /** - * @var \Magento\Usa\Model\Simplexml\ElementFactory + * @var \Magento\Shipping\Model\Simplexml\ElementFactory */ protected $_xmlElFactory; @@ -112,7 +110,7 @@ abstract class AbstractCarrier extends \Magento\Shipping\Model\Carrier\AbstractC * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory * @param \Magento\Logger\AdapterFactory $logAdapterFactory - * @param \Magento\Usa\Model\Simplexml\ElementFactory $xmlElFactory + * @param \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory * @param \Magento\Shipping\Model\Rate\ResultFactory $rateFactory * @param \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory * @param \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory @@ -130,7 +128,7 @@ abstract class AbstractCarrier extends \Magento\Shipping\Model\Carrier\AbstractC \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Magento\Logger\AdapterFactory $logAdapterFactory, - \Magento\Usa\Model\Simplexml\ElementFactory $xmlElFactory, + \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateFactory, \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory, diff --git a/app/code/Magento/Shipping/Model/Carrier/Source/GenericInterface.php b/app/code/Magento/Shipping/Model/Carrier/Source/GenericInterface.php new file mode 100644 index 00000000000..3297de554ce --- /dev/null +++ b/app/code/Magento/Shipping/Model/Carrier/Source/GenericInterface.php @@ -0,0 +1,34 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Shipping\Model\Carrier\Source; + +use Magento\Data\OptionSourceInterface; + +/** + * Interface GenericInterface + */ +interface GenericInterface extends OptionSourceInterface +{ +} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/AbstractCarrier/Source/Mode.php b/app/code/Magento/Shipping/Model/Config/Source/Online/Mode.php similarity index 82% rename from app/code/Magento/Usa/Model/Shipping/Carrier/AbstractCarrier/Source/Mode.php rename to app/code/Magento/Shipping/Model/Config/Source/Online/Mode.php index 5a960937221..592ccbaa287 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/AbstractCarrier/Source/Mode.php +++ b/app/code/Magento/Shipping/Model/Config/Source/Online/Mode.php @@ -18,23 +18,18 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Shipping\Model\Config\Source\Online; + +use Magento\Data\OptionSourceInterface; + /** * Shippers Modesource model - * - * @category Magento - * @package Magento_Usa - * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Usa\Model\Shipping\Carrier\AbstractCarrier\Source; - -class Mode implements \Magento\Option\ArrayInterface +class Mode implements OptionSourceInterface { /** * Returns array to be used in packages request type on back-end diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/AbstractCarrier/Source/Requesttype.php b/app/code/Magento/Shipping/Model/Config/Source/Online/Requesttype.php similarity index 81% rename from app/code/Magento/Usa/Model/Shipping/Carrier/AbstractCarrier/Source/Requesttype.php rename to app/code/Magento/Shipping/Model/Config/Source/Online/Requesttype.php index e83ff5612c2..d51e884ed6d 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/AbstractCarrier/Source/Requesttype.php +++ b/app/code/Magento/Shipping/Model/Config/Source/Online/Requesttype.php @@ -18,22 +18,18 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Shipping\Model\Config\Source\Online; + +use Magento\Data\OptionSourceInterface; + /** * Source model for Shippers Request Type - * - * @category Magento - * @package Magento_Usa - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Usa\Model\Shipping\Carrier\AbstractCarrier\Source; - -class Requesttype implements \Magento\Option\ArrayInterface +class Requesttype implements OptionSourceInterface { /** * Returns array to be used in packages request type on back-end diff --git a/app/code/Magento/Shipping/Model/Observer.php b/app/code/Magento/Shipping/Model/Observer.php index fe146366250..c7e914ea102 100644 --- a/app/code/Magento/Shipping/Model/Observer.php +++ b/app/code/Magento/Shipping/Model/Observer.php @@ -27,9 +27,9 @@ namespace Magento\Shipping\Model; class Observer { /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ResolverInterface */ - protected $_coreLocale; + protected $_localeResolver; /** * @var \Magento\Sales\Model\Resource\Report\ShippingFactory @@ -37,14 +37,14 @@ class Observer protected $_shippingFactory; /** - * @param \Magento\Core\Model\LocaleInterface $coreLocale + * @param \Magento\Locale\ResolverInterface $localeResolver * @param \Magento\Sales\Model\Resource\Report\ShippingFactory $shippingFactory */ public function __construct( - \Magento\Core\Model\LocaleInterface $coreLocale, + \Magento\Locale\ResolverInterface $localeResolver, \Magento\Sales\Model\Resource\Report\ShippingFactory $shippingFactory ) { - $this->_coreLocale = $coreLocale; + $this->_localeResolver = $localeResolver; $this->_shippingFactory = $shippingFactory; } @@ -55,11 +55,11 @@ class Observer */ public function aggregateSalesReportShipmentData() { - $this->_coreLocale->emulate(0); + $this->_localeResolver->emulate(0); $currentDate = $this->_coreLocale->date(); $date = $currentDate->subHour(25); $this->_shippingFactory->create()->aggregate($date); - $this->_coreLocale->revert(); + $this->_localeResolver->revert(); return $this; } } diff --git a/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php b/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php index 9892d93a999..bdf7add9120 100644 --- a/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php +++ b/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php @@ -24,14 +24,16 @@ namespace Magento\Shipping\Model\Order\Pdf; +use Magento\Shipping\Helper\Carrier; + class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf { /** - * Usa data + * Carrier helper * - * @var \Magento\Usa\Helper\Data + * @var \Magento\Shipping\Helper\Carrier */ - protected $_usaData = null; + protected $_carrierHelper; /** * @var \Magento\Core\Model\StoreManagerInterface @@ -43,6 +45,11 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf */ protected $_layout; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Stdlib\String $string @@ -52,10 +59,11 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf * @param \Magento\Sales\Model\Order\Pdf\Config $pdfConfig * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory * @param \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory - * @param \Magento\Core\Model\LocaleInterface $locale - * @param \Magento\Usa\Helper\Data $usaData + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate + * @param \Magento\Shipping\Helper\Carrier $carrierHelper * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\View\LayoutInterface $layout + * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -69,15 +77,17 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf \Magento\Sales\Model\Order\Pdf\Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, \Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory, - \Magento\Core\Model\LocaleInterface $locale, - \Magento\Usa\Helper\Data $usaData, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + Carrier $carrierHelper, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\View\LayoutInterface $layout, + \Magento\Locale\ResolverInterface $localeResolver, array $data = array() ) { - $this->_usaData = $usaData; + $this->_carrierHelper = $carrierHelper; $this->_storeManager = $storeManager; $this->_layout = $layout; + $this->_localeResolver = $localeResolver; parent::__construct( $paymentData, @@ -88,7 +98,7 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf $pdfConfig, $pdfTotalFactory, $pdfItemsFactory, - $locale, + $localeDate, $data ); } @@ -109,7 +119,7 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf $page = $this->newPage(); if ($shipment->getStoreId()) { - $this->locale->emulate($shipment->getStoreId()); + $this->_localeResolver->emulate($shipment->getStoreId()); $this->_storeManager->setCurrentStore($shipment->getStoreId()); } @@ -122,7 +132,7 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf $this->_afterGetPdf(); if ($shipment->getStoreId()) { - $this->locale->revert(); + $this->_localeResolver->revert(); } return $pdf; } @@ -178,7 +188,7 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf $package = new \Magento\Object($package); $params = new \Magento\Object($package->getParams()); - $dimensionUnits = $this->_usaData->getMeasureDimensionName($params->getDimensionUnits()); + $dimensionUnits = $this->_carrierHelper->getMeasureDimensionName($params->getDimensionUnits()); $typeText = __('Type') . ' : ' . $packaging->getContainerTypeByCode($params->getContainer()); @@ -228,7 +238,7 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf $this->y = $this->y - 10; $weightText = __('Total Weight') . ' : ' . $params->getWeight() .' ' - . $this->_usaData->getMeasureWeightName($params->getWeightUnits()); + . $this->_carrierHelper->getMeasureWeightName($params->getWeightUnits()); $page->drawText($weightText, 35, $this->y, 'UTF-8'); if ($params->getHeight() != null) { @@ -246,7 +256,7 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf $page->drawText($sizeText, 35, $this->y, 'UTF-8'); } if ($params->getGirth() != null) { - $dimensionGirthUnits = $this->_usaData->getMeasureDimensionName($params->getGirthDimensionUnits()); + $dimensionGirthUnits = $this->_carrierHelper->getMeasureDimensionName($params->getGirthDimensionUnits()); $girthText = __('Girth') . ' : ' . $params->getGirth() . ' ' . $dimensionGirthUnits; $page->drawText($girthText, 200, $this->y, 'UTF-8'); diff --git a/app/code/Magento/Shipping/Model/Order/Track.php b/app/code/Magento/Shipping/Model/Order/Track.php index a40c2944bc3..158d3c6c2a0 100644 --- a/app/code/Magento/Shipping/Model/Order/Track.php +++ b/app/code/Magento/Shipping/Model/Order/Track.php @@ -57,7 +57,7 @@ class Track extends \Magento\Sales\Model\Order\Shipment\Track /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\Core\Model\LocaleInterface $coreLocale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory @@ -71,7 +71,7 @@ class Track extends \Magento\Sales\Model\Order\Shipment\Track public function __construct( \Magento\Model\Context $context, \Magento\Registry $registry, - \Magento\Core\Model\LocaleInterface $coreLocale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\ShipmentFactory $shipmentFactory, @@ -83,7 +83,7 @@ class Track extends \Magento\Sales\Model\Order\Shipment\Track parent::__construct( $context, $registry, - $coreLocale, + $localeDate, $dateTime, $storeManager, $shipmentFactory, diff --git a/app/code/Magento/Usa/Model/Simplexml/Element.php b/app/code/Magento/Shipping/Model/Simplexml/Element.php similarity index 92% rename from app/code/Magento/Usa/Model/Simplexml/Element.php rename to app/code/Magento/Shipping/Model/Simplexml/Element.php index a419265195a..950babde551 100644 --- a/app/code/Magento/Usa/Model/Simplexml/Element.php +++ b/app/code/Magento/Shipping/Model/Simplexml/Element.php @@ -18,17 +18,14 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Simplexml; +namespace Magento\Shipping\Model\Simplexml; /** * Extends SimpleXML to add valuable functionality to \SimpleXMLElement class * - * @author Magento Core Team <core@magentocommerce.com> */ class Element extends \Magento\Simplexml\Element { @@ -54,7 +51,7 @@ class Element extends \Magento\Simplexml\Element * @param string $name The name of the child element to add. * @param string $value If specified, the value of the child element. * @param string $namespace If specified, the namespace to which the child element belongs. - * @return \Magento\Usa\Model\Simplexml\Element + * @return \Magento\Shipping\Model\Simplexml\Element */ public function addChild($name, $value = null, $namespace = null) { diff --git a/app/code/Magento/Shipping/Model/Tracking/Result/Status.php b/app/code/Magento/Shipping/Model/Tracking/Result/Status.php index ce8651064ff..cf4bf505310 100644 --- a/app/code/Magento/Shipping/Model/Tracking/Result/Status.php +++ b/app/code/Magento/Shipping/Model/Tracking/Result/Status.php @@ -27,24 +27,8 @@ namespace Magento\Shipping\Model\Tracking\Result; /** * Fields: - * - carrier: fedex - * - carrierTitle: Federal Express - * - tracking: 749011111111 - * - status: delivered - * - service: home delivery - * - delivery date: 2007-11-23 - * - delivery time: 16:01:00 - * - delivery location: Frontdoor - * - signedby: lindy - * - * Fields: - * -carrier: ups cgi - * -popup: 1 - * -url: http://wwwapps.ups.com/WebTracking/processInputRequest?HTMLVersion=5.0&error_carried=true&tracknums_displayed=5&TypeOfInquiryNumber=T&loc=en_US&InquiryNumber1=$tracking - * - * Fields: - * -carrier: usps - * -tracksummary: Your item was delivered at 6:50 am on February 6 in Los Angeles CA 90064 + * - carrier: carrier code + * - carrierTitle: carrier title */ class Status extends \Magento\Shipping\Model\Tracking\Result\AbstractResult { diff --git a/app/code/Magento/Shipping/etc/adminhtml/system.xml b/app/code/Magento/Shipping/etc/adminhtml/system.xml index e5d4643df46..598e401133f 100644 --- a/app/code/Magento/Shipping/etc/adminhtml/system.xml +++ b/app/code/Magento/Shipping/etc/adminhtml/system.xml @@ -59,149 +59,6 @@ <label>Shipping Methods</label> <tab>sales</tab> <resource>Magento_Shipping::carriers</resource> - <group id="flatrate" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Flat Rate</label> - <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enabled</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="name" translate="label" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Method Name</label> - </field> - <field id="price" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Price</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="handling_type" translate="label" type="select" sortOrder="7" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Calculate Handling Fee</label> - <source_model>Magento\Shipping\Model\Source\HandlingType</source_model> - </field> - <field id="handling_fee" translate="label" type="text" sortOrder="8" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Handling Fee</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sort Order</label> - </field> - <field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Title</label> - </field> - <field id="type" translate="label" type="select" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Type</label> - <source_model>Magento\Shipping\Model\Config\Source\Flatrate</source_model> - </field> - <field id="sallowspecific" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Applicable Countries</label> - <frontend_class>shipping-applicable-country</frontend_class> - <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> - </field> - <field id="specificcountry" translate="label" type="multiselect" sortOrder="91" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Specific Countries</label> - <source_model>Magento\Directory\Model\Config\Source\Country</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="showmethod" translate="label" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Show Method if Not Applicable</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="specificerrmsg" translate="label" type="textarea" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Displayed Error Message</label> - </field> - </group> - <group id="freeshipping" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Free Shipping</label> - <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enabled</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="free_shipping_subtotal" translate="label" type="text" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Minimum Order Amount</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="name" translate="label" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Method Name</label> - </field> - <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sort Order</label> - </field> - <field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Title</label> - </field> - <field id="sallowspecific" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Applicable Countries</label> - <frontend_class>shipping-applicable-country</frontend_class> - <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> - </field> - <field id="specificcountry" translate="label" type="multiselect" sortOrder="91" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Specific Countries</label> - <source_model>Magento\Directory\Model\Config\Source\Country</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="showmethod" translate="label" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Show Method if Not Applicable</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="specificerrmsg" translate="label" type="textarea" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Displayed Error Message</label> - </field> - </group> - <group id="tablerate" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Table Rates</label> - <field id="handling_type" translate="label" type="select" sortOrder="7" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Calculate Handling Fee</label> - <source_model>Magento\Shipping\Model\Source\HandlingType</source_model> - </field> - <field id="handling_fee" translate="label" type="text" sortOrder="8" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Handling Fee</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enabled</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="condition_name" translate="label" type="select" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Condition</label> - <source_model>Magento\Shipping\Model\Config\Source\Tablerate</source_model> - </field> - <field id="include_virtual_price" translate="label" type="select" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Include Virtual Products in Price Calculation</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="export" translate="label" type="export" sortOrder="5" showInDefault="0" showInWebsite="1" showInStore="0"> - <label>Export</label> - </field> - <field id="import" translate="label" type="import" sortOrder="6" showInDefault="0" showInWebsite="1" showInStore="0"> - <label>Import</label> - <backend_model>Magento\Shipping\Model\Config\Backend\Tablerate</backend_model> - </field> - <field id="name" translate="label" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Method Name</label> - </field> - <field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sort Order</label> - </field> - <field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Title</label> - </field> - <field id="sallowspecific" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Applicable Countries</label> - <frontend_class>shipping-applicable-country</frontend_class> - <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> - </field> - <field id="specificcountry" translate="label" type="multiselect" sortOrder="91" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Specific Countries</label> - <source_model>Magento\Directory\Model\Config\Source\Country</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="showmethod" translate="label" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Show Method if Not Applicable</label> - <frontend_class>shipping-skip-hide</frontend_class> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="specificerrmsg" translate="label" type="textarea" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Displayed Error Message</label> - </field> - </group> </section> </system> </config> diff --git a/app/code/Magento/Shipping/etc/config.xml b/app/code/Magento/Shipping/etc/config.xml index 7ec891415f9..0ae6c200b67 100644 --- a/app/code/Magento/Shipping/etc/config.xml +++ b/app/code/Magento/Shipping/etc/config.xml @@ -34,38 +34,5 @@ <region_id>12</region_id> </origin> </shipping> - <carriers> - <flatrate> - <active>0</active> - <sallowspecific>0</sallowspecific> - <model>Magento\Shipping\Model\Carrier\Flatrate</model> - <name>Fixed</name> - <price>5.00</price> - <title>Flat Rate</title> - <type>I</type> - <specificerrmsg>This shipping method is not available. To use this shipping method, please contact us.</specificerrmsg> - <handling_type>F</handling_type> - </flatrate> - <freeshipping> - <active>0</active> - <sallowspecific>0</sallowspecific> - <cutoff_cost>50</cutoff_cost> - <model>Magento\Shipping\Model\Carrier\Freeshipping</model> - <name>Free</name> - <title>Free Shipping</title> - <specificerrmsg>This shipping method is not available. To use this shipping method, please contact us.</specificerrmsg> - </freeshipping> - <tablerate> - <active>0</active> - <sallowspecific>0</sallowspecific> - <condition_name>package_weight</condition_name> - <include_virtual_price>1</include_virtual_price> - <model>Magento\Shipping\Model\Carrier\Tablerate</model> - <name>Table Rate</name> - <title>Best Way</title> - <specificerrmsg>This shipping method is not available. To use this shipping method, please contact us.</specificerrmsg> - <handling_type>F</handling_type> - </tablerate> - </carriers> </default> </config> diff --git a/app/code/Magento/Shipping/etc/module.xml b/app/code/Magento/Shipping/etc/module.xml index e323b9968e2..f981903296b 100755 --- a/app/code/Magento/Shipping/etc/module.xml +++ b/app/code/Magento/Shipping/etc/module.xml @@ -36,7 +36,6 @@ <module name="Magento_Backend"/> <module name="Magento_Directory"/> <module name="Magento_Contacts"/> - <module name="Magento_Usa"/> <module name="Magento_Customer"/> <module name="Magento_Payment"/> <module name="Magento_Theme"/> diff --git a/app/code/Magento/Shipping/view/adminhtml/order/packaging/packed.phtml b/app/code/Magento/Shipping/view/adminhtml/order/packaging/packed.phtml index 61e72415657..5b375f889bc 100644 --- a/app/code/Magento/Shipping/view/adminhtml/order/packaging/packed.phtml +++ b/app/code/Magento/Shipping/view/adminhtml/order/packaging/packed.phtml @@ -48,7 +48,7 @@ <th><?php echo __('Length') ?></th> <td> <?php if ($params->getLength() != null): ?> - <?php echo $params->getLength() .' '. $this->helper('Magento\Usa\Helper\Data')->getMeasureDimensionName($params->getDimensionUnits()) ?> + <?php echo $params->getLength() .' '. $this->helper('Magento\Shipping\Helper\Carrier')->getMeasureDimensionName($params->getDimensionUnits()) ?> <?php else: ?> -- <?php endif; ?> @@ -67,12 +67,12 @@ <td><?php echo $this->displayCustomsPrice($params->getCustomsValue()) ?></td> <?php else: ?> <th><?php echo __('Total Weight') ?></th> - <td><?php echo $params->getWeight() .' '. $this->helper('Magento\Usa\Helper\Data')->getMeasureWeightName($params->getWeightUnits()) ?></td> + <td><?php echo $params->getWeight() .' '. $this->helper('Magento\Shipping\Helper\Carrier')->getMeasureWeightName($params->getWeightUnits()) ?></td> <?php endif; ?> <th><?php echo __('Width') ?></th> <td> <?php if ($params->getWidth() != null): ?> - <?php echo $params->getWidth() .' '. $this->helper('Magento\Usa\Helper\Data')->getMeasureDimensionName($params->getDimensionUnits()) ?> + <?php echo $params->getWidth() .' '. $this->helper('Magento\Shipping\Helper\Carrier')->getMeasureDimensionName($params->getDimensionUnits()) ?> <?php else: ?> -- <?php endif; ?> @@ -92,7 +92,7 @@ <tr> <?php if ($this->displayCustomsValue()): ?> <th><?php echo __('Total Weight') ?></th> - <td><?php echo $params->getWeight() .' '. $this->helper('Magento\Usa\Helper\Data')->getMeasureWeightName($params->getWeightUnits()) ?></td> + <td><?php echo $params->getWeight() .' '. $this->helper('Magento\Shipping\Helper\Carrier')->getMeasureWeightName($params->getWeightUnits()) ?></td> <?php else: ?> <th> </th> <td> </td> @@ -100,7 +100,7 @@ <th><?php echo __('Height') ?></th> <td> <?php if ($params->getHeight() != null): ?> - <?php echo $params->getHeight() .' '. $this->helper('Magento\Usa\Helper\Data')->getMeasureDimensionName($params->getDimensionUnits()) ?> + <?php echo $params->getHeight() .' '. $this->helper('Magento\Shipping\Helper\Carrier')->getMeasureDimensionName($params->getDimensionUnits()) ?> <?php else: ?> -- <?php endif; ?> @@ -118,7 +118,7 @@ <?php endif; ?> <?php if ($params->getGirth()): ?> <th><?php echo __('Girth') ?></th> - <td><?php echo $params->getGirth() .' '. $this->helper('Magento\Usa\Helper\Data')->getMeasureDimensionName($params->getGirthDimensionUnits()) ?></td> + <td><?php echo $params->getGirth() .' '. $this->helper('Magento\Shipping\Helper\Carrier')->getMeasureDimensionName($params->getGirthDimensionUnits()) ?></td> <?php else: ?> <th> </th> <td> </td> diff --git a/app/code/Magento/Shipping/view/adminhtml/order/packaging/popup.phtml b/app/code/Magento/Shipping/view/adminhtml/order/packaging/popup.phtml index 0dab463f895..86bff6d8e99 100644 --- a/app/code/Magento/Shipping/view/adminhtml/order/packaging/popup.phtml +++ b/app/code/Magento/Shipping/view/adminhtml/order/packaging/popup.phtml @@ -28,7 +28,7 @@ <?php $shippingMethod = $this->getShipment()->getOrder()->getShippingMethod(); $sizeSource = $this->getSourceSizeModel()->toOptionArray(); -$girthEnabled = $this->helper('Magento\Usa\Helper\Data')->displayGirthValue($shippingMethod) && $this->isGirthAllowed() ? 1 : 0; +$girthEnabled = $this->isDisplayGirthValue() && $this->isGirthAllowed() ? 1 : 0; ?> <script type="text/javascript"> //<![CDATA[ diff --git a/app/code/Magento/Sitemap/Block/Adminhtml/Grid/Renderer/Time.php b/app/code/Magento/Sitemap/Block/Adminhtml/Grid/Renderer/Time.php index 51bd5c7da93..be21c3e7207 100644 --- a/app/code/Magento/Sitemap/Block/Adminhtml/Grid/Renderer/Time.php +++ b/app/code/Magento/Sitemap/Block/Adminhtml/Grid/Renderer/Time.php @@ -35,18 +35,18 @@ namespace Magento\Sitemap\Block\Adminhtml\Grid\Renderer; class Time extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; /** * @param \Magento\Backend\Block\Context $context - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, array $data = array() ) { $this->_date = $date; diff --git a/app/code/Magento/Sitemap/Model/Sitemap.php b/app/code/Magento/Sitemap/Model/Sitemap.php index 8d648482895..ba027e3e2bf 100644 --- a/app/code/Magento/Sitemap/Model/Sitemap.php +++ b/app/code/Magento/Sitemap/Model/Sitemap.php @@ -136,7 +136,7 @@ class Sitemap extends \Magento\Core\Model\AbstractModel protected $_cmsFactory; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_dateModel; @@ -164,7 +164,7 @@ class Sitemap extends \Magento\Core\Model\AbstractModel * @param \Magento\Sitemap\Model\Resource\Catalog\CategoryFactory $categoryFactory * @param \Magento\Sitemap\Model\Resource\Catalog\ProductFactory $productFactory * @param \Magento\Sitemap\Model\Resource\Cms\PageFactory $cmsFactory - * @param \Magento\Core\Model\Date $modelDate + * @param \Magento\Stdlib\DateTime\DateTime $modelDate * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\RequestInterface $request * @param \Magento\Stdlib\DateTime $dateTime @@ -181,7 +181,7 @@ class Sitemap extends \Magento\Core\Model\AbstractModel \Magento\Sitemap\Model\Resource\Catalog\CategoryFactory $categoryFactory, \Magento\Sitemap\Model\Resource\Catalog\ProductFactory $productFactory, \Magento\Sitemap\Model\Resource\Cms\PageFactory $cmsFactory, - \Magento\Core\Model\Date $modelDate, + \Magento\Stdlib\DateTime\DateTime $modelDate, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\RequestInterface $request, \Magento\Stdlib\DateTime $dateTime, diff --git a/app/code/Magento/Tax/Helper/Data.php b/app/code/Magento/Tax/Helper/Data.php index b0f7d42feb6..61dac07fbb2 100644 --- a/app/code/Magento/Tax/Helper/Data.php +++ b/app/code/Magento/Tax/Helper/Data.php @@ -120,9 +120,9 @@ class Data extends \Magento\App\Helper\AbstractHelper protected $_storeManager; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\FormatInterface */ - protected $_locale; + protected $_localeFormat; /** * @var \Magento\Eav\Model\Entity\AttributeFactory @@ -134,6 +134,11 @@ class Data extends \Magento\App\Helper\AbstractHelper */ protected $_taxItemFactory; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Helper\Data $coreData @@ -142,9 +147,10 @@ class Data extends \Magento\App\Helper\AbstractHelper * @param \Magento\Tax\Model\Config $taxConfig * @param \Magento\Tax\Model\Calculation $calculation * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\FormatInterface $localeFormat * @param \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory * @param \Magento\Tax\Model\Resource\Sales\Order\Tax\ItemFactory $taxItemFactory + * @param \Magento\Locale\ResolverInterface $localeResolver */ public function __construct( \Magento\App\Helper\Context $context, @@ -154,9 +160,10 @@ class Data extends \Magento\App\Helper\AbstractHelper \Magento\Tax\Model\Config $taxConfig, \Magento\Tax\Model\Calculation $calculation, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\FormatInterface $localeFormat, \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory, - \Magento\Tax\Model\Resource\Sales\Order\Tax\ItemFactory $taxItemFactory + \Magento\Tax\Model\Resource\Sales\Order\Tax\ItemFactory $taxItemFactory, + \Magento\Locale\ResolverInterface $localeResolver ) { parent::__construct($context); $this->_coreStoreConfig = $coreStoreConfig; @@ -165,9 +172,10 @@ class Data extends \Magento\App\Helper\AbstractHelper $this->_coreRegistry = $coreRegistry; $this->_calculation = $calculation; $this->_storeManager = $storeManager; - $this->_locale = $locale; + $this->_localeFormat = $localeFormat; $this->_attributeFactory = $attributeFactory; $this->_taxItemFactory = $taxItemFactory; + $this->_localeResolver = $localeResolver; } /** @@ -450,9 +458,9 @@ class Data extends \Magento\App\Helper\AbstractHelper */ public function getPriceFormat($store = null) { - $this->_locale->emulate($store); - $priceFormat = $this->_locale->getJsPriceFormat(); - $this->_locale->revert(); + $this->_localeResolver->emulate($store); + $priceFormat = $this->_localeFormat->getPriceFormat(); + $this->_localeResolver->revert(); if ($store) { $priceFormat['pattern'] = $this->_storeManager->getStore($store)->getCurrentCurrency()->getOutputFormat(); } diff --git a/app/code/Magento/Tax/Model/Observer.php b/app/code/Magento/Tax/Model/Observer.php index 8fc0474e9a3..00579e6f502 100644 --- a/app/code/Magento/Tax/Model/Observer.php +++ b/app/code/Magento/Tax/Model/Observer.php @@ -54,37 +54,45 @@ class Observer protected $_calculation; /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * @var \Magento\Tax\Model\Resource\Report\TaxFactory */ protected $_reportTaxFactory; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\Tax\Model\Sales\Order\TaxFactory $orderTaxFactory * @param \Magento\Tax\Model\Sales\Order\Tax\ItemFactory $taxItemFactory * @param \Magento\Tax\Model\Calculation $calculation - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Tax\Model\Resource\Report\TaxFactory $reportTaxFactory + * @param \Magento\Locale\ResolverInterface $localeResolver */ public function __construct( \Magento\Tax\Helper\Data $taxData, \Magento\Tax\Model\Sales\Order\TaxFactory $orderTaxFactory, \Magento\Tax\Model\Sales\Order\Tax\ItemFactory $taxItemFactory, \Magento\Tax\Model\Calculation $calculation, - \Magento\Core\Model\LocaleInterface $locale, - \Magento\Tax\Model\Resource\Report\TaxFactory $reportTaxFactory + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, + \Magento\Tax\Model\Resource\Report\TaxFactory $reportTaxFactory, + \Magento\Locale\ResolverInterface $localeResolver ) { $this->_taxData = $taxData; $this->_orderTaxFactory = $orderTaxFactory; $this->_taxItemFactory = $taxItemFactory; $this->_calculation = $calculation; - $this->_locale = $locale; + $this->_localeDate = $localeDate; $this->_reportTaxFactory = $reportTaxFactory; + $this->_localeResolver = $localeResolver; } /** @@ -254,13 +262,13 @@ class Observer */ public function aggregateSalesReportTaxData($schedule) { - $this->_locale->emulate(0); - $currentDate = $this->_locale->date(); + $this->_localeResolver->emulate(0); + $currentDate = $this->_localeDate->date(); $date = $currentDate->subHour(25); /** @var $reportTax \Magento\Tax\Model\Resource\Report\Tax */ $reportTax = $this->_reportTaxFactory->create(); $reportTax->aggregate($date); - $this->_locale->revert(); + $this->_localeResolver->revert(); return $this; } diff --git a/app/code/Magento/Tax/Model/Resource/Report/Tax.php b/app/code/Magento/Tax/Model/Resource/Report/Tax.php index 6212d3b6674..121a3ec35d2 100644 --- a/app/code/Magento/Tax/Model/Resource/Report/Tax.php +++ b/app/code/Magento/Tax/Model/Resource/Report/Tax.php @@ -44,7 +44,7 @@ class Tax extends \Magento\Reports\Model\Resource\Report\AbstractReport /** * @param \Magento\App\Resource $resource * @param \Magento\Logger $logger - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator @@ -54,7 +54,7 @@ class Tax extends \Magento\Reports\Model\Resource\Report\AbstractReport public function __construct( \Magento\App\Resource $resource, \Magento\Logger $logger, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Reports\Model\FlagFactory $reportsFlagFactory, \Magento\Stdlib\DateTime $dateTime, \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator, @@ -63,7 +63,7 @@ class Tax extends \Magento\Reports\Model\Resource\Report\AbstractReport ) { $this->_createdAtFactory = $createdAtFactory; $this->_updatedAtFactory = $updatedAtFactory; - parent::__construct($resource, $logger, $locale, $reportsFlagFactory, $dateTime, $timezoneValidator); + parent::__construct($resource, $logger, $localeDate, $reportsFlagFactory, $dateTime, $timezoneValidator); } /** diff --git a/app/code/Magento/Theme/Block/Html.php b/app/code/Magento/Theme/Block/Html.php index 982b8c95f1f..fe723f8c9bd 100644 --- a/app/code/Magento/Theme/Block/Html.php +++ b/app/code/Magento/Theme/Block/Html.php @@ -23,12 +23,18 @@ */ namespace Magento\Theme\Block; +use Magento\View\Element\Template; /** * Html page block */ class Html extends \Magento\View\Element\Template { + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * The list of available URLs * @@ -41,6 +47,21 @@ class Html extends \Magento\View\Element\Template */ protected $_title = ''; + /** + * @param Template\Context $context + * @param \Magento\Locale\ResolverInterface $localeResolver + * @param array $data + */ + public function __construct( + Template\Context $context, + \Magento\Locale\ResolverInterface $localeResolver, + array $data = array() + ) { + parent::__construct($context, $data); + $this->_localeResolver = $localeResolver; + } + + /** * Add block data * @return void @@ -181,7 +202,7 @@ class Html extends \Magento\View\Element\Template public function getLang() { if (!$this->hasData('lang')) { - $this->setData('lang', substr($this->_locale->getLocaleCode(), 0, 2)); + $this->setData('lang', substr($this->_localeResolver->getLocaleCode(), 0, 2)); } return $this->getData('lang'); } diff --git a/app/code/Magento/Theme/Block/Html/Footer.php b/app/code/Magento/Theme/Block/Html/Footer.php index bb7ecad4ba6..729b3d0b71c 100644 --- a/app/code/Magento/Theme/Block/Html/Footer.php +++ b/app/code/Magento/Theme/Block/Html/Footer.php @@ -27,7 +27,7 @@ namespace Magento\Theme\Block\Html; /** * Html page footer block */ -class Footer extends \Magento\View\Element\Template +class Footer extends \Magento\View\Element\Template implements \Magento\View\Block\IdentityInterface { /** * Copyright information @@ -99,4 +99,15 @@ class Footer extends \Magento\View\Element\Template } return $this->_copyright; } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + return array(\Magento\Core\Model\Store::CACHE_TAG, \Magento\Cms\Model\Block::CACHE_TAG); + } + } diff --git a/app/code/Magento/Theme/Block/Html/Head.php b/app/code/Magento/Theme/Block/Html/Head.php index 802b18ca4f7..11f57d7de6d 100644 --- a/app/code/Magento/Theme/Block/Html/Head.php +++ b/app/code/Magento/Theme/Block/Html/Head.php @@ -77,6 +77,11 @@ class Head extends \Magento\View\Element\Template */ protected $_fileStorageDatabase; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Core\Helper\File\Storage\Database $fileStorageDatabase @@ -84,6 +89,7 @@ class Head extends \Magento\View\Element\Template * @param \Magento\View\Asset\GroupedCollection $assets * @param \Magento\View\Asset\MergeService $assetMergeService * @param \Magento\View\Asset\MinifyService $assetMinifyService + * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data */ public function __construct( @@ -93,6 +99,7 @@ class Head extends \Magento\View\Element\Template \Magento\View\Asset\GroupedCollection $assets, \Magento\View\Asset\MergeService $assetMergeService, \Magento\View\Asset\MinifyService $assetMinifyService, + \Magento\Locale\ResolverInterface $localeResolver, array $data = array() ) { parent::__construct($context, $data); @@ -101,6 +108,7 @@ class Head extends \Magento\View\Element\Template $this->_assetMergeService = $assetMergeService; $this->_assetMinifyService = $assetMinifyService; $this->_pageAssets = $assets; + $this->_localeResolver = $localeResolver; } /** * Add RSS element to HEAD entity @@ -419,6 +427,6 @@ class Head extends \Magento\View\Element\Template */ public function getLocale() { - return substr($this->_locale->getLocaleCode(), 0, 2); + return substr($this->_localeResolver->getLocaleCode(), 0, 2); } } diff --git a/app/code/Magento/Theme/Block/Html/Topmenu.php b/app/code/Magento/Theme/Block/Html/Topmenu.php index fde794411bc..3872adb2cfb 100644 --- a/app/code/Magento/Theme/Block/Html/Topmenu.php +++ b/app/code/Magento/Theme/Block/Html/Topmenu.php @@ -27,8 +27,15 @@ namespace Magento\Theme\Block\Html; /** * Html page top menu block */ -class Topmenu extends \Magento\View\Element\Template +class Topmenu extends \Magento\View\Element\Template implements \Magento\View\Block\IdentityInterface { + /** + * Cache identities + * + * @var array + */ + protected $identities = array(); + /** * Top menu data tree * @@ -58,6 +65,7 @@ class Topmenu extends \Magento\View\Element\Template { $this->_eventManager->dispatch('page_block_html_topmenu_gethtml_before', array( 'menu' => $this->_menu, + 'block' => $this )); $this->_menu->setOutermostClass($outermostClass); @@ -301,4 +309,24 @@ class Topmenu extends \Magento\View\Element\Template return $classes; } + + /** + * Add identity + * + * @param $identity + */ + public function addIdentity($identity) + { + $this->identities[] = $identity; + } + + /** + * Get identities + * + * @return array + */ + public function getIdentities() + { + return $this->identities; + } } diff --git a/app/code/Magento/Theme/view/frontend/layout/default.xml b/app/code/Magento/Theme/view/frontend/layout/default.xml index 06ecd04d7f1..777e47d64d5 100644 --- a/app/code/Magento/Theme/view/frontend/layout/default.xml +++ b/app/code/Magento/Theme/view/frontend/layout/default.xml @@ -43,7 +43,7 @@ </container> </container> <container name="page_top" as="page_top" label="After Page Header"> - <block class="Magento\Theme\Block\Html\Topmenu" name="catalog.topnav" template="html/topmenu.phtml"/> + <block class="Magento\Theme\Block\Html\Topmenu" name="catalog.topnav" template="html/topmenu.phtml" ttl="3600"/> <container name="top.container" as="topContainer" label="After Page Header Top" htmlTag="div" htmlClass="top-container"/> <block class="Magento\Theme\Block\Html\Breadcrumbs" name="breadcrumbs" as="breadcrumbs"/> </container> diff --git a/app/code/Magento/Backend/Block/System/Shipping/Ups.php b/app/code/Magento/Ups/Block/Backend/System/CarrierConfig.php similarity index 71% rename from app/code/Magento/Backend/Block/System/Shipping/Ups.php rename to app/code/Magento/Ups/Block/Backend/System/CarrierConfig.php index 12a4a916961..bc15a050cf1 100644 --- a/app/code/Magento/Backend/Block/System/Shipping/Ups.php +++ b/app/code/Magento/Ups/Block/Backend/System/CarrierConfig.php @@ -18,23 +18,28 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Backend * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Ups\Block\Backend\System; + +use Magento\Backend\Block\Template; +use Magento\Backend\Block\Template\Context as TemplateContext; +use Magento\Ups\Helper\Config as ConfigHelper; +use Magento\Core\Model\Website; + /** - * Adminhtml shipping UPS content block + * Backend shipping UPS content block */ -namespace Magento\Backend\Block\System\Shipping; - -class Ups extends \Magento\Backend\Block\Template +class CarrierConfig extends Template { /** - * @var \Magento\Usa\Model\Shipping\Carrier\Ups + * Shipping carrier config + * + * @var \Magento\Ups\Helper\Config */ - protected $_shippingModel; + protected $carrierConfig; /** * @var \Magento\Core\Model\Website @@ -43,17 +48,17 @@ class Ups extends \Magento\Backend\Block\Template /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Usa\Model\Shipping\Carrier\Ups $shippingModel + * @param \Magento\Ups\Helper\Config $carrierConfig * @param \Magento\Core\Model\Website $websiteModel * @param array $data */ public function __construct( - \Magento\Backend\Block\Template\Context $context, - \Magento\Usa\Model\Shipping\Carrier\Ups $shippingModel, - \Magento\Core\Model\Website $websiteModel, + TemplateContext $context, + ConfigHelper $carrierConfig, + Website $websiteModel, array $data = array() ) { - $this->_shippingModel = $shippingModel; + $this->carrierConfig = $carrierConfig; $this->_websiteModel = $websiteModel; parent::__construct($context, $data); } @@ -61,11 +66,11 @@ class Ups extends \Magento\Backend\Block\Template /** * Get shipping model * - * @return \Magento\Usa\Model\Shipping\Carrier\Ups + * @return \Magento\Ups\Helper\Config */ - public function getShippingModel() + public function getCarrierConfig() { - return $this->_shippingModel; + return $this->carrierConfig; } /** diff --git a/app/code/Magento/Ups/Helper/Config.php b/app/code/Magento/Ups/Helper/Config.php new file mode 100644 index 00000000000..30ebaec996c --- /dev/null +++ b/app/code/Magento/Ups/Helper/Config.php @@ -0,0 +1,337 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Ups\Helper; + +/** + * Configuration data of carrier + */ +class Config +{ + /** + * Get configuration data of carrier + * + * @param string $type + * @param string $code + * @return array|string|false + */ + public function getCode($type, $code = '') + { + $codes = $this->getCodes(); + if (!isset($codes[$type])) { + return false; + } elseif ('' === $code) { + return $codes[$type]; + } + + if (!isset($codes[$type][$code])) { + return false; + } else { + return $codes[$type][$code]; + } + } + + /** + * Get configuration data of carrier + * + * @return array + */ + protected function getCodes() + { + return [ + 'action' => [ + 'single' => '3', + 'all' => '4', + ], + + 'originShipment' => [ + // United States Domestic Shipments + 'United States Domestic Shipments' => [ + '01' => __('UPS Next Day Air'), + '02' => __('UPS Second Day Air'), + '03' => __('UPS Ground'), + '07' => __('UPS Worldwide Express'), + '08' => __('UPS Worldwide Expedited'), + '11' => __('UPS Standard'), + '12' => __('UPS Three-Day Select'), + '13' => __('UPS Next Day Air Saver'), + '14' => __('UPS Next Day Air Early A.M.'), + '54' => __('UPS Worldwide Express Plus'), + '59' => __('UPS Second Day Air A.M.'), + '65' => __('UPS Saver'), + ], + // Shipments Originating in United States + 'Shipments Originating in United States' => [ + '01' => __('UPS Next Day Air'), + '02' => __('UPS Second Day Air'), + '03' => __('UPS Ground'), + '07' => __('UPS Worldwide Express'), + '08' => __('UPS Worldwide Expedited'), + '11' => __('UPS Standard'), + '12' => __('UPS Three-Day Select'), + '14' => __('UPS Next Day Air Early A.M.'), + '54' => __('UPS Worldwide Express Plus'), + '59' => __('UPS Second Day Air A.M.'), + '65' => __('UPS Worldwide Saver'), + ], + // Shipments Originating in Canada + 'Shipments Originating in Canada' => [ + '01' => __('UPS Express'), + '02' => __('UPS Expedited'), + '07' => __('UPS Worldwide Express'), + '08' => __('UPS Worldwide Expedited'), + '11' => __('UPS Standard'), + '12' => __('UPS Three-Day Select'), + '14' => __('UPS Express Early A.M.'), + '65' => __('UPS Saver'), + ], + // Shipments Originating in the European Union + 'Shipments Originating in the European Union' => [ + '07' => __('UPS Express'), + '08' => __('UPS Expedited'), + '11' => __('UPS Standard'), + '54' => __('UPS Worldwide Express PlusSM'), + '65' => __('UPS Saver'), + ], + // Polish Domestic Shipments + 'Polish Domestic Shipments' => [ + '07' => __('UPS Express'), + '08' => __('UPS Expedited'), + '11' => __('UPS Standard'), + '54' => __('UPS Worldwide Express Plus'), + '65' => __('UPS Saver'), + '82' => __('UPS Today Standard'), + '83' => __('UPS Today Dedicated Courrier'), + '84' => __('UPS Today Intercity'), + '85' => __('UPS Today Express'), + '86' => __('UPS Today Express Saver'), + ], + // Puerto Rico Origin + 'Puerto Rico Origin' => [ + '01' => __('UPS Next Day Air'), + '02' => __('UPS Second Day Air'), + '03' => __('UPS Ground'), + '07' => __('UPS Worldwide Express'), + '08' => __('UPS Worldwide Expedited'), + '14' => __('UPS Next Day Air Early A.M.'), + '54' => __('UPS Worldwide Express Plus'), + '65' => __('UPS Saver'), + ], + // Shipments Originating in Mexico + 'Shipments Originating in Mexico' => [ + '07' => __('UPS Express'), + '08' => __('UPS Expedited'), + '54' => __('UPS Express Plus'), + '65' => __('UPS Saver'), + ], + // Shipments Originating in Other Countries + 'Shipments Originating in Other Countries' => [ + '07' => __('UPS Express'), + '08' => __('UPS Worldwide Expedited'), + '11' => __('UPS Standard'), + '54' => __('UPS Worldwide Express Plus'), + '65' => __('UPS Saver') + ], + ], + + 'method' => [ + '1DM' => __('Next Day Air Early AM'), + '1DML' => __('Next Day Air Early AM Letter'), + '1DA' => __('Next Day Air'), + '1DAL' => __('Next Day Air Letter'), + '1DAPI' => __('Next Day Air Intra (Puerto Rico)'), + '1DP' => __('Next Day Air Saver'), + '1DPL' => __('Next Day Air Saver Letter'), + '2DM' => __('2nd Day Air AM'), + '2DML' => __('2nd Day Air AM Letter'), + '2DA' => __('2nd Day Air'), + '2DAL' => __('2nd Day Air Letter'), + '3DS' => __('3 Day Select'), + 'GND' => __('Ground'), + 'GNDCOM' => __('Ground Commercial'), + 'GNDRES' => __('Ground Residential'), + 'STD' => __('Canada Standard'), + 'XPR' => __('Worldwide Express'), + 'WXS' => __('Worldwide Express Saver'), + 'XPRL' => __('Worldwide Express Letter'), + 'XDM' => __('Worldwide Express Plus'), + 'XDML' => __('Worldwide Express Plus Letter'), + 'XPD' => __('Worldwide Expedited'), + ], + + 'pickup' => [ + 'RDP' => ["label" => 'Regular Daily Pickup', "code" => "01"], + 'OCA' => ["label" => 'On Call Air', "code" => "07"], + 'OTP' => ["label" => 'One Time Pickup', "code" => "06"], + 'LC' => ["label" => 'Letter Center', "code" => "19"], + 'CC' => ["label" => 'Customer Counter', "code" => "03"], + ], + + 'container' => [ + 'CP' => '00', // Customer Packaging + 'ULE' => '01', // UPS Letter Envelope + 'CSP' => '02', // Customer Supplied Package + 'UT' => '03', // UPS Tube + 'PAK' => '04', // PAK + 'UEB' => '21', // UPS Express Box + 'UW25' => '24', // UPS Worldwide 25 kilo + 'UW10' => '25', // UPS Worldwide 10 kilo + 'PLT' => '30', // Pallet + 'SEB' => '2a', // Small Express Box + 'MEB' => '2b', // Medium Express Box + 'LEB' => '2c', // Large Express Box + ], + + 'container_description' => [ + 'CP' => __('Customer Packaging'), + 'ULE' => __('UPS Letter Envelope'), + 'CSP' => __('Customer Supplied Package'), + 'UT' => __('UPS Tube'), + 'PAK' => __('PAK'), + 'UEB' => __('UPS Express Box'), + 'UW25' => __('UPS Worldwide 25 kilo'), + 'UW10' => __('UPS Worldwide 10 kilo'), + 'PLT' => __('Pallet'), + 'SEB' => __('Small Express Box'), + 'MEB' => __('Medium Express Box'), + 'LEB' => __('Large Express Box'), + ], + + 'dest_type' => [ + 'RES' => '01', // Residential + 'COM' => '02', // Commercial + ], + + 'dest_type_description' => [ + 'RES' => __('Residential'), + 'COM' => __('Commercial'), + ], + + 'unit_of_measure' => [ + 'LBS' => __('Pounds'), + 'KGS' => __('Kilograms'), + ], + + 'containers_filter' => [ + [ + 'containers' => ['00'], // Customer Packaging + 'filters' => [ + 'within_us' => [ + 'method' => [ + '01', // Next Day Air + '13', // Next Day Air Saver + '12', // 3 Day Select + '59', // 2nd Day Air AM + '03', // Ground + '14', // Next Day Air Early AM + '02', // 2nd Day Air + ], + ], + 'from_us' => [ + 'method' => [ + '07', // Worldwide Express + '54', // Worldwide Express Plus + '08', // Worldwide Expedited + '65', // Worldwide Saver + '11', // Standard + ], + ], + ], + ], + [ + // Small Express Box, Medium Express Box, Large Express Box, UPS Tube + 'containers' => ['2a', '2b', '2c', '03'], + 'filters' => [ + 'within_us' => [ + 'method' => [ + '01', // Next Day Air + '13', // Next Day Air Saver + '14', // Next Day Air Early AM + '02', // 2nd Day Air + '59', // 2nd Day Air AM + '13', // Next Day Air Saver + ], + ], + 'from_us' => [ + 'method' => [ + '07', // Worldwide Express + '54', // Worldwide Express Plus + '08', // Worldwide Expedited + '65', // Worldwide Saver + ], + ], + ], + ], + [ + 'containers' => ['24', '25'], // UPS Worldwide 25 kilo, UPS Worldwide 10 kilo + 'filters' => [ + 'within_us' => [ + 'method' => [], + ], + 'from_us' => [ + 'method' => [ + '07', // Worldwide Express + '54', // Worldwide Express Plus + '65', // Worldwide Saver + ], + ], + ], + ], + [ + 'containers' => ['01', '04'], // UPS Letter, UPS PAK + 'filters' => [ + 'within_us' => [ + 'method' => [ + '01', // Next Day Air + '14', // Next Day Air Early AM + '02', // 2nd Day Air + '59', // 2nd Day Air AM + '13', // Next Day Air Saver + ], + ], + 'from_us' => [ + 'method' => [ + '07', // Worldwide Express + '54', // Worldwide Express Plus + '65', // Worldwide Saver + ], + ], + ], + ], + [ + 'containers' => ['04'], // UPS PAK + 'filters' => [ + 'within_us' => [ + 'method' => [], + ], + 'from_us' => [ + 'method' => [ + '08', // Worldwide Expedited + ], + ], + ], + ], + ], + ]; + } +} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups.php b/app/code/Magento/Ups/Model/Carrier.php similarity index 80% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Ups.php rename to app/code/Magento/Ups/Model/Carrier.php index 45b81ec95ff..038b024af34 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups.php +++ b/app/code/Magento/Ups/Model/Carrier.php @@ -18,26 +18,23 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier; + +namespace Magento\Ups\Model; use Magento\Sales\Model\Quote\Address\RateRequest; +use Magento\Shipping\Model\Carrier\AbstractCarrierOnline; use Magento\Shipping\Model\Rate\Result; -use Magento\Usa\Model\Shipping\Carrier\AbstractCarrier; -use Magento\Usa\Model\Simplexml\Element; +use Magento\Shipping\Model\Simplexml\Element; +use Magento\Shipping\Model\Carrier\CarrierInterface; /** * UPS shipping implementation */ -class Ups - extends AbstractCarrier - implements \Magento\Shipping\Model\Carrier\CarrierInterface +class Carrier extends AbstractCarrierOnline implements CarrierInterface { - /** * Code of the carrier * @@ -128,20 +125,25 @@ class Ups protected $_customizableContainerTypes = array('CP', 'CSP'); /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\FormatInterface */ - protected $_locale; + protected $_localeFormat; /** * @var \Magento\Logger */ protected $_logger; + /** + * @var + */ + protected $configHelper; + /** * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory * @param \Magento\Logger\AdapterFactory $logAdapterFactory - * @param \Magento\Usa\Model\Simplexml\ElementFactory $xmlElFactory + * @param \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory * @param \Magento\Shipping\Model\Rate\ResultFactory $rateFactory * @param \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory * @param \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory @@ -152,7 +154,8 @@ class Ups * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Directory\Helper\Data $directoryData * @param \Magento\Logger $logger - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Locale\FormatInterface $localeFormat + * @param \Magento\Ups\Helper\Config $configHelper * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -161,7 +164,7 @@ class Ups \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Magento\Logger\AdapterFactory $logAdapterFactory, - \Magento\Usa\Model\Simplexml\ElementFactory $xmlElFactory, + \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateFactory, \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory, @@ -172,11 +175,13 @@ class Ups \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Directory\Helper\Data $directoryData, \Magento\Logger $logger, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Locale\FormatInterface $localeFormat, + \Magento\Ups\Helper\Config $configHelper, array $data = array() ) { $this->_logger = $logger; - $this->_locale = $locale; + $this->_localeFormat = $localeFormat; + $this->configHelper = $configHelper; parent::__construct( $coreStoreConfig, $rateErrorFactory, @@ -229,10 +234,10 @@ class Ups $rowRequest = new \Magento\Object(); if ($request->getLimitMethod()) { - $rowRequest->setAction($this->getCode('action', 'single')); + $rowRequest->setAction($this->configHelper->getCode('action', 'single')); $rowRequest->setProduct($request->getLimitMethod()); } else { - $rowRequest->setAction($this->getCode('action', 'all')); + $rowRequest->setAction($this->configHelper->getCode('action', 'all')); $rowRequest->setProduct('GND' . $this->getConfigData('dest_type')); } @@ -241,21 +246,21 @@ class Ups } else { $pickup = $this->getConfigData('pickup'); } - $rowRequest->setPickup($this->getCode('pickup', $pickup)); + $rowRequest->setPickup($this->configHelper->getCode('pickup', $pickup)); if ($request->getUpsContainer()) { $container = $request->getUpsContainer(); } else { $container = $this->getConfigData('container'); } - $rowRequest->setContainer($this->getCode('container', $container)); + $rowRequest->setContainer($this->configHelper->getCode('container', $container)); if ($request->getUpsDestType()) { $destType = $request->getUpsDestType(); } else { $destType = $this->getConfigData('dest_type'); } - $rowRequest->setDestType($this->getCode('dest_type', $destType)); + $rowRequest->setDestType($this->configHelper->getCode('dest_type', $destType)); if ($request->getOrigCountry()) { $origCountry = $request->getOrigCountry(); @@ -419,7 +424,7 @@ class Ups $weight = $this->getTotalNumOfBoxes($r->getFreeMethodWeight()); $weight = $this->_getCorrectWeight($weight); $r->setWeight($weight); - $r->setAction($this->getCode('action', 'single')); + $r->setAction($this->configHelper->getCode('action', 'single')); $r->setProduct($freeMethod); } @@ -431,7 +436,7 @@ class Ups protected function _getCgiQuotes() { $rowRequest = $this->_rawRequest; - if (AbstractCarrier::USA_COUNTRY_ID == $rowRequest->getDestCountry()) { + if (self::USA_COUNTRY_ID == $rowRequest->getDestCountry()) { $destPostal = substr($rowRequest->getDestPostal(), 0, 5); } else { $destPostal = $rowRequest->getDestPostal(); @@ -493,7 +498,7 @@ class Ups if ($origin === null) { $origin = $this->getConfigData('origin_shipment'); } - $arr = $this->getCode('originShipment', $origin); + $arr = $this->configHelper->getCode('originShipment', $origin); if (isset($arr[$code])) { return $arr[$code]; } else { @@ -520,7 +525,7 @@ class Ups switch (substr($row[0], -1)) { case 3: case 4: if (in_array($row[1], $allowedMethods)) { - $responsePrice = $this->_locale->getNumber($row[8]); + $responsePrice = $this->_localeFormat->getNumber($row[8]); $costArr[$row[1]] = $responsePrice; $priceArr[$row[1]] = $this->getMethodPrice($responsePrice, $row[1]); } @@ -532,7 +537,7 @@ class Ups break; case 6: if (in_array($row[3], $allowedMethods)) { - $responsePrice = $this->_locale->getNumber($row[10]); + $responsePrice = $this->_localeFormat->getNumber($row[10]); $costArr[$row[3]] = $responsePrice; $priceArr[$row[3]] = $this->getMethodPrice($responsePrice, $row[3]); } @@ -558,7 +563,7 @@ class Ups $rate->setCarrier('ups'); $rate->setCarrierTitle($this->getConfigData('title')); $rate->setMethod($method); - $methodArray = $this->getCode('method', $method); + $methodArray = $this->configHelper->getCode('method', $method); $rate->setMethodTitle($methodArray); $rate->setCost($costArr[$method]); $rate->setPrice($price); @@ -569,302 +574,6 @@ class Ups return $result; } - /** - * Get configuration data of carrier - * - * @param string $type - * @param string $code - * @return array|false - */ - public function getCode($type, $code = '') - { - $codes = array( - 'action' => array( - 'single' => '3', - 'all' => '4', - ), - 'originShipment' => array( - // United States Domestic Shipments - 'United States Domestic Shipments' => array( - '01' => __('UPS Next Day Air'), - '02' => __('UPS Second Day Air'), - '03' => __('UPS Ground'), - '07' => __('UPS Worldwide Express'), - '08' => __('UPS Worldwide Expedited'), - '11' => __('UPS Standard'), - '12' => __('UPS Three-Day Select'), - '13' => __('UPS Next Day Air Saver'), - '14' => __('UPS Next Day Air Early A.M.'), - '54' => __('UPS Worldwide Express Plus'), - '59' => __('UPS Second Day Air A.M.'), - '65' => __('UPS Saver'), - ), - // Shipments Originating in United States - 'Shipments Originating in United States' => array( - '01' => __('UPS Next Day Air'), - '02' => __('UPS Second Day Air'), - '03' => __('UPS Ground'), - '07' => __('UPS Worldwide Express'), - '08' => __('UPS Worldwide Expedited'), - '11' => __('UPS Standard'), - '12' => __('UPS Three-Day Select'), - '14' => __('UPS Next Day Air Early A.M.'), - '54' => __('UPS Worldwide Express Plus'), - '59' => __('UPS Second Day Air A.M.'), - '65' => __('UPS Worldwide Saver'), - ), - // Shipments Originating in Canada - 'Shipments Originating in Canada' => array( - '01' => __('UPS Express'), - '02' => __('UPS Expedited'), - '07' => __('UPS Worldwide Express'), - '08' => __('UPS Worldwide Expedited'), - '11' => __('UPS Standard'), - '12' => __('UPS Three-Day Select'), - '14' => __('UPS Express Early A.M.'), - '65' => __('UPS Saver'), - ), - // Shipments Originating in the European Union - 'Shipments Originating in the European Union' => array( - '07' => __('UPS Express'), - '08' => __('UPS Expedited'), - '11' => __('UPS Standard'), - '54' => __('UPS Worldwide Express PlusSM'), - '65' => __('UPS Saver'), - ), - // Polish Domestic Shipments - 'Polish Domestic Shipments' => array( - '07' => __('UPS Express'), - '08' => __('UPS Expedited'), - '11' => __('UPS Standard'), - '54' => __('UPS Worldwide Express Plus'), - '65' => __('UPS Saver'), - '82' => __('UPS Today Standard'), - '83' => __('UPS Today Dedicated Courrier'), - '84' => __('UPS Today Intercity'), - '85' => __('UPS Today Express'), - '86' => __('UPS Today Express Saver'), - ), - // Puerto Rico Origin - 'Puerto Rico Origin' => array( - '01' => __('UPS Next Day Air'), - '02' => __('UPS Second Day Air'), - '03' => __('UPS Ground'), - '07' => __('UPS Worldwide Express'), - '08' => __('UPS Worldwide Expedited'), - '14' => __('UPS Next Day Air Early A.M.'), - '54' => __('UPS Worldwide Express Plus'), - '65' => __('UPS Saver'), - ), - // Shipments Originating in Mexico - 'Shipments Originating in Mexico' => array( - '07' => __('UPS Express'), - '08' => __('UPS Expedited'), - '54' => __('UPS Express Plus'), - '65' => __('UPS Saver'), - ), - // Shipments Originating in Other Countries - 'Shipments Originating in Other Countries' => array( - '07' => __('UPS Express'), - '08' => __('UPS Worldwide Expedited'), - '11' => __('UPS Standard'), - '54' => __('UPS Worldwide Express Plus'), - '65' => __('UPS Saver') - ) - ), - - 'method'=>array( - '1DM' => __('Next Day Air Early AM'), - '1DML' => __('Next Day Air Early AM Letter'), - '1DA' => __('Next Day Air'), - '1DAL' => __('Next Day Air Letter'), - '1DAPI' => __('Next Day Air Intra (Puerto Rico)'), - '1DP' => __('Next Day Air Saver'), - '1DPL' => __('Next Day Air Saver Letter'), - '2DM' => __('2nd Day Air AM'), - '2DML' => __('2nd Day Air AM Letter'), - '2DA' => __('2nd Day Air'), - '2DAL' => __('2nd Day Air Letter'), - '3DS' => __('3 Day Select'), - 'GND' => __('Ground'), - 'GNDCOM' => __('Ground Commercial'), - 'GNDRES' => __('Ground Residential'), - 'STD' => __('Canada Standard'), - 'XPR' => __('Worldwide Express'), - 'WXS' => __('Worldwide Express Saver'), - 'XPRL' => __('Worldwide Express Letter'), - 'XDM' => __('Worldwide Express Plus'), - 'XDML' => __('Worldwide Express Plus Letter'), - 'XPD' => __('Worldwide Expedited'), - ), - - 'pickup'=>array( - 'RDP' => array("label"=>'Regular Daily Pickup',"code"=>"01"), - 'OCA' => array("label"=>'On Call Air',"code"=>"07"), - 'OTP' => array("label"=>'One Time Pickup',"code"=>"06"), - 'LC' => array("label"=>'Letter Center',"code"=>"19"), - 'CC' => array("label"=>'Customer Counter',"code"=>"03"), - ), - - 'container'=>array( - 'CP' => '00', // Customer Packaging - 'ULE' => '01', // UPS Letter Envelope - 'CSP' => '02', // Customer Supplied Package - 'UT' => '03', // UPS Tube - 'PAK' => '04', // PAK - 'UEB' => '21', // UPS Express Box - 'UW25' => '24', // UPS Worldwide 25 kilo - 'UW10' => '25', // UPS Worldwide 10 kilo - 'PLT' => '30', // Pallet - 'SEB' => '2a', // Small Express Box - 'MEB' => '2b', // Medium Express Box - 'LEB' => '2c', // Large Express Box - ), - - 'container_description'=>array( - 'CP' => __('Customer Packaging'), - 'ULE' => __('UPS Letter Envelope'), - 'CSP' => __('Customer Supplied Package'), - 'UT' => __('UPS Tube'), - 'PAK' => __('PAK'), - 'UEB' => __('UPS Express Box'), - 'UW25' => __('UPS Worldwide 25 kilo'), - 'UW10' => __('UPS Worldwide 10 kilo'), - 'PLT' => __('Pallet'), - 'SEB' => __('Small Express Box'), - 'MEB' => __('Medium Express Box'), - 'LEB' => __('Large Express Box'), - ), - - 'dest_type'=>array( - 'RES' => '01', // Residential - 'COM' => '02', // Commercial - ), - - 'dest_type_description'=>array( - 'RES' => __('Residential'), - 'COM' => __('Commercial'), - ), - - 'unit_of_measure'=>array( - 'LBS' => __('Pounds'), - 'KGS' => __('Kilograms'), - ), - 'containers_filter' => array( - array( - 'containers' => array('00'), // Customer Packaging - 'filters' => array( - 'within_us' => array( - 'method' => array( - '01', // Next Day Air - '13', // Next Day Air Saver - '12', // 3 Day Select - '59', // 2nd Day Air AM - '03', // Ground - '14', // Next Day Air Early AM - '02', // 2nd Day Air - ) - ), - 'from_us' => array( - 'method' => array( - '07', // Worldwide Express - '54', // Worldwide Express Plus - '08', // Worldwide Expedited - '65', // Worldwide Saver - '11', // Standard - ) - ) - ) - ), - array( - // Small Express Box, Medium Express Box, Large Express Box, UPS Tube - 'containers' => array('2a', '2b', '2c', '03'), - 'filters' => array( - 'within_us' => array( - 'method' => array( - '01', // Next Day Air - '13', // Next Day Air Saver - '14', // Next Day Air Early AM - '02', // 2nd Day Air - '59', // 2nd Day Air AM - '13', // Next Day Air Saver - ) - ), - 'from_us' => array( - 'method' => array( - '07', // Worldwide Express - '54', // Worldwide Express Plus - '08', // Worldwide Expedited - '65', // Worldwide Saver - ) - ) - ) - ), - array( - 'containers' => array('24', '25'), // UPS Worldwide 25 kilo, UPS Worldwide 10 kilo - 'filters' => array( - 'within_us' => array( - 'method' => array() - ), - 'from_us' => array( - 'method' => array( - '07', // Worldwide Express - '54', // Worldwide Express Plus - '65', // Worldwide Saver - ) - ) - ) - ), - array( - 'containers' => array('01', '04'), // UPS Letter, UPS PAK - 'filters' => array( - 'within_us' => array( - 'method' => array( - '01', // Next Day Air - '14', // Next Day Air Early AM - '02', // 2nd Day Air - '59', // 2nd Day Air AM - '13', // Next Day Air Saver - ) - ), - 'from_us' => array( - 'method' => array( - '07', // Worldwide Express - '54', // Worldwide Express Plus - '65', // Worldwide Saver - ) - ) - ) - ), - array( - 'containers' => array('04'), // UPS PAK - 'filters' => array( - 'within_us' => array( - 'method' => array() - ), - 'from_us' => array( - 'method' => array( - '08', // Worldwide Expedited - ) - ) - ) - ), - ) - ); - - if (!isset($codes[$type])) { - return false; - } elseif ('' === $code) { - return $codes[$type]; - } - - if (!isset($codes[$type][$code])) { - return false; - } else { - return $codes[$type][$code]; - } - } - /** * Get xml rates * @@ -878,7 +587,7 @@ class Ups $xmlRequest=$this->_xmlAccessRequest; $rowRequest = $this->_rawRequest; - if (AbstractCarrier::USA_COUNTRY_ID == $rowRequest->getDestCountry()) { + if (self::USA_COUNTRY_ID == $rowRequest->getDestCountry()) { $destPostal = substr($rowRequest->getDestPostal(), 0, 5); } else { $destPostal = $rowRequest->getDestPostal(); @@ -1421,7 +1130,7 @@ XMLAuth; $arr = array(); $isByCode = $this->getConfigData('type') == 'UPS_XML'; foreach ($allowed as $code) { - $arr[$code] = $isByCode ? $this->getShipmentByCode($code) : $this->getCode('method', $code); + $arr[$code] = $isByCode ? $this->getShipmentByCode($code) : $this->configHelper->getCode('method', $code); } return $arr; } @@ -1609,8 +1318,8 @@ XMLAuth; ->addChild('BillShipper') ->addChild('AccountNumber', $this->getConfigData('shipper_number')); - if ($request->getPackagingType() != $this->getCode('container', 'ULE') - && $request->getShipperAddressCountryCode() == AbstractCarrier::USA_COUNTRY_ID + if ($request->getPackagingType() != $this->configHelper->getCode('container', 'ULE') + && $request->getShipperAddressCountryCode() == self::USA_COUNTRY_ID && ($request->getRecipientAddressCountryCode() == 'CA' //Canada || $request->getRecipientAddressCountryCode() == 'PR') //Puerto Rico ) { @@ -1837,8 +1546,8 @@ XMLAuth; */ public function getContainerTypesAll() { - $codes = $this->getCode('container'); - $descriptions = $this->getCode('container_description'); + $codes = $this->configHelper->getCode('container'); + $descriptions = $this->configHelper->getCode('container_description'); $result = array(); foreach ($codes as $key => &$code) { $result[$code] = $descriptions[$key]; @@ -1854,7 +1563,7 @@ XMLAuth; */ public function getContainerTypesFilter() { - return $this->getCode('containers_filter'); + return $this->configHelper->getCode('containers_filter'); } /** @@ -1897,7 +1606,7 @@ XMLAuth; public function getCustomizableContainerTypes() { $result = array(); - $containerTypes = $this->getCode('container'); + $containerTypes = $this->configHelper->getCode('container'); foreach (parent::getCustomizableContainerTypes() as $containerType) { $result[$containerType] = $containerTypes[$containerType]; } @@ -1917,7 +1626,7 @@ XMLAuth; return null; } - if ($countyDestination == AbstractCarrier::USA_COUNTRY_ID) { + if ($countyDestination == self::USA_COUNTRY_ID) { return self::DELIVERY_CONFIRMATION_PACKAGE; } diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Container.php b/app/code/Magento/Ups/Model/Config/Source/Container.php similarity index 84% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Container.php rename to app/code/Magento/Ups/Model/Config/Source/Container.php index e19cf286e24..f980d754dad 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Container.php +++ b/app/code/Magento/Ups/Model/Config/Source/Container.php @@ -18,16 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Ups\Model\Config\Source; -namespace Magento\Usa\Model\Shipping\Carrier\Ups\Source; - -class Container extends \Magento\Usa\Model\Shipping\Carrier\Ups\Source\Generic +/** + * Class Container + */ +class Container extends \Magento\Ups\Model\Config\Source\Generic { /** * Carrier code diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/DestType.php b/app/code/Magento/Ups/Model/Config/Source/DestType.php similarity index 84% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/DestType.php rename to app/code/Magento/Ups/Model/Config/Source/DestType.php index 01d13239f70..56810fc54d6 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/DestType.php +++ b/app/code/Magento/Ups/Model/Config/Source/DestType.php @@ -18,16 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Ups\Model\Config\Source; -namespace Magento\Usa\Model\Shipping\Carrier\Ups\Source; - -class DestType extends \Magento\Usa\Model\Shipping\Carrier\Ups\Source\Generic +/** + * Class DestType + */ +class DestType extends \Magento\Ups\Model\Config\Source\Generic { /** * Carrier code diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Freemethod.php b/app/code/Magento/Ups/Model/Config/Source/Freemethod.php similarity index 85% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Freemethod.php rename to app/code/Magento/Ups/Model/Config/Source/Freemethod.php index 3bc1313d255..e1344da765c 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Freemethod.php +++ b/app/code/Magento/Ups/Model/Config/Source/Freemethod.php @@ -18,16 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Ups\Model\Config\Source; -namespace Magento\Usa\Model\Shipping\Carrier\Ups\Source; - -class Freemethod extends \Magento\Usa\Model\Shipping\Carrier\Ups\Source\Method +/** + * Class Freemethod + */ +class Freemethod extends \Magento\Ups\Model\Config\Source\Method { /** * {@inheritdoc} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Generic.php b/app/code/Magento/Ups/Model/Config/Source/Generic.php similarity index 73% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Generic.php rename to app/code/Magento/Ups/Model/Config/Source/Generic.php index cac9d09a8c4..179f8aa319b 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Generic.php +++ b/app/code/Magento/Ups/Model/Config/Source/Generic.php @@ -21,14 +21,20 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier\Ups\Source; -class Generic implements \Magento\Option\ArrayInterface +namespace Magento\Ups\Model\Config\Source; + +use Magento\Shipping\Model\Carrier\Source\GenericInterface; + +/** + * Generic source model + */ +class Generic implements GenericInterface { /** - * @var \Magento\Usa\Model\Shipping\Carrier\Ups + * @var \Magento\Ups\Helper\Config */ - protected $_shippingUps; + protected $carrierConfig; /** * Carrier code @@ -38,11 +44,11 @@ class Generic implements \Magento\Option\ArrayInterface protected $_code = ''; /** - * @param \Magento\Usa\Model\Shipping\Carrier\Ups $shippingUps + * @param \Magento\Ups\Helper\Config $carrierConfig */ - public function __construct(\Magento\Usa\Model\Shipping\Carrier\Ups $shippingUps) + public function __construct(\Magento\Ups\Helper\Config $carrierConfig) { - $this->_shippingUps = $shippingUps; + $this->carrierConfig = $carrierConfig; } /** @@ -52,7 +58,7 @@ class Generic implements \Magento\Option\ArrayInterface */ public function toOptionArray() { - $configData = $this->_shippingUps->getCode($this->_code); + $configData = $this->carrierConfig->getCode($this->_code); $arr = array(); foreach ($configData as $code => $title) { $arr[] = array('value' => $code, 'label' => __($title)); diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Method.php b/app/code/Magento/Ups/Model/Config/Source/Method.php similarity index 84% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Method.php rename to app/code/Magento/Ups/Model/Config/Source/Method.php index efceb1aeb02..2cef9d38600 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Method.php +++ b/app/code/Magento/Ups/Model/Config/Source/Method.php @@ -18,16 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Ups\Model\Config\Source; -namespace Magento\Usa\Model\Shipping\Carrier\Ups\Source; - -class Method extends \Magento\Usa\Model\Shipping\Carrier\Ups\Source\Generic +/** + * Class Method + */ +class Method extends \Magento\Ups\Model\Config\Source\Generic { /** * Carrier code diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/OriginShipment.php b/app/code/Magento/Ups/Model/Config/Source/OriginShipment.php similarity index 78% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/OriginShipment.php rename to app/code/Magento/Ups/Model/Config/Source/OriginShipment.php index 6a80ec3f365..435e184a5f4 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/OriginShipment.php +++ b/app/code/Magento/Ups/Model/Config/Source/OriginShipment.php @@ -18,21 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Ups\Model\Config\Source; + /** - * - * Usa Ups type action Dropdown source - * - * @author Magento Core Team <core@magentocommerce.com> + * Class OriginShipment */ -namespace Magento\Usa\Model\Shipping\Carrier\Ups\Source; - -class OriginShipment extends \Magento\Usa\Model\Shipping\Carrier\Ups\Source\Generic +class OriginShipment extends \Magento\Ups\Model\Config\Source\Generic { /** * Carrier code @@ -46,7 +41,7 @@ class OriginShipment extends \Magento\Usa\Model\Shipping\Carrier\Ups\Source\Gene */ public function toOptionArray() { - $orShipArr = $this->_shippingUps->getCode($this->_code); + $orShipArr = $this->carrierConfig->getCode($this->_code); $returnArr = array(); foreach ($orShipArr as $key => $val) { $returnArr[] = array('value' => $key,'label' => $key); diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Pickup.php b/app/code/Magento/Ups/Model/Config/Source/Pickup.php similarity index 83% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Pickup.php rename to app/code/Magento/Ups/Model/Config/Source/Pickup.php index 9236170dcac..62585d3c09d 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Pickup.php +++ b/app/code/Magento/Ups/Model/Config/Source/Pickup.php @@ -18,16 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Ups\Model\Config\Source; -namespace Magento\Usa\Model\Shipping\Carrier\Ups\Source; - -class Pickup extends \Magento\Usa\Model\Shipping\Carrier\Ups\Source\Generic +/** + * Class Pickup + */ +class Pickup extends \Magento\Ups\Model\Config\Source\Generic { /** * Carrier code @@ -41,7 +41,7 @@ class Pickup extends \Magento\Usa\Model\Shipping\Carrier\Ups\Source\Generic */ public function toOptionArray() { - $ups = $this->_shippingUps->getCode($this->_code); + $ups = $this->carrierConfig->getCode($this->_code); $arr = array(); foreach ($ups as $k => $v) { $arr[] = array('value'=>$k, 'label'=>__($v['label'])); diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Type.php b/app/code/Magento/Ups/Model/Config/Source/Type.php similarity index 76% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Type.php rename to app/code/Magento/Ups/Model/Config/Source/Type.php index 1f74934650a..970d1b61881 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Type.php +++ b/app/code/Magento/Ups/Model/Config/Source/Type.php @@ -18,21 +18,18 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Ups\Model\Config\Source; + +use Magento\Data\OptionSourceInterface; + /** - * - * Usa Ups type action Dropdown source - * - * @author Magento Core Team <core@magentocommerce.com> + * Class Type */ -namespace Magento\Usa\Model\Shipping\Carrier\Ups\Source; - -class Type implements \Magento\Option\ArrayInterface +class Type implements OptionSourceInterface { /** * {@inheritdoc} @@ -41,7 +38,6 @@ class Type implements \Magento\Option\ArrayInterface { return array( array('value' => 'UPS', 'label' => __('United Parcel Service')), - #array('value' => \Magento\Paypal\Model\Api\AbstractApi::PAYMENT_TYPE_ORDER, 'label' => __('Order')), array('value' => 'UPS_XML', 'label' => __('United Parcel Service XML')), ); } diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Unitofmeasure.php b/app/code/Magento/Ups/Model/Config/Source/Unitofmeasure.php similarity index 83% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Unitofmeasure.php rename to app/code/Magento/Ups/Model/Config/Source/Unitofmeasure.php index 10247c0f469..f26f47a0de2 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Unitofmeasure.php +++ b/app/code/Magento/Ups/Model/Config/Source/Unitofmeasure.php @@ -18,16 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Ups\Model\Config\Source; -namespace Magento\Usa\Model\Shipping\Carrier\Ups\Source; - -class Unitofmeasure extends \Magento\Usa\Model\Shipping\Carrier\Ups\Source\Generic +/** + * Class Unitofmeasure + */ +class Unitofmeasure extends \Magento\Ups\Model\Config\Source\Generic { /** * Carrier code @@ -41,7 +41,7 @@ class Unitofmeasure extends \Magento\Usa\Model\Shipping\Carrier\Ups\Source\Gener */ public function toOptionArray() { - $unitArr = $this->_shippingUps->getCode($this->_code); + $unitArr = $this->carrierConfig->getCode($this->_code); $returnArr = array(); foreach ($unitArr as $key => $val) { $returnArr[] = array('value'=>$key,'label'=>$key); diff --git a/app/code/Magento/Ups/etc/adminhtml/system.xml b/app/code/Magento/Ups/etc/adminhtml/system.xml new file mode 100644 index 00000000000..230b56cf246 --- /dev/null +++ b/app/code/Magento/Ups/etc/adminhtml/system.xml @@ -0,0 +1,174 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <system> + <section id="carriers"> + <group id="ups" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>UPS</label> + <field id="access_license_number" translate="label" type="obscure" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Access License Number</label> + <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> + </field> + <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled for Checkout</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="allowed_methods" translate="label" type="multiselect" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Allowed Methods</label> + <source_model>Magento\Ups\Model\Config\Source\Method</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="shipment_requesttype" translate="label" type="select" sortOrder="47" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Packages Request Type</label> + <source_model>Magento\Shipping\Model\Config\Source\Online\Requesttype</source_model> + </field> + <field id="container" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Container</label> + <source_model>Magento\Ups\Model\Config\Source\Container</source_model> + </field> + <field id="free_shipping_enable" translate="label" type="select" sortOrder="210" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Free Shipping Amount Threshold</label> + <source_model>Magento\Backend\Model\Config\Source\Enabledisable</source_model> + </field> + <field id="free_shipping_subtotal" translate="label" type="text" sortOrder="220" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Free Shipping Amount Threshold</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="dest_type" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Destination Type</label> + <source_model>Magento\Ups\Model\Config\Source\DestType</source_model> + </field> + <field id="free_method" translate="label" type="select" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Free Method</label> + <frontend_class>free-method</frontend_class> + <source_model>Magento\Ups\Model\Config\Source\Freemethod</source_model> + </field> + <field id="gateway_url" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Gateway URL</label> + </field> + <field id="gateway_xml_url" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Gateway XML URL</label> + </field> + <field id="handling_type" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Calculate Handling Fee</label> + <source_model>Magento\Shipping\Model\Source\HandlingType</source_model> + </field> + <field id="handling_action" translate="label" type="select" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Handling Applied</label> + <source_model>Magento\Shipping\Model\Source\HandlingAction</source_model> + </field> + <field id="handling_fee" translate="label" type="text" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Handling Fee</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="max_package_weight" translate="label" type="text" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="min_package_weight" translate="label" type="text" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Minimum Package Weight (Please consult your shipping carrier for minimum supported shipping weight)</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="origin_shipment" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Origin of the Shipment</label> + <source_model>Magento\Ups\Model\Config\Source\OriginShipment</source_model> + </field> + <field id="password" translate="label" type="obscure" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Password</label> + <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> + </field> + <field id="pickup" translate="label" type="select" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Pickup Method</label> + <source_model>Magento\Ups\Model\Config\Source\Pickup</source_model> + </field> + <field id="sort_order" translate="label" type="text" sortOrder="1000" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Sort Order</label> + </field> + <field id="title" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Title</label> + </field> + <field id="tracking_xml_url" translate="label" type="text" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Tracking XML URL</label> + </field> + <field id="type" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>UPS Type</label> + <source_model>Magento\Ups\Model\Config\Source\Type</source_model> + </field> + <field id="is_account_live" translate="label" type="select" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Live account</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="unit_of_measure" translate="label comment" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Weight Unit</label> + <source_model>Magento\Ups\Model\Config\Source\Unitofmeasure</source_model> + </field> + <field id="username" translate="label" type="obscure" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>User ID</label> + <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> + </field> + <field id="negotiated_active" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enable Negotiated Rates</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="shipper_number" translate="label comment" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Shipper Number</label> + <comment>Required for negotiated rates; 6-character UPS</comment> + </field> + <field id="sallowspecific" translate="label" type="select" sortOrder="900" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ship to Applicable Countries</label> + <frontend_class>shipping-applicable-country</frontend_class> + <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> + </field> + <field id="specificcountry" translate="label" type="multiselect" sortOrder="910" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ship to Specific Countries</label> + <source_model>Magento\Directory\Model\Config\Source\Country</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="showmethod" translate="label" type="select" sortOrder="920" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Show Method if Not Applicable</label> + <frontend_class>shipping-skip-hide</frontend_class> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="specificerrmsg" translate="label" type="textarea" sortOrder="800" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Displayed Error Message</label> + </field> + <field id="mode_xml" translate="label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Mode</label> + <comment>This enables or disables SSL verification of the Magento server by UPS.</comment> + <source_model>Magento\Shipping\Model\Config\Source\Online\Mode</source_model> + </field> + <field id="debug" translate="label" type="select" sortOrder="920" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Debug</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="active_rma" translate="label" type="select" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled for RMA</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + </group> + </section> + </system> +</config> diff --git a/app/code/Magento/Ups/etc/config.xml b/app/code/Magento/Ups/etc/config.xml new file mode 100644 index 00000000000..87997c1a033 --- /dev/null +++ b/app/code/Magento/Ups/etc/config.xml @@ -0,0 +1,64 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <default> + <carriers> + <ups> + <access_license_number backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> + <active>0</active> + <sallowspecific>0</sallowspecific> + <allowed_methods>1DM,1DML,1DA,1DAL,1DAPI,1DP,1DPL,2DM,2DML,2DA,2DAL,3DS,GND,GNDCOM,GNDRES,STD,XPR,WXS,XPRL,XDM,XDML,XPD,01,02,03,07,08,11,12,14,54,59,65</allowed_methods> + <origin_shipment>Shipments Originating in United States</origin_shipment> + <shipment_requesttype>0</shipment_requesttype> + <container>CP</container> + <cutoff_cost /> + <dest_type>RES</dest_type> + <free_method>GND</free_method> + <gateway_url>http://www.ups.com/using/services/rave/qcostcgi.cgi</gateway_url> + <gateway_xml_url>https://onlinetools.ups.com/ups.app/xml/Rate</gateway_xml_url> + <handling>0</handling> + <model>Magento\Ups\Model\Carrier</model> + <pickup>CC</pickup> + <title>United Parcel Service</title> + <tracking_xml_url>https://www.ups.com/ups.app/xml/Track</tracking_xml_url> + <unit_of_measure>LBS</unit_of_measure> + <username backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> + <password backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> + <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg> + <min_package_weight>0.1</min_package_weight> + <max_package_weight>150</max_package_weight> + <handling_type>F</handling_type> + <handling_action>O</handling_action> + <negotiated_active>0</negotiated_active> + <mode_xml>1</mode_xml> + <type>UPS</type> + <is_account_live>0</is_account_live> + <active_rma>0</active_rma> + <is_online>1</is_online> + </ups> + </carriers> + </default> +</config> diff --git a/app/code/Magento/Ups/etc/module.xml b/app/code/Magento/Ups/etc/module.xml new file mode 100644 index 00000000000..1a7d751d2b3 --- /dev/null +++ b/app/code/Magento/Ups/etc/module.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <module name="Magento_Ups" version="2.0.0.0" active="true"> + <depends> + <module name="Magento_Core"/> + <module name="Magento_Backend"/> + <module name="Magento_Sales"/> + <module name="Magento_Shipping"/> + <module name="Magento_Directory"/> + </depends> + </module> +</config> diff --git a/app/code/Magento/Ups/view/adminhtml/layout/adminhtml_system_config_edit.xml b/app/code/Magento/Ups/view/adminhtml/layout/adminhtml_system_config_edit.xml new file mode 100644 index 00000000000..187bc65b0bc --- /dev/null +++ b/app/code/Magento/Ups/view/adminhtml/layout/adminhtml_system_config_edit.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceContainer name="js"> + <block class="Magento\Ups\Block\Backend\System\CarrierConfig" template="system/shipping/carrier_config.phtml"/> + </referenceContainer> +</layout> diff --git a/app/code/Magento/Backend/view/adminhtml/system/shipping/ups.phtml b/app/code/Magento/Ups/view/adminhtml/system/shipping/carrier_config.phtml similarity index 95% rename from app/code/Magento/Backend/view/adminhtml/system/shipping/ups.phtml rename to app/code/Magento/Ups/view/adminhtml/system/shipping/carrier_config.phtml index a55cf92017a..a77b7fa9a9e 100644 --- a/app/code/Magento/Backend/view/adminhtml/system/shipping/ups.phtml +++ b/app/code/Magento/Ups/view/adminhtml/system/shipping/carrier_config.phtml @@ -18,19 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category design - * @package Magento_Backend * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ -/** @var $upsModel \Magento\Usa\Model\Shipping\Carrier\Ups */ -/** @var $this \Magento\Backend\Block\System\Shipping\Ups */ -$upsModel = $this->getShippingModel(); -$orShipArr = $upsModel->getCode('originShipment'); -$defShipArr = $upsModel->getCode('method'); +/** @var $upsModel \Magento\Ups\Helper\Config */ +/** @var $this \Magento\Ups\Block\Backend\System\CarrierConfig */ +$upsCarrierConfig = $this->getCarrierConfig(); +$orShipArr = $upsCarrierConfig->getCode('originShipment'); +$defShipArr = $upsCarrierConfig->getCode('method'); -/** @var $this \Magento\Backend\Block\Template */ $sectionCode = $this->getRequest()->getParam('section'); $websiteCode = $this->getRequest()->getParam('website'); $storeCode = $this->getRequest()->getParam('store'); diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl.php b/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl.php deleted file mode 100644 index b90655488a4..00000000000 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl.php +++ /dev/null @@ -1,1517 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Usa - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Usa\Model\Shipping\Carrier; - -use Magento\Shipping\Model\Rate\Result; -use Magento\Usa\Model\Simplexml\Element; - -/** - * DHL shipping implementation - */ -class Dhl - extends \Magento\Usa\Model\Shipping\Carrier\Dhl\AbstractDhl - implements \Magento\Shipping\Model\Carrier\CarrierInterface -{ - - /** - * Code of the carrier - * - * @var string - */ - const CODE = 'dhl'; - - /** - * Code of the carrier - * - * @var string - */ - protected $_code = self::CODE; - - /** - * Rate request data - * - * @var \Magento\Sales\Model\Quote\Address\RateRequest|null - */ - protected $_request = null; - - /** - * Raw rate request data - * - * @var \Magento\Object|null - */ - protected $_rawRequest = null; - - /** - * Rate result data - * - * @var Result|null - */ - protected $_result = null; - - /** - * Errors placeholder - * - * @var string[] - */ - protected $_errors = array(); - - /** - * Dhl rates result - * - * @var array - */ - protected $_dhlRates = array(); - - /** - * Default gateway url - * - * @var string - */ - protected $_defaultGatewayUrl = 'https://eCommerce.airborne.com/ApiLandingTest.asp'; - - /** - * Container types that could be customized - * - * @var string[] - */ - protected $_customizableContainerTypes = array('P'); - - /** - * Success code - * - * @var int - */ - const SUCCESS_CODE = 203; - - /** - * Success label code - * - * @var int - */ - const SUCCESS_LABEL_CODE = 100; - - /** - * Code for required additional protection - * - * @var string - */ - const ADDITIONAL_PROTECTION_ASSET = 'AP'; - - /** - * Code for not required additional protection - * - * @var string - */ - const ADDITIONAL_PROTECTION_NOT_REQUIRED = 'NR'; - - /** - * Config code of additional protection - * - * @var int - */ - const ADDITIONAL_PROTECTION_VALUE_CONFIG = 0; - - /** - * Subtotal code of additional protection - * - * @var int - */ - const ADDITIONAL_PROTECTION_VALUE_SUBTOTAL = 1; - - /** - * Subtotal with discount code of additional protection - * - * @var int - */ - const ADDITIONAL_PROTECTION_VALUE_SUBTOTAL_WITH_DISCOUNT = 2; - - /** - * Round to floor(lowest) code of additional protection - * - * @var int - */ - const ADDITIONAL_PROTECTION_ROUNDING_FLOOR = 0; - - /** - * Round to ceil(highest) code of additional protection - * - * @var int - */ - const ADDITIONAL_PROTECTION_ROUNDING_CEIL = 1; - - /** - * Round to precision code of additional protection - * - * @var int - */ - const ADDITIONAL_PROTECTION_ROUNDING_ROUND = 2; - - /** - * Usa data - * - * @var \Magento\Usa\Helper\Data - */ - protected $_usaData; - - /** - * Magento string lib - * - * @var \Magento\Stdlib\String - */ - protected $string; - - /** - * @var \Zend_Http_ClientFactory - */ - protected $_httpClientFactory; - - /** - * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory - * @param \Magento\Logger\AdapterFactory $logAdapterFactory - * @param \Magento\Usa\Model\Simplexml\ElementFactory $xmlElFactory - * @param \Magento\Shipping\Model\Rate\ResultFactory $rateFactory - * @param \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory - * @param \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory - * @param \Magento\Shipping\Model\Tracking\Result\ErrorFactory $trackErrorFactory - * @param \Magento\Shipping\Model\Tracking\Result\StatusFactory $trackStatusFactory - * @param \Magento\Directory\Model\RegionFactory $regionFactory - * @param \Magento\Directory\Model\CountryFactory $countryFactory - * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Directory\Helper\Data $directoryData - * @param \Magento\Usa\Helper\Data $usaData - * @param \Magento\Stdlib\String $string - * @param \Zend_Http_ClientFactory $httpClientFactory - * @param array $data - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) - */ - public function __construct( - \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, - \Magento\Logger\AdapterFactory $logAdapterFactory, - \Magento\Usa\Model\Simplexml\ElementFactory $xmlElFactory, - \Magento\Shipping\Model\Rate\ResultFactory $rateFactory, - \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, - \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory, - \Magento\Shipping\Model\Tracking\Result\ErrorFactory $trackErrorFactory, - \Magento\Shipping\Model\Tracking\Result\StatusFactory $trackStatusFactory, - \Magento\Directory\Model\RegionFactory $regionFactory, - \Magento\Directory\Model\CountryFactory $countryFactory, - \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Directory\Helper\Data $directoryData, - \Magento\Usa\Helper\Data $usaData, - \Magento\Stdlib\String $string, - \Zend_Http_ClientFactory $httpClientFactory, - array $data = array() - ) { - $this->string = $string; - $this->_usaData = $usaData; - $this->_httpClientFactory = $httpClientFactory; - parent::__construct( - $coreStoreConfig, - $rateErrorFactory, - $logAdapterFactory, - $xmlElFactory, - $rateFactory, - $rateMethodFactory, - $trackFactory, - $trackErrorFactory, - $trackStatusFactory, - $regionFactory, - $countryFactory, - $currencyFactory, - $directoryData, - $data - ); - } - - /** - * Collect and get rates - * - * @param \Magento\Sales\Model\Quote\Address\RateRequest $request - * @return bool|Result|null - */ - public function collectRates(\Magento\Sales\Model\Quote\Address\RateRequest $request) - { - if (!$this->getConfigFlag($this->_activeFlag)) { - return false; - } - - $requestDhl = clone $request; - $origCompanyName = $requestDhl->getOrigCompanyName(); - if (!$origCompanyName) { - $origCompanyName = $this->_coreStoreConfig->getConfig( - \Magento\Core\Model\Store::XML_PATH_STORE_STORE_NAME, - $requestDhl->getStoreId() - ); - } - - $origCountryId = $requestDhl->getOrigCountryId(); - if (!$origCountryId) { - $origCountryId = $this->_coreStoreConfig->getConfig( - \Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_COUNTRY_ID, - $requestDhl->getStoreId() - ); - } - $origState = $requestDhl->getOrigState(); - if (!$origState) { - $origState = $this->_coreStoreConfig->getConfig( - \Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_REGION_ID, - $requestDhl->getStoreId() - ); - } - $origCity = $requestDhl->getOrigCity(); - if (!$origCity) { - $origCity = $this->_coreStoreConfig->getConfig( - \Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_CITY, - $requestDhl->getStoreId() - ); - } - - $origPostcode = $requestDhl->getOrigPostcode(); - if (!$origPostcode) { - $origPostcode = $this->_coreStoreConfig->getConfig( - \Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ZIP, - $requestDhl->getStoreId() - ); - } - $requestDhl->setOrigCompanyName($origCompanyName) - ->setCountryId($origCountryId) - ->setOrigState($origState) - ->setOrigCity($origCity) - ->setOrigPostal($origPostcode); - $this->setRequest($requestDhl); - $this->_result = $this->_getQuotes(); - $this->_updateFreeMethodQuote($request); - - return $this->getResult(); - } - - /** - * Prepare and set request in property of current instance - * - * @param \Magento\Object $request - * @return $this - */ - public function setRequest(\Magento\Object $request) - { - $this->_request = $request; - - $r = new \Magento\Object(); - - if ($request->getAction() == 'GenerateLabel') { - $r->setAction('GenerateLabel'); - } else { - $r->setAction('RateEstimate'); - } - $r->setIsGenerateLabelReturn($request->getIsGenerateLabelReturn()); - - $r->setStoreId($request->getStoreId()); - - if ($request->getLimitMethod()) { - $r->setService($request->getLimitMethod()); - } - - if ($request->getDhlId()) { - $id = $request->getDhlId(); - } else { - $id = $this->getConfigData('id'); - } - $r->setId($id); - - if ($request->getDhlPassword()) { - $password = $request->getDhlPassword(); - } else { - $password = $this->getConfigData('password'); - } - $r->setPassword($password); - - if ($request->getDhlAccount()) { - $accountNbr = $request->getDhlAccount(); - } else { - $accountNbr = $this->getConfigData('account'); - } - $r->setAccountNbr($accountNbr); - - if ($request->getDhlShippingKey()) { - $shippingKey = $request->getDhlShippingKey(); - } else { - $shippingKey = $this->getConfigData('shipping_key'); - } - $r->setShippingKey($shippingKey); - - if ($request->getDhlShippingIntlKey()) { - $shippingKey = $request->getDhlShippingIntlKey(); - } else { - $shippingKey = $this->getConfigData('shipping_intlkey'); - } - $r->setShippingIntlKey($shippingKey); - - if ($request->getDhlShipmentType()) { - $shipmentType = $request->getDhlShipmentType(); - } else { - $shipmentType = $this->getConfigData('shipment_type'); - } - $r->setShipmentType($shipmentType); - - if ($request->getDhlDutiable()) { - $shipmentDutible = $request->getDhlDutiable(); - } else { - $shipmentDutible = $this->getConfigData('dutiable'); - } - $r->setDutiable($shipmentDutible); - - if ($request->getDhlDutyPaymentType()) { - $dutypaytype = $request->getDhlDutyPaymentType(); - } else { - $dutypaytype = $this->getConfigData('dutypaymenttype'); - } - $r->setDutyPaymentType($dutypaytype); - - if ($request->getDhlContentDesc()) { - $contentdesc = $request->getDhlContentDesc(); - } else { - $contentdesc = $this->getConfigData('contentdesc'); - } - $r->setContentDesc($contentdesc); - - if ($request->getDestPostcode()) { - $r->setDestPostal($request->getDestPostcode()); - } - - if ($request->getOrigCountry()) { - $origCountry = $request->getOrigCountry(); - } else { - $origCountry = $this->_coreStoreConfig->getConfig( - \Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_COUNTRY_ID, - $r->getStoreId() - ); - } - $r->setOrigCountry($origCountry); - - if ($request->getOrigCountryId()) { - $origCountryId = $request->getOrigCountryId(); - } else { - $origCountryId = $this->_coreStoreConfig->getConfig( - \Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_COUNTRY_ID, - $r->getStoreId() - ); - } - $r->setOrigCountryId($origCountryId); - - if ($request->getAction() == 'GenerateLabel') { - $packageParams = $request->getPackageParams(); - $shippingWeight = $request->getPackageWeight(); - if ($packageParams->getWeightUnits() != \Zend_Measure_Weight::POUND) { - $shippingWeight = round($this->_usaData->convertMeasureWeight( - $request->getPackageWeight(), - $packageParams->getWeightUnits(), - \Zend_Measure_Weight::POUND - )); - } - if ($packageParams->getDimensionUnits() != \Zend_Measure_Length::INCH) { - $packageParams->setLength(round($this->_usaData->convertMeasureDimension( - $packageParams->getLength(), - $packageParams->getDimensionUnits(), - \Zend_Measure_Length::INCH - ))); - $packageParams->setWidth(round($this->_usaData->convertMeasureDimension( - $packageParams->getWidth(), - $packageParams->getDimensionUnits(), - \Zend_Measure_Length::INCH - ))); - $packageParams->setHeight(round($this->_usaData->convertMeasureDimension( - $packageParams->getHeight(), - $packageParams->getDimensionUnits(), - \Zend_Measure_Length::INCH - ))); - } - $r->setPackageParams($packageParams); - } else { - /* - * DHL only accepts weight as a whole number. Maximum length is 3 digits. - */ - $shippingWeight = $request->getPackageWeight(); - if ($shipmentType != 'L') { - $weight = $this->getTotalNumOfBoxes($shippingWeight); - $shippingWeight = round(max(1, $weight), 0); - } - } - - $r->setValue(round($request->getPackageValue(), 2)); - $r->setValueWithDiscount($request->getPackageValueWithDiscount()); - $r->setCustomsValue($request->getPackageCustomsValue()); - $r->setDestStreet($this->string->substr(str_replace("\n", '', $request->getDestStreet()), 0, 35)); - $r->setDestStreetLine2($request->getDestStreetLine2()); - $r->setDestCity($request->getDestCity()); - $r->setOrigCompanyName($request->getOrigCompanyName()); - $r->setOrigCity($request->getOrigCity()); - $r->setOrigPhoneNumber($request->getOrigPhoneNumber()); - $r->setOrigPersonName($request->getOrigPersonName()); - $r->setOrigEmail($this->_coreStoreConfig->getConfig('trans_email/ident_general/email', $r->getStoreId())); - $r->setOrigCity($request->getOrigCity()); - $r->setOrigPostal($request->getOrigPostal()); - $originStreet1 = $this->_coreStoreConfig - ->getConfig(\Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ADDRESS1, $r->getStoreId()); - $originStreet2 = $this->_coreStoreConfig - ->getConfig(\Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ADDRESS2, $r->getStoreId()); - $r->setOrigStreet($request->getOrigStreet() ? $request->getOrigStreet() : $originStreet2); - $r->setOrigStreetLine2($request->getOrigStreetLine2()); - $r->setDestPhoneNumber($request->getDestPhoneNumber()); - $r->setDestPersonName($request->getDestPersonName()); - $r->setDestCompanyName($request->getDestCompanyName()); - - - if (is_numeric($request->getOrigState())) { - $r->setOrigState($this->_regionFactory->create()->load($request->getOrigState())->getCode()); - } else { - $r->setOrigState($request->getOrigState()); - } - - if ($request->getDestCountryId()) { - $destCountry = $request->getDestCountryId(); - } else { - $destCountry = self::USA_COUNTRY_ID; - } - - //for DHL, puero rico state for US will assume as puerto rico country - //for puerto rico, dhl will ship as international - if ($destCountry == self::USA_COUNTRY_ID && ($request->getDestPostcode() == '00912' - || $request->getDestRegionCode() == self::PUERTORICO_COUNTRY_ID) - ) { - $destCountry = self::PUERTORICO_COUNTRY_ID; - } - - $r->setDestCountryId($destCountry); - $r->setDestState($request->getDestRegionCode()); - - $r->setWeight($shippingWeight); - $r->setFreeMethodWeight($request->getFreeMethodWeight()); - - $r->setOrderShipment($request->getOrderShipment()); - - if ($request->getPackageId()) { - $r->setPackageId($request->getPackageId()); - } - - $r->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax()); - - $this->_rawRequest = $r; - return $this; - } - - /** - * Get result of request - * - * @return Result|null - */ - public function getResult() - { - return $this->_result; - } - - /** - * Get quotes - * - * @return Result - */ - protected function _getQuotes() - { - return $this->_getXmlQuotes(); - } - - /** - * Set free method request - * - * @param string $freeMethod - * @return void - */ - protected function _setFreeMethodRequest($freeMethod) - { - $r = $this->_rawRequest; - - $r->setFreeMethodRequest(true); - $weight = $this->getTotalNumOfBoxes($r->getFreeMethodWeight()); - $freeWeight = round(max(1, $weight), 0); - $r->setWeight($freeWeight); - $r->setService($freeMethod); - } - - /** - * Get xml quotes - * - * @return \Magento\Core\Model\AbstractModel|\Magento\Object - */ - protected function _getXmlQuotes() - { - return $this->_doRequest(); - } - - /** - * Do rate request and handle errors - * - * @return Result|\Magento\Object - */ - protected function _doRequest() - { - $r = $this->_rawRequest; - - $xml = $this->_xmlElFactory->create(array('data' => '<?xml version = "1.0" encoding = "UTF-8"?><eCommerce/>')); - $xml->addAttribute('action', 'Request'); - $xml->addAttribute('version', '1.1'); - - $requestor = $xml->addChild('Requestor'); - $requestor->addChild('ID', $r->getId()); - $requestor->addChild('Password', $r->getPassword()); - - $methods = explode(',', $this->getConfigData('allowed_methods')); - $internationcode = $this->getCode('international_searvice'); - $hasShipCode = false; - - $shipDate = $this->_getShipDate(); - - if ($r->hasService() && $r->getFreeMethodRequest()) { - if ($r->getDestCountryId() == self::USA_COUNTRY_ID) { - $shipment = $xml->addChild('Shipment'); - $shipKey = $r->getShippingKey(); - $r->setShipDate($shipDate); - } else { - $shipment = $xml->addChild('IntlShipment'); - $shipKey = $r->getShippingIntlKey(); - $r->setShipDate($this->_getShipDate(false)); - /* - * For internation shippingment customsvalue must be posted - */ - $shippingDuty = $shipment->addChild('Dutiable'); - $shippingDuty->addChild('DutiableFlag', ($r->getDutiable() ? 'Y' : 'N')); - $shippingDuty->addChild('CustomsValue', $r->getValue()); - $shippingDuty->addChild('IsSEDReqd', 'N'); - } - $hasShipCode = true; - $this->_createShipmentXml($shipment, $shipKey); - } else { - if ($r->getAction() == 'GenerateLabel') { - $methods = array($r->getService()); - } - - foreach ($methods as $method) { - $shipment = false; - if (in_array($method, array_keys($this->getCode('special_express')))) { - $r->setService('E'); - $r->setExtendedService($this->getCode('special_express', $method)); - } else { - $r->setService($method); - $r->setExtendedService(null); - } - if ($r->getDestCountryId() == self::USA_COUNTRY_ID && $method != $internationcode) { - $shipment = $xml->addChild('Shipment'); - $shipKey = $r->getShippingKey(); - $r->setShipDate($shipDate); - } elseif ($r->getDestCountryId() != self::USA_COUNTRY_ID && $method == $internationcode) { - $shipment = $xml->addChild('IntlShipment'); - $shipKey = $r->getShippingIntlKey(); - if ($r->getCustomsValue() != null && $r->getCustomsValue() != '') { - $customsValue = $r->getCustomsValue(); - } else { - $customsValue = $r->getValue(); - } - - $r->setShipDate($this->_getShipDate(false)); - - /* - * For internation shippingment customsvalue must be posted - */ - $shippingDuty = $shipment->addChild('Dutiable'); - $shippingDuty->addChild('DutiableFlag', ($r->getDutiable() ? 'Y' : 'N')); - $shippingDuty->addChild('CustomsValue', $customsValue); - $shippingDuty->addChild('IsSEDReqd', 'N'); - } - - if ($shipment !== false) { - $hasShipCode = true; - $this->_createShipmentXml($shipment, $shipKey); - } - } - } - - if (!$hasShipCode) { - $this->_errors[] = __('We don\'t have a way to ship to the selected shipping address. Please choose another address or edit the current address.'); - return null; - } - - $request = $xml->asXML(); - $request = utf8_encode($request); - $responseBody = $this->_getCachedQuotes($request); - if ($responseBody === null) { - $debugData = array('request' => $request); - try { - $url = $this->getConfigData('gateway_url'); - if (!$url) { - $url = $this->_defaultGatewayUrl; - } - $config = array( - 'adapter' => 'Zend_Http_Client_Adapter_Curl', - 'curloptions' => array( - CURLOPT_RETURNTRANSFER => true, - CURLOPT_URL => $url, - CURLOPT_SSL_VERIFYPEER => true, - CURLOPT_SSL_VERIFYHOST => false, - CURLOPT_POSTFIELDS => $request - ) - ); - $client = $this->_httpClientFactory->create( - array('data' => $config) - ); - $response = $client->request(); - $responseBody = $response->getBody(); - - $debugData['result'] = $responseBody; - $this->_setCachedQuotes($request, $responseBody); - } - catch (\Exception $e) { - $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); - $responseBody = ''; - } - $this->_debug($debugData); - } - - return $this->_parseXmlResponse($responseBody); - } - - /** - * Create shipment xml - * - * @param Element $shipment - * @param string $shipKey - * @return void - */ - protected function _createShipmentXml($shipment, $shipKey) - { - $r = $this->_rawRequest; - - $_haz = $this->getConfigFlag('hazardous_materials'); - - $_subtotal = $r->getValue(); - $_subtotalWithDiscount = $r->getValueWithDiscount(); - - $_width = max(0, (double)$this->getConfigData('default_width')); - $_height = max(0, (double)$this->getConfigData('default_height')); - $_length = max(0, (double)$this->getConfigData('default_length')); - - $packageParams = $r->getPackageParams(); - if ($packageParams) { - $_length = $packageParams->getLength(); - $_width = $packageParams->getWidth(); - $_height = $packageParams->getHeight(); - } - - $_apEnabled = $this->getConfigFlag('additional_protection_enabled'); - $_apUseSubtotal = $this->getConfigData('additional_protection_use_subtotal'); - $_apConfigValue = max(0, (double)$this->getConfigData('additional_protection_value')); - $_apMinValue = max(0, (double)$this->getConfigData('additional_protection_min_value')); - $_apValueRounding = $this->getConfigData('additional_protection_rounding'); - - $apValue = 0; - $apCode = self::ADDITIONAL_PROTECTION_NOT_REQUIRED; - if ($_apEnabled) { - if ($_apMinValue <= $_subtotal) { - switch ($_apUseSubtotal) { - case self::ADDITIONAL_PROTECTION_VALUE_SUBTOTAL: - $apValue = $_subtotal; - break; - case self::ADDITIONAL_PROTECTION_VALUE_SUBTOTAL_WITH_DISCOUNT: - $apValue = $_subtotalWithDiscount; - break; - default: - case self::ADDITIONAL_PROTECTION_VALUE_CONFIG: - $apValue = $_apConfigValue; - break; - } - - if ($apValue) { - $apCode = self::ADDITIONAL_PROTECTION_ASSET; - - - switch ($_apValueRounding) { - case self::ADDITIONAL_PROTECTION_ROUNDING_CEIL: - $apValue = ceil($apValue); - break; - case self::ADDITIONAL_PROTECTION_ROUNDING_ROUND: - $apValue = round($apValue); - break; - default: - case self::ADDITIONAL_PROTECTION_ROUNDING_FLOOR: - $apValue = floor($apValue); - break; - } - } - } - } - - if ($r->getAction() == 'GenerateLabel') { - $shipment->addAttribute('action', 'GenerateLabel'); - } else { - $shipment->addAttribute('action', 'RateEstimate'); - } - $shipment->addAttribute('version', '1.0'); - - $shippingCredentials = $shipment->addChild('ShippingCredentials'); - $shippingCredentials->addChild('ShippingKey', $shipKey); - $shippingCredentials->addChild('AccountNbr', $r->getAccountNbr()); - - $shipmentDetail = $shipment->addChild('ShipmentDetail'); - if ($r->getAction() == 'GenerateLabel') { - if ($this->_request->getReferenceData()) { - $referenceData = $this->_request->getReferenceData() . $this->_request->getPackageId(); - } else { - $referenceData = 'Order #' - . $r->getOrderShipment()->getOrder()->getIncrementId() - . ' P' - . $r->getPackageId(); - } - - $shipmentDetail->addChild('ShipperReference', $referenceData); - } - $shipmentDetail->addChild('ShipDate', $r->getShipDate()); - $shipmentDetail->addChild('Service')->addChild('Code', $r->getService()); - $shipmentDetail->addChild('ShipmentType')->addChild('Code', $r->getShipmentType()); - $shipmentDetail->addChild('Weight', $r->getWeight()); - $shipmentDetail->addChild('ContentDesc', $r->getContentDesc()); - $additionalProtection = $shipmentDetail->addChild('AdditionalProtection'); - $additionalProtection->addChild('Code', $apCode); - $additionalProtection->addChild('Value', floor($apValue)); - - if ($_width || $_height || $_length) { - $dimensions = $shipmentDetail->addChild('Dimensions'); - $dimensions->addChild('Length', $_length); - $dimensions->addChild('Width', $_width); - $dimensions->addChild('Height', $_height); - } - - if ($_haz || ($r->getExtendedService())) { - $specialServices = $shipmentDetail->addChild('SpecialServices'); - } - - if ($_haz) { - $hazardousMaterials = $specialServices->addChild('SpecialService'); - $hazardousMaterials->addChild('Code', 'HAZ'); - } - - if ($r->getExtendedService()) { - $extendedService = $specialServices->addChild('SpecialService'); - $extendedService->addChild('Code', $r->getExtendedService()); - } - - /* - * R = Receiver (if receiver, need AccountNbr) - * S = Sender - * 3 = Third Party (if third party, need AccountNbr) - */ - $billing = $shipment->addChild('Billing'); - $billing->addChild('Party')->addChild('Code', $r->getIsGenerateLabelReturn() ? 'R' : 'S'); - $billing->addChild('DutyPaymentType', $r->getDutyPaymentType()); - if ($r->getIsGenerateLabelReturn()) { - $billing->addChild('AccountNbr', $r->getAccountNbr()); - } - - $sender = $shipment->addChild('Sender'); - $sender->addChild('SentBy', ($r->getOrigPersonName())); - $sender->addChild('PhoneNbr', $r->getOrigPhoneNumber()); - $sender->addChild('Email', $r->getOrigEmail()); - - $senderAddress = $sender->addChild('Address'); - $senderAddress->addChild('Street', htmlspecialchars($r->getOrigStreet() ? $r->getOrigStreet() : 'N/A')); - $senderAddress->addChild('City', htmlspecialchars($r->getOrigCity())); - $senderAddress->addChild('State', htmlspecialchars($r->getOrigState())); - $senderAddress->addChild('CompanyName', htmlspecialchars($r->getOrigCompanyName())); - /* - * DHL xml service is using UK for united kingdom instead of GB which is a standard ISO country code - */ - $senderAddress->addChild('Country', ($r->getOrigCountryId() == 'GB' ? 'UK' : $r->getOrigCountryId())); - $senderAddress->addChild('PostalCode', $r->getOrigPostal()); - - $receiver = $shipment->addChild('Receiver'); - $receiver->addChild('AttnTo', $r->getDestPersonName()); - $receiver->addChild('PhoneNbr', $r->getDestPhoneNumber()); - - $receiverAddress = $receiver->addChild('Address'); - $receiverAddress->addChild('Street', htmlspecialchars($r->getDestStreet() ? $r->getDestStreet() : 'N/A')); - $receiverAddress->addChild('StreetLine2', - htmlspecialchars($r->getDestStreetLine2() ? $r->getDestStreetLine2() : 'N/A') - ); - $receiverAddress->addChild('City', htmlspecialchars($r->getDestCity())); - $receiverAddress->addChild('State', htmlspecialchars($r->getDestState())); - $receiverAddress->addChild('CompanyName', - htmlspecialchars($r->getDestCompanyName() ? $r->getDestCompanyName() : 'N/A') - ); - - /* - * DHL xml service is using UK for united kingdom instead of GB which is a standard ISO country code - */ - $receiverAddress->addChild('Country', ($r->getDestCountryId() == 'GB' ? 'UK' : $r->getDestCountryId())); - $receiverAddress->addChild('PostalCode', $r->getDestPostal()); - - if ($r->getAction() == 'GenerateLabel') { - $label = $shipment->addChild('ShipmentProcessingInstructions')->addChild('Label'); - $label->addChild('ImageType', 'PNG'); - } - } - - /** - * Parse xml response and return result - * - * @param string $response - * @return Result|\Magento\Object - */ - protected function _parseXmlResponse($response) - { - $r = $this->_rawRequest; - $costArr = array(); - $priceArr = array(); - $errorTitle = 'Unable to retrieve quotes'; - - if (strlen(trim($response)) > 0) { - if (strpos(trim($response), '<?xml') === 0) { - $xml = simplexml_load_string($response); - if (is_object($xml)) { - if ( - is_object($xml->Faults) - && is_object($xml->Faults->Fault) - && is_object($xml->Faults->Fault->Code) - && is_object($xml->Faults->Fault->Description) - && is_object($xml->Faults->Fault->Context) - ) { - $code = (string)$xml->Faults->Fault->Code; - $description = $xml->Faults->Fault->Description; - $context = $xml->Faults->Fault->Context; - $this->_errors[$code] = __('Error #%1 : %2 (%3)', $code, $description, $context); - } else { - if ($r->getDestCountryId() == self::USA_COUNTRY_ID) { - if ($xml->Shipment) { - foreach ($xml->Shipment as $shipXml) { - $this->_parseXmlObject($shipXml); - } - } else { - $this->_errors[] = __('Shipment is not available.'); - } - } else { - $shipXml = $xml->IntlShipment; - $this->_parseXmlObject($shipXml); - } - $shipXml = (($r->getDestCountryId() == self::USA_COUNTRY_ID) - ? $xml->Shipment - : $xml->IntlShipment - ); - } - } - } else { - $this->_errors[] = __('Please format your response correctly.'); - } - } - - if ($this->_rawRequest->getAction() == 'GenerateLabel') { - $result = new \Magento\Object(); - if (!empty($this->_errors)) { - $result->setErrors(implode($this->_errors, '; ')); - } else { - if ($xml !== false) { - if ($r->getDestCountryId() == self::USA_COUNTRY_ID) { - $shippingLabelContent = base64_decode((string)$xml->Shipment->Label->Image); - $trackingNumber = (string)$xml->Shipment->ShipmentDetail->AirbillNbr; - } else { - $shippingLabelContent = base64_decode((string)$xml->IntlShipment->Label->Image); - $trackingNumber = (string)$xml->IntlShipment->ShipmentDetail->AirbillNbr; - } - } - $result->setShippingLabelContent($shippingLabelContent); - $result->setTrackingNumber($trackingNumber); - } - return $result; - } else { - $result = $this->_rateFactory->create(); - if ($this->_dhlRates) { - foreach ($this->_dhlRates as $rate) { - $method = $rate['service']; - $data = $rate['data']; - $rate = $this->_rateMethodFactory->create(); - $rate->setCarrier('dhl'); - $rate->setCarrierTitle($this->getConfigData('title')); - $rate->setMethod($method); - $rate->setMethodTitle($data['term']); - $rate->setCost($data['price_total']); - $rate->setPrice($data['price_total']); - $result->append($rate); - } - } else if (!empty($this->_errors)) { - $error = $this->_rateErrorFactory->create(); - $error->setCarrier('dhl'); - $error->setCarrierTitle($this->getConfigData('title')); - $error->setErrorMessage($this->getConfigData('specificerrmsg')); - $result->append($error); - } - return $result; - } - } - - /** - * Parse xml object - * - * @param \SimpleXMLElement $shipXml - * @return $this - */ - protected function _parseXmlObject($shipXml) - { - if ( - is_object($shipXml->Faults) - && is_object($shipXml->Faults->Fault) - && is_object($shipXml->Faults->Fault->Desc) - && intval($shipXml->Faults->Fault->Code) != self::SUCCESS_CODE - && intval($shipXml->Faults->Fault->Code) != self::SUCCESS_LABEL_CODE - ) { - $code = (string)$shipXml->Faults->Fault->Code; - $description = $shipXml->Faults->Fault->Desc; - $this->_errors[$code] = __('Error #%1: %2', $code, $description); - } elseif ( - is_object($shipXml->Faults) - && is_object($shipXml->Result->Code) - && is_object($shipXml->Result->Desc) - && intval($shipXml->Result->Code) != self::SUCCESS_CODE - && intval($shipXml->Result->Code) != self::SUCCESS_LABEL_CODE - ) { - $code = (string)$shipXml->Result->Code; - $description = $shipXml->Result->Desc; - $this->_errors[$code] = __('Error #%1: %2', $code, $description); - } else { - $this->_addRate($shipXml); - } - return $this; - } - - /** - * Get configuration data of carrier - * - * @param string $type - * @param string $code - * @return array|false - */ - public function getCode($type, $code = '') - { - static $codes; - $codes = array( - 'service' => array( - 'IE' => __('International Express'), - 'E SAT' => __('Express Saturday'), - 'E 10:30AM' => __('Express 10:30 AM'), - 'E' => __('Express'), - 'N' => __('Next Afternoon'), - 'S' => __('Second Day Service'), - 'G' => __('Ground'), - ), - 'shipment_type' => array( - 'L' => __('Letter'), - 'P' => __('Package'), - ), - 'international_searvice' => 'IE', - 'dutypayment_type' => array( - 'S' => __('Sender'), - 'R' => __('Receiver'), - '3' => __('Third Party'), - ), - - 'special_express' => array( - 'E SAT' => 'SAT', - 'E 10:30AM' => '1030', - ), - - 'descr_to_service' => array( - 'E SAT' => 'Saturday', - 'E 10:30AM' => '10:30 A.M', - ), - - ); - - if (!isset($codes[$type])) { - return false; - } elseif ('' === $code) { - return $codes[$type]; - } - - if (!isset($codes[$type][$code])) { - return false; - } else { - return $codes[$type][$code]; - } - } - - /** - * Parse xml and add rates to instance property - * - * @param \SimpleXMLElement $shipXml - * @return void - */ - protected function _addRate($shipXml) - { - $r = $this->_rawRequest; - $services = $this->getCode('service'); - $regexps = $this->getCode('descr_to_service'); - $desc = ($shipXml->EstimateDetail) ? (string)$shipXml->EstimateDetail->ServiceLevelCommitment->Desc : null; - - $totalEstimate = $shipXml->EstimateDetail - ? (string)$shipXml->EstimateDetail->RateEstimate->TotalChargeEstimate - : null; - /* - * DHL can return with empty result and success code - * we need to make sure there is shipping estimate and code - */ - if ($desc && $totalEstimate) { - $service = (string)$shipXml->EstimateDetail->Service->Code; - $description = (string)$shipXml->EstimateDetail->ServiceLevelCommitment->Desc; - if ($service == 'E') { - foreach ($regexps as $expService => $exp) { - if (preg_match('/' . preg_quote($exp, '/') . '/', $description)) { - $service = $expService; - } - } - } - - $data['term'] = (isset($services[$service]) ? $services[$service] : $desc); - $data['price_total'] = $this->getMethodPrice($totalEstimate, $service); - $this->_dhlRates[] = array('service' => $service, 'data' => $data); - } - } - - /** - * Get tracking - * - * @param string|string[] $trackings - * @return Result|null - */ - public function getTracking($trackings) - { - $this->setTrackingReqeust(); - - if (!is_array($trackings)) { - $trackings = array($trackings); - } - $this->_getXMLTracking($trackings); - - return $this->_result; - } - - /** - * Set tracking request - * - * @return void - */ - protected function setTrackingReqeust() - { - $r = new \Magento\Object(); - - $id = $this->getConfigData('id'); - $r->setId($id); - - $password = $this->getConfigData('password'); - $r->setPassword($password); - - $this->_rawTrackRequest = $r; - } - - /** - * Send request for tracking - * - * @param string[] $trackings - * @return void - */ - protected function _getXMLTracking($trackings) - { - $r = $this->_rawTrackRequest; - - $xml = $this->_xmlElFactory->create(array('data' => '<?xml version = "1.0" encoding = "UTF-8"?><eCommerce/>')); - $xml->addAttribute('action', 'Request'); - $xml->addAttribute('version', '1.1'); - - $requestor = $xml->addChild('Requestor'); - $requestor->addChild('ID', $r->getId()); - $requestor->addChild('Password', $r->getPassword()); - - $track = $xml->addChild('Track'); - $track->addAttribute('action', 'Get'); - $track->addAttribute('version', '1.0'); - - foreach ($trackings as $tracking) { - $track->addChild('Shipment')->addChild('TrackingNbr', $tracking); - } - $request = $xml->asXML(); - $debugData = array('request' => $request); - /* - * tracking api cannot process from 3pm to 5pm PST time on Sunday - * DHL Airborne conduts a maintainance during that period. - */ - try { - $url = $this->getConfigData('gateway_url'); - if (!$url) { - $url = $this->_defaultGatewayUrl; - } - - $config = array( - 'adapter' => 'Zend_Http_Client_Adapter_Curl', - 'curloptions' => array( - CURLOPT_RETURNTRANSFER => true, - CURLOPT_URL => $url, - CURLOPT_SSL_VERIFYPEER => true, - CURLOPT_SSL_VERIFYHOST => false, - CURLOPT_POSTFIELDS => $request - ) - ); - $client = $this->_httpClientFactory->create( - array('data' => $config) - ); - $response = $client->request(); - $responseBody = $response->getBody(); - - $debugData['result'] = $responseBody; - } catch (\Exception $e) { - $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); - $responseBody = ''; - } - $this->_debug($debugData); - $this->_parseXmlTrackingResponse($trackings, $responseBody); - } - - /** - * Parse xml tracking response - * - * @param string[] $trackings value - * @param string $response - * @return void - */ - protected function _parseXmlTrackingResponse($trackings, $response) - { - $errorTitle = __('Unable to retrieve tracking'); - $resultArr = array(); - $errorArr = array(); - $trackingserror = array(); - $tracknum = ''; - if (strlen(trim($response)) > 0) { - if (strpos(trim($response), '<?xml') === 0) { - $xml = simplexml_load_string($response); - if (is_object($xml)) { - $trackxml = $xml->Track; - if ( - is_object($xml->Faults) - && is_object($xml->Faults->Fault) - && is_object($xml->Faults->Fault->Code) - && is_object($xml->Faults->Fault->Description) - && is_object($xml->Faults->Fault->Context) - ) { - $code = (string)$xml->Faults->Fault->Code; - $description = $xml->Faults->Fault->Description; - $context = $xml->Faults->Fault->Context; - $errorTitle = __('Error #%1 : %2 (%3)', $code, $description, $context); - } elseif (is_object($trackxml) && is_object($trackxml->Shipment)) { - foreach ($trackxml->Shipment as $txml) { - $rArr = array(); - - if (is_object($txml)) { - $tracknum = (string)$txml->TrackingNbr; - if ($txml->Fault) { - $code = (string)$txml->Fault->Code; - $description = $txml->Fault->Description; - $errorArr[$tracknum] = __('Error #%1: %2', $code, $description); - } elseif ($txml->Result) { - $code = (int)$txml->Result->Code; - if ($code === 0) { - /* - * Code 0== airbill found - */ - $rArr['service'] = (string)$txml->Service->Desc; - if (isset($txml->Weight)) { - $rArr['weight'] = (string)$txml->Weight . " lbs"; - } - if (isset($txml->Delivery)) { - $rArr['deliverydate'] = (string)$txml->Delivery->Date; - $rArr['deliverytime'] = (string)$txml->Delivery->Time . ':00'; - $rArr['status'] = __('Delivered'); - if (isset($txml->Delivery->Location->Desc)) { - $rArr['deliverylocation'] = (string)$txml->Delivery->Location->Desc; - } - } elseif (isset($txml->Pickup)) { - $rArr['deliverydate'] = (string)$txml->Pickup->Date; - $rArr['deliverytime'] = (string)$txml->Pickup->Time . ':00'; - $rArr['status'] = __('Shipment picked up'); - } else { - $rArr['status'] = (string)$txml->ShipmentType->Desc - . __(' was not delivered nor scanned'); - } - - $packageProgress = array(); - if (isset($txml->TrackingHistory) && isset($txml->TrackingHistory->Status)) { - - foreach ($txml->TrackingHistory->Status as $thistory) { - $tempArr = array(); - $tempArr['activity'] = (string)$thistory->StatusDesc; - $tempArr['deliverydate'] = (string)$thistory->Date; //YYYY-MM-DD - $tempArr['deliverytime'] = (string)$thistory->Time . ':00'; //HH:MM:ss - $addArr = array(); - if (isset($thistory->Location->City)) { - $addArr[] = (string)$thistory->Location->City; - } - if (isset($thistory->Location->State)) { - $addArr[] = (string)$thistory->Location->State; - } - if (isset($thistory->Location->CountryCode)) { - $addArr[] = (string)$thistory->Location->Country; - } - if ($addArr) { - $tempArr['deliverylocation'] = implode(', ', $addArr); - } elseif (isset($thistory['final_delivery']) - && (string)$thistory['final_delivery'] === 'true' - ) { - /* - * if the history is final delivery, there is no informationabout - * city, state and country - */ - $addArr = array(); - if (isset($txml->Receiver->City)) { - $addArr[] = (string)$txml->Receiver->City; - } - if (isset($thistory->Receiver->State)) { - $addArr[] = (string)$txml->Receiver->State; - } - if (isset($thistory->Receiver->CountryCode)) { - $addArr[] = (string)$txml->Receiver->Country; - } - $tempArr['deliverylocation'] = implode(', ', $addArr); - } - $packageProgress[] = $tempArr; - } - $rArr['progressdetail'] = $packageProgress; - - } - $resultArr[$tracknum] = $rArr; - } else { - $description = (string)$txml->Result->Desc; - if ($description) { - $errorArr[$tracknum] = __('Error #%1: %2', $code, $description); - } else { - $errorArr[$tracknum] = __('Unable to retrieve tracking'); - } - } - } else { - $errorArr[$tracknum] = __('Unable to retrieve tracking'); - } - - } - } - - } - } - } else { - $errorTitle = __('Response is in the wrong format'); - } - } - - $result = $this->_trackFactory->create(); - if ($errorArr || $resultArr) { - foreach ($errorArr as $t => $r) { - $error = $this->_trackErrorFactory->create(); - $error->setCarrier('dhl'); - $error->setCarrierTitle($this->getConfigData('title')); - $error->setTracking($t); - $error->setErrorMessage($r); - $result->append($error); - } - - foreach ($resultArr as $t => $data) { - $tracking = $this->_trackStatusFactory->create(); - $tracking->setCarrier('dhl'); - $tracking->setCarrierTitle($this->getConfigData('title')); - $tracking->setTracking($t); - $tracking->addData($data); - - $result->append($tracking); - } - } else { - foreach ($trackings as $t) { - $error = $this->_trackErrorFactory->create(); - $error->setCarrier('dhl'); - $error->setCarrierTitle($this->getConfigData('title')); - $error->setTracking($t); - $error->setErrorMessage($errorTitle); - $result->append($error); - - } - } - $this->_result = $result; - } - - /** - * Get tracking response - * - * @return string - */ - public function getResponse() - { - $statuses = ''; - if ($this->_result instanceof \Magento\Shipping\Model\Tracking\Result) { - if ($trackings = $this->_result->getAllTrackings()) { - foreach ($trackings as $tracking) { - if ($data = $tracking->getAllData()) { - if (isset($data['status'])) { - $statuses .= __($data['status']) . "\n<br/>"; - } else { - $statuses .= __($data['error_message']) . "\n<br/>"; - } - } - } - } - } - if (empty($statuses)) { - $statuses = __('Empty response'); - } - return $statuses; - } - - /** - * Get allowed shipping methods - * - * @return array - */ - public function getAllowedMethods() - { - $allowed = explode(',', $this->getConfigData('allowed_methods')); - $arr = array(); - foreach ($allowed as $k) { - $arr[$k] = $this->getCode('service', $k); - } - return $arr; - } - - /** - * Is state province required - * - * @return bool - */ - public function isStateProvinceRequired() - { - return true; - } - - /** - * Get additional protection value types - * - * @return array - */ - public function getAdditionalProtectionValueTypes() - { - return array( - self::ADDITIONAL_PROTECTION_VALUE_CONFIG => __('Configuration'), - self::ADDITIONAL_PROTECTION_VALUE_SUBTOTAL => __('Subtotal'), - self::ADDITIONAL_PROTECTION_VALUE_SUBTOTAL_WITH_DISCOUNT => __('Subtotal With Discount'), - ); - } - - /** - * Get additional protection rounding types - * - * @return array - */ - public function getAdditionalProtectionRoundingTypes() - { - return array( - self::ADDITIONAL_PROTECTION_ROUNDING_FLOOR => __('To Lower'), - self::ADDITIONAL_PROTECTION_ROUNDING_CEIL => __('To Upper'), - self::ADDITIONAL_PROTECTION_ROUNDING_ROUND => __('Round'), - ); - } - - /** - * Map request to shipment - * - * @param \Magento\Object $request - * @return void - */ - protected function _mapRequestToShipment(\Magento\Object $request) - { - $customsValue = $request->getPackageParams()->getCustomsValue(); - $request->setOrigPersonName($request->getShipperContactPersonName()); - $request->setOrigPostal($request->getShipperAddressPostalCode()); - $request->setOrigPhoneNumber($request->getShipperContactPhoneNumber()); - $request->setOrigCompanyName($request->getShipperContactCompanyName()); - $request->setOrigCountryId($request->getShipperAddressCountryCode()); - $request->setOrigState($request->getShipperAddressStateOrProvinceCode()); - $request->setOrigCity($request->getShipperAddressCity()); - $request->setOrigStreet($request->getShipperAddressStreet1() . ' ' . $request->getShipperAddressStreet2()); - $request->setOrigStreetLine2($request->getShipperAddressStreet2()); - - $request->setDestPersonName($request->getRecipientContactPersonName()); - $request->setDestPostcode($request->getRecipientAddressPostalCode()); - $request->setDestPhoneNumber($request->getRecipientContactPhoneNumber()); - $request->setDestCompanyName($request->getRecipientContactCompanyName()); - $request->setDestCountryId($request->getRecipientAddressCountryCode()); - $request->setDestRegionCode($request->getRecipientAddressStateOrProvinceCode()); - $request->setDestCity($request->getRecipientAddressCity()); - $request->setDestStreet($request->getRecipientAddressStreet1()); - $request->setDestStreetLine2($request->getRecipientAddressStreet2()); - - $request->setLimitMethod($request->getShippingMethod()); - $request->setPackageValue($customsValue); - $request->setValueWithDiscount($customsValue); - $request->setPackageCustomsValue($customsValue); - $request->setFreeMethodWeight(0); - $request->setDhlShipmentType($request->getPackagingType()); - - $request->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax()); - } - - /** - * Do shipment request to carrier web service, obtain Print Shipping Labels and process errors in response - * - * @param \Magento\Object $request - * @return \Magento\Object|Result - */ - protected function _doShipmentRequest(\Magento\Object $request) - { - $this->_prepareShipmentRequest($request); - $request->setAction('GenerateLabel'); - $this->_mapRequestToShipment($request); - $this->setRequest($request); - - return $this->_doRequest(); - } - - /** - * Return container types of carrier - * - * @param \Magento\Object|null $params - * @return array|bool - */ - public function getContainerTypes(\Magento\Object $params = null) - { - return $this->getCode('shipment_type'); - } -} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Doc.php b/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Doc.php deleted file mode 100644 index 8f25a8266c4..00000000000 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Doc.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Usa - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Source model for DHL shipping methods for documentation - * - * @category Magento - * @package Magento_Usa - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method; - -class Doc - extends \Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\AbstractMethod -{ - /** - * Carrier Product Type Indicator - * - * @var string $_contentType - */ - protected $_contentType = \Magento\Usa\Model\Shipping\Carrier\Dhl\International::DHL_CONTENT_TYPE_DOC; -} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Generic.php b/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Generic.php deleted file mode 100644 index b5fbfb40174..00000000000 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Generic.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method; - -class Generic -{ - /** - * @var \Magento\Usa\Model\Shipping\Carrier\Dhl\International - */ - protected $_shippingDhlInt; - - /** - * @var string - */ - protected $_code = ''; - - /** - * @param \Magento\Usa\Model\Shipping\Carrier\Dhl\International $shippingDhlInt - */ - public function __construct(\Magento\Usa\Model\Shipping\Carrier\Dhl\International $shippingDhlInt) - { - $this->_shippingDhlInt = $shippingDhlInt; - } - - /** - * Returns array to be used in multiselect on back-end - * - * @return array - */ - public function toOptionArray() - { - $configData = $this->_shippingDhlInt->getCode($this->_code); - $arr = array(); - foreach ($configData as $code => $title) { - $arr[] = array('value' => $code, 'label' => $title); - } - return $arr; - } -} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Size.php b/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Size.php deleted file mode 100644 index 0d0b62a81b0..00000000000 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Size.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Usa - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Source model for DHL shipping methods for documentation - * - * @category Magento - * @package Magento_Usa - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method; - -class Size extends \Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Generic -{ - /** - * Carrier code - * - * @var string - */ - protected $_code = 'size'; -} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Unitofmeasure.php b/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Unitofmeasure.php deleted file mode 100644 index 092fc40ae5a..00000000000 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/International/Source/Method/Unitofmeasure.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Usa - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Source model for DHL shipping methods for documentation - * - * @category Magento - * @package Magento_Usa - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method; - -class Unitofmeasure extends \Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Generic -{ - /** - * Carrier code - * - * @var string - */ - protected $_code = 'unit_of_measure'; -} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Value.php b/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Value.php deleted file mode 100644 index d00058bae4c..00000000000 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Value.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Usa - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - - -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\Source\Protection; - -class Value extends \Magento\Usa\Model\Shipping\Carrier\Dhl\Source\Generic -{ - /** - * {@inheritdoc} - */ - public function toOptionArray() - { - $carrier = $this->_shippingDhl; - $arr = array(); - foreach ($carrier->getAdditionalProtectionValueTypes() as $k=>$v) { - $arr[] = array('value'=>$k, 'label'=>$v); - } - return $arr; - } -} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Container.php b/app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Container.php deleted file mode 100644 index 52216d24da3..00000000000 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Container.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Usa - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - - -namespace Magento\Usa\Model\Shipping\Carrier\Usps\Source; - -class Container extends \Magento\Usa\Model\Shipping\Carrier\Usps\Source\Generic -{ - /** - * Carrier code - * - * @var string - */ - protected $_code = 'container'; -} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Freemethod.php b/app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Freemethod.php deleted file mode 100644 index bf6131aee90..00000000000 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Freemethod.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Usa - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - - -namespace Magento\Usa\Model\Shipping\Carrier\Usps\Source; - -class Freemethod extends \Magento\Usa\Model\Shipping\Carrier\Usps\Source\Method -{ - /** - * {@inheritdoc} - */ - public function toOptionArray() - { - $arr = parent::toOptionArray(); - array_unshift($arr, array('value'=>'', 'label'=>__('None'))); - return $arr; - } -} diff --git a/app/code/Magento/Usa/etc/adminhtml/system.xml b/app/code/Magento/Usa/etc/adminhtml/system.xml deleted file mode 100644 index 19147acfee9..00000000000 --- a/app/code/Magento/Usa/etc/adminhtml/system.xml +++ /dev/null @@ -1,702 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Usa - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <system> - <section id="carriers"> - <group id="dhl" translate="label" type="text" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>DHL (Deprecated)</label> - <field id="account" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Account Number</label> - </field> - <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enabled for Checkout</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="allowed_methods" translate="label" type="multiselect" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Allowed Methods</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Dhl\Source\Method</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="contentdesc" translate="label" type="text" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Package Description</label> - </field> - <field id="free_shipping_enable" translate="label" type="select" sortOrder="1210" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Shipping Amount Threshold</label> - <source_model>Magento\Backend\Model\Config\Source\Enabledisable</source_model> - </field> - <field id="free_shipping_subtotal" translate="label" type="text" sortOrder="1220" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Shipping Amount Threshold</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="dutiable" translate="label" type="select" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Shipment Dutiable</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="dutypaymenttype" translate="label" type="select" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Shipment Duty Payment Type</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Dhl\Source\Dutypaymenttype</source_model> - </field> - <field id="free_method" translate="label" type="select" sortOrder="1200" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Method</label> - <frontend_class>free-method</frontend_class> - <source_model>Magento\Usa\Model\Shipping\Carrier\Dhl\Source\Freemethod</source_model> - </field> - <field id="gateway_url" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Gateway URL</label> - </field> - <field id="handling_type" translate="label" type="select" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Calculate Handling Fee</label> - <source_model>Magento\Shipping\Model\Source\HandlingType</source_model> - </field> - <field id="handling_action" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Handling Applied</label> - <source_model>Magento\Shipping\Model\Source\HandlingAction</source_model> - </field> - <field id="handling_fee" translate="label" type="text" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Handling Fee</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="max_package_weight" translate="label" type="text" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="id" translate="label" type="obscure" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Access ID</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - </field> - <field id="password" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Password</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - </field> - <field id="shipment_requesttype" translate="label" type="select" sortOrder="85" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Packages Request Type</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\AbstractCarrier\Source\Requesttype</source_model> - </field> - <field id="shipment_type" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Shipment Type</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Dhl\Source\Shipmenttype</source_model> - </field> - <field id="shipping_intlkey" translate="label" type="obscure" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Shipping Key (International)</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - </field> - <field id="shipping_key" translate="label" type="obscure" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Shipping Key</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - </field> - <field id="sort_order" translate="label" type="text" sortOrder="2000" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sort Order</label> - </field> - <field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Title</label> - </field> - <field id="sallowspecific" translate="label" type="select" sortOrder="1900" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Applicable Countries</label> - <frontend_class>shipping-applicable-country</frontend_class> - <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> - </field> - <field id="specificcountry" translate="label" type="multiselect" sortOrder="1910" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Specific Countries</label> - <source_model>Magento\Directory\Model\Config\Source\Country</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="showmethod" translate="label" type="select" sortOrder="1940" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Show Method if Not Applicable</label> - <frontend_class>shipping-skip-hide</frontend_class> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="specificerrmsg" translate="label" type="textarea" sortOrder="800" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Displayed Error Message</label> - </field> - <field id="additional_protection_enabled" translate="label" type="select" sortOrder="1300" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Additional Protection Enabled</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="additional_protection_min_value" translate="label" type="text" sortOrder="1310" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Additional Protection Min Subtotal</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="additional_protection_use_subtotal" translate="label" type="select" sortOrder="1320" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Additional Protection Value</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Dhl\Source\Protection\Value</source_model> - </field> - <field id="additional_protection_value" translate="label comment" type="text" sortOrder="1330" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Additional Protection Configuration Value</label> - <comment>This is used when "Additional Protection Value" is set to "Configuration". Enter only a numeric amount.</comment> - </field> - <field id="additional_protection_rounding" translate="label" type="select" sortOrder="1340" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Additional Protection Value Rounding Method</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Dhl\Source\Protection\Rounding</source_model> - </field> - <field id="hazardous_materials" translate="label" type="select" sortOrder="1350" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Shipment Contains Hazardous Materials</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="default_length" translate="label" type="text" sortOrder="1360" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Default Package Length</label> - </field> - <field id="default_width" translate="label" type="text" sortOrder="1370" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Default Package Width</label> - </field> - <field id="default_height" translate="label" type="text" sortOrder="1380" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Default Package Height</label> - </field> - <field id="shipment_days" translate="label" type="multiselect" sortOrder="1390" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Domestic Shipment Days</label> - <source_model>Magento\Backend\Model\Config\Source\Locale\Weekdaycodes</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="intl_shipment_days" translate="label" type="multiselect" sortOrder="1400" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>International Shipment Days</label> - <source_model>Magento\Backend\Model\Config\Source\Locale\Weekdaycodes</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="debug" translate="label" type="select" sortOrder="1950" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Debug</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - </group> - <group id="fedex" translate="label" type="text" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>FedEx</label> - <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enabled for Checkout</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Title</label> - </field> - <field id="account" translate="label comment" type="obscure" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Account ID</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - <comment>Please make sure to use only digits here. No dashes are allowed.</comment> - </field> - <field id="meter_number" translate="label" type="obscure" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Meter Number</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - </field> - <field id="key" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Key</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - </field> - <field id="password" translate="label" type="obscure" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Password</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - </field> - <field id="sandbox_mode" translate="label" type="select" sortOrder="75" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sandbox Mode</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="shipment_requesttype" translate="label" type="select" sortOrder="77" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Packages Request Type</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\AbstractCarrier\Source\Requesttype</source_model> - </field> - <field id="packaging" translate="label" type="select" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Packaging</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Fedex\Source\Packaging</source_model> - </field> - <field id="dropoff" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Dropoff</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Fedex\Source\Dropoff</source_model> - </field> - <field id="max_package_weight" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="handling_type" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Calculate Handling Fee</label> - <source_model>Magento\Shipping\Model\Source\HandlingType</source_model> - </field> - <field id="handling_action" translate="label" type="select" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Handling Applied</label> - <source_model>Magento\Shipping\Model\Source\HandlingAction</source_model> - </field> - <field id="handling_fee" translate="label" type="text" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Handling Fee</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="residence_delivery" translate="label" type="select" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Residential Delivery</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="allowed_methods" translate="label" type="multiselect" sortOrder="150" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Allowed Methods</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Fedex\Source\Method</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="smartpost_hubid" translate="label comment" type="text" sortOrder="155" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Hub ID</label> - <comment>The field is applicable if the Smart Post method is selected.</comment> - </field> - <field id="free_method" translate="label" type="select" sortOrder="160" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Method</label> - <frontend_class>free-method</frontend_class> - <source_model>Magento\Usa\Model\Shipping\Carrier\Fedex\Source\Freemethod</source_model> - </field> - <field id="free_shipping_enable" translate="label" type="select" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Shipping Amount Threshold</label> - <source_model>Magento\Backend\Model\Config\Source\Enabledisable</source_model> - </field> - <field id="free_shipping_subtotal" translate="label" type="text" sortOrder="180" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Shipping Amount Threshold</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="specificerrmsg" translate="label" type="textarea" sortOrder="190" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Displayed Error Message</label> - </field> - <field id="sallowspecific" translate="label" type="select" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Applicable Countries</label> - <frontend_class>shipping-applicable-country</frontend_class> - <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> - </field> - <field id="specificcountry" translate="label" type="multiselect" sortOrder="210" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Specific Countries</label> - <source_model>Magento\Directory\Model\Config\Source\Country</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="debug" translate="label" type="select" sortOrder="220" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Debug</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="showmethod" translate="label" type="select" sortOrder="230" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Show Method if Not Applicable</label> - <frontend_class>shipping-skip-hide</frontend_class> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="sort_order" translate="label" type="text" sortOrder="240" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sort Order</label> - </field> - </group> - <group id="ups" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>UPS</label> - <field id="access_license_number" translate="label" type="obscure" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Access License Number</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - </field> - <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enabled for Checkout</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="allowed_methods" translate="label" type="multiselect" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Allowed Methods</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Ups\Source\Method</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="shipment_requesttype" translate="label" type="select" sortOrder="47" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Packages Request Type</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\AbstractCarrier\Source\Requesttype</source_model> - </field> - <field id="container" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Container</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Ups\Source\Container</source_model> - </field> - <field id="free_shipping_enable" translate="label" type="select" sortOrder="210" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Shipping Amount Threshold</label> - <source_model>Magento\Backend\Model\Config\Source\Enabledisable</source_model> - </field> - <field id="free_shipping_subtotal" translate="label" type="text" sortOrder="220" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Shipping Amount Threshold</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="dest_type" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Destination Type</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Ups\Source\DestType</source_model> - </field> - <field id="free_method" translate="label" type="select" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Method</label> - <frontend_class>free-method</frontend_class> - <source_model>Magento\Usa\Model\Shipping\Carrier\Ups\Source\Freemethod</source_model> - </field> - <field id="gateway_url" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Gateway URL</label> - </field> - <field id="gateway_xml_url" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Gateway XML URL</label> - </field> - <field id="handling_type" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Calculate Handling Fee</label> - <source_model>Magento\Shipping\Model\Source\HandlingType</source_model> - </field> - <field id="handling_action" translate="label" type="select" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Handling Applied</label> - <source_model>Magento\Shipping\Model\Source\HandlingAction</source_model> - </field> - <field id="handling_fee" translate="label" type="text" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Handling Fee</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="max_package_weight" translate="label" type="text" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="min_package_weight" translate="label" type="text" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Minimum Package Weight (Please consult your shipping carrier for minimum supported shipping weight)</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="origin_shipment" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Origin of the Shipment</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Ups\Source\OriginShipment</source_model> - </field> - <field id="password" translate="label" type="obscure" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Password</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - </field> - <field id="pickup" translate="label" type="select" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Pickup Method</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Ups\Source\Pickup</source_model> - </field> - <field id="sort_order" translate="label" type="text" sortOrder="1000" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sort Order</label> - </field> - <field id="title" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Title</label> - </field> - <field id="tracking_xml_url" translate="label" type="text" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Tracking XML URL</label> - </field> - <field id="type" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>UPS Type</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Ups\Source\Type</source_model> - </field> - <field id="is_account_live" translate="label" type="select" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Live account</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="unit_of_measure" translate="label comment" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Weight Unit</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Ups\Source\Unitofmeasure</source_model> - </field> - <field id="username" translate="label" type="obscure" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>User ID</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - </field> - <field id="negotiated_active" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enable Negotiated Rates</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="shipper_number" translate="label comment" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Shipper Number</label> - <comment>Required for negotiated rates; 6-character UPS</comment> - </field> - <field id="sallowspecific" translate="label" type="select" sortOrder="900" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Applicable Countries</label> - <frontend_class>shipping-applicable-country</frontend_class> - <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> - </field> - <field id="specificcountry" translate="label" type="multiselect" sortOrder="910" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Specific Countries</label> - <source_model>Magento\Directory\Model\Config\Source\Country</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="showmethod" translate="label" type="select" sortOrder="920" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Show Method if Not Applicable</label> - <frontend_class>shipping-skip-hide</frontend_class> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="specificerrmsg" translate="label" type="textarea" sortOrder="800" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Displayed Error Message</label> - </field> - <field id="mode_xml" translate="label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Mode</label> - <comment>This enables or disables SSL verification of the Magento server by UPS.</comment> - <source_model>Magento\Usa\Model\Shipping\Carrier\AbstractCarrier\Source\Mode</source_model> - </field> - <field id="debug" translate="label" type="select" sortOrder="920" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Debug</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - </group> - <group id="usps" translate="label" type="text" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>USPS</label> - <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enabled for Checkout</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="gateway_url" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Gateway URL</label> - </field> - <field id="gateway_secure_url" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Secure Gateway URL</label> - </field> - <field id="title" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Title</label> - </field> - <field id="userid" translate="label" type="obscure" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>User ID</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - </field> - <field id="password" translate="label" type="obscure" sortOrder="53" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Password</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - </field> - <field id="mode" translate="label" type="select" sortOrder="54" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Mode</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\AbstractCarrier\Source\Mode</source_model> - </field> - <field id="shipment_requesttype" translate="label" type="select" sortOrder="55" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Packages Request Type</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\AbstractCarrier\Source\Requesttype</source_model> - </field> - <field id="container" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Container</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Usps\Source\Container</source_model> - </field> - <field id="size" translate="label" type="select" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Size</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Usps\Source\Size</source_model> - </field> - <field id="width" translate="label" type="text" sortOrder="73" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Width</label> - <depends> - <field id="size">LARGE</field> - </depends> - </field> - <field id="length" translate="label" type="text" sortOrder="72" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Length</label> - <depends> - <field id="size">LARGE</field> - </depends> - </field> - <field id="height" translate="label" type="text" sortOrder="74" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Height</label> - <depends> - <field id="size">LARGE</field> - </depends> - </field> - <field id="girth" translate="label" type="text" sortOrder="76" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Girth</label> - <depends> - <field id="size">LARGE</field> - </depends> - </field> - <field id="machinable" translate="label" type="select" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Machinable</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Usps\Source\Machinable</source_model> - </field> - <field id="max_package_weight" translate="label" type="text" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="handling_type" translate="label" type="select" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Calculate Handling Fee</label> - <source_model>Magento\Shipping\Model\Source\HandlingType</source_model> - </field> - <field id="handling_action" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Handling Applied</label> - <source_model>Magento\Shipping\Model\Source\HandlingAction</source_model> - </field> - <field id="handling_fee" translate="label" type="text" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Handling Fee</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="allowed_methods" translate="label" type="multiselect" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Allowed Methods</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Usps\Source\Method</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="free_method" translate="label" type="select" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Method</label> - <frontend_class>free-method</frontend_class> - <source_model>Magento\Usa\Model\Shipping\Carrier\Usps\Source\Freemethod</source_model> - </field> - <field id="free_shipping_enable" translate="label" type="select" sortOrder="1500" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Shipping Amount Threshold</label> - <source_model>Magento\Backend\Model\Config\Source\Enabledisable</source_model> - </field> - <field id="free_shipping_subtotal" translate="label" type="text" sortOrder="160" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Shipping Amount Threshold</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="specificerrmsg" translate="label" type="textarea" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Displayed Error Message</label> - </field> - <field id="sallowspecific" translate="label" type="select" sortOrder="180" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Applicable Countries</label> - <frontend_class>shipping-applicable-country</frontend_class> - <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> - </field> - <field id="specificcountry" translate="label" type="multiselect" sortOrder="190" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Specific Countries</label> - <source_model>Magento\Directory\Model\Config\Source\Country</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="debug" translate="label" type="select" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Debug</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="showmethod" translate="label" type="select" sortOrder="210" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Show Method if Not Applicable</label> - <frontend_class>shipping-skip-hide</frontend_class> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="sort_order" translate="label" type="text" sortOrder="220" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sort Order</label> - </field> - </group> - <group id="dhlint" translate="label" type="text" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>DHL</label> - <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enabled for Checkout</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="gateway_url" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Gateway URL</label> - </field> - <field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Title</label> - </field> - <field id="id" translate="label" type="obscure" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Access ID</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - </field> - <field id="password" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Password</label> - <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> - </field> - <field id="account" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Account Number</label> - </field> - <field id="content_type" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Content Type</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Contenttype</source_model> - </field> - <field id="handling_type" translate="label" type="select" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Calculate Handling Fee</label> - <source_model>Magento\Shipping\Model\Source\HandlingType</source_model> - </field> - <field id="handling_action" translate="label comment" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Handling Applied</label> - <comment>"Per Order" allows a single handling fee for the entire order. "Per Package" allows an individual handling fee for each package.</comment> - <source_model>Magento\Shipping\Model\Source\HandlingAction</source_model> - </field> - <field id="handling_fee" translate="label" type="text" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Handling Fee</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="divide_order_weight" translate="label comment" type="select" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Divide Order Weight</label> - <comment>This allows breaking total order weight into smaller pieces if it exeeds 70 kg to ensure accurate calculation of shipping charges.</comment> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="unit_of_measure" translate="label" type="select" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Weight Unit</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Unitofmeasure</source_model> - <frontend_model>Magento\Usa\Block\Adminhtml\Dhl\Unitofmeasure</frontend_model> - </field> - <field id="size" translate="label" type="select" sortOrder="150" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Size</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Size</source_model> - </field> - <field id="height" translate="label" type="text" sortOrder="151" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Height</label> - <depends> - <field id="size">1</field> - </depends> - </field> - <field id="depth" translate="label" type="text" sortOrder="152" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Depth</label> - <depends> - <field id="size">1</field> - </depends> - </field> - <field id="width" translate="label" type="text" sortOrder="153" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Width</label> - <depends> - <field id="size">1</field> - </depends> - </field> - <field id="doc_methods" translate="label" type="multiselect" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Allowed Methods</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Doc</source_model> - <depends> - <field id="content_type">D</field> - </depends> - </field> - <field id="nondoc_methods" translate="label" type="multiselect" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Allowed Methods</label> - <source_model>Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Nondoc</source_model> - <depends> - <field id="content_type">N</field> - </depends> - </field> - <field id="ready_time" type="text" sortOrder="180" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ready time</label> - <comment>Package ready time after order submission (in hours)</comment> - </field> - <field id="specificerrmsg" translate="label" type="textarea" sortOrder="800" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Displayed Error Message</label> - </field> - <field id="free_method_doc" translate="label" type="select" sortOrder="1200" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Method</label> - <frontend_class>free-method</frontend_class> - <source_model>Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Freedoc</source_model> - <depends> - <field id="content_type">D</field> - </depends> - </field> - <field id="free_method_nondoc" translate="label" type="select" sortOrder="1200" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Method</label> - <frontend_class>free-method</frontend_class> - <source_model>Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Freenondoc</source_model> - <depends> - <field id="content_type">N</field> - </depends> - </field> - <field id="free_shipping_enable" translate="label" type="select" sortOrder="1210" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Shipping Amount Threshold</label> - <source_model>Magento\Backend\Model\Config\Source\Enabledisable</source_model> - </field> - <field id="free_shipping_subtotal" translate="label" type="text" sortOrder="1220" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Free Shipping Amount Threshold</label> - <validate>validate-number validate-zero-or-greater</validate> - </field> - <field id="sallowspecific" translate="label" type="select" sortOrder="1900" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Applicable Countries</label> - <frontend_class>shipping-applicable-country</frontend_class> - <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> - </field> - <field id="specificcountry" translate="label" type="multiselect" sortOrder="1910" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Ship to Specific Countries</label> - <source_model>Magento\Directory\Model\Config\Source\Country</source_model> - <can_be_empty>1</can_be_empty> - </field> - <field id="showmethod" translate="label" type="select" sortOrder="1940" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Show Method if Not Applicable</label> - <frontend_class>shipping-skip-hide</frontend_class> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - <field id="sort_order" translate="label" type="text" sortOrder="2000" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Sort Order</label> - </field> - <field id="debug" translate="label" type="select" sortOrder="1950" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Debug</label> - <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> - </field> - </group> - </section> - </system> -</config> diff --git a/app/code/Magento/Usa/etc/config.xml b/app/code/Magento/Usa/etc/config.xml deleted file mode 100644 index 0967adce90e..00000000000 --- a/app/code/Magento/Usa/etc/config.xml +++ /dev/null @@ -1,164 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Usa - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> -<config> - <default> - <system> - <media_storage_configuration> - <allowed_resources> - <dhl_folder>dhl</dhl_folder> - </allowed_resources> - </media_storage_configuration> - </system> - <carriers> - <dhl> - <account /> - <active>0</active> - <sallowspecific>0</sallowspecific> - <allowed_methods>IE,E SAT,E 10:30AM,E,N,S,G</allowed_methods> - <contentdesc>Big Box</contentdesc> - <cutoff_cost /> - <dutypaymenttype>R</dutypaymenttype> - <free_method>G</free_method> - <gateway_url>https://eCommerce.airborne.com/ApiLandingTest.asp</gateway_url> - <id backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <model>Magento\Usa\Model\Shipping\Carrier\Dhl</model> - <password backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <shipment_requesttype>0</shipment_requesttype> - <shipment_type>P</shipment_type> - <shipping_key backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <shipping_intlkey backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <title>DHL (Deprecated)</title> - <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg> - <max_package_weight>150</max_package_weight> - <handling_type>F</handling_type> - <handling_action>O</handling_action> - <shipment_days>Mon,Tue,Wed,Thu,Fri,Sat</shipment_days> - <intl_shipment_days>Mon,Tue,Wed,Thu,Fri</intl_shipment_days> - <additional_protection_rounding>0</additional_protection_rounding> - </dhl> - <fedex> - <account backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <meter_number backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <key backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <password backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <sandbox_mode>0</sandbox_mode> - <shipment_requesttype>0</shipment_requesttype> - <active>0</active> - <sallowspecific>0</sallowspecific> - <allowed_methods>EUROPE_FIRST_INTERNATIONAL_PRIORITY,FEDEX_1_DAY_FREIGHT,FEDEX_2_DAY_FREIGHT,FEDEX_2_DAY,FEDEX_2_DAY_AM,FEDEX_3_DAY_FREIGHT,FEDEX_EXPRESS_SAVER,FEDEX_GROUND,FIRST_OVERNIGHT,GROUND_HOME_DELIVERY,INTERNATIONAL_ECONOMY,INTERNATIONAL_ECONOMY_FREIGHT,INTERNATIONAL_FIRST,INTERNATIONAL_GROUND,INTERNATIONAL_PRIORITY,INTERNATIONAL_PRIORITY_FREIGHT,PRIORITY_OVERNIGHT,SMART_POST,STANDARD_OVERNIGHT,FEDEX_FREIGHT,FEDEX_NATIONAL_FREIGHT</allowed_methods> - <cutoff_cost /> - <dropoff>REGULAR_PICKUP</dropoff> - <free_method>FEDEX_GROUND</free_method> - <handling>0</handling> - <model>Magento\Usa\Model\Shipping\Carrier\Fedex</model> - <packaging>YOUR_PACKAGING</packaging> - <title>Federal Express</title> - <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg> - <max_package_weight>150</max_package_weight> - <handling_type>F</handling_type> - <handling_action>O</handling_action> - </fedex> - <ups> - <access_license_number backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <active>0</active> - <sallowspecific>0</sallowspecific> - <allowed_methods>1DM,1DML,1DA,1DAL,1DAPI,1DP,1DPL,2DM,2DML,2DA,2DAL,3DS,GND,GNDCOM,GNDRES,STD,XPR,WXS,XPRL,XDM,XDML,XPD,01,02,03,07,08,11,12,14,54,59,65</allowed_methods> - <origin_shipment>Shipments Originating in United States</origin_shipment> - <shipment_requesttype>0</shipment_requesttype> - <container>CP</container> - <cutoff_cost /> - <dest_type>RES</dest_type> - <free_method>GND</free_method> - <gateway_url>http://www.ups.com/using/services/rave/qcostcgi.cgi</gateway_url> - <gateway_xml_url>https://onlinetools.ups.com/ups.app/xml/Rate</gateway_xml_url> - <handling>0</handling> - <model>Magento\Usa\Model\Shipping\Carrier\Ups</model> - <pickup>CC</pickup> - <title>United Parcel Service</title> - <tracking_xml_url>https://www.ups.com/ups.app/xml/Track</tracking_xml_url> - <unit_of_measure>LBS</unit_of_measure> - <username backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <password backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg> - <min_package_weight>0.1</min_package_weight> - <max_package_weight>150</max_package_weight> - <handling_type>F</handling_type> - <handling_action>O</handling_action> - <negotiated_active>0</negotiated_active> - <mode_xml>1</mode_xml> - <type>UPS</type> - <is_account_live>0</is_account_live> - </ups> - <usps> - <active>0</active> - <sallowspecific>0</sallowspecific> - <allowed_methods>0_FCLE,0_FCL,0_FCP,1,2,3,4,6,7,13,16,17,22,23,25,27,28,33,34,35,36,37,42,43,53,55,56,57,61,INT_1,INT_2,INT_4,INT_6,INT_7,INT_8,INT_9,INT_10,INT_11,INT_12,INT_13,INT_14,INT_15,INT_16,INT_20,INT_26</allowed_methods> - <container>VARIABLE</container> - <cutoff_cost /> - <free_method /> - <gateway_url>http://production.shippingapis.com/ShippingAPI.dll</gateway_url> - <gateway_secure_url>https://secure.shippingapis.com/ShippingAPI.dll</gateway_secure_url> - <shipment_requesttype>0</shipment_requesttype> - <handling /> - <machinable>true</machinable> - <methods></methods> - <model>Magento\Usa\Model\Shipping\Carrier\Usps</model> - <size>REGULAR</size> - <title>United States Postal Service</title> - <userid backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <password backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <isproduction>0</isproduction> - <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg> - <max_package_weight>70</max_package_weight> - <handling_type>F</handling_type> - <handling_action>O</handling_action> - </usps> - <dhlint> - <model>Magento\Usa\Model\Shipping\Carrier\Dhl\International</model> - <account /> - <active>0</active> - <title>DHL</title> - <sallowspecific>0</sallowspecific> - <nondoc_methods>1,3,4,8,P,Q,E,F,H,J,M,V,Y</nondoc_methods> - <doc_methods>2,5,6,7,9,B,C,D,U,K,L,G,W,I,N,O,R,S,T,X</doc_methods> - <free_method>G</free_method> - <gateway_url>https://xmlpi-ea.dhl.com/XMLShippingServlet</gateway_url> - <id backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <password backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> - <content_type>N</content_type> - <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg> - <divide_order_weight>1</divide_order_weight> - <unit_of_measure>K</unit_of_measure> - <size>R</size> - <handling_type>F</handling_type> - <handling_action>O</handling_action> - <shipment_days>Mon,Tue,Wed,Thu,Fri</shipment_days> - </dhlint> - </carriers> - </default> -</config> diff --git a/app/code/Magento/Usa/i18n/de_DE.csv b/app/code/Magento/Usa/i18n/de_DE.csv deleted file mode 100644 index a6e531dc838..00000000000 --- a/app/code/Magento/Usa/i18n/de_DE.csv +++ /dev/null @@ -1,296 +0,0 @@ -" was not delivered nor scanned","wurde weder zugestellt noch eingescannt" -"""Per Order"" allows single handling fee for entire order. ""Per Package"" allows individual handling fee for each package.","""Pro Bestellung"" bedeutet einzelne Bearbeitungsgebühr für die gesamte Bestellung. ""Pro Paket"" bedeutet individuelle Bearbeitungsgebühr für jedes Paket." -"1 Day Freight","1-Tag Fracht" -"2 Day","2 Tage" -"2 Day Freight","2-Tage-Fracht" -"2Day","2 Tage" -"2nd Day Air","2. Tag Luftpost" -"2nd Day Air AM","2. Tag Luftpost vormittags" -"2nd Day Air AM Letter","2. Tag Luftpost vormittags Briefsendung" -"2nd Day Air Letter","2. Tag Luftpost Briefsendung" -"3 Day Freight","3-Tage-Fracht" -"3 Day Select","3-Tage-Select" -"Access ID","Zugangsnummer" -"Access License Number","Zugangslizenznummer" -"Account ID","Kundenkonto-ID" -"Account Number","Kundenkontonummer" -"Additional Protection Configuration Value","Zusätzliche Absicherung Konfigurationswert" -"Additional Protection Enabled","Zusätzliche Absicherung aktiviert" -"Additional Protection Min Subtotal","Zusätzliche Absicherung Mindestzwischensumme" -"Additional Protection Value","Zusätzliche Absicherung Wert" -"Additional Protection Value Rounding Method","Zusätzliche Absicherung Rundungsmethode für den Wert" -"Adult","Erwachsener" -"Adult Signature Required","Unterschrift eines Erwachsenen erforderlich" -"Allowed Methods","Erlaubte Mittel" -"Allows breaking total order weight into smaller pieces if it exeeds %s %s to ensure accurate calculation of shipping charges.","Das Gewicht der Gesamtbestellung kann in kleinere Stücke geteilt werden, wenn es %s %s überschreitet, um genaue Berechnung der Versandkosten zu gewährleisten." -"Allows breaking total order weight into smaller pieces if it exeeds 70 kg to ensure accurate calculation of shipping charges.","Das Gewicht der Gesamtbestellung kann in kleinere Stücke geteilt werden, wenn es 70 kg überschreitet, um genaue Berechnung der Versandkosten zu gewährleisten." -"Bound Printed Matter","Gebundene Drucksache" -"Break bulk economy","Sperrgut-Economy" -"Break bulk express","Sperrgut-Express" -"Business Service Center","Geschäftskundenservicezentrum" -"Calculate Handling Fee","Bearbeitungsgebühr berechnen" -"Canada Standard","Kanada Standard" -"Cannot identify measure unit for %s","Maßeinheit für %s kann nicht identifiziert werden" -"Cannot identify weight unit for %s","Gewichtseinheit für %s kann nicht identifiziert werden." -"Cannot retrieve shipping rates","Versandkosten konnten nicht abgerufen werden." -"Centimeters","Zentimeter" -"Commercial","Kommerziell" -"Configuration","Konfiguration" -"Container","Container" -"Content Type","Art des Inhaltes" -"Customer Packaging","Kundenverpackung" -"Customer Supplied Package","Vom Kunden geliefertes Paket" -"Customer services","Kundenservice" -"DHL","DHL" -"DHL (Deprecated)","DHL (veraltet)" -"Debug","Debug" -"Default Package Height","Standard Verpackungshöhe" -"Default Package Length","Standard Verpackungslänge" -"Default Package Width","Standard Verpackungsbreite" -"Delivered","Zugestellt" -"Delivery Confirmation","Lieferbestätigung" -"Depth","Tiefe" -"Destination Type","Zieltyp" -"Destination facility code is empty","Ziel Einrichtungscode ist leer" -"Development","Entwicklung" -"Direct","Direkt" -"Displayed Error Message","Angezeigte Fehlermeldung" -"Divide Order Weight","Teilen Sie das Bestellgewicht" -"Documents","Dokumente" -"Domestic Shipment Days","Versandtage im Inland" -"Domestic economy select","Auswahl heimische Wirtschaft" -"Domestic express","Inland Express" -"Drop Box","Briefkasten" -"Dropoff","Einwurf" -"Easy shop","Katalog" -"Economy select","Auswahl Wirtschaft" -"Empty response","Leere Rückmeldung" -"Enable Negotiated Rates","Vereinbarte Kosten aktivieren" -"Enabled for Checkout","Fertig zum Checkout" -"Enables/Disables SSL verification of Magento server by UPS.","Aktiviert/Deaktiviert die SSL-Überprüfung des Magneto Servers von UPS." -"Error #%s : %s","Fehler #%s : %s" -"Error #%s : %s (%s)","Fehler #%s: %s (%s)" -"Error #%s: %s","Fehler #%s: %s (%s)" -"Europack","Europack" -"Europe First Priority","Europa Höchste Priorität (Europe First Priority)" -"Exchange rate %s (Base Currency) -> %s not found. DHL method %s skipped","Umtauschkurs %s (Basiswährung) -> %s nicht gefunden. DHL-Methode %s übersprungen" -"Express","Express" -"Express 10:30","Express 10:30" -"Express 10:30 AM","Express bis 10:30 Uhr" -"Express 12:00","Express 12:00" -"Express 9:00","Express 9:00" -"Express Mail","Express-Sendung" -"Express Saturday","Express-Samstagszustellung" -"Express Saver","Express-Saver" -"Express easy","Express easy" -"Express envelope","Express-Umschlag" -"Express worldwide","Express Weltweit" -"Failed to parse xml document: %s","Konnte das XML-Dokument nicht analysieren: %s" -"FedEx","FedEx" -"FedEx 10kg Box","FedEx 10kg Box" -"FedEx 25kg Box","FedEx 25kg Box" -"FedEx Box","FedEx Box" -"FedEx Envelope","FedEx Brief (FedEx Envelope)" -"FedEx Pak","FedEx Paket (FedEx Pak)" -"FedEx Tube","FedEx Röhre (FedEx Tube)" -"First Overnight","Erste Klasse Übernacht-Service (First Overnight)" -"First-Class","Erste Klasse (First-Class)" -"Flat","Einheitstarif (Flat)" -"Flat-Rate Box","Flatrate Box" -"Flat-Rate Envelope","Flatrate Envelope" -"Free Method","Kostenloses Mittel" -"Free Shipping with Minimum Order Amount","Kostenloser Versand dank Mindestsumme der Bestellung" -"Freight","Fracht" -"Freight worldwide","Fracht Weltweit" -"Gateway URL","Gateway URL" -"Gateway XML URL","Gateway XML URL" -"Gift","Geschenk" -"Girth","Umfang" -"Globalmail business","Globalmail Business" -"Ground","Ground" -"Ground Commercial","Ground Commercial" -"Ground Residential","Ground Commercial" -"Handling Applied","Hinzugefügte Bearbeitungsgebühren" -"Handling Fee","Bearbeitungsgebühren" -"Height","Höhe" -"Height, width and length should be equal or greater than %s","Höhe, Breite und Tiefe sollten gleich oder größer als %s sein" -"Home Delivery","Lieferung frei Haus" -"Inches","Zoll" -"Indirect","Indirekt" -"International Economy","International Economy" -"International Express","International Express" -"International First","International Erste Klasse (International First)" -"International Ground","International Landweg" -"International Priority","International Priorität (International Priority)" -"International Shipment Days","International Versandtage" -"Intl Economy Freight","International Economy Fracht" -"Intl Priority Freight","International Priority Fracht" -"Jetline","Jetline" -"Jumbo box","Jumbo Box" -"Key","Schlüssel" -"Kilograms","Kilogramm" -"Large","Groß" -"Large Express Box","Große Expressbox" -"Length","Länge" -"Letter","Brief" -"Library","Sammlung" -"Live","Live" -"Machinable","Maschinell bearbeitbar" -"Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)","Höchstgewicht pro Sendung (Bitte fragen Sie Ihren Versanddienstleister nach dem Höchstgewicht der Sendung.)" -"Media Mail","Media Mail" -"Medical express","Medikamente Express" -"Medium Express Box","Mittlere Expressbox" -"Merchandise","Trikots" -"Meter Number","Anzahl Meter" -"Minimum Order Amount for Free Shipping","Mindestbestellmenge für kostenlosen Versand." -"Minimum Package Weight (Please consult your shipping carrier for minimum supported shipping weight)","Mindestgewicht der Verpackung (bitte wenden Sie sich an Ihren Frachtführer, um das zulässige Mindestgewicht der Verpackung zu erfragen)" -"Mode","Modus" -"National Freight","Nationale Fracht" -"Next Afternoon","Am nächsten Nachmittag" -"Next Day Air","Am nächsten Tag per Luftpost" -"Next Day Air Early AM","Am nächsten Tag per Luftpost am frühen Vormittag" -"Next Day Air Early AM Letter","Am nächsten Tag per Luftbrief am frühen Vormittag" -"Next Day Air Intra (Puerto Rico)","Am nächsten Tag per Inlands-Luftpost (Puerto Rico)" -"Next Day Air Letter","Am nächsten Tag per Luftbrief" -"Next Day Air Saver","Am nächsten Tag per Air Saver" -"Next Day Air Saver Letter","Am nächsten Tag per Air Saver Brief" -"No","Nein" -"No packages for request","Keine Sendungen angefordert" -"Non Documents","Keine Dokumente" -"Non documents","Keine Dokumente" -"Non-rectangular","Nicht rechteckig" -"None","Keins" -"Not Required","Nicht erforderlich" -"Order","Bestellung" -"Origin of the Shipment","Herkunftsort der Sendung" -"Origin serviceAreaCode is missing","Ursprungsservice AreaCode fehlt" -"Other","Sonstige" -"Others","Anderes" -"PAK","PAK" -"Package","Verpackung" -"Package Description","Beschreibung der Verpackung" -"Packages Request Type","Pakete-Anforderungstyp" -"Packaging","Verpackungsmaterial" -"Pallet","Strohsack" -"Parcel","Paket" -"Parcel Post","Paketpost" -"Password","Passwort" -"Pickup Method","Abholmethode" -"Piece Id barcode is missing","Stück ID Barcode fehlt" -"Piece number information is missing","Information zur Stückzahl fehlt" -"Please make sure to use only digits here. No dashes are allowed.","Bitte geben Sie hier nur Ziffern ein. Striche sind unzulässig." -"Pounds","Pfund" -"Priority Mail","Eilpost" -"Priority Overnight","Eilpost Übernacht" -"Product content code is invalid","Produkt-Inhaltscode ist ungültig" -"Product name is missing","Produktname fehlt" -"Receiver","Empfänger" -"Rectangular","Rechteckig" -"Regular","Regulär" -"Regular Pickup","Reguläre Abholung" -"Request Courier","Kurier anfordern" -"Required","Erforderlich" -"Required for negotiated rates; 6-character UPS.","Für vereinbarte Raten erforderlich; 6-Buchstaben UPS" -"Residential","Stationär" -"Residential Delivery","Lieferung an den stationären Wohnsitz" -"Response is in the wrong format","Antwort im falschen Format" -"Return","Retoure / Rücksendung" -"Round","Rund" -"Routing barcode is missing","Routen-Barcode fehlt" -"Same day","Am selben Tag" -"Sample","Beispiel" -"Sandbox Mode","Sandkasten-Modus" -"Second Day Service","Lieferung am zweiten Tag" -"Secure Gateway URL","Sichere Eingangs-URL" -"Secureline","Secureline" -"Sender","Absender" -"Sender city info is missing","Stadtinformation Absender fehlt" -"Sender contact name is missing","Kontaktname Absender fehlt" -"Sender country info is missing","Information Absenderland fehlt" -"Service type does not match","Service-Typ stimmt nicht überein" -"Ship to Applicable Countries","Versand in zutreffende Länder" -"Ship to Specific Countries","Versand in angegebene Länder" -"Shipment Contains Hazardous Materials","Sendung enthält gefährliche Substanzen" -"Shipment Dutiable","Sendung zollpflichtig" -"Shipment Duty Payment Type","Versand Zoll Zahlungstyp" -"Shipment Type","Versandtyp" -"Shipment is not available.","Versand nicht verfügbar." -"Shipment picked up","Sendung abgeholt" -"Shipper Number","Nummer des Spediteurs" -"Shipping Key","Sendungsnummer" -"Shipping Key (International)","Sendungsnummer (International)" -"Show Method if Not Applicable","Wenn nicht anwendbar, Verfahren anzeigen" -"Signature Required","Unterschrift erforderlich" -"Size","Grösse" -"Small Express Box","Kleine Express Box" -"Smart Post","Smart Post" -"Sort Order","Sortierreihenfolge" -"Specific","Spezifik" -"Sprintline","Sprintline" -"Standard Overnight","Standard über Nacht" -"Station","Station" -"Subtotal","Zwischensumme" -"Subtotal With Discount","Zwischensumme mit Preisnachlass" -"The response is in wrong format.","Die Antwort hat ein falsches Format" -"There is no available method for selected shipping address.","Für die ausgewählte Methode ist keine Versandadresse verfügbar" -"There is no items in this order","Es gibt keine Artikel in dieser Bestellung" -"Third Party","Dritte Person" -"Title","Titel" -"To Lower","herabsetzen" -"To Upper","hochsetzen" -"Tracking XML URL","Nachverfolgung XML URL" -"UPS","UPS" -"UPS Expedited","UPS Expeditiert" -"UPS Express","UPS Express" -"UPS Express Box","UPS Express Box" -"UPS Express Early A.M.","UPS Express in der Frühe" -"UPS Express Plus","USP Express Plus" -"UPS Ground","UPS Boden" -"UPS Letter Envelope","UPS Briefumschlag" -"UPS Next Day Air","UPS Luftfracht am Folgetag" -"UPS Next Day Air Early A.M.","UPS Luftfracht am frühen Morgen des nächsten Tages" -"UPS Next Day Air Saver","UPS Luftfracht Absicherung am Folgetag" -"UPS Saver","UPS Absicherung" -"UPS Second Day Air","UPS Luftfracht am zweiten Tag" -"UPS Second Day Air A.M.","UPS Luftfracht am zweiten Tag Früh" -"UPS Standard","UPS Standard" -"UPS Three-Day Select","UPS Drei Tage Auswahl" -"UPS Today Dedicated Courrier","UPS Heute bestimmter Courrier" -"UPS Today Express","UPS Heute Epress" -"UPS Today Express Saver","UPS Heute Express Absicherung" -"UPS Today Intercity","UPS Heute Intercity" -"UPS Today Standard","UPS Heute Standard" -"UPS Tube","UPS Untergrundbahn" -"UPS Type","UPS Typ" -"UPS Worldwide 10 kilo","UPS Weltweit 10 Kilogramm" -"UPS Worldwide 25 kilo","UPS Weltweit 25 Kilogramm" -"UPS Worldwide Expedited","UPS Weltweit Epeditiert" -"UPS Worldwide Express","UPS Weltweit Express" -"UPS Worldwide Express Plus","UPS Weltweit Express Plus" -"UPS Worldwide Express PlusSM","UPS Weltweit Express PlusSM" -"UPS Worldwide Saver","UPS Weltweit Spar" -"USPS","USPS" -"Unable to retrieve tracking","Nachverfolgung kann nicht abgerufen werden" -"United Parcel Service","United Parcel Service" -"United Parcel Service XML","United Parcel Service XML" -"Unknown error","Unbekannter Fehler" -"Used only when ""Additional Protection Value"" is set to ""Configuration"". Can contain only numeric amount.","Nur wenn ""Wert des zusätzlichen Schutzes"" auf ""Konfigurieren"" eingestellt ist. Darf nur Zahlenwert enthalten." -"User ID","Benutzerkennung" -"Variable","Variable" -"Waybill barcode information is missing","Frachtbrief Barcodeinformation fehlt" -"Weight Unit","Gewichtseinheit" -"Weight unit is invalid","Gewichtseinheit ist ungültig" -"Width","Breite" -"Worldwide Expedited","Weltweit Expediert" -"Worldwide Express","Weltweit Express" -"Worldwide Express Letter","Weltweit Expressbrief" -"Worldwide Express Plus","Weltweit Express Plus" -"Worldwide Express Plus Letter","Weltweit Express Plus Brief" -"Worldwide Express Saver","Weltweit Express Absicherung" -"Wrong Content Type.","Falscher Inhaltstyp." -"Wrong Region.","Falsche Region." -"Yes","Ja" -"Your Packaging","Ihre Verpackung" -"Zero shipping charge for '%s'","Null Versandkosten für '%s'" -"cm","cm" -"inch","Inch" diff --git a/app/code/Magento/Usa/i18n/en_US.csv b/app/code/Magento/Usa/i18n/en_US.csv deleted file mode 100644 index 85c6c163a17..00000000000 --- a/app/code/Magento/Usa/i18n/en_US.csv +++ /dev/null @@ -1,381 +0,0 @@ -" was not delivered nor scanned"," was not delivered nor scanned" -"""Per Order"" allows single handling fee for entire order. ""Per Package"" allows individual handling fee for each package.","""Per Order"" allows single handling fee for entire order. ""Per Package"" allows individual handling fee for each package." -"1 Day Freight","1 Day Freight" -"2 Day","2 Day" -"2 Day AM","2 Day AM" -"2 Day Freight","2 Day Freight" -"2Day","2Day" -"2nd Day Air","2nd Day Air" -"2nd Day Air AM","2nd Day Air AM" -"2nd Day Air AM Letter","2nd Day Air AM Letter" -"2nd Day Air Letter","2nd Day Air Letter" -"3 Day Freight","3 Day Freight" -"3 Day Select","3 Day Select" -"Access ID","Access ID" -"Access License Number","Access License Number" -"Account ID","Account ID" -"Account Number","Account Number" -"Additional Protection Configuration Value","Additional Protection Configuration Value" -"Additional Protection Enabled","Additional Protection Enabled" -"Additional Protection Min Subtotal","Additional Protection Min Subtotal" -"Additional Protection Value","Additional Protection Value" -"Additional Protection Value Rounding Method","Additional Protection Value Rounding Method" -"Adult","Adult" -"Adult Signature Required","Adult Signature Required" -"Allowed Methods","Allowed Methods" -"Allows breaking total order weight into smaller pieces if it exeeds %s %s to ensure accurate calculation of shipping charges.","Allows breaking total order weight into smaller pieces if it exeeds %s %s to ensure accurate calculation of shipping charges." -"Allows breaking total order weight into smaller pieces if it exeeds 70 kg to ensure accurate calculation of shipping charges.","Allows breaking total order weight into smaller pieces if it exeeds 70 kg to ensure accurate calculation of shipping charges." -"Bound Printed Matter","Bound Printed Matter" -"Break bulk economy","Break bulk economy" -"Break bulk express","Break bulk express" -"Business Service Center","Business Service Center" -"Calculate Handling Fee","Calculate Handling Fee" -"Canada Standard","Canada Standard" -"Cannot identify measure unit for %s","Cannot identify measure unit for %s" -"Cannot identify weight unit for %s","Cannot identify weight unit for %s" -"Cannot retrieve shipping rates","Cannot retrieve shipping rates" -"Centimeters","Centimeters" -"Commercial","Commercial" -"Configuration","Configuration" -"Container","Container" -"Content Type","Content Type" -"Customer Packaging","Customer Packaging" -"Customer Supplied Package","Customer Supplied Package" -"Customer services","Customer services" -"DHL","DHL" -"DHL (Deprecated)","DHL (Deprecated)" -"DHL service is not available at %s date","DHL service is not available at %s date" -"Debug","Debug" -"Default Package Height","Default Package Height" -"Default Package Length","Default Package Length" -"Default Package Width","Default Package Width" -"Delivered","Delivered" -"Delivery Confirmation","Delivery Confirmation" -"Depth","Depth" -"Destination Type","Destination Type" -"Destination facility code is empty","Destination facility code is empty" -"Development","Development" -"Direct","Direct" -"Displayed Error Message","Displayed Error Message" -"Divide Order Weight","Divide Order Weight" -"Documents","Documents" -"Domestic Shipment Days","Domestic Shipment Days" -"Domestic economy select","Domestic economy select" -"Domestic express","Domestic express" -"Drop Box","Drop Box" -"Dropoff","Dropoff" -"Easy shop","Easy shop" -"Economy select","Economy select" -"Empty response","Empty response" -"Enable Negotiated Rates","Enable Negotiated Rates" -"Enabled for Checkout","Enabled for Checkout" -"Enables/Disables SSL verification of Magento server by UPS.","Enables/Disables SSL verification of Magento server by UPS." -"Error #%s : %s","Error #%s : %s" -"Error #%s : %s (%s)","Error #%s : %s (%s)" -"Error #%s: %s","Error #%s: %s" -"Europack","Europack" -"Europe First Priority","Europe First Priority" -"Exchange rate %s (Base Currency) -> %s not found. DHL method %s skipped","Exchange rate %s (Base Currency) -> %s not found. DHL method %s skipped" -"Express","Express" -"Express 10:30","Express 10:30" -"Express 10:30 AM","Express 10:30 AM" -"Express 12:00","Express 12:00" -"Express 9:00","Express 9:00" -"Express Mail","Express Mail" -"Express Saturday","Express Saturday" -"Express Saver","Express Saver" -"Express easy","Express easy" -"Express envelope","Express envelope" -"Express worldwide","Express worldwide" -"Failed to parse xml document: %s","Failed to parse xml document: %s" -"FedEx","FedEx" -"FedEx 10kg Box","FedEx 10kg Box" -"FedEx 25kg Box","FedEx 25kg Box" -"FedEx Box","FedEx Box" -"FedEx Envelope","FedEx Envelope" -"FedEx Pak","FedEx Pak" -"FedEx Tube","FedEx Tube" -"First Overnight","First Overnight" -"First-Class","First-Class" -"First-Class Mail International Large Envelope","First-Class Mail International Large Envelope" -"First-Class Mail International Letter","First-Class Mail International Letter" -"First-Class Mail International Postcard","First-Class Mail International Postcard" -"First-Class Mail Large Envelope","First-Class Mail Large Envelope" -"First-Class Mail Large Postcards","First-Class Mail Large Postcards" -"First-Class Mail Letter","First-Class Mail Letter" -"First-Class Mail Parcel","First-Class Mail Parcel" -"First-Class Mail Postcards","First-Class Mail Postcards" -"First-Class Package International Service","First-Class Package International Service" -"First-Class Package Service","First-Class Package Service" -"First-Class Package Service Hold For Pickup","First-Class Package Service Hold For Pickup" -"Flat","Flat" -"Flat-Rate Box","Flat-Rate Box" -"Flat-Rate Envelope","Flat-Rate Envelope" -"Free Method","Free Method" -"Free Shipping with Minimum Order Amount","Free Shipping with Minimum Order Amount" -"Freight","Freight" -"Freight worldwide","Freight worldwide" -"Gateway URL","Gateway URL" -"Gateway XML URL","Gateway XML URL" -"Gift","Gift" -"Girth","Girth" -"Global Express Guaranteed (GXG)","Global Express Guaranteed (GXG)" -"Global Express Guaranteed Document","Global Express Guaranteed Document" -"Global Express Guaranteed Non-Document Non-Rectangular","Global Express Guaranteed Non-Document Non-Rectangular" -"Global Express Guaranteed Non-Document Rectangular","Global Express Guaranteed Non-Document Rectangular" -"Globalmail business","Globalmail business" -"Ground","Ground" -"Ground Commercial","Ground Commercial" -"Ground Residential","Ground Residential" -"Handling Applied","Handling Applied" -"Handling Fee","Handling Fee" -"Height","Height" -"Height, width and length should be equal or greater than %s","Height, width and length should be equal or greater than %s" -"Home Delivery","Home Delivery" -"Hub ID","Hub ID" -"Inches","Inches" -"Indirect","Indirect" -"International Economy","International Economy" -"International Express","International Express" -"International First","International First" -"International Ground","International Ground" -"International Priority","International Priority" -"International Shipment Days","International Shipment Days" -"Intl Economy Freight","Intl Economy Freight" -"Intl Priority Freight","Intl Priority Freight" -"Jetline","Jetline" -"Jumbo box","Jumbo box" -"Key","Key" -"Kilograms","Kilograms" -"Large","Large" -"Large Express Box","Large Express Box" -"Length","Length" -"Letter","Letter" -"Library","Library" -"Library Mail","Library Mail" -"Live","Live" -"Machinable","Machinable" -"Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)","Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)" -"Media Mail","Media Mail" -"Medical express","Medical express" -"Medium Express Box","Medium Express Box" -"Merchandise","Merchandise" -"Meter Number","Meter Number" -"Minimum Order Amount for Free Shipping","Minimum Order Amount for Free Shipping" -"Minimum Package Weight (Please consult your shipping carrier for minimum supported shipping weight)","Minimum Package Weight (Please consult your shipping carrier for minimum supported shipping weight)" -"Mode","Mode" -"National Freight","National Freight" -"Next Afternoon","Next Afternoon" -"Next Day Air","Next Day Air" -"Next Day Air Early AM","Next Day Air Early AM" -"Next Day Air Early AM Letter","Next Day Air Early AM Letter" -"Next Day Air Intra (Puerto Rico)","Next Day Air Intra (Puerto Rico)" -"Next Day Air Letter","Next Day Air Letter" -"Next Day Air Saver","Next Day Air Saver" -"Next Day Air Saver Letter","Next Day Air Saver Letter" -"No","No" -"No packages for request","No packages for request" -"Non Documents","Non Documents" -"Non documents","Non documents" -"Non-rectangular","Non-rectangular" -"None","None" -"Not Required","Not Required" -"Order","Order" -"Order #%s","Order #%s" -"Origin of the Shipment","Origin of the Shipment" -"Origin serviceAreaCode is missing","Origin serviceAreaCode is missing" -"Other","Other" -"Others","Others" -"PAK","PAK" -"Package","Package" -"Package Description","Package Description" -"Package content is missing","Package content is missing" -"Packages Request Type","Packages Request Type" -"Packaging","Packaging" -"Pallet","Pallet" -"Parcel","Parcel" -"Parcel Post","Parcel Post" -"Password","Password" -"Pickup Method","Pickup Method" -"Piece Id barcode is missing","Piece Id barcode is missing" -"Piece number information is missing","Piece number information is missing" -"Please make sure to use only digits here. No dashes are allowed.","Please make sure to use only digits here. No dashes are allowed." -"Please, specify origin country","Please, specify origin country" -"Pounds","Pounds" -"Priority Mail","Priority Mail" -"Priority Mail Express","Priority Mail Express" -"Priority Mail Express Flat Rate Boxes","Priority Mail Express Flat Rate Boxes" -"Priority Mail Express Flat Rate Boxes Hold For Pickup","Priority Mail Express Flat Rate Boxes Hold For Pickup" -"Priority Mail Express Flat Rate Envelope","Priority Mail Express Flat Rate Envelope" -"Priority Mail Express Flat Rate Envelope Hold For Pickup","Priority Mail Express Flat Rate Envelope Hold For Pickup" -"Priority Mail Express Hold For Pickup","Priority Mail Express Hold For Pickup" -"Priority Mail Express International","Priority Mail Express International" -"Priority Mail Express International Flat Rate Boxes","Priority Mail Express International Flat Rate Boxes" -"Priority Mail Express International Flat Rate Envelope","Priority Mail Express International Flat Rate Envelope" -"Priority Mail Express International Legal Flat Rate Envelope","Priority Mail Express International Legal Flat Rate Envelope" -"Priority Mail Express International Padded Flat Rate Envelope","Priority Mail Express International Padded Flat Rate Envelope" -"Priority Mail Express Legal Flat Rate Envelope","Priority Mail Express Legal Flat Rate Envelope" -"Priority Mail Express Legal Flat Rate Envelope Hold For Pickup","Priority Mail Express Legal Flat Rate Envelope Hold For Pickup" -"Priority Mail Express Padded Flat Rate Envelope","Priority Mail Express Padded Flat Rate Envelope" -"Priority Mail Express Padded Flat Rate Envelope Hold For Pickup","Priority Mail Express Padded Flat Rate Envelope Hold For Pickup" -"Priority Mail Express Sunday/Holiday Delivery","Priority Mail Express Sunday/Holiday Delivery" -"Priority Mail Express Sunday/Holiday Delivery Flat Rate Boxes","Priority Mail Express Sunday/Holiday Delivery Flat Rate Boxes" -"Priority Mail Express Sunday/Holiday Delivery Flat Rate Envelope","Priority Mail Express Sunday/Holiday Delivery Flat Rate Envelope" -"Priority Mail Express Sunday/Holiday Delivery Legal Flat Rate Envelope","Priority Mail Express Sunday/Holiday Delivery Legal Flat Rate Envelope" -"Priority Mail Express Sunday/Holiday Delivery Padded Flat Rate Envelope","Priority Mail Express Sunday/Holiday Delivery Padded Flat Rate Envelope" -"Priority Mail Flat Rate Envelope","Priority Mail Flat Rate Envelope" -"Priority Mail Flat Rate Envelope Hold For Pickup","Priority Mail Flat Rate Envelope Hold For Pickup" -"Priority Mail Gift Card Flat Rate Envelope","Priority Mail Gift Card Flat Rate Envelope" -"Priority Mail Gift Card Flat Rate Envelope Hold For Pickup","Priority Mail Gift Card Flat Rate Envelope Hold For Pickup" -"Priority Mail Hold For Pickup","Priority Mail Hold For Pickup" -"Priority Mail International","Priority Mail International" -"Priority Mail International DVD Flat Rate priced box","Priority Mail International DVD Flat Rate priced box" -"Priority Mail International Flat Rate Envelope","Priority Mail International Flat Rate Envelope" -"Priority Mail International Gift Card Flat Rate Envelope","Priority Mail International Gift Card Flat Rate Envelope" -"Priority Mail International Large Flat Rate Box","Priority Mail International Large Flat Rate Box" -"Priority Mail International Large Video Flat Rate priced box","Priority Mail International Large Video Flat Rate priced box" -"Priority Mail International Legal Flat Rate Envelope","Priority Mail International Legal Flat Rate Envelope" -"Priority Mail International Medium Flat Rate Box","Priority Mail International Medium Flat Rate Box" -"Priority Mail International Padded Flat Rate Envelope","Priority Mail International Padded Flat Rate Envelope" -"Priority Mail International Small Flat Rate Box","Priority Mail International Small Flat Rate Box" -"Priority Mail International Small Flat Rate Envelope","Priority Mail International Small Flat Rate Envelope" -"Priority Mail International Window Flat Rate Envelope","Priority Mail International Window Flat Rate Envelope" -"Priority Mail Large Flat Rate Box","Priority Mail Large Flat Rate Box" -"Priority Mail Large Flat Rate Box Hold For Pickup","Priority Mail Large Flat Rate Box Hold For Pickup" -"Priority Mail Legal Flat Rate Envelope","Priority Mail Legal Flat Rate Envelope" -"Priority Mail Legal Flat Rate Envelope Hold For Pickup","Priority Mail Legal Flat Rate Envelope Hold For Pickup" -"Priority Mail Medium Flat Rate Box","Priority Mail Medium Flat Rate Box" -"Priority Mail Medium Flat Rate Box Hold For Pickup","Priority Mail Medium Flat Rate Box Hold For Pickup" -"Priority Mail Padded Flat Rate Envelope","Priority Mail Padded Flat Rate Envelope" -"Priority Mail Padded Flat Rate Envelope Hold For Pickup","Priority Mail Padded Flat Rate Envelope Hold For Pickup" -"Priority Mail Regional Rate Box A","Priority Mail Regional Rate Box A" -"Priority Mail Regional Rate Box A Hold For Pickup","Priority Mail Regional Rate Box A Hold For Pickup" -"Priority Mail Regional Rate Box B","Priority Mail Regional Rate Box B" -"Priority Mail Regional Rate Box B Hold For Pickup","Priority Mail Regional Rate Box B Hold For Pickup" -"Priority Mail Regional Rate Box C","Priority Mail Regional Rate Box C" -"Priority Mail Regional Rate Box C Hold For Pickup","Priority Mail Regional Rate Box C Hold For Pickup" -"Priority Mail Small Flat Rate Box","Priority Mail Small Flat Rate Box" -"Priority Mail Small Flat Rate Box Hold For Pickup","Priority Mail Small Flat Rate Box Hold For Pickup" -"Priority Mail Small Flat Rate Envelope","Priority Mail Small Flat Rate Envelope" -"Priority Mail Small Flat Rate Envelope Hold For Pickup","Priority Mail Small Flat Rate Envelope Hold For Pickup" -"Priority Mail Window Flat Rate Envelope","Priority Mail Window Flat Rate Envelope" -"Priority Mail Window Flat Rate Envelope Hold For Pickup","Priority Mail Window Flat Rate Envelope Hold For Pickup" -"Priority Overnight","Priority Overnight" -"Product content code is invalid","Product content code is invalid" -"Product name is missing","Product name is missing" -"Receiver","Receiver" -"Rectangular","Rectangular" -"Reference code is missing","Reference code is missing" -"Regular","Regular" -"Regular Pickup","Regular Pickup" -"Request Courier","Request Courier" -"Required","Required" -"Required for negotiated rates; 6-character UPS.","Required for negotiated rates; 6-character UPS." -"Residential","Residential" -"Residential Delivery","Residential Delivery" -"Response is in the wrong format","Response is in the wrong format" -"Return","Return" -"Round","Round" -"Routing barcode is missing","Routing barcode is missing" -"Same day","Same day" -"Sample","Sample" -"Sandbox Mode","Sandbox Mode" -"Second Day Service","Second Day Service" -"Secure Gateway URL","Secure Gateway URL" -"Secureline","Secureline" -"Sender","Sender" -"Sender city info is missing","Sender city info is missing" -"Sender contact name is missing","Sender contact name is missing" -"Sender country info is missing","Sender country info is missing" -"Service type does not match","Service type does not match" -"Ship to Applicable Countries","Ship to Applicable Countries" -"Ship to Specific Countries","Ship to Specific Countries" -"Shipment Contains Hazardous Materials","Shipment Contains Hazardous Materials" -"Shipment Dutiable","Shipment Dutiable" -"Shipment Duty Payment Type","Shipment Duty Payment Type" -"Shipment Type","Shipment Type" -"Shipment is not available.","Shipment is not available." -"Shipment picked up","Shipment picked up" -"Shipper Number","Shipper Number" -"Shipping Accept XML URL","Shipping Accept XML URL" -"Shipping Confirm XML URL","Shipping Confirm XML URL" -"Shipping Key","Shipping Key" -"Shipping Key (International)","Shipping Key (International)" -"Show Method if Not Applicable","Show Method if Not Applicable" -"Signature Required","Signature Required" -"Size","Size" -"Small Express Box","Small Express Box" -"Smart Post","Smart Post" -"Sort Order","Sort Order" -"Specific","Specific" -"Sprintline","Sprintline" -"Standard Overnight","Standard Overnight" -"Standard Post","Standard Post" -"Station","Station" -"Subtotal","Subtotal" -"Subtotal With Discount","Subtotal With Discount" -"The field is applicable if the Smart Post method is selected.","The field is applicable if the Smart Post method is selected." -"The response is in wrong format.","The response is in wrong format." -"There is no available method for selected shipping address.","There is no available method for selected shipping address." -"There is no items in this order","There is no items in this order" -"Third Party","Third Party" -"Title","Title" -"To Lower","To Lower" -"To Upper","To Upper" -"Tracking XML URL","Tracking XML URL" -"UPS","UPS" -"UPS Expedited","UPS Expedited" -"UPS Express","UPS Express" -"UPS Express Box","UPS Express Box" -"UPS Express Early A.M.","UPS Express Early A.M." -"UPS Express Plus","UPS Express Plus" -"UPS Ground","UPS Ground" -"UPS Letter Envelope","UPS Letter Envelope" -"UPS Next Day Air","UPS Next Day Air" -"UPS Next Day Air Early A.M.","UPS Next Day Air Early A.M." -"UPS Next Day Air Saver","UPS Next Day Air Saver" -"UPS Saver","UPS Saver" -"UPS Second Day Air","UPS Second Day Air" -"UPS Second Day Air A.M.","UPS Second Day Air A.M." -"UPS Standard","UPS Standard" -"UPS Three-Day Select","UPS Three-Day Select" -"UPS Today Dedicated Courrier","UPS Today Dedicated Courrier" -"UPS Today Express","UPS Today Express" -"UPS Today Express Saver","UPS Today Express Saver" -"UPS Today Intercity","UPS Today Intercity" -"UPS Today Standard","UPS Today Standard" -"UPS Tube","UPS Tube" -"UPS Type","UPS Type" -"UPS Worldwide 10 kilo","UPS Worldwide 10 kilo" -"UPS Worldwide 25 kilo","UPS Worldwide 25 kilo" -"UPS Worldwide Expedited","UPS Worldwide Expedited" -"UPS Worldwide Express","UPS Worldwide Express" -"UPS Worldwide Express Plus","UPS Worldwide Express Plus" -"UPS Worldwide Express PlusSM","UPS Worldwide Express PlusSM" -"UPS Worldwide Saver","UPS Worldwide Saver" -"USPS","USPS" -"USPS GXG Envelopes","USPS GXG Envelopes" -"Unable to retrieve tracking","Unable to retrieve tracking" -"United Parcel Service","United Parcel Service" -"United Parcel Service XML","United Parcel Service XML" -"Unknown error","Unknown error" -"Used only when ""Additional Protection Value"" is set to ""Configuration"". Can contain only numeric amount.","Used only when ""Additional Protection Value"" is set to ""Configuration"". Can contain only numeric amount." -"User ID","User ID" -"Variable","Variable" -"Waybill barcode information is missing","Waybill barcode information is missing" -"Weight Unit","Weight Unit" -"Weight unit is invalid","Weight unit is invalid" -"Width","Width" -"Worldwide Expedited","Worldwide Expedited" -"Worldwide Express","Worldwide Express" -"Worldwide Express Letter","Worldwide Express Letter" -"Worldwide Express Plus","Worldwide Express Plus" -"Worldwide Express Plus Letter","Worldwide Express Plus Letter" -"Worldwide Express Saver","Worldwide Express Saver" -"Wrong Content Type.","Wrong Content Type." -"Wrong Region.","Wrong Region." -"Yes","Yes" -"Your Packaging","Your Packaging" -"Zero shipping charge for '%s'","Zero shipping charge for '%s'" -"cm","cm" -"inch","inch" \ No newline at end of file diff --git a/app/code/Magento/Usa/i18n/es_ES.csv b/app/code/Magento/Usa/i18n/es_ES.csv deleted file mode 100644 index b54cfc66cb7..00000000000 --- a/app/code/Magento/Usa/i18n/es_ES.csv +++ /dev/null @@ -1,296 +0,0 @@ -" was not delivered nor scanned","no ha sido entregado ni escaneado" -"""Per Order"" allows single handling fee for entire order. ""Per Package"" allows individual handling fee for each package.","""Por Pedido"" permite una única tarifa de gastos de manipulación para todo el pedido. ""Por Paquete"" permite una tarifa de gastos de gestión individual para cada paquete." -"1 Day Freight","EnvÃo en 1 dÃa" -"2 Day","DÃa 2" -"2 Day Freight","EnvÃo en 2 dÃas" -"2Day","2 dÃas" -"2nd Day Air","2º dÃa en avión" -"2nd Day Air AM","2º dÃa en avión por la mañana" -"2nd Day Air AM Letter","2º dÃa por correo aéreo por la mañana" -"2nd Day Air Letter","2º dÃa por correo aéreo" -"3 Day Freight","EnvÃo en 3 dÃas" -"3 Day Select","Seleccione 3 dÃas" -"Access ID","Acceso usuario" -"Access License Number","Número de licencia de acceso" -"Account ID","Cuenta usuario" -"Account Number","Número de cuenta" -"Additional Protection Configuration Value","Valor de configuración de protección adicional" -"Additional Protection Enabled","Protección adicional habilitada" -"Additional Protection Min Subtotal","MÃnimo subtotal protección adicional" -"Additional Protection Value","Valor de protección adicional" -"Additional Protection Value Rounding Method","Método de redondeo del valor de protección adicional" -"Adult","Adulto" -"Adult Signature Required","Se Requiere Firma de Adulto" -"Allowed Methods","Métodos permitidos" -"Allows breaking total order weight into smaller pieces if it exeeds %s %s to ensure accurate calculation of shipping charges.","Permite dividir el peso del pedido total en piezas pequeñas si sobrepasa los %s %s para asegurar un cálculo exacto de los gastos de envÃo." -"Allows breaking total order weight into smaller pieces if it exeeds 70 kg to ensure accurate calculation of shipping charges.","Permite dividir el peso del pedido total en piezas pequeñas si sobrepasa los 70 kg para asegurar un cálculo exacto de los gastos de envÃo." -"Bound Printed Matter","Asunto impreso limitado" -"Break bulk economy","Fraccionar economÃa a granel" -"Break bulk express","Fraccionar envÃo urgente a granel" -"Business Service Center","Centro de servicios" -"Calculate Handling Fee","Calcular el gastos de envÃo" -"Canada Standard","Canadá Estándar" -"Cannot identify measure unit for %s","No se puede identificar la unidad de medida para %s" -"Cannot identify weight unit for %s","No se puede identificar la unidad de peso para %s" -"Cannot retrieve shipping rates","Imposible recuperar las tarifas de transporte" -"Centimeters","CentÃmetros" -"Commercial","Comercial" -"Configuration","Configuración" -"Container","Container" -"Content Type","Tipo de Contenido" -"Customer Packaging","Embalado por el cliente" -"Customer Supplied Package","Paquete Suministrado por el Cliente" -"Customer services","Atención al cliente" -"DHL","DHL" -"DHL (Deprecated)","DHL (Rechazado)" -"Debug","Depurar" -"Default Package Height","Altura del paquete por defecto" -"Default Package Length","Longitud del paquete por defecto" -"Default Package Width","Anchura del paquete por defecto" -"Delivered","Entregado" -"Delivery Confirmation","Confirmación de EnvÃo" -"Depth","Anchura" -"Destination Type","Tipo de destino" -"Destination facility code is empty","El código de la instalación de destino está vacÃo" -"Development","Nueva situación" -"Direct","Directo" -"Displayed Error Message","Mostrado mensaje de error" -"Divide Order Weight","Dividir el Peso del Pedido" -"Documents","Documentos" -"Domestic Shipment Days","DÃas para envÃos nacionales" -"Domestic economy select","Selección de economÃa doméstica" -"Domestic express","EnvÃo urgente doméstico" -"Drop Box","Buzón" -"Dropoff","De entrega" -"Easy shop","Compra fácil" -"Economy select","Selección de economÃa" -"Empty response","Respuesta vacÃa" -"Enable Negotiated Rates","Habilitar tarifas negociadas" -"Enabled for Checkout","Habilitado para Cobro" -"Enables/Disables SSL verification of Magento server by UPS.","Activa/desactiva la verificación SSL del servidor Magento por UPS" -"Error #%s : %s","Error #%s : %s" -"Error #%s : %s (%s)","Error #%s : %s (%s)" -"Error #%s: %s","Error #%s: %s" -"Europack","Europack" -"Europe First Priority","Primera Prioridad Europa" -"Exchange rate %s (Base Currency) -> %s not found. DHL method %s skipped","Tipo de cambio %s (Moneda Base) -> %s no encontrado. Método DHL %s omitido" -"Express","Express" -"Express 10:30","EnvÃo urgente 10:30" -"Express 10:30 AM","Express 10:30 AM" -"Express 12:00","EnvÃo urgente 12:00" -"Express 9:00","EnvÃo urgente 9:00" -"Express Mail","Correo Express" -"Express Saturday","Express Sábado" -"Express Saver","Express de Ahorro" -"Express easy","EnvÃo urgente fácil" -"Express envelope","Sobre urgente" -"Express worldwide","EnvÃo urgente internacional" -"Failed to parse xml document: %s","Fallo en la conversión del documento xml: %s" -"FedEx","FedEx" -"FedEx 10kg Box","Caja de 10 Kg. de FedEx" -"FedEx 25kg Box","Caja de 25 Kg. de FedEx" -"FedEx Box","Caja de FedEx" -"FedEx Envelope","Sobre de FedEx" -"FedEx Pak","Paquete de FedEx" -"FedEx Tube","Tubo de FedEx" -"First Overnight","El Primero Nocturno" -"First-Class","Primera Clase" -"Flat","Fijo" -"Flat-Rate Box","Caja de Tarifa Plana" -"Flat-Rate Envelope","Sobre de Tarifa Plana" -"Free Method","Método Gratuito" -"Free Shipping with Minimum Order Amount","EnvÃo Gratuito con Cantidad MÃnima de Pedido" -"Freight","MercancÃas" -"Freight worldwide","Transporte internacional" -"Gateway URL","URL de la pasarela" -"Gateway XML URL","Pasarela XML URL" -"Gift","Regalo" -"Girth","Circunferencia" -"Globalmail business","Negocio de correo global" -"Ground","Rutina" -"Ground Commercial","Rutina Comercial" -"Ground Residential","Rutina Residencial" -"Handling Applied","Portes Aplicados" -"Handling Fee","Gastos de Tramitación" -"Height","Altura" -"Height, width and length should be equal or greater than %s","Altura, anchura y longitud deberÃan ser iguales o mayores que %s" -"Home Delivery","Entrega a Domicilio" -"Inches","CentÃmetros" -"Indirect","Indirecto" -"International Economy","Internacional Económico" -"International Express","Internacional Rápido" -"International First","Internacional Primera" -"International Ground","Suelo Internacional" -"International Priority","Internacional Prioritario" -"International Shipment Days","DÃas de Envio Internacional" -"Intl Economy Freight","Transporte Internacional Económico" -"Intl Priority Freight","Transporte Internacional Prioritario" -"Jetline","Jetline" -"Jumbo box","Buzón Jumbo" -"Key","Clave" -"Kilograms","Kilogramos" -"Large","Grande" -"Large Express Box","Gran Paquete Urgente" -"Length","Longitud" -"Letter","Carta" -"Library","Biblioteca" -"Live","Vivo" -"Machinable","Manufacturable" -"Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)","Peso Máximo de Paquete (Por favor, consulte el peso máximo admitido para envÃos con su empresa de transportes)" -"Media Mail","Correo de medios de comunicación" -"Medical express","EnvÃo médico urgente" -"Medium Express Box","Paquete Mediano Urgente" -"Merchandise","MercancÃa" -"Meter Number","Número de Contador" -"Minimum Order Amount for Free Shipping","Cantidad MÃnima de Pedido para EnvÃos Gratuitos" -"Minimum Package Weight (Please consult your shipping carrier for minimum supported shipping weight)","Peso MÃnimo de Paquete (Por favor, consulte el peso mÃnimo admitido para envÃos con su empresa de transportes)" -"Mode","Modalidad" -"National Freight","MercancÃa nacional" -"Next Afternoon","Mañana por la Tarde" -"Next Day Air","Transporte Aéreo al DÃa Siguiente" -"Next Day Air Early AM","Transporte Aéreo al DÃa Siguiente a Primera Hora de la Mañana" -"Next Day Air Early AM Letter","Carta por Transporte Aéreo al DÃa Siguiente a Primera Hora de la Mañana" -"Next Day Air Intra (Puerto Rico)","Transporte Aéreo Interno al DÃa Siguiente (Puerto Rico)" -"Next Day Air Letter","Carta por Transporte Aéreo al DÃa Siguiente" -"Next Day Air Saver","Transporte Aéreo al DÃa Siguiente con Ahorro" -"Next Day Air Saver Letter","Carta por Transporte Aéreo al DÃa Siguiente con Ahorro" -"No","No" -"No packages for request","No hay paquetes que solicitar" -"Non Documents","No documentos" -"Non documents","No documentos" -"Non-rectangular","No rectangular" -"None","Ninguno" -"Not Required","No requerido" -"Order","Encargar" -"Origin of the Shipment","Origen del envÃo" -"Origin serviceAreaCode is missing","Falta el código de área del servicio de origen" -"Other","Otra" -"Others","Otros" -"PAK","PAK" -"Package","Paquete" -"Package Description","Descripción del paquete" -"Packages Request Type","Tipo de Solicitud de Paquetes" -"Packaging","Embalaje" -"Pallet","Palé" -"Parcel","Paquete" -"Parcel Post","Servicio de paquetes postales" -"Password","Contraseña" -"Pickup Method","Método de recogida" -"Piece Id barcode is missing","Falta el código de barras de identificación de la pieza" -"Piece number information is missing","Falta la información del número de la pieza" -"Please make sure to use only digits here. No dashes are allowed.","Por favor, asegúrese de introducir solamente dÃgitos. No se pueden utilizar guiones." -"Pounds","Libras" -"Priority Mail","Correo urgente" -"Priority Overnight","Prioridad durante la noche" -"Product content code is invalid","El código de contenido del producto no es válido" -"Product name is missing","Falta el nombre del producto" -"Receiver","Destinatario" -"Rectangular","Rectangular" -"Regular","Ordinario" -"Regular Pickup","Recogida ordinaria" -"Request Courier","Solicitar servicio de mensajerÃa" -"Required","Requerido" -"Required for negotiated rates; 6-character UPS.","Requerido para tarifas negociadas; UPS de 6 caracteres." -"Residential","Residencial" -"Residential Delivery","Entrega residencial" -"Response is in the wrong format","La respuesta está en el formato equivocado" -"Return","Devolución" -"Round","Redondo" -"Routing barcode is missing","Falta el código de barras de enrutamiento" -"Same day","El mismo dÃa" -"Sample","Ejemplo" -"Sandbox Mode","Modo de prueba" -"Second Day Service","Servicio de segundo dÃa" -"Secure Gateway URL","URL de Gateway Seguro" -"Secureline","Secureline" -"Sender","Remitente" -"Sender city info is missing","Falta la información de la ciudad del remitente" -"Sender contact name is missing","Falta el nombre de contacto del remitente" -"Sender country info is missing","Falta la información del paÃs del remitente" -"Service type does not match","El tipo de servicio no coincide" -"Ship to Applicable Countries","Enviar a los paÃses aplicables" -"Ship to Specific Countries","Enviar a paÃses especÃficos" -"Shipment Contains Hazardous Materials","El envÃo contiene materiales peligrosos" -"Shipment Dutiable","EnvÃo sujeto a derechos de aduana" -"Shipment Duty Payment Type","Tipo de pago de impuestos de envÃo" -"Shipment Type","Tipo de envÃo" -"Shipment is not available.","El envÃo no está disponible" -"Shipment picked up","EnvÃo recogido" -"Shipper Number","Número de expedidor" -"Shipping Key","Clave de envÃo" -"Shipping Key (International)","Clave de envÃo (internacional)" -"Show Method if Not Applicable","Mostrar el método si no se aplica" -"Signature Required","Firma requerida" -"Size","Tamaño" -"Small Express Box","Caja express pequeña" -"Smart Post","Smart Post" -"Sort Order","Ordenar Pedido" -"Specific","EspecÃfico" -"Sprintline","Sprintline" -"Standard Overnight","Estándar de un dÃa para otro" -"Station","Central" -"Subtotal","Subtotal" -"Subtotal With Discount","Subtotal con descuento" -"The response is in wrong format.","La respuesta tiene un formato incorrecto." -"There is no available method for selected shipping address.","No existe un método disponible para la dirección de envÃo seleccionada." -"There is no items in this order","No hay artÃculos en este pedido" -"Third Party","Terceras Partes" -"Title","TÃtulo" -"To Lower","Al Inferior" -"To Upper","Al Superior" -"Tracking XML URL","Seguimiento de URL XML" -"UPS","UPS" -"UPS Expedited","UPS Urgente" -"UPS Express","UPS Express" -"UPS Express Box","UPS Express Box" -"UPS Express Early A.M.","UPS Express A Primera Hora de la Mañana" -"UPS Express Plus","UPS Express Plus" -"UPS Ground","UPS Ground" -"UPS Letter Envelope","UPS Sobre de Carta" -"UPS Next Day Air","UPS Aéreo Entrega Al DÃa Siguiente" -"UPS Next Day Air Early A.M.","UPS Aéreo Entrega Al DÃa Siguiente A Primera Hora de la Mañana" -"UPS Next Day Air Saver","UPS Saver Aéreo Entrega Al DÃa Siguiente" -"UPS Saver","UPS Saver" -"UPS Second Day Air","UPS Aéreo Entrega Al Final del Segundo DÃa Laborable" -"UPS Second Day Air A.M.","UPS Aéreo Entrega En La Mañana del Segundo DÃa Laborable" -"UPS Standard","UPS Standard" -"UPS Three-Day Select","UPS Entrega Al Final Del Tercer DÃa Laborable" -"UPS Today Dedicated Courrier","UPS Entrega En el DÃa por MensajerÃa Dedicada" -"UPS Today Express","UPS Entrega En el DÃa En Una Hora" -"UPS Today Express Saver","UPS Entrega En el DÃa En Dos Horas y Media" -"UPS Today Intercity","UPS Entrega En el DÃa Interurbana" -"UPS Today Standard","UPS Entrega En el DÃa A Última Hora" -"UPS Tube","UPS Tube" -"UPS Type","Tipo de UPS" -"UPS Worldwide 10 kilo","UPS Internacional 10 kilos" -"UPS Worldwide 25 kilo","UPS Internacional 25 kilos" -"UPS Worldwide Expedited","UPS Internacional Expedited" -"UPS Worldwide Express","UPS Internacional Express" -"UPS Worldwide Express Plus","UPS Internacional Express Plus" -"UPS Worldwide Express PlusSM","UPS Internacional Express PlusSM" -"UPS Worldwide Saver","UPS Ahorro Internacional" -"USPS","USPS" -"Unable to retrieve tracking","No se puede recuperar el seguimiento." -"United Parcel Service","United Parcel Service" -"United Parcel Service XML","XML de United Parcel Service" -"Unknown error","Error desconocido" -"Used only when ""Additional Protection Value"" is set to ""Configuration"". Can contain only numeric amount.","Se usa sólo cuando el ""Valor de protección adicional"" está establecido en ""Configuración"". Sólo puede contener cantidades numéricas. " -"User ID","ID de Usuario" -"Variable","Variable" -"Waybill barcode information is missing","Falta la información de albarán del código de barras" -"Weight Unit","Unidad de Peso" -"Weight unit is invalid","La unidad de peso no es válida" -"Width","Ancho" -"Worldwide Expedited","Internacional Expedited" -"Worldwide Express","Internacional Express" -"Worldwide Express Letter","Carta Internacional Express" -"Worldwide Express Plus","Internacional Express Plus" -"Worldwide Express Plus Letter","Carta Internacional Express Plus" -"Worldwide Express Saver","Internacional Express Saver" -"Wrong Content Type.","Tipo de Contenido Incorrecto." -"Wrong Region.","Región Incorrecta." -"Yes","SÃ" -"Your Packaging","Su Embalaje" -"Zero shipping charge for '%s'","Cero gastos de envÃo para '%s'" -"cm","cm" -"inch","pulgada" diff --git a/app/code/Magento/Usa/i18n/fr_FR.csv b/app/code/Magento/Usa/i18n/fr_FR.csv deleted file mode 100644 index f6ad7544c19..00000000000 --- a/app/code/Magento/Usa/i18n/fr_FR.csv +++ /dev/null @@ -1,296 +0,0 @@ -" was not delivered nor scanned","n'a été ni livré, ni scanné" -"""Per Order"" allows single handling fee for entire order. ""Per Package"" allows individual handling fee for each package.","""Par commande"" permet des frais uniques pour une commande entière. ""Par colis"" permet une gestion individuelle de chaque colis." -"1 Day Freight","Fret une journée" -"2 Day","2 jours" -"2 Day Freight","Fret deux jours" -"2Day","2 jours" -"2nd Day Air","2nd Day Air" -"2nd Day Air AM","2nd Day Air AM" -"2nd Day Air AM Letter","2nd Day Air AM Letter" -"2nd Day Air Letter","2nd Day Air Letter" -"3 Day Freight","Fret 3 jours" -"3 Day Select","3 Day Select" -"Access ID","Identifiant d'accès" -"Access License Number","Numéro de la licence d'accès" -"Account ID","Identifiant du compte" -"Account Number","Numéro de compte" -"Additional Protection Configuration Value","Valeur de la protection supplémentaire" -"Additional Protection Enabled","Protection supplémentaire activée" -"Additional Protection Min Subtotal","Sous-total de la protection supplémentaire" -"Additional Protection Value","Valeur de la protection supplémentaire" -"Additional Protection Value Rounding Method","Méthode d'arrondi de la valeur de la protection supplémentaire" -"Adult","Adulte" -"Adult Signature Required","Signature d'un adulte requise" -"Allowed Methods","Méthodes autorisées" -"Allows breaking total order weight into smaller pieces if it exeeds %s %s to ensure accurate calculation of shipping charges.","Permet de séparer le poids total de la commande en plusieurs parties s'il dépasse %s %s afin d'assurer un calcul précis des frais d'expédition." -"Allows breaking total order weight into smaller pieces if it exeeds 70 kg to ensure accurate calculation of shipping charges.","Permet de séparer le poids total de la commande en plusieurs parties s'il dépasse 70 kg afin d'assurer un calcul précis des frais d'expédition." -"Bound Printed Matter","Lier l'imprimé" -"Break bulk economy","Tarif économique vrac" -"Break bulk express","Break bulk express" -"Business Service Center","Centre de service aux entreprises" -"Calculate Handling Fee","Calculer les frais de gestion" -"Canada Standard","Canada Standard" -"Cannot identify measure unit for %s","Ne peut pas identifier l'unité pour %s" -"Cannot identify weight unit for %s","Impossible d'identifier l'unité de poids pour %s" -"Cannot retrieve shipping rates","Ne peut pas récupérer les frais d'expédition" -"Centimeters","Centimètres" -"Commercial","Commercial" -"Configuration","Configuration" -"Container","Conteneur" -"Content Type","Type de contenu" -"Customer Packaging","Conditionnement de l'utilisateur" -"Customer Supplied Package","Colis fourni par le client" -"Customer services","Service client" -"DHL","DHL" -"DHL (Deprecated)","DHL (obsolète)" -"Debug","Déboguer" -"Default Package Height","Hauteur du colis par défaut" -"Default Package Length","Longueur du colis par défaut" -"Default Package Width","Largeur du colis par défaut" -"Delivered","Livré" -"Delivery Confirmation","Confirmation de livraison" -"Depth","Profondeur" -"Destination Type","Type de destination" -"Destination facility code is empty","Le code de centre de destination est vide" -"Development","Développement" -"Direct","Direct" -"Displayed Error Message","Message d'erreur affiché" -"Divide Order Weight","Poids de commande fractionnelle" -"Documents","Documents" -"Domestic Shipment Days","Jours de livraison" -"Domestic economy select","Domestic economy select" -"Domestic express","Domestic express" -"Drop Box","Boîte de dépôt" -"Dropoff","Déposer" -"Easy shop","Easy shop" -"Economy select","Economy select" -"Empty response","Réponse vide" -"Enable Negotiated Rates","Permettre les tarifs négociés" -"Enabled for Checkout","Activé pour le paiement" -"Enables/Disables SSL verification of Magento server by UPS.","Activer/Désactiver la vérification des serveurs de Magento par UPS." -"Error #%s : %s","Erreur n° %s : %s" -"Error #%s : %s (%s)","Erreur #%s : %s (%s)" -"Error #%s: %s","Erreur #%s: %s" -"Europack","Europack" -"Europe First Priority","Europe First Priority" -"Exchange rate %s (Base Currency) -> %s not found. DHL method %s skipped","Impossible de trouver taux de change %s (devise de base) -> %s. Omission de la méthode DHL %s" -"Express","Express" -"Express 10:30","Express 10:30" -"Express 10:30 AM","Express 10:30 AM" -"Express 12:00","Express 12:00" -"Express 9:00","Express 9:00" -"Express Mail","Express Mail" -"Express Saturday","Express Saturday" -"Express Saver","Express Saver" -"Express easy","Express easy" -"Express envelope","Express envelope" -"Express worldwide","Express worldwide" -"Failed to parse xml document: %s","Échec de l'analyse du document xlm %s" -"FedEx","FedEx" -"FedEx 10kg Box","FedEx 10kg Box" -"FedEx 25kg Box","FedEx 25kg Box" -"FedEx Box","FedEx Box" -"FedEx Envelope","FedEx Envelope" -"FedEx Pak","FedEx Pak" -"FedEx Tube","FedEx Tube" -"First Overnight","First Overnight" -"First-Class","First-Class" -"Flat","Flat" -"Flat-Rate Box","Flat-Rate Box" -"Flat-Rate Envelope","Flat-Rate Envelope" -"Free Method","Méthode gratuite" -"Free Shipping with Minimum Order Amount","Expédition gratuite avec montant minimum de la commande" -"Freight","Fret" -"Freight worldwide","Fret international" -"Gateway URL","URL de la passerelle" -"Gateway XML URL","URL XML de la passerelle" -"Gift","Cadeau" -"Girth","circonférence" -"Globalmail business","Globalmail business" -"Ground","Sol" -"Ground Commercial","Sol commercial" -"Ground Residential","Sol résidentiel" -"Handling Applied","Gestion appliquée" -"Handling Fee","Frais de gestion" -"Height","Hauteur" -"Height, width and length should be equal or greater than %s","La hauteur, la largeur et la longueur doivent être supérieures ou égales à %s" -"Home Delivery","Livraison à la maison" -"Inches","Pouces" -"Indirect","Indirect" -"International Economy","International Economy" -"International Express","International Express" -"International First","International First" -"International Ground","Terres internationales" -"International Priority","International Priority" -"International Shipment Days","International Shipment Days" -"Intl Economy Freight","Intl Economy Freight" -"Intl Priority Freight","Intl Priority Freight" -"Jetline","Jetline" -"Jumbo box","Jumbo box" -"Key","Clé" -"Kilograms","Kilogrammes" -"Large","Large" -"Large Express Box","Large Express Box" -"Length","Longueur" -"Letter","Lettre" -"Library","Bibliothèque" -"Live","En direct" -"Machinable","Usinable" -"Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)","Poids maximum du colis (veuillez consulter votre transporteur pour le poids maximum supporté)" -"Media Mail","Media Mail" -"Medical express","Medical express" -"Medium Express Box","Medium Express Box" -"Merchandise","Marchandise" -"Meter Number","Numéro de mètre" -"Minimum Order Amount for Free Shipping","Montant minimum de la commande pour expédition gratuite" -"Minimum Package Weight (Please consult your shipping carrier for minimum supported shipping weight)","Poids minimum du colis (veuillez consulter votre transporteur pour le poids minimum supporté)" -"Mode","Mode" -"National Freight","Fret nationale" -"Next Afternoon","Next Afternoon" -"Next Day Air","Next Day Air" -"Next Day Air Early AM","Next Day Air Early AM" -"Next Day Air Early AM Letter","Next Day Air Early AM Letter" -"Next Day Air Intra (Puerto Rico)","Next Day Air Intra (Puerto Rico)" -"Next Day Air Letter","Next Day Air Letter" -"Next Day Air Saver","Next Day Air Saver" -"Next Day Air Saver Letter","Next Day Air Saver Letter" -"No","Non" -"No packages for request","Pas de colis par requête" -"Non Documents","Non-documents" -"Non documents","Non-documents" -"Non-rectangular","Non rectangulaire" -"None","Aucun" -"Not Required","Non requis" -"Order","Commande" -"Origin of the Shipment","Origine de l'expédition" -"Origin serviceAreaCode is missing","Code d'aire de service d'origine manquant" -"Other","Autre" -"Others","Autres" -"PAK","PAK" -"Package","Colis" -"Package Description","Description du colis" -"Packages Request Type","Type de demande de colis" -"Packaging","Conditionnement" -"Pallet","Pallet" -"Parcel","Colis" -"Parcel Post","Parcel Post" -"Password","Mot de passe" -"Pickup Method","Méthode de ramassage" -"Piece Id barcode is missing","Identifiant code-barre de l'unité manquant" -"Piece number information is missing","Informations sur le numéro de l'unité manquantes" -"Please make sure to use only digits here. No dashes are allowed.","Veuillez n'utiliser que des chiffres dans ce champ. Les tirets ne sont pas autorisés." -"Pounds","Livres" -"Priority Mail","Priority Mail" -"Priority Overnight","Priority Overnight" -"Product content code is invalid","Code de contenu du produit incorrect" -"Product name is missing","Nom du produit manquant" -"Receiver","Destinataire" -"Rectangular","Rectangulaire" -"Regular","Ordinaire" -"Regular Pickup","Ramasse ordinaire" -"Request Courier","Demander un courrier" -"Required","Requis" -"Required for negotiated rates; 6-character UPS.","Requis pour les taux négociés, UPS 6 caractères." -"Residential","Résidentiel" -"Residential Delivery","Livraison résidentielle" -"Response is in the wrong format","Réponse dans le mauvais format" -"Return","Retour" -"Round","Rond" -"Routing barcode is missing","Code-barre de routage manquant" -"Same day","Même jour" -"Sample","Échantillon" -"Sandbox Mode","Mode Sandbox" -"Second Day Service","Second Day Service" -"Secure Gateway URL","URL paserelle sécurisée" -"Secureline","Secureline" -"Sender","Expéditeur" -"Sender city info is missing","La ville de l'expéditeur est manquante" -"Sender contact name is missing","Le nom de l'expéditeur est manquant" -"Sender country info is missing","Le pays de l'expéditeur est manquant" -"Service type does not match","Le type de service ne correspond pas" -"Ship to Applicable Countries","Envoyer aux pays en vigueur" -"Ship to Specific Countries","Envoyer à des pays spécifiques" -"Shipment Contains Hazardous Materials","Le colis contient des matières dangereuses" -"Shipment Dutiable","Colis taxable" -"Shipment Duty Payment Type","Type de paiement des taxes sur le colis" -"Shipment Type","Type d'expédition" -"Shipment is not available.","Expédition non disponible." -"Shipment picked up","Colis récupéré." -"Shipper Number","Numéro de l'expéditeur" -"Shipping Key","Clé de l'envoi" -"Shipping Key (International)","Clé de l'envoi (international)" -"Show Method if Not Applicable","Afficher la méthode si non disponible" -"Signature Required","Signature requise" -"Size","Taille" -"Small Express Box","Petit colis express" -"Smart Post","Poste intelligente" -"Sort Order","Trier les widgets" -"Specific","Spécifique" -"Sprintline","Sprintline" -"Standard Overnight","Standard nuit" -"Station","Gare" -"Subtotal","Sous-total" -"Subtotal With Discount","Sous-total avec réduction" -"The response is in wrong format.","La réponse est au mauvais format" -"There is no available method for selected shipping address.","Il n'y a pas de méthode disponible pour l'adresse d'expédition sélectionnée." -"There is no items in this order","Il n'y a pas d'objets dans cette commande" -"Third Party","Tierce partie" -"Title","Titre" -"To Lower","Vers plus petit" -"To Upper","Vers plus haut" -"Tracking XML URL","URL vers le XML de tracking" -"UPS","UPS" -"UPS Expedited","Expédié par UPS" -"UPS Express","UPS Express" -"UPS Express Box","Boîte UPS Express" -"UPS Express Early A.M.","UPS Express début de matinée" -"UPS Express Plus","UPS Express plus" -"UPS Ground","UPS sol" -"UPS Letter Envelope","Enveloppe UPS Letter" -"UPS Next Day Air","UPS par avion, lendemain" -"UPS Next Day Air Early A.M.","UPS par avion, lendemain début de matinée" -"UPS Next Day Air Saver","UPS lendemain par avion économique" -"UPS Saver","UPS économique" -"UPS Second Day Air","UPS deux jours par avion" -"UPS Second Day Air A.M.","UPS deux jours par avion le matin" -"UPS Standard","UPS Standard" -"UPS Three-Day Select","UPS 3 jours Select" -"UPS Today Dedicated Courrier","UPS jour-même courrier" -"UPS Today Express","UPS jour-même express" -"UPS Today Express Saver","UPS jour-même express économique" -"UPS Today Intercity","UPS jour-même intercity" -"UPS Today Standard","UPS jour-même standard" -"UPS Tube","UPS Tube" -"UPS Type","UPS Type" -"UPS Worldwide 10 kilo","UPS Monde 10kg" -"UPS Worldwide 25 kilo","UPS Monde 25kg" -"UPS Worldwide Expedited","UPS Monde Expédié" -"UPS Worldwide Express","UPS Monde Express" -"UPS Worldwide Express Plus","UPS Monde Express Plus" -"UPS Worldwide Express PlusSM","UPS Monde Express PlusSM" -"UPS Worldwide Saver","UPS Worldwide Saver" -"USPS","USPS" -"Unable to retrieve tracking","Échec de la récupération" -"United Parcel Service","United Parcel Service (UPS)" -"United Parcel Service XML","XML United Parcel Service (UPS)" -"Unknown error","Erreur inconnue" -"Used only when ""Additional Protection Value"" is set to ""Configuration"". Can contain only numeric amount.","Utilisé uniquement lorsque ""Valeur de la protection additionnelle"" est fixé sur ""Configuration"". Peut uniquement contenir une valeur numérique." -"User ID","Identifiant de l'utilisateur" -"Variable","Variable" -"Waybill barcode information is missing","Information du code-barre de la feuille de route manquante" -"Weight Unit","Unité de poids" -"Weight unit is invalid","Unité de poids invalide" -"Width","Largeur" -"Worldwide Expedited","Monde expédié" -"Worldwide Express","Monde Express" -"Worldwide Express Letter","Lettre Monde Express" -"Worldwide Express Plus","Monde Express Plus" -"Worldwide Express Plus Letter","Lettre Monde Express Plus" -"Worldwide Express Saver","Économique Monde Express" -"Wrong Content Type.","Type de contenu incorrect." -"Wrong Region.","Région incorrecte." -"Yes","oui" -"Your Packaging","Votre colis" -"Zero shipping charge for '%s'","Aucun frais de port pour '%s'" -"cm","cm" -"inch","pouce" diff --git a/app/code/Magento/Usa/i18n/nl_NL.csv b/app/code/Magento/Usa/i18n/nl_NL.csv deleted file mode 100644 index 3e701fb7f28..00000000000 --- a/app/code/Magento/Usa/i18n/nl_NL.csv +++ /dev/null @@ -1,296 +0,0 @@ -" was not delivered nor scanned","was niet geleverd nog gescand" -"""Per Order"" allows single handling fee for entire order. ""Per Package"" allows individual handling fee for each package.","Met ""Per bestelling"" hoeft er slechts eenmaal verzendkosten te worden betaald voor de complete bestelling. Met ""Per Pakket"" dient er voor ieder pakket verzendkosten te worden betaald." -"1 Day Freight","1 Dag Vracht" -"2 Day","2 Dagen" -"2 Day Freight","2 Dagen Vracht" -"2Day","Vandaag" -"2nd Day Air","Arriveert 2 werkdagen na verzenddatum" -"2nd Day Air AM","Arriveert 2 werkdagen na verzenddatum in de middag" -"2nd Day Air AM Letter","2de Dag Lucht AM Brief" -"2nd Day Air Letter","2de Dag Luchtpost" -"3 Day Freight","3 Dagen Vracht" -"3 Day Select","Levering aan het eind van de 3e werkdag" -"Access ID","Toegang ID" -"Access License Number","Toegang Licentie Nummer" -"Account ID","Account ID" -"Account Number","Account nummer" -"Additional Protection Configuration Value","Additionele Bescherming Configuratie Waarde" -"Additional Protection Enabled","Additionele Bescherming Ingesteld" -"Additional Protection Min Subtotal","Additionele Bescherming Min Subtotaal" -"Additional Protection Value","Additionele Bescherming Waarde" -"Additional Protection Value Rounding Method","Additionele Bescherming Waarde Afrond Methode" -"Adult","Volwassen" -"Adult Signature Required","Handtekening van een volwassene vereist." -"Allowed Methods","Toegestane Methoden" -"Allows breaking total order weight into smaller pieces if it exeeds %s %s to ensure accurate calculation of shipping charges.","Sta toe dat het totale bestelgewicht in kleinere stukken wordt opgedeeld als het %s %s overstijgt om voor een nauwkeurige berekening van de verzendkosten te zorgen." -"Allows breaking total order weight into smaller pieces if it exeeds 70 kg to ensure accurate calculation of shipping charges.","Sta toe dat het totale bestelgewicht in kleinere stukken wordt opgedeeld als het de 70kg overstijgt om voor een nauwkeurige berekening van de verzendkosten te zorgen." -"Bound Printed Matter","Ingebonden Geprint Materiaal" -"Break bulk economy","Stukgoed economie" -"Break bulk express","Stukgoed expres" -"Business Service Center","Business Service Center" -"Calculate Handling Fee","Bereken Behandelingskosten" -"Canada Standard","Canada standaard" -"Cannot identify measure unit for %s","Kan meeteenheid voor %s niet vaststellen" -"Cannot identify weight unit for %s","Kan de weegeenheid voor %s niet vaststellen" -"Cannot retrieve shipping rates","Kan verzendkosten niet ophalen" -"Centimeters","Centimeters" -"Commercial","Reclame" -"Configuration","Configuratie" -"Container","Container" -"Content Type","Inhoudstype" -"Customer Packaging","Klant verpakking" -"Customer Supplied Package","Door klant geleverde verpakking" -"Customer services","Klantenservice" -"DHL","DHL" -"DHL (Deprecated)","DHL (Afgekeurd)" -"Debug","Debug" -"Default Package Height","Standaard pakkethoogte" -"Default Package Length","Standaard pakketlengte" -"Default Package Width","Standaard pakketbreedte" -"Delivered","Bezorgd" -"Delivery Confirmation","Afleveringsbevestiging" -"Depth","Diepte" -"Destination Type","Bestemmingstype" -"Destination facility code is empty","Voorzieningscode van de bestemming is leeg" -"Development","Ontwikkeling" -"Direct","Direct" -"Displayed Error Message","Geef Foutmelding Weer" -"Divide Order Weight","Verdeel Bestel Gewicht" -"Documents","Documenten" -"Domestic Shipment Days","Dagen voor binnenlandse verzending" -"Domestic economy select","Kies binnenlandse economie" -"Domestic express","Binnenlandse expres" -"Drop Box","Drop Box" -"Dropoff","Dropoff" -"Easy shop","Winkel gemakkelijk" -"Economy select","Kies economie" -"Empty response","Leeg antwoord" -"Enable Negotiated Rates","Onderhandelde tarieven aanzetten" -"Enabled for Checkout","Aangezet voor de afrekening" -"Enables/Disables SSL verification of Magento server by UPS.","Aanzetten/Uitzetten van SSL verificatie van de Magento server door UPS." -"Error #%s : %s","Fout #%s : %s" -"Error #%s : %s (%s)","Fout #%s : %s (%s)" -"Error #%s: %s","Fout #%s: %s" -"Europack","Europack" -"Europe First Priority","Europa Hoogste Prioriteit" -"Exchange rate %s (Base Currency) -> %s not found. DHL method %s skipped","Wisselkoers % s (basisvaluta) ->% s niet gevonden. DHL methode % s overgeslagen" -"Express","Expresse" -"Express 10:30","Express 10:30" -"Express 10:30 AM","Expresse 10:30" -"Express 12:00","Express 12:00" -"Express 9:00","Expres 9:00" -"Express Mail","Express Post" -"Express Saturday","Expresse Zaterdag" -"Express Saver","Express Bespaarder" -"Express easy","Expres easy" -"Express envelope","Expres envelop" -"Express worldwide","Expres wereldwijd" -"Failed to parse xml document: %s","Niet instaat om XML document: %s te ontleden" -"FedEx","FedEx" -"FedEx 10kg Box","FedEx 10kg Box" -"FedEx 25kg Box","FedEx 25kg Box" -"FedEx Box","FedEx Box" -"FedEx Envelope","FedEx Enveloppe" -"FedEx Pak","FedEx Pak" -"FedEx Tube","FedEx Buis" -"First Overnight","Levering eerstvolgende ochtend van een werkdag" -"First-Class","Eerste Klas" -"Flat","Plat" -"Flat-Rate Box","Plat Tarief Box" -"Flat-Rate Envelope","Plat Tarief Enveloppe" -"Free Method","Gratis Methode" -"Free Shipping with Minimum Order Amount","Gratis Verscheping met Minimale Bestel Grote" -"Freight","Vracht" -"Freight worldwide","Vrachtkosten wereldwijd" -"Gateway URL","Gateway URL" -"Gateway XML URL","Gateway XML URL" -"Gift","Geschenk" -"Girth","Omtrek" -"Globalmail business","Zakelijke Globalmail" -"Ground","Grond" -"Ground Commercial","Grond reclame" -"Ground Residential","Grond woning" -"Handling Applied","Toegepaste behandeling" -"Handling Fee","Behandelingskosten" -"Height","Hoogte" -"Height, width and length should be equal or greater than %s","Hoogte, breedte en lengte moet gelijk of groter zijn dan% s" -"Home Delivery","Thuisbezorging" -"Inches","Inches (duimen)" -"Indirect","Indirect" -"International Economy","Internationaal economie" -"International Express","Internationaal express" -"International First","Internationaal eerst" -"International Ground","Internationaal grond" -"International Priority","Internationaal prioriteit" -"International Shipment Days","Internationaal aantal verzendingsdagen" -"Intl Economy Freight","Intl economie vracht" -"Intl Priority Freight","Intl prioriteit vracht" -"Jetline","Jetline" -"Jumbo box","Jumbo box" -"Key","Sleutel" -"Kilograms","Kilogram" -"Large","Groot" -"Large Express Box","Grote expres doos" -"Length","Lengte" -"Letter","Letter" -"Library","Bibliotheek" -"Live","Live" -"Machinable","Machinaal" -"Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)","Maximum Pakket Gewicht (Neem alstublieft contact op met uw vervoerder voor het maximaal toegestane verstuur gewicht)" -"Media Mail","Mediapost" -"Medical express","Medische express" -"Medium Express Box","Medium Express Box" -"Merchandise","Handelswaar" -"Meter Number","Meter Nummer:" -"Minimum Order Amount for Free Shipping","Minimale Bestellingsgrootheid voor Gratis Versturing" -"Minimum Package Weight (Please consult your shipping carrier for minimum supported shipping weight)","Minimum Pakket Gewicht (Neem alstublieft contact op met uw vervoerder voor het minimaal toegestane verstuur gewicht)" -"Mode","Modus" -"National Freight","Nationale Vracht" -"Next Afternoon","Volgende Middag" -"Next Day Air","Levering volgende werkdag" -"Next Day Air Early AM","Levering volgende werkdag in de vroege ochtend" -"Next Day Air Early AM Letter","Morgen Vroege Ochtend Brief" -"Next Day Air Intra (Puerto Rico)","Morgen Lucht Intro (Puerto Rico)" -"Next Day Air Letter","Morgen Lucht Brief" -"Next Day Air Saver","Levering volgende werkdag" -"Next Day Air Saver Letter","Morgen Lucht Redder Brief" -"No","Nee" -"No packages for request","Geen Pakketjes gevraagd" -"Non Documents","Zonder documenten" -"Non documents","Zonder documenten" -"Non-rectangular","Niet Rechthoekig" -"None","Geen" -"Not Required","Niet Benodigd" -"Order","Bestelling" -"Origin of the Shipment","Herkomst van de Verzending" -"Origin serviceAreaCode is missing","Kengetal van de herkomstdienst ontbreekt" -"Other","Andere" -"Others","Anders" -"PAK","PAK" -"Package","Pakket" -"Package Description","Pakketbeschrijving" -"Packages Request Type","Pakket verzoektype" -"Packaging","Verpakking" -"Pallet","Pallet" -"Parcel","Pakje" -"Parcel Post","Pakketpost" -"Password","Wachtwoord" -"Pickup Method","Ophaalmethode" -"Piece Id barcode is missing","Stuk ID barcode ontbreekt" -"Piece number information is missing","Stuk nummer informatie ontbreekt" -"Please make sure to use only digits here. No dashes are allowed.","Gebruik alleen getallen hier. Streepjes zijn niet toegestaan." -"Pounds","Ponden" -"Priority Mail","Prioritaire Post" -"Priority Overnight","Levering volgende werkdag" -"Product content code is invalid","Inhoudscode van het product is ongeldig" -"Product name is missing","Productnaam ontbreekt" -"Receiver","Ontvanger" -"Rectangular","Rechthoekig" -"Regular","Gewoon" -"Regular Pickup","Gewone ophaal" -"Request Courier","Koerier aanvragen" -"Required","Benodigd" -"Required for negotiated rates; 6-character UPS.","Vereist voor onderhandelde tarieven; 6-karakter UPS." -"Residential","residentieel" -"Residential Delivery","Thuisbezorging" -"Response is in the wrong format","Antwoord is in het verkeerde formaat" -"Return","Retour" -"Round","Rond" -"Routing barcode is missing","Route barcode ontbreekt" -"Same day","Dezelfde dag" -"Sample","Monster" -"Sandbox Mode","Sandbox modus" -"Second Day Service","Tweede Dag Service" -"Secure Gateway URL","Veilige Poort URL" -"Secureline","Secureline" -"Sender","Verzender" -"Sender city info is missing","Info over de stad van de afzender ontbreekt" -"Sender contact name is missing","Contactnaam van de afzender ontbreekt" -"Sender country info is missing","Info over het land van de afzender ontbreekt" -"Service type does not match","Servicetype komt niet overeen" -"Ship to Applicable Countries","Verscheep naar Aanwendbare Landen" -"Ship to Specific Countries","Verscheep naar Gespecificeerde Landen" -"Shipment Contains Hazardous Materials","Verzending Bevat Gevaarlijke Materialen" -"Shipment Dutiable","Verzending Belastbaar" -"Shipment Duty Payment Type","Verzending Belasting Betaling Type" -"Shipment Type","Verzending Type" -"Shipment is not available.","Verzending niet beschikbaar" -"Shipment picked up","Verzending opgehaald" -"Shipper Number","Verzender Nummer" -"Shipping Key","Verzending Sleutel" -"Shipping Key (International)","Verzending Sleutel (Internationaal)" -"Show Method if Not Applicable","Laat Methode Zien indien Niet Mogelijk" -"Signature Required","Handtekening Benodigd" -"Size","Grote" -"Small Express Box","Kleine Express Box" -"Smart Post","Slimme Post" -"Sort Order","Sorteer Bestelling" -"Specific","specifiek" -"Sprintline","Sprintline" -"Standard Overnight","Standaard levering volgende werkdag" -"Station","Station" -"Subtotal","Subtotaal" -"Subtotal With Discount","Subtotaal Met Korting" -"The response is in wrong format.","Het antwoord is in een verkeerd formaat." -"There is no available method for selected shipping address.","Er is geen beschikbare verzending methode voor het geselecteerde adres" -"There is no items in this order","Er zijn geen artikelen in deze bestelling" -"Third Party","Derde Partij" -"Title","Titel" -"To Lower","Omlaag" -"To Upper","Omhoog" -"Tracking XML URL","Tracking XML URL" -"UPS","UPS" -"UPS Expedited","Versnelde UPS" -"UPS Express","UPS Express" -"UPS Express Box","UPS Express Box" -"UPS Express Early A.M.","UPS Express Vroege Levering" -"UPS Express Plus","UPS Express Plus" -"UPS Ground","UPS Over de weg" -"UPS Letter Envelope","UPS Brief Enveloppe" -"UPS Next Day Air","UPS Volgende Dag Lucht" -"UPS Next Day Air Early A.M.","UPS Volgende Dag Lucht Vroeg in de Ochtend" -"UPS Next Day Air Saver","UPS Volgende Dag Lucht Redder" -"UPS Saver","UPS Redder" -"UPS Second Day Air","UPS Tweede Dag Lucht" -"UPS Second Day Air A.M.","UPS Tweede Dag Lucht Vroeg in de Ochtend" -"UPS Standard","UPS Standaard" -"UPS Three-Day Select","UPS Derde Dag Selectie" -"UPS Today Dedicated Courrier","UPS Vandaag Toegewijde Bezorger" -"UPS Today Express","UPS Vandaag Express" -"UPS Today Express Saver","UPS Vandaag Express Redder" -"UPS Today Intercity","UPS Vandaag Intercity" -"UPS Today Standard","UPS Vandaag Standaard" -"UPS Tube","UPS Koker" -"UPS Type","UPS Type" -"UPS Worldwide 10 kilo","UPS Wereldwijd 10 kilo" -"UPS Worldwide 25 kilo","UPS Wereldwijd 25 kilo" -"UPS Worldwide Expedited","UPS Wereldwijd Versneld" -"UPS Worldwide Express","UPS Wereldwijd per Expresse" -"UPS Worldwide Express Plus","UPS Wereldwijd per Expresse Plus" -"UPS Worldwide Express PlusSM","UPS Wereldwijd per Expresse PlusSM" -"UPS Worldwide Saver","UPS Worldwide Saver" -"USPS","USPS" -"Unable to retrieve tracking","Kan de tracking niet terugvinden" -"United Parcel Service","United Pakketdienst" -"United Parcel Service XML","United Pakketdienst XML" -"Unknown error","Onbekende fout" -"Used only when ""Additional Protection Value"" is set to ""Configuration"". Can contain only numeric amount.","Wordt alleen gebruikt wanneer ""Additionele beschermingswaarde"" is ingesteld op ""Configuratie"". Kan alleen numerieke hoeveelheid bevatten." -"User ID","Gebruikers ID" -"Variable","Variabele" -"Waybill barcode information is missing","Vrachtbrief barcode informatie ontbreekt" -"Weight Unit","Gewicht Unit" -"Weight unit is invalid","Gewichtseenheid is ongeldig" -"Width","Breedte" -"Worldwide Expedited","Wereldwijd Versneld" -"Worldwide Express","Wereldwijd per Expresse" -"Worldwide Express Letter","Wereldwijd Brief per Expresse" -"Worldwide Express Plus","Wereldwijd per Expresse Plus" -"Worldwide Express Plus Letter","Wereldwijde expres plus brief" -"Worldwide Express Saver","Wereldwijde expres besparing" -"Wrong Content Type.","Verkeerd inhoudstype" -"Wrong Region.","Verkeerde regio" -"Yes","Ja" -"Your Packaging","Uw verpakking" -"Zero shipping charge for '%s'","Nul verzendkosten voor '% s'" -"cm","cm" -"inch","inch" diff --git a/app/code/Magento/Usa/i18n/pt_BR.csv b/app/code/Magento/Usa/i18n/pt_BR.csv deleted file mode 100644 index 9462d08390f..00000000000 --- a/app/code/Magento/Usa/i18n/pt_BR.csv +++ /dev/null @@ -1,296 +0,0 @@ -" was not delivered nor scanned","não foi entregue ou verificado" -"""Per Order"" allows single handling fee for entire order. ""Per Package"" allows individual handling fee for each package.","""Por Ordem"" permite uma única taxa de manuseio para o pedido inteiro. ""Por Pacote"" permite taxa de manuseio individual para cada pacote." -"1 Day Freight","Frete 1 dia" -"2 Day","2 dias" -"2 Day Freight","Frete 2 dias" -"2Day","2 dias" -"2nd Day Air","2º dia Aéreo" -"2nd Day Air AM","2º dia Aéreo manhã" -"2nd Day Air AM Letter","Carta 2º dia Aéreo Manhã" -"2nd Day Air Letter","Carta 2º dia Aéreo" -"3 Day Freight","Frete 3 dias" -"3 Day Select","3 dias" -"Access ID","ID de acesso" -"Access License Number","Acessar número de licença" -"Account ID","ID da conta" -"Account Number","Número de Conta" -"Additional Protection Configuration Value","Valor da configuração da proteção adicional" -"Additional Protection Enabled","Proteção adicional habilitada" -"Additional Protection Min Subtotal","Subtotal mÃn. da proteção adicional" -"Additional Protection Value","Valor da proteção adicional" -"Additional Protection Value Rounding Method","Método de arredondamento do valor da proteção adicional" -"Adult","Adulto" -"Adult Signature Required","Exigida Assinatura de Adulto" -"Allowed Methods","Métodos Permitidos" -"Allows breaking total order weight into smaller pieces if it exeeds %s %s to ensure accurate calculation of shipping charges.","Permitir que o peso total do pedido seja dividido em partes menores se exceder %s %s para assegurar cálculos corretos de taxas de remessa." -"Allows breaking total order weight into smaller pieces if it exeeds 70 kg to ensure accurate calculation of shipping charges.","Permitir que o peso total do pedido seja dividido em partes menores se exceder 70 kg para assegurar cálculos corretos de taxas de remessa." -"Bound Printed Matter","Encadernar materiais impressos" -"Break bulk economy","Carga fracionada econômica" -"Break bulk express","Carga fracionada expressa" -"Business Service Center","Centro de serviço de negócios" -"Calculate Handling Fee","Calcular a Taxa de Manuseio" -"Canada Standard","Padrão Canadá" -"Cannot identify measure unit for %s","Não foi possÃvel indentificar unidade de medida para %s" -"Cannot identify weight unit for %s","Não foi possÃvel identificar unidade de peso para %s" -"Cannot retrieve shipping rates","Não é possÃvel recuperar taxas de embarque" -"Centimeters","CentÃmetros" -"Commercial","Comercial" -"Configuration","Configuração" -"Container","Recipiente" -"Content Type","Tipo de Conteúdo" -"Customer Packaging","Acondicionamento do Cliente" -"Customer Supplied Package","Pacote Fornecido pelo Cliente" -"Customer services","Atendimento ao cliente" -"DHL","DHL" -"DHL (Deprecated)","DHL (Não aconselhado)" -"Debug","Debug" -"Default Package Height","Altura Padrão do Pacote" -"Default Package Length","Comprimento Padrão do Pacote" -"Default Package Width","Largura Padrão do Pacote" -"Delivered","Entregue" -"Delivery Confirmation","Confirmação de entrega" -"Depth","Profundidade" -"Destination Type","Tipo de Destino" -"Destination facility code is empty","O código do local de destino está vazio" -"Development","Desenvolvimento" -"Direct","Direto" -"Displayed Error Message","Mensagem de Erro Apresentada" -"Divide Order Weight","Dividir Peso do Pedido" -"Documents","Documentos" -"Domestic Shipment Days","Dias de Embarque Doméstico" -"Domestic economy select","Seleção econômica doméstica" -"Domestic express","Expresso doméstico" -"Drop Box","Caixa Suspensa" -"Dropoff","Caixa de correio" -"Easy shop","Compre fácil" -"Economy select","Seleção econômica" -"Empty response","Resposta vazia" -"Enable Negotiated Rates","Habilitar Taxas Negociadas" -"Enabled for Checkout","Habilitado para checkout" -"Enables/Disables SSL verification of Magento server by UPS.","Habilita/Desabilita verificação SSL de servidor Magento por UPS." -"Error #%s : %s","Erro #%s : %s" -"Error #%s : %s (%s)","Erro #%s : %s (%s)" -"Error #%s: %s","Erro #%s: %s" -"Europack","Europack" -"Europe First Priority","Europa Prioridade" -"Exchange rate %s (Base Currency) -> %s not found. DHL method %s skipped","Taxa de câmbio %s (Moeda Base) -> %s não encontrada. Método DHL %s omitido" -"Express","Expresso" -"Express 10:30","Expressa 10:30" -"Express 10:30 AM","Expresso 10:30 AM" -"Express 12:00","Expressa 12:00" -"Express 9:00","Express 9:00" -"Express Mail","Correio Expresso" -"Express Saturday","Expresso de Sábado" -"Express Saver","Express Econômico" -"Express easy","Expresso fácil" -"Express envelope","Envelope expresso" -"Express worldwide","Expresso mundial" -"Failed to parse xml document: %s","Falha ao analisar documento xml: %s" -"FedEx","FedEx" -"FedEx 10kg Box","FedEx 10kg Box" -"FedEx 25kg Box","FedEx 25kg Box" -"FedEx Box","FedEx Box" -"FedEx Envelope","FedEx Envelope" -"FedEx Pak","FedEx Pak" -"FedEx Tube","FedEx Tube" -"First Overnight","Primeira Pernoite" -"First-Class","Primeira Classe" -"Flat","Plano" -"Flat-Rate Box","Caixa fixa" -"Flat-Rate Envelope","Envelope Fixo" -"Free Method","Método grátis" -"Free Shipping with Minimum Order Amount","Envio grátis com Valor MÃnimo de Encomenda" -"Freight","Frete" -"Freight worldwide","Frete mundial" -"Gateway URL","URL do Gateway" -"Gateway XML URL","Porta de Entrada XML URL" -"Gift","Presente" -"Girth","Circunferência" -"Globalmail business","Negócios de remessa global" -"Ground","Terreno" -"Ground Commercial","Terreno Comercial" -"Ground Residential","Terreno Residencial" -"Handling Applied","Manuseio Aplicado" -"Handling Fee","Taxa de Manuseio" -"Height","Altura" -"Height, width and length should be equal or greater than %s","Altura, largura e comprimento devem ser iguais ou maiores que %s" -"Home Delivery","Entrega em DomicÃlio" -"Inches","Polegadas" -"Indirect","Indireto" -"International Economy","Economia Internacional" -"International Express","Expresso Internacional" -"International First","Internacional Primeiro" -"International Ground","Terreno Internacional" -"International Priority","Prioridade Internacional" -"International Shipment Days","Dias de Remessa Internacional" -"Intl Economy Freight","Frete de Economia Internacional" -"Intl Priority Freight","Frete de Prioridade Internacional" -"Jetline","Jetline" -"Jumbo box","Caixa jumbo" -"Key","Senha" -"Kilograms","Quilogramas" -"Large","Grande" -"Large Express Box","Caixa Expressa Grande" -"Length","Comprimento" -"Letter","Carta" -"Library","Biblioteca" -"Live","Ao Vivo" -"Machinable","Maquinável" -"Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)","Peso Máximo do Pacote (Por favor consulte a sua operadora de transporte para o peso máximo de transporte suportado)" -"Media Mail","Correio de MÃdia" -"Medical express","Expresso médico" -"Medium Express Box","Caixa Expresso Média" -"Merchandise","Merchandise" -"Meter Number","Número Medidor" -"Minimum Order Amount for Free Shipping","Valor do Pedido MÃnimo para Frete Grátis" -"Minimum Package Weight (Please consult your shipping carrier for minimum supported shipping weight)","Peso MÃnimo do Pacote (Por favor consulte a sua operadora de transporte para o peso mÃnimo de transporte suportado)" -"Mode","Modo" -"National Freight","Frete Nacional" -"Next Afternoon","Tarde Seguinte" -"Next Day Air","Aéreo Dia Seguinte" -"Next Day Air Early AM","Aéreo InÃcio da Manhã do Dia Seguinte" -"Next Day Air Early AM Letter","Carta Aérea InÃcio da Manhã do Dia Seguinte" -"Next Day Air Intra (Puerto Rico)","Aéreo Interno Dia Seguinte (Porto Rico)" -"Next Day Air Letter","Carta Aérea Dia Seguinte" -"Next Day Air Saver","Aéreo Econômico Dia Seguinte" -"Next Day Air Saver Letter","Carta Aérea Econômica Dia Seguinte" -"No","Não" -"No packages for request","Nenhum pacote para o pedido" -"Non Documents","Não documentos" -"Non documents","Não documentos" -"Non-rectangular","Não retangular" -"None","Nenhum" -"Not Required","Não é Necessário" -"Order","Pedido" -"Origin of the Shipment","Origem da Remessa" -"Origin serviceAreaCode is missing","O Código de origem da área de serviço está faltando" -"Other","Outra" -"Others","Outros" -"PAK","PAK" -"Package","Embalagem" -"Package Description","Descrição do pacote" -"Packages Request Type","Tipo de Solicitação de Pacotes" -"Packaging","Acondicionamento" -"Pallet","Paleta" -"Parcel","Pacote" -"Parcel Post","Encomenda Postal" -"Password","Senha" -"Pickup Method","Método de Coleta" -"Piece Id barcode is missing","O código de barras da peça está faltando" -"Piece number information is missing","Faltam informações sobre o número da peça" -"Please make sure to use only digits here. No dashes are allowed.","Por favor, certifique-se de usar somente dÃgitos aqui. Travessões não são permitidos." -"Pounds","Libras" -"Priority Mail","Correio Prioritário" -"Priority Overnight","Prioridade durante a noite" -"Product content code is invalid","O código do conteúdo do produto é inválido" -"Product name is missing","O nome do produto está faltando" -"Receiver","Destinatário" -"Rectangular","Retangular" -"Regular","Regular" -"Regular Pickup","Coleta Regular" -"Request Courier","Solicitar correio" -"Required","Obrigatório" -"Required for negotiated rates; 6-character UPS.","Requerido para taxas negociadas; UPS de 6 caracteres." -"Residential","Residencial" -"Residential Delivery","Entrega Residencial" -"Response is in the wrong format","A resposta está em formato errado" -"Return","Retorno" -"Round","Arredondado" -"Routing barcode is missing","O código de barras de direcionamento está faltando" -"Same day","Mesmo dia" -"Sample","Amostra" -"Sandbox Mode","Modo Sandbox" -"Second Day Service","Serviço de Segundo Dia" -"Secure Gateway URL","Porta de Entrada URL Segura" -"Secureline","Linha segura" -"Sender","Remetente" -"Sender city info is missing","A informação cidade do remetente está faltando" -"Sender contact name is missing","O nome do remetente está faltando" -"Sender country info is missing","O paÃs do remetente está faltando" -"Service type does not match","O tipo de serviço não combina" -"Ship to Applicable Countries","Enviar a PaÃses Aplicáveis" -"Ship to Specific Countries","Enviar a PaÃses EspecÃficos" -"Shipment Contains Hazardous Materials","A remessa contém materiais perigosos" -"Shipment Dutiable","Remessa tributável" -"Shipment Duty Payment Type","Tipo de Pagamento Oficial da Remessa" -"Shipment Type","Tipo de Remessa" -"Shipment is not available.","A remessa não está disponÃvel" -"Shipment picked up","Remessa coletada" -"Shipper Number","Número do Expedidor" -"Shipping Key","Chave de Expedição" -"Shipping Key (International)","Chave de Expedição (Internacional)" -"Show Method if Not Applicable","Mostrar Método se Não Aplicável" -"Signature Required","Assinatura Requerida" -"Size","Tamanho" -"Small Express Box","Caixa Expressa Pequena" -"Smart Post","Postagem Inteligente" -"Sort Order","Classificar pedido" -"Specific","EspecÃfico" -"Sprintline","Sprintline" -"Standard Overnight","Pernoite Padrão" -"Station","Estação" -"Subtotal","Subtotal" -"Subtotal With Discount","Subtotal com desconto" -"The response is in wrong format.","A resposta está em formato errado." -"There is no available method for selected shipping address.","Não há método disponÃvel para o endereço de entrega selecionado." -"There is no items in this order","Não há itens neste pedido" -"Third Party","Terceiros" -"Title","TÃtulo" -"To Lower","mais abaixo" -"To Upper","mais acima" -"Tracking XML URL","Rastreamento XML URL" -"UPS","UPS" -"UPS Expedited","UPS Acelerado" -"UPS Express","UPS Expresso" -"UPS Express Box","UPS Caixa Expressa" -"UPS Express Early A.M.","UPS Expresso Manhã" -"UPS Express Plus","UPS Expresso Plus" -"UPS Ground","UPS Por terra" -"UPS Letter Envelope","UPS Envelope de Carta" -"UPS Next Day Air","UPS Dia Seguinte" -"UPS Next Day Air Early A.M.","UPS Manhã do Dia Seguinte" -"UPS Next Day Air Saver","UPS Dia Seguinte Econômico" -"UPS Saver","UPS Econômico" -"UPS Second Day Air","UPS Segundo Dia" -"UPS Second Day Air A.M.","UPS Manhã do Segundo Dia" -"UPS Standard","UPS Padrão" -"UPS Three-Day Select","UPS Três dias" -"UPS Today Dedicated Courrier","UPS Correio de Entrega Hoje" -"UPS Today Express","UPS Expresso Hoje" -"UPS Today Express Saver","UPS Expresso Hoje Econômico" -"UPS Today Intercity","UPS Hoje Interurbano" -"UPS Today Standard","UPS Hoje Padrão" -"UPS Tube","UPS Tubo" -"UPS Type","UPS Tipo" -"UPS Worldwide 10 kilo","UPS Mundial 10kg" -"UPS Worldwide 25 kilo","UPS Mundial 25kg" -"UPS Worldwide Expedited","UPS Mundial Acelerado" -"UPS Worldwide Express","UPS Mundial Expresso" -"UPS Worldwide Express Plus","UPS Mundial Expresso Plus" -"UPS Worldwide Express PlusSM","UPS Mundial Expresso PlusSM" -"UPS Worldwide Saver","UPS Mundial Econômico" -"USPS","USPS" -"Unable to retrieve tracking","Não é possÃvel recuperar o rastreamento" -"United Parcel Service","United Parcel Service" -"United Parcel Service XML","United Parcel Service XML" -"Unknown error","Erro desconhecido" -"Used only when ""Additional Protection Value"" is set to ""Configuration"". Can contain only numeric amount.","Usado somente quando ""Valor de Proteção Adicional"" é acionado em ""Configuração"". Só é possÃvel conter quantidade numérica." -"User ID","Identificação do Usuário" -"Variable","Variável" -"Waybill barcode information is missing","As informações do código de barra da guia de mercadorias estão faltando" -"Weight Unit","Unidade de Peso" -"Weight unit is invalid","Unidade de peso inválida" -"Width","Largura" -"Worldwide Expedited","Mundial Acelerado" -"Worldwide Express","Mundial Expresso" -"Worldwide Express Letter","Carta Mundial Expressa" -"Worldwide Express Plus","Mundial Expresso Plus" -"Worldwide Express Plus Letter","Carta Mundial Express Plus" -"Worldwide Express Saver","Economizador Mundial Express" -"Wrong Content Type.","Tipo de Conteúdo Errado." -"Wrong Region.","Região Errada." -"Yes","Sim" -"Your Packaging","Sua Embalagem" -"Zero shipping charge for '%s'","Taxa de remessa zero para %s'" -"cm","cm" -"inch","polegada" diff --git a/app/code/Magento/Usa/i18n/zh_CN.csv b/app/code/Magento/Usa/i18n/zh_CN.csv deleted file mode 100644 index ac55be8aff8..00000000000 --- a/app/code/Magento/Usa/i18n/zh_CN.csv +++ /dev/null @@ -1,296 +0,0 @@ -" was not delivered nor scanned","尚未å‘布或扫æ" -"""Per Order"" allows single handling fee for entire order. ""Per Package"" allows individual handling fee for each package.","“预定â€å¯ä»¥è®©æ•´ä¸ªè®¢å•åªæ”¶å–一笔处ç†è´¹ç”¨ã€‚“æ¯åŒ…裹â€éœ€è¦ä¸ºæ¯ä¸ªåŒ…裹收å–处ç†è´¹ç”¨ã€‚" -"1 Day Freight","1天é€è¾¾" -"2 Day","2天" -"2 Day Freight","2天é€è¾¾" -"2Day","2天" -"2nd Day Air","2天航空" -"2nd Day Air AM","第二天航空æœè‡³" -"2nd Day Air AM Letter","第二天航空æœè‡³ä¿¡ä»¶" -"2nd Day Air Letter","第二天航空信件" -"3 Day Freight","3天é€è¾¾" -"3 Day Select","3天选择" -"Access ID","访问ID" -"Access License Number","访问许å¯ç¼–å·" -"Account ID","叿ˆ·ID" -"Account Number","叿ˆ·å·ç " -"Additional Protection Configuration Value","é¢å¤–çš„ä¿æŠ¤å·²å¯ç”¨" -"Additional Protection Enabled","é¢å¤–çš„ä¿æŠ¤å·²å¯ç”¨" -"Additional Protection Min Subtotal","é¢å¤–çš„ä¿æŠ¤å‡åŽ»å°è®¡" -"Additional Protection Value","é¢å¤–ä¿æŠ¤çš„ä»·å€¼" -"Additional Protection Value Rounding Method","é¢å¤–ä¿æŠ¤ä»·å€¼å‡‘æ•´æ–¹æ³•" -"Adult","æˆäºº" -"Adult Signature Required","éœ€è¦æ ¸å¯¹ç¾å" -"Allowed Methods","å…许的方å¼" -"Allows breaking total order weight into smaller pieces if it exeeds %s %s to ensure accurate calculation of shipping charges.","为确ä¿å‡†ç¡®ä¼°ç®—è¿è´¹ï¼Œå¯å°†é‡é‡è¶…过 %s %s 的包裹拆分为多个å°ä»¶ã€‚" -"Allows breaking total order weight into smaller pieces if it exeeds 70 kg to ensure accurate calculation of shipping charges.","为确ä¿å‡†ç¡®ä¼°ç®—è¿è´¹ï¼Œæ€»é‡é‡è¶…过 70kg 的包裹将拆分为多个å°ä»¶ã€‚" -"Bound Printed Matter","有å°é¢çš„å°åˆ·å“" -"Break bulk economy","ç»æµŽå¼æ‹†åˆ†" -"Break bulk express","å¿«é€Ÿå¼æ‹†åˆ†" -"Business Service Center","商业æœåŠ¡ä¸å¿ƒ" -"Calculate Handling Fee","计算的手ç»è´¹" -"Canada Standard","åŠ æ‹¿å¤§æ ‡å‡†" -"Cannot identify measure unit for %s","æ— æ³•ç¡®è®¤ %s 的度é‡å•ä½" -"Cannot identify weight unit for %s","æ— æ³•ç¡®è®¤ %s çš„é‡é‡å•ä½" -"Cannot retrieve shipping rates","æ— æ³•èŽ·å–è¿è´¹" -"Centimeters","厘米" -"Commercial","商业" -"Configuration","é…ç½®" -"Container","容器" -"Content Type","内容类型" -"Customer Packaging","客户自å–" -"Customer Supplied Package","客户æä¾›åŒ…裹" -"Customer services","客户æœåŠ¡" -"DHL","DHL" -"DHL (Deprecated)","DHL(ä¸èµžæˆï¼‰" -"Debug","调试" -"Default Package Height","默认包裹高度" -"Default Package Length","默认包裹长度" -"Default Package Width","默认包裹宽度" -"Delivered","已交付" -"Delivery Confirmation","交付确认" -"Depth","深度" -"Destination Type","目的地类型" -"Destination facility code is empty","目的地代ç 为空" -"Development","å¼€å‘" -"Direct","直接" -"Displayed Error Message","显示的错误信æ¯" -"Divide Order Weight","拆分订å•é‡é‡" -"Documents","文档" -"Domestic Shipment Days","国内è¿é€å¤©æ•°" -"Domestic economy select","é€‰æ‹©ç»æµŽåž‹" -"Domestic express","选择快速型" -"Drop Box","å–ä»¶ç®±" -"Dropoff","自å–" -"Easy shop","è½»æ¾è´ç‰©" -"Economy select","é€‰æ‹©ç»æµŽçš„" -"Empty response","æ— éœ€åº”ç”" -"Enable Negotiated Rates","å¯ç”¨å商费率" -"Enabled for Checkout","为付款å¯ç”¨" -"Enables/Disables SSL verification of Magento server by UPS.","å¯ç”¨/ç¦ç”¨UPS对MagentoæœåŠ¡å™¨çš„SSL验è¯ã€‚" -"Error #%s : %s","错误 #%s : %s" -"Error #%s : %s (%s)","错误 #%s : %s (%s)" -"Error #%s: %s","错误 #%s: %s" -"Europack","欧洲" -"Europe First Priority","欧洲优先" -"Exchange rate %s (Base Currency) -> %s not found. DHL method %s skipped","费率 %s (基本货å¸) -> %s 未找到。DHL 方法 %s 被跳过" -"Express","快速" -"Express 10:30","快速 10:30" -"Express 10:30 AM","快速早10:30" -"Express 12:00","快速 12:00" -"Express 9:00","快速 9:00" -"Express Mail","快速邮件" -"Express Saturday","快速周å…" -"Express Saver","å¿«é€Ÿç»æµŽ" -"Express easy","快速简å•" -"Express envelope","快速信å°" -"Express worldwide","快速全çƒ" -"Failed to parse xml document: %s","è§£æžxml文档 %s 出错" -"FedEx","FedEx" -"FedEx 10kg Box","FedEx 10公斤箱å" -"FedEx 25kg Box","DefEx 25公斤箱å" -"FedEx Box","FedEx ç®±å" -"FedEx Envelope","FedExä¿¡å°" -"FedEx Pak","FedEx èšé…¯åŒ…装" -"FedEx Tube","FedEx 包装管" -"First Overnight","次日达" -"First-Class","一类" -"Flat","å¹³å¦" -"Flat-Rate Box","平纸箱" -"Flat-Rate Envelope","平信å°" -"Free Method","å…费方法" -"Free Shipping with Minimum Order Amount","有最å°è®¢å•æ•°é‡è¦æ±‚çš„å…è´¹é€è´§" -"Freight","é€è¾¾" -"Freight worldwide","直飞全çƒ" -"Gateway URL","网关 URL" -"Gateway XML URL","网关 XML URL" -"Gift","礼å“" -"Girth","周长" -"Globalmail business","å…¨çƒé‚®å¯„业务" -"Ground","地é¢" -"Ground Commercial","地é¢è¿é€" -"Ground Residential","地é¢ä½å®…" -"Handling Applied","需è¦çš„处ç†" -"Handling Fee","处ç†è´¹" -"Height","高度" -"Height, width and length should be equal or greater than %s","高度ã€å®½åº¦ï¼ŒåŠé•¿åº¦å¿…é¡»ç‰äºŽæˆ–大于 %s" -"Home Delivery","å®¶åºè¿é€" -"Inches","英寸" -"Indirect","éžç›´æŽ¥" -"International Economy","å›½é™…ç»æµŽåž‹" -"International Express","国际快速型" -"International First","国际优先" -"International Ground","国际陆云" -"International Priority","国际优先" -"International Shipment Days","国际é€è´§æ—¥" -"Intl Economy Freight","å›½é™…ç»æµŽè¾¾" -"Intl Priority Freight","国际优先达" -"Jetline","Jetline" -"Jumbo box","Jumbo ç®±" -"Key","密钥" -"Kilograms","åƒå…‹" -"Large","大型" -"Large Express Box","大型快递箱" -"Length","长度" -"Letter","ä¿¡ä»¶" -"Library","图书馆" -"Live","动æ€" -"Machinable","å¯åŠ å·¥" -"Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)","最大包裹é‡é‡ï¼ˆå¯æ”¯æŒçš„æœ€å¤§åŒ…裹é‡é‡è¯·å’¨è¯¢æ‚¨çš„物æµå…¬å¸ï¼‰" -"Media Mail","媒体邮件" -"Medical express","医疗快速" -"Medium Express Box","ä¸ç‰å¿«é€’ç®±" -"Merchandise","商å“" -"Meter Number","仪表编å·" -"Minimum Order Amount for Free Shipping","å…费货è¿çš„æœ€å°è®¢å•é‡" -"Minimum Package Weight (Please consult your shipping carrier for minimum supported shipping weight)","最å°åŒ…裹é‡é‡ï¼ˆå¯æ”¯æŒçš„æœ€å°åŒ…裹é‡é‡è¯·å’¨è¯¢æ‚¨çš„物æµå…¬å¸ï¼‰" -"Mode","模å¼" -"National Freight","全国达" -"Next Afternoon","第二天下åˆ" -"Next Day Air","下一日空è¿" -"Next Day Air Early AM","ä¸‹ä¸€æ—¥ç©ºè¿æœè‡³" -"Next Day Air Early AM Letter","ä¸‹ä¸€æ—¥ç©ºè¿æœè‡³ä¿¡ä»¶" -"Next Day Air Intra (Puerto Rico)","下一日空è¿ï¼ˆæ³¢å¤šé»Žå„)" -"Next Day Air Letter","下一日空è¿ä¿¡ä»¶" -"Next Day Air Saver","下一日空è¿èŠ‚çº¦åž‹" -"Next Day Air Saver Letter","下一日空è¿èŠ‚çº¦åž‹ä¿¡ä»¶" -"No","å¦" -"No packages for request","æ— æ‰€è¯·æ±‚çš„åŒ…è£¹" -"Non Documents","æ— æ–‡æ¡£" -"Non documents","æ— æ–‡æ¡£" -"Non-rectangular","éžçŸ©å½¢" -"None","æ— " -"Not Required","éžå¿…é¡»" -"Order","订å•" -"Origin of the Shipment","å§‹å‘è¿é€" -"Origin serviceAreaCode is missing","æ¥æºæœåŠ¡åŒºåŸŸä»£ç 丢失" -"Other","其它" -"Others","å…¶ä»–" -"PAK","PAK" -"Package","包裹" -"Package Description","包裹æè¿°" -"Packages Request Type","包裹请求类型" -"Packaging","打包" -"Pallet","托盘" -"Parcel","å°åŒ…" -"Parcel Post","邮政包裹" -"Password","密ç " -"Pickup Method","å–货方法" -"Piece Id barcode is missing","ä»·æ ¼ ID æ¡ç 丢失" -"Piece number information is missing","ä»·æ ¼æ•°å—ä¿¡æ¯ä¸¢å¤±" -"Please make sure to use only digits here. No dashes are allowed.","请在这里åªä½¿ç”¨æ•°å—,ä¸èƒ½ä½¿ç”¨æ¨ªçº¿ã€‚" -"Pounds","磅" -"Priority Mail","优先邮件" -"Priority Overnight","第二天优先" -"Product content code is invalid","产å“å†…å®¹ä»£ç æ— 效" -"Product name is missing","产å“å称丢失" -"Receiver","收件人" -"Rectangular","矩形" -"Regular","常规" -"Regular Pickup","常规å–ä»¶" -"Request Courier","需è¦å¿«é€’员" -"Required","å¿…é¡»" -"Required for negotiated rates; 6-character UPS.","费率需å商,6å—符 UPS。" -"Residential","ä½å®…" -"Residential Delivery","ä½å®…é€è´§" -"Response is in the wrong format","å“åº”çš„æ ¼å¼æœ‰è¯¯" -"Return","退货" -"Round","周围" -"Routing barcode is missing","æµè½¬æ¡ç 丢失" -"Same day","当天" -"Sample","范例" -"Sandbox Mode","沙箱模å¼" -"Second Day Service","第二日æœåŠ¡" -"Secure Gateway URL","安全网关URL" -"Secureline","安全线" -"Sender","å‘逿–¹" -"Sender city info is missing","å‘逿–¹åŸŽå¸‚ä¿¡æ¯ä¸¢å¤±" -"Sender contact name is missing","å‘逿–¹è”系人姓å丢失" -"Sender country info is missing","å‘逿–¹å›½å®¶ä¿¡æ¯ä¸¢å¤±" -"Service type does not match","æœåŠ¡ç±»åž‹ä¸åŒ¹é…" -"Ship to Applicable Countries","å‘é€åˆ°é€‚用的国家" -"Ship to Specific Countries","å‘é€åˆ°æŒ‡å®šå›½å®¶" -"Shipment Contains Hazardous Materials","è¿å•包å«å±é™©ç‰©å“" -"Shipment Dutiable","è¿å•应纳税" -"Shipment Duty Payment Type","è¿å•税务支付类型" -"Shipment Type","è¿é€ç±»åž‹" -"Shipment is not available.","è¿é€ä¸å¯ç”¨ã€‚" -"Shipment picked up","è¿å•å–ä»¶" -"Shipper Number","è¿å•å·" -"Shipping Key","è¿å•密钥" -"Shipping Key (International)","è¿å•密钥(国际)" -"Show Method if Not Applicable","如果ä¸å¯ç”¨ï¼Œæ˜¾ç¤ºå…¶ä»–方法" -"Signature Required","需è¦ç¾å" -"Size","尺寸" -"Small Express Box","快递å°ç®±" -"Smart Post","智能å‘布" -"Sort Order","排åºé¡ºåº" -"Specific","指定" -"Sprintline","Sprintline" -"Standard Overnight","æ ‡å‡†æ¬¡æ—¥" -"Station","ç«™å°" -"Subtotal","å°è®¡" -"Subtotal With Discount","ä¸å«æŠ˜æ‰£å°è®¡" -"The response is in wrong format.","å“åº”æ ¼å¼æœ‰è¯¯ã€‚" -"There is no available method for selected shipping address.","所选è¿é€åœ°å€æ²¡æœ‰å¯ç”¨è¿é€æ–¹æ³•。" -"There is no items in this order","该订å•ä¸åŒ…å«å•†å“" -"Third Party","第三方" -"Title","æ ‡é¢˜" -"To Lower","è¦é™ä½Ž" -"To Upper","è¦å‡é«˜" -"Tracking XML URL","追踪XML URL" -"UPS","UPS" -"UPS Expedited","UPSåŠ å¿«" -"UPS Express","UPS快速" -"UPS Express Box","UPSå¿«ä»¶ç®±" -"UPS Express Early A.M.","UPS快速æœè‡³" -"UPS Express Plus","UPSå¿«é€ŸåŠ æ€¥" -"UPS Ground","UPS陆è¿" -"UPS Letter Envelope","UPSä¿¡å°" -"UPS Next Day Air","UPS次日空è¿" -"UPS Next Day Air Early A.M.","UPSæ¬¡æ—¥ç©ºè¿æœè‡³" -"UPS Next Day Air Saver","UPS次日空è¿èŠ‚çº¦åž‹" -"UPS Saver","UPS节约型" -"UPS Second Day Air","UPS次日空è¿" -"UPS Second Day Air A.M.","UPSæ¬¡æ—¥ç©ºè¿æœè‡³" -"UPS Standard","UPSæ ‡å‡†åž‹" -"UPS Three-Day Select","UPS第三天选择" -"UPS Today Dedicated Courrier","UPS当天专è¿" -"UPS Today Express","UPS当天快速" -"UPS Today Express Saver","UPS当天快速节约型" -"UPS Today Intercity","UPS当天城际" -"UPS Today Standard","UPSå½“å¤©æ ‡å‡†åž‹" -"UPS Tube","UPS包装管" -"UPS Type","UPS类型" -"UPS Worldwide 10 kilo","UPSå…¨çƒ10公斤" -"UPS Worldwide 25 kilo","UPSå…¨çƒ25公斤" -"UPS Worldwide Expedited","UPSå…¨çƒä¸“è¿" -"UPS Worldwide Express","UPSå…¨çƒå¿«é€Ÿ" -"UPS Worldwide Express Plus","UPSå…¨çƒå¿«é€ŸåŠ æ€¥" -"UPS Worldwide Express PlusSM","UPSå…¨çƒå¿«é€ŸåŠ æ€¥SM" -"UPS Worldwide Saver","UPS Worldwide Saver" -"USPS","USPS" -"Unable to retrieve tracking","æ— æ³•èŽ·å–追踪" -"United Parcel Service","美国è”åˆåŒ…裹æœåŠ¡" -"United Parcel Service XML","美国è”åˆåŒ…裹æœåŠ¡XML" -"Unknown error","未知错误" -"Used only when ""Additional Protection Value"" is set to ""Configuration"". Can contain only numeric amount.","åªæœ‰åœ¨â€œé¢å¤–ä¿æŠ¤ä»·å€¼â€è¢«è®¾ç½®ä¸ºâ€œé…ç½®â€æ—¶ä½¿ç”¨ã€‚åªèƒ½åŒ…嫿•°é¢ã€‚" -"User ID","用户ID" -"Variable","å˜é‡" -"Waybill barcode information is missing","Waybill æ¡ç ä¿¡æ¯ä¸¢å¤±" -"Weight Unit","é‡é‡å•ä½" -"Weight unit is invalid","é‡é‡å•使— 效" -"Width","宽" -"Worldwide Expedited","å…¨çƒä¸“递" -"Worldwide Express","å…¨çƒå¿«é€Ÿ" -"Worldwide Express Letter","å…¨çƒå¿«é€Ÿä¿¡ä»¶" -"Worldwide Express Plus","å…¨çƒå¿«é€ŸåŠ æ€¥" -"Worldwide Express Plus Letter","å…¨çƒå¿«é€ŸåŠ æ€¥ä¿¡ä»¶" -"Worldwide Express Saver","å…¨çƒå¿«é€ŸèŠ‚çº¦åž‹" -"Wrong Content Type.","内容类型有误。" -"Wrong Region.","地区有误。" -"Yes","是" -"Your Packaging","您的包裹" -"Zero shipping charge for '%s'","'%s' å…è¿è´¹" -"cm","厘米" -"inch","英寸" diff --git a/app/code/Magento/User/Block/User/Edit/Tab/Main.php b/app/code/Magento/User/Block/User/Edit/Tab/Main.php index 703c2f234db..40ecaaa8d22 100644 --- a/app/code/Magento/User/Block/User/Edit/Tab/Main.php +++ b/app/code/Magento/User/Block/User/Edit/Tab/Main.php @@ -35,11 +35,17 @@ class Main extends \Magento\Backend\Block\Widget\Form\Generic */ protected $_authSession; + /** + * @var \Magento\Locale\ListsInterface + */ + protected $_LocaleLists; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory * @param \Magento\Backend\Model\Auth\Session $authSession + * @param \Magento\Locale\ListsInterface $localeLists * @param array $data */ public function __construct( @@ -47,9 +53,11 @@ class Main extends \Magento\Backend\Block\Widget\Form\Generic \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, \Magento\Backend\Model\Auth\Session $authSession, + \Magento\Locale\ListsInterface $localeLists, array $data = array() ) { $this->_authSession = $authSession; + $this->_LocaleLists = $localeLists; parent::__construct($context, $registry, $formFactory, $data); } @@ -129,7 +137,7 @@ class Main extends \Magento\Backend\Block\Widget\Form\Generic 'name' => 'interface_locale', 'label' => __('Interface Locale'), 'title' => __('Interface Locale'), - 'values' => $this->_locale->getTranslatedOptionLocales(), + 'values' => $this->_LocaleLists->getTranslatedOptionLocales(), 'class' => 'select', )); diff --git a/app/code/Magento/User/Controller/Adminhtml/User.php b/app/code/Magento/User/Controller/Adminhtml/User.php index a01d8b69c05..6ba29f98324 100644 --- a/app/code/Magento/User/Controller/Adminhtml/User.php +++ b/app/code/Magento/User/Controller/Adminhtml/User.php @@ -105,7 +105,7 @@ class User extends \Magento\Backend\App\AbstractAction return; } } else { - $model->setInterfaceLocale(\Magento\Core\Model\LocaleInterface::DEFAULT_LOCALE); + $model->setInterfaceLocale(\Magento\Locale\ResolverInterface::DEFAULT_LOCALE); } $this->_title->add($model->getId() ? $model->getName() : __('New User')); @@ -153,7 +153,7 @@ class User extends \Magento\Backend\App\AbstractAction $currentUser = $this->_objectManager->get('Magento\Backend\Model\Auth\Session')->getUser(); if ($userId == $currentUser->getId() - && $this->_objectManager->get('Magento\Core\Model\Locale\Validator')->isValid($data['interface_locale']) + && $this->_objectManager->get('Magento\Locale\Validator')->isValid($data['interface_locale']) ) { $this->_objectManager->get('Magento\Backend\Model\Locale\Manager') ->switchBackendInterfaceLocale($data['interface_locale']); diff --git a/app/code/Magento/User/Model/Role.php b/app/code/Magento/User/Model/Role.php index 7d5bce6557e..cc5802cd771 100644 --- a/app/code/Magento/User/Model/Role.php +++ b/app/code/Magento/User/Model/Role.php @@ -45,6 +45,11 @@ namespace Magento\User\Model; */ class Role extends \Magento\Core\Model\AbstractModel { + /** + * @var string + */ + protected $_eventPrefix = 'admin_roles'; + /** * @var \Magento\User\Model\Resource\Role\User\CollectionFactory */ @@ -53,9 +58,9 @@ class Role extends \Magento\Core\Model\AbstractModel /** * @param \Magento\Model\Context $context * @param \Magento\Registry $registry - * @param \Magento\User\Model\Resource\Role\User\CollectionFactory $userRolesFactory - * @param \Magento\User\Model\Resource\Role $resource - * @param \Magento\User\Model\Resource\Role\Collection $resourceCollection + * @param Resource\Role\User\CollectionFactory $userRolesFactory + * @param Resource\Role $resource + * @param Resource\Role\Collection $resourceCollection * @param array $data */ public function __construct( @@ -91,11 +96,6 @@ class Role extends \Magento\Core\Model\AbstractModel $this->_resourceCollection = $objectManager->get('Magento\User\Model\Resource\Role\Collection'); } - /** - * @var string - */ - protected $_eventPrefix = 'admin_roles'; - /** * Class constructor * diff --git a/app/code/Magento/User/Model/User.php b/app/code/Magento/User/Model/User.php index 2303d06abda..57f0758d935 100644 --- a/app/code/Magento/User/Model/User.php +++ b/app/code/Magento/User/Model/User.php @@ -627,7 +627,7 @@ class User */ protected function _getEncodedPassword($password) { - return $this->_encryptor->getHash($password, 2); + return $this->_encryptor->getHash($password, true); } /** diff --git a/app/code/Magento/User/etc/module.xml b/app/code/Magento/User/etc/module.xml index 6a867c9e3ba..fc9ad8bb2e7 100755 --- a/app/code/Magento/User/etc/module.xml +++ b/app/code/Magento/User/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config> - <module name="Magento_User" version="1.6.1.5" active="true"> + <module name="Magento_User" version="1.6.1.6" active="true"> <sequence> <module name="Magento_Backend"/> </sequence> diff --git a/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.3-1.6.1.4.php b/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.3-1.6.1.4.php index f27b3532f81..9d448164b7d 100644 --- a/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.3-1.6.1.4.php +++ b/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.3-1.6.1.4.php @@ -34,6 +34,6 @@ $connection->addColumn($installer->getTable('admin_user'), 'interface_locale', a 'type' => \Magento\DB\Ddl\Table::TYPE_TEXT, 'length' => 5, 'nullable' => false, - 'default' => \Magento\Core\Model\LocaleInterface::DEFAULT_LOCALE, + 'default' => \Magento\Locale\ResolverInterface::DEFAULT_LOCALE, 'comment' => 'Backend interface locale' )); \ No newline at end of file diff --git a/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.5-1.6.1.6.php b/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.5-1.6.1.6.php new file mode 100644 index 00000000000..e91609f20e4 --- /dev/null +++ b/app/code/Magento/User/sql/user_setup/upgrade-1.6.1.5-1.6.1.6.php @@ -0,0 +1,36 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/* @var $installer \Magento\Core\Model\Resource\Setup */ +$installer = $this; + +$connection = $installer->getConnection(); + +// Increase length of the password column to accommodate passwords with long salts +$connection->changeColumn($installer->getTable('admin_user'), 'password', 'password', array( + 'type' => \Magento\DB\Ddl\Table::TYPE_TEXT, + 'length' => 255, + 'nullable' => false, + 'comment' => 'User Password' +)); diff --git a/dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleObjectManager.php b/app/code/Magento/Usps/Block/Adminhtml/Order/Packaging/Plugin/DisplayGirth.php similarity index 54% rename from dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleObjectManager.php rename to app/code/Magento/Usps/Block/Adminhtml/Order/Packaging/Plugin/DisplayGirth.php index 6d2150ffc1a..ec10fe4a20c 100644 --- a/dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleObjectManager.php +++ b/app/code/Magento/Usps/Block/Adminhtml/Order/Packaging/Plugin/DisplayGirth.php @@ -18,63 +18,48 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Code - * @subpackage unit_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Code\Plugin\GeneratorTest; -use Magento\ObjectManager; + +namespace Magento\Usps\Block\Adminhtml\Order\Packaging\Plugin; + +use Magento\Shipping\Block\Adminhtml\Order\Packaging; +use Magento\Usps\Helper\Data as DataHelper; /** - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * Plugin class */ -class SimpleObjectManager implements \Magento\ObjectManager +class DisplayGirth { - /** - * Create new object instance + * Usps data helper * - * @param string $type - * @param array $arguments - * @return mixed + * @var \Magento\Usps\Helper\Data */ - public function create($type, array $arguments = array()) - { - return new $type($arguments); - } + protected $helper; /** - * Retrieve cached object instance + * Construct * - * @param string $type - * @return mixed + * @param \Magento\Usps\Helper\Data $helper */ - public function get($type) + public function __construct(DataHelper $helper) { - return $this->create($type); + $this->helper = $helper; } /** - * Configure object manager + * Is display girth value for specified shipping method * - * @param array $configuration - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function configure(array $configuration) - { - } - - /** - * Set factory + * @param \Magento\Shipping\Block\Adminhtml\Order\Packaging $subject + * @param \Closure $proceed * - * @param ObjectManager\Factory $factory + * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function setFactory(ObjectManager\Factory $factory) + public function aroundIsDisplayGirthValue(Packaging $subject, \Closure $proceed) { - + return $this->helper->displayGirthValue($subject->getShipment()->getOrder()->getShippingMethod()); } - - } diff --git a/app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php b/app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php new file mode 100644 index 00000000000..f36d1424b54 --- /dev/null +++ b/app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php @@ -0,0 +1,119 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Usps\Block\Rma\Adminhtml\Rma\Edit\Tab\General\Shipping\Packaging; + +use Magento\App\RequestInterface; +use Magento\Usps\Helper\Data as UspsHelper; +use Magento\Usps\Model\Carrier; + +/** + * Rma block plugin + */ +class Plugin +{ + /** + * Usps helper + * + * @var \Magento\Usps\Helper\Data + */ + protected $uspsHelper; + + /** + * Request + * + * @var \Magento\App\RequestInterface + */ + protected $request; + + /** + * Construct + * + * @param \Magento\Usps\Helper\Data $uspsHelper + * @param \Magento\App\RequestInterface $request + */ + public function __construct(UspsHelper $uspsHelper, RequestInterface $request) + { + $this->uspsHelper = $uspsHelper; + $this->request = $request; + } + + /** + * Add rule to isGirthAllowed() method + * + * @param \Magento\Object $subject $subject + * @param bool $result + * @return bool + */ + public function afterIsGirthAllowed( + \Magento\Object $subject, + $result + ) { + return $result && $this->uspsHelper->displayGirthValue($this->request->getParam('method')); + } + + /** + * Add rule to isGirthAllowed() method + * + * @param \Magento\Object $subject + * @param \Closure $proceed + * @return array + */ + public function aroundCheckSizeAndGirthParameter( + \Magento\Object $subject, + \Closure $proceed + ) { + $carrier = $subject->getCarrier(); + $size = $subject->getSourceSizeModel(); + + $girthEnabled = false; + $sizeEnabled = false; + if ($carrier && isset($size[0]['value'])) { + if ($size[0]['value'] == Carrier::SIZE_LARGE + && in_array( + key($subject->getContainers()), + array( + Carrier::CONTAINER_NONRECTANGULAR, + Carrier::CONTAINER_VARIABLE, + ) + ) + ) { + $girthEnabled = true; + } + + if (in_array( + key($subject->getContainers()), + array( + Carrier::CONTAINER_NONRECTANGULAR, + Carrier::CONTAINER_RECTANGULAR, + Carrier::CONTAINER_VARIABLE, + ) + )) { + $sizeEnabled = true; + } + } + + return array($girthEnabled, $sizeEnabled); + } +} diff --git a/app/code/Magento/Usps/Helper/Data.php b/app/code/Magento/Usps/Helper/Data.php new file mode 100644 index 00000000000..c190983bf15 --- /dev/null +++ b/app/code/Magento/Usps/Helper/Data.php @@ -0,0 +1,70 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Usps\Helper; + +use Magento\App\Helper\AbstractHelper; + +/** + * Usps data helper + */ +class Data extends AbstractHelper +{ + /** + * Available shipping methods + * + * @var array + */ + protected $availableShippingMethods = array( + 'usps_0_FCLE', // First-Class Mail Large Envelope + 'usps_1', // Priority Mail + 'usps_2', // Priority Mail Express Hold For Pickup + 'usps_3', // Priority Mail Express + 'usps_4', // Standard Post + 'usps_6', // Media Mail + 'usps_INT_1', // Priority Mail Express International + 'usps_INT_2', // Priority Mail International + 'usps_INT_4', // Global Express Guaranteed (GXG) + 'usps_INT_7', // Global Express Guaranteed Non-Document Non-Rectangular + 'usps_INT_8', // Priority Mail International Flat Rate Envelope + 'usps_INT_9', // Priority Mail International Medium Flat Rate Box + 'usps_INT_10', // Priority Mail Express International Flat Rate Envelope + 'usps_INT_11', // Priority Mail International Large Flat Rate Box + 'usps_INT_12', // USPS GXG Envelopes + 'usps_INT_14', // First-Class Mail International Large Envelope + 'usps_INT_16', // Priority Mail International Small Flat Rate Box + 'usps_INT_20', // Priority Mail International Small Flat Rate Envelope + 'usps_INT_26', // Priority Mail Express International Flat Rate Boxes + ); + + /** + * Define if we need girth parameter in the package window + * + * @param string $shippingMethod + * @return bool + */ + public function displayGirthValue($shippingMethod) + { + return in_array($shippingMethod, $this->availableShippingMethods); + } +} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Usps.php b/app/code/Magento/Usps/Model/Carrier.php old mode 100755 new mode 100644 similarity index 98% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Usps.php rename to app/code/Magento/Usps/Model/Carrier.php index 4bf5a7c9181..d4141a68556 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Usps.php +++ b/app/code/Magento/Usps/Model/Carrier.php @@ -18,24 +18,19 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier; +namespace Magento\Usps\Model; +use Magento\Shipping\Helper\Carrier as CarrierHelper; +use Magento\Shipping\Model\Carrier\AbstractCarrierOnline; use Magento\Shipping\Model\Rate\Result; /** - * USPS shipping rates estimation - * - * @link http://www.usps.com/webtools/htm/Development-Guide-v3-0b.htm - * @author Magento Core Team <core@magentocommerce.com> + * USPS shipping */ -class Usps - extends \Magento\Usa\Model\Shipping\Carrier\AbstractCarrier - implements \Magento\Shipping\Model\Carrier\CarrierInterface +class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\Carrier\CarrierInterface { /** * USPS containers @@ -82,7 +77,7 @@ class Usps * Destination Zip Code required flag * * @var boolean - * @deprecated since 1.7.0 functionality implemented in \Magento\Usa\Model\Shipping\Carrier\AbstractCarrier + * @deprecated since 1.7.0 functionality implemented in \Magento\Shipping\Model\Carrier\AbstractCarrierOnline */ protected $_isZipCodeRequired; @@ -122,11 +117,11 @@ class Usps protected $_customizableContainerTypes = array('VARIABLE', 'RECTANGULAR', 'NONRECTANGULAR'); /** - * Usa data + * Carrier helper * - * @var \Magento\Usa\Helper\Data + * @var \Magento\Shipping\Helper\Carrier */ - protected $_usaData = null; + protected $_carrierHelper; /** * @var \Magento\Catalog\Model\Resource\Product\CollectionFactory @@ -142,7 +137,7 @@ class Usps * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory * @param \Magento\Logger\AdapterFactory $logAdapterFactory - * @param \Magento\Usa\Model\Simplexml\ElementFactory $xmlElFactory + * @param \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory * @param \Magento\Shipping\Model\Rate\ResultFactory $rateFactory * @param \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory * @param \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory @@ -152,7 +147,7 @@ class Usps * @param \Magento\Directory\Model\CountryFactory $countryFactory * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Directory\Helper\Data $directoryData - * @param \Magento\Usa\Helper\Data $usaData + * @param \Magento\Shipping\Helper\Carrier $carrierHelper * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory * @param \Zend_Http_ClientFactory $httpClientFactory * @param array $data @@ -163,7 +158,7 @@ class Usps \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Sales\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Magento\Logger\AdapterFactory $logAdapterFactory, - \Magento\Usa\Model\Simplexml\ElementFactory $xmlElFactory, + \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory, \Magento\Shipping\Model\Rate\ResultFactory $rateFactory, \Magento\Sales\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory, @@ -173,12 +168,12 @@ class Usps \Magento\Directory\Model\CountryFactory $countryFactory, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Directory\Helper\Data $directoryData, - \Magento\Usa\Helper\Data $usaData, + CarrierHelper $carrierHelper, \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory, \Zend_Http_ClientFactory $httpClientFactory, array $data = array() ) { - $this->_usaData = $usaData; + $this->_carrierHelper = $carrierHelper; $this->_productCollectionFactory = $productCollectionFactory; $this->_httpClientFactory = $httpClientFactory; parent::__construct( @@ -1429,7 +1424,7 @@ class Usps $packageWeight = $request->getPackageWeight(); if ($packageParams->getWeightUnits() != \Zend_Measure_Weight::OUNCE) { - $packageWeight = round($this->_usaData->convertMeasureWeight( + $packageWeight = round($this->_carrierHelper->convertMeasureWeight( $request->getPackageWeight(), $packageParams->getWeightUnits(), \Zend_Measure_Weight::OUNCE @@ -1520,7 +1515,7 @@ class Usps $packageParams = $request->getPackageParams(); $packageWeight = $request->getPackageWeight(); if ($packageParams->getWeightUnits() != \Zend_Measure_Weight::OUNCE) { - $packageWeight = round($this->_usaData->convertMeasureWeight( + $packageWeight = round($this->_carrierHelper->convertMeasureWeight( $request->getPackageWeight(), $packageParams->getWeightUnits(), \Zend_Measure_Weight::OUNCE @@ -1599,31 +1594,31 @@ class Usps $girth = $packageParams->getGirth(); $packageWeight = $request->getPackageWeight(); if ($packageParams->getWeightUnits() != \Zend_Measure_Weight::POUND) { - $packageWeight = $this->_usaData->convertMeasureWeight( + $packageWeight = $this->_carrierHelper->convertMeasureWeight( $request->getPackageWeight(), $packageParams->getWeightUnits(), \Zend_Measure_Weight::POUND ); } if ($packageParams->getDimensionUnits() != \Zend_Measure_Length::INCH) { - $length = round($this->_usaData->convertMeasureDimension( + $length = round($this->_carrierHelper->convertMeasureDimension( $packageParams->getLength(), $packageParams->getDimensionUnits(), \Zend_Measure_Length::INCH )); - $width = round($this->_usaData->convertMeasureDimension( + $width = round($this->_carrierHelper->convertMeasureDimension( $packageParams->getWidth(), $packageParams->getDimensionUnits(), \Zend_Measure_Length::INCH )); - $height = round($this->_usaData->convertMeasureDimension( + $height = round($this->_carrierHelper->convertMeasureDimension( $packageParams->getHeight(), $packageParams->getDimensionUnits(), \Zend_Measure_Length::INCH )); } if ($packageParams->getGirthDimensionUnits() != \Zend_Measure_Length::INCH) { - $girth = round($this->_usaData->convertMeasureDimension( + $girth = round($this->_carrierHelper->convertMeasureDimension( $packageParams->getGirth(), $packageParams->getGirthDimensionUnits(), \Zend_Measure_Length::INCH @@ -1754,7 +1749,7 @@ class Usps $itemWeight = $item->getWeight() * $item->getQty(); if ($packageParams->getWeightUnits() != \Zend_Measure_Weight::POUND) { - $itemWeight = $this->_usaData->convertMeasureWeight( + $itemWeight = $this->_carrierHelper->convertMeasureWeight( $itemWeight, $packageParams->getWeightUnits(), \Zend_Measure_Weight::POUND diff --git a/app/code/Magento/Usps/Model/Source/Container.php b/app/code/Magento/Usps/Model/Source/Container.php new file mode 100644 index 00000000000..36ad8a6ad8f --- /dev/null +++ b/app/code/Magento/Usps/Model/Source/Container.php @@ -0,0 +1,38 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Usps\Model\Source; + +/** + * Container source + */ +class Container extends Generic +{ + /** + * Carrier code + * + * @var string + */ + protected $code = 'container'; +} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Freemethod.php b/app/code/Magento/Usps/Model/Source/Freemethod.php similarity index 75% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Freemethod.php rename to app/code/Magento/Usps/Model/Source/Freemethod.php index 707aaaae56f..e5e47a9f25f 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Freemethod.php +++ b/app/code/Magento/Usps/Model/Source/Freemethod.php @@ -18,22 +18,25 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\Source; -class Freemethod extends \Magento\Usa\Model\Shipping\Carrier\Dhl\Source\Method +namespace Magento\Usps\Model\Source; + +/** + * Freemethod source + */ +class Freemethod extends Method { /** * {@inheritdoc} */ public function toOptionArray() { - $arr = parent::toOptionArray(); - array_unshift($arr, array('value'=>'', 'label'=>__('None'))); - return $arr; + $options = parent::toOptionArray(); + + array_unshift($options, ['value' => '', 'label' => __('None')]); + return $options; } } diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Generic.php b/app/code/Magento/Usps/Model/Source/Generic.php similarity index 63% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Generic.php rename to app/code/Magento/Usps/Model/Source/Generic.php index aa0fb934a5b..522de71bea6 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Generic.php +++ b/app/code/Magento/Usps/Model/Source/Generic.php @@ -22,28 +22,34 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier\Usps\Source; +namespace Magento\Usps\Model\Source; -class Generic implements \Magento\Option\ArrayInterface +use Magento\Shipping\Model\Carrier\Source\GenericInterface; +use Magento\Usps\Model\Carrier; + +/** + * Generic source + */ +class Generic implements GenericInterface { /** - * @var \Magento\Usa\Model\Shipping\Carrier\Usps + * @var \Magento\Usps\Model\Carrier */ - protected $_shippingUsps; + protected $shippingUsps; /** * Carrier code * * @var string */ - protected $_code = ''; + protected $code = ''; /** - * @param \Magento\Usa\Model\Shipping\Carrier\Usps $shippingUsps + * @param \Magento\Usps\Model\Carrier $shippingUsps */ - public function __construct(\Magento\Usa\Model\Shipping\Carrier\Usps $shippingUsps) + public function __construct(Carrier $shippingUsps) { - $this->_shippingUsps = $shippingUsps; + $this->shippingUsps = $shippingUsps; } /** @@ -53,13 +59,13 @@ class Generic implements \Magento\Option\ArrayInterface */ public function toOptionArray() { - $configData = $this->_shippingUsps->getCode($this->_code); - $arr = array(); - if ($configData) { - foreach ($configData as $code => $title) { - $arr[] = array('value' => $code, 'label' => __($title)); + $options = []; + $codes = $this->shippingUsps->getCode($this->code); + if ($codes) { + foreach ($codes as $code => $title) { + $options[] = ['value' => $code, 'label' => __($title)]; } } - return $arr; + return $options; } } diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Machinable.php b/app/code/Magento/Usps/Model/Source/Machinable.php similarity index 81% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Machinable.php rename to app/code/Magento/Usps/Model/Source/Machinable.php index b8b9c727c9d..2be52088a3e 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Usps/Source/Machinable.php +++ b/app/code/Magento/Usps/Model/Source/Machinable.php @@ -18,21 +18,21 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Usps\Model\Source; -namespace Magento\Usa\Model\Shipping\Carrier\Usps\Source; - -class Machinable extends \Magento\Usa\Model\Shipping\Carrier\Usps\Source\Generic +/** + * Machinable source + */ +class Machinable extends Generic { /** * Carrier code * * @var string */ - protected $_code = 'machinable'; + protected $code = 'machinable'; } diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Method.php b/app/code/Magento/Usps/Model/Source/Method.php similarity index 81% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Method.php rename to app/code/Magento/Usps/Model/Source/Method.php index b5c9ee7d2f1..b0c9caa4e74 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Method.php +++ b/app/code/Magento/Usps/Model/Source/Method.php @@ -18,21 +18,21 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Usps\Model\Source; -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\Source; - -class Method extends \Magento\Usa\Model\Shipping\Carrier\Dhl\Source\Generic +/** +* Method source +*/ +class Method extends Generic { /** * Carrier code * * @var string */ - protected $_code = 'service'; + protected $code = 'method'; } diff --git a/app/code/Magento/Usps/Model/Source/Size.php b/app/code/Magento/Usps/Model/Source/Size.php new file mode 100644 index 00000000000..174a1af1f60 --- /dev/null +++ b/app/code/Magento/Usps/Model/Source/Size.php @@ -0,0 +1,38 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Usps\Model\Source; + +/** + * Size source + */ +class Size extends Generic +{ + /** + * Carrier code + * + * @var string + */ + protected $code = 'size'; +} diff --git a/app/code/Magento/Usps/etc/adminhtml/di.xml b/app/code/Magento/Usps/etc/adminhtml/di.xml new file mode 100644 index 00000000000..d158abc6fea --- /dev/null +++ b/app/code/Magento/Usps/etc/adminhtml/di.xml @@ -0,0 +1,46 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <type name="Magento\Rma\Block\Adminhtml\Rma\Edit\Tab\General\Shipping\Packaging"> + <arguments> + <argument name="sourceSizeModel" xsi:type="object">Magento\Usps\Model\Source\Size</argument> + </arguments> + <plugin name="usps" type="Magento\Usps\Block\Rma\Adminhtml\Rma\Edit\Tab\General\Shipping\Packaging\Plugin"/> + </type> + <type name="Magento\Shipping\Block\Adminhtml\Order\Packaging"> + <arguments> + <argument name="sourceSizeModel" xsi:type="object">Magento\Usps\Model\Source\Size</argument> + </arguments> + <plugin name="usps" type="Magento\Usps\Block\Adminhtml\Order\Packaging\Plugin\DisplayGirth"/> + </type> + <type name="Magento\Module\Updater\SetupFactory"> + <arguments> + <argument name="resourceTypes" xsi:type="array"> + <item name="usps_setup" xsi:type="string">Magento\Core\Model\Resource\Setup</item> + </argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/Usps/etc/adminhtml/system.xml b/app/code/Magento/Usps/etc/adminhtml/system.xml new file mode 100644 index 00000000000..2e48dbdacb8 --- /dev/null +++ b/app/code/Magento/Usps/etc/adminhtml/system.xml @@ -0,0 +1,162 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <system> + <section id="carriers"> + <group id="usps" translate="label" type="text" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>USPS</label> + <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled for Checkout</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="gateway_url" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Gateway URL</label> + </field> + <field id="gateway_secure_url" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Secure Gateway URL</label> + </field> + <field id="title" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Title</label> + </field> + <field id="userid" translate="label" type="obscure" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>User ID</label> + <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> + </field> + <field id="password" translate="label" type="obscure" sortOrder="53" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Password</label> + <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> + </field> + <field id="mode" translate="label" type="select" sortOrder="54" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Mode</label> + <source_model>Magento\Shipping\Model\Config\Source\Online\Mode</source_model> + </field> + <field id="shipment_requesttype" translate="label" type="select" sortOrder="55" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Packages Request Type</label> + <source_model>Magento\Shipping\Model\Config\Source\Online\Requesttype</source_model> + </field> + <field id="container" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Container</label> + <source_model>Magento\Usps\Model\Source\Container</source_model> + </field> + <field id="size" translate="label" type="select" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Size</label> + <source_model>Magento\Usps\Model\Source\Size</source_model> + </field> + <field id="width" translate="label" type="text" sortOrder="73" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Width</label> + <depends> + <field id="size">LARGE</field> + </depends> + </field> + <field id="length" translate="label" type="text" sortOrder="72" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Length</label> + <depends> + <field id="size">LARGE</field> + </depends> + </field> + <field id="height" translate="label" type="text" sortOrder="74" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Height</label> + <depends> + <field id="size">LARGE</field> + </depends> + </field> + <field id="girth" translate="label" type="text" sortOrder="76" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Girth</label> + <depends> + <field id="size">LARGE</field> + </depends> + </field> + <field id="machinable" translate="label" type="select" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Machinable</label> + <source_model>Magento\Usps\Model\Source\Machinable</source_model> + </field> + <field id="max_package_weight" translate="label" type="text" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="handling_type" translate="label" type="select" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Calculate Handling Fee</label> + <source_model>Magento\Shipping\Model\Source\HandlingType</source_model> + </field> + <field id="handling_action" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Handling Applied</label> + <source_model>Magento\Shipping\Model\Source\HandlingAction</source_model> + </field> + <field id="handling_fee" translate="label" type="text" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Handling Fee</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="allowed_methods" translate="label" type="multiselect" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Allowed Methods</label> + <source_model>Magento\Usps\Model\Source\Method</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="free_method" translate="label" type="select" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Free Method</label> + <frontend_class>free-method</frontend_class> + <source_model>Magento\Usps\Model\Source\Freemethod</source_model> + </field> + <field id="free_shipping_enable" translate="label" type="select" sortOrder="1500" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Free Shipping Amount Threshold</label> + <source_model>Magento\Backend\Model\Config\Source\Enabledisable</source_model> + </field> + <field id="free_shipping_subtotal" translate="label" type="text" sortOrder="160" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Free Shipping Amount Threshold</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="specificerrmsg" translate="label" type="textarea" sortOrder="170" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Displayed Error Message</label> + </field> + <field id="sallowspecific" translate="label" type="select" sortOrder="180" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ship to Applicable Countries</label> + <frontend_class>shipping-applicable-country</frontend_class> + <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> + </field> + <field id="specificcountry" translate="label" type="multiselect" sortOrder="190" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Ship to Specific Countries</label> + <source_model>Magento\Directory\Model\Config\Source\Country</source_model> + <can_be_empty>1</can_be_empty> + </field> + <field id="debug" translate="label" type="select" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Debug</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="showmethod" translate="label" type="select" sortOrder="210" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Show Method if Not Applicable</label> + <frontend_class>shipping-skip-hide</frontend_class> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + <field id="sort_order" translate="label" type="text" sortOrder="220" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Sort Order</label> + </field> + <field id="active_rma" translate="label" type="select" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="0"> + <label>Enabled for RMA</label> + <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> + </field> + </group> + </section> + </system> +</config> diff --git a/app/code/Magento/Usps/etc/config.xml b/app/code/Magento/Usps/etc/config.xml new file mode 100644 index 00000000000..7767b678bab --- /dev/null +++ b/app/code/Magento/Usps/etc/config.xml @@ -0,0 +1,57 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <default> + <carriers> + <usps> + <active>0</active> + <sallowspecific>0</sallowspecific> + <allowed_methods>0_FCLE,0_FCL,0_FCP,1,2,3,4,6,7,13,16,17,22,23,25,27,28,33,34,35,36,37,42,43,53,55,56,57,61,INT_1,INT_2,INT_4,INT_6,INT_7,INT_8,INT_9,INT_10,INT_11,INT_12,INT_13,INT_14,INT_15,INT_16,INT_20,INT_26</allowed_methods> + <container>VARIABLE</container> + <cutoff_cost /> + <free_method /> + <gateway_url>http://production.shippingapis.com/ShippingAPI.dll</gateway_url> + <gateway_secure_url>https://secure.shippingapis.com/ShippingAPI.dll</gateway_secure_url> + <shipment_requesttype>0</shipment_requesttype> + <handling /> + <machinable>true</machinable> + <methods></methods> + <model>Magento\Usps\Model\Carrier</model> + <size>REGULAR</size> + <title>United States Postal Service</title> + <userid backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> + <password backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> + <isproduction>0</isproduction> + <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg> + <max_package_weight>70</max_package_weight> + <handling_type>F</handling_type> + <handling_action>O</handling_action> + <active_rma>0</active_rma> + <is_online>1</is_online> + </usps> + </carriers> + </default> +</config> diff --git a/app/code/Magento/Usps/etc/module.xml b/app/code/Magento/Usps/etc/module.xml new file mode 100644 index 00000000000..f1f0ca1389c --- /dev/null +++ b/app/code/Magento/Usps/etc/module.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<config> + <module name="Magento_Usps" version="2.0.0.0" active="true"> + <depends> + <module name="Magento_Shipping"/> + <module name="Magento_Directory"/> + <module name="Magento_Core"/> + <module name="Magento_Catalog"/> + <module name="Magento_Sales"/> + </depends> + </module> +</config> diff --git a/app/code/Magento/Usa/sql/usa_setup/upgrade-1.6.0.1-1.6.0.2.php b/app/code/Magento/Usps/sql/usps_setup/install-2.0.0.0.php similarity index 91% rename from app/code/Magento/Usa/sql/usa_setup/upgrade-1.6.0.1-1.6.0.2.php rename to app/code/Magento/Usps/sql/usps_setup/install-2.0.0.0.php index 62149bab2be..a2fb4950c41 100644 --- a/app/code/Magento/Usa/sql/usa_setup/upgrade-1.6.0.1-1.6.0.2.php +++ b/app/code/Magento/Usps/sql/usps_setup/install-2.0.0.0.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -28,7 +26,7 @@ $installer = $this; $configDataTable = $installer->getTable('core_config_data'); $connection = $installer->getConnection(); -$oldToNewMethodCodesMap = array( +$oldToNewMethodCodesMap = [ 'First-Class' => '0_FCLE', 'First-Class Mail International Large Envelope' => 'INT_14', 'First-Class Mail International Letter' => 'INT_13', @@ -70,16 +68,14 @@ $oldToNewMethodCodesMap = array( 'Priority Mail International Small Flat Rate Box' => 'INT_16', 'Priority Mail International Medium Flat Rate Box' => 'INT_9', 'Priority Mail International Large Flat Rate Box' => 'INT_11', -); +]; $select = $connection->select() ->from($configDataTable) - ->where('path IN (?)', - array( - 'carriers/usps/free_method', - 'carriers/usps/allowed_methods' - ) - ); + ->where('path IN (?)', [ + 'carriers/usps/free_method', + 'carriers/usps/allowed_methods', + ]); $oldConfigValues = $connection->fetchAll($select); foreach ($oldConfigValues as $oldValue) { @@ -87,7 +83,7 @@ foreach ($oldConfigValues as $oldValue) { if (stripos($oldValue['path'], 'free_method') && isset($oldToNewMethodCodesMap[$oldValue['value']])) { $newValue = $oldToNewMethodCodesMap[$oldValue['value']]; } else if (stripos($oldValue['path'], 'allowed_methods')) { - $newValuesList = array(); + $newValuesList = []; foreach (explode(',', $oldValue['value']) as $shippingMethod) { if (isset($oldToNewMethodCodesMap[$shippingMethod])) { $newValuesList[] = $oldToNewMethodCodesMap[$shippingMethod]; @@ -98,11 +94,8 @@ foreach ($oldConfigValues as $oldValue) { continue; } - if (!empty($newValue) && $newValue != $oldValue['value']) { + if ($newValue && $newValue != $oldValue['value']) { $whereConfigId = $connection->quoteInto('config_id = ?', $oldValue['config_id']); - $connection->update($configDataTable, - array('value' => $newValue), - $whereConfigId - ); + $connection->update($configDataTable, ['value' => $newValue], $whereConfigId); } } diff --git a/app/code/Magento/Webapi/Controller/Soap.php b/app/code/Magento/Webapi/Controller/Soap.php index a4702dceed4..80160293f84 100644 --- a/app/code/Magento/Webapi/Controller/Soap.php +++ b/app/code/Magento/Webapi/Controller/Soap.php @@ -63,13 +63,18 @@ class Soap implements \Magento\App\FrontControllerInterface /** @var \Magento\Core\Model\App */ protected $_application; - /** @var \Magento\Oauth\OauthInterface */ + /** + * @var \Magento\Oauth\OauthInterface + */ protected $_oauthService; /** - * Initialize dependencies. - * - * @param \Magento\Webapi\Controller\Soap\Request $request + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + + /** + * @param Soap\Request $request * @param Response $response * @param \Magento\Webapi\Model\Soap\Wsdl\Generator $wsdlGenerator * @param \Magento\Webapi\Model\Soap\Server $soapServer @@ -77,6 +82,7 @@ class Soap implements \Magento\App\FrontControllerInterface * @param \Magento\App\State $appState * @param \Magento\AppInterface $application * @param \Magento\Oauth\OauthInterface $oauthService + * @param \Magento\Locale\ResolverInterface $localeResolver */ public function __construct( \Magento\Webapi\Controller\Soap\Request $request, @@ -86,7 +92,8 @@ class Soap implements \Magento\App\FrontControllerInterface ErrorProcessor $errorProcessor, \Magento\App\State $appState, \Magento\AppInterface $application, - \Magento\Oauth\OauthInterface $oauthService + \Magento\Oauth\OauthInterface $oauthService, + \Magento\Locale\ResolverInterface $localeResolver ) { $this->_request = $request; $this->_response = $response; @@ -96,6 +103,7 @@ class Soap implements \Magento\App\FrontControllerInterface $this->_appState = $appState; $this->_application = $application; $this->_oauthService = $oauthService; + $this->_localeResolver = $localeResolver; } /** @@ -175,7 +183,12 @@ class Soap implements \Magento\App\FrontControllerInterface } $this->_setResponseContentType($contentType); $this->_response->setHttpResponseCode($httpCode); - $soapFault = new \Magento\Webapi\Model\Soap\Fault($this->_application, $this->_soapServer, $maskedException); + $soapFault = new \Magento\Webapi\Model\Soap\Fault( + $this->_application, + $this->_soapServer, + $maskedException, + $this->_localeResolver + ); // TODO: Generate list of available URLs when invalid WSDL URL specified $this->_setResponseBody($soapFault->toXml()); } diff --git a/app/code/Magento/Webapi/Model/Plugin/AuthorizationServiceV1.php b/app/code/Magento/Webapi/Model/Plugin/AuthorizationServiceV1.php index 30f9e7ac7e1..6c86f01747b 100644 --- a/app/code/Magento/Webapi/Model/Plugin/AuthorizationServiceV1.php +++ b/app/code/Magento/Webapi/Model/Plugin/AuthorizationServiceV1.php @@ -23,7 +23,6 @@ */ namespace Magento\Webapi\Model\Plugin; -use Magento\Code\Plugin\InvocationChain; use Magento\Authz\Model\UserIdentifier; use Magento\Integration\Service\IntegrationV1 as IntegrationService; use Magento\Integration\Model\Integration; @@ -63,21 +62,29 @@ class AuthorizationServiceV1 * It's ok that we break invocation chain since we're dealing with ACL here - if something is not allowed at any * point it couldn't be made allowed at some other point. * - * @param array $arguments - * @param InvocationChain $invocationChain + * @param \Magento\Authz\Service\AuthorizationV1 $subject + * @param callable $proceed + * @param $resources + * @param UserIdentifier $userIdentifier + * * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundIsAllowed(array $arguments, InvocationChain $invocationChain) - { - /** @var UserIdentifier $userIdentifier */ - $userIdentifier = $arguments[1] ?: $this->_userIdentifier; + public function aroundIsAllowed( + \Magento\Authz\Service\AuthorizationV1 $subject, + \Closure $proceed, + $resources, + \Magento\Authz\Model\UserIdentifier $userIdentifier = null + ) { + /** @var UserIdentifier $userIdentifierObject */ + $userIdentifierObject = $userIdentifier ?: $this->_userIdentifier; - if ($userIdentifier->getUserType() !== UserIdentifier::USER_TYPE_INTEGRATION) { - return $invocationChain->proceed($arguments); + if ($userIdentifierObject->getUserType() !== UserIdentifier::USER_TYPE_INTEGRATION) { + return $proceed($resources, $userIdentifier); } try { - $integration = $this->_integrationService->get($userIdentifier->getUserId()); + $integration = $this->_integrationService->get($userIdentifierObject->getUserId()); } catch (\Exception $e) { // Wrong integration ID or DB not reachable or whatever - give up and don't allow just in case $this->_logger->logException($e); @@ -88,6 +95,6 @@ class AuthorizationServiceV1 return false; } - return $invocationChain->proceed($arguments); + return $proceed($resources, $userIdentifier); } } diff --git a/app/code/Magento/Webapi/Model/Plugin/IntegrationServiceV1.php b/app/code/Magento/Webapi/Model/Plugin/IntegrationServiceV1.php index 0adb76dd9c4..54ce3ffa1b2 100644 --- a/app/code/Magento/Webapi/Model/Plugin/IntegrationServiceV1.php +++ b/app/code/Magento/Webapi/Model/Plugin/IntegrationServiceV1.php @@ -55,10 +55,13 @@ class IntegrationServiceV1 /** * Persist API permissions. * + * @param \Magento\Integration\Service\IntegrationV1 $subject * @param IntegrationModel $integration + * * @return IntegrationModel + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterCreate($integration) + public function afterCreate(\Magento\Integration\Service\IntegrationV1 $subject, $integration) { $this->_saveApiPermissions($integration); return $integration; @@ -67,10 +70,13 @@ class IntegrationServiceV1 /** * Persist API permissions. * + * @param \Magento\Integration\Service\IntegrationV1 $subject * @param IntegrationModel $integration + * * @return IntegrationModel + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterUpdate($integration) + public function afterUpdate(\Magento\Integration\Service\IntegrationV1 $subject, $integration) { $this->_saveApiPermissions($integration); return $integration; @@ -79,10 +85,13 @@ class IntegrationServiceV1 /** * Add API permissions to integration data. * + * @param \Magento\Integration\Service\IntegrationV1 $subject * @param IntegrationModel $integration + * * @return IntegrationModel + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterGet($integration) + public function afterGet(\Magento\Integration\Service\IntegrationV1 $subject, $integration) { $this->_addAllowedResources($integration); return $integration; @@ -143,10 +152,13 @@ class IntegrationServiceV1 /** * Process integration resource permissions after the integration is created * + * @param \Magento\Integration\Service\IntegrationV1 $subject * @param array $integrationData Data of integration deleted + * * @return array $integrationData + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterDelete(array $integrationData) + public function afterDelete(\Magento\Integration\Service\IntegrationV1 $subject, array $integrationData) { //No check needed for integration data since it cannot be empty in the parent invocation - delete $userIdentifier = $this->_userIdentifierFactory->create( diff --git a/app/code/Magento/Webapi/Model/Plugin/Setup.php b/app/code/Magento/Webapi/Model/Plugin/Setup.php index 02a6b4eef12..0ace6674ebe 100644 --- a/app/code/Magento/Webapi/Model/Plugin/Setup.php +++ b/app/code/Magento/Webapi/Model/Plugin/Setup.php @@ -86,11 +86,16 @@ class Setup /** * Process integration resource permissions after the integration is created * + * @param \Magento\Integration\Model\Resource\Setup $subject * @param string[] $integrationNames Name of integrations passed as array from the invocation chain + * * @return string[] + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterInitIntegrationProcessing($integrationNames) - { + public function afterInitIntegrationProcessing( + \Magento\Integration\Model\Resource\Setup $subject, + $integrationNames + ) { if (empty($integrationNames)) { return array(); } diff --git a/app/code/Magento/Webapi/Model/Soap/Fault.php b/app/code/Magento/Webapi/Model/Soap/Fault.php index 0e295ca1f34..60d77f9d0e8 100644 --- a/app/code/Magento/Webapi/Model/Soap/Fault.php +++ b/app/code/Magento/Webapi/Model/Soap/Fault.php @@ -75,23 +75,32 @@ class Fault extends \RuntimeException */ protected $_details = array(); - /** @var \Magento\Core\Model\App */ + /** + * @var \Magento\Core\Model\App + */ protected $_application; - /** @var Server */ + /** + * @var Server + */ protected $_soapServer; /** - * Construct exception. - * + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + + /** * @param \Magento\Core\Model\App $application * @param Server $soapServer * @param \Magento\Webapi\Exception $previousException + * @param \Magento\Locale\ResolverInterface $localeResolver */ public function __construct( \Magento\Core\Model\App $application, Server $soapServer, - \Magento\Webapi\Exception $previousException + \Magento\Webapi\Exception $previousException, + \Magento\Locale\ResolverInterface $localeResolver ) { parent::__construct($previousException->getMessage(), $previousException->getCode(), $previousException); $this->_soapCode = $previousException->getOriginator(); @@ -99,6 +108,7 @@ class Fault extends \RuntimeException $this->_errorCode = $previousException->getCode(); $this->_application = $application; $this->_soapServer = $soapServer; + $this->_localeResolver = $localeResolver; $this->_setFaultName($previousException->getName()); } @@ -209,7 +219,7 @@ class Fault extends \RuntimeException */ public function getLanguage() { - return $this->_application->getLocale()->getLocale()->getLanguage(); + return $this->_localeResolver->getLocale()->getLanguage(); } /** diff --git a/app/code/Magento/Wishlist/Block/AbstractBlock.php b/app/code/Magento/Wishlist/Block/AbstractBlock.php index 63fa260c1b9..690bcc7d17b 100644 --- a/app/code/Magento/Wishlist/Block/AbstractBlock.php +++ b/app/code/Magento/Wishlist/Block/AbstractBlock.php @@ -282,7 +282,7 @@ abstract class AbstractBlock extends \Magento\Catalog\Block\Product\AbstractProd */ public function getFormatedDate($date) { - return $this->formatDate($date, \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM); + return $this->formatDate($date, \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM); } /** diff --git a/app/code/Magento/Wishlist/Block/Customer/Sidebar.php b/app/code/Magento/Wishlist/Block/Customer/Sidebar.php index a8928b407a4..44ec917379a 100644 --- a/app/code/Magento/Wishlist/Block/Customer/Sidebar.php +++ b/app/code/Magento/Wishlist/Block/Customer/Sidebar.php @@ -34,7 +34,7 @@ */ namespace Magento\Wishlist\Block\Customer; -class Sidebar extends \Magento\Wishlist\Block\AbstractBlock +class Sidebar extends \Magento\Wishlist\Block\AbstractBlock implements \Magento\View\Block\IdentityInterface { /** * Retrieve block title @@ -122,4 +122,19 @@ class Sidebar extends \Magento\Wishlist\Block\AbstractBlock { return $this->getItemCount() > 0; } + + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities() + { + $identities = array(); + foreach ($this->getWishlistItems() as $item) { + /** @var $item \Magento\Wishlist\Model\Item */ + $identities = array_merge($identities, $item->getProduct()->getIdentities()); + } + return $identities; + } } diff --git a/app/code/Magento/Wishlist/Block/Link.php b/app/code/Magento/Wishlist/Block/Link.php index b398b4ad3c9..6ecc67920f3 100644 --- a/app/code/Magento/Wishlist/Block/Link.php +++ b/app/code/Magento/Wishlist/Block/Link.php @@ -27,7 +27,7 @@ */ namespace Magento\Wishlist\Block; -class Link extends \Magento\View\Element\Html\Link +class Link extends \Magento\View\Element\Html\Link implements \Magento\View\Block\IdentityInterface { /** * Template name @@ -124,4 +124,21 @@ class Link extends \Magento\View\Element\Html\Link return; } } + + /** + * Retrieve block cache tags + * + * @return array + */ + public function getIdentities() + { + /** @var $wishlist \Magento\Wishlist\Model\Wishlist */ + $wishlist = $this->_wishlistHelper->getWishlist(); + $identities = $wishlist->getIdentities(); + foreach ($wishlist->getItemCollection() as $item) { + /** @var $item \Magento\Wishlist\Model\Item */ + $identities = array_merge($identities, $item->getProduct()->getIdentities()); + } + return $identities; + } } diff --git a/app/code/Magento/Wishlist/Controller/AbstractController.php b/app/code/Magento/Wishlist/Controller/AbstractController.php index dd1f61fd3d1..d5515e0be64 100644 --- a/app/code/Magento/Wishlist/Controller/AbstractController.php +++ b/app/code/Magento/Wishlist/Controller/AbstractController.php @@ -67,7 +67,7 @@ abstract class AbstractController extends \Magento\App\Action\Action { if (!$this->_localFilter) { $this->_localFilter = new \Zend_Filter_LocalizedToNormalized( - array('locale' => $this->_objectManager->get('Magento\Core\Model\LocaleInterface')->getLocaleCode()) + array('locale' => $this->_objectManager->get('Magento\Locale\ResolverInterface')->getLocaleCode()) ); } $qty = $this->_localFilter->filter((float)$qty); diff --git a/app/code/Magento/Wishlist/Model/Item.php b/app/code/Magento/Wishlist/Model/Item.php index 38ac05f5909..b323cd745e9 100644 --- a/app/code/Magento/Wishlist/Model/Item.php +++ b/app/code/Magento/Wishlist/Model/Item.php @@ -18,12 +18,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Wishlist * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Wishlist\Model; /** * Wishlist item model @@ -39,13 +37,7 @@ * @method \Magento\Wishlist\Model\Item setAddedAt(string $value) * @method string getDescription() * @method \Magento\Wishlist\Model\Item setDescription(string $value) - * - * @category Magento - * @package Magento_Wishlist - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Wishlist\Model; - use Magento\Wishlist\Model\Item\Option; use Magento\Wishlist\Model\Item\OptionFactory; use Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory; @@ -62,11 +54,11 @@ class Item extends \Magento\Core\Model\AbstractModel */ protected $_customOptionDownloadUrl = 'wishlist/index/downloadCustomOption'; - /** - * Prefix of model events names - * - * @var string - */ + /** + * Prefix of model events names + * + * @var string + */ protected $_eventPrefix = 'wishlist_item'; /** @@ -112,7 +104,7 @@ class Item extends \Magento\Core\Model\AbstractModel protected $_storeManager; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -145,7 +137,7 @@ class Item extends \Magento\Core\Model\AbstractModel * @param \Magento\Model\Context $context * @param \Magento\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl * @param OptionFactory $wishlistOptFactory @@ -159,7 +151,7 @@ class Item extends \Magento\Core\Model\AbstractModel \Magento\Model\Context $context, \Magento\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\Resource\Url $catalogUrl, OptionFactory $wishlistOptFactory, @@ -318,8 +310,8 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Validate wish list item data * - * @throws \Magento\Core\Exception * @return bool + * @throws \Magento\Core\Exception */ public function validate() { @@ -536,6 +528,7 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Set buy request - object, holding request received from * product view page with keys and options for configured product + * * @param \Magento\Object $buyRequest * @return $this */ diff --git a/app/code/Magento/Wishlist/Model/Item/Option.php b/app/code/Magento/Wishlist/Model/Item/Option.php index 8f9355c2968..901f2f7ad2f 100644 --- a/app/code/Magento/Wishlist/Model/Item/Option.php +++ b/app/code/Magento/Wishlist/Model/Item/Option.php @@ -18,21 +18,14 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Wishlist * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Wishlist\Model\Item; /** * Item option model - * - * @category Magento - * @package Magento_Wishlist - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Wishlist\Model\Item; - use Magento\Catalog\Model\Product; use Magento\Wishlist\Model\Item; @@ -62,7 +55,7 @@ class Option extends \Magento\Core\Model\AbstractModel /** * Checks that item option model has data changes * - * @return boolean + * @return bool */ protected function _hasModelChanged() { diff --git a/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php b/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php index 3bbe9caac5d..81982e248ff 100644 --- a/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php +++ b/app/code/Magento/Wishlist/Model/Resource/Item/Collection.php @@ -112,7 +112,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl protected $_storeManager; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -164,7 +164,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\CatalogInventory\Helper\Data $catalogInventoryData * @param \Magento\Sales\Helper\Admin $adminhtmlSales * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Wishlist\Model\Config $wishlistConfig * @param \Magento\Catalog\Model\Product\Visibility $productVisibility * @param \Magento\App\Resource $coreResource @@ -186,7 +186,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl \Magento\CatalogInventory\Helper\Data $catalogInventoryData, \Magento\Sales\Helper\Admin $adminhtmlSales, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\Wishlist\Model\Config $wishlistConfig, \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\App\Resource $coreResource, @@ -482,14 +482,14 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl $now = $this->_date->date(); $gmtOffset = (int)$this->_date->getGmtOffset(); if (isset($constraints['from'])) { - $lastDay = new \Zend_Date($now, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); + $lastDay = new \Magento\Stdlib\DateTime\Date($now, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); $lastDay->subSecond($gmtOffset) ->subDay(intval($constraints['from'])); $filter['to'] = $lastDay; } if (isset($constraints['to'])) { - $firstDay = new \Zend_Date($now, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); + $firstDay = new \Magento\Stdlib\DateTime\Date($now, \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT); $firstDay->subSecond($gmtOffset) ->subDay(intval($constraints['to']) + 1); $filter['from'] = $firstDay; diff --git a/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php b/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php index 44726147ebd..0600be92d75 100644 --- a/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php +++ b/app/code/Magento/Wishlist/Model/Resource/Item/Collection/Grid.php @@ -44,7 +44,7 @@ class Grid extends \Magento\Wishlist\Model\Resource\Item\Collection * @param \Magento\CatalogInventory\Helper\Data $catalogInventoryData * @param \Magento\Sales\Helper\Admin $adminhtmlSales * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Wishlist\Model\Config $wishlistConfig * @param \Magento\Catalog\Model\Product\Visibility $productVisibility * @param \Magento\App\Resource $coreResource @@ -67,7 +67,7 @@ class Grid extends \Magento\Wishlist\Model\Resource\Item\Collection \Magento\CatalogInventory\Helper\Data $catalogInventoryData, \Magento\Sales\Helper\Admin $adminhtmlSales, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\Wishlist\Model\Config $wishlistConfig, \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\App\Resource $coreResource, diff --git a/app/code/Magento/Wishlist/Model/Wishlist.php b/app/code/Magento/Wishlist/Model/Wishlist.php index 302b4cc79a1..7773cd66936 100644 --- a/app/code/Magento/Wishlist/Model/Wishlist.php +++ b/app/code/Magento/Wishlist/Model/Wishlist.php @@ -44,8 +44,13 @@ use Magento\Wishlist\Model\Resource\Wishlist\Collection; * @method string getUpdatedAt() * @method \Magento\Wishlist\Model\Wishlist setUpdatedAt(string $value) */ -class Wishlist extends \Magento\Core\Model\AbstractModel +class Wishlist extends \Magento\Core\Model\AbstractModel implements \Magento\Object\IdentityInterface { + /** + * Cache tag + */ + const CACHE_TAG = 'wishlist'; + /** * Prefix of model events names * @@ -93,7 +98,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel protected $_storeManager; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -135,7 +140,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel * @param ResourceWishlist $resource * @param Collection $resourceCollection * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param ItemFactory $wishlistItemFactory * @param CollectionFactory $wishlistCollectionFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory @@ -152,7 +157,7 @@ class Wishlist extends \Magento\Core\Model\AbstractModel ResourceWishlist $resource, Collection $resourceCollection, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, ItemFactory $wishlistItemFactory, CollectionFactory $wishlistCollectionFactory, \Magento\Catalog\Model\ProductFactory $productFactory, @@ -675,4 +680,14 @@ class Wishlist extends \Magento\Core\Model\AbstractModel $this->_hasDataChanges = true; return parent::save(); } + + /** + * Return unique ID(s) for each object in system + * + * @return array + */ + public function getIdentities() + { + return array(self::CACHE_TAG . '_' . $this->getId()); + } } diff --git a/app/code/Magento/Wishlist/etc/frontend/di.xml b/app/code/Magento/Wishlist/etc/frontend/di.xml index 4255b3c5632..844083d65f9 100644 --- a/app/code/Magento/Wishlist/etc/frontend/di.xml +++ b/app/code/Magento/Wishlist/etc/frontend/di.xml @@ -47,14 +47,4 @@ </argument> </arguments> </type> - <virtualType name="wishlistInitSession" type="Magento\Core\App\Action\Plugin\Session"> - <arguments> - <argument name="cookieCheckActions" xsi:type="array"> - <item name="wishlistAdd" xsi:type="string">add</item> - </argument> - </arguments> - </virtualType> - <type name="Magento\Wishlist\Controller\Index"> - <plugin name="sessionInitializer" type="wishlistInitSession" /> - </type> </config> diff --git a/app/code/Magento/Wishlist/view/frontend/layout/catalog_category_view.xml b/app/code/Magento/Wishlist/view/frontend/layout/catalog_category_view.xml new file mode 100644 index 00000000000..63cde1af50d --- /dev/null +++ b/app/code/Magento/Wishlist/view/frontend/layout/catalog_category_view.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceContainer name="content"> + <block class="Magento\Core\Block\RequireCookie" name="require-cookie" template="Magento_Core::require_cookie.phtml"> + <arguments> + <argument name="triggers" xsi:type="array"> + <item name="addToWishlistLink" xsi:type="string">.action.towishlist</item> + </argument> + </arguments> + </block> + </referenceContainer> +</layout> diff --git a/app/code/Magento/Wishlist/view/frontend/layout/catalog_product_view.xml b/app/code/Magento/Wishlist/view/frontend/layout/catalog_product_view.xml new file mode 100644 index 00000000000..63cde1af50d --- /dev/null +++ b/app/code/Magento/Wishlist/view/frontend/layout/catalog_product_view.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceContainer name="content"> + <block class="Magento\Core\Block\RequireCookie" name="require-cookie" template="Magento_Core::require_cookie.phtml"> + <arguments> + <argument name="triggers" xsi:type="array"> + <item name="addToWishlistLink" xsi:type="string">.action.towishlist</item> + </argument> + </arguments> + </block> + </referenceContainer> +</layout> diff --git a/app/code/Magento/Wishlist/view/frontend/layout/default.xml b/app/code/Magento/Wishlist/view/frontend/layout/default.xml index d1e63d967bc..17c8f378393 100644 --- a/app/code/Magento/Wishlist/view/frontend/layout/default.xml +++ b/app/code/Magento/Wishlist/view/frontend/layout/default.xml @@ -28,6 +28,6 @@ <block class="Magento\Wishlist\Block\Link" name="wish-list-link" after="my-account-link"/> </referenceBlock> <referenceContainer name="right"> - <block class="Magento\Wishlist\Block\Customer\Sidebar" name="wishlist_sidebar" as="wishlist" template="Magento_Wishlist::sidebar.phtml" cacheable="false"/> + <block class="Magento\Wishlist\Block\Customer\Sidebar" name="wishlist_sidebar" as="wishlist" template="Magento_Wishlist::sidebar.phtml"/> </referenceContainer> </layout> diff --git a/app/design/frontend/magento_plushe/Magento_Customer/layout/default.xml b/app/design/frontend/magento_plushe/Magento_Customer/layout/default.xml index 1ea9a37f8d1..2532ed27181 100644 --- a/app/design/frontend/magento_plushe/Magento_Customer/layout/default.xml +++ b/app/design/frontend/magento_plushe/Magento_Customer/layout/default.xml @@ -25,8 +25,8 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceBlock name="header.links"> - <block class="Magento\Customer\Block\Account\Customer" name="customer" template="account/customer.phtml" before="-" cacheable="false"/> - <block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link-login" cacheable="false"/> + <block class="Magento\Customer\Block\Account\Customer" name="customer" template="account/customer.phtml" before="-"/> + <block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link-login"/> </referenceBlock> <move element="register-link" destination="header.links"/> <move element="top.links" destination="customer"/> diff --git a/app/etc/di.xml b/app/etc/di.xml index 7c1b9b7d5f8..58e999b9d77 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -39,7 +39,13 @@ <preference for="Magento\View\DesignInterface" type="Magento\Core\Model\View\Design\Proxy" /> <preference for="Magento\View\Design\ThemeInterface" type="Magento\Core\Model\Theme" /> <preference for="Magento\View\ConfigInterface" type="Magento\View\Config" /> - <preference for="Magento\Core\Model\LocaleInterface" type="Magento\Core\Model\Locale" /> + <preference for="Magento\Locale\ListsInterface" type="Magento\Locale\Lists" /> + <type name="Magento\Locale\Lists"> + <arguments> + <argument name="currencyInstalled" xsi:type="string">system/currency/installed</argument> + </arguments> + </type> + <preference for="Magento\Locale\ConfigInterface" type="Magento\Locale\Config" /> <preference for="Magento\UrlInterface" type="Magento\Url" /> <preference for="Magento\Data\Collection\Db\FetchStrategyInterface" type="Magento\Data\Collection\Db\FetchStrategy\Query" /> <preference for="Magento\Config\ScopeInterface" type="Magento\Config\Scope" /> @@ -65,6 +71,23 @@ <preference for="Magento\Json\DecoderInterface" type="Magento\Json\Decoder" /> <preference for="Magento\Message\ManagerInterface" type="Magento\Message\Manager" /> <preference for="Magento\App\Config\ValueInterface" type="Magento\Core\Model\Config\Value" /> + <preference for="Magento\Module\DependencyManagerInterface" type="Magento\Module\DependencyManager" /> + <preference for="Magento\Interception\Chain" type="Magento\Interception\Chain\Chain" /> + <preference for="Magento\Module\Output\ConfigInterface" type="Magento\Core\Model\Module\Output\Config" /> + <preference for="Magento\View\Design\Theme\CustomizationInterface" type="Magento\View\Design\Theme\Customization" /> + <preference for="Magento\Image\Adapter\ConfigInterface" type="Magento\Image\Adapter\Config" /> + <preference for="Magento\View\Design\Theme\Image\PathInterface" type="Magento\Core\Model\Theme\Image\Path" /> + <preference for="Magento\Session\Config\ConfigInterface" type="Magento\Core\Model\Session\Config" /> + <preference for="Magento\Session\SidResolverInterface" type="Magento\Core\Model\Session\SidResolver\Proxy" /> + <preference for="Magento\TranslateInterface" type="Magento\Translate" /> + <preference for="Magento\Config\ScopeListInterface" type="interceptionConfigScope" /> + <preference for="Magento\View\Design\Theme\Label\ListInterface" type="Magento\Core\Model\Resource\Theme\Collection" /> + <preference for="Magento\Mview\ConfigInterface" type="Magento\Mview\Config" /> + <preference for="Magento\Mview\ViewInterface" type="Magento\Mview\View" /> + <preference for="Magento\Mview\ProcessorInterface" type="Magento\Mview\Processor" /> + <preference for="Magento\Mview\View\CollectionInterface" type="Magento\Mview\View\Collection" /> + <preference for="Magento\Mview\View\SubscriptionInterface" type="Magento\Mview\View\Subscription" /> + <preference for="Magento\Mview\View\ChangelogInterface" type="Magento\Mview\View\Changelog" /> <type name="Magento\Message\Manager"> <arguments> <argument name="session" xsi:type="object">Magento\Message\Session\Proxy</argument> @@ -90,15 +113,6 @@ </argument> </arguments> </type> - <preference for="Magento\Module\Output\ConfigInterface" type="Magento\Core\Model\Module\Output\Config" /> - <preference for="Magento\View\Design\Theme\CustomizationInterface" type="Magento\View\Design\Theme\Customization" /> - <preference for="Magento\Image\Adapter\ConfigInterface" type="Magento\Image\Adapter\Config" /> - <preference for="Magento\View\Design\Theme\Image\PathInterface" type="Magento\Core\Model\Theme\Image\Path" /> - <preference for="Magento\Session\Config\ConfigInterface" type="Magento\Core\Model\Session\Config" /> - <preference for="Magento\Session\SidResolverInterface" type="Magento\Core\Model\Session\SidResolver\Proxy" /> - <preference for="Magento\TranslateInterface" type="Magento\Translate" /> - <preference for="Magento\Config\ScopeListInterface" type="interceptionConfigScope" /> - <preference for="Magento\View\Design\Theme\Label\ListInterface" type="Magento\Core\Model\Resource\Theme\Collection" /> <virtualType name="interceptionConfigScope" type="Magento\Config\Scope"> <arguments> <argument name="defaultScope" xsi:type="string">global</argument> @@ -158,6 +172,7 @@ <type name="Magento\Translate"> <arguments> <argument name="cache" xsi:type="object">Magento\App\Cache\Type\Translate</argument> + <argument name="locale" xsi:type="object">Magento\Locale\Resolver\Proxy</argument> </arguments> </type> <type name="Magento\Data\Structure" shared="false" /> @@ -309,12 +324,6 @@ <argument name="argumentInterpreter" xsi:type="object">layoutArgumentInterpreter</argument> </arguments> </type> - <preference for="Magento\Mview\ConfigInterface" type="Magento\Mview\Config" /> - <preference for="Magento\Mview\ViewInterface" type="Magento\Mview\View" /> - <preference for="Magento\Mview\ProcessorInterface" type="Magento\Mview\Processor" /> - <preference for="Magento\Mview\View\CollectionInterface" type="Magento\Mview\View\Collection" /> - <preference for="Magento\Mview\View\SubscriptionInterface" type="Magento\Mview\View\Subscription" /> - <preference for="Magento\Mview\View\ChangelogInterface" type="Magento\Mview\View\Changelog" /> <type name="Magento\Mview\View"> <arguments> <argument name="state" xsi:type="object" shared="false">Magento\Core\Model\Mview\View\State</argument> @@ -331,4 +340,25 @@ <argument name="stateCollection" xsi:type="object" shared="false">Magento\Mview\View\State\CollectionInterface</argument> </arguments> </type> + <type name="Magento\Code\Generator"> + <arguments> + <argument name="generatedEntities" xsi:type="array"> + <item name="factory" xsi:type="string">\Magento\ObjectManager\Code\Generator\Factory</item> + <item name="proxy" xsi:type="string">\Magento\ObjectManager\Code\Generator\Proxy</item> + <item name="interceptor" xsi:type="string">\Magento\Interception\Code\Generator\Interceptor</item> + <item name="decorator" xsi:type="string">\Magento\Interception\Code\Generator\Decorator</item> + </argument> + </arguments> + </type> + <type name="Magento\App\Cache\Frontend\Pool"> + <arguments> + <argument name="frontendSettings" xsi:type="array"> + <item name="page_cache" xsi:type="array"> + <item name="backend_options" xsi:type="array"> + <item name="cache_dir" xsi:type="string">page_cache</item> + </item> + </item> + </argument> + </arguments> + </type> </config> diff --git a/dev/shell/install.php b/dev/shell/install.php index f81a8d591b5..06991e30223 100644 --- a/dev/shell/install.php +++ b/dev/shell/install.php @@ -24,17 +24,6 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -define('SYNOPSIS', <<<SYNOPSIS -php -f install.php -- --show_locales -php -f install.php -- --show_currencies -php -f install.php -- --show_timezones -php -f install.php -- --show_install_options -php -f install.php -- [--<install_option_name> "<option_value>", ...] -php -f install.php -- --uninstall - -SYNOPSIS -); - /** * Parse command line arguments */ @@ -56,7 +45,49 @@ foreach ($_SERVER['argv'] as $argNameOrValue) { } if (empty($args)) { - echo SYNOPSIS; + $detailedOptions = array('show_locales', 'show_currencies', 'show_timezones', 'show_install_options'); + echo 'Detailed info:' . PHP_EOL; + foreach ($detailedOptions as $option) { + echo ' php -f ' . $_SERVER['argv'][0] . ' -- --' . $option . PHP_EOL; + } + echo <<<INSTALLSCHEME +Installation scheme: + php -f {$_SERVER['argv'][0]} -- [--<install_option_name> "<option_value>" ...] +Uninstallation: + php -f {$_SERVER['argv'][0]} -- --uninstall + +INSTALLSCHEME; + + $exampleOptions = array( + 'license_agreement_accepted' => 'yes', + 'locale' => 'en_US', + 'timezone' => '"America/Los_Angeles"', + 'default_currency' => 'USD', + 'db_host' => 'localhost', + 'db_name' => 'magento', + 'db_user' => 'root', + 'url' => '"http://magento.local/"', + 'use_rewrites' => 'no', + 'use_secure_admin' => 'yes', + 'admin_lastname' => 'Smith', + 'admin_firstname' => 'John', + 'admin_email' => '"john.smith@some-email.com"', + 'admin_username' => 'admin', + 'admin_password' => '1234qasd', + 'use_secure' => 'no', + 'secure_base_url' => '"https://magento.local"', + 'cleanup_database' => '', + ); + echo 'Example of installation:' . PHP_EOL; + echo ' php -f ' . $_SERVER['argv'][0] . ' --'; + foreach ($exampleOptions as $option => $value) { + if (!empty($value)) { + echo ' --' . $option . ' ' . $value; + } else { + echo ' --' . $option; + } + } + echo PHP_EOL; exit(1); } diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php index 24fc545255d..3472d13848b 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Application.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php @@ -148,7 +148,8 @@ class Application Filesystem::MEDIA_DIR => array('path' => "$installDir/media"), Filesystem::STATIC_VIEW_DIR => array('path' => "$installDir/pub_static"), Filesystem::PUB_VIEW_CACHE_DIR => array('path' => "$installDir/pub_cache"), - Filesystem::GENERATION_DIR => array('path' => $generationDir) + Filesystem::GENERATION_DIR => array('path' => $generationDir), + Filesystem::CACHE_DIR => array('path' => $installDir . '/cache') ), \Magento\App\State::PARAM_MODE => $appMode ); diff --git a/dev/tests/integration/framework/Magento/TestFramework/Interception/PluginList.php b/dev/tests/integration/framework/Magento/TestFramework/Interception/PluginList.php index 7b50c12dd46..e7f65ec46a1 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Interception/PluginList.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Interception/PluginList.php @@ -38,9 +38,12 @@ class PluginList extends \Magento\Interception\PluginList\PluginList * @param \Magento\ObjectManager\Relations $relations * @param \Magento\ObjectManager\Config $omConfig * @param \Magento\Interception\Definition $definitions + * @param \Magento\ObjectManager $objectManager + * @param \Magento\ObjectManager\Definition $classDefinitions * @param array $scopePriorityScheme - * @param \Magento\ObjectManager\Definition\Compiled $classDefinitions * @param string $cacheId + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Config\ReaderInterface $reader, @@ -49,12 +52,14 @@ class PluginList extends \Magento\Interception\PluginList\PluginList \Magento\ObjectManager\Relations $relations, \Magento\ObjectManager\Config $omConfig, \Magento\Interception\Definition $definitions, + \Magento\ObjectManager $objectManager, + \Magento\ObjectManager\Definition $classDefinitions, array $scopePriorityScheme, - $cacheId = 'plugins', - \Magento\ObjectManager\Definition\Compiled $classDefinitions = null + $cacheId = 'plugins' ) { parent::__construct($reader, $configScope, $cache, $relations, $omConfig, - $definitions, $scopePriorityScheme, $cacheId, $classDefinitions); + $definitions, $objectManager, $classDefinitions, $scopePriorityScheme, $cacheId + ); $this->_originScopeScheme = $this->_scopePriorityScheme; } @@ -67,4 +72,4 @@ class PluginList extends \Magento\Interception\PluginList\PluginList $this->_data = array(); $this->_loadedScopes = array(); } -} \ No newline at end of file +} diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManager.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManager.php index 3831a6f243b..dc36068eac4 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManager.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManager.php @@ -37,6 +37,19 @@ class ObjectManager extends \Magento\App\ObjectManager 'Magento\Registry' ); + /** + * @var array + */ + protected $persistedInstances = array( + 'Magento\App\Resource', + 'Magento\Config\Scope', + 'Magento\ObjectManager\Relations', + 'Magento\ObjectManager\Config', + 'Magento\Interception\Definition', + 'Magento\ObjectManager\Definition', + 'Magento\Core\Model\Session\Config' + ); + /** * Clear InstanceManager cache * @@ -54,17 +67,10 @@ class ObjectManager extends \Magento\App\ObjectManager $sharedInstances = array( 'Magento\ObjectManager' => $this, 'Magento\App\ObjectManager' => $this ); - if (isset($this->_sharedInstances['Magento\App\Resource'])) { - $sharedInstances['Magento\App\Resource'] = $this->_sharedInstances['Magento\App\Resource']; - } - - if (isset($this->_sharedInstances['Magento\Config\Scope'])) { - $sharedInstances['Magento\Config\Scope'] = $this->_sharedInstances['Magento\Config\Scope']; - } - - if (isset($this->_sharedInstances['Magento\Core\Model\Session\Config'])) { - $sharedInstances['Magento\Core\Model\Session\Config'] = - $this->_sharedInstances['Magento\Core\Model\Session\Config']; + foreach ($this->persistedInstances as $persistedClass) { + if (isset($this->_sharedInstances[$persistedClass])) { + $sharedInstances[$persistedClass] = $this->_sharedInstances[$persistedClass]; + } } $this->_sharedInstances = $sharedInstances; $this->_config->clean(); diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManager/Config.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManager/Config.php index 0a34502895a..6dc179a6ccb 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManager/Config.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManager/Config.php @@ -23,7 +23,7 @@ */ namespace Magento\TestFramework\ObjectManager; -class Config extends \Magento\ObjectManager\Config\Config +class Config extends \Magento\Interception\ObjectManager\Config { /** * Clean configuration diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php index 5a2e508fb34..1d32e46093b 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php @@ -51,11 +51,6 @@ class ObjectManagerFactory extends \Magento\App\ObjectManagerFactory */ protected $_primaryConfigData = null; - /** - * @var \Magento\TestFramework\Interception\PluginList - */ - protected $_pluginList = null; - /** * Proxy over arguments instance, used by the application and all the DI stuff * @@ -100,8 +95,6 @@ class ObjectManagerFactory extends \Magento\App\ObjectManagerFactory \Magento\TestFramework\ObjectManager::setInstance($objectManager); - $this->_pluginList->reset(); - $objectManager->configure($this->_primaryConfigData); $objectManager->addSharedInstance($directoryList, 'Magento\App\Filesystem\DirectoryList'); $objectManager->addSharedInstance($directoryList, 'Magento\Filesystem\DirectoryList'); @@ -123,6 +116,7 @@ class ObjectManagerFactory extends \Magento\App\ObjectManagerFactory 'Magento\App\Request\Http' => 'Magento\TestFramework\Request', 'Magento\App\ResponseInterface' => 'Magento\TestFramework\Response', 'Magento\App\Response\Http' => 'Magento\TestFramework\Response', + 'Magento\Interception\PluginList\PluginList' => 'Magento\TestFramework\Interception\PluginList' ), )); @@ -130,6 +124,7 @@ class ObjectManagerFactory extends \Magento\App\ObjectManagerFactory $this->appArgumentsProxy->setSubject($appArguments); $objectManager->addSharedInstance($appArguments, 'Magento\App\Arguments'); + $objectManager->get('Magento\Interception\PluginList')->reset(); $objectManager->configure( $objectManager->get('Magento\App\ObjectManager\ConfigLoader')->load('global') ); @@ -153,32 +148,6 @@ class ObjectManagerFactory extends \Magento\App\ObjectManagerFactory return $this->_primaryConfigData; } - /** - * Create plugin list object - * - * @param \Magento\ObjectManager $locator - * @param \Magento\ObjectManager\Relations $relations - * @param \Magento\ObjectManager\DefinitionFactory $definitionFactory - * @param \Magento\ObjectManager\Config\Config $diConfig - * @param \Magento\ObjectManager\Definition $definitions - * @return \Magento\Interception\PluginList\PluginList - */ - protected function _createPluginList( - \Magento\ObjectManager $locator, - \Magento\ObjectManager\Relations $relations, - \Magento\ObjectManager\DefinitionFactory $definitionFactory, - \Magento\ObjectManager\Config\Config $diConfig, - \Magento\ObjectManager\Definition $definitions - ) { - $locator->configure(array('preferences' => - array('Magento\Interception\PluginList\PluginList' => 'Magento\TestFramework\Interception\PluginList') - )); - $this->_pluginList = parent::_createPluginList( - $locator, $relations, $definitionFactory, $diConfig, $definitions - ); - return $this->_pluginList; - } - /** * Override method in while running integration tests to prevent getting Exception * diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/CookieTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/CookieTest.php index e73d9b1ba78..289ba4858bd 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/CookieTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/CookieTest.php @@ -48,7 +48,8 @@ class CookieTest extends \PHPUnit_Framework_TestCase 'http://example.com' ), new \Magento\TestFramework\Response( - $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false) + $this->getMock('\Magento\Stdlib\Cookie', array(), array(), '', false), + $this->getMock('Magento\App\Http\Context', array(), array(), '', false) ) ); } diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ResponseTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ResponseTest.php index 7e07180cd8c..e47759f1321 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ResponseTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ResponseTest.php @@ -32,7 +32,8 @@ class ResponseTest extends \PHPUnit_Framework_TestCase public function testCanSendHeaders() { $response = new \Magento\TestFramework\Response( - $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false) + $this->getMock('\Magento\Stdlib\Cookie', array(), array(), '', false), + $this->getMock('Magento\App\Http\Context', array(), array(), '', false) ); $this->assertTrue($response->canSendHeaders()); $this->assertTrue($response->canSendHeaders(false)); diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php index b8650c985e5..841244f9550 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php @@ -50,7 +50,10 @@ class ControllerAbstractTest extends \Magento\TestFramework\TestCase\AbstractCon $this->getMock('\Magento\App\Route\ConfigInterface', array(), array(), '', false), $this->getMock('Magento\App\Request\PathInfoProcessorInterface', array(), array(), '', false) ); - $response = new \Magento\TestFramework\Response(); + $response = new \Magento\TestFramework\Response( + $this->getMock('\Magento\Stdlib\Cookie', array(), array(), '', false), + $this->getMock('Magento\App\Http\Context', array(), array(), '', false) + ); $this->_objectManager = $this->getMock( 'Magento\TestFramework\ObjectManager', array('get', 'create'), array(), '', false diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/GridTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/GridTest.php index 7f2fbcd9070..9f8bdc70e70 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/GridTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/GridTest.php @@ -87,9 +87,9 @@ class GridTest extends \PHPUnit_Framework_TestCase protected function _getColumnSetMock() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $directoryList = $objectManager->create('\Magento\App\Filesystem\DirectoryList', array('root' => __DIR__)); + $directoryList = $objectManager->create('Magento\App\Filesystem\DirectoryList', array('root' => __DIR__)); return $this->getMock('Magento\Backend\Block\Widget\Grid\ColumnSet', array(), array( - $objectManager->create('\Magento\View\Element\Template\Context', array( + $objectManager->create('Magento\View\Element\Template\Context', array( 'filesystem' => $objectManager->create( '\Magento\App\Filesystem', array('directoryList' => $directoryList) diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/AuthTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/AuthTest.php index c4d5be5fc79..2cd9c4e7316 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Model/AuthTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/AuthTest.php @@ -95,6 +95,7 @@ class AuthTest extends \PHPUnit_Framework_TestCase */ public function testLogout() { + $this->markTestIncomplete('MAGETWO-17021'); $this->_model->login( \Magento\TestFramework\Bootstrap::ADMIN_NAME, \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD); $this->assertNotEmpty($this->_model->getAuthStorage()->getData()); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/LocaleTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/Locale/ResolverTest.php similarity index 83% rename from dev/tests/integration/testsuite/Magento/Backend/Model/LocaleTest.php rename to dev/tests/integration/testsuite/Magento/Backend/Model/Locale/ResolverTest.php index 9090529bbd3..3e1abfdfe92 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Model/LocaleTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/Locale/ResolverTest.php @@ -25,15 +25,15 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Backend\Model; +namespace Magento\Backend\Model\Locale; /** * @magentoAppArea adminhtml */ -class LocaleTest extends \PHPUnit_Framework_TestCase +class ResolverTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Locale\ResolverInterface */ protected $_model; @@ -41,19 +41,19 @@ class LocaleTest extends \PHPUnit_Framework_TestCase { parent::setUp(); $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Backend\Model\Locale'); + ->create('Magento\Backend\Model\Locale\Resolver'); } /** - * @covers \Magento\Core\Model\LocaleInterface::setLocale + * @covers \Magento\Locale\ResolverInterface::setLocale */ public function testSetLocaleWithDefaultLocale() { - $this->_checkSetLocale(\Magento\Core\Model\LocaleInterface::DEFAULT_LOCALE); + $this->_checkSetLocale(\Magento\Locale\ResolverInterface::DEFAULT_LOCALE); } /** - * @covers \Magento\Core\Model\LocaleInterface::setLocale + * @covers \Magento\Locale\ResolverInterface::setLocale */ public function testSetLocaleWithBaseInterfaceLocale() { @@ -67,7 +67,7 @@ class LocaleTest extends \PHPUnit_Framework_TestCase } /** - * @covers \Magento\Core\Model\LocaleInterface::setLocale + * @covers \Magento\Locale\ResolverInterface::setLocale */ public function testSetLocaleWithSessionLocale() { @@ -77,7 +77,7 @@ class LocaleTest extends \PHPUnit_Framework_TestCase } /** - * @covers \Magento\Core\Model\LocaleInterface::setLocale + * @covers \Magento\Locale\ResolverInterface::setLocale */ public function testSetLocaleWithRequestLocale() { diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/_files/config_section.php b/dev/tests/integration/testsuite/Magento/Backend/Model/_files/config_section.php index 414e06b1a7e..681a5b7d331 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Model/_files/config_section.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/_files/config_section.php @@ -25,62 +25,30 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -return array(array ('section' => 'payment', 'groups' =>array( -// TODO: This piece of code should be uncommented after revert of changes described in MPI-1023 comments -// 'account' => array ( -// 'fields' => array ( -// 'merchant_country' => array ('value' => 'US'), -// ), -// ), - 'paypal_payments' => array( - 'groups' => array( - 'payflow_advanced' => array( - 'groups' => array( - 'required_settings' => array( - 'groups' => array( - 'payments_advanced' => array( - 'fields' => array( - 'business_account' => array ('value' => 'owner@example.com') - ) - ) - ) - ) - ) - ), - 'payflow_link' => array( - 'groups' => array( - 'payflow_link_required' => array( - 'fields' => array( - 'enable_payflow_link' => array('value' => '1') - ), - 'groups' => array( - 'payflow_link_payflow_link' => array( - 'fields' => array( - 'partner' => array ('value' => 'link_partner'), - 'vendor' => array ('value' => 'link_vendor'), - 'user' => array ('value' => 'link_user'), - 'pwd' => array ('value' => 'password'), - ) - ) - ) - ) - ) - ) - ) - ) - ), - 'expected' => array( - 'paypal' => array( - 'paypal/general/business_account' => 'owner@example.com', -// TODO: This piece of code should be uncommented after revert of changes described in MPI-1023 comments -// 'paypal/general/merchant_country' => 'US' - ), - 'payment/payflow_link' => array( - 'payment/payflow_link/active' => '1', - 'payment/payflow_link/partner' => 'link_partner', - 'payment/payflow_link/vendor' => 'link_vendor', - 'payment/payflow_link/user' => 'link_user', - 'payment/payflow_link/pwd' => 'password', - ) - ) -)); +return [['section' => 'dev', 'groups' => [ + 'log' => [ + 'fields' => [ + 'active' => ['value' => '1'], + 'file' => ['value' => 'fileName.log'], + 'exception_file' => ['value' => 'exceptionFileName.log'], + ] + ], + 'debug' => [ + 'fields' => [ + 'template_hints' => ['value' => '1'], + 'template_hints_blocks' => ['value' => '0'], + ] + ] + ], + 'expected' => [ + 'dev/log' => [ + 'dev/log/active' => '1', + 'dev/log/file' => 'fileName.log', + 'dev/log/exception_file' => 'exceptionFileName.log', + ], + 'dev/debug' => [ + 'dev/debug/template_hints' => '1', + 'dev/debug/template_hints_blocks' => '0', + ], + ] +]]; diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php index 1fbbda14d92..a4a7717db37 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php @@ -35,6 +35,7 @@ class CategoryTest extends \Magento\Backend\Utility\Controller /** * @magentoDataFixture Magento/Core/_files/store.php * @magentoDbIsolation enabled + * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 * @dataProvider saveActionDataProvider * @param array $inputData * @param array $defaultAttributes diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php index 4429db7f9b3..926cbfb87d9 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php @@ -81,23 +81,14 @@ class AttributeTest extends \Magento\Backend\Utility\Controller */ public function testSaveActionCleanAttributeLabelCache() { - // ensure string translation is cached - $this->_translate('Fixture String'); - /** @var \Magento\Core\Model\Resource\Translate\String $translateString */ - $translateString = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Core\Model\Resource\Translate\String'); - $translateString->saveTranslate('Fixture String', 'New Db Translation', 'en_US'); - $this->assertEquals( - 'Fixture Db Translation', $this->_translate('Fixture String'), 'Translation is expected to be cached' - ); - + /** @var \Magento\Core\Model\Resource\Translate\String $string */ + $string = $this->_objectManager->create('Magento\Core\Model\Resource\Translate\String'); + $this->assertEquals($this->_translate('string to translate'), 'predefined string translation'); + $string->saveTranslate('string to translate', 'new string translation'); $postData = $this->_getAttributeData() + array('attribute_id' => 1); $this->getRequest()->setPost($postData); $this->dispatch('backend/catalog/product_attribute/save'); - - $this->assertEquals( - 'New Db Translation', $this->_translate('Fixture String'), 'Translation cache is expected to be flushed' - ); + $this->assertEquals($this->_translate('string to translate'), 'new string translation'); } /** @@ -112,9 +103,8 @@ class AttributeTest extends \Magento\Backend\Utility\Controller \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\DesignInterface') ->setDesignTheme(1); /** @var \Magento\TranslateInterface $translate */ - $translate = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\TranslateInterface'); - $translate->init(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, null); + $translate = $this->_objectManager->create('Magento\TranslateInterface'); + $translate->init(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, null, true); return $translate->translate(array($string)); } @@ -145,7 +135,7 @@ class AttributeTest extends \Magento\Backend\Utility\Controller 'used_for_sort_by' => '0', 'apply_to' => array('simple'), 'frontend_label' => array( - \Magento\Core\Model\Store::DEFAULT_STORE_ID => 'Fixture String', + \Magento\Core\Model\Store::DEFAULT_STORE_ID => 'string to translate', ), ); } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php index 856106f4b68..2c899b7bf0b 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php @@ -143,7 +143,7 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Log\Model\Visitor'); /** @var \Magento\Stdlib\DateTime $dateTime */ - $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('\Magento\Stdlib\DateTime'); + $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Stdlib\DateTime'); $visitor->setSessionId(md5(time()) . md5(microtime())) ->setLastVisitAt($dateTime->now()) ->save(); @@ -164,7 +164,7 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController ->create('Magento\Log\Model\Visitor'); /** @var \Magento\Stdlib\DateTime $dateTime */ - $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('\Magento\Stdlib\DateTime'); + $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Stdlib\DateTime'); $visitor->setSessionId(md5(time()) . md5(microtime())) ->setLastVisitAt($dateTime->now()) @@ -182,7 +182,7 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController $visitor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Log\Model\Visitor'); /** @var \Magento\Stdlib\DateTime $dateTime */ - $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('\Magento\Stdlib\DateTime'); + $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Stdlib\DateTime'); $visitor->setSessionId(md5(time()) . md5(microtime())) ->setLastVisitAt($dateTime->now()) ->save(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php index 7eaa52cf4c0..fc77a22baf9 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php @@ -161,6 +161,7 @@ class CategoryTest extends \PHPUnit_Framework_TestCase /** * @magentoDataFixture Magento/Core/_files/store.php * @magentoAppIsolation enabled + * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 */ public function testSetStoreIdWithNonNumericValue() { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php index 6a170631483..1737b86773b 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RowTest.php @@ -75,9 +75,9 @@ class RowTest extends \Magento\TestFramework\Indexer\TestCase $this->markTestSkipped('Incomplete due to MAGETWO-21369'); $categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('\Magento\Catalog\Model\CategoryFactory'); + ->create('Magento\Catalog\Model\CategoryFactory'); $listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('\Magento\Catalog\Block\Product\ListProduct'); + ->create('Magento\Catalog\Block\Product\ListProduct'); $this->assertTrue( $this->_state->isFlatEnabled(), diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php index 48afbb4caf2..e6fcb752570 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php @@ -68,6 +68,7 @@ class ProcessorTest extends \Magento\TestFramework\Indexer\TestCase * @magentoAppIsolation enabled * @magentoAppArea adminhtml * @magentoDataFixture Magento/Catalog/_files/multiple_products.php + * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 */ public function testSaveAttribute() { @@ -87,6 +88,7 @@ class ProcessorTest extends \Magento\TestFramework\Indexer\TestCase * @magentoAppIsolation enabled * @magentoAppArea adminhtml * @magentoDataFixture Magento/Catalog/_files/multiple_products.php + * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 */ public function testDeleteAttribute() { @@ -106,6 +108,7 @@ class ProcessorTest extends \Magento\TestFramework\Indexer\TestCase * @magentoAppIsolation enabled * @magentoAppArea adminhtml * @magentoDataFixture Magento/Core/_files/store.php + * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 */ public function testAddNewStore() { @@ -116,6 +119,7 @@ class ProcessorTest extends \Magento\TestFramework\Indexer\TestCase * @magentoDbIsolation enabled * @magentoAppIsolation enabled * @magentoAppArea adminhtml + * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 */ public function testAddNewStoreGroup() { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php index 441614f9754..790a9e488d1 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php @@ -96,7 +96,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase ->saveCache('test', 'catalog_product_999', array('catalog_product_999')); // potential bug: it cleans by cache tags, generated from its ID, which doesn't make much sense $this->_model->setId(999)->cleanCache(); - $this->assertEmpty( + $this->assertFalse( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App') ->loadCache('catalog_product_999') ); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/UrlTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/UrlTest.php index 651541c9814..de9cababa76 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/UrlTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/UrlTest.php @@ -78,11 +78,6 @@ class UrlTest extends \PHPUnit_Framework_TestCase $this->assertInstanceOf('Magento\Catalog\Model\Category', $this->_model->getCategoryModel()); } - public function testGetProductModel() - { - $this->assertInstanceOf('Magento\Catalog\Model\Product', $this->_model->getProductModel()); - } - public function testGetStoreRootCategory() { $root = $this->_model->getStoreRootCategory(1); diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/ResultTest.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/ResultTest.php index 091b0952a8c..eaf1c7ee2d8 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/ResultTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/ResultTest.php @@ -34,6 +34,9 @@ class ResultTest extends \Magento\TestFramework\TestCase\AbstractController */ public function testIndexActionTranslation() { + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $objectManager->get('Magento\Locale\ResolverInterface')->setLocale('de_DE'); + $this->getRequest()->setParam('q', 'query_text'); $this->dispatch('catalogsearch/result'); diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/_files/query.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/_files/query.php index 483a9d426f8..3a1d6a5caf4 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogSearch/_files/query.php +++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/_files/query.php @@ -24,11 +24,8 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); -$objectManager->get('Magento\Core\Model\Locale')->setLocale('de_DE'); - /** @var $query \Magento\CatalogSearch\Model\Query */ $query = $objectManager->create('Magento\CatalogSearch\Model\Query'); $query->setStoreId(1); diff --git a/dev/tests/integration/testsuite/Magento/Centinel/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Centinel/Helper/DataTest.php index 2425ba21741..e35e0789152 100644 --- a/dev/tests/integration/testsuite/Magento/Centinel/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Centinel/Helper/DataTest.php @@ -41,6 +41,6 @@ class DataTest extends \PHPUnit_Framework_TestCase ->create('Magento\Payment\Model\Info'); $paymentInfo->setMethod('checkmo'); $result = $block->getInfoBlock($paymentInfo); - $this->assertInstanceOf('Magento\Payment\Block\Info\Checkmo', $result); + $this->assertInstanceOf('Magento\OfflinePayments\Block\Info\Checkmo', $result); } } diff --git a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest.php b/dev/tests/integration/testsuite/Magento/Code/GeneratorTest.php index 2aa7b0aaf32..2ad6dc26388 100644 --- a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest.php +++ b/dev/tests/integration/testsuite/Magento/Code/GeneratorTest.php @@ -26,8 +26,10 @@ */ namespace Magento\Code; -require_once __DIR__ . '/GeneratorTest/SourceClassWithNamespace.php'; +use \Magento\ObjectManager\Code\Generator as DIGenerator; +use \Magento\Interception\Code\Generator as InterceptionGenerator; +require_once __DIR__ . '/GeneratorTest/SourceClassWithNamespace.php'; require_once __DIR__ . '/GeneratorTest/ParentClassWithNamespace.php'; /** @@ -76,7 +78,15 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase ); $this->_generator = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Code\Generator', - array('ioObject' => $this->_ioObject) + array( + 'ioObject' => $this->_ioObject, + 'generatedEntities' => array( + DIGenerator\Factory::ENTITY_TYPE => '\Magento\ObjectManager\Code\Generator\Factory', + DIGenerator\Proxy::ENTITY_TYPE => '\Magento\ObjectManager\Code\Generator\Proxy', + InterceptionGenerator\Interceptor::ENTITY_TYPE + => '\Magento\Interception\Code\Generator\Interceptor', + ) + ) ); } @@ -92,55 +102,18 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase return preg_replace('/(\/\*[\w\W]*)\nclass/', 'class', $classBody); } - public function testGenerateClassFactoryWithoutNamespace() - { - $factoryClassName = self::CLASS_NAME_WITHOUT_NAMESPACE . 'Factory'; - $result = false; - $generatorResult = $this->_generator->generateClass($factoryClassName); - // \Magento\Code\Generator will return a skip if the class has already been auto-loaded - if (\Magento\Code\Generator::GENERATION_SUCCESS == $generatorResult - || \Magento\Code\Generator::GENERATION_SKIP == $generatorResult - ) { - $result = true; - } - $this->assertTrue($result); - - /** @var $factory \Magento\ObjectManager_Factory */ - $factory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create($factoryClassName); - $object = $factory->create(); - $this->assertInstanceOf(self::CLASS_NAME_WITHOUT_NAMESPACE, $object); - - // This test is only valid if the factory created the object if Autoloader did not pick it up automatically - if (\Magento\Code\Generator::GENERATION_SUCCESS == $generatorResult) { - $content = $this->_clearDocBlock( - file_get_contents( - $this->_ioObject->getResultFileName( - self::CLASS_NAME_WITHOUT_NAMESPACE . 'Factory' - ) - ) - ); - $expectedContent = $this->_clearDocBlock( - file_get_contents( - __DIR__ . '/GeneratorTest/SourceClassWithoutNamespaceFactory.php' - ) - ); - $this->assertEquals($expectedContent, $content); - } - } - public function testGenerateClassFactoryWithNamespace() { $factoryClassName = self::CLASS_NAME_WITH_NAMESPACE . 'Factory'; $result = false; $generatorResult = $this->_generator->generateClass($factoryClassName); if (\Magento\Code\Generator::GENERATION_SUCCESS == $generatorResult - || \Magento\Code\Generator::GENERATION_SKIP == $generatorResult ) { $result = true; } $this->assertTrue($result); - /** @var $factory \Magento\ObjectManager_Factory */ + /** @var $factory \Magento\ObjectManager\Factory */ $factory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create($factoryClassName); $object = $factory->create(); @@ -152,35 +125,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase file_get_contents($this->_ioObject->getResultFileName(self::CLASS_NAME_WITH_NAMESPACE . 'Factory')) ); $expectedContent = $this->_clearDocBlock( - file_get_contents(__DIR__ . '/GeneratorTest/SourceClassWithNamespaceFactory.php') - ); - $this->assertEquals($expectedContent, $content); - } - } - - public function testGenerateClassProxyWithoutNamespace() - { - $proxyClassName = self::CLASS_NAME_WITHOUT_NAMESPACE . 'Proxy'; - $result = false; - $generatorResult = $this->_generator->generateClass($proxyClassName); - if (\Magento\Code\Generator::GENERATION_SUCCESS == $generatorResult - || \Magento\Code\Generator::GENERATION_SKIP == $generatorResult - ) { - $result = true; - } - $this->assertTrue($result); - - $proxy = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create($proxyClassName); - $this->assertInstanceOf(self::CLASS_NAME_WITHOUT_NAMESPACE, $proxy); - - if (\Magento\Code\Generator::GENERATION_SUCCESS == $generatorResult) { - $content = $this->_clearDocBlock( - file_get_contents($this->_ioObject->getResultFileName(self::CLASS_NAME_WITHOUT_NAMESPACE . 'Proxy')) - ); - $expectedContent = $this->_clearDocBlock( - file_get_contents( - __DIR__ . '/GeneratorTest/SourceClassWithoutNamespaceProxy.php' - ) + file_get_contents(__DIR__ . '/_expected/SourceClassWithNamespaceFactory.php') ); $this->assertEquals($expectedContent, $content); } @@ -188,12 +133,10 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase public function testGenerateClassProxyWithNamespace() { - $proxyClassName = self::CLASS_NAME_WITH_NAMESPACE . 'Proxy'; + $proxyClassName = self::CLASS_NAME_WITH_NAMESPACE . '\Proxy'; $result = false; $generatorResult = $this->_generator->generateClass($proxyClassName); - if (\Magento\Code\Generator::GENERATION_SUCCESS == $generatorResult - || \Magento\Code\Generator::GENERATION_SKIP == $generatorResult - ) { + if (\Magento\Code\Generator::GENERATION_SUCCESS == $generatorResult) { $result = true; } $this->assertTrue($result); @@ -204,37 +147,10 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase // This test is only valid if the factory created the object if Autoloader did not pick it up automatically if (\Magento\Code\Generator::GENERATION_SUCCESS == $generatorResult) { $content = $this->_clearDocBlock( - file_get_contents($this->_ioObject->getResultFileName(self::CLASS_NAME_WITH_NAMESPACE . 'Proxy')) + file_get_contents($this->_ioObject->getResultFileName(self::CLASS_NAME_WITH_NAMESPACE . '\Proxy')) ); $expectedContent = $this->_clearDocBlock( - file_get_contents(__DIR__ . '/GeneratorTest/SourceClassWithNamespaceProxy.php') - ); - $this->assertEquals($expectedContent, $content); - } - } - - public function testGenerateClassInterceptorWithoutNamespace() - { - $interceptorClassName = self::CLASS_NAME_WITHOUT_NAMESPACE . 'Interceptor'; - $interceptorClassName = self::CLASS_NAME_WITH_NAMESPACE . 'Interceptor'; - $result = false; - $generatorResult = $this->_generator->generateClass($interceptorClassName); - if (\Magento\Code\Generator::GENERATION_SUCCESS == $generatorResult - || \Magento\Code\Generator::GENERATION_SKIP == $generatorResult - ) { - $result = true; - } - $this->assertTrue($result); - - if (\Magento\Code\Generator::GENERATION_SUCCESS == $generatorResult) { - $content = $this->_clearDocBlock( - file_get_contents($this->_ioObject-> - getResultFileName(self::CLASS_NAME_WITHOUT_NAMESPACE . 'Interceptor')) - ); - $expectedContent = $this->_clearDocBlock( - file_get_contents( - __DIR__ . '/GeneratorTest/SourceClassWithoutNamespaceInterceptor.php' - ) + file_get_contents(__DIR__ . '/_expected/SourceClassWithNamespaceProxy.php') ); $this->assertEquals($expectedContent, $content); } @@ -242,49 +158,20 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase public function testGenerateClassInterceptorWithNamespace() { - $interceptorClassName = self::CLASS_NAME_WITH_NAMESPACE . 'Interceptor'; + $interceptorClassName = self::CLASS_NAME_WITH_NAMESPACE . '\Interceptor'; $result = false; $generatorResult = $this->_generator->generateClass($interceptorClassName); - if (\Magento\Code\Generator::GENERATION_SUCCESS == $generatorResult - || \Magento\Code\Generator::GENERATION_SKIP == $generatorResult - ) { - $result = true; - } - $this->assertTrue($result); - if (\Magento\Code\Generator::GENERATION_SUCCESS == $generatorResult) { - $content = $this->_clearDocBlock( - file_get_contents($this->_ioObject->getResultFileName(self::CLASS_NAME_WITH_NAMESPACE . 'Interceptor')) - ); - $expectedContent = $this->_clearDocBlock( - file_get_contents(__DIR__ . '/GeneratorTest/SourceClassWithNamespaceInterceptor.php') - ); - $this->assertEquals($expectedContent, $content); - } - } - - public function testGenerateInterfaceInterceptorWithoutNamespace() - { - $interceptorName = self::INTERFACE_NAME_WITHOUT_NAMESPACE . 'Interceptor'; - $result = false; - $generatorResult = $this->_generator->generateClass($interceptorName); - if (\Magento\Code\Generator::GENERATION_SUCCESS == $generatorResult - || \Magento\Code\Generator::GENERATION_SKIP == $generatorResult - ) { $result = true; } $this->assertTrue($result); if (\Magento\Code\Generator::GENERATION_SUCCESS == $generatorResult) { $content = $this->_clearDocBlock( - file_get_contents( - $this->_ioObject->getResultFileName(self::INTERFACE_NAME_WITHOUT_NAMESPACE . 'Interceptor') - ) + file_get_contents($this->_ioObject->getResultFileName(self::CLASS_NAME_WITH_NAMESPACE . '\Interceptor')) ); $expectedContent = $this->_clearDocBlock( - file_get_contents( - __DIR__ . '/GeneratorTest/SourceInterfaceWithoutNamespaceInterceptor.php' - ) + file_get_contents(__DIR__ . '/_expected/SourceClassWithNamespaceInterceptor.php') ); $this->assertEquals($expectedContent, $content); } diff --git a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/ParentClassWithoutNamespace.php b/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/ParentClassWithoutNamespace.php deleted file mode 100644 index 3f8ff4281af..00000000000 --- a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/ParentClassWithoutNamespace.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Code - * @subpackage unit_tests - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Code\GeneratorTest; - -use \Zend\Code\Generator\DocBlockGenerator; - -class ParentClassWithoutNamespace -{ - /** - * Public parent method - * - * @param \Zend\Code\Generator\DocBlockGenerator $docBlockGenerator - * @param string $param1 - * @param string $param2 - * @param string $param3 - * @param array $array - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function publicParentMethod( - DocBlockGenerator $docBlockGenerator, - $param1 = '', - $param2 = '\\', - $param3 = '\'', - array $array = array() - ) { - } - - /** - * Protected parent method - * - * @param \Zend\Code\Generator\DocBlockGenerator $docBlockGenerator - * @param string $param1 - * @param string $param2 - * @param string $param3 - * @param array $array - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - protected function _protectedParentMethod( - DocBlockGenerator $docBlockGenerator, - $param1 = '', - $param2 = '\\', - $param3 = '\'', - array $array = array() - ) { - } - - /** - * Private parent method - * - * @param \Zend\Code\Generator\DocBlockGenerator $docBlockGenerator - * @param string $param1 - * @param string $param2 - * @param string $param3 - * @param array $array - * - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - private function _privateParentMethod( - DocBlockGenerator $docBlockGenerator, - $param1 = '', - $param2 = '\\', - $param3 = '\'', - array $array = array() - ) { - } - - public function publicParentWithoutParameters() - { - } - - public static function publicParentStatic() - { - } - - final public function publicParentFinal() - { - } -} diff --git a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithNamespaceInterceptor.php b/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithNamespaceInterceptor.php deleted file mode 100644 index a2e5c898b82..00000000000 --- a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithNamespaceInterceptor.php +++ /dev/null @@ -1,218 +0,0 @@ -<?php -namespace Magento\Code\GeneratorTest; - -/** - * Interceptor class for Magento\Code\GeneratorTest\SourceClassWithNamespace - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -class SourceClassWithNamespaceInterceptor extends \Magento\Code\GeneratorTest\SourceClassWithNamespace -{ - /** - * Object Manager factory - * - * @var \Magento\ObjectManager\Factory - */ - protected $_factory = null; - - /** - * Object Manager instance - * - * @var \Magento\ObjectManager - */ - protected $_objectManager = null; - - /** - * Subject type - * - * @var string - */ - protected $_subjectType = null; - - /** - * Subject - * - * @var \Magento\Code\GeneratorTest\SourceClassWithNamespace - */ - protected $_subject = null; - - /** - * List of plugins - * - * @var \Magento\Interception\PluginList - */ - protected $_pluginList = null; - - /** - * Subject constructor arguments - * - * @var array - */ - protected $_arguments = null; - - /** - * Interceptor constructor - * - * @param \Magento\ObjectManager\Factory $factory - * @param \Magento\ObjectManager\ObjectManager $objectManager - * @param string $subjectType - * @param \Magento\Interception\PluginList $pluginList - * @param array $arguments - */ - public function __construct( - \Magento\ObjectManager\Factory $factory, - \Magento\ObjectManager\ObjectManager $objectManager, - $subjectType, - \Magento\Interception\PluginList $pluginList, - array $arguments - ) { - $this->_factory = $factory; - $this->_objectManager = $objectManager; - $this->_subjectType = $subjectType; - $this->_pluginList = $pluginList; - $this->_arguments = $arguments; - } - - /** - * Retrieve subject - * - * @return mixed - */ - protected function _getSubject() - { - if (is_null($this->_subject)) { - $this->_subject = $this->_factory->create($this->_subjectType, $this->_arguments); - } - return $this->_subject; - } - - /** - * Invoke method - * - * @param string $methodName - * @param array $methodArguments - * @return mixed - */ - protected function _invoke($methodName, array $methodArguments) - { - $beforeMethodName = 'before' . $methodName; - foreach ($this->_pluginList->getPlugins($this->_subjectType, $methodName, 'before') as $plugin) { - $methodArguments = $this->_objectManager->get($plugin) - ->$beforeMethodName($methodArguments); - } - $invocationChain = new \Magento\Code\Plugin\InvocationChain( - $this->_getSubject(), - $methodName, - $this->_objectManager, - $this->_pluginList->getPlugins($this->_subjectType, $methodName, 'around') - ); - $invocationResult = $invocationChain->proceed($methodArguments); - $afterMethodName = 'after' . $methodName; - $afterPlugins = array_reverse( - $this->_pluginList->getPlugins($this->_subjectType, $methodName, 'after') - ); - foreach ($afterPlugins as $plugin) { - $invocationResult = $this->_objectManager->get($plugin) - ->$afterMethodName($invocationResult); - } - return $invocationResult; - } - - /** - * @return array - */ - public function __sleep() - { - $this->_getSubject(); - return array('_subject', '_subjectType'); - } - - /** - * Clone subject instance - */ - public function __clone() - { - $this->_subject = clone $this->_getSubject(); - } - - /** - * Retrieve ObjectManager from the global scope - */ - public function __wakeup() - { - $this->_objectManager = \Magento\App\ObjectManager::getInstance(); - $this->_pluginList = $this->_objectManager->get('Magento\Interception\PluginList'); - } - - /** - * {@inheritdoc} - */ - public function publicChildMethod( - \Zend\Code\Generator\ClassGenerator $classGenerator, - $param1 = '', - $param2 = '\\', - $param3 = '\'', - array $array = array() - ) { - return $this->_invoke('publicChildMethod', func_get_args()); - } - - /** - * {@inheritdoc} - */ - public function publicMethodWithReference( - \Zend\Code\Generator\ClassGenerator &$classGenerator, - &$param1, - array &$array - ) { - return $this->_invoke('publicMethodWithReference', func_get_args()); - } - - /** - * {@inheritdoc} - */ - public function publicChildWithoutParameters() - { - return $this->_invoke('publicChildWithoutParameters', func_get_args()); - } - - /** - * {@inheritdoc} - */ - public function publicParentMethod( - \Zend\Code\Generator\DocBlockGenerator $docBlockGenerator, - $param1 = '', - $param2 = '\\', - $param3 = '\'', - array $array = array() - ) { - return $this->_invoke('publicParentMethod', func_get_args()); - } - - /** - * {@inheritdoc} - */ - public function publicParentWithoutParameters() - { - return $this->_invoke('publicParentWithoutParameters', func_get_args()); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespace.php b/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespace.php deleted file mode 100644 index 2c16252fdc5..00000000000 --- a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespace.php +++ /dev/null @@ -1,133 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Code - * @subpackage unit_tests - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Code\GeneratorTest; - -use \Zend\Code\Generator\ClassGenerator; - -class SourceClassWithoutNamespace - extends \Magento\Code\GeneratorTest\ParentClassWithoutNamespace -{ - /** - * Public child constructor - * - * @param string $param1 - * @param string $param2 - * @param string $param3 - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function __construct($param1 = '', $param2 = '\\', $param3 = '\'') - { - } - - /** - * Public child method - * - * @param \Zend\Code\Generator\ClassGenerator $classGenerator - * @param string $param1 - * @param string $param2 - * @param string $param3 - * @param array $array - * @return void - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function publicChildMethod( - ClassGenerator $classGenerator, - $param1 = '', - $param2 = '\\', - $param3 = '\'', - array $array = array() - ) { - } - - /** - * Public child method with reference - * - * @param \Zend\Code\Generator\ClassGenerator $classGenerator - * @param string $param1 - * @param array $array - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function publicMethodWithReference(ClassGenerator &$classGenerator, &$param1, array &$array) - { - } - - /** - * Protected child method - * - * @param \Zend\Code\Generator\ClassGenerator $classGenerator - * @param string $param1 - * @param string $param2 - * @param string $param3 - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - protected function _protectedChildMethod( - ClassGenerator $classGenerator, - $param1 = '', - $param2 = '\\', - $param3 = '\'' - ) { - } - - /** - * Private child method - * - * @param \Zend\Code\Generator\ClassGenerator $classGenerator - * @param string $param1 - * @param string $param2 - * @param string $param3 - * @param array $array - * @return void - * - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - private function _privateChildMethod( - ClassGenerator $classGenerator, - $param1 = '', - $param2 = '\\', - $param3 = '\'', - array $array = array() - ) { - } - - public function publicChildWithoutParameters() - { - } - - public static function publicChildStatic() - { - } - - final public function publicChildFinal() - { - } -} diff --git a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespaceInterceptor.php b/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespaceInterceptor.php deleted file mode 100644 index 7f5909f4c68..00000000000 --- a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespaceInterceptor.php +++ /dev/null @@ -1,219 +0,0 @@ -<?php -/** - * Interceptor class for \Magento\Code\GeneratorTest\SourceClassWithoutNamespace - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Code\GeneratorTest; - -class SourceClassWithoutNamespaceInterceptor - extends \Magento\Code\GeneratorTest\SourceClassWithoutNamespace -{ - /** - * Object Manager factory - * - * @var \Magento\ObjectManager\Factory - */ - protected $_factory = null; - - /** - * Object Manager instance - * - * @var \Magento\ObjectManager - */ - protected $_objectManager = null; - - /** - * Subject type - * - * @var string - */ - protected $_subjectType = null; - - /** - * Subject - * - * @var \Magento\Code\GeneratorTest\SourceClassWithoutNamespace - */ - protected $_subject = null; - - /** - * List of plugins - * - * @var \Magento\Interception\PluginList - */ - protected $_pluginList = null; - - /** - * Subject constructor arguments - * - * @var array - */ - protected $_arguments = null; - - /** - * Interceptor constructor - * - * @param \Magento\ObjectManager\Factory $factory - * @param \Magento\ObjectManager\ObjectManager $objectManager - * @param string $subjectType - * @param \Magento\Interception\PluginList $pluginList - * @param array $arguments - */ - public function __construct( - \Magento\ObjectManager\Factory $factory, - \Magento\ObjectManager\ObjectManager $objectManager, - $subjectType, - \Magento\Interception\PluginList $pluginList, - array $arguments - ) { - $this->_factory = $factory; - $this->_objectManager = $objectManager; - $this->_subjectType = $subjectType; - $this->_pluginList = $pluginList; - $this->_arguments = $arguments; - } - - /** - * Retrieve subject - * - * @return mixed - */ - protected function _getSubject() - { - if (is_null($this->_subject)) { - $this->_subject = $this->_factory->create($this->_subjectType, $this->_arguments); - } - return $this->_subject; - } - - /** - * Invoke method - * - * @param string $methodName - * @param array $methodArguments - * @return mixed - */ - protected function _invoke($methodName, array $methodArguments) - { - $beforeMethodName = 'before' . $methodName; - foreach ($this->_pluginList->getPlugins($this->_subjectType, $methodName, 'before') as $plugin) { - $methodArguments = $this->_objectManager->get($plugin) - ->$beforeMethodName($methodArguments); - } - $invocationChain = new \Magento\Code\Plugin\InvocationChain( - $this->_getSubject(), - $methodName, - $this->_objectManager, - $this->_pluginList->getPlugins($this->_subjectType, $methodName, 'around') - ); - $invocationResult = $invocationChain->proceed($methodArguments); - $afterMethodName = 'after' . $methodName; - $afterPlugins = array_reverse( - $this->_pluginList->getPlugins($this->_subjectType, $methodName, 'after') - ); - foreach ($afterPlugins as $plugin) { - $invocationResult = $this->_objectManager->get($plugin) - ->$afterMethodName($invocationResult); - } - return $invocationResult; - } - - /** - * @return array - */ - public function __sleep() - { - $this->_getSubject(); - return array('_subject', '_subjectType'); - } - - /** - * Clone subject instance - */ - public function __clone() - { - $this->_subject = clone $this->_getSubject(); - } - - /** - * Retrieve ObjectManager from the global scope - */ - public function __wakeup() - { - $this->_objectManager = \Magento\App\ObjectManager::getInstance(); - $this->_pluginList = $this->_objectManager->get('Magento\Interception\PluginList'); - } - - /** - * {@inheritdoc} - */ - public function publicChildMethod( - \Zend\Code\Generator\ClassGenerator $classGenerator, - $param1 = '', - $param2 = '\\', - $param3 = '\'', - array $array = array() - ) { - return $this->_invoke('publicChildMethod', func_get_args()); - } - - /** - * {@inheritdoc} - */ - public function publicMethodWithReference( - \Zend\Code\Generator\ClassGenerator &$classGenerator, - &$param1, - array &$array - ) { - return $this->_invoke('publicMethodWithReference', func_get_args()); - } - - /** - * {@inheritdoc} - */ - public function publicChildWithoutParameters() - { - return $this->_invoke('publicChildWithoutParameters', func_get_args()); - } - - /** - * {@inheritdoc} - */ - public function publicParentMethod( - \Zend\Code\Generator\DocBlockGenerator $docBlockGenerator, - $param1 = '', - $param2 = '\\', - $param3 = '\'', - array $array = array() - ) { - return $this->_invoke('publicParentMethod', func_get_args()); - } - - /** - * {@inheritdoc} - */ - public function publicParentWithoutParameters() - { - return $this->_invoke('publicParentWithoutParameters', func_get_args()); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespaceProxy.php b/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespaceProxy.php deleted file mode 100644 index 721041f800d..00000000000 --- a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespaceProxy.php +++ /dev/null @@ -1,167 +0,0 @@ -<?php -/** - * Proxy class for \Magento\Code\GeneratorTest\SourceClassWithoutNamespace - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Code\GeneratorTest; - -class SourceClassWithoutNamespaceProxy - extends \Magento\Code\GeneratorTest\SourceClassWithoutNamespace -{ - /** - * Object Manager instance - * - * @var \Magento\ObjectManager - */ - protected $_objectManager = null; - - /** - * Proxied instance name - * - * @var string - */ - protected $_instanceName = null; - - /** - * Proxied instance - * - * @var \Magento\Code\GeneratorTest\SourceClassWithoutNamespace - */ - protected $_subject = null; - - /** - * Instance shareability flag - * - * @var bool - */ - protected $_isShared = null; - - /** - * Proxy constructor - * - * @param \Magento\ObjectManager $objectManager - * @param string $instanceName - * @param bool $shared - */ - public function __construct( - \Magento\ObjectManager $objectManager, - $instanceName = 'Magento\Code\GeneratorTest\SourceClassWithoutNamespace', - $shared = true - ) { - $this->_objectManager = $objectManager; - $this->_instanceName = $instanceName; - $this->_isShared = $shared; - } - - /** - * @return array - */ - public function __sleep() - { - return array('_subject', '_isShared'); - } - - /** - * Retrieve ObjectManager from global scope - */ - public function __wakeup() - { - $this->_objectManager = \Magento\App\ObjectManager::getInstance(); - } - - /** - * Clone proxied instance - */ - public function __clone() - { - $this->_subject = clone $this->_getSubject(); - } - - /** - * Get proxied instance - * - * @return \Magento\Code\GeneratorTest\SourceClassWithoutNamespace - */ - protected function _getSubject() - { - if (!$this->_subject) { - $this->_subject = true === $this->_isShared - ? $this->_objectManager->get($this->_instanceName) - : $this->_objectManager->create($this->_instanceName); - } - return $this->_subject; - } - - /** - * {@inheritdoc} - */ - public function publicChildMethod( - \Zend\Code\Generator\ClassGenerator $classGenerator, - $param1 = '', - $param2 = '\\', - $param3 = '\'', - array $array = array() - ) { - return $this->_getSubject()->publicChildMethod($classGenerator, $param1, $param2, $param3, $array); - } - - /** - * {@inheritdoc} - */ - public function publicMethodWithReference( - \Zend\Code\Generator\ClassGenerator &$classGenerator, - &$param1, - array &$array - ) { - return $this->_getSubject()->publicMethodWithReference($classGenerator, $param1, $array); - } - - /** - * {@inheritdoc} - */ - public function publicChildWithoutParameters() - { - return $this->_getSubject()->publicChildWithoutParameters(); - } - - /** - * {@inheritdoc} - */ - public function publicParentMethod( - \Zend\Code\Generator\DocBlockGenerator $docBlockGenerator, - $param1 = '', - $param2 = '\\', - $param3 = '\'', - array $array = array() - ) { - return $this->_getSubject()->publicParentMethod($docBlockGenerator, $param1, $param2, $param3, $array); - } - - /** - * {@inheritdoc} - */ - public function publicParentWithoutParameters() - { - return $this->_getSubject()->publicParentWithoutParameters(); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceInterfaceWithoutNamespaceInterceptor.php b/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceInterfaceWithoutNamespaceInterceptor.php deleted file mode 100644 index 9db9d2f010e..00000000000 --- a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceInterfaceWithoutNamespaceInterceptor.php +++ /dev/null @@ -1,182 +0,0 @@ -<?php -/** - * Interceptor class for \Magento\Code\GeneratorTest\SourceInterfaceWithoutNamespace - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Code\GeneratorTest; - -class SourceInterfaceWithoutNamespaceInterceptor - implements \Magento\Code\GeneratorTest\SourceInterfaceWithoutNamespace -{ - /** - * Object Manager factory - * - * @var \Magento\ObjectManager\Factory - */ - protected $_factory = null; - - /** - * Object Manager instance - * - * @var \Magento\ObjectManager - */ - protected $_objectManager = null; - - /** - * Subject type - * - * @var string - */ - protected $_subjectType = null; - - /** - * Subject - * - * @var \Magento\Code\GeneratorTest\SourceInterfaceWithoutNamespace - */ - protected $_subject = null; - - /** - * List of plugins - * - * @var \Magento\Interception\PluginList - */ - protected $_pluginList = null; - - /** - * Subject constructor arguments - * - * @var array - */ - protected $_arguments = null; - - /** - * Interceptor constructor - * - * @param \Magento\ObjectManager\Factory $factory - * @param \Magento\ObjectManager\ObjectManager $objectManager - * @param string $subjectType - * @param \Magento\Interception\PluginList $pluginList - * @param array $arguments - */ - public function __construct( - \Magento\ObjectManager\Factory $factory, - \Magento\ObjectManager\ObjectManager $objectManager, - $subjectType, - \Magento\Interception\PluginList $pluginList, - array $arguments - ) { - $this->_factory = $factory; - $this->_objectManager = $objectManager; - $this->_subjectType = $subjectType; - $this->_pluginList = $pluginList; - $this->_arguments = $arguments; - } - - /** - * Retrieve subject - * - * @return mixed - */ - protected function _getSubject() - { - if (is_null($this->_subject)) { - $this->_subject = $this->_factory->create($this->_subjectType, $this->_arguments); - } - return $this->_subject; - } - - /** - * Invoke method - * - * @param string $methodName - * @param array $methodArguments - * @return mixed - */ - protected function _invoke($methodName, array $methodArguments) - { - $beforeMethodName = 'before' . $methodName; - foreach ($this->_pluginList->getPlugins($this->_subjectType, $methodName, 'before') as $plugin) { - $methodArguments = $this->_objectManager->get($plugin) - ->$beforeMethodName($methodArguments); - } - $invocationChain = new \Magento\Code\Plugin\InvocationChain( - $this->_getSubject(), - $methodName, - $this->_objectManager, - $this->_pluginList->getPlugins($this->_subjectType, $methodName, 'around') - ); - $invocationResult = $invocationChain->proceed($methodArguments); - $afterMethodName = 'after' . $methodName; - $afterPlugins = array_reverse( - $this->_pluginList->getPlugins($this->_subjectType, $methodName, 'after') - ); - foreach ($afterPlugins as $plugin) { - $invocationResult = $this->_objectManager->get($plugin) - ->$afterMethodName($invocationResult); - } - return $invocationResult; - } - - /** - * @return array - */ - public function __sleep() - { - $this->_getSubject(); - return array('_subject', '_subjectType'); - } - - /** - * Clone subject instance - */ - public function __clone() - { - $this->_subject = clone $this->_getSubject(); - } - - /** - * Retrieve ObjectManager from the global scope - */ - public function __wakeup() - { - $this->_objectManager = \Magento\App\ObjectManager::getInstance(); - $this->_pluginList = $this->_objectManager->get('Magento\Interception\PluginList'); - } - - /** - * {@inheritdoc} - */ - public function doWorkWithParams($param1, array $param2) - { - return $this->_invoke('doWorkWithParams', func_get_args()); - } - - /** - * {@inheritdoc} - */ - public function doWork() - { - return $this->_invoke('doWork', func_get_args()); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithNamespaceFactory.php b/dev/tests/integration/testsuite/Magento/Code/_expected/SourceClassWithNamespaceFactory.php similarity index 91% rename from dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithNamespaceFactory.php rename to dev/tests/integration/testsuite/Magento/Code/_expected/SourceClassWithNamespaceFactory.php index c438e153244..6a27493dcef 100644 --- a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithNamespaceFactory.php +++ b/dev/tests/integration/testsuite/Magento/Code/_expected/SourceClassWithNamespaceFactory.php @@ -47,10 +47,8 @@ class SourceClassWithNamespaceFactory * @param \Magento\ObjectManager $objectManager * @param string $instanceName */ - public function __construct( - \Magento\ObjectManager $objectManager, - $instanceName = 'Magento\Code\GeneratorTest\SourceClassWithNamespace' - ) { + public function __construct(\Magento\ObjectManager $objectManager, $instanceName = 'Magento\Code\GeneratorTest\SourceClassWithNamespace') + { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; } diff --git a/dev/tests/integration/testsuite/Magento/Code/_expected/SourceClassWithNamespaceInterceptor.php b/dev/tests/integration/testsuite/Magento/Code/_expected/SourceClassWithNamespaceInterceptor.php new file mode 100644 index 00000000000..286fea8ced0 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Code/_expected/SourceClassWithNamespaceInterceptor.php @@ -0,0 +1,189 @@ +<?php +namespace Magento\Code\GeneratorTest\SourceClassWithNamespace; + +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +class Interceptor extends \Magento\Code\GeneratorTest\SourceClassWithNamespace +{ + /** + * Object Manager instance + * + * @var \Magento\ObjectManager + */ + protected $pluginLocator = null; + + /** + * List of plugins + * + * @var \Magento\Interception\PluginList + */ + protected $pluginList = null; + + /** + * Invocation chain + * + * @var \Magento\Interception\Chain + */ + protected $chain = null; + + /** + * Subject type name + * + * @var string + */ + protected $subjectType = null; + + public function __construct(\Magento\ObjectManager $pluginLocator, \Magento\Interception\PluginList $pluginList, \Magento\Interception\Chain $chain, $param1 = '', $param2 = '\\', $param3 = '\'') + { + $this->pluginLocator = $pluginLocator; + $this->pluginList = $pluginList; + $this->chain = $chain; + $this->subjectType = get_parent_class($this); + parent::__construct($param1, $param2, $param3); + } + + public function ___callParent($method, array $arguments) + { + return call_user_func_array(array('parent', $method), $arguments); + } + + public function __sleep() + { + if (method_exists(get_parent_class($this), '__sleep')) { + return parent::__sleep(); + } else { + return array_keys(get_class_vars(get_parent_class($this))); + } + } + + public function __wakeup() + { + $this->pluginLocator = \Magento\App\ObjectManager::getInstance(); + $this->pluginList = $this->pluginLocator->get('Magento\Interception\PluginList'); + $this->chain = $this->pluginLocator->get('Magento\Interception\Chain'); + $this->subjectType = get_parent_class($this); + } + + protected function ___call($method, array $arguments, array $pluginInfo) + { + $capMethod = ucfirst($method); + $result = null; + if (isset($pluginInfo[\Magento\Interception\Definition::LISTENER_BEFORE])) { + foreach ($pluginInfo[\Magento\Interception\Definition::LISTENER_BEFORE] as $code) { + $beforeResult = call_user_func_array( + array($this->pluginList->getPlugin($this->subjectType, $code), 'before'. $capMethod), array_merge(array($this), $arguments) + ); + if ($beforeResult) { + $arguments = $beforeResult; + } + } + } + if (isset($pluginInfo[\Magento\Interception\Definition::LISTENER_AROUND])) { + $chain = $this->chain; + $type = $this->subjectType; + $subject = $this; + $code = $pluginInfo[\Magento\Interception\Definition::LISTENER_AROUND]; + $next = function () use ($chain, $type, $method, $subject, $code) { + return $chain->invokeNext($type, $method, $subject, func_get_args(), $code); + }; + $result = call_user_func_array( + array($this->pluginList->getPlugin($this->subjectType, $code), 'around' . $capMethod), + array_merge(array($this, $next), $arguments) + ); + } else { + $result = call_user_func_array(array('parent', $method), $arguments); + } + if (isset($pluginInfo[\Magento\Interception\Definition::LISTENER_AFTER])) { + foreach ($pluginInfo[\Magento\Interception\Definition::LISTENER_AFTER] as $code) { + $result = $this->pluginList->getPlugin($this->subjectType, $code) + ->{'after' . $capMethod}($this, $result); + } + } + return $result; + } + + /** + * {@inheritdoc} + */ + public function publicChildMethod(\Zend\Code\Generator\ClassGenerator $classGenerator, $param1 = '', $param2 = '\\', $param3 = '\'', array $array = array()) + { + $pluginInfo = $this->pluginList->getNext($this->subjectType, 'publicChildMethod'); + if (!$pluginInfo) { + return parent::publicChildMethod($classGenerator, $param1, $param2, $param3, $array); + } else { + return $this->___call('publicChildMethod', func_get_args(), $pluginInfo); + } + } + + /** + * {@inheritdoc} + */ + public function publicMethodWithReference(\Zend\Code\Generator\ClassGenerator &$classGenerator, &$param1, array &$array) + { + $pluginInfo = $this->pluginList->getNext($this->subjectType, 'publicMethodWithReference'); + if (!$pluginInfo) { + return parent::publicMethodWithReference($classGenerator, $param1, $array); + } else { + return $this->___call('publicMethodWithReference', func_get_args(), $pluginInfo); + } + } + + /** + * {@inheritdoc} + */ + public function publicChildWithoutParameters() + { + $pluginInfo = $this->pluginList->getNext($this->subjectType, 'publicChildWithoutParameters'); + if (!$pluginInfo) { + return parent::publicChildWithoutParameters(); + } else { + return $this->___call('publicChildWithoutParameters', func_get_args(), $pluginInfo); + } + } + + /** + * {@inheritdoc} + */ + public function publicParentMethod(\Zend\Code\Generator\DocBlockGenerator $docBlockGenerator, $param1 = '', $param2 = '\\', $param3 = '\'', array $array = array()) + { + $pluginInfo = $this->pluginList->getNext($this->subjectType, 'publicParentMethod'); + if (!$pluginInfo) { + return parent::publicParentMethod($docBlockGenerator, $param1, $param2, $param3, $array); + } else { + return $this->___call('publicParentMethod', func_get_args(), $pluginInfo); + } + } + + /** + * {@inheritdoc} + */ + public function publicParentWithoutParameters() + { + $pluginInfo = $this->pluginList->getNext($this->subjectType, 'publicParentWithoutParameters'); + if (!$pluginInfo) { + return parent::publicParentWithoutParameters(); + } else { + return $this->___call('publicParentWithoutParameters', func_get_args(), $pluginInfo); + } + } +} diff --git a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithNamespaceProxy.php b/dev/tests/integration/testsuite/Magento/Code/_expected/SourceClassWithNamespaceProxy.php similarity index 79% rename from dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithNamespaceProxy.php rename to dev/tests/integration/testsuite/Magento/Code/_expected/SourceClassWithNamespaceProxy.php index 87a5569846b..52b3e3a3168 100644 --- a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithNamespaceProxy.php +++ b/dev/tests/integration/testsuite/Magento/Code/_expected/SourceClassWithNamespaceProxy.php @@ -1,5 +1,5 @@ <?php -namespace Magento\Code\GeneratorTest; +namespace Magento\Code\GeneratorTest\SourceClassWithNamespace; /** * Proxy class for Magento\Code\GeneratorTest\SourceClassWithNamespace @@ -25,7 +25,7 @@ namespace Magento\Code\GeneratorTest; * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class SourceClassWithNamespaceProxy extends \Magento\Code\GeneratorTest\SourceClassWithNamespace +class Proxy extends \Magento\Code\GeneratorTest\SourceClassWithNamespace { /** * Object Manager instance @@ -62,11 +62,8 @@ class SourceClassWithNamespaceProxy extends \Magento\Code\GeneratorTest\SourceCl * @param string $instanceName * @param bool $shared */ - public function __construct( - \Magento\ObjectManager $objectManager, - $instanceName = 'Magento\Code\GeneratorTest\SourceClassWithNamespace', - $shared = true - ) { + public function __construct(\Magento\ObjectManager $objectManager, $instanceName = 'Magento\Code\GeneratorTest\SourceClassWithNamespace', $shared = true) + { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; $this->_isShared = $shared; @@ -114,24 +111,16 @@ class SourceClassWithNamespaceProxy extends \Magento\Code\GeneratorTest\SourceCl /** * {@inheritdoc} */ - public function publicChildMethod( - \Zend\Code\Generator\ClassGenerator $classGenerator, - $param1 = '', - $param2 = '\\', - $param3 = '\'', - array $array = array() - ) { + public function publicChildMethod(\Zend\Code\Generator\ClassGenerator $classGenerator, $param1 = '', $param2 = '\\', $param3 = '\'', array $array = array()) + { return $this->_getSubject()->publicChildMethod($classGenerator, $param1, $param2, $param3, $array); } /** * {@inheritdoc} */ - public function publicMethodWithReference( - \Zend\Code\Generator\ClassGenerator &$classGenerator, - &$param1, - array &$array - ) { + public function publicMethodWithReference(\Zend\Code\Generator\ClassGenerator &$classGenerator, &$param1, array &$array) + { return $this->_getSubject()->publicMethodWithReference($classGenerator, $param1, $array); } @@ -146,13 +135,8 @@ class SourceClassWithNamespaceProxy extends \Magento\Code\GeneratorTest\SourceCl /** * {@inheritdoc} */ - public function publicParentMethod( - \Zend\Code\Generator\DocBlockGenerator $docBlockGenerator, - $param1 = '', - $param2 = '\\', - $param3 = '\'', - array $array = array() - ) { + public function publicParentMethod(\Zend\Code\Generator\DocBlockGenerator $docBlockGenerator, $param1 = '', $param2 = '\\', $param3 = '\'', array $array = array()) + { return $this->_getSubject()->publicParentMethod($docBlockGenerator, $param1, $param2, $param3, $array); } diff --git a/dev/tests/integration/testsuite/Magento/Core/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Core/Helper/DataTest.php index 81ea32cb7ed..4681427fcba 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Helper/DataTest.php @@ -36,11 +36,6 @@ class DataTest extends \PHPUnit_Framework_TestCase */ protected $_helper = null; - /** - * @var \Magento\Core\Model\LocaleInterface - */ - protected $locale; - /** * @var \DateTime */ @@ -49,8 +44,6 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_helper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Helper\Data'); - $this->locale = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\LocaleInterface'); $this->_dateTime = new \DateTime; $this->_dateTime->setTimezone(new \DateTimeZone(self::DATE_TIMEZONE)); } diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/App/AreaTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/App/AreaTest.php index 554ead2670c..15ccf089fa2 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/App/AreaTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/App/AreaTest.php @@ -77,11 +77,13 @@ class AreaTest extends \PHPUnit_Framework_TestCase // @codingStandardsIgnoreStart /** * @magentoConfigFixture current_store design/theme/ua_regexp a:1:{s:1:"_";a:2:{s:6:"regexp";s:10:"/firefox/i";s:5:"value";s:13:"magento_blank";}} + * @magentoConfigFixture current_store design/package/ua_regexp a:1:{s:1:"_";a:2:{s:6:"regexp";s:10:"/firefox/i";s:5:"value";s:13:"magento_blank";}} * @magentoAppIsolation enabled */ // @codingStandardsIgnoreEnd public function testDetectDesignUserAgent() { + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var $request \Magento\TestFramework\Request */ $request = $objectManager->create('Magento\TestFramework\Request'); @@ -92,10 +94,14 @@ class AreaTest extends \PHPUnit_Framework_TestCase $this->assertEquals('magento_blank', $design->getDesignTheme()->getThemePath()); } + // @codingStandardsIgnoreStart /** + * @magentoConfigFixture current_store design/theme/ua_regexp a:1:{s:1:"_";a:2:{s:6:"regexp";s:10:"/firefox/i";s:5:"value";s:13:"magento_blank";}} + * @magentoConfigFixture current_store design/package/ua_regexp a:1:{s:1:"_";a:2:{s:6:"regexp";s:10:"/firefox/i";s:5:"value";s:13:"magento_blank";}} * @magentoDataFixture Magento/Core/_files/design_change.php * @magentoAppIsolation enabled */ + // @codingStandardsIgnoreEnd public function testDetectDesignDesignChange() { $this->_model->detectDesign(); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php index 5a89cae7fff..353d39309bf 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php @@ -92,25 +92,12 @@ class AppTest extends \PHPUnit_Framework_TestCase $this->assertEquals(\Magento\Core\Model\App::DISTRO_LOCALE_CODE, $this->_model->getDistroLocaleCode()); } - public function testGetLocale() - { - $locale = $this->_model->getLocale(); - $this->assertInstanceOf('Magento\Core\Model\LocaleInterface', $locale); - $this->assertSame($locale, $this->_model->getLocale()); - } public function testGetBaseCurrencyCode() { $this->assertEquals('USD', $this->_model->getBaseCurrencyCode()); } - public function testGetFrontController() - { - $front = $this->_mageModel->getFrontController(); - $this->assertInstanceOf('Magento\App\FrontController', $front); - $this->assertSame($front, $this->_mageModel->getFrontController()); - } - public function testGetCacheInstance() { $cache = $this->_mageModel->getCacheInstance(); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php index ae37800854a..e9eef6c7e7c 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/DesignTest.php @@ -121,7 +121,7 @@ class DesignTest extends \PHPUnit_Framework_TestCase public function testLoadChangeCache() { /** @var \Magento\Stdlib\DateTime $dateTime */ - $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('\Magento\Stdlib\DateTime'); + $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Stdlib\DateTime'); $date = $dateTime->now(true); $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Core\Model\StoreManagerInterface')->getAnyStoreView()->getId(); // fixture design_change @@ -180,17 +180,19 @@ class DesignTest extends \PHPUnit_Framework_TestCase $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Core\Model\StoreManagerInterface')->getStore($storeCode); - $store->setConfig(\Magento\Core\Model\LocaleInterface::XML_PATH_DEFAULT_TIMEZONE, $storeTimezone); + $defaultTimeZonePath = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Stdlib\DateTime\TimezoneInterface')->getDefaultTimezonePath(); + $store->setConfig($defaultTimeZonePath, $storeTimezone); $storeId = $store->getId(); - /** @var $locale \Magento\Core\Model\LocaleInterface|\PHPUnit_Framework_MockObject_MockObject */ - $locale = $this->getMock('Magento\Core\Model\LocaleInterface'); + /** @var $locale \Magento\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject */ + $locale = $this->getMock('Magento\Stdlib\DateTime\TimezoneInterface'); $locale->expects($this->once()) - ->method('storeTimeStamp') + ->method('scopeTimeStamp') ->with($storeId) ->will($this->returnValue($storeDatetime)); // store time must stay unchanged during test execution $design = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Core\Model\Design', array('locale' => $locale)); + ->create('Magento\Core\Model\Design', array('localeDate' => $locale)); $design->loadChange($storeId); $actualDesign = $design->getDesign(); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/LayoutTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/LayoutTest.php index 72458399b2b..c7c85b04fc2 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/LayoutTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/LayoutTest.php @@ -129,7 +129,7 @@ class LayoutTest extends \PHPUnit_Framework_TestCase <block class="Magento\View\Element\Text" name="block1"> <block class="Magento\View\Element\Text"/> </block> - <block class="Magento\View\Element\Text" template="test"/> + <block class="Magento\View\Element\Text" template="test" ttl="360"/> <block class="Magento\View\Element\Text"/> </layout>', 'Magento\View\Layout\Element' @@ -141,6 +141,7 @@ class LayoutTest extends \PHPUnit_Framework_TestCase $child = $this->_layout->getBlock('block1_schedule_block'); $this->assertSame($this->_layout->getBlock('block1'), $child->getParentBlock()); $this->assertEquals('test', $this->_layout->getBlock('schedule_block')->getData('template')); + $this->assertEquals('360', $this->_layout->getBlock('schedule_block')->getData('ttl')); $this->assertFalse($this->_layout->getBlock('nonexisting')); } @@ -200,7 +201,6 @@ class LayoutTest extends \PHPUnit_Framework_TestCase $block = $this->_layout->createBlock($blockType, $blockName, array('data' => $blockData)); - $this->assertEquals($this->_layout, $block->getLayout()); $this->assertRegExp($expectedName, $block->getNameInLayout()); $this->assertEquals($expectedData, $block->getData()); } diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php index b16e5e1f1f0..60b1563480c 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php @@ -65,7 +65,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase 'storeManager' => $objectManager->get('Magento\Core\Model\StoreManager'), 'sidResolver' => $objectManager->get('Magento\Session\SidResolverInterface'), 'cookie' => $objectManager->get('Magento\Stdlib\Cookie'), - 'response' => $objectManager->get('\Magento\App\Response\Http'), + 'httpContext' => $objectManager->get('Magento\App\Http\Context'), ); return $this->getMock( diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Theme/Source/ThemeTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Theme/Source/ThemeTest.php index 93c47cda0fa..e46ce243eea 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Theme/Source/ThemeTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Theme/Source/ThemeTest.php @@ -39,7 +39,7 @@ class ThemeTest extends \PHPUnit_Framework_TestCase public function testGetAllOptions() { /** @var $model \Magento\Core\Model\Theme\Source\Theme */ - $model = Bootstrap::getObjectManager()->create('\Magento\Core\Model\Theme\Source\Theme'); + $model = Bootstrap::getObjectManager()->create('Magento\Core\Model\Theme\Source\Theme'); /** @var $expectedCollection \Magento\Core\Model\Theme\Collection */ $expectedCollection = Bootstrap::getObjectManager() diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/db_translate_admin_store.php b/dev/tests/integration/testsuite/Magento/Core/_files/db_translate_admin_store.php index be412e11abb..aa676ddd26a 100644 --- a/dev/tests/integration/testsuite/Magento/Core/_files/db_translate_admin_store.php +++ b/dev/tests/integration/testsuite/Magento/Core/_files/db_translate_admin_store.php @@ -27,4 +27,4 @@ /** @var \Magento\Core\Model\Resource\Translate\String $translateString */ $translateString = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Core\Model\Resource\Translate\String'); -$translateString->saveTranslate('Fixture String', 'Fixture Db Translation', null); +$translateString->saveTranslate('string to translate', 'predefined string translation', null); diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/second_third_store.php b/dev/tests/integration/testsuite/Magento/Core/_files/second_third_store.php new file mode 100644 index 00000000000..5b21438429a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Core/_files/second_third_store.php @@ -0,0 +1,66 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** @var \Magento\Core\Model\Website $website */ +$website = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Core\Model\Website'); +$website->setName('Second Website') + ->setCode('secondwebsite') + ->save(); + +$websiteId = $website->getId(); +$groupId = $website->getDefaultGroupId(); + +/** @var \Magento\Core\Model\Store $store */ +$store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Core\Model\Store'); +$store->setCode('secondstore') + ->setName('Second Store') + ->setSortOrder(10) + ->setIsActive(1); +$store->save(); + + +/** @var \Magento\Core\Model\Website $website */ +$website = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Core\Model\Website'); +$website->setName('Third Website') + ->setCode('thirdwebsite') + ->save(); + +$websiteId = $website->getId(); +$groupId = $website->getDefaultGroupId(); + +/** @var \Magento\Core\Model\Store $store */ +$store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Core\Model\Store'); +$store->setCode('thirdstore') + ->setName('Third Store') + ->setSortOrder(10) + ->setIsActive(1); +$store->save(); + +/* Refresh stores memory cache */ +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\StoreManagerInterface') + ->reinitStores(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/AddressTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/AddressTest.php index 20044d18890..afd8fd7df80 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/AddressTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/AddressTest.php @@ -34,11 +34,16 @@ class AddressTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Customer\Model\Session */ protected $_customerSession; + /** + * @var \Magento\Module\Manager + */ + protected $objectManager; + protected function setUp() { - $this->_customerSession = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('\Magento\Customer\Model\Session'); - $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\LayoutInterface') + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->_customerSession = $this->objectManager->get('Magento\Customer\Model\Session'); + $this->_block = $this->objectManager->get('Magento\View\LayoutInterface') ->createBlock( 'Magento\Customer\Block\Account\Dashboard\Address', '', @@ -56,18 +61,27 @@ class AddressTest extends \PHPUnit_Framework_TestCase */ public function testGetCustomer() { - $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Customer\Service\V1\CustomerServiceInterface') - ->getCustomer(1); - $this->_customerSession->setCustomerId(1); + $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Customer\Service\V1\CustomerCurrentServiceInterface') + ->getCustomer(); $object = $this->_block->getCustomer(); $this->assertEquals($customer, $object); } public function testGetCustomerMissingCustomer() { - $this->assertNull($this->_block->getCustomer()); + $moduleManager = $this->objectManager->get('Magento\Module\Manager'); + if ($moduleManager->isEnabled('Magento_PageCache')) { + $customerDtoBuilder = $this->objectManager + ->create('Magento\Customer\Service\V1\Dto\CustomerBuilder'); + $customerDto = $customerDtoBuilder + ->setGroupId($this->_customerSession->getCustomerGroupId())->create(); + $this->assertEquals($customerDto, $this->_block->getCustomer()); + } else { + $this->assertNull($this->_block->getCustomer()); + } + } /** @@ -78,6 +92,8 @@ class AddressTest extends \PHPUnit_Framework_TestCase */ public function testGetPrimaryShippingAddressHtml($customerId, $expected) { + // todo: this test is sensitive to caching impact + if (!empty($customerId)) { $this->_customerSession->setCustomerId($customerId); } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/HelloTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/HelloTest.php new file mode 100644 index 00000000000..59ab7b31c99 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/HelloTest.php @@ -0,0 +1,88 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Account\Dashboard; + +class HelloTest extends \PHPUnit_Framework_TestCase +{ + /** + * The Hello block. + * + * @var Hello + */ + private $block; + + /** + * Session model. + * + * @var \Magento\Customer\Model\Session + */ + private $customerSession; + + /** + * Execute per test initialization. + */ + public function setUp() + { + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $objectManager->get('Magento\App\State')->setAreaCode('frontend'); + + $this->customerSession = $objectManager->get('Magento\Customer\Model\Session'); + $this->block = $objectManager + ->get('Magento\View\LayoutInterface') + ->createBlock( + 'Magento\Customer\Block\Account\Dashboard\Hello', + '', + ['customerSession' => $this->customerSession] + ) + ->setTemplate('account/dashboard/hello.phtml'); + } + + /** + * Execute per test post cleanup. + */ + public function tearDown() + { + $this->customerSession->unsCustomerId(); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetCustomerName() + { + $this->customerSession->setCustomerId(1); + $this->assertEquals('Firstname Lastname', $this->block->getCustomerName()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testToHtml() + { + $this->customerSession->setCustomerId(1); + $html = $this->block->toHtml(); + $this->assertContains("<div class=\"block dashboard welcome\">", $html); + $this->assertContains("<strong>Hello, Firstname Lastname!</strong>", $html); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/NewsletterTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/NewsletterTest.php new file mode 100644 index 00000000000..110d14bc115 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/NewsletterTest.php @@ -0,0 +1,70 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Account\Dashboard; + +class NewsletterTest extends \PHPUnit_Framework_TestCase +{ + /** + * Newsletter block under test. + * + * @var Newsletter + */ + protected $block; + + /** + * Session model. + * + * @var \Magento\Customer\Model\Session + */ + protected $customerSession; + + /** + * Execute per test initialization. + */ + protected function setUp() + { + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + + $this->customerSession = $objectManager->get('Magento\Customer\Model\Session'); + $this->block = $objectManager + ->get('Magento\View\LayoutInterface') + ->createBlock( + 'Magento\Customer\Block\Account\Dashboard\Newsletter', + '', + ['customerSession' => $this->customerSession] + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetSubscriptionObject() + { + $this->customerSession->setCustomerId(1); + + $subscriber = $this->block->getSubscriptionObject(); + $this->assertInstanceOf('Magento\Newsletter\Model\Subscriber', $subscriber); + $this->assertFalse($subscriber->isSubscribed()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Account/DashboardTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Account/DashboardTest.php new file mode 100644 index 00000000000..c188ca252f1 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Account/DashboardTest.php @@ -0,0 +1,127 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Account; + +use Magento\TestFramework\Helper\Bootstrap; + +class DashboardTest extends \PHPUnit_Framework_TestCase +{ + /** @var Dashboard */ + private $block; + + /** @var \Magento\Customer\Model\Session */ + private $customerSession; + + /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */ + private $customerService; + + /** + * Execute per test initialization. + */ + public function setUp() + { + $this->customerSession = + Bootstrap::getObjectManager()->get('Magento\Customer\Model\Session'); + $this->customerService = + Bootstrap::getObjectManager() + ->get('Magento\Customer\Service\V1\CustomerServiceInterface'); + + $this->block = Bootstrap::getObjectManager()->get('Magento\View\LayoutInterface') + ->createBlock( + 'Magento\Customer\Block\Account\Dashboard', + '', + [ + 'customerSession' => $this->customerSession, + 'customerService' => $this->customerService + ] + ); + } + + /** + * Execute per test cleanup. + */ + public function tearDown() + { + $this->customerSession->unsCustomerId(); + } + + /** + * Verify that the Dashboard::getCustomer() method returns a valid Customer Dto. + * + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetCustomer() + { + $customer = $this->customerService->getCustomer(1); + $this->customerSession->setCustomerId(1); + $object = $this->block->getCustomer(); + $this->assertEquals($customer, $object); + $this->assertInstanceOf('Magento\Customer\Service\V1\Dto\Customer', $object); + } + + /** + * Verify that the specified customer has neither a default billing no shipping address. + * + * @magentoDataFixture Magento/Customer/_files/customer_no_address.php + */ + public function testGetPrimaryAddressesNoAddresses() + { + $this->customerSession->setCustomerId(5); + $this->assertFalse($this->block->getPrimaryAddresses()); + } + + /** + * Verify that the specified customer has the same default billing and shipping address. + * + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/customer_address.php + */ + public function testGetPrimaryAddressesBillingShippingSame() + { + $customer = $this->customerService->getCustomer(1); + $this->customerSession->setCustomerId(1); + $addresses = $this->block->getPrimaryAddresses(); + $this->assertCount(1, $addresses); + $address = $addresses[0]; + $this->assertInstanceOf('Magento\Customer\Service\V1\Dto\Address', $address); + $this->assertEquals($customer->getDefaultBilling(), $address->getId()); + $this->assertEquals($customer->getDefaultShipping(), $address->getId()); + } + + /** + * Verify that the specified customer has different default billing and shipping addresses. + * + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/customer_primary_addresses.php + */ + public function testGetPrimaryAddressesBillingShippingDifferent() + { + $this->customerSession->setCustomerId(1); + $addresses = $this->block->getPrimaryAddresses(); + $this->assertCount(2, $addresses); + $this->assertNotEquals($addresses[0], $addresses[1]); + $this->assertTrue($addresses[0]->isDefaultBilling()); + $this->assertTrue($addresses[1]->isDefaultShipping()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Address/EditTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Address/EditTest.php index ccecbb84210..7c0dbc02383 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Address/EditTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Address/EditTest.php @@ -21,7 +21,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Customer\Block\Address; /** @@ -46,7 +45,6 @@ class EditTest extends \PHPUnit_Framework_TestCase $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->_customerSession = $objectManager->get('\Magento\Customer\Model\Session'); - $this->_customerSession->setCustomerId(1); $this->_context = $objectManager->get('Magento\Backend\Block\Template\Context'); @@ -57,11 +55,14 @@ class EditTest extends \PHPUnit_Framework_TestCase /** @var $layout \Magento\Core\Model\Layout */ $layout = $objectManager->get('Magento\View\LayoutInterface'); - + $customerCurrentService = $objectManager->create( + 'Magento\Customer\Service\V1\CustomerCurrentServiceInterface', + ['customerSession' => $this->_customerSession] + ); $this->_block = $layout->createBlock( 'Magento\Customer\Block\Address\Edit', '', - array('customerSession' => $this->_customerSession) + ['customerSession' => $this->_customerSession, 'customerCurrentService' => $customerCurrentService] ); } @@ -88,6 +89,24 @@ class EditTest extends \PHPUnit_Framework_TestCase $this->assertEquals(1, $this->_block->getRegionId()); } + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/customer_address.php + */ + public function testGetCountryId() + { + $this->assertEquals('US', $this->_block->getCountryId()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php + */ + public function testGetCustomerAddressCount() + { + $this->assertEquals(2, $this->_block->getCustomerAddressCount()); + } + /** * @magentoDataFixture Magento/Customer/_files/customer.php */ diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Address/Renderer/DefaultRendererTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Address/Renderer/DefaultRendererTest.php index f1bffc5bd5b..dd1492ea573 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Address/Renderer/DefaultRendererTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Address/Renderer/DefaultRendererTest.php @@ -61,10 +61,8 @@ class DefaultRendererTest extends \PHPUnit_Framework_TestCase 'firstname' => 'John', 'lastname' => 'Smith', 'postcode' => '75477', - 'region' => [ - 'region' => 'Alabama', - 'region_id' => '1', - ], + 'region' => 'Alabama', + 'region_id' => '1', 'street' => ['Green str, 67'], 'telephone' => '3468676', ]; diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/GroupTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/GroupTest.php new file mode 100644 index 00000000000..1bb38b99c85 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Renderer/Attribute/GroupTest.php @@ -0,0 +1,84 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Block\Adminhtml\Edit\Renderer\Attribute; + +use Magento\Data\Form\Element\AbstractElement; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test Magento\Customer\Block\Adminhtml\Edit\Renderer\Attribute\Group + * + * @magentoAppArea adminhtml + */ +class GroupTest extends \PHPUnit_Framework_TestCase +{ + /** @var Group */ + private $groupRenderer; + + /** @var AbstractElement */ + private $groupElement; + + public function setUp() + { + /** @var \Magento\Customer\Block\Adminhtml\Edit\Tab\Account $accountBlock */ + $accountBlock = Bootstrap::getObjectManager() + ->get('Magento\Customer\Block\Adminhtml\Edit\Tab\Account'); + $accountBlock->initForm(); + $this->groupElement = $accountBlock->getForm()->getElement('group_id'); + + + $this->groupRenderer = Bootstrap::getObjectManager() + ->create('Magento\Customer\Block\Adminhtml\Edit\Renderer\Attribute\Group'); + + } + + public function testRender() + { + /** @var \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $metadataService */ + $metadataService = Bootstrap::getObjectManager() + ->get('Magento\Customer\Service\V1\CustomerMetadataServiceInterface'); + $autoGroupAttribute = $metadataService->getCustomerAttributeMetadata('disable_auto_group_change'); + $this->groupRenderer->setDisableAutoGroupChangeAttribute($autoGroupAttribute); + + $html = $this->groupRenderer->render($this->groupElement); + + $this->assertContains('<option value="1">General</option>', $html); + $this->assertContains('<option value="2">Wholesale</option>', $html); + $this->assertContains('<option value="3">Retailer</option>', $html); + $this->assertContains('<span>Group</span>', $html); + $this->assertContains('Disable Automatic Group Change Based on VAT ID', $html); + } + + public function testRenderWithoutAutoGroup() + { + $html = $this->groupRenderer->render($this->groupElement); + + $this->assertContains('<option value="1">General</option>', $html); + $this->assertContains('<option value="2">Wholesale</option>', $html); + $this->assertContains('<option value="3">Retailer</option>', $html); + $this->assertContains('<span>Group</span>', $html); + $this->assertNotContains('Disable Automatic Group Change Based on VAT ID', $html); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/AccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/AccountTest.php new file mode 100644 index 00000000000..21dbfea79f8 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/AccountTest.php @@ -0,0 +1,181 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Block\Adminhtml\Edit\Tab; + +use Magento\Customer\Controller\RegistryConstants; + +/** + * Test for Account + * + * @magentoAppArea adminhtml + */ +class AccountTest extends \PHPUnit_Framework_TestCase +{ + /** @var Account */ + protected $accountBlock; + + /** @var \Magento\ObjectManager */ + protected $objectManager; + + /** @var \Magento\Registry */ + protected $coreRegistry; + + /** @var \Magento\Backend\Model\Session */ + protected $backendSession; + + /** @var \Magento\Backend\Block\Template\Context */ + protected $context; + + /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */ + protected $customerService; + + public function setUp() + { + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->coreRegistry = $this->objectManager->get('Magento\Registry'); + $this->coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1); + $this->backendSession = $this->objectManager->get('Magento\Backend\Model\Session'); + + $this->context = $this->objectManager + ->get( + 'Magento\Backend\Block\Template\Context', + ['backendSession' => $this->backendSession] + ); + + $this->accountBlock = $this->objectManager->get('Magento\View\LayoutInterface') + ->createBlock( + 'Magento\Customer\Block\Adminhtml\Edit\Tab\Account', + '', + ['context' => $this->context] + ); + + $this->customerService = $this->objectManager->get('Magento\Customer\Service\V1\CustomerServiceInterface'); + } + + public function tearDown() + { + $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testToHtml() + { + $this->backendSession->setCustomerData( + ['customer_id' => 1, 'account' => $this->customerService->getCustomer(1)->__toArray()] + ); + + $result = $this->accountBlock->initForm()->toHtml(); + + // Verify account email + $this->assertRegExp('/id="_accountemail"[^>]*value="customer@example.com"/', $result); + $this->assertRegExp('/input id="_accountfirstname"[^>]*value="Firstname"/', $result); + + // Verify confirmation controls are not present + $this->assertNotContains('field-confirmation', $result); + $this->assertNotContains('_accountconfirmation', $result); + + // Prefix is present but empty + $this->assertRegExp('/<input id="_accountprefix"[^>]*value=""/', $result); + + // Does not contain send email controls + $this->assertNotContains('<input id="_accountsendemail"', $result); + $this->assertNotContains('<select id="_accountsendemail_store_id"', $result); + } + + /** + * @magentoDataFixture Magento/Customer/_files/inactive_customer.php + */ + public function testNeedsConfirmation() + { + $this->backendSession->setCustomerData( + ['customer_id' => 1, 'account' => $this->customerService->getCustomer(1)->__toArray()] + ); + + $result = $this->accountBlock->initForm()->toHtml(); + + // Verify confirmation controls are present + $this->assertContains('<div class="field field-confirmation "', $result); + $this->assertContains('<select id="_accountconfirmation"', $result); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testPrefix() + { + $this->backendSession->setCustomerData( + [ + 'customer_id' => 1, + 'account' => array_merge($this->customerService->getCustomer(1)->__toArray(), ['prefix' => 'Mr']), + ] + ); + $result = $this->accountBlock->initForm()->toHtml(); + + // Prefix has value + $this->assertRegExp('/<input id="_accountprefix"[^>]*value="Mr"/', $result); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testNotReadOnly() + { + $this->backendSession->setCustomerData( + [ + 'customer_id' => 1, + 'account' => $this->customerService->getCustomer(1)->__toArray(), + ] + ); + + $this->accountBlock->initForm()->toHtml(); + $element = $this->accountBlock->getForm()->getElement('firstname'); + + // Make sure readonly has not been set (is null) or set to false + $this->assertTrue(is_null($element->getReadonly()) || !$element->getReadonly()); + } + + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testNewCustomer() + { + $customerBuilder = new \Magento\Customer\Service\V1\Dto\CustomerBuilder(); + + $this->backendSession->setCustomerData( + [ + 'customer_id' => 0, + 'account' => $customerBuilder->create()->__toArray(), + ] + ); + $result = $this->accountBlock->initForm()->toHtml(); + + // Contains send email controls + $this->assertContains('<input id="_accountsendemail"', $result); + $this->assertContains('<select id="_accountsendemail_store_id"', $result); + } +} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/AddressesTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/AddressesTest.php new file mode 100644 index 00000000000..bc1a0b31548 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/AddressesTest.php @@ -0,0 +1,176 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\Customer\Service\V1\CustomerAddressServiceInterface; +use Magento\Customer\Service\V1\CustomerServiceInterface; +use Magento\Customer\Service\V1\Dto\Customer; +use Magento\Customer\Service\V1\Dto\Address; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test Magento\Customer\Block\Adminhtml\Edit\Tab\Addresses + * + * @magentoAppArea adminhtml + * @magentoDataFixture Magento/Customer/_files/customer_sample.php + */ +class AddressesTest extends \PHPUnit_Framework_TestCase +{ + /** @var CustomerServiceInterface */ + private $_customerService; + + /** @var CustomerAddressServiceInterface */ + private $_addressService; + + /** @var \Magento\Registry */ + private $_coreRegistry; + /** @var \Magento\Backend\Model\Session */ + private $_backendSession; + + /** @var \Magento\ObjectManager */ + private $_objectManager; + + /** @var array */ + private $_customerData; + + public function setUp() + { + $this->_objectManager = Bootstrap::getObjectManager(); + $this->_customerService = $this->_objectManager->get( + 'Magento\Customer\Service\V1\CustomerServiceInterface' + ); + $this->_addressService = $this->_objectManager->get( + 'Magento\Customer\Service\V1\CustomerAddressServiceInterface' + ); + $this->_coreRegistry = $this->_objectManager->get('Magento\Registry'); + $this->_backendSession = $this->_objectManager->get('Magento\Backend\Model\Session'); + + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1); + } + + public function tearDown() + { + $this->_backendSession->unsCustomerData(); + $this->_coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + } + + /** + * Validate country default gets displayed + */ + public function testInitFormEmpty() + { + $block = $this->_objectManager->create('Magento\Customer\Block\Adminhtml\Edit\Tab\Addresses'); + $this->_backendSession->setCustomerData(['account' => [], 'address' => []]); + + /** @var Addresses $block */ + $block = $block->initForm(); + /** @var \Magento\Data\Form $form */ + $form = $block->getForm(); + + // Validate Country gets set + $this->assertEquals('US', $form->getElement('country_id')->getValue()); + } + + public function testInitForm() + { + $this->setupExistingCustomerData(); + $block = $this->_objectManager->create('Magento\Customer\Block\Adminhtml\Edit\Tab\Addresses'); + + /** @var Addresses $block */ + $block = $block->initForm(); + /** @var \Magento\Data\Form $form */ + $form = $block->getForm(); + + $this->assertInstanceOf('Magento\Data\Form\Element\Fieldset', $form->getElement('address_fieldset')); + $this->assertInstanceOf('Magento\Data\Form\Element\Text', $form->getElement('prefix')); + $this->assertInstanceOf('Magento\Data\Form\Element\Text', $form->getElement('firstname')); + $this->assertInstanceOf('Magento\Data\Form\Element\Text', $form->getElement('middlename')); + $this->assertInstanceOf('Magento\Data\Form\Element\Text', $form->getElement('lastname')); + $this->assertInstanceOf('Magento\Data\Form\Element\Text', $form->getElement('suffix')); + $this->assertInstanceOf('Magento\Data\Form\Element\Text', $form->getElement('company')); + $this->assertInstanceOf('Magento\Data\Form\Element\Multiline', $form->getElement('street')); + $this->assertEquals(2, $form->getElement('street')->getLineCount()); + $this->assertInstanceOf('Magento\Data\Form\Element\Text', $form->getElement('city')); + $this->assertInstanceOf('Magento\Data\Form\Element\Select', $form->getElement('country_id')); + $this->assertEquals('US', $form->getElement('country_id')->getValue()); + $this->assertInstanceOf('Magento\Data\Form\Element\Text', $form->getElement('region')); + $this->assertInstanceOf('Magento\Data\Form\Element\Hidden', $form->getElement('region_id')); + $this->assertInstanceOf('Magento\Data\Form\Element\Text', $form->getElement('postcode')); + $this->assertInstanceOf('Magento\Data\Form\Element\Text', $form->getElement('telephone')); + $this->assertInstanceOf('Magento\Data\Form\Element\Text', $form->getElement('fax')); + $this->assertInstanceOf('Magento\Data\Form\Element\Text', $form->getElement('vat_id')); + } + + public function testToHtml() + { + $this->setupExistingCustomerData(); + /** @var \Magento\Customer\Block\Adminhtml\Edit\Tab\Addresses $block */ + $block = $this->_objectManager->get('Magento\View\LayoutInterface') + ->createBlock('Magento\Customer\Block\Adminhtml\Edit\Tab\Addresses'); + + $html = $block->initForm()->toHtml(); + + $this->assertContains('Customer Addresses', $html); + $this->assertContains('Remove address', $html); + $this->assertContains('Edit address', $html); + $this->assertContains('test firstname test lastname', $html); + $this->assertContains('test street', $html); + $this->assertContains('removed street', $html); + $this->assertContains('T: +7000000001', $html); + $this->assertContains('Default Billing Address', $html); + $this->assertContains('Default Shipping Address', $html); + $this->assertContains('Add New Address', $html); + $this->assertContains('<option value="US" selected="selected">United States</option>', $html); + $this->assertContains('Texas', $html); + + $this->assertContains('<li class="address-list-item" id="address_item_1" data-item="1">', $html); + $this->assertContains('<a href="#form_address_item_3"', $html); + $this->assertContains('<div class="address-item-edit-content"', $html); + $this->assertContains('id="form_address_item_1" data-item="1"', $html); + $this->assertContains('{"name": "address_item_1"}}', $html); + $this->assertContains('<input id="_item1prefix" name="address[1][prefix]"', $html); + } + + /** + * Put existing customer data into the backend session + */ + protected function setupExistingCustomerData() + { + /** @var Customer $customer */ + $customer = $this->_customerService->getCustomer(1); + $this->_customerData = [ + 'customer_id' => $customer->getCustomerId(), + 'account' => $customer->getAttributes(), + ]; + $this->_customerData['account']['id'] = $customer->getCustomerId(); + /** @var Address[] $addresses */ + $addresses = $this->_addressService->getAddresses(1); + foreach ($addresses as $addressDto) { + $this->_customerData['address'][$addressDto->getId()] = $addressDto->getAttributes(); + $this->_customerData['address'][$addressDto->getId()]['id'] = $addressDto->getId(); + } + $this->_backendSession->setCustomerData($this->_customerData); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartTest.php new file mode 100644 index 00000000000..0851f98eec6 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartTest.php @@ -0,0 +1,125 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab; + +use Magento\Customer\Controller\RegistryConstants; + +/** + * Magento\Customer\Block\Adminhtml\Edit\Tab\Cart + * + * @magentoAppArea adminhtml + */ +class CartTest extends \PHPUnit_Framework_TestCase +{ + const CUSTOMER_ID_VALUE = 1234; + + /** @var \Magento\Backend\Block\Template\Context */ + private $_context; + + /** @var \Magento\Registry */ + private $_coreRegistry; + + /** @var \Magento\Core\Model\StoreManagerInterface */ + private $_storeManager; + + /** @var Cart */ + private $_block; + + /** @var \Magento\ObjectManager */ + private $_objectManager; + + public function setUp() + { + $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + + $this->_storeManager = $this->_objectManager->get('Magento\Core\Model\StoreManager'); + $this->_context = $this->_objectManager + ->get( + 'Magento\Backend\Block\Template\Context', + array('storeManager' => $this->_storeManager) + ); + + $this->_coreRegistry = $this->_objectManager->get('Magento\Registry'); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, self::CUSTOMER_ID_VALUE); + + $this->_block = $this->_objectManager->get('Magento\View\LayoutInterface') + ->createBlock( + 'Magento\Customer\Block\Adminhtml\Edit\Tab\Cart', + '', + array( + 'context' => $this->_context, + 'registry' => $this->_coreRegistry + ) + ); + } + + public function tearDown() + { + $this->_coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + } + + public function testGetCustomerId() + { + $this->assertEquals(self::CUSTOMER_ID_VALUE, $this->_block->getCustomerId()); + } + + public function testGetGridUrl() + { + $this->assertContains('/backend/customer/index/cart', $this->_block->getGridUrl()); + } + + public function testGetGridParentHtml() + { + $this->_block = $this->_objectManager->get('Magento\View\LayoutInterface') + ->createBlock( + 'Magento\Customer\Block\Adminhtml\Edit\Tab\Cart', + '', + array() + ); + $mockCollection = $this->getMockBuilder('\Magento\Data\Collection') + ->disableOriginalConstructor() + ->getMock(); + $this->_block->setCollection($mockCollection); + $this->assertContains("<div class=\"grid-actions\">", $this->_block->getGridParentHtml()); + } + + public function testGetRowUrl() + { + $row = new \Magento\Object(); + $row->setProductId(1); + $this->assertContains('/backend/catalog/product/edit/id/1', $this->_block->getRowUrl($row)); + } + + public function testGetHtml() + { + $html = $this->_block->toHtml(); + $this->assertContains("<div id=\"customer_cart_grid\">", $html); + $this->assertContains("<div class=\"grid-actions\">", $html); + $this->assertContains("customer_cart_gridJsObject = new varienGrid('customer_cart_grid',", $html); + $this->assertContains( + "backend/customer/cart_product_composite_cart/configure/customer_id/" . self::CUSTOMER_ID_VALUE, + $html + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartsTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartsTest.php new file mode 100644 index 00000000000..347cb204b3f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/CartsTest.php @@ -0,0 +1,96 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab; + +use Magento\Customer\Controller\Adminhtml\Index; + +/** + * Magento\Customer\Block\Adminhtml\Edit\Tab\Carts + * + * @magentoAppArea adminhtml + */ +class CartsTest extends \PHPUnit_Framework_TestCase +{ + /** @var Carts */ + private $_block; + + /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */ + private $_customerService; + + /** @var \Magento\Backend\Block\Template\Context */ + private $_context; + + /** @var \Magento\ObjectManager */ + private $_objectManager; + + public function setUp() + { + $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->_customerService = $this->_objectManager->get('Magento\Customer\Service\V1\CustomerServiceInterface'); + $storeManager = $this->_objectManager->get('Magento\Core\Model\StoreManager'); + $this->_context = $this->_objectManager + ->get( + 'Magento\Backend\Block\Template\Context', + array('storeManager' => $storeManager) + ); + + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetHtml() + { + $customer = $this->_customerService->getCustomer(1); + $data = ['account' => $customer->__toArray()]; + $this->_context->getBackendSession()->setCustomerData($data); + + $this->_block = $this->_objectManager->get('Magento\View\LayoutInterface') + ->createBlock('Magento\Customer\Block\Adminhtml\Edit\Tab\Carts', '', ['context' => $this->_context]); + + $html = $this->_block->toHtml(); + $this->assertContains("<div id=\"customer_cart_grid1\">", $html); + $this->assertContains("<div class=\"grid-actions\">", $html); + $this->assertContains("customer_cart_grid1JsObject = new varienGrid('customer_cart_grid1',", $html); + $this->assertContains("backend/customer/cart_product_composite_cart/configure/website_id/1", $html); + } + + public function testGetHtmlNoCustomer() + { + $data = ['account' => []]; + $this->_context->getBackendSession()->setCustomerData($data); + + $this->_block = $this->_objectManager->get('Magento\View\LayoutInterface') + ->createBlock('Magento\Customer\Block\Adminhtml\Edit\Tab\Carts', '', ['context' => $this->_context]); + + $html = $this->_block->toHtml(); + $this->assertContains("<div id=\"customer_cart_grid0\">", $html); + $this->assertContains("<div class=\"grid-actions\">", $html); + $this->assertContains("customer_cart_grid0JsObject = new varienGrid('customer_cart_grid0',", $html); + $this->assertContains("backend/customer/cart_product_composite_cart/configure/website_id/0/key/", $html); + } + + +} + \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/NewsletterTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/NewsletterTest.php new file mode 100644 index 00000000000..f3d9e7cce73 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/NewsletterTest.php @@ -0,0 +1,91 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Class NewsletterTest + * + * @magentoAppArea adminhtml + */ +class NewsletterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Newsletter + */ + private $block; + + /** + * Core registry + * + * @var \Magento\Registry + */ + private $coreRegistry; + + /** + * Execute per test initialization. + */ + public function setUp() + { + $objectManager = Bootstrap::getObjectManager(); + $objectManager->get('Magento\App\State')->setAreaCode('adminhtml'); + + $this->coreRegistry = $objectManager->get('Magento\Registry'); + $this->block = $objectManager->get('Magento\View\LayoutInterface') + ->createBlock( + 'Magento\Customer\Block\Adminhtml\Edit\Tab\Newsletter', + '', + [ + 'registry' => $this->coreRegistry + ] + ) + ->setTemplate('tab/newsletter.phtml'); + } + + /** + * Execute post test cleanup + */ + public function tearDown() + { + $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testToHtml() + { + $this->coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1); + $html = $this->block->initForm()->toHtml(); + + $this->assertStringStartsWith("<div class=\"entry-edit\">", $html); + $this->assertContains("<span>Newsletter Information</span>", $html); + $this->assertContains("type=\"checkbox\"", $html); + $this->assertNotContains("checked=\"checked\"", $html); + $this->assertContains("<span>Subscribed to Newsletter</span>", $html); + $this->assertContains(">No Newsletter Found<", $html); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/OrdersTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/OrdersTest.php new file mode 100644 index 00000000000..ee90ff1e535 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/OrdersTest.php @@ -0,0 +1,103 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Class OrdersTest + * + * @magentoAppArea adminhtml + */ +class OrdersTest extends \PHPUnit_Framework_TestCase +{ + /** + * The orders block under test. + * + * @var Orders + */ + private $block; + + /** + * Core registry. + * + * @var \Magento\Registry + */ + private $coreRegistry; + + /** + * Execute per test initialization. + */ + public function setUp() + { + $objectManager = Bootstrap::getObjectManager(); + $objectManager->get('Magento\App\State')->setAreaCode('adminhtml'); + + $this->coreRegistry = $objectManager->get('Magento\Registry'); + $this->coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1); + + $this->block = $objectManager->get('Magento\View\LayoutInterface') + ->createBlock( + 'Magento\Customer\Block\Adminhtml\Edit\Tab\Orders', + '', + ['coreRegistry' => $this->coreRegistry] + ); + $this->block->getPreparedCollection(); + } + + /** + * Execute post test cleanup. + */ + public function tearDown() + { + $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + $this->block->setCollection(null); + } + + /** + * Verify that a valid Url is returned for a given sales order row. + */ + public function testGetRowUrl() + { + $row = new \Magento\Object(['id' => 1]); + $this->assertContains('sales/order/view/order_id/1', $this->block->getRowUrl($row)); + } + + /** + * Verify that a valid grid Url is returned. + */ + public function testGetGridUrl() + { + $this->assertContains('customer/index/orders', $this->block->getGridUrl()); + } + + /** + * Verify that the sales order grid Html is valid and contains no records. + */ + public function testToHtml() + { + $this->assertContains("We couldn't find any records.", $this->block->toHtml()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/AccordionTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/AccordionTest.php index f1a66c88fdd..43a4e1eb0ef 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/AccordionTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/AccordionTest.php @@ -27,39 +27,89 @@ namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; +use Magento\Customer\Controller\RegistryConstants; + /** * @magentoAppArea adminhtml */ class AccordionTest extends \PHPUnit_Framework_TestCase { - /** - * @var \Magento\Customer\Block\Adminhtml\Edit\Tab\View\Accordion - */ - protected $_block; + /** @var \Magento\Core\Model\Layout */ + protected $layout; + + /** @var \Magento\Registry */ + protected $registry; + + /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */ + protected $customerService; + + /** @var \Magento\Backend\Model\Session */ + protected $backendSession; protected function setUp() { parent::setUp(); - /** @var $customer \Magento\Customer\Model\Customer */ - $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Customer\Model\Customer'); - $customer->load(1); /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get('Magento\Registry')->register('current_customer', $customer); - /** @var $layout \Magento\View\LayoutInterface */ - $layout = $objectManager->create( + $this->registry = $objectManager->get('Magento\Registry'); + $this->customerService = $objectManager->get('Magento\Customer\Service\V1\CustomerServiceInterface'); + $this->backendSession = $objectManager->get('Magento\Backend\Model\Session'); + $this->layout = $objectManager->create( 'Magento\Core\Model\Layout', array('area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) ); - $this->_block = $layout->createBlock('Magento\Customer\Block\Adminhtml\Edit\Tab\View\Accordion'); + } + + protected function tearDown() + { + $this->registry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); } /** - * magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoConfigFixture customer/account_share/scope 1 */ - public function testToHtml() + public function testToHtmlEmptyWebsiteShare() { - $this->assertContains('Wishlist - 0 item(s)', $this->_block->toHtml()); + $this->registry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1); + $block = $this->layout->createBlock('Magento\Customer\Block\Adminhtml\Edit\Tab\View\Accordion'); + + $html = $block->toHtml(); + + $this->assertContains('Wishlist - 0 item(s)', $html); + $this->assertContains('Shopping Cart - 0 item(s)', $html); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Core/_files/second_third_store.php + * @magentoConfigFixture current_store customer/account_share/scope 0 + */ + public function testToHtmlEmptyGlobalShareAndSessionData() + { + $this->registry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1); + $customer = $this->customerService->getCustomer(1); + $this->backendSession->setCustomerData(['account' => $customer->__toArray()]); + $block = $this->layout->createBlock('Magento\Customer\Block\Adminhtml\Edit\Tab\View\Accordion'); + + $html = $block->toHtml(); + + $this->assertContains('Wishlist - 0 item(s)', $html); + $this->assertContains('Shopping Cart of Main Website - 0 item(s)', $html); + $this->assertContains('Shopping Cart of Second Website - 0 item(s)', $html); + $this->assertContains('Shopping Cart of Third Website - 0 item(s)', $html); + } + + /** + * @magentoConfigFixture customer/account_share/scope 1 + */ + public function testToHtmlEmptyWebsiteShareNewCustomer() + { + $block = $this->layout->createBlock('Magento\Customer\Block\Adminhtml\Edit\Tab\View\Accordion'); + + $html = $block->toHtml(); + + $this->assertContains('Wishlist - 0 item(s)', $html); + $this->assertContains('Shopping Cart - 0 item(s)', $html); } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/CartTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/CartTest.php new file mode 100644 index 00000000000..c12a4911d1c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/CartTest.php @@ -0,0 +1,137 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Class CartTest + * + * @magentoAppArea adminhtml + */ +class CartTest extends \PHPUnit_Framework_TestCase +{ + /** + * Shopping cart. + * + * @var Cart + */ + private $block; + + /** + * Core registry. + * + * @var \Magento\Registry + */ + private $coreRegistry; + + /** + * Execute per test initialization. + */ + public function setUp() + { + $objectManager = Bootstrap::getObjectManager(); + $objectManager->get('Magento\App\State')->setAreaCode('adminhtml'); + + $this->coreRegistry = $objectManager->get('Magento\Registry'); + $this->coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1); + + $this->block = $objectManager->get('Magento\View\LayoutInterface') + ->createBlock( + 'Magento\Customer\Block\Adminhtml\Edit\Tab\View\Cart', + '', + [ + 'coreRegistry' => $this->coreRegistry, + 'data' => ['website_id' => 1] + ] + ); + $this->block->getPreparedCollection(); + } + + /** + * Execute per test cleanup. + */ + public function tearDown() + { + $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + } + + /** + * Verify that the Url for a product row in the cart grid is correct. + */ + public function testGetRowUrl() + { + $row = new \Magento\Object(['product_id' => 1]); + $this->assertContains('catalog/product/edit/id/1', $this->block->getRowUrl($row)); + } + + /** + * Verify that the headers in the cart grid are visible. + */ + public function testGetHeadersVisibility() + { + $this->assertTrue($this->block->getHeadersVisibility()); + } + + /** + * Verify that the customer has a single item in his cart. + * + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/quote.php + */ + public function testGetCollection() + { + $this->assertEquals(1, $this->block->getCollection()->getSize()); + } + + /** + * Verify the basic content of an empty cart. + * + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testToHtmlEmptyCart() + { + $this->assertEquals(0, $this->block->getCollection()->getSize()); + $this->assertContains( + "There are no items in customer's shopping cart at the moment", + $this->block->toHtml() + ); + } + + /** + * Verify the Html content for a single item in the customer's cart. + * + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/quote.php + */ + public function testToHtmlCartItem() + { + $html = $this->block->toHtml(); + $this->assertContains('Simple Product', $html); + $this->assertContains('simple', $html); + $this->assertContains('$10.00', $html); + $this->assertContains('catalog/product/edit/id/1', $html); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/OrdersTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/OrdersTest.php new file mode 100644 index 00000000000..12f7572ba32 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/OrdersTest.php @@ -0,0 +1,130 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Class OrdersTest + * + * @magentoAppArea adminhtml + */ +class OrdersTest extends \PHPUnit_Framework_TestCase +{ + /** + * The orders block under test. + * + * @var Orders + */ + private $block; + + /** + * Core registry. + * + * @var \Magento\Registry + */ + private $coreRegistry; + + /** + * Execute per test initialization. + */ + public function setUp() + { + $objectManager = Bootstrap::getObjectManager(); + $objectManager->get('Magento\App\State')->setAreaCode('adminhtml'); + + $this->coreRegistry = $objectManager->get('Magento\Registry'); + $this->coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1); + + $this->block = $objectManager->get('Magento\View\LayoutInterface') + ->createBlock( + 'Magento\Customer\Block\Adminhtml\Edit\Tab\View\Orders', + '', + ['coreRegistry' => $this->coreRegistry] + ); + $this->block->getPreparedCollection(); + } + + /** + * Execute post test cleanup. + */ + public function tearDown() + { + $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + $this->block->setCollection(null); + } + + /** + * Verify that the correct Url is return for a row in the orders grid. + */ + public function testGetRowUrl() + { + $row = new \Magento\Object(['id' => 1]); + $this->assertContains('sales/order/view/order_id/1', $this->block->getRowUrl($row)); + } + + /** + * Verify that the grid headers are visible. + */ + public function testGetHeadersVisibility() + { + $this->assertTrue($this->block->getHeadersVisibility()); + } + + /** + * Verify the integrity of the orders collection. + */ + public function testGetCollection() + { + $collection = $this->block->getCollection(); + $this->assertEquals(0, $collection->getSize()); + $this->assertEquals(5, $collection->getPageSize()); + $this->assertEquals(1, $collection->getCurPage()); + } + + /** + * Check the empty grid Html. + */ + public function testToHtmlEmptyOrders() + { + $this->assertEquals(0, $this->block->getCollection()->getSize()); + $this->assertContains("We couldn't find any records.", $this->block->toHtml()); + } + + /** + * Verify the contents of the grid Html when there is a sales order. + * + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Sales/_files/order.php + * @magentoDataFixture Magento/Customer/_files/sales_order.php + */ + public function testToHtmlWithOrders() + { + $html = $this->block->toHtml(); + $this->assertContains('100000001', $html); + $this->assertContains('firstname lastname', $html); + $this->assertEquals(1, $this->block->getCollection()->getSize()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/SalesTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/SalesTest.php new file mode 100644 index 00000000000..d9da8bba7ac --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/SalesTest.php @@ -0,0 +1,148 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Class SalesTest + * + * @magentoAppArea adminhtml + */ +class SalesTest extends \PHPUnit_Framework_TestCase +{ + const MAIN_WEBSITE = 1; + + /** + * Sales block under test. + * + * @var Sales + */ + private $block; + + /** + * Core registry. + * + * @var \Magento\Registry + */ + private $coreRegistry; + + /** + * Sales order view Html. + * + * @var string + */ + private $html; + + /** + * Execute per test initialization. + */ + public function setUp() + { + $objectManager = Bootstrap::getObjectManager(); + $objectManager->get('Magento\App\State')->setAreaCode('adminhtml'); + + $this->coreRegistry = $objectManager->get('Magento\Registry'); + $this->coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1); + + $this->block = $objectManager->get('Magento\View\LayoutInterface') + ->createBlock( + 'Magento\Customer\Block\Adminhtml\Edit\Tab\View\Sales', + 'sales_' . mt_rand(), + ['coreRegistry' => $this->coreRegistry] + ) + ->setTemplate('tab/view/sales.phtml'); + $this->html = $this->block->toHtml(); + } + + /** + * Execute post test cleanup. + */ + public function tearDown() + { + $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + $this->html = ''; + } + + /** + * Test basic currency formatting on the Main Website. + */ + public function testFormatCurrency() + { + $this->assertEquals( + '<span class="price">$10.00</span>', + $this->block->formatCurrency(10.00, self::MAIN_WEBSITE) + ); + } + + /** + * Verify that the website is not in single store mode. + */ + public function testIsSingleStoreMode() + { + $this->assertFalse($this->block->isSingleStoreMode()); + } + + /** + * Verify sales totals. No sales so there are no totals. + */ + public function testGetTotals() + { + $this->assertEquals( + [ + 'lifetime' => 0, + 'base_lifetime' => 0, + 'base_avgsale' => 0, + 'num_orders' => 0 + ], + $this->block->getTotals()->getData() + ); + } + + /** + * Verify that there are no rows in the sales order grid. + */ + public function testGetRows() + { + $this->assertEmpty($this->block->getRows()); + } + + /** + * Verify that the Main Website has no websites. + */ + public function testGetWebsiteCount() + { + $this->assertEquals(0, $this->block->getWebsiteCount(self::MAIN_WEBSITE)); + } + + /** + * Verify basic content of the sales view Html. + */ + public function testToHtml() + { + $this->assertContains('<span class="title">Sales Statistics</span>', $this->html); + $this->assertContains('<strong>All Store Views</strong>', $this->html); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php index 1e595e19550..9f3aa8ee816 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/ViewTest.php @@ -23,8 +23,8 @@ */ namespace Magento\Customer\Block\Adminhtml\Edit\Tab; -use Magento\Core\Model\LocaleInterface; -use Magento\Customer\Model\Customer as CustomerModel; +use Magento\Customer\Controller\RegistryConstants; +use Magento\Customer\Service\V1\Dto\Customer; /** * Magento\Customer\Block\Adminhtml\Edit\Tab\View @@ -33,16 +33,17 @@ use Magento\Customer\Model\Customer as CustomerModel; */ class ViewTest extends \PHPUnit_Framework_TestCase { - const CURRENT_CUSTOMER = 'current_customer'; - /** @var \Magento\Backend\Block\Template\Context */ private $_context; /** @var \Magento\Registry */ private $_coreRegistry; - /** @var \Magento\Customer\Model\CustomerFactory */ - private $_customerFactory; + /** @var \Magento\Customer\Service\V1\Dto\CustomerBuilder */ + private $_customerBuilder; + + /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */ + private $_customerService; /** @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface */ private $_groupService; @@ -64,8 +65,9 @@ class ViewTest extends \PHPUnit_Framework_TestCase array('storeManager' => $this->_storeManager) ); - $this->_customerFactory = $objectManager->get('Magento\Customer\Model\CustomerFactory'); + $this->_customerBuilder = $objectManager->get('Magento\Customer\Service\V1\Dto\CustomerBuilder'); $this->_coreRegistry = $objectManager->get('Magento\Registry'); + $this->_customerService = $objectManager->get('Magento\Customer\Service\V1\CustomerServiceInterface'); $this->_groupService = $objectManager->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface'); $this->_block = $objectManager->get('Magento\View\LayoutInterface') @@ -82,7 +84,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase public function tearDown() { - $this->_coreRegistry->unregister(self::CURRENT_CUSTOMER); + $this->_coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); } /** @@ -90,12 +92,12 @@ class ViewTest extends \PHPUnit_Framework_TestCase */ public function testGetCustomer() { - $this->assertSame($this->_loadCustomer(), $this->_block->getCustomer()); + $this->assertEquals($this->_loadCustomer(), $this->_block->getCustomer()); } public function testGetCustomerEmpty() { - $this->assertSame($this->_createCustomer(), $this->_block->getCustomer()); + $this->assertEquals($this->_createCustomer(), $this->_block->getCustomer()); } /** @@ -118,8 +120,9 @@ class ViewTest extends \PHPUnit_Framework_TestCase */ public function testGetCreateDate() { - $createdAt = $this->_block - ->formatDate($this->_loadCustomer()->getCreatedAt(), LocaleInterface::FORMAT_TYPE_MEDIUM, true); + $createdAt = $this->_block->formatDate( + $this->_loadCustomer()->getCreatedAt(), \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, true + ); $this->assertEquals($createdAt, $this->_block->getCreateDate()); } @@ -130,8 +133,10 @@ class ViewTest extends \PHPUnit_Framework_TestCase { $customer = $this->_loadCustomer(); $date = $this->_context - ->getLocale()->storeDate($customer->getStoreId(), $customer->getCreatedAtTimestamp(), true); - $storeCreateDate = $this->_block->formatDate($date, LocaleInterface::FORMAT_TYPE_MEDIUM, true); + ->getLocaleDate()->scopeDate($customer->getStoreId(), $customer->getCreatedAt(), true); + $storeCreateDate = $this->_block->formatDate( + $date, \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, true + ); $this->assertEquals($storeCreateDate, $this->_block->getStoreCreateDate()); } @@ -140,9 +145,15 @@ class ViewTest extends \PHPUnit_Framework_TestCase */ public function testGetStoreCreateDateTimezone() { + /** + * @var \Magento\Stdlib\DateTime\TimezoneInterface $defaultTimeZonePath + */ + $defaultTimeZonePath = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Stdlib\DateTime\TimezoneInterface')->getDefaultTimezonePath(); $timezone = $this->_context ->getStoreConfig() - ->getConfig(LocaleInterface::XML_PATH_DEFAULT_TIMEZONE, $this->_loadCustomer()->getStoreId()); + ->getConfig( + $defaultTimeZonePath, $this->_loadCustomer()->getStoreId()); $this->assertEquals($timezone, $this->_block->getStoreCreateDateTimezone()); } @@ -151,30 +162,24 @@ class ViewTest extends \PHPUnit_Framework_TestCase */ public function testIsConfirmedStatusConfirmed() { - $this->_loadCustomer()->setConfirmation(false); + $this->_loadCustomer(); $this->assertEquals('Confirmed', $this->_block->getIsConfirmedStatus()); } - public function testIsConfirmedStatusConfirmationIsRequired() - { - $customer = $this->getMock( - 'Magento\Customer\Model\Customer', ['getConfirmation', 'isConfirmationRequired'], [], '', false - ); - $customer->expects($this->once())->method('getConfirmation')->will($this->returnValue(true)); - $customer->expects($this->once())->method('isConfirmationRequired')->will($this->returnValue(true)); - $this->_coreRegistry->register(self::CURRENT_CUSTOMER, $customer); - $this->assertEquals('Not confirmed, cannot login', $this->_block->getIsConfirmedStatus()); - } - /** - * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDbIsolation enabled */ public function testIsConfirmedStatusConfirmationIsNotRequired() { - $customer = $this->_loadCustomer(); - $customer->setConfirmation(true); - $customer->setSkipConfirmationIfEmail($customer->getEmail()); - $this->assertEquals('Not confirmed, can login', $this->_block->getIsConfirmedStatus()); + /** @var Customer $customer */ + $customer = $this->_customerBuilder->setConfirmation(true) + ->setFirstname('firstname') + ->setLastname('lastname') + ->setEmail('email@email.com') + ->create(); + $id = $this->_customerService->saveCustomer($customer); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $id); + $this->assertEquals('Confirmation Not Required', $this->_block->getIsConfirmedStatus()); } /** @@ -200,8 +205,11 @@ class ViewTest extends \PHPUnit_Framework_TestCase */ public function testGetBillingAddressHtml() { - $html = $this->_loadCustomer()->getPrimaryBillingAddress()->format('html'); - $this->assertEquals($html, $this->_block->getBillingAddressHtml()); + $this->_loadCustomer(); + $html = $this->_block->getBillingAddressHtml(); + $this->assertContains('John Smith<br/>', $html); + $this->assertContains('Green str, 67<br />', $html); + $this->assertContains('CityM, Alabama, 75477<br/>', $html); } public function testGetBillingAddressHtmlNoDefaultAddress() @@ -240,33 +248,42 @@ class ViewTest extends \PHPUnit_Framework_TestCase /** * @magentoDataFixture Magento/Customer/_files/customer.php */ - public function testIsHidden() + public function testIsHiddenNot() { $this->_loadCustomer(); $this->assertFalse($this->_block->isHidden()); } - public function testIsHiddenNot() + public function testIsHidden() { $this->_createCustomer(); $this->assertTrue($this->_block->isHidden()); } /** - * @return CustomerModel + * @return Customer */ private function _createCustomer() { - $customer = $this->_customerFactory->create(); - $this->_coreRegistry->register(self::CURRENT_CUSTOMER, $customer); + /** @var \Magento\Customer\Service\V1\Dto\Customer $customer */ + $customer = $this->_customerBuilder->setFirstname('firstname') + ->setLastname('lastname') + ->setEmail('email@email.com') + ->create(); + $data = ['account' => $customer->__toArray()]; + $this->_context->getBackendSession()->setCustomerData($data); return $customer; } /** - * @return CustomerModel + * @return Customer */ private function _loadCustomer() { - return $this->_createCustomer()->load(1); + $customer = $this->_customerService->getCustomer(1); + $data = ['account' => $customer->__toArray()]; + $this->_context->getBackendSession()->setCustomerData($data); + $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customer->getCustomerId()); + return $customer; } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/TabsTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/TabsTest.php new file mode 100644 index 00000000000..c240cb29a21 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/TabsTest.php @@ -0,0 +1,149 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Adminhtml\Edit; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Customer\Service\V1\Dto\Customer; + +/** + * Class TabsTest + * + * @magentoAppArea adminhtml + */ +class TabsTest extends \PHPUnit_Framework_TestCase +{ + /** + * The edit block under test. + * + * @var Tabs + */ + private $block; + + /** + * Customer service. + * + * @var \Magento\Customer\Service\V1\CustomerServiceInterface + */ + private $customerService; + + /** + * Backend context. + * + * @var \Magento\Backend\Block\Template\Context + */ + private $context; + + /** + * Core Registry. + * + * @var \Magento\Registry + */ + private $coreRegistry; + + /** + * Execute per test initialization. + */ + public function setUp() + { + $objectManager = Bootstrap::getObjectManager(); + $objectManager->get('Magento\App\State')->setAreaCode('adminhtml'); + + $this->context = $objectManager->get('Magento\Backend\Block\Template\Context'); + $this->customerService = $objectManager->get('Magento\Customer\Service\V1\CustomerServiceInterface'); + + $this->coreRegistry = $objectManager->get('Magento\Registry'); + $this->coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1); + + $this->block = $objectManager->get('Magento\View\LayoutInterface') + ->createBlock( + 'Magento\Customer\Block\Adminhtml\Edit\Tabs', + '', + [ + 'context' => $this->context, + 'registry' => $this->coreRegistry + ] + ); + } + + /** + * Execute post class cleanup after all tests have executed. + */ + public function tearDown() + { + $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + $this->context->getBackendSession()->setCustomerData([]); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testToHtml() + { + $customer = $this->customerService + ->getCustomer($this->coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID)); + + $customerData['customer_id'] = $customer->getCustomerId(); + $customerData['account'] = $customer->__toArray(); + $customerData['address'] = []; + $this->context->getBackendSession()->setCustomerData($customerData); + + $html = $this->block->toHtml(); + + $this->assertContains('name="cart" title="Shopping Cart"', $html); + $this->assertContains('name="wishlist" title="Wishlist"', $html); + + $this->assertStringMatchesFormat('%a name="account[firstname]" %s value="Firstname" %a', $html); + $this->assertStringMatchesFormat('%a name="account[lastname]" %s value="Lastname" %a', $html); + $this->assertStringMatchesFormat('%a name="account[email]" %s value="customer@example.com" %a', $html); + } + + /** + * No data fixture nor is there a customer Id set in the registry. + */ + public function testToHtmlNoCustomerId() + { + $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + + $customerData['account'] = [ + Customer::FIRSTNAME => 'John', + Customer::LASTNAME => 'Doe', + Customer::EMAIL => 'john.doe@gmail.com', + Customer::GROUP_ID => 1, + Customer::WEBSITE_ID => 1 + ]; + $customerData['address'] = []; + + $this->context->getBackendSession()->setCustomerData($customerData); + + $html = $this->block->toHtml(); + + $this->assertNotContains('name="cart" title="Shopping Cart"', $html); + $this->assertNotContains('name="wishlist" title="Wishlist"', $html); + + $this->assertStringMatchesFormat('%a name="account[firstname]" %s value="John" %a', $html); + $this->assertStringMatchesFormat('%a name="account[lastname]" %s value="Doe" %a', $html); + $this->assertStringMatchesFormat('%a name="account[email]" %s value="john.doe@gmail.com" %a', $html); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/EditTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/EditTest.php new file mode 100644 index 00000000000..278336c239d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/EditTest.php @@ -0,0 +1,160 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Adminhtml; + +use Magento\Customer\Controller\RegistryConstants; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Customer\Service\V1\Dto\Customer; + +/** + * Class EditTest + * + * @magentoAppArea adminhtml + * @magentoDataFixture createCustomer + */ +class EditTest extends \PHPUnit_Framework_TestCase +{ + /** + * The edit block under test. + * + * @var Edit + */ + private $block; + + /** + * Core Registry. + * + * @var \Magento\Registry + */ + private $coreRegistry; + + /** + * The customer Id. + * + * @var int + */ + private static $customerId; + + /** + * Create a new Customer. + */ + public static function createCustomer() + { + $customerService = Bootstrap::getObjectManager() + ->get('Magento\Customer\Service\V1\CustomerServiceInterface'); + $customer = new Customer([ + 'group_id' => 1, + 'website_id' => 1, + 'firstname' => 'Firstname', + 'lastname' => 'Lastname', + 'email' => 'firstname.lastname@gmail.com' + ]); + self::$customerId = $customerService->saveCustomer($customer); + } + + /** + * Execute per test initialization. + */ + public function setUp() + { + $objectManager = Bootstrap::getObjectManager(); + $objectManager->get('Magento\App\State')->setAreaCode('adminhtml'); + + $this->coreRegistry = $objectManager->get('Magento\Registry'); + $this->coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, self::$customerId); + + $this->block = $objectManager->get('Magento\View\LayoutInterface') + ->createBlock( + 'Magento\Customer\Block\Adminhtml\Edit', + '', + ['coreRegistry' => $this->coreRegistry] + ); + } + + /** + * Execute post class cleanup after all tests have executed. + */ + public function tearDown() + { + $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + } + + /** + * Verify that the customer Id is the one that was set in the registry. + */ + public function testGetCustomerId() + { + $this->assertEquals(self::$customerId, $this->block->getCustomerId()); + } + + /** + * Verify that the correct order create Url is generated. + */ + public function testGetCreateOrderUrl() + { + $this->assertContains( + 'sales/order_create/start/customer_id/' . self::$customerId, + $this->block->getCreateOrderUrl() + ); + } + + /** + * Verify that the header text is correct for a new customer. + */ + public function testGetHeaderTextNewCustomer() + { + $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID); + $this->assertEquals('New Customer', $this->block->getHeaderText()); + } + + /** + * Verify that the header text is correct for an existing customer. + */ + public function testGetHeaderTextExistingCustomer() + { + $this->assertEquals('Firstname Lastname', $this->block->getHeaderText()); + } + + /** + * Verify that the correct customer validation Url is generated. + */ + public function testGetValidationUrl() + { + $this->assertContains('customer/index/validate', $this->block->getValidationUrl()); + } + + /** + * Verify the basic content of the block's form Html. + */ + public function testGetFormHtml() + { + $html = $this->block->getFormHtml(); + $this->assertContains('<div class="entry-edit form-inline">', $html); + $this->assertStringMatchesFormat( + '%a name="customer_id" %s value="' . self::$customerId . '" %a', + $html + ); + $this->assertContains('id="product_composite_configure_form"', $html); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/GridTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/GridTest.php index 5eec60717f6..6adbda968b7 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/GridTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/GridTest.php @@ -25,7 +25,6 @@ namespace Magento\Customer\Block\Adminhtml; use Magento\Backend\App\Area\FrontNameResolver; -use Magento\Core\Model\LocaleInterface; use Magento\Customer\Service\V1\CustomerService; use Magento\Stdlib\DateTime; use Magento\TestFramework\Helper\Bootstrap; @@ -44,7 +43,7 @@ class GridTest extends \PHPUnit_Framework_TestCase /** @var CustomerService */ private $customerService; - /** @var LocaleInterface */ + /** @var \Magento\Stdlib\DateTime\TimezoneInterface */ private $locale; @@ -58,7 +57,7 @@ class GridTest extends \PHPUnit_Framework_TestCase 'Magento\Customer\Service\V1\CustomerService' ); $this->locale = Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\LocaleInterface' + 'Magento\Stdlib\DateTime\TimezoneInterface' ); } @@ -101,7 +100,7 @@ EOT; private function formatDatetime($date) { $format = $this->locale->getDateTimeFormat( - LocaleInterface::FORMAT_TYPE_MEDIUM + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM ); return $this->locale->date($date, DateTime::DATETIME_INTERNAL_FORMAT)->toString($format); } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/Edit/FormTest.php index ba37a908919..c78011d4b40 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/Edit/FormTest.php @@ -25,6 +25,7 @@ namespace Magento\Customer\Block\Adminhtml\Group\Edit; use Magento\Backend\App\Area\FrontNameResolver; +use Magento\Customer\Controller\RegistryConstants; use Magento\Customer\Service\V1\Dto\CustomerGroup; use Magento\Customer\Service\V1\Dto\Filter; use Magento\Customer\Service\V1\Dto\SearchCriteria; @@ -38,15 +39,24 @@ use Magento\TestFramework\Helper\Bootstrap; */ class FormTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\View\LayoutInterface */ + /** + * @var \Magento\View\LayoutInterface + */ private $layout; - /** @var \Magento\Customer\Service\V1\CustomerGroupService */ + /** + * @var \Magento\Customer\Service\V1\CustomerGroupService + */ private $customerGroupService; - /** @var \Magento\Registry */ + /** + * @var \Magento\Registry + */ private $registry; + /** + * Execute per test initialization. + */ public function setUp() { parent::setUp(); @@ -54,22 +64,26 @@ class FormTest extends \PHPUnit_Framework_TestCase 'Magento\Core\Model\Layout', ['area' => FrontNameResolver::AREA_CODE] ); - $this->customerGroupService = Bootstrap::getObjectManager()->get( - 'Magento\Customer\Service\V1\CustomerGroupServiceInterface' - ); - + $this->customerGroupService = Bootstrap::getObjectManager() + ->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface'); $this->registry = Bootstrap::getObjectManager()->get('Magento\Registry'); } + /** + * Execute per test cleanup. + */ public function tearDown() { - $this->registry->unregister('current_group'); + $this->registry->unregister(RegistryConstants::CURRENT_GROUP_ID); } + /** + * Test retrieving a valid group form. + */ public function testGetForm() { - $customerGroup = $this->customerGroupService->getDefaultGroup(0); - $this->registry->register('current_group', $customerGroup); + $this->registry + ->register(RegistryConstants::CURRENT_GROUP_ID, $this->customerGroupService->getDefaultGroup(0)->getId()); /** @var $block Form */ $block = $this->layout->createBlock('Magento\Customer\Block\Adminhtml\Group\Edit\Form', 'block'); @@ -102,7 +116,7 @@ class FormTest extends \PHPUnit_Framework_TestCase ->create(); /** @var CustomerGroup $customerGroup */ $customerGroup = $this->customerGroupService->searchGroups($searchCriteria)->getItems()[0]; - $this->registry->register('current_group', $customerGroup); + $this->registry->register(RegistryConstants::CURRENT_GROUP_ID, $customerGroup->getId()); /** @var $block Form */ $block = $this->layout->createBlock('Magento\Customer\Block\Adminhtml\Group\Edit\Form', 'block'); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/EditTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/EditTest.php index 5634fe2367e..4e3eaa1178b 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/EditTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Group/EditTest.php @@ -25,6 +25,7 @@ namespace Magento\Customer\Block\Adminhtml\Group; use Magento\Backend\App\Area\FrontNameResolver; +use Magento\Customer\Controller\RegistryConstants; use Magento\Customer\Service\V1\Dto\CustomerGroup; use Magento\Customer\Service\V1\Dto\Filter; use Magento\Customer\Service\V1\Dto\SearchCriteria; @@ -39,15 +40,24 @@ use Magento\TestFramework\TestCase\AbstractController; */ class EditTest extends AbstractController { - /** @var \Magento\View\LayoutInterface */ + /** + * @var \Magento\View\LayoutInterface + */ private $layout; - /** @var \Magento\Customer\Service\V1\CustomerGroupService */ + /** + * @var \Magento\Customer\Service\V1\CustomerGroupService + */ private $customerGroupService; - /** @var \Magento\Registry */ + /** + * @var \Magento\Registry + */ private $registry; + /** + * Execute per test initialization. + */ public function setUp() { parent::setUp(); @@ -55,23 +65,27 @@ class EditTest extends AbstractController 'Magento\Core\Model\Layout', ['area' => FrontNameResolver::AREA_CODE] ); - $this->customerGroupService = Bootstrap::getObjectManager()->create( - 'Magento\Customer\Service\V1\CustomerGroupService' - ); - + $this->customerGroupService = Bootstrap::getObjectManager() + ->create('Magento\Customer\Service\V1\CustomerGroupService'); $this->registry = Bootstrap::getObjectManager()->get('Magento\Registry'); } + /** + * Execute per test cleanup. + */ public function tearDown() { - $this->registry->unregister('current_group'); + $this->registry->unregister(RegistryConstants::CURRENT_GROUP_ID); } + /** + * Verify that the Delete button does not exist for the default group. + */ public function testDeleteButtonNotExistInDefaultGroup() { - $customerGroup = $this->customerGroupService->getDefaultGroup(0); - $this->registry->register('current_group', $customerGroup); - $this->getRequest()->setParam('id', $customerGroup->getId()); + $groupId = $this->customerGroupService->getDefaultGroup(0)->getId(); + $this->registry->register(RegistryConstants::CURRENT_GROUP_ID, $groupId); + $this->getRequest()->setParam('id', $groupId); /** @var $block Edit */ $block = $this->layout->createBlock('Magento\Customer\Block\Adminhtml\Group\Edit', 'block'); @@ -94,7 +108,7 @@ class EditTest extends AbstractController /** @var CustomerGroup $customerGroup */ $customerGroup = $this->customerGroupService->searchGroups($searchCriteria)->getItems()[0]; $this->getRequest()->setParam('id', $customerGroup->getId()); - $this->registry->register('current_group', $customerGroup); + $this->registry->register(RegistryConstants::CURRENT_GROUP_ID, $customerGroup->getId()); /** @var $block Edit */ $block = $this->layout->createBlock('Magento\Customer\Block\Adminhtml\Group\Edit', 'block'); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/GenderTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/GenderTest.php index 7a1626f3d2c..bd8bab3064e 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/GenderTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/GenderTest.php @@ -26,24 +26,46 @@ */ namespace Magento\Customer\Block\Widget; +use Magento\TestFramework\Helper\Bootstrap; class GenderTest extends \PHPUnit_Framework_TestCase { - /** - * @var \Magento\Customer\Block\Widget\Gender - */ + /** @var Gender */ protected $_block; + /** + * Test initialization and set up. Create the Gender block. + * @return void + */ protected function setUp() { - $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\LayoutInterface') + $objectManager = Bootstrap::getObjectManager(); + $objectManager->get('Magento\App\State')->setAreaCode('frontend'); + $this->_block = $objectManager->get('Magento\View\LayoutInterface') ->createBlock('Magento\Customer\Block\Widget\Gender'); } + /** + * Test the Gender::getGenderOptions() method. + * @return void + */ public function testGetGenderOptions() { $options = $this->_block->getGenderOptions(); $this->assertInternalType('array', $options); $this->assertNotEmpty($options); + $this->assertContainsOnlyInstancesOf('Magento\Customer\Service\V1\Dto\Eav\Option', $options); + } + + /** + * Test the Gender::toHtml() method. + * @return void + */ + public function testToHtml() + { + $html = $this->_block->toHtml(); + $this->assertContains('<span>Gender</span>', $html); + $this->assertContains('<option value="1">Male</option>', $html); + $this->assertContains('<option value="2">Female</option>', $html); } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/NameTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/NameTest.php new file mode 100644 index 00000000000..0b085d9009f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/NameTest.php @@ -0,0 +1,91 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Block\Widget; + +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test \Magento\Customer\Block\Widget\Name + */ +class NameTest extends \PHPUnit_Framework_TestCase +{ + /** @var Name */ + protected $_block; + + protected function setUp() + { + $objectManager = Bootstrap::getObjectManager(); + $objectManager->get('Magento\App\State')->setAreaCode('frontend'); + $this->_block = $objectManager->get('Magento\View\LayoutInterface') + ->createBlock('Magento\Customer\Block\Widget\Name'); + } + + public function testToHtmlSimpleName() + { + /** @var \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder */ + $customerBuilder = Bootstrap::getObjectManager()->get('Magento\Customer\Service\V1\Dto\CustomerBuilder'); + $customerBuilder->setFirstname('Jane'); + $customerBuilder->setLastname('Doe'); + $this->_block->setObject($customerBuilder->create()); + + $html = $this->_block->toHtml(); + + $this->assertContains('title="First Name"', $html); + $this->assertContains('value="Jane"', $html); + $this->assertContains('title="Last Name"', $html); + $this->assertContains('value="Doe"', $html); + $this->assertNotContains('title="Middle Name/Initial"', $html); + $this->assertNotContains('title="Prefix"', $html); + $this->assertNotContains('title="Suffix"', $html); + } + + /** + * @magentoDataFixture Magento/Customer/_files/attribute_user_fullname.php + */ + public function testToHtmlFancyName() + { + /** @var \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder */ + $customerBuilder = Bootstrap::getObjectManager()->get('Magento\Customer\Service\V1\Dto\CustomerBuilder'); + $customerBuilder->setPrefix('Dr.') + ->setFirstname('Jane') + ->setMiddlename('Roe') + ->setLastname('Doe') + ->setSuffix('Ph.D.'); + $this->_block->setObject($customerBuilder->create()); + + $html = $this->_block->toHtml(); + + $this->assertContains('title="First Name"', $html); + $this->assertContains('value="Jane"', $html); + $this->assertContains('title="Last Name"', $html); + $this->assertContains('value="Doe"', $html); + $this->assertContains('title="Middle Name/Initial"', $html); + $this->assertContains('value="Roe"', $html); + $this->assertContains('title="Prefix"', $html); + $this->assertContains('value="Dr."', $html); + $this->assertContains('title="Suffix"', $html); + $this->assertContains('value="Ph.D."', $html); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php new file mode 100644 index 00000000000..0eda0cbd176 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php @@ -0,0 +1,62 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Block\Widget; + +/** + * Test class for \Magento\Customer\Block\Widget\Taxvat + * + * @magentoAppArea frontend + */ +class TaxvatTest extends \PHPUnit_Framework_TestCase +{ + + public function testToHtml() + { + /** @var \Magento\Customer\Block\Widget\Taxvat $block */ + $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Block\Widget\Taxvat'); + + $this->assertContains('title="Tax/VAT number"', $block->toHtml()); + $this->assertNotContains('required', $block->toHtml()); + } + + /** + * @magentoDbIsolation enabled + */ + public function testToHtmlRequired() + { + /** @var \Magento\Customer\Model\Attribute $model */ + $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Attribute'); + $model->loadByCode('customer', 'taxvat')->setIsRequired(true); + $model->save(); + + /** @var \Magento\Customer\Block\Widget\Taxvat $block */ + $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Block\Widget\Taxvat'); + + $this->assertContains('title="Tax/VAT number"', $block->toHtml()); + $this->assertContains('required', $block->toHtml()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php old mode 100644 new mode 100755 index ca3a38687ea..3f7128121b2 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php @@ -25,6 +25,8 @@ namespace Magento\Customer\Controller; +use Magento\TestFramework\Helper\Bootstrap; + class AccountTest extends \Magento\TestFramework\TestCase\AbstractController { /** @@ -35,7 +37,10 @@ class AccountTest extends \Magento\TestFramework\TestCase\AbstractController $logger = $this->getMock('Magento\Logger', array(), array(), '', false); $session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Customer\Model\Session', array($logger)); - $session->login('customer@example.com', 'password'); + $service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Service\V1\CustomerAccountService'); + $customer = $service->authenticate('customer@example.com', 'password'); + $session->setCustomerDtoAsLoggedIn($customer); } /** @@ -44,10 +49,7 @@ class AccountTest extends \Magento\TestFramework\TestCase\AbstractController */ public function testIndexAction() { - $logger = $this->getMock('Magento\Logger', array(), array(), '', false); - $session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Customer\Model\Session', array($logger)); - $session->login('customer@example.com', 'password'); + $this->_login(); $this->dispatch('customer/account/index'); $body = $this->getResponse()->getBody(); @@ -397,4 +399,203 @@ class AccountTest extends \Magento\TestFramework\TestCase\AbstractController \Magento\Message\MessageInterface::TYPE_SUCCESS ); } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testEditAction() + { + $this->_login(); + $this->dispatch('customer/account/edit'); + + $this->assertEquals(200, $this->getResponse()->getHttpResponseCode()); + + $body = $this->getResponse()->getBody(); + $this->assertContains('<div class="field name firstname required">', $body); + // Verify the password check box is not checked + $this->assertContains('<input type="checkbox" name="change_password" id="change-password" value="1" ' . + 'title="Change Password" class="checkbox"/>', $body); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testChangePasswordEditAction() + { + $this->_login(); + $this->dispatch('customer/account/edit/changepass/1'); + + $this->assertEquals(200, $this->getResponse()->getHttpResponseCode()); + + $body = $this->getResponse()->getBody(); + $this->assertContains('<div class="field name firstname required">', $body); + // Verify the password check box is checked + $this->assertContains('<input type="checkbox" name="change_password" id="change-password" value="1" ' . + 'title="Change Password" checked="checked" class="checkbox"/>', $body); + } + + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testEditPostAction() + { + /** @var $customerService \Magento\Customer\Service\V1\CustomerServiceInterface */ + $customerService = Bootstrap::getObjectManager() + ->get('Magento\Customer\Service\V1\CustomerServiceInterface'); + $customer = $customerService->getCustomer(1); + $this->assertEquals('Firstname', $customer->getFirstname()); + $this->assertEquals('Lastname', $customer->getLastname()); + $this->assertEquals('customer@example.com', $customer->getEmail()); + + $this->_login(); + $this->getRequest() + ->setServer(['REQUEST_METHOD' => 'POST']) + ->setPost([ + 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), + 'firstname' => 'John', + 'lastname' => 'Doe', + 'email' => 'johndoe@email.com' + ]); + + $this->dispatch('customer/account/editPost'); + + $this->assertRedirect($this->stringEndsWith('customer/account/')); + $this->assertSessionMessages( + $this->equalTo(['The account information has been saved.']), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + + $customer = $customerService->getCustomer(1); + $this->assertEquals('John', $customer->getFirstname()); + $this->assertEquals('Doe', $customer->getLastname()); + $this->assertEquals('johndoe@email.com', $customer->getEmail()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testChangePasswordEditPostAction() + { + /** @var $customerService \Magento\Customer\Service\V1\CustomerServiceInterface */ + $customerService = Bootstrap::getObjectManager() + ->get('Magento\Customer\Service\V1\CustomerServiceInterface'); + $customer = $customerService->getCustomer(1); + $this->assertEquals('Firstname', $customer->getFirstname()); + $this->assertEquals('Lastname', $customer->getLastname()); + $this->assertEquals('customer@example.com', $customer->getEmail()); + + /** @var $customerAccountService \Magento\Customer\Service\V1\CustomerAccountServiceInterface */ + $customerAccountService = Bootstrap::getObjectManager() + ->get('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); + $this->assertTrue($customerAccountService->validatePassword(1, 'password')); + + $this->_login(); + $this->getRequest() + ->setServer(['REQUEST_METHOD' => 'POST']) + ->setPost([ + 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), + 'firstname' => 'John', + 'lastname' => 'Doe', + 'email' => 'johndoe@email.com', + 'change_password' => 1, + 'current_password' => 'password', + 'password' => 'new-password', + 'confirmation' => 'new-password' + ]); + + $this->dispatch('customer/account/editPost'); + + $this->assertRedirect($this->stringEndsWith('customer/account/')); + $this->assertSessionMessages( + $this->equalTo(['The account information has been saved.']), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + + $customer = $customerService->getCustomer(1); + $this->assertEquals('John', $customer->getFirstname()); + $this->assertEquals('Doe', $customer->getLastname()); + $this->assertEquals('johndoe@email.com', $customer->getEmail()); + $this->assertTrue($customerAccountService->validatePassword(1, 'new-password')); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testMissingDataEditPostAction() + { + $this->_login(); + $this->getRequest() + ->setServer(['REQUEST_METHOD' => 'POST']) + ->setPost([ + 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), + 'firstname' => 'John', + 'lastname' => 'Doe', + 'email' => 'bad-email' + ]); + + $this->dispatch('customer/account/editPost'); + + $this->assertRedirect($this->stringEndsWith('customer/account/edit/')); + $this->assertSessionMessages( + $this->equalTo(['Invalid input']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testWrongPasswordEditPostAction() + { + $this->_login(); + $this->getRequest() + ->setServer(['REQUEST_METHOD' => 'POST']) + ->setPost([ + 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), + 'firstname' => 'John', + 'lastname' => 'Doe', + 'email' => 'johndoe@email.com', + 'change_password' => 1, + 'current_password' => 'wrong-password', + 'password' => 'new-password', + 'confirmation' => 'new-password' + ]); + + $this->dispatch('customer/account/editPost'); + + $this->assertRedirect($this->stringEndsWith('customer/account/edit/')); + $this->assertSessionMessages( + $this->equalTo(["Password doesn't match for this account."]), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testWrongConfirmationEditPostAction() + { + $this->_login(); + $this->getRequest() + ->setServer(['REQUEST_METHOD' => 'POST']) + ->setPost([ + 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), + 'firstname' => 'John', + 'lastname' => 'Doe', + 'email' => 'johndoe@email.com', + 'change_password' => 1, + 'current_password' => 'password', + 'password' => 'new-password', + 'confirmation' => 'new-password-no-match' + ]); + + $this->dispatch('customer/account/editPost'); + + $this->assertRedirect($this->stringEndsWith('customer/account/edit/')); + $this->assertSessionMessages( + $this->equalTo(['Confirm your new password']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php index a73cf8e0bad..5ad51a04e5a 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php @@ -34,9 +34,12 @@ class AddressTest extends \Magento\TestFramework\TestCase\AbstractController parent::setUp(); $logger = $this->getMock('Magento\Logger', array(), array(), '', false); - $session = Bootstrap::getObjectManager() + $session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Customer\Model\Session', array($logger)); - $session->login('customer@example.com', 'password'); + $service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Service\V1\CustomerAccountService'); + $customer = $service->authenticate('customer@example.com', 'password'); + $session->setCustomerDtoAsLoggedIn($customer); } /** diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/CartTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/CartTest.php new file mode 100644 index 00000000000..28687249d49 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/CartTest.php @@ -0,0 +1,119 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Controller\Adminhtml\Cart\Product\Composite; + +/** + * @magentoAppArea adminhtml + */ +class CartTest extends \Magento\Backend\Utility\Controller +{ + /** + * @var \Magento\Sales\Model\Resource\Quote\Item\CollectionFactory + */ + protected $quoteItemCollectionFactory; + + public function setUp() + { + parent::setUp(); + $this->quoteItemCollectionFactory = $this->_objectManager->get( + '\Magento\Sales\Model\Resource\Quote\Item\CollectionFactory' + ); + } + + public function testConfigureActionNoCustomerId() + { + $this->dispatch('backend/customer/cart_product_composite_cart/configure'); + $this->assertEquals('{"error":true,"message":"No customer ID defined."}', $this->getResponse()->getBody()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testConfigureActionNoQuoteId() + { + $this->getRequest()->setParam('customer_id', 1); + $this->getRequest()->setParam('website_id', 1); + $this->dispatch('backend/customer/cart_product_composite_cart/configure'); + $this->assertEquals( + '{"error":true,"message":"Please correct the quote items and try again."}', + $this->getResponse()->getBody() + ); + } + + /** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/quote.php + */ + public function testConfigureAction() + { + $items = $this->quoteItemCollectionFactory->create(); + $itemId = $items->getAllIds()[0]; + $this->getRequest()->setParam('customer_id', 1); + $this->getRequest()->setParam('website_id', 1); + $this->getRequest()->setParam('id', $itemId); + $this->dispatch('backend/customer/cart_product_composite_cart/configure'); + $this->assertContains( + '<input id="product_composite_configure_input_qty" class="input-text" type="text" name="qty" value="1">', + $this->getResponse()->getBody() + ); + } + + public function testUpdateActionNoCustomerId() + { + $this->dispatch('backend/customer/cart_product_composite_cart/update'); + $this->assertRedirect($this->stringContains('catalog/product/showUpdateResult')); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testUpdateActionNoQuoteId() + { + $this->getRequest()->setParam('customer_id', 1); + $this->getRequest()->setParam('website_id', 1); + $this->dispatch('backend/customer/cart_product_composite_cart/update'); + $this->assertRedirect($this->stringContains('catalog/product/showUpdateResult')); + } + + /** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/quote.php + */ + public function testUpdateAction() + { + $items = $this->quoteItemCollectionFactory->create(); + $itemId = $items->getAllIds()[0]; + $this->getRequest()->setParam('customer_id', 1); + $this->getRequest()->setParam('website_id', 1); + $this->getRequest()->setParam('id', $itemId); + + $this->dispatch('backend/customer/cart_product_composite_cart/update'); + $this->assertRedirect($this->stringContains('catalog/product/showUpdateResult')); + } +} + \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/GroupTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/GroupTest.php index 4f4cd62d74c..037ffb543c1 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/GroupTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/GroupTest.php @@ -23,8 +23,11 @@ */ namespace Magento\Customer\Controller\Adminhtml; +use Magento\Customer\Controller\RegistryConstants; use Magento\Message\MessageInterface; use Magento\TestFramework\Helper\Bootstrap; +use Magento\Customer\Service\V1\Dto\CustomerGroup; +use Magento\Customer\Service\V1\CustomerGroupServiceInterface; /** * @magentoAppArea adminhtml @@ -33,26 +36,27 @@ class GroupTest extends \Magento\Backend\Utility\Controller { const TAX_CLASS_ID = 3; const CUSTOMER_GROUP_CODE = 'New Customer Group'; + const BASE_CONTROLLER_URL = 'http://localhost/index.php/backend/customer/group/'; protected static $_customerGroupId; public static function setUpBeforeClass() { - /** @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService */ + /** @var CustomerGroupServiceInterface $groupService */ $groupService = Bootstrap::getObjectManager() ->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface'); - $group = new \Magento\Customer\Service\V1\Dto\CustomerGroup([ - 'id' => null, - 'code' => self::CUSTOMER_GROUP_CODE, - 'tax_class_id' => self::TAX_CLASS_ID + $group = new CustomerGroup([ + 'id' => null, + 'code' => self::CUSTOMER_GROUP_CODE, + 'tax_class_id' => self::TAX_CLASS_ID ]); self::$_customerGroupId = $groupService->saveGroup($group);; } public static function tearDownAfterClass() { - /** @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService */ + /** @var CustomerGroupServiceInterface $groupService */ $groupService = Bootstrap::getObjectManager() ->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface'); $groupService->deleteGroup(self::$_customerGroupId); @@ -65,6 +69,12 @@ class GroupTest extends \Magento\Backend\Utility\Controller $this->assertRegExp('/<h1 class\="title">\s*New Customer Group\s*<\/h1>/', $responseBody); } + public function testDeleteActionNoGroupId() + { + $this->dispatch('backend/customer/group/delete'); + $this->assertRedirect($this->stringStartsWith(self::BASE_CONTROLLER_URL)); + } + /** * @magentoDbIsolation enabled */ @@ -77,8 +87,10 @@ class GroupTest extends \Magento\Backend\Utility\Controller * Check that success message is set */ $this->assertSessionMessages( - $this->equalTo(['The customer group has been deleted.']), MessageInterface::TYPE_SUCCESS + $this->equalTo(['The customer group has been deleted.']), + MessageInterface::TYPE_SUCCESS ); + $this->assertRedirect($this->stringStartsWith(self::BASE_CONTROLLER_URL . 'index')); } public function testDeleteActionNonExistingGroupId() @@ -90,8 +102,10 @@ class GroupTest extends \Magento\Backend\Utility\Controller * Check that error message is set */ $this->assertSessionMessages( - $this->equalTo(['The customer group no longer exists.']), MessageInterface::TYPE_ERROR + $this->equalTo(['The customer group no longer exists.']), + MessageInterface::TYPE_ERROR ); + $this->assertRedirect($this->stringStartsWith(self::BASE_CONTROLLER_URL)); } /** @@ -109,10 +123,11 @@ class GroupTest extends \Magento\Backend\Utility\Controller $this->assertSessionMessages($this->logicalNot($this->isEmpty()), MessageInterface::TYPE_SUCCESS); $this->assertSessionMessages( - $this->equalTo(['The customer group has been saved.']), MessageInterface::TYPE_SUCCESS + $this->equalTo(['The customer group has been saved.']), + MessageInterface::TYPE_SUCCESS ); - /** @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService */ + /** @var CustomerGroupServiceInterface $groupService */ $groupService = Bootstrap::getObjectManager() ->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface'); $customerGroupData = $groupService->getGroup(self::$_customerGroupId)->__toArray(); @@ -140,10 +155,11 @@ class GroupTest extends \Magento\Backend\Utility\Controller $this->dispatch('backend/customer/group/save'); $this->assertSessionMessages( - $this->equalTo(['The customer group has been saved.']), MessageInterface::TYPE_SUCCESS + $this->equalTo(['The customer group has been saved.']), + MessageInterface::TYPE_SUCCESS ); - /** @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService */ + /** @var CustomerGroupServiceInterface $groupService */ $groupService = Bootstrap::getObjectManager() ->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface'); @@ -162,7 +178,7 @@ class GroupTest extends \Magento\Backend\Utility\Controller $this->getRequest()->setParam('id', self::$_customerGroupId); $this->dispatch('backend/customer/group/save'); - /** @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService */ + /** @var CustomerGroupServiceInterface $groupService */ $groupService = Bootstrap::getObjectManager() ->get('Magento\Customer\Service\V1\CustomerGroupServiceInterface'); $customerGroupCode = $groupService->getGroup(self::$_customerGroupId)->getCode(); @@ -178,13 +194,17 @@ class GroupTest extends \Magento\Backend\Utility\Controller $this->dispatch('backend/customer/group/save'); + $this->assertSessionMessages($this->isEmpty(), MessageInterface::TYPE_SUCCESS); $this->assertSessionMessages($this->logicalNot($this->isEmpty()), MessageInterface::TYPE_ERROR); $this->assertSessionMessages( - $this->equalTo(['No such entity with groupId = 10000']), MessageInterface::TYPE_ERROR + $this->equalTo(['No such entity with groupId = 10000']), + MessageInterface::TYPE_ERROR ); - /** @var \Magento\Session\SessionManagerInterface $sessionManager */ - $sessionManager = Bootstrap::getObjectManager()->get('Magento\Session\SessionManagerInterface'); - $this->assertEmpty($sessionManager->getCustomerGroupData()); + /** @var \MagentoRegistry $coreRegistry */ + $coreRegistry = Bootstrap::getObjectManager()->get('Magento\Registry'); + $this->assertNull($coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID)); + + $this->assertRedirect($this->stringStartsWith(self::BASE_CONTROLLER_URL . 'edit/id/10000')); } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php old mode 100644 new mode 100755 index 36ab3a4d058..294ad0b1077 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php @@ -18,15 +18,15 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Customer - * @subpackage integration_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Customer\Controller\Adminhtml; +use Magento\Customer\Controller\RegistryConstants; +use Magento\Newsletter\Model\Subscriber; +use Magento\TestFramework\Helper\Bootstrap; + /** * @magentoAppArea adminhtml */ @@ -39,10 +39,20 @@ class IndexTest extends \Magento\Backend\Utility\Controller */ protected $_baseControllerUrl; + /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */ + protected $customerService; + + /** @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface */ + protected $customerAddressService; + protected function setUp() { parent::setUp(); $this->_baseControllerUrl = 'http://localhost/index.php/backend/customer/index/'; + $this->customerService = Bootstrap::getObjectManager() + ->get('Magento\Customer\Service\V1\CustomerServiceInterface'); + $this->customerAddressService = Bootstrap::getObjectManager() + ->get('Magento\Customer\Service\V1\CustomerAddressServiceInterface'); } protected function tearDown() @@ -50,17 +60,16 @@ class IndexTest extends \Magento\Backend\Utility\Controller /** * Unset customer data */ - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Session') + Bootstrap::getObjectManager()->get('Magento\Backend\Model\Session') ->setCustomerData(null); /** * Unset messages */ - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Session') + Bootstrap::getObjectManager()->get('Magento\Backend\Model\Session') ->getMessages(true); } - public function testSaveActionWithEmptyPostData() { $this->getRequest()->setPost(array()); @@ -89,7 +98,8 @@ class IndexTest extends \Magento\Backend\Utility\Controller * Check that customer data were set to session */ $this->assertEquals( - $post, \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + $post, + Bootstrap::getObjectManager() ->get('Magento\Backend\Model\Session')->getCustomerData() ); $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'new')); @@ -124,8 +134,11 @@ class IndexTest extends \Magento\Backend\Utility\Controller /** * Check that customer data were set to session */ - $this->assertEquals($post, \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Backend\Model\Session')->getCustomerData()); + $this->assertEquals( + $post, + Bootstrap::getObjectManager() + ->get('Magento\Backend\Model\Session')->getCustomerData() + ); $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'new')); } @@ -135,7 +148,7 @@ class IndexTest extends \Magento\Backend\Utility\Controller public function testSaveActionWithValidCustomerDataAndValidAddressData() { /** @var $objectManager \Magento\TestFramework\ObjectManager */ - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $objectManager = Bootstrap::getObjectManager(); $post = array( 'account' => array( @@ -148,17 +161,19 @@ class IndexTest extends \Magento\Backend\Utility\Controller 'default_billing' => '_item1', 'password' => 'auto' ), - 'address' => array('_item1' => array( - 'firstname' => 'test firstname', - 'lastname' => 'test lastname', - 'street' => array( - 'test street' - ), - 'city' => 'test city', - 'country_id' => 'US', - 'postcode' => '01001', - 'telephone' => '+7000000001', - )), + 'address' => array( + '_item1' => array( + 'firstname' => 'test firstname', + 'lastname' => 'test lastname', + 'street' => array( + 'test street' + ), + 'city' => 'test city', + 'country_id' => 'US', + 'postcode' => '01001', + 'telephone' => '+7000000001', + ) + ), ); $this->getRequest()->setPost($post); $this->getRequest()->setParam('back', '1'); @@ -184,12 +199,19 @@ class IndexTest extends \Magento\Backend\Utility\Controller * Check that customer id set and addresses saved */ $registry = $objectManager->get('Magento\Registry'); - $customer = $registry->registry('current_customer'); - $this->assertInstanceOf('Magento\Customer\Model\Customer', $customer); - $this->assertCount(1, $customer->getAddressesCollection()); + $customerId = $registry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + $customer = $this->customerService->getCustomer($customerId); + $this->assertEquals('test firstname', $customer->getFirstname()); + $addresses = $this->customerAddressService->getAddresses($customerId); + $this->assertEquals(1, count($addresses)); + $this->assertNotEquals(0, $customer->getDefaultBilling()); + $this->assertNull($customer->getDefaultShipping()); - $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl - . 'edit/id/' . $customer->getId() . '/back/1') + $this->assertRedirect( + $this->stringStartsWith( + $this->_baseControllerUrl + . 'edit/id/' . $customerId . '/back/1' + ) ); } @@ -224,10 +246,10 @@ class IndexTest extends \Magento\Backend\Utility\Controller 'telephone' => '+7000000001', ), '_item1' => array( - 'firstname' => 'test firstname', - 'lastname' => 'test lastname', - 'street' => array('test street'), - 'city' => 'test city', + 'firstname' => 'new firstname', + 'lastname' => 'new lastname', + 'street' => array('new street'), + 'city' => 'new city', 'country_id' => 'US', 'postcode' => '01001', 'telephone' => '+7000000001', @@ -250,17 +272,20 @@ class IndexTest extends \Magento\Backend\Utility\Controller * Check that success message is set */ $this->assertSessionMessages( - $this->equalTo(array('You saved the customer.')), \Magento\Message\MessageInterface::TYPE_SUCCESS + $this->equalTo(array('You saved the customer.')), + \Magento\Message\MessageInterface::TYPE_SUCCESS ); /** @var $objectManager \Magento\TestFramework\ObjectManager */ - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $objectManager = Bootstrap::getObjectManager(); /** * Check that customer id set and addresses saved */ - $customer = $objectManager->get('Magento\Registry')->registry('current_customer'); - $this->assertInstanceOf('Magento\Customer\Model\Customer', $customer); + $registry = $objectManager->get('Magento\Registry'); + $customerId = $registry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); + $customer = $this->customerService->getCustomer($customerId); + $this->assertEquals('test firstname', $customer->getFirstname()); /** * Addresses should be removed by \Magento\Customer\Model\Resource\Customer::_saveAddresses during _afterSave @@ -269,17 +294,12 @@ class IndexTest extends \Magento\Backend\Utility\Controller * addressThree - removed * _item1 - new address */ - $this->assertCount(2, $customer->getAddressesCollection()); - - /** @var $savedCustomer \Magento\Customer\Model\Customer */ - $savedCustomer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Customer\Model\Customer'); - $savedCustomer->load($customer->getId()); - /** - * addressOne - updated - * _item1 - new address - */ - $this->assertCount(2, $savedCustomer->getAddressesCollection()); + $addresses = $this->customerAddressService->getAddresses($customerId); + $this->assertEquals(2, count($addresses)); + $updatedAddress = $this->customerAddressService->getAddressById(1); + $this->assertEquals('update firstname', $updatedAddress->getFirstname()); + $newAddress = $this->customerAddressService->getDefaultShippingAddress($customerId); + $this->assertEquals('new firstname', $newAddress->getFirstname()); $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'index/key/')); } @@ -309,8 +329,652 @@ class IndexTest extends \Magento\Backend\Utility\Controller $this->equalTo(array('Customer with the same email already exists in associated website.')), \Magento\Message\MessageInterface::TYPE_ERROR ); - $this->assertEquals($post, \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Backend\Model\Session')->getCustomerData()); + $this->assertEquals( + $post, + Bootstrap::getObjectManager() + ->get('Magento\Backend\Model\Session')->getCustomerData() + ); $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'new/key/')); } + + /** + * @magentoDataFixture Magento/Customer/_files/customer_sample.php + */ + public function testEditAction() + { + $customerData = [ + 'customer_id' => '1', + 'account' => [ + 'middlename' => 'new middlename', + 'group_id' => 1, + 'website_id' => 1, + 'firstname' => 'new firstname', + 'lastname' => 'new lastname', + 'email' => 'exmaple@domain.com', + 'default_shipping' => '_item1', + 'new_password' => 'auto', + 'sendemail_store_id' => '1', + 'sendemail' => '1', + + ], + 'address' => [ + '1' => array( + 'firstname' => 'update firstname', + 'lastname' => 'update lastname', + 'street' => array('update street'), + 'city' => 'update city', + 'country_id' => 'US', + 'postcode' => '01001', + 'telephone' => '+7000000001', + ), + '_item1' => [ + 'firstname' => 'default firstname', + 'lastname' => 'default lastname', + 'street' => array('default street'), + 'city' => 'default city', + 'country_id' => 'US', + 'postcode' => '01001', + 'telephone' => '+7000000001', + ], + '_template_' => [ + 'firstname' => '', + 'lastname' => '', + 'street' => array(), + 'city' => '', + 'country_id' => 'US', + 'postcode' => '', + 'telephone' => '', + ] + ] + ]; + /** + * set customer data + */ + Bootstrap::getObjectManager()->get('Magento\Backend\Model\Session') + ->setCustomerData($customerData); + $this->getRequest()->setParam('id', 1); + $this->dispatch('backend/customer/index/edit'); + $body = $this->getResponse()->getBody(); + + // verify + $this->assertContains('<h1 class="title">new firstname new lastname</h1>', $body); + + $accountStr = 'data-ui-id="adminhtml-edit-tab-account-fieldset-element-text-account-'; + $this->assertNotContains($accountStr . 'firstname" value="test firstname"', $body); + $this->assertContains($accountStr . 'firstname" value="new firstname"', $body); + + $addressStr = 'data-ui-id="adminhtml-edit-tab-addresses-fieldset-element-text-address-'; + $this->assertNotContains($addressStr . '1-firstname" value="test firstname"', $body); + $this->assertContains($addressStr . '1-firstname" value="update firstname"', $body); + $this->assertContains($addressStr . '2-firstname" value="test firstname"', $body); + $this->assertContains($addressStr . '3-firstname" value="removed firstname"', $body); + $this->assertContains($addressStr . 'item1-firstname" value="default firstname"', $body); + $this->assertContains($addressStr . 'template-firstname" value=""', $body); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer_sample.php + */ + public function testEditActionNoSessionData() + { + $this->getRequest()->setParam('id', 1); + $this->dispatch('backend/customer/index/edit'); + $body = $this->getResponse()->getBody(); + + // verify + $this->assertContains('<h1 class="title">test firstname test lastname</h1>', $body); + + $accountStr = 'data-ui-id="adminhtml-edit-tab-account-fieldset-element-text-account-'; + $this->assertContains($accountStr . 'firstname" value="test firstname"', $body); + + $addressStr = 'data-ui-id="adminhtml-edit-tab-addresses-fieldset-element-text-address-'; + $this->assertContains($addressStr . '1-firstname" value="test firstname"', $body); + $this->assertContains($addressStr . '2-firstname" value="test firstname"', $body); + $this->assertContains($addressStr . '3-firstname" value="removed firstname"', $body); + $this->assertNotContains($addressStr . 'item1-firstname"', $body); + $this->assertContains($addressStr . 'template-firstname" value=""', $body); + } + + public function testNewAction() + { + $this->dispatch('backend/customer/index/edit'); + $body = $this->getResponse()->getBody(); + + // verify + $this->assertContains('<h1 class="title">New Customer</h1>', $body); + + $accountStr = 'data-ui-id="adminhtml-edit-tab-account-fieldset-element-text-account-'; + $this->assertContains($accountStr . 'firstname" value=""', $body); + + $addressStr = 'data-ui-id="adminhtml-edit-tab-addresses-fieldset-element-text-address-'; + $this->assertNotContains($addressStr . '1-firstname"', $body); + $this->assertNotContains($addressStr . '2-firstname"', $body); + $this->assertNotContains($addressStr . '3-firstname"', $body); + $this->assertNotContains($addressStr . 'item1-firstname"', $body); + $this->assertContains($addressStr . 'template-firstname" value=""', $body); + } + + /** + * Test the editing of a new customer that has not been saved but the page has been reloaded + */ + public function testNewActionWithCustomerData() + { + $customerData = [ + 'customer_id' => 0, + 'account' => [ + 'created_in' => false, + 'disable_auto_group_change' => false, + 'email' => false, + 'firstname' => false, + 'group_id' => false, + 'lastname' => false, + 'website_id' => false, + ], + 'address' => [] + ]; + $context = Bootstrap::getObjectManager()->get('Magento\Backend\Block\Template\Context'); + $context->getBackendSession()->setCustomerData($customerData); + $this->testNewAction(); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer_sample.php + */ + public function testDeleteAction() + { + $this->getRequest()->setParam('id', 1); + $this->dispatch('backend/customer/index/delete'); + $this->assertRedirect($this->stringContains('customer/index')); + $this->assertSessionMessages( + $this->equalTo(['You deleted the customer.']), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer_sample.php + */ + public function testNotExistingCustomerDeleteAction() + { + $this->getRequest()->setParam('id', 2); + $this->dispatch('backend/customer/index/delete'); + $this->assertRedirect($this->stringContains('customer/index')); + $this->assertSessionMessages( + $this->equalTo(['No such entity with customerId = 2']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer_sample.php + */ + public function testCartAction() + { + $this->getRequest()->setParam('id', 1) + ->setParam('website_id', 1) + ->setPost('delete', 1); + $this->dispatch('backend/customer/index/cart'); + $body = $this->getResponse()->getBody(); + $this->assertContains('<div id="customer_cart_grid1">', $body); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer_sample.php + */ + public function testProductReviewsAction() + { + $this->getRequest()->setParam('id', 1); + $this->dispatch('backend/customer/index/productReviews'); + $body = $this->getResponse()->getBody(); + $this->assertContains('<div id="reviwGrid">', $body); + } + + /** + * @magentoDataFixture Magento/Customer/_files/two_customers.php + */ + public function testMassSubscriberAction() + { + // Pre-condition + /** @var \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory */ + $subscriberFactory = Bootstrap::getObjectManager()->get('Magento\Newsletter\Model\SubscriberFactory'); + $this->assertNull($subscriberFactory->create()->loadByCustomer(1)->getSubscriberStatus()); + $this->assertNull($subscriberFactory->create()->loadByCustomer(2)->getSubscriberStatus()); + // Setup + $this->getRequest()->setParam('customer', [1, 2]); + + // Test + $this->dispatch('backend/customer/index/massSubscribe'); + + // Assertions + $this->assertRedirect($this->stringContains('customer/index')); + $this->assertSessionMessages( + $this->equalTo(['A total of 2 record(s) were updated.']), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + $this->assertEquals( + Subscriber::STATUS_SUBSCRIBED, + $subscriberFactory->create()->loadByCustomer(1)->getSubscriberStatus() + ); + $this->assertEquals( + Subscriber::STATUS_SUBSCRIBED, + $subscriberFactory->create()->loadByCustomer(2)->getSubscriberStatus() + ); + } + + public function testMassSubscriberActionNoSelection() + { + $this->dispatch('backend/customer/index/massSubscribe'); + + $this->assertRedirect($this->stringContains('customer/index')); + $this->assertSessionMessages( + $this->equalTo(['Please select customer(s).']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + } + + public function testMassSubscriberActionInvalidId() + { + $this->getRequest()->setParam('customer', [4200]); + + $this->dispatch('backend/customer/index/massSubscribe'); + + $this->assertRedirect($this->stringContains('customer/index')); + $this->assertSessionMessages( + $this->equalTo(['No such entity with customerId = 4200']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/two_customers.php + */ + public function testMassSubscriberActionPartialUpdate() + { + // Pre-condition + /** @var \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory */ + $subscriberFactory = Bootstrap::getObjectManager()->get('Magento\Newsletter\Model\SubscriberFactory'); + $this->assertNull($subscriberFactory->create()->loadByCustomer(1)->getSubscriberStatus()); + $this->assertNull($subscriberFactory->create()->loadByCustomer(2)->getSubscriberStatus()); + // Setup + $this->getRequest()->setParam('customer', [1, 4200, 2]); + + // Test + $this->dispatch('backend/customer/index/massSubscribe'); + + // Assertions + $this->assertRedirect($this->stringContains('customer/index')); + $this->assertSessionMessages( + $this->equalTo(['A total of 2 record(s) were updated.']), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + $this->assertSessionMessages( + $this->equalTo(['No such entity with customerId = 4200']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + $this->assertEquals( + Subscriber::STATUS_SUBSCRIBED, + $subscriberFactory->create()->loadByCustomer(1)->getSubscriberStatus() + ); + $this->assertEquals( + Subscriber::STATUS_SUBSCRIBED, + $subscriberFactory->create()->loadByCustomer(2)->getSubscriberStatus() + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testMassDeleteAction() + { + $this->getRequest()->setPost('customer', [1]); + $this->dispatch('backend/customer/index/massDelete'); + $this->assertSessionMessages( + $this->equalTo(['A total of 1 record(s) were deleted.']), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + $this->assertRedirect($this->stringContains('customer/index')); + } + + public function testInvalidIdMassDeleteAction() + { + $this->getRequest()->setPost('customer', [1]); + $this->dispatch('backend/customer/index/massDelete'); + $this->assertSessionMessages( + $this->equalTo(['No such entity with customerId = 1']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + } + + /** + * Valid group Id but no customer Ids specified + */ + public function testMassDeleteActionNoCustomerIds() + { + $this->dispatch('backend/customer/index/massDelete'); + $this->assertSessionMessages( + $this->equalTo(['Please select customer(s).']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/two_customers.php + */ + public function testMassDeleteActionPartialUpdate() + { + $this->getRequest()->setPost('customer', [1, 999, 2, 9999]); + $this->dispatch('backend/customer/index/massDelete'); + $this->assertSessionMessages( + $this->equalTo(['A total of 2 record(s) were deleted.']), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + $this->assertSessionMessages( + $this->equalTo(['No such entity with customerId = 999', 'No such entity with customerId = 9999']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testMassAssignGroupAction() + { + $customer = $this->customerService->getCustomer(1); + $this->assertEquals(1, $customer->getGroupId()); + + $this->getRequest()->setParam('group', 0)->setPost('customer', [1]); + $this->dispatch('backend/customer/index/massAssignGroup'); + $this->assertSessionMessages( + $this->equalTo(['A total of 1 record(s) were updated.']), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + $this->assertRedirect($this->stringContains('customer/index')); + + $customer = $this->customerService->getCustomer(1); + $this->assertEquals(0, $customer->getGroupId()); + } + + /** + * Valid group Id but no data fixture so no customer exists with customer Id = 1 + */ + public function testMassAssignGroupActionInvalidCustomerId() + { + $this->getRequest()->setParam('group', 0)->setPost('customer', [1]); + $this->dispatch('backend/customer/index/massAssignGroup'); + $this->assertSessionMessages( + $this->equalTo(['No such entity with customerId = 1']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + } + + /** + * Valid group Id but no customer Ids specified + */ + public function testMassAssignGroupActionNoCustomerIds() + { + $this->getRequest()->setParam('group', 0); + $this->dispatch('backend/customer/index/massAssignGroup'); + $this->assertSessionMessages( + $this->equalTo(['Please select customer(s).']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/two_customers.php + */ + public function testMassAssignGroupActionPartialUpdate() + { + $this->assertEquals(1, $this->customerService->getCustomer(1)->getGroupId()); + $this->assertEquals(1, $this->customerService->getCustomer(2)->getGroupId()); + + $this->getRequest()->setParam('group', 0)->setPost('customer', [1, 4200, 2]); + $this->dispatch('backend/customer/index/massAssignGroup'); + $this->assertSessionMessages( + $this->equalTo(['A total of 2 record(s) were updated.']), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + $this->assertSessionMessages( + $this->equalTo(['No such entity with customerId = 4200']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + + $this->assertEquals(0, $this->customerService->getCustomer(1)->getGroupId()); + $this->assertEquals(0, $this->customerService->getCustomer(2)->getGroupId()); + } + + + /** + * @magentoDataFixture Magento/Customer/_files/two_customers.php + */ + public function testMassUnsubscriberAction() + { + // Setup + /** @var \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory */ + $subscriberFactory = Bootstrap::getObjectManager()->get('Magento\Newsletter\Model\SubscriberFactory'); + $subscriberFactory->create()->updateSubscription(1, true); + $subscriberFactory->create()->updateSubscription(2, true); + $this->getRequest()->setParam('customer', [1, 2]); + + // Test + $this->dispatch('backend/customer/index/massUnsubscribe'); + + // Assertions + $this->assertRedirect($this->stringContains('customer/index')); + $this->assertSessionMessages( + $this->equalTo(['A total of 2 record(s) were updated.']), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + $this->assertEquals( + Subscriber::STATUS_UNSUBSCRIBED, + $subscriberFactory->create()->loadByCustomer(1)->getSubscriberStatus() + ); + $this->assertEquals( + Subscriber::STATUS_UNSUBSCRIBED, + $subscriberFactory->create()->loadByCustomer(2)->getSubscriberStatus() + ); + } + + public function testMassUnsubscriberActionNoSelection() + { + $this->dispatch('backend/customer/index/massUnsubscribe'); + + $this->assertRedirect($this->stringContains('customer/index')); + $this->assertSessionMessages( + $this->equalTo(['Please select customer(s).']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + } + + public function testMassUnsubscriberActionInvalidId() + { + $this->getRequest()->setParam('customer', [4200]); + + $this->dispatch('backend/customer/index/massUnsubscribe'); + + $this->assertRedirect($this->stringContains('customer/index')); + $this->assertSessionMessages( + $this->equalTo(['No such entity with customerId = 4200']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/two_customers.php + */ + public function testMassUnsubscriberActionPartialUpdate() + { + // Setup + /** @var \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory */ + $subscriberFactory = Bootstrap::getObjectManager()->get('Magento\Newsletter\Model\SubscriberFactory'); + $subscriberFactory->create()->updateSubscription(1, true); + $subscriberFactory->create()->updateSubscription(2, true); + $this->getRequest()->setParam('customer', [1, 4200, 2]); + + // Test + $this->dispatch('backend/customer/index/massUnsubscribe'); + + // Assertions + $this->assertRedirect($this->stringContains('customer/index')); + $this->assertSessionMessages( + $this->equalTo(['A total of 2 record(s) were updated.']), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + $this->assertSessionMessages( + $this->equalTo(['No such entity with customerId = 4200']), + \Magento\Message\MessageInterface::TYPE_ERROR + ); + $this->assertEquals( + Subscriber::STATUS_UNSUBSCRIBED, + $subscriberFactory->create()->loadByCustomer(1)->getSubscriberStatus() + ); + $this->assertEquals( + Subscriber::STATUS_UNSUBSCRIBED, + $subscriberFactory->create()->loadByCustomer(2)->getSubscriberStatus() + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/customer_address.php + */ + public function testValidateCustomerWithAddressSuccess() + { + $customerData = [ + 'id' => '1', + 'account' => [ + 'middlename' => 'new middlename', + 'group_id' => 1, + 'website_id' => 1, + 'firstname' => 'new firstname', + 'lastname' => 'new lastname', + 'email' => 'exmaple@domain.com', + 'default_shipping' => '_item1', + 'new_password' => 'auto', + 'sendemail_store_id' => '1', + 'sendemail' => '1', + + ], + 'address' => [ + '_item1' => [ + 'firstname' => 'update firstname', + 'lastname' => 'update lastname', + 'street' => ['update street'], + 'city' => 'update city', + 'country_id' => 'US', + 'postcode' => '01001', + 'telephone' => '+7000000001', + ], + '_template_' => [ + 'firstname' => '', + 'lastname' => '', + 'street' => [], + 'city' => '', + 'country_id' => 'US', + 'postcode' => '', + 'telephone' => '', + ] + ] + ]; + /** + * set customer data + */ + $this->getRequest()->setParams($customerData); + $this->dispatch('backend/customer/index/validate'); + $body = $this->getResponse()->getBody(); + + /** + * Check that no errors were generated and set to session + */ + $this->assertSessionMessages($this->isEmpty(), \Magento\Message\MessageInterface::TYPE_ERROR); + + $this->assertEquals('{"error":0}', $body); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/customer_address.php + */ + public function testValidateCustomerWithAddressFailure() + { + $customerData = [ + 'id' => '1', + 'account' => [ + 'middlename' => 'new middlename', + 'group_id' => 1, + 'website_id' => 1, + 'firstname' => 'new firstname', + 'lastname' => 'new lastname', + 'email' => '*', + 'default_shipping' => '_item1', + 'new_password' => 'auto', + 'sendemail_store_id' => '1', + 'sendemail' => '1', + + ], + 'address' => [ + '1' => [ + 'firstname' => '', + 'lastname' => '', + 'street' => ['update street'], + 'city' => 'update city', + 'postcode' => '01001', + 'telephone' => '', + ], + '_template_' => [ + 'lastname' => '', + 'street' => [], + 'city' => '', + 'country_id' => 'US', + 'postcode' => '', + 'telephone' => '', + ] + ] + ]; + /** + * set customer data + */ + $this->getRequest()->setParams($customerData); + $this->dispatch('backend/customer/index/validate'); + $body = $this->getResponse()->getBody(); + + $this->assertContains('{"error":1,"message":', $body); + $this->assertContains('Please correct this email address: \"*\".', $body); + $this->assertContains('\"First Name\" is a required value.', $body); + $this->assertContains('\"First Name\" length must be equal or greater than 1 characters', $body); + $this->assertContains('\"Last Name\" is a required value.', $body); + $this->assertContains('\"Last Name\" length must be equal or greater than 1 characters', $body); + $this->assertContains('\"Telephone\" is a required value.', $body); + $this->assertContains('\"Telephone\" length must be equal or greater than 1 characters', $body); + $this->assertContains('\"Country\" is a required value.', $body); + } + + public function testResetPasswordActionNoCustomerId() + { + // No customer ID in post, will just get redirected to base + $this->dispatch('backend/customer/index/resetPassword'); + $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl)); + } + + public function testResetPasswordActionBadCustomerId() + { + // Bad customer ID in post, will just get redirected to base + $this->getRequest()->setPost(['customer_id' => '789']); + $this->dispatch('backend/customer/index/resetPassword'); + $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl)); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testResetPasswordActionSuccess() + { + $this->getRequest()->setPost(['customer_id' => '1']); + $this->dispatch('backend/customer/index/resetPassword'); + $this->assertSessionMessages( + $this->equalTo(array('Customer will receive an email with a link to reset password.')), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'edit')); + } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Config/ShareTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/ShareTest.php new file mode 100644 index 00000000000..de0f9731e2c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/ShareTest.php @@ -0,0 +1,65 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model\Config; + +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test \Magento\Customer\Model\Config\Share + */ +class ShareTest extends \PHPUnit_Framework_TestCase +{ + public function testGetSharedWebsiteIds() + { + /** @var Share $share */ + $share = Bootstrap::getObjectManager() + ->get('Magento\Customer\Model\Config\Share'); + + $websiteIds = $share->getSharedWebsiteIds(42); + + $this->assertEquals([42], $websiteIds); + } + + /** + * @magentoDataFixture Magento/Core/_files/second_third_store.php + * @magentoConfigFixture current_store customer/account_share/scope 0 + */ + public function testGetSharedWebsiteIdsMultipleSites() + { + /** @var Share $share */ + $share = Bootstrap::getObjectManager() + ->get('Magento\Customer\Model\Config\Share'); + $expectedIds = [1]; + /** @var \Magento\Core\Model\Website $website */ + $website = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Core\Model\Website'); + $expectedIds[] = $website->load('secondwebsite')->getId(); + $expectedIds[] = $website->load('thirdwebsite')->getId(); + + $websiteIds = $share->getSharedWebsiteIds(42); + + $this->assertEquals($expectedIds, $websiteIds); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormFactoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormFactoryTest.php index 826a999f1f6..45d967aedba 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormFactoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormFactoryTest.php @@ -58,7 +58,6 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase ]; $this->_expectedData = $this->_requestData; - $this->_expectedData['street'] = trim(implode("\n", $this->_expectedData['street'])); unset($this->_expectedData['id']); unset($this->_expectedData['default_shipping']); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormTest.php index 756b069b8d2..a7254e1941c 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormTest.php @@ -73,7 +73,27 @@ class FormTest extends \PHPUnit_Framework_TestCase 'region' => 'California' ]; - $this->_expected = $this->_attributes; + $requestData = [ + 'company' => 'Company Name', + 'fax' => '(555) 555-5555', + 'middlename' => 'Mid', + 'prefix' => 'Mr.', + 'suffix' => 'Esq.', + 'vat_id' => '', + 'firstname' => 'New Name', + 'lastname' => 'Doe', + 'street' => ['2211 New Street'], + 'city' => 'San Jose', + 'country_id' => 'US', + 'postcode' => '95131', + 'telephone' => '5125125125', + 'region_id' => 12, + 'region' => 'California' + ]; + $this->_request = $objectManager->get('Magento\App\RequestInterface'); + $this->_request->setParams($requestData); + + $this->_expected = array_merge($this->_attributes, $requestData); unset($this->_expected['id']); unset($this->_expected['default_shipping']); @@ -82,8 +102,7 @@ class FormTest extends \PHPUnit_Framework_TestCase unset($this->_expected['prefix']); unset($this->_expected['suffix']); - $this->_request = $objectManager->get('Magento\App\RequestInterface'); - $this->_request->setParams($this->_attributes); + } public function testCompactData() @@ -117,7 +136,6 @@ class FormTest extends \PHPUnit_Framework_TestCase public function testRestoreData() { - $this->_expected['street'] = trim(implode("\n", $this->_expected['street'])); $attributeValues = $this->_form->restoreData($this->_form->extractData($this->_request)); $this->assertEquals($this->_expected, $attributeValues); } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/SessionTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/SessionTest.php index 1a1b85e7ca5..a1167a31c40 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/SessionTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/SessionTest.php @@ -43,16 +43,6 @@ class SessionTest extends \PHPUnit_Framework_TestCase ->create('Magento\Customer\Model\Session'); } - public function testLogin() - { - $this->markTestSkipped('MAGETWO-18328'); - $oldSessionId = $this->_customerSession->getSessionId(); - $this->assertTrue($this->_customerSession->login('customer@example.com', 'password')); // fixture - $this->assertTrue($this->_customerSession->isLoggedIn()); - $newSessionId = $this->_customerSession->getSessionId(); - $this->assertNotEquals($oldSessionId, $newSessionId); - } - public function testLoginById() { $this->markTestSkipped('MAGETWO-18328'); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php index e17322b21d1..39f5507c43d 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php @@ -32,6 +32,7 @@ use Magento\Exception\StateException; * * @SuppressWarnings(PHPMD.TooManyMethods) * @SuppressWarnings(PHPMD.ExcessivePublicCount) + * @magentoAppArea frontend */ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase { @@ -127,8 +128,6 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase } /** - * @magentoDataFixture Magento/Customer/_files/customer.php - * * @expectedException \Magento\Exception\AuthenticationException * @expectedExceptionMessage Invalid login or password */ @@ -138,6 +137,38 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase $this->_service->authenticate('non_existing_user', 'password', true); } + + /** + * @magentoAppArea frontend + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testValidatePassword() + { + // Customer e-mail and password are pulled from the fixture customer.php + $this->_service->validatePassword(1, 'password'); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * + * @expectedException \Magento\Exception\AuthenticationException + * @expectedExceptionMessage Password doesn't match for this account + */ + public function testValidatePasswordWrongPassword() + { + // Customer e-mail and password are pulled from the fixture customer.php + $this->_service->validatePassword(1, 'wrongPassword'); + } + + /** + * @expectedException \Magento\Exception\NoSuchEntityException + */ + public function testValidatePasswordWrongUser() + { + // Customer e-mail and password are pulled from the fixture customer.php + $this->_service->validatePassword(4200, 'password'); + } + /** * @magentoDataFixture Magento/Customer/_files/inactive_customer.php * @magentoAppArea frontend @@ -150,20 +181,38 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase // Assert in just one test that the fixture is working $this->assertNotNull($customerModel->getConfirmation(), 'New customer needs to be confirmed'); - $this->_service->activateAccount($customerModel->getId(), $customerModel->getConfirmation()); + $this->_service->activateAccount($customerModel->getId()); $customerModel = $this->_objectManager->create('Magento\Customer\Model\Customer'); $customerModel->load(1); $this->assertNull($customerModel->getConfirmation(), 'Customer should be considered confirmed now'); } + /** + * @magentoDataFixture Magento/Customer/_files/inactive_customer.php + * @magentoAppArea frontend + */ + public function testValidateAccountConfirmationKey() + { + /** @var \Magento\Customer\Model\Customer $customerModel */ + $customerModel = $this->_objectManager->create('Magento\Customer\Model\Customer'); + $customerModel->load(1); + // Assert in just one test that the fixture is working + $this->assertNotNull($customerModel->getConfirmation(), 'New customer needs to be confirmed'); + + $valid = $this->_service->validateAccountConfirmationKey($customerModel->getId(), + $customerModel->getConfirmation()); + + $this->assertTrue($valid); + } + /** * @magentoDataFixture Magento/Customer/_files/inactive_customer.php * * @expectedException \Magento\Exception\StateException * @expectedExceptionCode \Magento\Exception\StateException::INPUT_MISMATCH */ - public function testActivateAccountWrongKey() + public function testValidateAccountConfirmationKeyWrongKey() { /** @var \Magento\Customer\Model\Customer $customerModel */ $customerModel = $this->_objectManager->create('Magento\Customer\Model\Customer'); @@ -171,7 +220,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase $key = $customerModel->getConfirmation(); try { - $this->_service->activateAccount($customerModel->getId(), $key . $key); + $this->_service->validateAccountConfirmationKey($customerModel->getId(), $key . $key); $this->fail('Expected exception was not thrown'); } catch (InputException $ie) { $expectedParams = [ @@ -193,9 +242,8 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Customer\Model\Customer $customerModel */ $customerModel = $this->_objectManager->create('Magento\Customer\Model\Customer'); $customerModel->load(1); - $key = $customerModel->getConfirmation(); try { - $this->_service->activateAccount('1234' . $customerModel->getId(), $key); + $this->_service->activateAccount('1234' . $customerModel->getId()); $this->fail('Expected exception not thrown.'); } catch (NoSuchEntityException $nsee) { $expectedParams = [ @@ -217,10 +265,9 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Customer\Model\Customer $customerModel */ $customerModel = $this->_objectManager->create('Magento\Customer\Model\Customer'); $customerModel->load(1); - $key = $customerModel->getConfirmation(); - $this->_service->activateAccount($customerModel->getId(), $key); + $this->_service->activateAccount($customerModel->getId()); - $this->_service->activateAccount($customerModel->getId(), $key); + $this->_service->activateAccount($customerModel->getId()); } @@ -336,7 +383,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase { $email = 'customer@example.com'; - $this->_service->sendPasswordResetLink($email, 1); + $this->_service->sendPasswordResetLink($email, 1, CustomerAccountServiceInterface::EMAIL_RESET); } /** @@ -348,7 +395,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase $email = 'foo@example.com'; try { - $this->_service->sendPasswordResetLink($email, 0); + $this->_service->sendPasswordResetLink($email, 0, CustomerAccountServiceInterface::EMAIL_RESET); $this->fail('Expected exception not thrown.'); } catch (NoSuchEntityException $nsee) { $expectedParams = [ @@ -362,69 +409,18 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase /** * @magentoDataFixture Magento/Customer/_files/customer.php */ - public function testResetPassword() - { - $resetToken = 'lsdj579slkj5987slkj595lkj'; - $password = 'password_secret'; - - $this->_customerBuilder->populateWithArray(array_merge($this->_customerService->getCustomer(1)->__toArray(), [ - 'rp_token' => $resetToken, - 'rp_token_created_at' => date('Y-m-d') - ])); - $this->_customerService->saveCustomer($this->_customerBuilder->create()); - - $this->_service->resetPassword(1, $password, $resetToken); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - * - * @expectedException \Magento\Exception\StateException - * @expectedExceptionCode \Magento\Exception\StateException::EXPIRED - */ - public function testResetPasswordTokenExpired() + public function testChangePassword() { $resetToken = 'lsdj579slkj5987slkj595lkj'; $password = 'password_secret'; - $this->_customerBuilder->populateWithArray(array_merge($this->_customerService->getCustomer(1)->__toArray(), [ - 'rp_token' => $resetToken, - 'rp_token_created_at' => '1970-01-01', - ])); - $this->_customerService->saveCustomer($this->_customerBuilder->create()); - - $this->_service->resetPassword(1, $password, $resetToken); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - * - */ - public function testResetPasswordTokenInvalid() - { - $resetToken = 'lsdj579slkj5987slkj595lkj'; - $invalidToken = 0; - $password = 'password_secret'; - $this->_customerBuilder->populateWithArray(array_merge($this->_customerService->getCustomer(1)->__toArray(), [ 'rp_token' => $resetToken, 'rp_token_created_at' => date('Y-m-d') ])); $this->_customerService->saveCustomer($this->_customerBuilder->create()); - try { - $this->_service->resetPassword(1, $password, $invalidToken); - $this->fail('Expected exception not thrown.'); - } catch (InputException $ie) { - $expectedParams = [ - [ - 'value' => $invalidToken, - 'fieldName' => 'resetPasswordLinkToken', - 'code' => InputException::INVALID_FIELD_VALUE, - ] - ]; - $this->assertEquals($expectedParams, $ie->getParams()); - } + $this->_service->changePassword(1, $password); } /** @@ -441,7 +437,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase ])); $this->_customerService->saveCustomer($this->_customerBuilder->create()); try { - $this->_service->resetPassword(4200, $password, $resetToken); + $this->_service->changePassword(4200, $password); $this->fail('Expected exception not thrown.'); } catch (NoSuchEntityException $nsee) { $expectedParams = [ @@ -451,35 +447,6 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase } } - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testResetPasswordTokenInvalidUserId() - { - $resetToken = 'lsdj579slkj5987slkj595lkj'; - $password = 'password_secret'; - - $this->_customerBuilder->populateWithArray(array_merge($this->_customerService->getCustomer(1)->__toArray(), [ - 'rp_token' => $resetToken, - 'rp_token_created_at' => date('Y-m-d') - ])); - $this->_customerService->saveCustomer($this->_customerBuilder->create()); - try { - $this->_service->resetPassword(0, $password, $resetToken); - $this->fail('Expected exception not thrown.'); - } catch (InputException $ie) { - $expectedParams = [ - [ - 'value' => 0, - 'fieldName' => 'customerId', - 'code' => InputException::INVALID_FIELD_VALUE, - ] - ]; - $this->assertEquals($expectedParams, $ie->getParams()); - } - - } - /** * @magentoAppArea frontend * @magentoAppIsolation enabled diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerMetadataServiceTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerMetadataServiceTest.php index 919ce30f98c..9a43f26320c 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerMetadataServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerMetadataServiceTest.php @@ -59,15 +59,6 @@ class CustomerMetadataServiceTest extends \PHPUnit_Framework_TestCase } } - public function testAttributeMetadataCached() - { - $firstCallMetadata = $this->_service->getAddressAttributeMetadata('firstname'); - $secondCallMetadata = $this->_service->getAddressAttributeMetadata('firstname'); - - $this->assertSame($firstCallMetadata, $secondCallMetadata); - - } - /** * @magentoDataFixture Magento/Customer/_files/customer.php */ diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_fullname.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_fullname.php new file mode 100644 index 00000000000..3f60bf3a685 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_fullname.php @@ -0,0 +1,40 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Catalog + * @subpackage integration_tests + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Attribute'); +$model->loadByCode('customer', 'prefix') + ->setIsVisible('1'); +$model->save(); + +$model->loadByCode('customer', 'middlename') + ->setIsVisible('1'); +$model->save(); + +$model->loadByCode('customer', 'suffix') + ->setIsVisible('1'); +$model->save(); diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Shipmenttype.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_primary_addresses.php similarity index 74% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Shipmenttype.php rename to dev/tests/integration/testsuite/Magento/Customer/_files/customer_primary_addresses.php index 7857231d173..23103a5f219 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Shipmenttype.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_primary_addresses.php @@ -18,21 +18,17 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +require 'customer_two_addresses.php'; -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\Source; +/** @var \Magento\Customer\Model\Customer $customer */ +$customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Customer') + ->load(1); +$customer->setDefaultBilling(1) + ->setDefaultShipping(2); +$customer->save(); -class Shipmenttype extends \Magento\Usa\Model\Shipping\Carrier\Dhl\Source\Generic -{ - /** - * Carrier code - * - * @var string - */ - protected $_code = 'shipment_type'; -} diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php b/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php new file mode 100644 index 00000000000..3deca72f86e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/quote.php @@ -0,0 +1,67 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App') + ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product'); +$product->setTypeId('virtual') + ->setId(1) + ->setAttributeSetId(4) + ->setName('Simple Product') + ->setSku('simple') + ->setPrice(10) + ->setStoreId(1) + ->setStockData( + array( + 'use_config_manage_stock' => 1, + 'qty' => 100, + 'is_qty_decimal' => 0, + 'is_in_stock' => 100, + ) + ) + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->save(); +$product->load(1); + +/** @var $quote \Magento\Sales\Model\Quote */ +$quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Quote'); +$quoteItem = $quote->setCustomerId(1) + ->setStoreId( + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\StoreManagerInterface') + ->getStore()->getId() + ) + ->setReservedOrderId('test01') + ->addProduct($product, 10); +/** @var $quoteItem \Magento\Sales\Model\Quote\Item */ +$quoteItem->setQty(1); +$quote->getPayment()->setMethod('checkmo'); +$quote->getBillingAddress(); +$quote->getShippingAddress()->setCollectShippingRates(true); +$quote->collectTotals(); +$quote->save(); +$quoteItem->setQuote($quote); +$quoteItem->save(); \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/sales_order.php b/dev/tests/integration/testsuite/Magento/Customer/_files/sales_order.php new file mode 100644 index 00000000000..5a4f6252daa --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/sales_order.php @@ -0,0 +1,38 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** @var \Magento\Customer\Model\Customer $customer */ +$customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Customer') + ->load(1); + +/** @var \Magento\Sales\Model\Order $order */ +$order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Sales\Model\Order') + ->loadByIncrementId('100000001'); +$order->setCustomerIsGuest(false) + ->setCustomerId($customer->getId()) + ->setCustomerEmail($customer->getEmail()); +$order->save(); + diff --git a/dev/tests/integration/testsuite/Magento/Usa/Block/Adminhtml/Dhl/UnitofmeasureTest.php b/dev/tests/integration/testsuite/Magento/Dhl/Block/Adminhtml/UnitofmeasureTest.php similarity index 86% rename from dev/tests/integration/testsuite/Magento/Usa/Block/Adminhtml/Dhl/UnitofmeasureTest.php rename to dev/tests/integration/testsuite/Magento/Dhl/Block/Adminhtml/UnitofmeasureTest.php index 061234bcc03..e57f41e5002 100644 --- a/dev/tests/integration/testsuite/Magento/Usa/Block/Adminhtml/Dhl/UnitofmeasureTest.php +++ b/dev/tests/integration/testsuite/Magento/Dhl/Block/Adminhtml/UnitofmeasureTest.php @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Block\Adminhtml\Dhl; +namespace Magento\Dhl\Block\Adminhtml; /** * @magentoAppArea adminhtml @@ -36,8 +36,8 @@ class UnitofmeasureTest extends \PHPUnit_Framework_TestCase { /** @var $layout \Magento\Core\Model\Layout */ $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\LayoutInterface'); - /** @var $block \Magento\Usa\Block\Adminhtml\Dhl\Unitofmeasure */ - $block = $layout->createBlock('Magento\Usa\Block\Adminhtml\Dhl\Unitofmeasure'); + /** @var $block \Magento\Dhl\Block\Adminhtml\Unitofmeasure */ + $block = $layout->createBlock('Magento\Dhl\Block\Adminhtml\Unitofmeasure'); $this->assertNotEmpty($block->toHtml()); } } diff --git a/dev/tests/integration/testsuite/Magento/Gdata/Gshopping/ContentTest.php b/dev/tests/integration/testsuite/Magento/Gdata/Gshopping/ContentTest.php index 30c022f0a32..80daed5f57c 100644 --- a/dev/tests/integration/testsuite/Magento/Gdata/Gshopping/ContentTest.php +++ b/dev/tests/integration/testsuite/Magento/Gdata/Gshopping/ContentTest.php @@ -30,9 +30,9 @@ class ContentTest extends \PHPUnit_Framework_TestCase { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Gdata\Gshopping\Content $context */ - $context = $objectManager->create('\Magento\Gdata\Gshopping\Content'); + $context = $objectManager->create('Magento\Gdata\Gshopping\Content'); $entry = $context->newEntry(); - $this->assertInstanceOf('\Magento\Gdata\Gshopping\Entry', $entry); + $this->assertInstanceOf('Magento\Gdata\Gshopping\Entry', $entry); $this->assertEquals($context, $entry->getService()); } } diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Block/Adminhtml/Export/FilterTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Block/Adminhtml/Export/FilterTest.php index 0109389e8e5..7b48dcf7c4a 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Block/Adminhtml/Export/FilterTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Block/Adminhtml/Export/FilterTest.php @@ -62,8 +62,8 @@ class FilterTest $this->assertNotEmpty($html); $dateFormat = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Core\Model\LocaleInterface') - ->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + ->get('Magento\Stdlib\DateTime\TimezoneInterface') + ->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); $pieces = array_filter(explode('<strong>', $html)); foreach ($pieces as $piece) { $this->assertContains('dateFormat: "' . $dateFormat . '",', $piece); diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php index 58ce685b183..fd664535b05 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php @@ -72,7 +72,7 @@ class AbstractEavTest extends \PHPUnit_Framework_TestCase $objectManager->get('Magento\Core\Model\StoreManager'), $objectManager->get('Magento\ImportExport\Model\Export\Factory'), $objectManager->get('Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory'), - $objectManager->get('Magento\Core\Model\LocaleInterface'), + $objectManager->get('Magento\Stdlib\DateTime\TimezoneInterface'), $objectManager->get('Magento\Eav\Model\Config') ); } diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php index 9e12004760f..24781c3930a 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php @@ -235,7 +235,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase ->getNextAutoincrement($tableName); /** @var \Magento\Stdlib\DateTime $dateTime */ - $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('\Magento\Stdlib\DateTime'); + $dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Stdlib\DateTime'); $entityData = array( 'entity_id' => $addressId, diff --git a/dev/tests/integration/testsuite/Magento/Interception/Fixture/Intercepted.php b/dev/tests/integration/testsuite/Magento/Interception/Fixture/Intercepted.php new file mode 100644 index 00000000000..38286803abd --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Interception/Fixture/Intercepted.php @@ -0,0 +1,73 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Interception\Fixture; + + +class Intercepted extends InterceptedParent implements InterceptedInterface +{ + protected $_key; + + public function A($param1) + { + $this->_key = $param1; + return $this; + } + + public function B($param1, $param2) + { + return '<B>' . $param1 . $param2 . $this->C($param1) . '</B>'; + } + + public function C($param1) + { + return '<C>' . $param1 . '</C>'; + } + + public function D($param1) + { + return '<D>' . $this->_key . $param1 . '</D>'; + } + + public final function E($param1) + { + return '<E>' . $this->_key . $param1 . '</E>'; + } + + public function F($param1) + { + return '<F>' . $param1 . '</F>'; + } + + public function G($param1) + { + return '<G>' . $param1 . "</G>"; + } + + public function K($param1) + { + return '<K>' . $param1 . '</K>'; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Interception/Fixture/Intercepted/InterfacePlugin.php b/dev/tests/integration/testsuite/Magento/Interception/Fixture/Intercepted/InterfacePlugin.php new file mode 100644 index 00000000000..28478fe10f7 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Interception/Fixture/Intercepted/InterfacePlugin.php @@ -0,0 +1,67 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Interception\Fixture\Intercepted; + +use Magento\Interception\Fixture\InterceptedInterface; + +class InterfacePlugin +{ + /** + * @param InterceptedInterface $subject + * @param \Closure $next + * @param string $param1 + * @return string + */ + public function aroundC(InterceptedInterface $subject, \Closure $next, $param1) + { + return '<IP:C>' . $next($param1) . '</IP:C>'; + } + + /** + * @param InterceptedInterface $subject + * @param \Closure $next + * @param $param1 + * @return string + */ + public function aroundF(InterceptedInterface $subject, \Closure $next, $param1) + { + return '<IP:F>' . $subject->D($next($subject->C($param1))) . '</IP:F>'; + } + + public function beforeG(InterceptedInterface $subject, $param1) + { + return array('<IP:bG>' . $param1 . '</IP:bG>'); + } + + public function aroundG(InterceptedInterface $subject, \Closure $next, $param1) + { + return $next('<IP:G>' . $param1 . '</IP:G>'); + } + + public function afterG(InterceptedInterface $subject, $result) + { + return '<IP:aG>' . $result . '</IP:aG>'; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Interception/Fixture/Intercepted/Plugin.php b/dev/tests/integration/testsuite/Magento/Interception/Fixture/Intercepted/Plugin.php new file mode 100644 index 00000000000..9b7f41bb4a1 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Interception/Fixture/Intercepted/Plugin.php @@ -0,0 +1,67 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Interception\Fixture\Intercepted; + +use Magento\Interception\Fixture\Intercepted as Intercepted; + +class Plugin +{ + /** + * @var int + */ + protected $_counter = 0; + + public function aroundC(Intercepted $subject, \Closure $next, $param1) + { + return '<P:C>' . $next($param1) . '</P:C>'; + } + + public function aroundD(Intercepted $subject, \Closure $next, $param1) + { + $this->_counter++; + return '<P:D>' . $this->_counter . ': ' . $next($param1) . '</P:D>'; + } + + public function aroundK(Intercepted $subject, \Closure $next, $param1) + { + $result = $subject->C($param1); + return '<P:K>' . $subject->F($result) . '</P:K>'; + } + + public function beforeG(Intercepted $subject, $param1) + { + return array('<P:bG>' . $param1 . '</P:bG>'); + } + + public function aroundG(Intercepted $subject, \Closure $next, $param1) + { + return $next('<P:G>' . $param1 . '</P:G>'); + } + + public function afterG(Intercepted $subject, $result) + { + return '<P:aG>' . $result . '</P:aG>'; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Interception/Fixture/InterceptedInterface.php b/dev/tests/integration/testsuite/Magento/Interception/Fixture/InterceptedInterface.php new file mode 100644 index 00000000000..1b0b23dd620 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Interception/Fixture/InterceptedInterface.php @@ -0,0 +1,34 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Interception\Fixture; + + +interface InterceptedInterface +{ + public function C($param1); + + public function F($param1); +} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Interception/Fixture/InterceptedParent.php b/dev/tests/integration/testsuite/Magento/Interception/Fixture/InterceptedParent.php new file mode 100644 index 00000000000..b9710eec80b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Interception/Fixture/InterceptedParent.php @@ -0,0 +1,40 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Interception\Fixture; + + +class InterceptedParent implements InterceptedParentInterface +{ + public function A($param1) + { + return 'A' . $param1 . 'A'; + } + + public function B($param1, $param2) + { + return $param1 . $param2 . $this->A($param1); + } +} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Interception/Fixture/InterceptedParentInterface.php b/dev/tests/integration/testsuite/Magento/Interception/Fixture/InterceptedParentInterface.php new file mode 100644 index 00000000000..614b53c0714 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Interception/Fixture/InterceptedParentInterface.php @@ -0,0 +1,32 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Interception\Fixture; + + +interface InterceptedParentInterface +{ + public function A($param1); +} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Interception/GeneralTest.php b/dev/tests/integration/testsuite/Magento/Interception/GeneralTest.php new file mode 100644 index 00000000000..bf831dc066b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Interception/GeneralTest.php @@ -0,0 +1,168 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Interception; + +/** + * Class GeneralTest + * @package Magento\Interception + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class GeneralTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_configReader; + + /** + * @var \Magento\ObjectManager + */ + protected $_objectManager; + + public function setUp() + { + $classReader = new \Magento\Code\Reader\ClassReader(); + $relations = new \Magento\ObjectManager\Relations\Runtime($classReader); + $definitions = new \Magento\ObjectManager\Definition\Runtime($classReader); + $config = new \Magento\Interception\ObjectManager\Config($relations, $definitions); + $argInterpreter = new \Magento\Data\Argument\Interpreter\Composite(array(), 'type'); + $argObjectFactory = new \Magento\ObjectManager\Config\Argument\ObjectFactory($config); + $factory = new \Magento\ObjectManager\Factory\Factory( + $config, $argInterpreter, $argObjectFactory, $definitions + ); + + $this->_configReader = $this->getMock('Magento\Config\ReaderInterface'); + $this->_configReader->expects($this->any())->method('read')->will($this->returnValue(array( + 'Magento\Interception\Fixture\InterceptedInterface' => array('plugins' => array( + 'first' => array( + 'instance' => 'Magento\Interception\Fixture\Intercepted\InterfacePlugin', + 'sortOrder' => 10 + ) + )), + 'Magento\Interception\Fixture\Intercepted' => array('plugins' => array( + 'second' => array( + 'instance' => 'Magento\Interception\Fixture\Intercepted\Plugin', + 'sortOrder' => 20 + ) + )) + ))); + + $areaList = $this->getMock('Magento\App\AreaList', array(), array(), '', false); + $areaList->expects($this->any())->method('getCodes')->will($this->returnValue(array())); + $configScope = new \Magento\Config\Scope($areaList, 'global'); + $cache = $this->getMock('Magento\Config\CacheInterface'); + $cache->expects($this->any())->method('load')->will($this->returnValue(false)); + $definitions = new \Magento\ObjectManager\Definition\Runtime(); + $interceptionConfig = new Config\Config( + $this->_configReader, $configScope, $cache, $relations, $config, $definitions + ); + $interceptionDefinitions = new Definition\Runtime(); + $this->_objectManager = new \Magento\ObjectManager\ObjectManager( + $factory, $config, array( + 'Magento\Config\CacheInterface' => $cache, + 'Magento\Config\ScopeInterface' => $configScope, + 'Magento\Config\ReaderInterface' => $this->_configReader, + 'Magento\ObjectManager\Relations' => $relations, + 'Magento\ObjectManager\Config' => $config, + 'Magento\ObjectManager\Definition' => $definitions, + 'Magento\Interception\Definition' => $interceptionDefinitions + ) + ); + $argObjectFactory->setObjectManager($this->_objectManager); + $config->setInterceptionConfig($interceptionConfig); + $config->extend(array('preferences' => array( + 'Magento\Interception\PluginList' => 'Magento\Interception\PluginList\PluginList', + 'Magento\Interception\Chain' => 'Magento\Interception\Chain\Chain' + ))); + } + + public function testMethodCanBePluginized() + { + $subject = $this->_objectManager->create('Magento\Interception\Fixture\Intercepted'); + $this->assertEquals('<P:D>1: <D>test</D></P:D>', $subject->D('test')); + } + + public function testPluginCanCallOnlyNextMethodOnNext() + { + $subject = $this->_objectManager->create('Magento\Interception\Fixture\Intercepted'); + $this->assertEquals( + '<IP:aG><P:aG><G><P:G><P:bG><IP:G><IP:bG>test</IP:bG></IP:G></P:bG></P:G></G></P:aG></IP:aG>', + $subject->G('test') + ); + } + + public function testBeforeAndAfterPluginsAreExecuted() + { + $subject = $this->_objectManager->create('Magento\Interception\Fixture\Intercepted'); + $this->assertEquals( + '<IP:F><P:D>1: <D>prefix_<F><IP:C><P:C><C>test</C></P:C>' + . '</IP:C></F></D></P:D></IP:F>', + $subject->A('prefix_')->F('test') + ); + } + + public function testPluginCallsOtherMethodsOnSubject() + { + $subject = $this->_objectManager->create('Magento\Interception\Fixture\Intercepted'); + $this->assertEquals( + '<P:K><IP:F><P:D>1: <D>prefix_<F><IP:C><P:C><C><IP:C><P:C><C>test' + . '</C></P:C></IP:C></C></P:C></IP:C></F></D></P:D></IP:F></P:K>', + $subject->A('prefix_')->K('test') + ); + } + + public function testInterfacePluginsAreInherited() + { + $subject = $this->_objectManager->create('Magento\Interception\Fixture\Intercepted'); + $this->assertEquals('<IP:C><P:C><C>test</C></P:C></IP:C>', $subject->C('test')); + } + + public function testInternalMethodCallsAreIntercepted() + { + $subject = $this->_objectManager->create('Magento\Interception\Fixture\Intercepted'); + $this->assertEquals('<B>12<IP:C><P:C><C>1</C></P:C></IP:C></B>', $subject->B('1', '2')); + } + + public function testChainedMethodsAreIntercepted() + { + $subject = $this->_objectManager->create('Magento\Interception\Fixture\Intercepted'); + $this->assertEquals('<P:D>1: <D>prefix_test</D></P:D>', $subject->A('prefix_')->D('test')); + } + + public function testFinalMethodWorks() + { + $subject = $this->_objectManager->create('Magento\Interception\Fixture\Intercepted'); + $this->assertEquals('<P:D>1: <D>prefix_test</D></P:D>', $subject->A('prefix_')->D('test')); + $this->assertEquals('<E>prefix_final</E>', $subject->E('final')); + $this->assertEquals('<P:D>2: <D>prefix_test</D></P:D>', $subject->D('test')); + } + + public function testObjectKeepsStateBetweenInvocations() + { + $subject = $this->_objectManager->create('Magento\Interception\Fixture\Intercepted'); + $this->assertEquals('<P:D>1: <D>test</D></P:D>', $subject->D('test')); + $this->assertEquals('<P:D>2: <D>test</D></P:D>', $subject->D('test')); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/LocaleTest.php b/dev/tests/integration/testsuite/Magento/Locale/ResolverTest.php similarity index 84% rename from dev/tests/integration/testsuite/Magento/Core/Model/LocaleTest.php rename to dev/tests/integration/testsuite/Magento/Locale/ResolverTest.php index d3ba8998210..948fd88e997 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/LocaleTest.php +++ b/dev/tests/integration/testsuite/Magento/Locale/ResolverTest.php @@ -22,19 +22,16 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * Test for \Magento\Core\Model\Locale class - */ -namespace Magento\Core\Model; +namespace Magento\Locale; -class LocaleTest extends \PHPUnit_Framework_TestCase +class ResolverTest extends \PHPUnit_Framework_TestCase { public function testGetLocale() { $objectManager = \Magento\App\ObjectManager::getInstance(); \Zend_Locale_Data::removeCache(); $this->assertNull(\Zend_Locale_Data::getCache()); - $model = $objectManager->create('Magento\Core\Model\Locale', array('locale' => 'some_locale')); + $model = $objectManager->create('Magento\Locale\ResolverInterface', array('locale' => 'some_locale')); $this->assertInstanceOf('Zend_Locale', $model->getLocale()); $this->assertInstanceOf('Zend_Cache_Core', \Zend_Locale_Data::getCache()); } diff --git a/dev/tests/integration/testsuite/Magento/Multishipping/Controller/CheckoutTest.php b/dev/tests/integration/testsuite/Magento/Multishipping/Controller/CheckoutTest.php index 14e1f06be40..67cc0985cdd 100644 --- a/dev/tests/integration/testsuite/Magento/Multishipping/Controller/CheckoutTest.php +++ b/dev/tests/integration/testsuite/Magento/Multishipping/Controller/CheckoutTest.php @@ -27,6 +27,8 @@ namespace Magento\Multishipping\Controller; +use Magento\TestFramework\Helper\Bootstrap; + /** * Test class for \Magento\Multishipping\Controller\Checkout * @@ -52,9 +54,12 @@ class CheckoutTest extends \Magento\TestFramework\TestCase\AbstractController ->setQuoteId($quote->getId()); $logger = $this->getMock('Magento\Logger', array(), array(), '', false); /** @var $session \Magento\Customer\Model\Session */ - $session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + $session = Bootstrap::getObjectManager() ->create('Magento\Customer\Model\Session', array($logger)); - $session->login('customer@example.com', 'password'); + $service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Service\V1\CustomerAccountService'); + $customer = $service->authenticate('customer@example.com', 'password'); + $session->setCustomerDtoAsLoggedIn($customer); $this->getRequest()->setPost('payment', array('method' => 'checkmo')); $this->dispatch('multishipping/checkout/overview'); $html = $this->getResponse()->getBody(); diff --git a/dev/tests/integration/testsuite/Magento/Payment/Block/InfoTest.php b/dev/tests/integration/testsuite/Magento/Payment/Block/InfoTest.php index 3823d9c7173..6553b404203 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Block/InfoTest.php +++ b/dev/tests/integration/testsuite/Magento/Payment/Block/InfoTest.php @@ -44,7 +44,7 @@ class InfoTest extends \PHPUnit_Framework_TestCase $paymentInfoBank = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Payment\Model\Info'); $paymentInfoBank->setMethodInstance(\Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Payment\Model\Method\Banktransfer')); + ->create('Magento\OfflinePayments\Model\Banktransfer')); /** @var $childBank \Magento\Payment\Block\Info\Instructions */ $childBank = $layout->addBlock('Magento\Payment\Block\Info\Instructions', 'child.one', 'block'); $childBank->setInfo($paymentInfoBank); @@ -57,9 +57,10 @@ class InfoTest extends \PHPUnit_Framework_TestCase $paymentInfoCheckmo = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Payment\Model\Info'); $paymentInfoCheckmo->setMethodInstance(\Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Payment\Model\Method\Checkmo')); - /** @var $childCheckmo \Magento\Payment\Block\Info\Checkmo */ - $childCheckmo = $layout->addBlock('Magento\Payment\Block\Info\Checkmo', 'child.just.another', 'block'); + ->create('Magento\OfflinePayments\Model\Checkmo')); + /** @var $childCheckmo \Magento\OfflinePayments\Block\Info\Checkmo */ + $childCheckmo = $layout->addBlock('Magento\OfflinePayments\Block\Info\Checkmo', + 'child.just.another', 'block'); $childCheckmo->setInfo($paymentInfoCheckmo); $pdfArray = $block->getChildPdfAsArray(); diff --git a/dev/tests/integration/testsuite/Magento/Payment/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Payment/Helper/DataTest.php index 6c9c60b2d67..472f1872014 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Payment/Helper/DataTest.php @@ -39,6 +39,6 @@ class DataTest extends \PHPUnit_Framework_TestCase ->create('Magento\Payment\Model\Info'); $paymentInfo->setMethod('checkmo'); $result = $helper->getInfoBlock($paymentInfo); - $this->assertInstanceOf('Magento\Payment\Block\Info\Checkmo', $result); + $this->assertInstanceOf('Magento\OfflinePayments\Block\Info\Checkmo', $result); } } diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/Config/ReaderTest.php b/dev/tests/integration/testsuite/Magento/Payment/Model/Config/ReaderTest.php index e39218dbbc0..76824b3b765 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Model/Config/ReaderTest.php +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/Config/ReaderTest.php @@ -61,7 +61,7 @@ class ReaderTest extends \PHPUnit_Framework_TestCase 'SM' => 'Switch/Maestro', ), 'groups' => array( - 'paypal' => 'PayPal' + 'any_payment' => 'Any Payment' ), 'methods' => array( 'checkmo' => array( @@ -91,7 +91,7 @@ class ReaderTest extends \PHPUnit_Framework_TestCase 'SO' => 'Solo', ), 'groups' => array( - 'paypal' => 'PayPal Payment Methods', + 'any_payment' => 'Any Payment Methods', 'offline' => 'Offline Payment Methods', ), 'methods' => array( @@ -106,4 +106,4 @@ class ReaderTest extends \PHPUnit_Framework_TestCase ); $this->assertEquals($expected, $result); } -} \ No newline at end of file +} diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/ConfigTest.php b/dev/tests/integration/testsuite/Magento/Payment/Model/ConfigTest.php index 21086499247..6855d6ba579 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Model/ConfigTest.php +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/ConfigTest.php @@ -71,7 +71,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetGroups() { $expected = array( - 'paypal' => 'PayPal Payment Methods', + 'any_payment' => 'Any Payment Methods', 'offline' => 'Offline Payment Methods', ); $groups = $this->_model->getGroups(); diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment.xml b/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment.xml index 9d9df16d133..5394b88291a 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment.xml +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment.xml @@ -34,8 +34,8 @@ </type> </credit_cards> <groups> - <group id="paypal"> - <label>PayPal</label> + <group id="any_payment"> + <label>Any Payment</label> </group> </groups> <methods> diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment2.xml b/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment2.xml index 2b7e7810d8d..b9a1869e298 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment2.xml +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment2.xml @@ -34,8 +34,8 @@ </type> </credit_cards> <groups> - <group id="paypal"> - <label>PayPal Payment Methods</label> + <group id="any_payment"> + <label>Any Payment Methods</label> </group> <group id="offline"> <label>Offline Payment Methods</label> diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php index b44c878ac82..1cb08d6ef02 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php @@ -42,7 +42,7 @@ class VoidTest extends \PHPUnit_Framework_TestCase $coreStoreConfig = $objectManager->get('Magento\Core\Model\Store\Config'); $logger = $objectManager->get('Magento\Logger'); $logAdapterFactory = $objectManager->get('Magento\Logger\AdapterFactory'); - $locale = $objectManager->get('Magento\Core\Model\LocaleInterface'); + $localeDate = $objectManager->get('Magento\Stdlib\DateTime\TimezoneInterface'); $centinelService = $objectManager->get('Magento\Centinel\Model\Service'); $storeManager = $objectManager->get('Magento\Core\Model\StoreManagerInterface'); $configFactory = $objectManager->get('Magento\Paypal\Model\ConfigFactory'); @@ -61,7 +61,7 @@ class VoidTest extends \PHPUnit_Framework_TestCase $logAdapterFactory, $logger, $moduleList, - $locale, + $localeDate, $centinelService, $storeManager, $configFactory, diff --git a/dev/tests/integration/testsuite/Magento/Profiler/Driver/Standard/Output/FirebugTest.php b/dev/tests/integration/testsuite/Magento/Profiler/Driver/Standard/Output/FirebugTest.php index 1578b399319..993c2b7cd56 100644 --- a/dev/tests/integration/testsuite/Magento/Profiler/Driver/Standard/Output/FirebugTest.php +++ b/dev/tests/integration/testsuite/Magento/Profiler/Driver/Standard/Output/FirebugTest.php @@ -38,13 +38,16 @@ class FirebugTest extends \PHPUnit_Framework_TestCase protected $_response; /** - * @var \Magento\App\RequestInterface|PHPUnit_Framework_MockObject_MockObject + * @var \Magento\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_request; protected function setUp() { - $this->_response = $this->getMock('\Magento\App\Response\Http', array('canSendHeaders', 'sendHeaders')); + $this->_response = $this->getMockBuilder('\Magento\App\Response\Http') + ->setMethods(array('canSendHeaders', 'sendHeaders')) + ->disableOriginalConstructor() + ->getMock(); $this->_response ->expects($this->any()) ->method('canSendHeaders') diff --git a/dev/tests/integration/testsuite/Magento/RecurringProfile/Block/Catalog/Product/View/ProfileTest.php b/dev/tests/integration/testsuite/Magento/RecurringProfile/Block/Catalog/Product/View/ProfileTest.php index 2b3b262649f..7bdbf25ecb4 100644 --- a/dev/tests/integration/testsuite/Magento/RecurringProfile/Block/Catalog/Product/View/ProfileTest.php +++ b/dev/tests/integration/testsuite/Magento/RecurringProfile/Block/Catalog/Product/View/ProfileTest.php @@ -49,11 +49,11 @@ class ProfileTest extends \PHPUnit_Framework_TestCase $html = $block->getDateHtml(); $this->assertNotEmpty($html); $dateFormat = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Core\Model\LocaleInterface') - ->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + ->get('Magento\Stdlib\DateTime\TimezoneInterface') + ->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); $timeFormat = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Core\Model\LocaleInterface') - ->getTimeFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + ->get('Magento\Stdlib\DateTime\TimezoneInterface') + ->getTimeFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT); $this->assertContains('dateFormat: "' . $dateFormat . '",', $html); $this->assertContains('timeFormat: "' . $timeFormat . '",', $html); } diff --git a/dev/tests/integration/testsuite/Magento/RecurringProfile/_files/recurring_profile.php b/dev/tests/integration/testsuite/Magento/RecurringProfile/_files/recurring_profile.php index 03767572806..7a20d166b42 100644 --- a/dev/tests/integration/testsuite/Magento/RecurringProfile/_files/recurring_profile.php +++ b/dev/tests/integration/testsuite/Magento/RecurringProfile/_files/recurring_profile.php @@ -28,8 +28,31 @@ use Magento\TestFramework\Helper\Bootstrap; define('FIXTURE_RECURRING_PROFILE_SCHEDULE_DESCRIPTION', 'fixture-recurring-profile-schedule'); +$objectManager = Bootstrap::getObjectManager(); +// Mock Profile class, because no default implementation of \Magento\Payment\Model\Recurring\Profile\MethodInterface +$profile = \PHPUnit_Framework_MockObject_Generator::getMock( + 'Magento\RecurringProfile\Model\Profile', + ['isValid'], + [ + $objectManager->get('Magento\Model\Context'), + $objectManager->get('Magento\Registry'), + $objectManager->get('Magento\Payment\Helper\Data'), + $objectManager->get('Magento\RecurringProfile\Model\PeriodUnits'), + $objectManager->get('Magento\RecurringProfile\Block\Fields'), + $objectManager->get('Magento\Stdlib\DateTime\TimezoneInterface'), + $objectManager->get('Magento\Locale\ResolverInterface'), + $objectManager->get('Magento\Sales\Model\OrderFactory'), + $objectManager->get('Magento\Sales\Model\Order\AddressFactory'), + $objectManager->get('Magento\Sales\Model\Order\PaymentFactory'), + $objectManager->get('Magento\Sales\Model\Order\ItemFactory'), + $objectManager->get('Magento\Math\Random'), + $objectManager->get('Magento\RecurringProfile\Model\States') + ] +); +$profile->expects(new \PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount) + ->method('isValid') + ->will(new \PHPUnit_Framework_MockObject_Stub_Return(true)); /** @var Magento\RecurringProfile\Model\Profile $profile */ -$profile = Bootstrap::getObjectManager()->create('Magento\RecurringProfile\Model\Profile'); $profile ->setQuote(Bootstrap::getObjectManager()->create('Magento\Sales\Model\Quote')->load(1)) ->setPeriodUnit('year') @@ -37,7 +60,6 @@ $profile ->setScheduleDescription(FIXTURE_RECURRING_PROFILE_SCHEDULE_DESCRIPTION) ->setBillingAmount(1) ->setCurrencyCode('USD') - ->setMethodCode('paypal_express') ->setInternalReferenceId('rp-1') ->setCustomerId(1) ->save(); diff --git a/dev/tests/integration/testsuite/Magento/Rss/Controller/IndexTest.php b/dev/tests/integration/testsuite/Magento/Rss/Controller/IndexTest.php index d0d7c34609d..3559f57af21 100644 --- a/dev/tests/integration/testsuite/Magento/Rss/Controller/IndexTest.php +++ b/dev/tests/integration/testsuite/Magento/Rss/Controller/IndexTest.php @@ -65,8 +65,12 @@ class IndexTest extends \Magento\TestFramework\TestCase\AbstractController $this->getRequest()->setParam('wishlist_id', $wishlist->getId()) ->setParam('data', base64_encode('1')) ; - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Customer\Model\Session') - ->login('customer@example.com', 'password'); + $session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Customer\Model\Session'); + $service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Service\V1\CustomerAccountService'); + $customer = $service->authenticate('customer@example.com', 'password'); + $session->setCustomerDtoAsLoggedIn($customer); + $this->dispatch('rss/index/wishlist'); $this->assertContains('<![CDATA[Simple Product]]>', $this->getResponse()->getBody()); } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php index 87ad1531c12..8f4c04f9f6a 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php @@ -72,7 +72,7 @@ class AbstractTest 'frontend_label' => 'Date', ) ); - $dateAttribute = $objectManager->create('\Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', $arguments); + $dateAttribute = $objectManager->create('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', $arguments); $attributes = array('date' => $dateAttribute); $method->invoke($block, $attributes, $fieldset); diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/FormTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/FormTest.php index eaef5c66bcb..02be3a95bf4 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/FormTest.php @@ -99,13 +99,13 @@ class FormTest extends \PHPUnit_Framework_TestCase {"{$addressIds[0]}": {"firstname":"John","lastname":"Smith","company":false,"street":"Green str, 67","city":"CityM", "country_id":"US", - "region":{"region_code":"AL","region":"Alabama","region_id":1}, - "region_id":false,"postcode":"75477","telephone":"3468676","fax":false,"vat_id":false}, + "region":"Alabama","region_id":1, + "postcode":"75477","telephone":"3468676","fax":false,"vat_id":false}, "{$addressIds[1]}": {"firstname":"John","lastname":"Smith","company":false,"street":"Black str, 48","city":"CityX", "country_id":"US", - "region":{"region_code":"AL","region":"Alabama","region_id":1}, - "region_id":false,"postcode":"47676","telephone":"3234676","fax":false,"vat_id":false} + "region":"Alabama","region_id":1, + "postcode":"47676","telephone":"3234676","fax":false,"vat_id":false} }, "store_id":1,"currency_symbol":"$","shipping_method_reseted":true,"payment_method":null } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/Address/CollectTotalsTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/Address/CollectTotalsTest.php index db112711531..511bf8bd6e1 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/Address/CollectTotalsTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Observer/Frontend/Quote/Address/CollectTotalsTest.php @@ -34,7 +34,7 @@ class CollectTotalsTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('\Magento\Sales\Model\Observer\Frontend\Quote\Address\CollectTotals'); + ->create('Magento\Sales\Model\Observer\Frontend\Quote\Address\CollectTotals'); } /** @@ -106,4 +106,4 @@ class CollectTotalsTest extends \PHPUnit_Framework_TestCase $this->assertEquals(1, $quote->getCustomer()->getGroupId()); } -} \ No newline at end of file +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Resource/Sale/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Resource/Sale/CollectionTest.php index 16beb72e055..6c77ca17f7f 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Resource/Sale/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Resource/Sale/CollectionTest.php @@ -34,8 +34,8 @@ class CollectionTest extends \PHPUnit_Framework_TestCase public function testSetCustomerFilter() { $collectionModel = Bootstrap::getObjectManager()->create('Magento\Sales\Model\Resource\Sale\Collection'); - $this->assertEquals(1, $collectionModel->setCustomerFilter(1)->count()); + $this->assertEquals(1, $collectionModel->setCustomerIdFilter(1)->count()); $collectionModel = Bootstrap::getObjectManager()->create('Magento\Sales\Model\Resource\Sale\Collection'); - $this->assertEquals(0, $collectionModel->setCustomerFilter(2)->count()); + $this->assertEquals(0, $collectionModel->setCustomerIdFilter(2)->count()); } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Service/QuoteTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Service/QuoteTest.php index fcda438e2fc..1bb8b76d7fa 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Service/QuoteTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Service/QuoteTest.php @@ -66,7 +66,7 @@ class QuoteTest extends \PHPUnit_Framework_TestCase /** * @var AddressBuilder */ - protected $_customerAddressBuilder; + protected $_addressBuilder; public function setUp() @@ -120,16 +120,13 @@ class QuoteTest extends \PHPUnit_Framework_TestCase { $this->_prepareQuote(false); - $response = $this->_customerAccountService->createAccount( - $this->getSampleCustomerEntity(), + $customerDto = $this->_customerAccountService->createAccount( + $this->getSampleCustomerEntity(), $this->getSampleAddressEntity(), 'password' ); - $this->assertEquals('registered', $response->getStatus()); - - $existingCustomerId = $response->getCustomerId(); - $customerDto = $this->_customerService->getCustomer($existingCustomerId); + $existingCustomerId = $customerDto->getCustomerId(); $customerDto = $this->_customerBuilder->mergeDtoWithArray( $customerDto, [CustomerDto::EMAIL => 'new@example.com'] @@ -191,15 +188,13 @@ class QuoteTest extends \PHPUnit_Framework_TestCase public function testSubmitOrderRollbackExistingCustomer() { $this->_prepareQuoteWithMockTransaction(); - $response = $this->_customerAccountService->createAccount( - $this->getSampleCustomerEntity(), + $customerDto = $this->_customerAccountService->createAccount( + $this->getSampleCustomerEntity(), $this->getSampleAddressEntity(), 'password' ); - $this->assertEquals('registered', $response->getStatus()); - $existingCustomerId = $response->getCustomerId(); - $customerDto = $this->_customerService->getCustomer($existingCustomerId); + $existingCustomerId = $customerDto->getCustomerId(); $customerDto = $this->_customerBuilder->mergeDtoWithArray( $customerDto, [CustomerDto::EMAIL => 'new@example.com'] diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php index 1b164dfc010..248df5c9808 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Payment/MethodsTest.php @@ -46,7 +46,7 @@ class MethodsTest extends \PHPUnit_Framework_TestCase ->get('Magento\View\Element\BlockFactory'); $storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Core\Model\StoreManagerInterface')->getStore()->getId(); - /** @var $model \Magento\Payment\Model\Method\AbstractMethod */ + /** @var $model \Magento\Payment\Model\MethodInterface */ if (empty($methodClass)) { /** * Note that $code is not whatever the payment method getCode() returns diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Widget/TemplateFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Widget/TemplateFilesTest.php index 8907f5e58e4..0c62057c7b9 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Widget/TemplateFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Magento/Widget/TemplateFilesTest.php @@ -27,13 +27,11 @@ namespace Magento\Test\Integrity\Magento\Widget; +/** + * @magentoAppArea frontend + */ class TemplateFilesTest extends \PHPUnit_Framework_TestCase { - public static function setUpBeforeClass() - { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\State')->setAreaCode('frontend'); - } - /** * Check if all the declared widget templates actually exist * diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/UsaConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/CarrierConfigFilesTest.php similarity index 95% rename from dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/UsaConfigFilesTest.php rename to dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/CarrierConfigFilesTest.php index 55452281ef4..9c93b3c2bcd 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/UsaConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/CarrierConfigFilesTest.php @@ -1,8 +1,6 @@ <?php -namespace Magento\Test\Integrity\Modular; - /** - * Test configuration of Usa shipping carriers + * Test configuration of Online Shipping carriers * * Magento * @@ -25,7 +23,9 @@ namespace Magento\Test\Integrity\Modular; * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class UsaConfigFilesTest extends \PHPUnit_Framework_TestCase +namespace Magento\Test\Integrity\Modular; + +class CarrierConfigFilesTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\Backend\Model\Config\Structure\Reader diff --git a/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php b/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php index 1bd1534dafd..25d44156c38 100644 --- a/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php +++ b/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php @@ -74,11 +74,9 @@ class HtmlTest extends \PHPUnit_Framework_TestCase )); $storeManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Core\Model\StoreManagerInterface'); - $locale = $this->getMock('Magento\Core\Model\LocaleInterface', array(), array(), '', false); $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Theme\Block\Html', array( 'storeManager' => $storeManager, - 'locale' => $locale, 'urlHelperMock' => $codeData, 'context' => $context )); diff --git a/dev/tests/integration/testsuite/Magento/TranslateTest.php b/dev/tests/integration/testsuite/Magento/TranslateTest.php index ef2c6d1e581..b222e1110ab 100644 --- a/dev/tests/integration/testsuite/Magento/TranslateTest.php +++ b/dev/tests/integration/testsuite/Magento/TranslateTest.php @@ -95,7 +95,7 @@ class TranslateTest extends \PHPUnit_Framework_TestCase $objectManager->get('Magento\App\ConfigInterface'), $objectManager->get('Magento\Core\Model\Store\Config'), $objectManager->get('Magento\Core\Model\ThemeFactory'), - $objectManager->get('Magento\Core\Model\App'), + $objectManager->get('Magento\Locale\ResolverInterface'), $objectManager->get('Magento\App\State'), array('frontend' => 'test_default') ) diff --git a/dev/tests/integration/testsuite/Magento/Usa/Model/Shipping/Carrier/UpsTest.php b/dev/tests/integration/testsuite/Magento/Ups/Model/CarrierTest.php similarity index 66% rename from dev/tests/integration/testsuite/Magento/Usa/Model/Shipping/Carrier/UpsTest.php rename to dev/tests/integration/testsuite/Magento/Ups/Model/CarrierTest.php index bdcee99cec2..9b9eb5cfc1f 100644 --- a/dev/tests/integration/testsuite/Magento/Usa/Model/Shipping/Carrier/UpsTest.php +++ b/dev/tests/integration/testsuite/Magento/Ups/Model/CarrierTest.php @@ -22,24 +22,24 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier; +namespace Magento\Ups\Model; -class UpsTest extends \PHPUnit_Framework_TestCase +class CarrierTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Usa\Model\Shipping\Carrier\Ups + * @var \Magento\Ups\Model\Carrier */ - private $_object; + private $carrier; protected function setUp() { - $this->_object = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Usa\Model\Shipping\Carrier\Ups'); + $this->carrier = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Ups\Model\Carrier'); } public function testGetShipAcceptUrl() { - $this->assertEquals($this->_object->getShipAcceptUrl(), 'https://wwwcie.ups.com/ups.app/xml/ShipAccept'); + $this->assertEquals('https://wwwcie.ups.com/ups.app/xml/ShipAccept', $this->carrier->getShipAcceptUrl()); } /** @@ -49,12 +49,12 @@ class UpsTest extends \PHPUnit_Framework_TestCase */ public function testGetShipAcceptUrlLive() { - $this->assertEquals($this->_object->getShipAcceptUrl(), 'https://onlinetools.ups.com/ups.app/xml/ShipAccept'); + $this->assertEquals('https://onlinetools.ups.com/ups.app/xml/ShipAccept', $this->carrier->getShipAcceptUrl()); } public function testGetShipConfirmUrl() { - $this->assertEquals($this->_object->getShipConfirmUrl(), 'https://wwwcie.ups.com/ups.app/xml/ShipConfirm'); + $this->assertEquals('https://wwwcie.ups.com/ups.app/xml/ShipConfirm', $this->carrier->getShipConfirmUrl()); } /** @@ -64,6 +64,6 @@ class UpsTest extends \PHPUnit_Framework_TestCase */ public function testGetShipConfirmUrlLive() { - $this->assertEquals($this->_object->getShipConfirmUrl(), 'https://onlinetools.ups.com/ups.app/xml/ShipConfirm'); + $this->assertEquals('https://onlinetools.ups.com/ups.app/xml/ShipConfirm', $this->carrier->getShipConfirmUrl()); } } diff --git a/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php b/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php index a53290a8f3e..81c1b0aa7b4 100644 --- a/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php +++ b/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php @@ -314,6 +314,36 @@ class UserTest extends \PHPUnit_Framework_TestCase $this->_model->save(); } + /** + * @magentoDbIsolation enabled + */ + public function testBeforeSavePasswordHash() + { + $this->_model->setUsername('john.doe') + ->setFirstname('John') + ->setLastname('Doe') + ->setEmail('jdoe@gmail.com') + ->setPassword('123123q') + ; + $this->_model->save(); + $this->assertNotContains('123123q', $this->_model->getPassword(), 'Password is expected to be hashed'); + $this->assertRegExp( + '/^[0-9a-f]+:[0-9a-zA-Z]{32}$/', + $this->_model->getPassword(), + 'Salt is expected to be saved along with the password' + ); + + /** @var \Magento\User\Model\User $model */ + $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\User\Model\User'); + $model->load($this->_model->getId()); + $this->assertEquals( + $this->_model->getPassword(), + $model->getPassword(), + 'Password data has been corrupted during saving' + ); + } + /** * @expectedException \Magento\Core\Exception * @expectedExceptionMessage Your password confirmation must match your password. diff --git a/dev/tests/integration/testsuite/Magento/View/Element/AbstractBlockTest.php b/dev/tests/integration/testsuite/Magento/View/Element/AbstractBlockTest.php index 9bb7de97aee..f1b00411d6c 100644 --- a/dev/tests/integration/testsuite/Magento/View/Element/AbstractBlockTest.php +++ b/dev/tests/integration/testsuite/Magento/View/Element/AbstractBlockTest.php @@ -512,14 +512,14 @@ class AbstractBlockTest extends \PHPUnit_Framework_TestCase public function testFormatDate() { $locale = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\LocaleInterface'); + 'Magento\Stdlib\DateTime\TimezoneInterface'); $this->assertEquals($locale->formatDate(), $this->_block->formatDate()); } public function testFormatTime() { $locale = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\LocaleInterface'); + 'Magento\Stdlib\DateTime\TimezoneInterface'); $this->assertEquals($locale->formatTime(), $this->_block->formatTime()); } diff --git a/dev/tests/integration/testsuite/Magento/View/PublicationTest.php b/dev/tests/integration/testsuite/Magento/View/PublicationTest.php index c84ade2ae21..04b9980776f 100644 --- a/dev/tests/integration/testsuite/Magento/View/PublicationTest.php +++ b/dev/tests/integration/testsuite/Magento/View/PublicationTest.php @@ -90,7 +90,7 @@ class PublicationTest extends \PHPUnit_Framework_TestCase { $this->_initTestTheme($allowDuplication); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\LocaleInterface') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Locale\ResolverInterface') ->setLocale($locale); $url = $this->viewUrl->getViewFileUrl($file); $this->assertStringEndsWith($expectedUrl, $url); @@ -377,8 +377,22 @@ class PublicationTest extends \PHPUnit_Framework_TestCase public function testPublishCssFileFromModule( $cssViewFile, $designParams, $expectedCssFile, $expectedCssContent, $expectedRelatedFiles ) { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App') + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + + $objectManager->configure( + ['Magento\View\Design\Fallback\Factory' => ['arguments' => [ + 'filesystem' => [ + 'value' => 'Magento\View\MockedFilesystem', + 'name' => 'filesystem', + \Magento\ObjectManager\Config\Reader\Dom::TYPE_ATTRIBUTE => 'object' + ] + + ]]] + ); + + $objectManager->get('Magento\Core\Model\App') ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); + $this->viewUrl->getViewFileUrl($cssViewFile, $designParams); $expectedCssFile = $this->viewService->getPublicDir() . '/' . $expectedCssFile; @@ -413,32 +427,32 @@ class PublicationTest extends \PHPUnit_Framework_TestCase 'area' => 'adminhtml', 'theme' => 'magento_backend', 'locale' => 'en_US', - 'module' => 'Magento_Catalog', + 'module' => 'Magento_ModuleA', ), - 'adminhtml/magento_backend/en_US/Magento_Catalog/product/product.css', + 'adminhtml/magento_backend/en_US/Magento_ModuleA/product/product.css', array( - 'url(../../Magento_Backend/images/gallery-image-base-label.png)', + 'url(../../Magento_ModuleB/images/gallery-image-base-label.png)', ), array( - 'adminhtml/magento_backend/en_US/Magento_Backend/images/gallery-image-base-label.png', + 'adminhtml/magento_backend/en_US/Magento_ModuleB/images/gallery-image-base-label.png', ), ), 'adminhtml' => array( - 'Magento_Paypal::styles.css', + 'Magento_ModuleC::styles.css', array( 'area' => 'adminhtml', 'theme' => 'vendor_test', 'locale' => 'en_US', 'module' => false, ), - 'adminhtml/vendor_test/en_US/Magento_Paypal/styles.css', + 'adminhtml/vendor_test/en_US/Magento_ModuleC/styles.css', array( - 'url(images/paypal-logo.png)', - 'url(images/pp-allinone.png)', + 'url(images/logo.png)', + 'url(images/allinone.png)', ), array( - 'adminhtml/vendor_test/en_US/Magento_Paypal/images/paypal-logo.png', - 'adminhtml/vendor_test/en_US/Magento_Paypal/images/pp-allinone.png', + 'adminhtml/vendor_test/en_US/Magento_ModuleC/images/logo.png', + 'adminhtml/vendor_test/en_US/Magento_ModuleC/images/allinone.png', ), ), ); @@ -735,3 +749,17 @@ class PublicationTest extends \PHPUnit_Framework_TestCase $this->assertFileEquals($expectedFile, $actualFile); } } + +class MockedFilesystem extends \Magento\App\Filesystem +{ + /** + * Re-write modules directory + * + * @param string $code + * @return string + */ + public function getPath($code = self::ROOT_DIR) + { + return $code == \Magento\App\Filesystem::MODULES_DIR ? __DIR__ . '/_files' : parent::getPath($code); + } +} diff --git a/dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleA/view/adminhtml/product/product.css b/dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleA/view/adminhtml/product/product.css new file mode 100644 index 00000000000..323396a8239 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleA/view/adminhtml/product/product.css @@ -0,0 +1,897 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/* Action "Back" as cross */ +[class^=" catalog-product-"] .page-actions .action-back, +[class^=" catalog-product-"] .page-actions .action-back:hover, +[class^=" catalog-product-"] .page-actions .action-back:active, +[class^=" newsletter-"] .page-actions .action-back, +[class^=" newsletter-"] .page-actions .action-back:hover, +[class^=" newsletter-"] .page-actions .action-back:active { + overflow: hidden; + padding: 5px 6px 3px; + margin-left: 12px; + color: #7a7976;; +} + +[class^=" catalog-product-"] .page-actions .action-back:hover, +[class^=" newsletter-"] .page-actions .action-back:hover { + color: #000; +} + +[class^=" catalog-product-"] .page-actions .action-back.mage-error, +[class^=" newsletter-"] .page-actions .action-back.mage-error { + color: #b57c72; +} + +[class^=" catalog-product-"] .page-actions .action-back:before, +[class^=" newsletter-"] .page-actions .action-back:before { + display: inline-block; + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e07d'; /* close icon */ + font-size: 16px; +} + +[class^=" catalog-product-"] .page-actions .action-back span, +[class^=" newsletter-"] .page-actions .action-back span { + display: inline-block; + overflow: hidden; + text-indent: -999em; +} + +.page-actions .switcher { + display: inline-block; + vertical-align: top; + margin: 6px 17px 6px 6px; +} + +/* Image Management */ +.images { + position: relative; + border: 2px dotted #ccc; + border-radius: 5px; + margin-bottom: 2px; + padding: 5px; +} + +.image, +.gallery .ui-state-highlight { + position: relative; + width: 17.874%; + border: 1px solid #ccc; + border-radius: 4px; + float: left; + margin: 5px 1%; + overflow: hidden; + background: #fff; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; +} + +.image .spacer { + width: 100%; +} + +.image .product-image { + position: absolute; + left: 0; + top: 0; + right: 0; + bottom: 0; + margin: auto; + width: 100%; + z-index: 1; +} + +.image-label { + visibility: hidden; + position: absolute; + top: 0; + left: 0; + width: 33px; + height: 33px; + background: url(Magento_ModuleB::images/gallery-image-base-label.png) no-repeat; + content: ''; + z-index: 2; +} + +.image.base-image .image-label { + visibility: visible; +} + +.image-fade { + visibility: hidden; + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + background: rgba(247, 242, 236, .8); + content: attr(data-image-hidden-label); + text-align: center; + text-transform: uppercase; + color: #a69a8f; + font: 18px/110px 'CallunaSans', Arial, sans-serif; + font-weight: 500; + z-index: 3; +} + +.eq-ie8 .image-fade { + background: #f7f2ec; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)"; +} + +.image.hidden-for-front .image-fade { + visibility: visible; +} + +.gallery .image.hidden-for-front .image-fade { + line-height: 160px; +} + +.image.active { + box-shadow: 0 0 10px #2ea9ec; +} + +.image .actions { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + text-align: center; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + z-index: 1; +} + +.image .actions [class^="action-"], +.image[data-image-hidden]:hover .actions [class^="action-"], +.image.hidden-for-front:hover .actions [class^="action-"] { + visibility: hidden; +} + +.image:hover .actions [class^="action-"], +.image[data-image-hidden]:hover .actions .action-delete, +.hidden-for-front:hover .actions .action-delete { + visibility: visible; +} + +.image .action-delete { + position: absolute; + top: 2px; + right: 2px; + z-index: 2; +} + +.image .action-make-base { + position: absolute; + bottom: 20px; + left: 10%; + right: 10%; + padding: 5px; + margin: auto; +} + +.image.base-image .action-make-base { + display: none; +} + +.image .draggable-handle:before { + content: ''; +} + +.gallery .image .action-delete { + top: 5px; + right: 5px; +} + +.image.ui-sortable-placeholder { + background: #d7ebf5; + border: 1px dotted #93dbff; + visibility: visible !important; +} + +.image-placeholder .fileinput-button { + position: absolute; + left: 0; + top: 0; + right: 0; + bottom: 0; +} + +.image-placeholder .fileinput-button > span { + display: none; +} + +.image-placeholder input[type="file"] { + position: absolute; + top: 0; + right: 0; + left: 0; + bottom: 0; + width: 100%; + height: 100%; + opacity: 0; + border: 500px solid transparent; + font-size: 10em; + z-index: 2; + cursor: pointer; +} + +.image-placeholder-text { + padding: 0 10px; + position: absolute; + left: 0; + right: 0; + bottom: 0; + font-size: 11px; + font-weight: bold; + line-height: 1.333; + text-align: center; + color: #cac8c4; +} + +.gallery .image-placeholder { + background-position: 50% 30%; +} + +.gallery .image-placeholder-text { + margin-bottom: 15%; +} + +@media screen and (max-width: 1200px) { + .gallery .image-placeholder-text { + margin-bottom: 5px; + } +} + +/* Gallery image panel */ +.image-panel { + display: none; + position: relative; + top: 5px; + clear: both; + background: #fff; + margin: 0 -18px 15px; + padding: 20px 15px; + box-shadow: 0 1px 3px #aaa inset; + border-bottom: 1px solid #cfd0cb; +} + +.eq-ie8 .image-panel { + border: solid #d6d3d0; + border-width: 2px 1px 1px; +} + +.eq-ie8 .image-pointer { + top: -13px; +} + +.image-panel-controls, +.image-panel-preview { + float: left; + width: 65.95744680199999%; + margin-left: 2.127659574%; +} + +.image-panel-preview { + margin-left: 0; +} + +.image-panel-controls { + width: 29.914893614%; + padding: 28px 1% 0 1%; +} + +.image-panel-controls .image-name { + display: block; + margin: 0 0 3px; + color: #666; +} + +.image-file-params { + margin: 0 0 10px 0; + font-size: 11px; + color: #666; +} + +.image-panel-controls .action-remove, +.image-panel-controls .action-remove:hover, +.image-panel-controls .action-remove:active, +.image-panel-controls .action-remove:focus, +.image-panel-controls .action-remove[disabled] { + color: #a29c94; + font: 12px/1.333 Arial, Verdana, sans-serif; + text-decoration: underline; + margin: 0 0 46px 0; +} + +.image-panel-controls .fieldset-image-panel { + padding: 0 5px 0 0; +} + +.image-panel-controls .fieldset-image-panel .field { + margin-bottom: 30px; +} + +.image-panel-controls .fieldset-image-panel .label { + width: 100%; + text-align: left; + margin-bottom: 10px; + padding-top: 0; +} + +.image-panel-controls .fieldset-image-panel .field > .control, +.image-panel-controls textarea { + width: 100%; + resize: vertical; +} + +.image-panel-preview img { + width: 100%; +} + +.image-panel .action-close { + position: absolute; + top: 15px; + right: 15px; +} + +.image-panel .action-close:before { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e07d'; /* close icon */ + font-size: 16px; + color: #bbb; +} + +.image-panel .action-close span { + display: none; +} + +/* action in fieldset wrapper */ +#group-fields-product-details-wrapper .attribute-selector { + visibility: hidden; +} + +#group-fields-product-details-wrapper.opened .attribute-selector { + visibility: visible; +} + +.action-manage-images { + font: 11px/1.666 Arial, Verdana, sans-serif; + color: #a29c94; + text-decoration: underline; +} + +/* Quantity filed on product */ +.field-quantity_and_stock_status input[type="text"], +.field-weight .control .field:first-child { + width: 140px; + margin-right: 15px; +} + +.field-quantity_and_stock_status select { + vertical-align: middle; +} + +/* Weight field */ +.field-weight .control { + display: table; + width: 100%; +} + +.field-weight .control .field:first-child .control { + width: 100%; +} + +.field-weight .choice { + padding-top: 3px; +} + +.field-weight .choice input { + margin-right: 5px; + vertical-align: bottom; +} + +.field-price .addon > input { + width: 99px; + float: left; +} + +/* Validation for Product Fields with addons */ +.field-price .control, +.field-special_price .control, +.field-msrp .control, +.field-weight .control, +.field-quantity_and_stock_status .control { + position: relative; +} + +.field-price label.mage-error, +.field-special_price label.mage-error, +.field-msrp label.mage-error, +.field-weight label.mage-error, +.field-quantity_and_stock_status label.mage-error { + position: absolute; + left: 0; + top: 30px; +} + +.field-tax_class_id .addon select { + border-radius: 4px; +} + +.actions-select .dropdown-menu { + margin-top: 1px; + min-width: 38px; +} + +.actions-select .dropdown-menu li { + padding: 5px; + text-align: center; +} + +.actions-select .action-toggle, +.actions-select .action-toggle:hover, +.actions-select .action-toggle:active, +.actions-select .action-toggle:focus, +.actions-select .action-toggle[disabled] { + background: #fff; + padding: 4px 4px 3px 7px; + color: #888; + filter: none; +} + +.actions-select .action-toggle > span { + display: inline-block; + font-family: Arial, Verdana, sans-serif; + margin-right: 3px; +} + +.actions-select .action-toggle:before { + display: inline-block; + float: right; + color: #888; +} + +/* Variations Search Field */ +#variations-search-field { + margin-bottom: 16px; +} + +#variations-search-field > .control { + position: relative; + width: 42%; +} + +#variations-search-field > .control > input { + padding-right: 25px; +} + +#configurable-attributes-container .field-variation > .label { + margin-left: -7px; +} + +#configurable-attributes-container .field-variation > .control { + width: 43%; +} + +#configurable-attributes-container { + margin-bottom: 23px; +} + +#configurable-attributes-container .col-name { + width: 65%; +} + +#configurable-attributes-container .col-include { + width: 80px; +} + +#configurable-attributes-container .col-actions { + width: 80px; +} + +#configurable-attributes-container .col-change-price { + width: 150px; +} + +#configurable-attributes-container .field-change-pricing .field { + float: left; +} + +#configurable-attributes-container .field-change-pricing .field-pricing-value { + width: 75px; +} + +#configurable-attributes-container .field-change-pricing .action-toggle { + min-width: 40px; +} + +@media screen and (max-width: 960px) { + [class^="fields-group-"] .field { + width: auto !important; + } +} + +#configurable-attributes-container .field-pricing-value .control { + width: 75px; +} + +#configurable-attributes-container .field-pricing-value .pricing-value { + width: 100%; + padding: 4px; + border-right: none; + border-radius: 4px 0 0 4px; +} + +#configurable-attributes-container .field-pricing-measure select { + border-radius: 0 4px 4px 0; +} + +/* "Generate Variations" button */ +.generate { + margin-bottom: 18px; +} + +#product-variations-matrix > .title { + margin-bottom: 10px; +} + +/* Variations Image Uploader */ +.eq-ie8 .actions-image-uploader .action-upload { + filter: none; +} + +.actions-image-uploader .action-toggle, +.actions-image-uploader .action-toggle:hover, +.actions-image-uploader .action-toggle:active, +.actions-image-uploader .action-toggle:focus, +.actions-image-uploader .action-toggle[disabled] { + position: relative; + height: 33px; + padding-left: 2px; + padding-right: 2px; + background: #fff; + filter: none; + color: #888; +} + +.actions-image-uploader.active .action-toggle { + border-radius: 0 5px 0 0; +} + +.actions-image-uploader.active .action-toggle:after { + position: absolute; + left: 0; + right: 0; + bottom: -1px; + height: 1px; + background: #fff; + z-index: 991; + content: ''; +} + +.actions-image-uploader .dropdown-menu { + margin-top: -1px; + border-radius: 3px 0 3px 3px; +} + +#product-variations-matrix img.variation { + position: relative; + border: 0; + width: 32px; + height: 32px; + z-index: 2; +} + +#product-variations-matrix .action-upload { + position: relative; + border: 1px solid #b7b2a7; + background: #fff; + border-radius: 0; + padding: 0; + width: 31px; + height: 31px; + line-height: 31px; + text-align: center; + color: #9f9a91; + overflow: hidden; + cursor: default; + filter: none; +} + +#product-variations-matrix .action-upload input[type="file"] { + position: absolute; + left: 0; + top: 0; + width: 31px; + height: 31px; + background: none; + border: 500px solid transparent; + font-size: 10em; + z-index: 3; + cursor: pointer; +} + +#product-variations-matrix .action-upload:hover { + color: #7e7e7e; +} + +#product-variations-matrix .action-upload:before { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e02d'; /* plus icon */ + font-size: 22px; + position: absolute; + left: 0; + top: 0; + right: 0; + bottom: 0; + z-index: 1; + text-align: center; +} + +#product-variations-matrix .action-upload.loading:before { + content: ''; +} + +#product-variations-matrix .action-upload.loading:after { + left: 0; + top: 0; + right: 0; + bottom: 0; + margin: 0; + width: 31px; + height: 31px; + z-index: 4; +} + +#product-variations-matrix .action-upload span, +#product-variations-matrix .action-choose span { + display: none; +} + +#product-variations-matrix .action-choose, +#product-variations-matrix .action-choose:hover, +#product-variations-matrix .action-choose[disabled] { + color: #b8b3a7; + float: right; + margin: 6px 0 0 5px; +} + +#product-variations-matrix .action-choose:hover { + color: #7e7e7e; +} + +#product-variations-matrix .action-choose:before { + font-family: 'MUI-Icons'; + font-style: normal; + speak: none; + font-weight: normal; + -webkit-font-smoothing: antialiased; + content: '\e03f'; /* user icon */ +} + +#product-variations-matrix .col-name > a + .action-choose:before { + content: '\e040'; /* user icon */ + color: #a09a8c; +} + +#product-variations-matrix .col-name > input { + width: 88%; +} + +#product-variations-matrix .col-actions { + width: 60px; +} + +#product-variations-matrix .col-name { + width: 30%; +} + +#product-variations-matrix .col-sku { + width: 20%; +} + +#product-variations-matrix .col-display, +#product-variations-matrix .col-qty, +#product-variations-matrix .col-weight { + width: 5%; +} + +/* Select Associated Product popup window */ +#configurable_associated_products_grid .filter-actions, +#configurable_associated_products_grid .filter { + display: none; +} + +#product_options_container .data-table td, +#attribute-tier_price-container .data-table td, +#attribute-group_price-container .data-table td { + vertical-align: top; +} + +#product_options_container .product-option-scope-checkbox { + margin: 10px 5px 10px 0; +} + +#product_options_container .select + .product-option-scope-checkbox { + margin: 0 5px; +} + +#allow_open_amount { + margin-top: 8px; +} + +.mage-new-category-dialog .ui-dialog-content .fieldset { + padding: 0; + margin: 0; +} + +.mage-new-category-dialog .ui-dialog-content .label { + width: 25%; +} + +.mage-new-category-dialog .ui-dialog-content .control { + width: 75%; +} + +.mage-new-category-dialog .ui-dialog-buttonset { + text-align: left; +} + +.mage-new-category-dialog .ui-dialog-buttonset .action-create { + margin: 0 0 0 25%; + vertical-align: middle; +} + +/* + Advanced Pricing tab +-------------------------------------- */ +.field-recurring_profile > .control > .field-row:first-child + .fieldset { + margin-top: -14px; +} + +.field-recurring_profile > .control > .fieldset > .field > .label { + width: 30%; +} + +.field-recurring_profile > .control > .fieldset > .field > .control { + width: 70%; +} + +.field-recurring_profile > .control > .fieldset > .field > .field-service { + display: none; +} + +/* Change Attribute Set */ +#product_info_tabs li.removed, +.field.removed { + display: none !important; +} + +/* + Custom Options +-------------------------------------- */ +#product_options_container_top .field-option-title { + width: 500px; +} + +#product_options_container_top .field-option-input-type { + width: 170px; +} + +#product_options_container_top .col-draggable .draggable-handle { + top: 7px; +} + +#product_options_container_top .col-name, +#product_options_container_top .col-sku { + width: 38%; +} + +#product_options_container_top .add-select-row ~ label.mage-error { + display: block; + margin: 5px 0 0; +} + +.eq-ie8 #product_options_container_top .fieldset, +.eq-ie8 #product_options_container_top .fieldset-alt { + margin-bottom: 0; +} + +/* + Tier Price Table +-------------------------------------- */ +.tiers_table .col-qty { + text-align: left; + width: 150px; +} + +.tiers_table .col-qty > input { + width: 40%; + margin-right: 5px; +} + +.tiers_table .col-qty > .nobr { + width: 50%; + float: right; + margin-top: 6px; + text-overflow: ellipsis; + overflow: hidden; +} + +.tiers_table .col-price { + width: 15%; +} + +.new-variation-set { + margin-left: 2.127659574%; +} + +.not-applicable-attribute { + display: none; +} + +.attribute-selector { + margin: -3px -4px 0 0; +} + +.attribute-selector .dropdown-menu { + left: auto; + right: 0; +} + +.attribute-selector .action-choose { + margin: 0; +} + +.attribute-selector .mage-suggest-dropdown > ul { + position: relative; + max-height: 200px; + overflow: auto; + z-index: 1; +} + +.attribute-selector .dropdown-menu .actions { + padding: 14px 12px; +} diff --git a/dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleB/view/adminhtml/images/gallery-image-base-label.png b/dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleB/view/adminhtml/images/gallery-image-base-label.png new file mode 100644 index 0000000000000000000000000000000000000000..49f86d4c08400542e89fe2293ad765ffa6488962 GIT binary patch literal 1892 zcmaJ?Yfuws6x~P+Q9&YtT5xn(@c}i-CJ2E|0(l}S2?Ajnus#x!6+=umO%{_tt1${# zuoZO*=r{;IVin6!TBwSG6&QTABORS0Rtstg)}qvE6)Mt=726-BJG1*e=A3iSz2E(2 zKT1tm?msnTDgXffvLs15F@||xDuwu}?w!Yo;VoR6i7T;nxJ_e00ih1dMnRcTlY^$C z8lB_)izp8Od_a9hCZ4H~BU;SJ(0DNnyU|Rr0f3iaH*2&86bG}>9KDGTJ!)=+K)sF+ zsiGCI!YoGD>yz>=s4_n#Lz{2V#_6Dhc#vmD2mvFCYe2hkgUO26`Oqs}gqVA`nGpC2 zf*bhI-=;DZsh}9MpkOourfcCC7>r>tSW(M39L`dZ4YOb-%x1FKbQTARVk0mNzJ4Gg znnkw`NtYzPjzz5a(0Uv<BTS~vW@Ff*7?>r8$%>1M^J=i!bOJ%QI!w66PB&Q>j4Mb` ztJb17<9f^ldKER<SRT%Y2&aFiU^KsxHCbPmi6|J;t}!!N4A`5}I8dSZf2h&;25rUD z(SQ8@r?54{VMdwhs1?hzXo-Vcx4;|9jEF6$2FENJ7`9=&imB@{9J8*+%%E5q4XX4e z9cHt>LMs%A%w)wiCM_zH@F9ZF(Cc*wTO^foqNUPUPE-_&C1s0Z*uq31ht1|lV<b|s zaGWc_w0TC<gpYG||8Ns0<a!&yXeJ^{P>X&es!OzBM(|a_h<;)(;tBO$b9EDYkxa;C z5@wj*WBu1Lk8csZ<DI@~T4M30?NJla>lUJ^hjrbPiM!GxlL#~HJ?#~Sq&;bKI>#Ov zt#v&Op}|e?g_dO_G^+5ABX6$;x4SMZk=K;PO9E@CE|HL&hDW<rss>)xG%y<(_bLQ~ z*^>`$6pD_fcw%ln$p7xf?dYegZyJ;VbH8hTHo_hAjPX43p@(0dQ@>raDdfI^BiS18 z>k1C=^cI`D@7=pA@;MRjCbivoZWX!x%i9`<ZY?bw>G1!^9X^L#UFSY5393#EP**q3 zTRneGwwX#T{@AB}e)d$LAdp0!((4(9l5V72iS23^UaMz057Wr0aG<l%yg7h!^OrEX zS(LSVrvq&qXi*iuOr6uW)b~6EcsWG~aP=oetG{o)Z97#d>H?MzN8vwyF7lKbQmL2L zWEEfK<%IJhfciy?fo@^jbvrQ2wZq2-dg>$t1q)sTJLYZ+<+cK(N&Bn=(|L7mLoq+J zMNTX0xCfl3k?TJ$daxk4Ocf+J0)I8wAlQFj(0}Js*wGWay>SSdRR#^tF6ql#yLE3> zP~kNoQ5Zg{H@?36!l<UZsa!i!6u1pp88&l==h{ZQq2y}v{70h$i4^``S!88+Rh^7f z<ZuB^i6nVGhf;N*?~tQrX2J^7^2=R3oFC`I;v6_o(Q?-HZMeDwGA~>P92e#`;4=;Z zq56}-0q1z?o>fI*mOp86@+Z&E73BMNoC$JgP46zp`b(b2pK`2>Tt)Izg24cN?t^1L zg&uKsO#i){y`(moW*?j5gRLrSJzXRJvhDP7CwJ^wAw-UE9`0Ni*6$+*LfXY=X?}T4 z=f`>`Z(hr})-vx3@;K-lw`z$0S&^q3A?ruvq<&J=j2*#(X~lKE-Q3Zg$2CWv?2)~E zSi!I-oYW-PLnmGK8yU)2cxTHO+XNhLrSFvjrZB5%N=xx|D$SXcTc28)!@audRJrHF zXQPqv4G68GL`&KJmh!!68OJRNmmaILl&;<%k5orqIa}6eKCf%+IzeiVV;4}M!z9p6 zPL7Hwh}g9MW~WNDtGc0t@mto$v=_cTA?m8T&L_2L$*r2gfz3cRZELtgrC>E&HVj|< z<M)ma=$ZJL>A!rixTp4q$62Mj;avLjwa(VQYFqK`({}&fQe`sV-5(qF-XQgb>F4{M zwbhlIoRxtaHp%;YxwDb`u}7hUNxs5k8CCRm$bz8n17IHaj(~^r1d9f1o(gJRcPGQS zq*C9sh-mlK>wZ(WLZ8fcK1{FMa-r)*scB88KiKCk`f$y>#WUT0HD50bZ95RIjmXt0 zkzKTzlrn0zi1Y+pG*=zoei&#M%R`(L)-mA3=nOS5yT7QP$CU2%{`X|k6iJ;(?fMHf CSJ=(~ literal 0 HcmV?d00001 diff --git a/dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleC/view/adminhtml/images/allinone.png b/dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleC/view/adminhtml/images/allinone.png new file mode 100644 index 0000000000000000000000000000000000000000..c95d0d9132dc2174ce697f684b757010c13e77f2 GIT binary patch literal 7141 zcmaKRby$?&+BGF1Eea?#G=eb05JQKQNQZ#ZFf%a33>^{<ASsA6LrRJwNT(nnogz|0 zch}H@e0bjTJMZ_$cfRMkp6A|sUu&&<-Fx4E?I%)KTaEJegWGs`c$Df-l=W|7-p$KF zN__JbK_jki!hH`F6AuFv+{4@24Th%(McKdr>dw}7FnyRc)Yr8KCWD7Z2tXK`c$jEu zO4*{Eg{=Q#gnXP`ZrFHuGV(qy*0zo?4}cBK4uO>A*lYa80YE@yIgG`$Kw2(JFnh$4 zmu@hFm)eH5FCA?qp&asZ02v>t8v$pShc&>**$L?`<s-}SFI}md@!w@22jE{24@X&! z|1o8vr3+9(xxoNpLLfm~kT?h+E-WN0A_{>(9s$50VGs}m1`2}(g&|TRU?~s?@b8D? zCYu`+E~T%m`tMvfGg%IM4-Xe9Akf>}TgY2P2<2u66qb~f{Hp;53*I0E-F=ZB);@wr zcg}wllwt0+ZU`3-1PTfGt7vV5^7N49xN-VFB{;kMM;7V+?`^u-FrbgM3s6`H^tYsc zfLdDrf2gzbf6(q8`mq1?`~MVnH}rLZ0rg?-C{H)rn}dUM{!Qf~rQ`;)_CUEAqEJr% z?4qtc$^+$Yk8%Mh8HfRl5lAS?+x=f?EiEZ^q`QYT(iWz!EX#4j7eXMQQV?-*h!{i( zqzD2%78X_!eyl1Xtom40Q4$0Ki9*0C|8SL2ww}%~q{ly8=>Kws|10-zBRIR<WLAc` zA-rHvRX3C~;9mtxA^xkE$149-@84YLfAw->{J+%!yfFj(d#wN0G5@o4(>s5M|7qHr z$$#1&hP>%@x0|Mp$~vXM!(%j6S5`Finc6lbGkexme?6Dk*R%})yy>Pl*42%u`+h5> zZuG^{m@3weZa_cX{O5Rcjrvs4K(YFiXrz&rzi^~pv9D`n6qBoBUQrRc!c13zKBzAc z=q-H(->vsqX1CIGyy#uqb05Tr*bRbk+1IB5BJQwYz<gj|gXh-%9>;I;{t;}4baTJY zZT<pQFlMGtE8q&F^3#HPe~e8!)10)Gy~U=w)g_M@CHD<a01_DVM=$5HBR?pvTd)D& zHh_+pa-HpPw^SrsEM3szHbzs$^H%`{=}f)NY|-_s+j7Os1T<HNudXwU_<ecDYo)a} zvtrXlF$JIWv9+#!xTQUfIX-uHcT}H**S5)Ta9l1t{=pB<k2dnqz=V_pV&xk1S7loh z1em9o2_SfxrFe$c%!)6)3E34F_{~fvPhR$f_n1>GZZ(eo2^&B#C0dD1e<sN>$(3@T zgp-q?>Fq|<W`D(IST=LL?pOY=Dc;Ex-S5E^tsap!BRnJM%Zjvu=9kXezfVfc)7<8y zjAlD<-1&%nfhXiDx)p}+iX72q=XUA=6LZ`c&yVqb8;t_rr3!ozJI%lVakYNC<MF6d zxy4%Jh@pv7<LW*f?Og0#EPIJawfW>d7XR_%oytXA$s$C`f!EPE*92aC=AU#{YUsh8 zR87_taw&95c4Aqm_mJ&?dS3`7Ud<nCw{q>$m-3-BF!|*8VCT1vox$W#Y*u61KJ4Or zdui><pP+IM^>5Gi_Uc}4x-AHJ3MLc57xd{kp34p$lare`R!Zv{T5o52mF`1d6fTVJ z8u()Tv{!`pJ0Mk6s&qapS8Z4FoS_<fyfo58OY1-Ku$3+1BPr@BQJMW*Pcsl;bvxj_ zJ?f{up7u!{ZhDIVu<(=3bf54;I&Ld7j*1Y0Oo3o%$=M}LI4L=$SHI_!>Zt;sbM01o z=^m4^Zsl+5#cD$f`o0qS?D`AGq_coARl~8d#wtsVgr0GSYV1Ql_KmJzFi42OqV0() z(eD5`PY?gY*urSW3<(JbbGXrLe|(e!byLcp)tJo&{NEx%3$f|n{JVB(?#gG1Eie>_ zX|+FlDp^61WLuQA!a#XX=lBE%D&$c`X+-bHq7L_q6!S>JhuCStSn74pTo9h^x{}qR z6UNz!w^L?OdR_<q)e{(j@2xKQ1-b;eeC0UmS$tBK@|}1u7$^6mMs4Qqx4k-v%k|UY zh6mW<4lk;NuZ}eMaZ`hzOOx;*PY-L6_joPUcApfUIVGLVq+n$&xvl%^<JH}aG@qO5 z>Q5RSyU<V-J8Y3`OUG45GM0!3KG~L*&q}U1EYUf+KADQyRQC3+P5YD<rtD39+VBo9 z+dXjh;<6L&4*LCj2ny9nh1gA_s-<G%d(%2|z}?IYw*|(!F?%0>LS@9o4hq^T(hhhl zHCV^%KR#fgY7Nf{Qb<d1-&v(TexX(TEyd4>Y3m5ryl1sNtf?{KT09XaM2z|Q_P#kG zA~ALO-r{>kF3kkK`&Pu_mIuCYlK#3Qs{VC{_B*t9!3UUPE$sITig@o@b)NVGs($-- zXki1JQf%Mt^0$0?#xp_pQ=VS5{mODKeLODUU?xTECP}a9>(W-YKzPY8$k?G!vz-v| zf%W&r^e<R~YNxCuO8-z364Sf5RRGMj^K80m0x~%=T{ul){%Aij+zVFu+4cER>1T~n zN3b9FG5I-e;w+-&K#4OoTe5UyV)RHJ!62@3dLp~EP>OjliRIPO_9)5&d~BN#<>)qk z71aCel`(qVrt@tZ0s}=4MzK722>yA8Or!yQUO{Tc=8DG?HIBGrrG0k`{aS2<>-@2F z%}#%8rU1e+C)JA!t4y4MrGo0i&8DdGBQxt55FEq)QfGy4?#HmyJunNbIY>P6ick4s zcMr3YAWfACD}0a>)cl!l+NzRM7T253Ur>=#_*KfLf1Ta0@=$|jc`v}C47;+-+MAsw zz2N(@L*EdYVN)3KI|y_w%MIDWe2a2by2$N;{t(%}H(Qj+vR-^DlW8iRl3Mm1>D~P) zdSKyd@v;`ano?`m@w=glqpzojmTP{C@6&E%;kQuxDVX!0x}Dboj#9!FFrTuy`vjc1 zZ7;1a)^i@s;hIWF)*w}>GpgS^m_@}!yXp{$YxG)d=7$^21_swv$hEAvyzoFd&(Znk zS#nJ#=Vxie1||-VE#YGQ*{t<MI^K{!_%{6?$BQ>fxW5yzk?oHlVg}&2@78+8v$I*k z{2M_u@Z3I=`f!r-K!%HFx?aD0iJpe^C03Io|2!ON)&CiQ2+x-#!5$BpSMP*Ma+<%N z9vC4DQL1m?`qDcJs3_Ag>jO3%^-s?^%6P68RCdXBfy0iE+j5GJDGaAianDlsJsd=V zmp^*+leh0xH*H^01(i9%x8oYqLD%bKhd&njB8z7yPd0}FrEouaKX5zk4obh0)5Wt< zr4g}Fblcl|3Avpabih6$U*<XWd$jJ$B={EMr4F{)7i%$<5eZ?{x-?#|)owLmy>sWz z^2Wxbb%|C1H=le`Q0K@<jm$TELYhmf+oL<Pt|kwxOQph%Y%NT)o-$C>wkY#?wz7=P z4G*I$Dk^R_P&8v}uJTqa>z$3an-ya&6m<JTj7Y59NfU2_;?j1!^zjG8Nzyv1B1cq{ z<Hw#q<PM#|zx8n%8PeaXulI029_JS{Cr~7pwO5Aws>jYRlb+vffPFnUc3*m1m$=Ox z)f9QTV=C<*iSIhU*aeC(+~85V`Xy-Jjcvo9j9cgY&~7)pbWM`DjUD}{=>4<iRq~}k zZHYPqsX=9=!a7=oK$YBp;B7~sK=mEGlEf)e^mbZ-csgA)0m=I-FVGZ<BrjxF(!K+1 zd9R9wkubP<BlmRYXH@F`e0+A>$goQnczg1^c5MD4=!)^{FvB6%C`ii6q#aq6Sjg#e z#5O-BP~L@qrA9&)j8{<Cwh2foH`G3}q1UwH56KiT7l7I{Q&36ZVB5FqDcnlk2skI) z9vWjZ6uS39O;5Km#nHpZQnt1EJiLt>fTy9DWykPo8gYF!ipg_&3EP2Q+df*EKe9yu zHrI0${_gG~nmlxuS6Al&8XDx&Gc&$&A|DhL75!Zt9UO*7CnCxsNY{jv4aAt#qp|~j zOpFpyH@O!N!Yf;y#M>1$+x4lbsZC0Z0{3=y2C@Z`GN}=6H28hF#Mr)M8zq`+yYM<9 z43`0qMVaQ9#6cnhNoo7@S;cGDYI2$EOz{eGsx^p7R{L|+5?vb5(><1Gk`$RSXTWC2 zGg8KNvn_`P>k#k!hCc5Mv_F~k-0wMLKs(%oGG~Ee`6<hBLRf~bJfE#a&Y*js<IwpX ze;?883;nQDHl0@E`g;@ppK0`hSbYLoL45XbJNjQ%OA9j0jr#Zr9dC6ly&w7c00Q5Q ze%O)j`eL})6k=>uK2`42ix<7YHrh1&PU_X{SKl%b1C@~dF;kTFK$;k%wAUlK%Y7xP ztZ@rJN?x6;?^D%|3x&THPrrOot~eKc{kiGu%#*a36*lvh)I?g7GAp?(|3h^OW(gY8 zTBM4HhbWI$+UwJ~S8Q@}a!)ihm*=+TzP<XebNGI@Tnbtn^lr}evn1~RdAUHS&%j00 zl|eVkd2&*PM#{ho=;AVUi`S~;ttlQi`G6G_rPf`?6<IJRjvDjD2cmCRR#hPULWgQt z2!G6Ma6lZ#*?7mdrTra(VAv;sT&CoCnIid7K#;;ltkI#f#pSx=a?-f%YMI==oAJ`n zZ#P$o-^8p;41Ln4^95i{)1=OU7^9MTif6idv2j-f*cOu)KcgQCoZ==?1*|cYCk+B1 za3}VwugF_w$>6mtKdKi5W=2Nz6vTvbXY+)}RiiH!F*A+cA;GMvLjm~g?j)~i-$dv+ zz000^`!IlHu}Mc>$<6IfMP+5V&w-88R25mJ-O%czK93){Dkjwq_X2V0a~`rAD*Fmt zl8}nYrs)-C=<EBUFGxk9Su=NYnP3HYVHZCQ1Vgkph>FdL%D#rw)yDOvKx*1_ii2y7 z@adZRI@`6`N)Y8UjhMl?X3C3Ukk9L|!*xtSzmxa(M5J7lxRDbfMtvSXN`IV*%8~O? ze9=XXcaNRZLybLFM%hLCw62AQE5C`eo-bu?-&y&btC^!e-2P-;<n%g<al;#T$2x}( z_+j)3{P9}^nf0io*X7xaEpr4X8|n9xwN8WkB-#vy?9<m{8%c9Jb$DKPHS(ZVNlTkC zFXhk`$kJYL!p7QK_{Pr<wpSO&8I%l<OwbGM;kM_8E9=-=;Kk8K2q}2TKU8syKygc} z94`OB^+Da6r<zRC%zLk%z2?pG2^L`^6cjnI8_Zxw^Kb%zvE$XQOR68_$7fVzg^$O3 zU8VMTv{#KexyRTzZ3uLqp*jmIxm`Y}OP#iou0M0LCoN%P5qV$O6D--YU@!VS&Z|DS zGRN@{@$2cOy&=(s52EPY%Sj?JHlObmMdW^~SlUDhJ(K9^ZB_a@3al^9fzt1Vvr^IM zG~qbH#By#zZo*Gtxpn*M36ctxkkarubWnF5xIDH$Nb5t;_*n;Ev1slWwOjqqFl7nP zy-d>HkC5OTl}cFKc^@fGHmmJL1^M~<&Ff4W)M0%5*0mIv-iY~C)JHPPgBY)rn#dwN zi%{hX>Q>CmyCL-8o<YC+n`x#$pfwz$I^p*t7o3lif7Q${Erss?a-^YK?$NrqN05g> z_or6%DFmVQEG>t$4uc3uBoZ<uTnVJTcb5Sa<m4eKDGbr7oE8Dc&%S?`L!Z&eQ@ErC z(Xrjpnq&vDfso)rozjk>td|7XT9lfe9<3q&J=M3&J@_qXW;(i%qazQQqhX~C=f<w- zW$lkE%XU)-Th0u67ItkZ3`nbMU}s+9pObMfvsKz!NX$(1Ynrs8UuVC@9#xIxv#@T2 z6QpgUb_Y7P^IhaVIz!*at{N_SSc}b`Srb@H_*0FOp+&+&^=1V5AmU1S`qR=PHNC&~ z_gK2WEOo{#B6$31<!!n2vpq|<+5ViN)>p=vewEzLFU7V5t%>cBL_|j_C?$|>CYupV zy^+`xqt**Ch|8eqz+rs0s*AdtHlsWDTGG7lpuF#ez2-ldEg&gx<5O6$|NiGQm@4c# z<K7UZdSOl)(E8})2gk4md8TTpimlE5xRP;CA_TCoGIVfwx^&=vNOs=}^EEs9&8iU- zD+^srk1KoX^$G3fFg=w`$qTF?Nbc(BC!df|XIm(_Bqx}jg1flQzj=S(<?CUufPH>T z=y`ls^V6;(%Y-56edq4xKhgZ}gVHZF9<b~5r;9L2m4pGYAb5tfx6oTw*(legPV31E z7^8fkjJVT8OUMIwO`|{{61?5>h}XcO%Wf#TGw+q8VyWh>)66`AV^W-Z7l|6VB%{2f zUi6RUHqbCw2wJKQ-0UL@2}UeR7olbjj`B@pYIg4yesjIc3N4fme90B@s9t43D0s;< zqEJ9=mXz#B5xGE_1;$)=6H!Sh1qzdFm0=7P)ZaI_a>s^zuF6fG6Is;+im_Mg;1e9f zqcP%C5WzuNy_1YzJ?JSz52Bj=M$2pift84@B`tJuM-GAHr?f9^Pov|RchunFY+MSe z7Tk7mIROEZG#D{IcfC8WQt;!?#rh!G3zdHuM3!`C>^mDt+<N-^K8E~u&rS$>L-_*M zM5Z`9g{*eo7{Tha3)2XztGi|u!Q~3HKeR{P6R1<STdg%xPv%(hwUOs`KpC}?s8-d~ zxY3!Ln)Y$JcjoV`bTC+c6`(6&zmC;vj3t9wh~|8G2Kn*bDB+<{n+Wykl9ivozi4uR zPx2#W+QEC{i@zife6DbPU#U*MmQDs!|0J)keiBL9a(JH*6m5dbBs4xKejY-rnQ%Q) z&2LAecEvjZJEiK3$hV%pY)Fj`icrUsEE>MZt*SUl4%yxr$_`Ke^#09*;NAdU-7EwA zA@#m)sN8G%R;Jbl)3@8_(dO&d>-t<eTJ!k*kmruf4;J1G^b&lQ)a}4%2+@_<z-34b z1TZ-U%hbXkZk1C9+-Yi$&sJAYDkK+3|A#wM0p6Kro^sGur8p7zDOD2^s{DXkP7;YH zo!fzSWFMxF_l??f-y@;m=jShT92Xi)q;Pt48y?~%E=WoL<`x+lS<$CYiwQ-EmmcsD zjPL33&N9~P_Jddy*W5~uQ0w{{&swS4m>4H<sIP5%+~c$LQ3;**(wfZxa*6od%Lq!p zg#w*H+r@dSL*A<&%45M8pH*8ChSems#rno}2lFcxal5f3T=?Rba2)NVMr?hLwS=*W z_L727_@$|pDt(!M!#;13@#gT;_m}C9Z(Yx~V0%rzFulJW`}*q{zYtGHO9;NWGt)FV zFsC-17CS}{m@p1KeBsEH>gm8ljMW*bWX|fkRR1=7*2p@cXf5YoNN*%|AXd8$0BT0L zH&Fkggx`ign2-|Gw|RMhUS9O%T<rFS^7#6A;CZI;p3*82%DPmxzJ{Edty;l?278Ap zCD5|f4q2-y<F5o9-#se3xz(bw<b|$^0RU(qe*GBh^W~E9t#et^Y{TMA#}MztH-2dI z@2T9&yD|ws&fou>YbA&`$H4Bk+_JigC-LQSE{JSgpP|@p^dYo>!Y99wF~sb?;Up?! zi-|@v9Y;!Q=@QGa6!ec<RQyR~EFhP0u)x`KbRO-6;!#u1P9(Ko?F230ck}aqIFa6E ziGJjAzPaQ%ER0tV{xWS52ArnZPd)37LaK~J*R$G%$BLY3MU39540o_feX;!&zR9(x zw)@hG)6dt19!i&p8L=FUT8d*yn67w<4E!}(PEpkXNq=`}+4xSgWt-`J7dHVsP=#=A z_u_b)9Xf)_jp$wfSP798qYr|{-$z?cUy2Fcc>^^szA|d*4yK_uuVr|M>*(yPaXy&Q zD`h4=X;QSBUNcKSIN5YVsC|fc_44;}kdI1Dvd@{%>wE-w_h^PhCwd-Wn~c8FWS5*` z>v|=PspKJ?Uj3jyue2&7H_ens+8ykumGMWoY;)#rH?X+vl6HYn8t|?&lqXp=rpQX( ztXOnbn$eaOqd|K}ynF4b79D1Eq;>2fH0~qNAgh2xTDTZL+{=R5)2sfZ_zZZ3)b}S{ zEttNLwD<ZL$MIO~;`C$@zT(lUHCt{>nx9fS?nYC&l92+Z=v-#c@$p%~KQjoJW1A(Z z<a#qlO--hR&>~k!8#sOC*oC|$v{O)Y06Zcol;o`@o{=KuTca~VV|cP3mvS&D&+Ca0 zZfGTBhN$KI*suQnpfb~xkQ={d3d){6q)ks)<S6W#5)29D;m0~#(|@d2X*uQ>s24FZ z6B1gRhpskPsLneLeP-CsBnrsPn4--uK6korw>H`{GaKr<^PTHT=DjIw#ew>@=A=J1 zi0l9|V_vfp*d2f{btZH1V!DrsMK6+Tuj$N`-g^OD78<Ct#a`O{Zg=ofxF9F&M7xz& zX-<2_y^#j_$6^jxrI{DXaNNAo(ojX7%;yv}_pR1^2U!?N=HU6S{K<!5$*}1T-8(<{ zUTp48)F6M-m}+D+z?kOfw+E4$`yre(wZjZ!VK{Rj6&)U-+Bes(CFu2-O>S$SBoP$J zOFyjx?^;)myhwkRV$fb=v6C^7Z|W<aQjs8&_~NV@k3*Z4=*4Gx6G0<4yU*{+XV`B) zS*Bu=XDy_8^6_)<B@s7%+{Y;4PtzOOhfiL(xLMewb~Wv3xw}hP0pL3`v3*SAxX_)q zCh<Yy3zKVgh_z^k3Cg9FZ--CnImM5nGpWCjtm3v<X$x}h@JZmCoe|VMm9vILCUmFT zmNwOXqNF6y<YB@enDu(y-#-M_mn+YR9HDQ-G24pV;)>ap$?FJHO&}92fu}w^G^PcK z-K}qoYn)d_kKSRN>HgzD7L5dxR1qmaB+uWu(euUmhS42IOVYIyzv2WXi;0Vel_jv( zmTbj|WbSX{%q9mZY}IR2x~ay%0C3AJ@nH9c*`$p)A(!+(JJlHfacic~Qdx&pggoOW z68q=*VM%Sw)pmhQI6+H-viUM0eKtGsXIEk_{vT}HNNk&`$5f4iiouh5eI+NJrLJ#x zwH=n%8i@kO`Y=)xzCcV!b_4Blzpiw*Ke@~kXkft<Pe><w_>@q16uN{<p_lC4c0`)O z-sA?QKn4jnqeulx`PNIXu^R1w&WHJI?}%r31Fd+2uR}a6b+CT~r+AJo0mW*~0vz3b x7w>Q42w^Ad`Cx<qn)YQwuG((xr8ycOPhSA2l<xa1{O^x9bro&p(#KZ8{|DC6bguva literal 0 HcmV?d00001 diff --git a/dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleC/view/adminhtml/images/logo.png b/dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleC/view/adminhtml/images/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..8714f9f01c0ff47aa7020b8c380ca5cac3a44a4f GIT binary patch literal 1869 zcmaJ?X;c$u6dgst5{RWJ2%=60tzaRUBrM68uw_`%k_aJ|RHzt|Aq+5?I2lYtp;QsA zt%9~3YTY=Zv|0tRt_TVOtx(YlxUgv{ic)c_O5LiRSh4+4I_J!M%enWy``-7yGoQvP zqMRH&8~^}tl0~CRX0*O;<L#L5S4StK%-~K(sOfkzl{RZA3<%SaDHtdtG<r;lX>>~# zHDh7`umN$EnpVqW5G_e?G*%49LKqn~0Ej~@MvXQDqrntRj~gV=ont2;5Z6hdgaA1# zH%hTIJUW}g;<FVhZFYuMq=Q0&L9qp41PF}QfEFUtU_vYs=%p^g%&ps82z&{lGbGU8 zrquFSP)br57{G!3v~VB{2J$#Ofqzg?kT1xGc`z5|b9sC}UJxSSBQOlUdLSkmrAtMW zXymI{%t`{K(X<iaa?NHl$1LEGl%C5Ii9}WnKHrZ)_?ea%XpP0sVDcJKKrxe+!i_Xe z8bGU}CWXwRB@pBE?-U5*YgvQoRhgKAaV;7nm&bvvDUAT-^8bet#A~#PR$~A7{ZC<& zYKal!Dlrq8MQNFXOZBpbG9pq6)6gWPBFW5=D#oUfG-*mBji59>08GFQI?`-<iI&R| znZZPB3|dTvN+5>M!EqfD$P)>|g+ghN6b|I^BKRT{g+<bEf00NK7K93gBV3f!W)YZy z9^vZ#;i98*t&Kn!naC(c;fpa{Bt;V7%Y+epbT46}>b>IXM)wjvDwoTc;aZRNU&lPM z#q^GK`nqYE#p|}m3{0<6OjE~V@35J>(jY^_RF<wGb^W^bP)GT9mz&)eoyx5*Pu@2; z{mXYt4kd@)w<S(2JeK@3)mJ^}MnAFdTb+L(46L}CCxpaJ-~V1c9MfhSQM_+rs{s)V zi@VQmeE>m~mwkVPcdSoNx2&nWQ!=k(eNED&pX}QA<TM>_I`X{xNp{G`Xf1bJ&xvdI zrrJ;wq!)}Y0`fMRft0Zg(uP6TM)$lA#nNQQ2J>)s_X~Ay!MQpUYi^I;Wxp#j06g2j zA}=QK^g*!4>(TW!`OWs9TW)^4#g-1;&YL4`PP8cM@@ti1^x*_=P||)TX?37^piMev zL$J;D*?9Vdv8-wBZjVhXfVjf$E9G!c=^t;|?Vg&M-dn%G?n-9~3z?AH@2`zdJu~F~ z{7KoWpWe*#<~iM}-ZjpS>J8{}7sO7#m0#=lco5xozUj)t99Ag%YUxU8a?u+el{<^F zPEH$BxFZK%(|hGpAmx*|BHaG_INP(Q8?smjW)64Cpm`3km*0>*v|+l?`BaV5Va_Gw zjDFd)Vo$brxw}owoT#o14m}I1T$5CGlgCs6Z7#VhL{l`1utX=7(q*A=(v0~izhbMy z#Q6I9@?gETgUA=n;hR@!<(XaH3gWFK=WEeE+fy=EZRYzB311B-%$VuoKO;h`z0lqH zIDnc}xh`_`4_$+CH}o;vW7mLEA$baF?M(E!evFL)_WXIu){^~#DKjUxu3H*TL^eCN z<g><H#6MHrsuJA0AsJr3BYf^y&*t`$ZY6#`=a+j2Dw|vTjETN)KD8@2_x$}Y+|-Li zwZ5{hLw%x~-+Hoddu!TLh+RU(&Kb$5M_)@;-EV_66gN*@7Ve{TypKG5lvKtpTw7em zT6}5C`})rt*Xs91+wY;4vRa*^+r%L}yE>1@Nd*ya-+QoSR!-?nFG=yHpxW*_r~avc zYxPI+d~;>*L1&=<;;-5#vqN_~carfNJ(9NEj&_5chTPk#kdj9>eu)vGF)K}z<<m1d z<|?0-%g5U{2KLUc{xUorSMIxU-ZNpVMmrV=E`5Hwp&y^}jbs+YYI?d+xs2`GniD#3 z(ruf|kN(fl#dk0HxO#My9H>XfZAdybuU?d~vQaL*u4?)7c>3MGQry3y_-N#Qm-ZlH z)6T$yQ7s3#=|C!b*RoZ$8{btH_z&zh85KkLaZy^CYe(oORZH1b7TuAG#zN1{%hL;k zEBmwKqLwEp78HF@LDu*WW{pcJSSu!vS8it&=SF3dQrm%$qQ11v@9nkCy;Gxhr%MH{ h4lNNY(yko_Y=CK{U$C=eU*}qXaIy#mS`of*`Cq=e*1iA$ literal 0 HcmV?d00001 diff --git a/dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleC/view/adminhtml/styles.css b/dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleC/view/adminhtml/styles.css new file mode 100644 index 00000000000..f2b2af06a53 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/View/_files/Magento/ModuleC/view/adminhtml/styles.css @@ -0,0 +1,31 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +.pp-general-uk > .entry-edit-head > .config-heading .heading strong, +.pp-method-payflow > .entry-edit-head > .config-heading .heading strong, +.pp-method-express > .entry-edit-head > .config-heading .heading strong, +.pp-method-general > .entry-edit-head > .config-heading .heading strong { padding-left:90px; background:url(images/logo.png) no-repeat 0 0px; line-height: 23px; } +.pp-method-general > .entry-edit-head > .config-heading:before { content:url(images/allinone.png); float:right; } +.payflow-settings-notice {padding-bottom: 1em;max-width: 660px;} +.payflow-settings-notice .important-label {color:red;} +.payflow-settings-notice ul.options-list {list-style:disc;padding:0 2em;} diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php index 8b217d4dca2..409678e85ac 100644 --- a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php +++ b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php @@ -45,7 +45,10 @@ class IndexTest extends \Magento\TestFramework\TestCase\AbstractController $logger = $this->getMock('Magento\Logger', array(), array(), '', false); $this->_customerSession = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Customer\Model\Session', array($logger)); - $this->_customerSession->login('customer@example.com', 'password'); + $service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Service\V1\CustomerAccountService'); + $customer = $service->authenticate('customer@example.com', 'password'); + $this->_customerSession->setCustomerDtoAsLoggedIn($customer); $this->_messages = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Message\ManagerInterface'); diff --git a/dev/tests/performance/framework/Magento/TestFramework/Helper/Categories.php b/dev/tests/performance/framework/Magento/TestFramework/Helper/Categories.php index d28f0e8421b..53a7cf6aa96 100644 --- a/dev/tests/performance/framework/Magento/TestFramework/Helper/Categories.php +++ b/dev/tests/performance/framework/Magento/TestFramework/Helper/Categories.php @@ -58,7 +58,7 @@ class Categories public function __construct() { - $rootCategoryId = $this->getObjectManager()->create('\Magento\Core\Model\StoreManager')->getDefaultStoreView() + $rootCategoryId = $this->getObjectManager()->create('Magento\Core\Model\StoreManager')->getDefaultStoreView() ->getRootCategoryId(); /** @var $category \Magento\Catalog\Model\Category */ diff --git a/dev/tests/static/framework/Magento/TestFramework/Utility/Classes.php b/dev/tests/static/framework/Magento/TestFramework/Utility/Classes.php index 436fa4dc94b..3a23141521b 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Utility/Classes.php +++ b/dev/tests/static/framework/Magento/TestFramework/Utility/Classes.php @@ -337,4 +337,15 @@ class Classes return $classes; } + /** + * Retrieve module name by class + * + * @param string $class + * @return string + */ + public static function getClassModuleName($class) + { + $parts = explode('\\', trim($class, '\\')); + return $parts[0] . '_' . $parts[1]; + } } diff --git a/dev/tests/static/framework/Magento/TestFramework/Utility/Files.php b/dev/tests/static/framework/Magento/TestFramework/Utility/Files.php index ec14f402d8d..4c4beb51d05 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Utility/Files.php +++ b/dev/tests/static/framework/Magento/TestFramework/Utility/Files.php @@ -759,4 +759,21 @@ class Files } return $result; } + + /** + * Check module existence + * + * @param string $moduleName + * @return bool + */ + public function isModuleExists($moduleName) + { + $key = __METHOD__ . "/{$moduleName}"; + if (!isset(self::$_cache[$key])) { + list($namespace, $module) = explode('_', $moduleName); + self::$_cache[$key] = file_exists("{$this->_path}/app/code/{$namespace}/{$module}"); + } + + return self::$_cache[$key]; + } } diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php index 9f57513e5c1..6b57235d7ad 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php @@ -65,6 +65,13 @@ class CompilerTest extends \PHPUnit_Framework_TestCase */ protected $_validator; + /** + * Class arguments reader + * + * @var \Magento\Interception\Code\InterfaceValidator + */ + protected $pluginValidator; + protected function setUp() { $this->_shell = new \Magento\Shell(new \Magento\OSInfo()); @@ -92,6 +99,7 @@ class CompilerTest extends \PHPUnit_Framework_TestCase $this->_validator->add(new \Magento\Code\Validator\ContextAggregation()); $this->_validator->add(new \Magento\Code\Validator\TypeDuplication()); $this->_validator->add(new \Magento\Code\Validator\ArgumentSequence()); + $this->pluginValidator = new \Magento\Interception\Code\InterfaceValidator(); } protected function tearDown() @@ -149,7 +157,7 @@ class CompilerTest extends \PHPUnit_Framework_TestCase /** * Checks if class is a real one or generated Factory - * @param $instanceName class name + * @param string $instanceName class name * @throws \PHPUnit_Framework_AssertionFailedError * @return bool */ @@ -277,6 +285,20 @@ class CompilerTest extends \PHPUnit_Framework_TestCase ); } + /** + * Test consistency of plugin interfaces + */ + public function testPluginInterfaces() + { + $invoker = new \Magento\TestFramework\Utility\AggregateInvoker($this); + $invoker( + function ($plugin, $type) { + $this->validatePlugins($plugin, $type); + }, + $this->pluginDataProvider() + ); + } + /** * Validate constructor integrity */ @@ -288,7 +310,10 @@ class CompilerTest extends \PHPUnit_Framework_TestCase $autoloader, $this->_generationDir ); - $generator = new \Magento\Code\Generator(null, $autoloader, $generatorIo); + $generator = new \Magento\Code\Generator($autoloader, $generatorIo, array( + \Magento\ObjectManager\Code\Generator\Factory::ENTITY_TYPE + => 'Magento\ObjectManager\Code\Generator\Factory', + )); $autoloader = new \Magento\Code\Generator\Autoloader($generator); spl_autoload_register(array($autoloader, 'load')); @@ -302,11 +327,59 @@ class CompilerTest extends \PHPUnit_Framework_TestCase spl_autoload_unregister(array($autoloader, 'load')); } + /** + * Validate plugin interface + * + * @param string $plugin + * @param string $type + */ + protected function validatePlugins($plugin, $type) + { + try { + $module = \Magento\TestFramework\Utility\Classes::getClassModuleName($type); + if (\Magento\TestFramework\Utility\Files::init()->isModuleExists($module)) { + $this->pluginValidator->validate($plugin, $type); + } + } catch (\Magento\Interception\Code\ValidatorException $exception) { + $this->fail($exception->getMessage()); + } + } + + /** + * Get application plugins + * + * @return array + */ + protected function pluginDataProvider() + { + $files = \Magento\TestFramework\Utility\Files::init()->getDiConfigs(); + $plugins = array(); + foreach ($files as $file) { + $dom = new \DOMDocument(); + $dom->load($file); + $xpath = new \DOMXPath($dom); + $pluginList = $xpath->query('//config/type/plugin'); + foreach ($pluginList as $node) { + /** @var $node \DOMNode */ + $type = $node->parentNode->attributes->getNamedItem('name')->nodeValue; + $type = \Magento\TestFramework\Utility\Classes::resolveVirtualType($type); + if ($node->attributes->getNamedItem('type')) { + $plugin = $node->attributes->getNamedItem('type')->nodeValue; + $plugin = \Magento\TestFramework\Utility\Classes::resolveVirtualType($plugin); + $plugins[] = array('plugin' => $plugin, 'intercepted type' => $type); + } + } + } + + return $plugins; + } + /** * Test DI compiler * * @depends testConfigurationOfInstanceParameters * @depends testConstructorIntegrity + * @depends testPluginInterfaces */ public function testCompiler() { @@ -319,4 +392,6 @@ class CompilerTest extends \PHPUnit_Framework_TestCase $this->fail($exception->getPrevious()->getMessage()); } } + + } diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/ArgumentsTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/ArgumentsTest.php index e91524bf031..237e36e3d10 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/ArgumentsTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/ArgumentsTest.php @@ -38,17 +38,35 @@ class ArgumentsTest extends \Magento\Test\Integrity\Phrase\AbstractTestCase */ protected $_phraseCollector; + + /** + * List of files that must be omitted + * + * @todo remove blacklist related logic when all files correspond to the standard + * @var array + */ + protected $blackList; + protected function setUp() { $this->_phraseCollector = new \Magento\Tools\I18n\Code\Parser\Adapter\Php\Tokenizer\PhraseCollector( new \Magento\Tools\I18n\Code\Parser\Adapter\Php\Tokenizer() ); + + $rootDir = \Magento\TestFramework\Utility\Files::init()->getPathToSource(); + $this->blackList = array( + // the file below is the only file where strings are translated without corresponding arguments + $rootDir . str_replace('/', DIRECTORY_SEPARATOR, '/app/code/Magento/Core/Helper/Js.php'), + ); } public function testArguments() { $errors = array(); foreach ($this->_getFiles() as $file) { + if (in_array($file, $this->blackList)) { + continue; + } $this->_phraseCollector->parse($file); foreach ($this->_phraseCollector->getPhrases() as $phrase) { if (preg_match_all('/%(\d+)/', $phrase['phrase'], $matches) || $phrase['arguments']) { diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt index b8e9e2e76bb..3e5fea104bb 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt @@ -68,3 +68,6 @@ dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/Sniffs/Annotati dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/Helper/Helper.php dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/Model/Model.php dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/code/Magento/FirstModule/Model/WithoutDependencies.php +dev/tests/integration/testsuite/Magento/Code/_expected/SourceClassWithNamespaceFactory.php +dev/tests/integration/testsuite/Magento/Code/_expected/SourceClassWithNamespaceInterceptor.php +dev/tests/integration/testsuite/Magento/Code/_expected/SourceClassWithNamespaceProxy.php diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt index 126b7949c0e..c39970fdd15 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt @@ -27,3 +27,4 @@ Zend PEAR_PackageFileManager2 PEAR Magento\LibFirst +\Magento\SomeModule\Exception diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/core.txt b/dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/core.txt index 4010d4ff6ed..f779ea7b6f9 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/core.txt +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/core.txt @@ -9,6 +9,7 @@ app/code/Magento/Downloadable app/code/Magento/GiftMessage app/code/Magento/Install app/code/Magento/Newsletter +app/code/Magento/OfflinePayments app/code/Magento/Payment app/code/Magento/Paypal app/code/Magento/Persistent diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php index 9260e13d43e..d8fc1b7f313 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -334,7 +334,7 @@ return array( 'Magento\Backend\Model\Config\Backend\Serialized\Array' ), array('Mage_Adminhtml_Model_System_Config_Backend_Shipping_Tablerate', - 'Magento\Shipping\Model\Config\Backend\Tablerate' + 'Magento\OfflineShipping\Model\Config\Backend\Tablerate' ), array('Mage_Adminhtml_Model_System_Config_Backend_Sitemap_Cron', 'Magento\Cron\Model\Config\Backend\Sitemap' @@ -527,10 +527,10 @@ return array( 'Magento\Shipping\Model\Config\Source\Allspecificcountries' ), array('Mage_Adminhtml_Model_System_Config_Source_Shipping_Flatrate', - 'Magento\Shipping\Model\Config\Source\Flatrate' + 'Magento\OfflineShipping\Model\Config\Source\Flatrate' ), array('Mage_Adminhtml_Model_System_Config_Source_Shipping_Tablerate', - 'Magento\Shipping\Model\Config\Source\Tablerate' + 'Magento\OfflineShipping\Model\Config\Source\Tablerate' ), array('Mage_Adminhtml_Model_System_Config_Source_Shipping_Taxclass', 'Magento\Tax\Model\Config\Source\TaxClass\Product' @@ -1616,6 +1616,7 @@ return array( array('Magento\Backend\Controller\AbstractAction', 'Magento\Backend\App\AbstractAction'), array('Magento\Backend\Controller\Context', 'Magento\Backend\App\Action\Context'), array('Magento\Backend\Controller\Adminhtml\Action', 'Magento\Backend\App\Action'), + array('Magento\Backend\Block\System\Shipping\Ups', 'Magento\Ups\Block\Backend\System\CarrierConfig'), array('Magento\Core\Block\Text', 'Magento\View\Element\Text'), array('Magento\Core\Block\Text\ListText', 'Magento\View\Element\Text\ListText'), array('Magento\Core\Block\Text\TextList\Item', 'Magento\View\Element\Text\TextList\Item'), @@ -1856,6 +1857,7 @@ return array( 'Magento\App\Dir\Verification', 'Magento\App\Filesystem\DirectoryList\Verification' ), + array('Magento\Backend\Helper\Addresses'), array('Magento\Core\Model\Cookie', 'Magento\Stdlib\Cookie'), array('Magento\Core\Model\Logger', 'Magento\Logger'), array('Magento\Core\Block\Template\Context', 'Magento\View\Element\Template\Context'), @@ -2157,6 +2159,75 @@ return array( ['Magento\Core\Helper\String', 'Magento\Code\NameBuilder'], ['Magento\Core\Model\Context', 'Magento\Model\Context'], ['Magento\Core\Model\Registry', 'Magento\Registry'], + ['Magento\Code\Plugin\InvocationChain'], ['Magento\Catalog\Helper\Product\Flat'], - ['Magento\Catalog\Helper\Flat\AbstractFlat'] + ['Magento\Catalog\Helper\Flat\AbstractFlat'], + [ + 'Magento\Core\Model\LocaleInterface', + 'Magento\Locale\ResolverInterface, Magento\Locale\CurrencyInterface,' + . 'Magento\Locale\FormatInterface, Magento\Stdlib\DateTime\TimezoneInterface' + ], + [ + 'Magento\Core\Model\Locale', + 'Magento\Locale\Resolver, Magento\Locale\Currency, Magento\Locale\Format, ' + . 'Magento\Stdlib\DateTime\Timezone, Magento\Locale\Lists' + ], + ['Magento\Core\Model\Locale\Hierarchy\Config\Converter', 'Magento\Locale\Hierarchy\Config\Converter'], + ['Magento\Core\Model\Locale\Hierarchy\Config\FileResolver', 'Magento\Locale\Hierarchy\Config\FileResolver'], + ['Magento\Core\Model\Locale\Hierarchy\Config\Reader', 'Magento\Locale\Hierarchy\Config\Reader'], + ['Magento\Core\Model\Locale\Hierarchy\Config\SchemaLocator', 'Magento\Locale\Hierarchy\Config\SchemaLocator'], + ['Magento\Core\Model\Locale\Config', 'Magento\Locale\Config'], + ['Magento\Core\Model\Locale\Validator', 'Magento\Locale\Validator'], + ['Magento\Core\Model\Date', 'Magento\Stdlib\DateTime\DateTime'], + ['Magento\Shipping\Model\Config\Source\Flatrate', 'Magento\OfflineShipping\Model\Config\Source\Flatrate'], + ['Magento\Shipping\Model\Carrier\Flatrate', 'Magento\OfflineShipping\Model\Carrier\Flatrate'], + ['Magento\Usa\Block\Adminhtml\Dhl\Unitofmeasure', 'Magento\Dhl\Block\Adminhtml\Unitofmeasure'], + ['Magento\Usa\Model\Shipping\Carrier\Dhl\International', 'Magento\Dhl\Model\Carrier'], + ['Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\AbstractMethod', 'Magento\Dhl\Model\Source\Method\AbstractMethod'], + ['Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Doc', 'Magento\Dhl\Model\Source\Method\Doc'], + ['Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Freedoc', 'Magento\Dhl\Model\Source\Method\Freedoc'], + ['Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Freenondoc', 'Magento\Dhl\Model\Source\Method\Freenondoc'], + ['Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Generic', 'Magento\Dhl\Model\Source\Method\Generic'], + ['Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Nondoc', 'Magento\Dhl\Model\Source\Method\Nondoc'], + ['Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Size', 'Magento\Dhl\Model\Source\Method\Size'], + ['Magento\Usa\Model\Shipping\Carrier\Dhl\International\Source\Method\Unitofmeasure', 'Magento\Dhl\Model\Source\Method\Unitofmeasure'], + ['Magento\Usa\Model\Shipping\Carrier\Dhl\AbstractDhl', 'Magento\Dhl\Model\AbstractDhl'], + ['Magento\Usa\Model\Shipping\Carrier\Dhl'], + ['Magento\Usa\Model\Shipping\Carrier\Fedex', 'Magento\Fedex\Model\Carrier'], + ['Magento\Usa\Model\Shipping\Carrier\Fedex\Source\Droppff', 'Magento\Fedex\Model\Source\Droppff'], + ['Magento\Usa\Model\Shipping\Carrier\Fedex\Source\Freemethod', 'Magento\Fedex\Model\Source\Freemethod'], + ['Magento\Usa\Model\Shipping\Carrier\Fedex\Source\Generic', 'Magento\Fedex\Model\Source\Generic'], + ['Magento\Usa\Model\Shipping\Carrier\Fedex\Source\Method', 'Magento\Fedex\Model\Source\Method'], + ['Magento\Usa\Model\Shipping\Carrier\Fedex\Source\Packaging', 'Magento\Fedex\Model\Source\Packaging'], + ['Magento\Core\App\Action\Plugin\Session', 'Magento\Core\Block\RequireCookie'], + ['Magento\Rma\Model\CarrierFactory'], + ['Magento\Usa\Helper\Data'], + ['Magento\Usa\Model\Shipping\Carrier\Ups\Source\Mode'], + ['Magento\Usa\Model\Shipping\Carrier\Ups\Source\Container', 'Magento\Ups\Model\Config\Source\Container'], + ['Magento\Usa\Model\Shipping\Carrier\Ups\Source\DestType', 'Magento\Ups\Model\Config\Source\DestType'], + ['Magento\Usa\Model\Shipping\Carrier\Ups\Source\Freemethod', 'Magento\Ups\Model\Config\Source\Freemethod'], + ['Magento\Usa\Model\Shipping\Carrier\Ups\Source\Generic', 'Magento\Ups\Model\Config\Source\Generic'], + ['Magento\Usa\Model\Shipping\Carrier\Ups\Source\Method', 'Magento\Ups\Model\Config\Source\Method'], + ['Magento\Usa\Model\Shipping\Carrier\Ups\Source\OriginShipment', 'Magento\Ups\Model\Config\Source\OriginShipment'], + ['Magento\Usa\Model\Shipping\Carrier\Ups\Source\Pickup', 'Magento\Ups\Model\Config\Source\Pickup'], + ['Magento\Usa\Model\Shipping\Carrier\Ups\Source\Type', 'Magento\Ups\Model\Config\Source\Type'], + ['Magento\Usa\Model\Shipping\Carrier\Ups\Source\Unitofmeasure', 'Magento\Ups\Model\Config\Source\Unitofmeasure'], + ['Magento\Usa\Model\Shipping\Carrier\Usps\Source\Container', 'Magento\Usps\Model\Source\Container'], + ['Magento\Usa\Model\Shipping\Carrier\Usps\Source\Freemethod', 'Magento\Usps\Model\Source\Freemethod'], + ['Magento\Usa\Model\Shipping\Carrier\Usps\Source\Generic', 'Magento\Usps\Model\Source\Generic'], + ['Magento\Usa\Model\Shipping\Carrier\Usps\Source\Machinable', 'Magento\Usps\Model\Source\Machinable'], + ['Magento\Usa\Model\Shipping\Carrier\Usps\Source\Method', 'Magento\Usps\Model\Source\Method'], + ['Magento\Usa\Model\Shipping\Carrier\Usps\Source\Size', 'Magento\Usps\Model\Source\Size'], + ['Magento\Usa\Model\Shipping\Carrier\Usps', 'Magento\Usps\Model\Carrier'], + ['Magento\Usa\Model\Shipping\Carrier\Ups', 'Magento\Ups\Model\Carrier'], + ['Magento\Usa\Model\Simplexml\Element', 'Magento\Shipping\Model\Simplexml\Element'], + ['Magento\Usa\Model\Shipping\Carrier\AbstractCarrier', 'Magento\Shipping\Model\Carrier\AbstractCarrierOnline'], + [ + 'Magento\Usa\Model\Shipping\Carrier\AbstractCarrier\Source\Mode', + 'Magento\Shipping\Model\Config\Source\Online\Mode' + ], + [ + 'Magento\Usa\Model\Shipping\Carrier\AbstractCarrier\Source\Requesttype', + 'Magento\Shipping\Model\Config\Source\Online\Requesttype' + ], ); diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_config_nodes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_config_nodes.php index e21573de224..373a1d22295 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_config_nodes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_config_nodes.php @@ -30,13 +30,13 @@ return array( '/config/global/cache/betatypes' => '', '/config/admin/fieldsets' => '', '/config/general/locale' => - 'This configuration moved to Di configuration of \Magento\Core\Model\Locale\Config model', + 'This configuration moved to Di configuration of \Magento\Locale\ConfigInterface', '/config/global/can_use_base_url' => 'This configuration moved to Di configuration of \Magento\Backend\App\Action\Context class', '/config/global/locale/allow/codes' => - 'This configuration moved to Di configuration of \Magento\Core\Model\Locale\Config model', + 'This configuration moved to Di configuration of \Magento\Locale\ConfigInterface', '/config/global/locale/allow/currencies' => - 'This configuration moved to Di configuration of \Magento\Core\Model\Locale\Config model', + 'This configuration moved to Di configuration of \Magento\Locale\ConfigInterface', '/config/global/mime/types' => 'This configuration moved to Di configuration for \Magento\Downloadable\Helper\File class', '/config/global/models/*/deprecatedNode' => '', diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php index 55c3b4fe457..afff898987e 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php @@ -69,24 +69,24 @@ return array( 'Mage_Core_Model_Resource', 'Magento_Core_Model_Config_Resource::DEFAULT_WRITE_CONNECTION' ), - array('DEFAULT_CURRENCY', 'Magento\Core\Model\Locale', 'Magento_Core_Model_LocaleInterface::DEFAULT_CURRENCY'), + array('DEFAULT_CURRENCY', 'Magento\Locale', 'Magento_Core_Model_LocaleInterface::DEFAULT_CURRENCY'), array('DEFAULT_ERROR_HANDLER', 'Magento\Core\Model\App'), array('DEFAULT_READ_CONNECTION', 'Magento\App\Resource\Config'), array('DEFAULT_WRITE_CONNECTION', 'Magento\App\Resource\Config'), array('DEFAULT_ERROR_HANDLER', 'Mage'), - array('DEFAULT_LOCALE', 'Magento\Core\Model\Locale', 'Magento_Core_Model_LocaleInterface::DEFAULT_LOCALE'), + array('DEFAULT_LOCALE', 'Magento\Locale', 'Magento_Core_Model_LocaleInterface::DEFAULT_LOCALE'), array('DEFAULT_THEME_NAME', 'Magento\Core\Model\Design\PackageInterface'), array('DEFAULT_THEME_NAME', 'Magento\Core\Model\Design\Package'), - array('DEFAULT_TIMEZONE', 'Magento\Core\Model\Locale', 'Magento_Core_Model_LocaleInterface::DEFAULT_TIMEZONE'), + array('DEFAULT_TIMEZONE', 'Magento\Locale', 'Magento_Core_Model_LocaleInterface::DEFAULT_TIMEZONE'), array('DEFAULT_STORE_ID', 'Magento\Catalog\Model\AbstractModel', 'Magento\Core\Model\Store::DEFAULT_STORE_ID'), array('DEFAULT_VALUE_TABLE_PREFIX'), array('ENTITY_PRODUCT', 'Magento\Review\Model\Review'), array('EXCEPTION_CODE_IS_GROUPED_PRODUCT'), array('FALLBACK_MAP_DIR', 'Magento\Core\Model\Design\PackageInterface'), - array('FORMAT_TYPE_FULL', 'Magento\Core\Model\Locale', 'Magento_Core_Model_LocaleInterface::FORMAT_TYPE_FULL'), - array('FORMAT_TYPE_LONG', 'Magento\Core\Model\Locale', 'Magento_Core_Model_LocaleInterface::FORMAT_TYPE_LONG'), - array('FORMAT_TYPE_MEDIUM', 'Magento\Core\Model\Locale', 'Magento_Core_Model_LocaleInterface::FORMAT_TYPE_MEDIUM'), - array('FORMAT_TYPE_SHORT', 'Magento\Core\Model\Locale', 'Magento_Core_Model_LocaleInterface::FORMAT_TYPE_SHORT'), + array('FORMAT_TYPE_FULL', 'Magento\Locale', 'Magento_Core_Model_LocaleInterface::FORMAT_TYPE_FULL'), + array('FORMAT_TYPE_LONG', 'Magento\Locale', 'Magento_Core_Model_LocaleInterface::FORMAT_TYPE_LONG'), + array('FORMAT_TYPE_MEDIUM', 'Magento\Locale', 'Magento_Core_Model_LocaleInterface::FORMAT_TYPE_MEDIUM'), + array('FORMAT_TYPE_SHORT', 'Magento\Locale', 'Magento_Core_Model_LocaleInterface::FORMAT_TYPE_SHORT'), array('GALLERY_IMAGE_TABLE', 'Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media'), array('HASH_ALGO'), array('INIT_OPTION_DIRS', 'Magento\Core\Model\App', 'Magento_Core_Model_App::PARAM_APP_DIRS'), @@ -140,6 +140,9 @@ return array( 'Magento\View\Publisher\FileInterface::PUBLIC_VIEW_DIR' ), array('REGISTRY_FORM_PARAMS_KEY', null, 'direct value'), + array('RULE_PERM_ALLOW', '\Magento\Math\Random'), + array('RULE_PERM_DENY', '\Magento\Math\Random'), + array('RULE_PERM_INHERIT', '\Magento\Math\Random'), array('SCOPE_TYPE_GROUP', 'Magento\Core\Model\App', 'Magento_Core_Model_StoreManagerInterface::SCOPE_TYPE_GROUP'), array('SCOPE_TYPE_STORE', 'Magento\Core\Model\App', 'Magento_Core_Model_StoreManagerInterface::SCOPE_TYPE_STORE'), array( @@ -172,10 +175,10 @@ return array( ), array( 'XML_PATH_ALLOW_CURRENCIES', - 'Magento\Core\Model\Locale', + 'Magento\Locale', 'Magento_Core_Model_LocaleInterface::XML_PATH_ALLOW_CURRENCIES' ), - array('XML_PATH_ALLOW_CODES', 'Magento\Core\Model\LocaleInterface'), + array('XML_PATH_ALLOW_CODES', 'Magento\LocaleInterface'), array('XML_PATH_ALLOW_DUPLICATION', 'Magento\Core\Model\Design\PackageInterface', 'Magento_Core_Model_Design_Package::XML_PATH_ALLOW_DUPLICATION' ), @@ -195,15 +198,15 @@ return array( 'Magento\View\Element\Template', 'Magento\Core\Model\TemplateEngine\Plugin::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS' ), - array('XML_PATH_DEFAULT_COUNTRY', 'Magento\Core\Model\Locale'), + array('XML_PATH_DEFAULT_COUNTRY', 'Magento\Locale'), array( 'XML_PATH_DEFAULT_LOCALE', - 'Magento\Core\Model\Locale', + 'Magento\Locale', 'Magento_Core_Model_LocaleInterface::XML_PATH_DEFAULT_LOCALE' ), array( 'XML_PATH_DEFAULT_TIMEZONE', - 'Magento\Core\Model\Locale', + 'Magento\Locale', 'Magento_Core_Model_LocaleInterface::XML_PATH_DEFAULT_TIMEZONE' ), array('XML_PATH_INDEXER_DATA', 'Magento\Index\Model\Process'), @@ -354,11 +357,16 @@ return array( array('CHARS_LOWERS', '\Magento\Core\Helper\Data', '\Magento\Math\Random::CHARS_LOWERS'), array('CHARS_UPPERS', '\Magento\Core\Helper\Data', '\Magento\Math\Random::CHARS_UPPERS'), array('CHARS_DIGITS', '\Magento\Core\Helper\Data', '\Magento\Math\Random::CHARS_DIGITS'), - array('CHARS_SPECIALS', '\Magento\Core\Helper\Data', '\Magento\Math\Random::CHARS_SPECIALS'), - array('CHARS_PASSWORD_LOWERS', '\Magento\Core\Helper\Data', '\Magento\Math\Random::CHARS_PASSWORD_LOWERS'), - array('CHARS_PASSWORD_UPPERS', '\Magento\Core\Helper\Data', '\Magento\Math\Random::CHARS_PASSWORD_UPPERS'), - array('CHARS_PASSWORD_DIGITS', '\Magento\Core\Helper\Data', '\Magento\Math\Random::CHARS_PASSWORD_DIGITS'), - array('CHARS_PASSWORD_SPECIALS', '\Magento\Core\Helper\Data', '\Magento\Math\Random::CHARS_PASSWORD_SPECIALS'), + array('CHARS_SPECIALS', '\Magento\Core\Helper\Data'), + array('CHARS_SPECIALS', '\Magento\Math\Random'), + array('CHARS_PASSWORD_LOWERS', '\Magento\Core\Helper\Data'), + array('CHARS_PASSWORD_LOWERS', '\Magento\Math\Random'), + array('CHARS_PASSWORD_UPPERS', '\Magento\Core\Helper\Data'), + array('CHARS_PASSWORD_UPPERS', '\Magento\Math\Random'), + array('CHARS_PASSWORD_DIGITS', '\Magento\Core\Helper\Data'), + array('CHARS_PASSWORD_DIGITS', '\Magento\Math\Random'), + array('CHARS_PASSWORD_SPECIALS', '\Magento\Core\Helper\Data'), + array('CHARS_PASSWORD_SPECIALS', '\Magento\Math\Random'), array('XML_NODE_REMOTE_ADDR_HEADERS', '\Magento\Core\Helper\Http'), array( 'XML_PATH_EU_COUNTRIES_LIST', diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index 0def4c17ae0..42ac62fcca8 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -133,7 +133,7 @@ return array( array('_inludeControllerClass', '', '_includeControllerClass'), array('_isApplyDesign', 'Magento\Catalog\Model\Design'), array('_isApplyFor', 'Magento\Catalog\Model\Design'), - array('_isPositiveDecimalNumber', 'Magento\Shipping\Model\Resource\Carrier\Tablerate'), + array('_isPositiveDecimalNumber', 'Magento\OfflineShipping\Model\Resource\Carrier\Tablerate'), array('_isRuntimeValidated', 'Magento\ObjectManager\Config\Reader\Dom'), array('_loadCache', 'Magento\Backend\Model\Menu\Config'), array('_loadCache', 'Magento\Core\Model\Config'), @@ -151,7 +151,7 @@ return array( array('_getAddressForm', 'Magento\Sales\Block\Adminhtml\Order\Create\Form\Address'), array('_parseDescription', 'Magento\Sales\Model\Order\Pdf\Items\AbstractItems'), array('_parsePackageTheme', 'Magento\Widget\Model\Widget\Instance'), - array('_parseXmlTrackingResponse', 'Magento\Usa\Model\Shipping\Carrier\Fedex'), + array('_parseXmlTrackingResponse', 'Magento\Fedex\Model\Carrier'), array('_prepareCondition', 'Magento\CatalogSearch\Model\Advanced'), array('_prepareConfigurableProductData', 'Magento\ImportExport\Model\Export\Entity\Product'), array('_prepareConfigurableProductPrice', 'Magento\ImportExport\Model\Export\Entity\Product'), @@ -268,7 +268,7 @@ return array( array('chechAllowedExtension'), array('checkConfigurableProducts', 'Magento\Eav\Model\Resource\Entity\Attribute\Collection'), array('checkDatabase', 'Magento\Install\Model\Installer\Db'), - array('checkDateTime', 'Magento\Core\Model\Date'), + array('checkDateTime', 'Magento\Stdlib\DateTime\DateTime'), array('chooseTemplate', 'Magento\Checkout\Block\Cart'), array('cleanCache', 'Magento\Core\Model\Config'), array('cleanDbRow', 'Magento\App\Resource'), @@ -379,6 +379,8 @@ return array( array('getDirectOutput', 'Magento\Core\Model\Layout'), array('getDirectOutput', 'Magento\View\LayoutInterface'), array('getDistroServerVars', 'Magento\Core\Model\Config', 'getDistroBaseUrl'), + array('getDuplicateButtonHtml', 'Magento\Catalog\Block\Adminhtml\Product\Edit'), + array('getElementBackendConfig', 'Magento\Paypal\Helper\Data'), array('getElementClass', 'Magento\Core\Model\Layout\Update'), array('getEngineFactory', 'Magento\View\Element\Template\Context', 'getEnginePool'), array('getEntityIdsToIncrementIds', 'Magento\Rss\Model\Resource\Order'), @@ -664,7 +666,7 @@ return array( array('orderedAction', 'Magento\Backend\Controller\Report\Product'), array('output', 'Magento_Shell'), array('pageHandleExists', 'Magento\Core\Model\Layout\Update', 'Magento\Core\Model\Layout\Merge'), - array('parseDateTime', 'Magento\Core\Model\Date'), + array('parseDateTime', 'Magento\Stdlib\DateTime\DateTime'), array('postDispatchMyAccountSave'), array('postDispatchSystemImportExportRun'), array('prepareAddressInfo', 'Magento\Sales\Block\Recurring\Profile\View'), @@ -998,7 +1000,7 @@ return array( array('copyFieldsetToTarget', 'Magento\Core\Helper\Data', 'Magento\Object\Copy::copyFieldsetToTarget'), array('formatDate', '\Magento\Core\Helper\Data', '\Magento\Core\Model\Locale::formatDate'), array('formatTime', '\Magento\Core\Helper\Data', '\Magento\Core\Model\Locale::formatTime'), - array('_getConfigTimezone', '\Magento\Core\Model\Date', '\Magento\Core\Model\Locale::getConfigTimezone'), + array('_getConfigTimezone', '\Magento\Stdlib\DateTime\DateTime', '\Magento\Core\Model\Locale::getConfigTimezone'), array('_filterPostData', '\Magento\Checkout\Controller\Onepage'), array('_filterPostData', '\Magento\Customer\Controller\Account'), array('_filterPostData', '\Magento\Customer\Controller\Adminhtml\Index'), @@ -1029,8 +1031,8 @@ return array( '\Magento\App\Response\RedirectInterface::getRefererUrl' ), array('_isUrlInternal', '\Magento\Core\Controller\Varien\Action'), - array('_filterDateTime', '\Magento\Core\Controller\Varien\Action', '\Magento\Core\Filter\DateTime::filter'), - array('_filterDates', '\Magento\Core\Controller\Varien\Action', '\Magento\Core\Filter\Date::filter'), + array('_filterDateTime', '\Magento\Core\Controller\Varien\Action', '\Magento\Stdlib\DateTime\Filter\DateTime::filter'), + array('_filterDates', '\Magento\Core\Controller\Varien\Action', '\Magento\Stdlib\DateTime\Filter\Date::filter'), array('_initDesign', '\Magento\Core\Controller\Varien\Action', '\Magento\Core\Model\DesignLoader::load'), array('_firePreDispatchEvents', '\Magento\Core\Controller\Varien\Action'), @@ -1197,7 +1199,7 @@ return array( array( 'catalogProductPrepareSave', '\Magento\PricePermissions\Model\Observer', '\Magento\PricePermissions\Controller\Adminhtml\Product\Initialization\Helper\Plugin\PricePermissions::' - . 'afterInitialize' + . 'afterInitialize' ), array( 'getGroupedOptions', '\Magento\Catalog\Helper\Product\Configuration', @@ -1320,4 +1322,43 @@ return array( array('sendTransactional', 'Magento\Email\Model\Template'), array('_getMail', 'Magento\Email\Model\Template'), array('send', 'Magento\Email\Model\Template'), + ['setDefaultLocale', 'Magento\Core\Model\Locale', 'Magento\Locale\Resolver'], + ['getDefaultLocale', 'Magento\Core\Model\Locale', 'Magento\Locale\Resolver'], + ['setLocale', 'Magento\Core\Model\Locale', 'Magento\Locale\Resolver'], + ['getLocale', 'Magento\Core\Model\Locale', 'Magento\Locale\Resolver'], + ['getLocaleCode', 'Magento\Core\Model\Locale', 'Magento\Locale\Resolver'], + ['setLocaleCode', 'Magento\Core\Model\Locale', 'Magento\Locale\Resolver'], + ['emulate', 'Magento\Core\Model\Locale', 'Magento\Locale\Resolver'], + ['revert', 'Magento\Core\Model\Locale', 'Magento\Locale\Resolver'], + ['getTimezone', 'Magento\Core\Model\Locale', 'Magento\Stdlib\DateTime\Timezone::getDefaultTimezone'], + ['getDateFormat', 'Magento\Core\Model\Locale', 'Magento\Stdlib\DateTime\Timezone'], + ['getDateFormatWithLongYear', 'Magento\Core\Model\Locale', 'Magento\Stdlib\DateTime\Timezone'], + ['getTimeFormat', 'Magento\Core\Model\Locale', 'Magento\Stdlib\DateTime\Timezone'], + ['getDateTimeFormat', 'Magento\Core\Model\Locale', 'Magento\Stdlib\DateTime\Timezone'], + ['date', 'Magento\Core\Model\Locale', 'Magento\Stdlib\DateTime\Timezone'], + ['storeDate', 'Magento\Core\Model\Locale', 'Magento\Stdlib\DateTime\Timezone::scopeDate'], + ['utcDate', 'Magento\Core\Model\Locale', 'Magento\Stdlib\DateTime\Timezone'], + ['storeTimeStamp', 'Magento\Core\Model\Locale', 'Magento\Stdlib\DateTime\Timezone::scopeTimeStamp'], + ['formatDate', 'Magento\Core\Model\Locale', 'Magento\Stdlib\DateTime\Timezone'], + ['getTranslation', 'Magento\Core\Model\Locale', 'Magento\Stdlib\DateTime\Timezone::_getTranslation'], + ['getCurrency', 'Magento\Core\Model\Locale', 'Magento\Locale\Currency'], + ['currency', 'Magento\Core\Model\Locale', 'Magento\Locale\Currency::getCurrency'], + ['getNumber', 'Magento\Core\Model\Locale', 'Magento\Locale\Format'], + ['getJsPriceFormat', 'Magento\Core\Model\Locale', 'Magento\Locale\Format::getPriceFormat'], + ['getOptionLocales', 'Magento\Core\Model\Locale', 'Magento\Locale\Lists'], + ['getTranslatedOptionLocales', 'Magento\Core\Model\Locale', 'Magento\Locale\Lists'], + ['getOptionTimezones', 'Magento\Core\Model\Locale', 'Magento\Locale\Lists'], + ['getOptionWeekdays', 'Magento\Core\Model\Locale', 'Magento\Locale\Lists'], + ['getOptionCountries', 'Magento\Core\Model\Locale', 'Magento\Locale\Lists'], + ['getOptionCurrencies', 'Magento\Core\Model\Locale', 'Magento\Locale\Lists'], + ['getTranslationList', 'Magento\Core\Model\Locale', 'Magento\Locale\Lists'], + ['getCountryTranslation', 'Magento\Core\Model\Locale', 'Magento\Locale\Lists'], + ['getCountryTranslationList', 'Magento\Core\Model\Locale', 'Magento\Locale\Lists'], + ['getAllowLocales', 'Magento\Core\Model\Locale'], + ['getAllowCurrencies', 'Magento\Core\Model\Locale'], + ['convertMeasureWeight', 'Magento\Usa\Helper\Data', 'Magento\Shipping\Helper\Carrier::convertMeasureWeight'], + ['convertMeasureDimension', 'Magento\Usa\Helper\Data', 'Magento\Shipping\Helper\Carrier::convertMeasureDimension'], + ['getMeasureWeightName', 'Magento\Usa\Helper\Data', 'Magento\Shipping\Helper\Carrier::getMeasureWeightName'], + ['getMeasureDimensionName', 'Magento\Usa\Helper\Data', 'Magento\Shipping\Helper\Carrier::getMeasureDimensionName'], + ['displayGirthValue', 'Magento\Usa\Helper\Data', 'Magento\Usps\Helper\Data::displayGirthValue'], ); diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php index 2884cf65bea..53d9736dcd7 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php @@ -91,7 +91,7 @@ return array( array('_setAttributes', 'Magento\Catalog\Model\Product\Type\AbstractType'), array('_skipFieldsByModel'), array('_ship_id'), - array('_shipTable', 'Magento\Shipping\Model\Resource\Carrier\Tablerate\Collection'), + array('_shipTable', 'Magento\OfflineShipping\Model\Resource\Carrier\Tablerate\Collection'), array('_showTemplateHints', 'Magento\View\Element\Template', 'Magento\Core\Model\TemplateEngine\Plugin\DebugHints'), array('_showTemplateHintsBlocks', 'Magento\View\Element\Template', @@ -126,7 +126,7 @@ return array( array('_fileIo', '\Magento\Theme\Model\Uploader\Service', '_filesystem'), array('_streamFactory', '\Magento\Core\Model\File\Storage\Config', '_filesystem'), array('_streamFactory', '\Magento\Core\Model\File\Storage\Synchronization', '_filesystem'), - array('_allowedFormats', '\Magento\Core\Helper\Data', '\Magento\Core\Model\Locale'), + array('_allowedFormats', '\Magento\Core\Helper\Data', '\Magento\Locale'), array('types', '\Magento\Core\Model\Theme'), array('_collectionFactory', '\Magento\Install\Controller\Action', 'themeProvider'), array('_collectionFactory', '\Magento\Theme\Model\Config\Customization', 'themeProvider'), @@ -198,7 +198,7 @@ return array( array('_dirs', 'Magento\Core\Block\Template'), array('_applicationDirs', 'Magento\Core\Model\Config\FileResolver'), array('_dir', 'Magento\Core\Model\File\Storage'), - array('_dir', 'Magento\Core\Model\Locale\Hierarchy\Config\FileResolver'), + array('_dir', 'Magento\Locale\Hierarchy\Config\FileResolver'), array('_dirs', 'Magento\Core\Block\Template\Context'), array('_dir', 'Magento\Core\Model\Page\Asset\MergeService'), array('_dir', 'Magento\Core\Model\Page\Asset\MinifyService'), diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt index 9236edc3e92..24a99856aa9 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/blacklist/common.txt @@ -24,6 +24,8 @@ dev/tests/integration/testsuite/Magento/DB/Adapter/Pdo/MysqlTest.php dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php dev/tests/integration/testsuite/Magento/Test/Integrity/Theme/TemplateFilesTest.php dev/tests/integration/testsuite/Magento/Backend/Block/System/Config/FormStub.php +dev/tests/integration/testsuite/Magento/Interception/Fixture +dev/tests/integration/testsuite/Magento/Code/_expected dev/tests/integration/tmp dev/tests/static/testsuite/Magento/Test/Php/Exemplar/CodeMessTest/phpmd/input dev/tests/static/testsuite/Magento/Test/Php/Exemplar/CodeStyleTest/phpcs/input @@ -31,7 +33,6 @@ dev/tests/static/testsuite/Magento/Test/Php/Exemplar/CodeStyleTest/phpcs/expecte dev/tests/static/testsuite/Magento/Test/Legacy/_files dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/MysqlStub.php dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/Option/ValueTest.php -dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleObjectManager.php dev/tests/unit/testsuite/Magento/Core/Model/Resource/Db/AbstractTest.php dev/tests/unit/testsuite/Magento/Core/Model/Session/ConfigTest.php dev/tests/unit/testsuite/Magento/View/TemplateEngine/_files diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt index 153d35ec1fc..e689d073141 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt @@ -48,7 +48,6 @@ Magento/Core/Model/Layout/File/Source/Override Magento/Core/Model/Store Magento/Cron/Model/Config/Backend/Product Magento/Customer/Block/Account/Dashboard -Magento/Customer/Block/Adminhtml/Edit/Tab Magento/Customer/Model/Config/Backend/Show Magento/Customer/Model/Metadata Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code @@ -86,7 +85,7 @@ Magento/CatalogRule/Model Magento/Tax/Block/Checkout Magento/Tax/Model/Sales/Pdf Magento/Tax/Model/Config/Price -Magento/Usa/Model/Shipping/Carrier +Magento/Usps/Model Magento/Webapi/Block/Adminhtml Magento/Webapi/Model Magento/Widget/Model/Widget/Instance @@ -114,3 +113,7 @@ Magento/Newsletter/Model/Template/Filter Magento/Newsletter/Model/Resource/Subscriber Magento/CatalogInventory/Model/Resource/Stock/Item lib/Magento/Filesystem/Driver +Magento/OfflineShipping/Model/Carrier +Magento/Usps/Model/Carrier +Magento/Dhl/Model +Magento/Shipping/Model diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt index b547e1c49dc..fa516c87da7 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt @@ -39,8 +39,6 @@ app/code/Magento/Core/data app/code/Magento/Core/Model/Config app/code/Magento/Core/Model/Design.php app/code/Magento/Core/Model/Layout/Update.php -app/code/Magento/Core/Model/Locale/Validator.php -app/code/Magento/Core/Model/LocaleInterface.php app/code/Magento/Core/Model/Resource/Theme app/code/Magento/Core/Model/Resource/Theme.php app/code/Magento/Core/Model/Session/Validator.php @@ -55,8 +53,8 @@ app/code/Magento/Cron/Model/Config/SchemaLocator.php app/code/Magento/Cron/Model/Config.php app/code/Magento/Cron/Model/ConfigInterface.php app/code/Magento/Directory/Helper -app/code/Magento/Customer/Block/Account/{Authorization,Register}Link.php -app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Account.php +app/code/Magento/Customer/Block +app/code/Magento/Customer/Controller app/code/Magento/Customer/Model/Address/Config app/code/Magento/Customer/Model/Address/Config.php app/code/Magento/Customer/Service @@ -139,3 +137,4 @@ lib/Magento/Service lib/Magento/Url/SecurityInfoInterface.php lib/Magento/View lib/Magento/App/AbstractShell.php +lib/Magento/Locale/Validator.php diff --git a/dev/tests/unit/framework/Magento/Test/Block/Adminhtml.php b/dev/tests/unit/framework/Magento/Test/Block/Adminhtml.php index 34ef9902be3..6b4f0831548 100644 --- a/dev/tests/unit/framework/Magento/Test/Block/Adminhtml.php +++ b/dev/tests/unit/framework/Magento/Test/Block/Adminhtml.php @@ -84,9 +84,6 @@ class Adminhtml extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Core\Model\StoreManager */ protected $_storeManagerMock; - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Core\Model\LocaleInterface */ - protected $_localeMock; - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Math\Random */ protected $_mathMock; @@ -121,7 +118,6 @@ class Adminhtml extends \PHPUnit_Framework_TestCase $escaperMock = $this->_makeMock('Magento\Escaper'); $filterManagerMock = $this->_makeMock('Magento\Filter\FilterManager'); $backendSessionMock = $this->_makeMock('Magento\Backend\Model\Session'); - $this->_localeMock = $this->_makeMock('Magento\Core\Model\LocaleInterface'); $appState = $this->_makeMock('Magento\App\State'); $this->_mathMock = $this->_makeMock('Magento\Math\Random'); $this->_formKey = $this->_makeMock('Magento\Data\Form\FormKey'); @@ -152,7 +148,6 @@ class Adminhtml extends \PHPUnit_Framework_TestCase $appMock, $escaperMock, $filterManagerMock, - $this->_localeMock, $this->_filesystemMock, $viewFileSystemMock, $templatePoolMock, diff --git a/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Helper/ObjectManagerTest.php b/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Helper/ObjectManagerTest.php index f31f7050716..51a51f06632 100644 --- a/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Helper/ObjectManagerTest.php +++ b/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Helper/ObjectManagerTest.php @@ -42,8 +42,7 @@ class ObjectManagerTest extends \PHPUnit_Framework_TestCase 'cache' => 'Magento\App\CacheInterface', 'design' => 'Magento\View\DesignInterface', 'session' => 'Magento\Session\SessionManagerInterface', - 'storeConfig' => 'Magento\Core\Model\Store\Config', - 'frontController' => 'Magento\App\FrontController' + 'storeConfig' => 'Magento\Core\Model\Store\Config' ); /** diff --git a/dev/tests/unit/testsuite/Magento/App/Action/ForwardTest.php b/dev/tests/unit/testsuite/Magento/App/Action/ForwardTest.php index 256c9dd6620..35da548a378 100644 --- a/dev/tests/unit/testsuite/Magento/App/Action/ForwardTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Action/ForwardTest.php @@ -43,7 +43,7 @@ class ForwardTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_request = $this->getMock('Magento\App\Request\Http', array(), array(), '', false ); - $this->_response = $this->getMock('\Magento\App\Response\Http'); + $this->_response = $this->getMock('\Magento\App\Response\Http', array(), array(), '', false); $this->_actionAbstract = new \Magento\App\Action\Forward( $this->_request, @@ -88,8 +88,10 @@ class ForwardTest extends \PHPUnit_Framework_TestCase { $infoProcessorMock = $this->getMock('Magento\App\Request\PathInfoProcessorInterface'); $routerListMock = $this->getMock('Magento\App\Route\ConfigInterface'); + $cookieMock = $this->getMock('Magento\Stdlib\Cookie', array(), array(), '', false); + $contextMock = $this->getMock('Magento\App\Http\Context', array(), array(), '', false); $request = new \Magento\App\Request\Http($routerListMock, $infoProcessorMock); - $response = new \Magento\App\Response\Http(); + $response = new \Magento\App\Response\Http($cookieMock, $contextMock); $response->headersSentThrowsException = false; $action = new \Magento\App\Action\Forward($request, $response); diff --git a/dev/tests/unit/testsuite/Magento/App/FrontController/Plugin/ClickjackingTest.php b/dev/tests/unit/testsuite/Magento/App/FrontController/Plugin/ClickjackingTest.php index de74e8cc295..02f778fe155 100644 --- a/dev/tests/unit/testsuite/Magento/App/FrontController/Plugin/ClickjackingTest.php +++ b/dev/tests/unit/testsuite/Magento/App/FrontController/Plugin/ClickjackingTest.php @@ -30,45 +30,51 @@ class ClickjackingTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\App\FrontController\Plugin\Clickjacking */ - protected $_plugin; + protected $plugin; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_responseMock; + protected $responseMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; protected function setUp() { - $this->_responseMock = $this->getMock('Magento\App\Response\Http', array(), array(), '', false); - $this->_plugin = new \Magento\App\FrontController\Plugin\Clickjacking(); + $this->responseMock = $this->getMock('Magento\App\Response\Http', array(), array(), '', false); + $this->subjectMock = $this->getMock('Magento\App\FrontController', array(), array(), '', false); + $this->plugin = new \Magento\App\FrontController\Plugin\Clickjacking(); } public function testAfterDispatchIfHeaderExist() { - $this->_responseMock + $this->responseMock ->expects($this->once()) ->method('getHeader') ->with('X-Frame-Options') ->will($this->returnValue(false)); - $this->_responseMock + $this->responseMock ->expects($this->once()) ->method('setHeader') ->with('X-Frame-Options', 'SAMEORIGIN') - ->will($this->returnValue($this->_responseMock)); - $this->assertEquals($this->_responseMock, $this->_plugin->afterDispatch($this->_responseMock)); + ->will($this->returnValue($this->responseMock)); + $this->assertEquals($this->responseMock, $this->plugin->afterDispatch($this->subjectMock, $this->responseMock)); } public function testAfterDispatchIfHeaderNotExist() { - $this->_responseMock + $this->responseMock ->expects($this->once()) ->method('getHeader') ->with('X-Frame-Options') ->will($this->returnValue(true)); - $this->_responseMock + $this->responseMock ->expects($this->never()) ->method('setHeader'); - $this->assertEquals($this->_responseMock, $this->_plugin->afterDispatch($this->_responseMock)); + $this->assertEquals($this->responseMock, $this->plugin->afterDispatch($this->subjectMock, $this->responseMock)); } } \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/App/FrontControllerTest.php b/dev/tests/unit/testsuite/Magento/App/FrontControllerTest.php index 24da577f171..8dd39bae0a0 100644 --- a/dev/tests/unit/testsuite/Magento/App/FrontControllerTest.php +++ b/dev/tests/unit/testsuite/Magento/App/FrontControllerTest.php @@ -77,8 +77,10 @@ class FrontControllerTest extends \PHPUnit_Framework_TestCase $this->_routerList->expects($this->atLeastOnce())->method('valid')->will($this->returnValue(true)); $this->_routerList->expects($this->atLeastOnce())->method('current')->will($this->returnValue($this->_router)); $controllerInstance = $this->getMock('Magento\App\ActionInterface'); + $response = $this->getMock('Magento\App\Response\Http', [], [], '', false); + $controllerInstance->expects($this->any())->method('getResponse')->will($this->returnValue($response)); $this->_router->expects($this->atLeastOnce())->method('match')->will($this->returnValue($controllerInstance)); - $controllerInstance->expects($this->atLeastOnce())->method('dispatch')->with($this->_request); + $controllerInstance->expects($this->any())->method('dispatch')->with($this->_request); $this->_model->dispatch($this->_request); } } diff --git a/app/code/Magento/Backend/Helper/Addresses.php b/dev/tests/unit/testsuite/Magento/App/PageCache/IdentifierTest.php similarity index 52% rename from app/code/Magento/Backend/Helper/Addresses.php rename to dev/tests/unit/testsuite/Magento/App/PageCache/IdentifierTest.php index a7a4b722bd1..79726e136d5 100644 --- a/app/code/Magento/Backend/Helper/Addresses.php +++ b/dev/tests/unit/testsuite/Magento/App/PageCache/IdentifierTest.php @@ -18,36 +18,31 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Adminhtml * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\App\PageCache; -/** - * Adminhtml addresses helper - * - * @category Magento - * @package Magento_Adminhtml - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\Backend\Helper; - -class Addresses extends \Magento\App\Helper\AbstractHelper +class IdentifierTest extends \PHPUnit_Framework_TestCase { - const DEFAULT_STREET_LINES_COUNT = 2; - - /** - * Check if number of street lines is non-zero - * - * @param \Magento\Customer\Model\Attribute $attribute - * @return \Magento\Customer\Model\Attribute - */ - public function processStreetAttribute(\Magento\Customer\Model\Attribute $attribute) + public function testGetValue() { - if ($attribute->getScopeMultilineCount() <= 0) { - $attribute->setScopeMultilineCount(self::DEFAULT_STREET_LINES_COUNT); - } - return $attribute; + $uri = 'index.php/customer'; + $vary = 1; + $expected = md5(serialize([$uri, $vary])); + + $requestMock = $this->getMockBuilder('\Magento\App\Request\Http') + ->disableOriginalConstructor() + ->getMock(); + $requestMock->expects($this->once()) + ->method('getRequestUri') + ->will($this->returnValue($uri)); + $requestMock->expects($this->once()) + ->method('get') + ->with($this->equalTo(\Magento\App\Response\Http::COOKIE_VARY_STRING)) + ->will($this->returnValue($vary)); + $model = new \Magento\App\PageCache\Identifier($requestMock); + $result = $model->getValue(); + $this->assertEquals($expected, $result); } } diff --git a/dev/tests/unit/testsuite/Magento/App/PageCache/KernelTest.php b/dev/tests/unit/testsuite/Magento/App/PageCache/KernelTest.php new file mode 100644 index 00000000000..b47f7cb0348 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/App/PageCache/KernelTest.php @@ -0,0 +1,206 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\App\PageCache; + +class KernelTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Kernel + */ + protected $kernel; + + /** + * @var \Magento\App\PageCache\Cache|\PHPUnit_Framework_MockObject_MockObject + */ + protected $cacheMock; + + /** + * @var \Magento\App\PageCache\Identifier|\PHPUnit_Framework_MockObject_MockObject + */ + protected $identifierMock; + + /** + * @var \Magento\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * Setup + */ + public function setUp() + { + $this->cacheMock = $this->getMock('Magento\App\PageCache\Cache', array(), array(), '', false); + $this->identifierMock = $this->getMock('Magento\App\PageCache\Identifier', array(), array(), '', false); + $this->requestMock = $this->getMock('Magento\App\Request\Http', array(), array(), '', false); + $this->kernel = new Kernel($this->cacheMock, $this->identifierMock, $this->requestMock); + $this->responseMock = $this->getMockBuilder('Magento\App\Response\Http') + ->setMethods(array('getHeader', 'getHttpResponseCode', 'setNoCacheHeaders', 'clearHeader')) + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * @dataProvider loadProvider + * @param mixed $expected + * @param string $id + * @param mixed $cache + * @param bool $isGet + * @param bool $isHead + */ + public function testLoad($expected, $id, $cache, $isGet, $isHead) + { + $this->requestMock + ->expects($this->once()) + ->method('isGet') + ->will($this->returnValue($isGet)); + $this->requestMock + ->expects($this->any()) + ->method('isHead') + ->will($this->returnValue($isHead)); + $this->cacheMock + ->expects($this->any()) + ->method('load') + ->with($this->equalTo($id)) + ->will($this->returnValue(serialize($cache))); + $this->identifierMock + ->expects($this->any()) + ->method('getValue') + ->will($this->returnValue($id)); + $this->assertEquals($expected, $this->kernel->load()); + } + + /** + * @return array + */ + public function loadProvider() + { + $data = array(1, 2, 3); + return array( + array($data, 'existing key', $data, true, false), + array($data, 'existing key', $data, false, true), + array(new \Magento\Object($data), 'existing key', new \Magento\Object($data), true, false), + array(false, 'existing key', $data, false, false), + array(false, 'non existing key', false, true, false), + array(false, 'non existing key', false, false, false), + ); + } + + public function testProcessSaveCache() + { + $cacheControlHeader = 'public, max-age=100, s-maxage=100'; + $httpCode = 200; + + $this->responseMock + ->expects($this->at(0)) + ->method('getHeader') + ->with('Cache-Control') + ->will($this->returnValue(array('value' => $cacheControlHeader))); + $this->responseMock + ->expects($this->once()) + ->method('getHttpResponseCode') + ->will($this->returnValue($httpCode)); + $this->requestMock + ->expects($this->once()) + ->method('isGet') + ->will($this->returnValue(true)); + $this->responseMock + ->expects($this->once()) + ->method('setNoCacheHeaders'); + $this->responseMock + ->expects($this->at(3)) + ->method('getHeader') + ->with('X-Magento-Tags'); + $this->responseMock + ->expects($this->at(4)) + ->method('clearHeader') + ->with($this->equalTo('Set-Cookie')); + $this->responseMock + ->expects($this->at(5)) + ->method('clearHeader') + ->with($this->equalTo('X-Magento-Tags')); + $this->cacheMock + ->expects($this->once()) + ->method('save'); + $this->kernel->process($this->responseMock); + } + + /** + * @dataProvider processNotSaveCacheProvider + * @param string $cacheControlHeader + * @param int $httpCode + * @param bool $isGet + * @param bool $overrideHeaders + */ + public function testProcessNotSaveCache($cacheControlHeader, $httpCode, $isGet, $overrideHeaders) + { + $this->responseMock + ->expects($this->once()) + ->method('getHeader') + ->with('Cache-Control') + ->will($this->returnValue(array('value' => $cacheControlHeader))); + $this->responseMock + ->expects($this->any()) + ->method('getHttpResponseCode') + ->will($this->returnValue($httpCode)); + $this->requestMock + ->expects($this->any()) + ->method('isGet') + ->will($this->returnValue($isGet)); + if ($overrideHeaders) { + $this->responseMock + ->expects($this->once()) + ->method('setNoCacheHeaders'); + } + $this->cacheMock + ->expects($this->never()) + ->method('save'); + $this->kernel->process($this->responseMock); + } + + /** + * @return array + */ + public function processNotSaveCacheProvider() + { + return array( + array('private, max-age=100', 200, true, false), + array('private, max-age=100', 200, false, false), + array('private, max-age=100', 404, true, false), + array('private, max-age=100', 500, true, false), + array('no-store, no-cache, must-revalidate, max-age=0', 200, true, false), + array('no-store, no-cache, must-revalidate, max-age=0', 200, false, false), + array('no-store, no-cache, must-revalidate, max-age=0', 404, true, false), + array('no-store, no-cache, must-revalidate, max-age=0', 500, true, false), + array('public, max-age=100, s-maxage=100', 404, true, true), + array('public, max-age=100, s-maxage=100', 500, true, true), + array('public, max-age=100, s-maxage=100', 200, false, true), + ); + } +} diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Rounding.php b/dev/tests/unit/testsuite/Magento/App/PageCache/PageCacheTest.php similarity index 60% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Rounding.php rename to dev/tests/unit/testsuite/Magento/App/PageCache/PageCacheTest.php index 036156f8ac4..e256bcaf69c 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Protection/Rounding.php +++ b/dev/tests/unit/testsuite/Magento/App/PageCache/PageCacheTest.php @@ -18,27 +18,25 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\App\PageCache; - -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\Source\Protection; - -class Rounding extends \Magento\Usa\Model\Shipping\Carrier\Dhl\Source\Generic +class PageCacheTest extends \PHPUnit_Framework_TestCase { - /** - * {@inheritdoc} - */ - public function toOptionArray() + public function testIdentifierProperty() { - $carrier = $this->_shippingDhl; - $arr = array(); - foreach ($carrier->getAdditionalProtectionRoundingTypes() as $k=>$v) { - $arr[] = array('value'=>$k, 'label'=>$v); - } - return $arr; + $identifier = 'page_cache'; + + $poolMock = $this->getMockBuilder('\Magento\App\Cache\Frontend\Pool') + ->disableOriginalConstructor() + ->getMock(); + $poolMock->expects($this->once()) + ->method('get') + ->with($this->equalTo($identifier)) + ->will($this->returnArgument(0)); + $model = new \Magento\App\PageCache\Cache($poolMock); + $this->assertInstanceOf('Magento\App\PageCache\Cache', $model); } } diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/VersionTest.php b/dev/tests/unit/testsuite/Magento/App/PageCache/VersionTest.php similarity index 86% rename from dev/tests/unit/testsuite/Magento/PageCache/Model/VersionTest.php rename to dev/tests/unit/testsuite/Magento/App/PageCache/VersionTest.php index 655979f1c7f..0d76c2fc3b7 100644 --- a/dev/tests/unit/testsuite/Magento/PageCache/Model/VersionTest.php +++ b/dev/tests/unit/testsuite/Magento/App/PageCache/VersionTest.php @@ -18,40 +18,34 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_PageCache * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\PageCache\Model; +namespace Magento\App\PageCache; -/** - * Class VersionTest - * @package Magento\PageCache\Model - */ class VersionTest extends \PHPUnit_Framework_TestCase { /** - * Cookie mock + * Version instance * - * @var \Magento\Stdlib\Cookie|\PHPUnit_Framework_MockObject_MockObject + * @var Version */ - private $cookieMock; + protected $version; /** - * Request mock + * Cookie mock * - * @var \Magento\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Stdlib\Cookie|\PHPUnit_Framework_MockObject_MockObject */ - private $requestMock; + protected $cookieMock; /** - * Version instance + * Request mock * - * @var Version + * @var \Magento\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ - private $versionInstance; + protected $requestMock; /** * Create cookie and request mock, version instance @@ -60,7 +54,7 @@ class VersionTest extends \PHPUnit_Framework_TestCase { $this->cookieMock = $this->getMock('Magento\Stdlib\Cookie', array('set'), array(), '', false); $this->requestMock = $this->getMock('Magento\App\Request\Http', array('isPost'), array(), '', false); - $this->versionInstance = new Version($this->cookieMock, $this->requestMock); + $this->version = new Version($this->cookieMock, $this->requestMock); } /** @@ -81,7 +75,7 @@ class VersionTest extends \PHPUnit_Framework_TestCase if ($isPost) { $this->cookieMock->expects($this->once())->method('set'); } - $this->versionInstance->process(); + $this->version->process(); } /** diff --git a/dev/tests/unit/testsuite/Magento/App/Resource/ConfigTest.php b/dev/tests/unit/testsuite/Magento/App/Resource/ConfigTest.php index f9573a3ad05..a19513d1b5c 100644 --- a/dev/tests/unit/testsuite/Magento/App/Resource/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Resource/ConfigTest.php @@ -78,7 +78,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ), ); - $this->_cacheMock->expects($this->once()) + $this->_cacheMock->expects($this->any()) ->method('load') ->will($this->returnValue(serialize($this->_resourcesConfig))); diff --git a/dev/tests/unit/testsuite/Magento/App/Response/HttpTest.php b/dev/tests/unit/testsuite/Magento/App/Response/HttpTest.php index 8072cce6d87..85584af1119 100644 --- a/dev/tests/unit/testsuite/Magento/App/Response/HttpTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Response/HttpTest.php @@ -30,9 +30,21 @@ class HttpTest extends \PHPUnit_Framework_TestCase */ protected $_model; + /** + * @var \Magento\Stdlib\Cookie|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_cookieMock; + + /** + * @var \Magento\App\Http\Context + */ + protected $_context; + protected function setUp() { - $this->_model = new \Magento\App\Response\Http(); + $this->_cookieMock = $this->getMock('Magento\Stdlib\Cookie', array(), array(), '', false); + $this->_context = new \Magento\App\Http\Context(); + $this->_model = new Http($this->_cookieMock, $this->_context); $this->_model->headersSentThrowsException = false; $this->_model->setHeader('name', 'value'); } @@ -54,13 +66,90 @@ class HttpTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->_model->getHeader('Test')); } - public function testGetVaryString() + public function testSendVary() { $vary = array('some-vary-key' => 'some-vary-value'); - ksort($vary); $expected = sha1(serialize($vary)); - $this->_model->setVary('some-vary-key', 'some-vary-value'); - $this->assertEquals($expected, $this->_model->getVaryString()); + $this->_context->setValue('some-vary-key', 'some-vary-value'); + $this->_cookieMock + ->expects($this->once()) + ->method('set') + ->with(Http::COOKIE_VARY_STRING, $expected); + $this->_model->sendVary(); + } + + /** + * Test setting public cache headers + */ + public function testSetPublicHeaders() + { + $ttl = 120; + $pragma = 'cache'; + $cacheControl = 'public, max-age=' . $ttl . ', s-maxage=' . $ttl; + $between = 1000; + + $this->_model->setPublicHeaders($ttl); + $this->assertEquals($pragma, $this->_model->getHeader('Pragma')['value']); + $this->assertEquals($cacheControl, $this->_model->getHeader('Cache-Control')['value']); + $expiresResult = time($this->_model->getHeader('Expires')['value']); + $this->assertTrue($expiresResult > $between || $expiresResult < $between); + } + + + /** + * Test for setting public headers without time to live parameter + */ + public function testSetPublicHeadersWithoutTtl() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'time to live is a mandatory parameter for set public headers' + ); + $this->_model->setPublicHeaders(null); + } + + /** + * Test setting public cache headers + */ + public function testSetPrivateHeaders() + { + $ttl = 120; + $pragma = 'cache'; + $cacheControl = 'private, max-age=' . $ttl; + $expires = gmdate('D, d M Y H:i:s T', strtotime('+' . $ttl . ' seconds')); + + $this->_model->setPrivateHeaders($ttl); + $this->assertEquals($pragma, $this->_model->getHeader('Pragma')['value']); + $this->assertEquals($cacheControl, $this->_model->getHeader('Cache-Control')['value']); + $this->assertEquals($expires, $this->_model->getHeader('Expires')['value']); + } + + /** + * Test for setting public headers without time to live parameter + */ + public function testSetPrivateHeadersWithoutTtl() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'time to live is a mandatory parameter for set private headers' + ); + $this->_model->setPrivateHeaders(null); + } + + /** + * Test setting public cache headers + */ + public function testSetNoCacheHeaders() + { + $pragma = 'no-cache'; + $cacheControl = 'no-store, no-cache, must-revalidate, max-age=0'; + $expires = gmdate('D, d M Y H:i:s T', strtotime('-1 year')); + + $this->_model->setNoCacheHeaders(); + $this->assertEquals($pragma, $this->_model->getHeader('Pragma')['value']); + $this->assertEquals($cacheControl, $this->_model->getHeader('Cache-Control')['value']); + $this->assertEquals($expires, $this->_model->getHeader('Expires')['value']); } + } diff --git a/dev/tests/unit/testsuite/Magento/App/Route/Config/_files/routes.php b/dev/tests/unit/testsuite/Magento/App/Route/Config/_files/routes.php index 0f4663a055f..36e2e3c5130 100644 --- a/dev/tests/unit/testsuite/Magento/App/Route/Config/_files/routes.php +++ b/dev/tests/unit/testsuite/Magento/App/Route/Config/_files/routes.php @@ -29,26 +29,26 @@ return array( 'id' => 'adminhtml', 'frontName' => 'admin', 'modules' => array( - 'Magento_Sales', - 'Magento_Catalog', - 'Magento_Wishlist', - 'Magento_Adminhtml', - 'Magento_Customer', - 'Magento_Paypal', + 'Magento_ModuleA', + 'Magento_ModuleB', + 'Magento_ModuleC', + 'Magento_ModuleD', + 'Magento_ModuleE', + 'Magento_ModuleF', ), ), 'customer' => array( 'id' => 'customer', 'frontName' => 'customer', 'modules' => array( - 'Magento_Customer', + 'Magento_ModuleE', ), ), 'wishlist' => array( 'id' => 'wishlist', 'frontName' => 'wishlist', 'modules' => array( - 'Magento_Wishlist', + 'Magento_ModuleC', ), ), ), diff --git a/dev/tests/unit/testsuite/Magento/App/Route/Config/_files/routes.xml b/dev/tests/unit/testsuite/Magento/App/Route/Config/_files/routes.xml index 7d7add8c962..3f4bb1a4e11 100644 --- a/dev/tests/unit/testsuite/Magento/App/Route/Config/_files/routes.xml +++ b/dev/tests/unit/testsuite/Magento/App/Route/Config/_files/routes.xml @@ -26,18 +26,18 @@ <config> <router id="backend"> <route id="adminhtml" frontName="admin"> - <module name="Magento_Adminhtml" /> - <module name="Magento_Catalog" before="Magento_Adminhtml" /> - <module name="Magento_Wishlist" before="Magento_Adminhtml" /> - <module name="Magento_Sales" before="Magento_Catalog" /> - <module name="Magento_Customer" /> - <module name="Magento_Paypal" after="Magento_Customer" /> + <module name="Magento_ModuleD" /> + <module name="Magento_ModuleB" before="Magento_ModuleD" /> + <module name="Magento_ModuleC" before="Magento_ModuleD" /> + <module name="Magento_ModuleA" before="Magento_ModuleB" /> + <module name="Magento_ModuleE" /> + <module name="Magento_ModuleF" after="Magento_ModuleE" /> </route> <route id="customer" frontName="customer"> - <module name="Magento_Customer" before="Magento_Wishlist" /> + <module name="Magento_ModuleE" before="Magento_ModuleC" /> </route> <route id="wishlist" frontName="wishlist"> - <module name="Magento_Wishlist" /> + <module name="Magento_ModuleC" /> </route> </router> <router id="front" /> diff --git a/dev/tests/unit/testsuite/Magento/Backend/App/Action/Plugin/MassactionKeyTest.php b/dev/tests/unit/testsuite/Magento/Backend/App/Action/Plugin/MassactionKeyTest.php index 02face5ae7c..1c7ef16d13a 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/App/Action/Plugin/MassactionKeyTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/App/Action/Plugin/MassactionKeyTest.php @@ -29,25 +29,31 @@ class MassactionKeyTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Backend\App\Action\Plugin\MassactionKey */ - protected $_plugin; + protected $plugin; + + /** + * @var \Closure + */ + protected $closureMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_invocationChainMock; + protected $requestMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_requestMock; + protected $subjectMock; protected function setUp() { - $this->_invocationChainMock = $this->getMock( - 'Magento\Code\Plugin\InvocationChain', array(), array(), '', false - ); - $this->_requestMock = $this->getMock('Magento\App\Request\Http', array(), array(), '', false); - $this->_plugin = new \Magento\Backend\App\Action\Plugin\MassactionKey(); + $this->closureMock = function () { + return 'Expected'; + }; + $this->subjectMock = $this->getMock('Magento\Backend\App\AbstractAction', array(), array(), '', false); + $this->requestMock = $this->getMock('Magento\App\Request\Http', array(), array(), '', false); + $this->plugin = new \Magento\Backend\App\Action\Plugin\MassactionKey(); } /** @@ -60,14 +66,12 @@ class MassactionKeyTest extends \PHPUnit_Framework_TestCase public function testAroundDispatchWhenMassactionPrepareKeyRequestExists($postData, $convertedData) { - $this->_requestMock ->expects($this->at(0)) + $this->requestMock ->expects($this->at(0)) ->method('getPost')->with('massaction_prepare_key')->will($this->returnValue('key')); - $this->_requestMock->expects($this->at(1))->method('getPost')->with('key')->will($this->returnValue($postData)); - $this->_requestMock->expects($this->once())->method('setPost')->with('key', $convertedData); - $this->_invocationChainMock->expects($this->once()) - ->method('proceed')->with(array($this->_requestMock))->will($this->returnValue('Expected')); + $this->requestMock->expects($this->at(1))->method('getPost')->with('key')->will($this->returnValue($postData)); + $this->requestMock->expects($this->once())->method('setPost')->with('key', $convertedData); $this->assertEquals('Expected', - $this->_plugin->aroundDispatch(array($this->_requestMock), $this->_invocationChainMock)); + $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock)); } public function aroundDispatchDataProvider() @@ -88,12 +92,10 @@ class MassactionKeyTest extends \PHPUnit_Framework_TestCase public function testAroundDispatchWhenMassactionPrepareKeyRequestNotExists() { - $this->_requestMock ->expects($this->once()) + $this->requestMock ->expects($this->once()) ->method('getPost')->with('massaction_prepare_key')->will($this->returnValue(false)); - $this->_requestMock->expects($this->never())->method('setPost'); - $this->_invocationChainMock->expects($this->once()) - ->method('proceed')->with(array($this->_requestMock))->will($this->returnValue('Expected')); + $this->requestMock->expects($this->never())->method('setPost'); $this->assertEquals('Expected', - $this->_plugin->aroundDispatch(array($this->_requestMock), $this->_invocationChainMock)); + $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock)); } } diff --git a/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/Grid/Column/Renderer/CurrencyTest.php b/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/Grid/Column/Renderer/CurrencyTest.php index 1a5d32cdc07..7c8f41103ef 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/Grid/Column/Renderer/CurrencyTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/Grid/Column/Renderer/CurrencyTest.php @@ -72,7 +72,7 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManagerInterface'); - $this->_localeMock = $this->getMock('Magento\Core\Model\LocaleInterface'); + $this->_localeMock = $this->getMock('Magento\Locale\CurrencyInterface'); $this->_requestMock = $this->getMock('Magento\App\RequestInterface'); $this->_curLocatorMock = $this->getMock( @@ -105,7 +105,7 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_blockCurrency = $helper->getObject('Magento\Backend\Block\Widget\Grid\Column\Renderer\Currency', array( 'storeManager' => $this->_storeManagerMock, - 'locale' => $this->_localeMock, + 'localeCurrency' => $this->_localeMock, 'currencyLocator' => $this->_curLocatorMock, 'request' => $this->_requestMock, 'currencyFactory' => $currencyFactoryMock @@ -142,7 +142,7 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase $currLocaleMock = $this->getMock('Zend_Currency', array(), array(), '', false); $currLocaleMock->expects($this->once())->method('toCurrency')->with(15.0000)->will($this->returnValue('15USD')); - $this->_localeMock->expects($this->once())->method('currency')->with('defaultCurrency') + $this->_localeMock->expects($this->once())->method('getCurrency')->with('defaultCurrency') ->will($this->returnValue($currLocaleMock)); $this->assertEquals('15USD', $this->_blockCurrency->render($this->_row)); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Controller/Adminhtml/System/AccountTest.php b/dev/tests/unit/testsuite/Magento/Backend/Controller/Adminhtml/System/AccountTest.php index d6ddb8dcbcc..ecf7aad3150 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Controller/Adminhtml/System/AccountTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Controller/Adminhtml/System/AccountTest.php @@ -53,7 +53,7 @@ class AccountTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\User\Model\User */ protected $_userMock; - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Core\Model\Locale\Validator */ + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Locale\Validator */ protected $_validatorMock; /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Model\Locale\Manager */ @@ -99,7 +99,7 @@ class AccountTest extends \PHPUnit_Framework_TestCase ->setMethods(array('load', 'save', 'sendPasswordResetNotificationEmail', '__sleep', '__wakeup')) ->getMock(); - $this->_validatorMock = $this->getMockBuilder('Magento\Core\Model\Locale\Validator') + $this->_validatorMock = $this->getMockBuilder('Magento\Locale\Validator') ->disableOriginalConstructor() ->setMethods(array('isValid')) ->getMock(); @@ -168,7 +168,7 @@ class AccountTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->_userMock)); $this->_objectManagerMock->expects($this->at(2)) ->method('get') - ->with($this->equalTo('Magento\Core\Model\Locale\Validator')) + ->with($this->equalTo('Magento\Locale\Validator')) ->will($this->returnValue($this->_validatorMock)); $this->_objectManagerMock->expects($this->at(3)) ->method('get') diff --git a/dev/tests/unit/testsuite/Magento/Backend/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Backend/Helper/DataTest.php index 57aa5b99124..efd9132b91f 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Helper/DataTest.php @@ -46,11 +46,12 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_helper = new \Magento\Backend\Helper\Data( $this->getMock('Magento\App\Helper\Context', array(), array(), '', false, false), $this->getMock('\Magento\App\Route\Config', array(), array(), '', false), - $this->getMock('Magento\Core\Model\App', array(), array(), '', false), + $this->getMock('Magento\Locale\ResolverInterface'), $this->getMock('\Magento\Backend\Model\Url', array(), array(), '', false), $this->getMock('\Magento\Backend\Model\Auth', array(), array(), '', false), $this->_frontResolverMock, - $this->getMock('\Magento\Math\Random', array(), array(), '', false) + $this->getMock('\Magento\Math\Random', array(), array(), '', false), + $this->getMock('\Magento\App\RequestInterface') ); } diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Locale/ManagerTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Locale/ManagerTest.php index 2a406040c93..6055cfb0796 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Locale/ManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Locale/ManagerTest.php @@ -115,7 +115,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase { $locale = $this->_model->getUserInterfaceLocale(); - $this->assertEquals($locale, \Magento\Core\Model\LocaleInterface::DEFAULT_LOCALE); + $this->assertEquals($locale, \Magento\Locale\ResolverInterface::DEFAULT_LOCALE); } /** diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/TranslateTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/TranslateTest.php index 914257b133c..52e6e66dc36 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/TranslateTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/TranslateTest.php @@ -34,11 +34,8 @@ class TranslateTest extends \PHPUnit_Framework_TestCase */ public function testInit($area, $expectedScope) { - $localeMock = $this->getMock('\Magento\Core\Model\LocaleInterface'); + $localeMock = $this->getMock('\Magento\Locale\ResolverInterface'); $appMock = $this->getMock('\Magento\AppInterface', array(), array(), '', false); - $appMock->expects($this->once()) - ->method('getLocale') - ->will($this->returnValue($localeMock)); $appStateMock = $this->getMock('\Magento\App\State', array(), array(), '', false); $appStateMock->expects($this->any()) ->method('getAreaCode') @@ -78,7 +75,8 @@ class TranslateTest extends \PHPUnit_Framework_TestCase 'appState' => $appStateMock, 'scopeResolver' => $scopeResolverMock, 'viewDesign' => $designMock, - 'translateFactory' => $translateFactoryMock + 'translateFactory' => $translateFactoryMock, + 'localeResolver' => $localeMock )); $translate->init(); } diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Controller/Adminhtml/Product/Initialization/Helper/Plugin/BundleTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Controller/Adminhtml/Product/Initialization/Helper/Plugin/BundleTest.php index a70d7604041..e78cd81fd45 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Controller/Adminhtml/Product/Initialization/Helper/Plugin/BundleTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Controller/Adminhtml/Product/Initialization/Helper/Plugin/BundleTest.php @@ -43,6 +43,11 @@ class BundleTest extends \PHPUnit_Framework_TestCase */ protected $productMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + protected function setUp() { $this->requestMock = $this->getMock('Magento\App\Request\Http', array(), array(), '', false); @@ -52,6 +57,8 @@ class BundleTest extends \PHPUnit_Framework_TestCase 'getProductOptions', 'setProductOptions', 'setCanSaveBundleSelections', '__wakeup' ); $this->productMock = $this->getMock('\Magento\Catalog\Model\Product', $methods, array(), '', false); + $this->subjectMock = $this->getMock('Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper', + array(), array(), '', false); $this->model = new \Magento\Bundle\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Bundle( $this->requestMock ); @@ -88,7 +95,7 @@ class BundleTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($productOptionsBefore)); $this->productMock->expects($this->once())->method('setProductOptions')->with($productOptionsAfter); $this->productMock->expects($this->once())->method('setCanSaveBundleSelections')->with(true); - $this->model->afterInitialize($this->productMock); + $this->model->afterInitialize($this->subjectMock, $this->productMock); } public function testAfterInitializeIfBundleSelectionsAndCustomOptionsExist() @@ -106,7 +113,7 @@ class BundleTest extends \PHPUnit_Framework_TestCase $this->productMock->expects($this->once())->method('getPriceType')->will($this->returnValue(2)); $this->productMock->expects($this->any())->method('getOptionsReadonly')->will($this->returnValue(true)); $this->productMock->expects($this->once())->method('setCanSaveBundleSelections')->with(false); - $this->model->afterInitialize($this->productMock); + $this->model->afterInitialize($this->subjectMock, $this->productMock); } public function testAfterInitializeIfCustomAndBundleOptionNotExist() @@ -130,6 +137,6 @@ class BundleTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(false)); $this->productMock->expects($this->never())->method('setProductOptions'); $this->productMock->expects($this->once())->method('setCanSaveBundleSelections')->with(true); - $this->model->afterInitialize($this->productMock); + $this->model->afterInitialize($this->subjectMock, $this->productMock); } } diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Model/Plugin/QuoteItemTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Model/Plugin/QuoteItemTest.php index a3d4fbf5dcc..c8a5f61e788 100644 --- a/dev/tests/unit/testsuite/Magento/Bundle/Model/Plugin/QuoteItemTest.php +++ b/dev/tests/unit/testsuite/Magento/Bundle/Model/Plugin/QuoteItemTest.php @@ -26,25 +26,34 @@ namespace Magento\Bundle\Model\Plugin; class QuoteItemTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Bundle\Model\Plugin\QuoteItem */ - protected $_model; + protected $model; /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_quoteItemMock; + protected $quoteItemMock; /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_invocationChainMock; + protected $orderItemMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_orderItemMock; + /** + * @var /PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + + /** + * @var /Closure + */ + protected $closureMock; protected function setUp() { - $this->_orderItemMock = $this->getMock('Magento\Sales\Model\Order\Item', array(), array(), '', false); - $this->_quoteItemMock = $this->getMock('Magento\Sales\Model\Quote\Item', array(), array(), '', false); - $this->_invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', - array(), array(), '', false); - - $this->_model = new \Magento\Bundle\Model\Plugin\QuoteItem(); + $this->orderItemMock = $this->getMock('Magento\Sales\Model\Order\Item', array(), array(), '', false); + $this->quoteItemMock = $this->getMock('Magento\Sales\Model\Quote\Item', array(), array(), '', false); + $orderItem = $this->orderItemMock; + $this->closureMock = function () use ($orderItem) { + return $orderItem; + }; + $this->subjectMock = $this->getMock('Magento\Sales\Model\Convert\Quote', array(), array(), '', false); + $this->model = new \Magento\Bundle\Model\Plugin\QuoteItem(); } public function testAroundItemToOrderItemPositive() @@ -54,14 +63,12 @@ class QuoteItemTest extends \PHPUnit_Framework_TestCase array(), array(), '', false); $productMock->expects($this->once())->method('getCustomOption')->with('bundle_selection_attributes') ->will($this->returnValue($bundleAttribute)); - $this->_quoteItemMock->expects($this->once())->method('getProduct') + $this->quoteItemMock->expects($this->once())->method('getProduct') ->will($this->returnValue($productMock)); - $this->_orderItemMock->expects($this->once())->method('setProductOptions'); - $this->_invocationChainMock->expects($this->once())->method('proceed') - ->will($this->returnValue($this->_orderItemMock)); + $this->orderItemMock->expects($this->once())->method('setProductOptions'); - $orderItem = $this->_model->aroundItemToOrderItem(array($this->_quoteItemMock), $this->_invocationChainMock); - $this->assertSame($this->_orderItemMock, $orderItem); + $orderItem = $this->model->aroundItemToOrderItem($this->subjectMock, $this->closureMock, $this->quoteItemMock); + $this->assertSame($this->orderItemMock, $orderItem); } public function testAroundItemToOrderItemNegative() @@ -69,13 +76,11 @@ class QuoteItemTest extends \PHPUnit_Framework_TestCase $productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); $productMock->expects($this->once())->method('getCustomOption')->with('bundle_selection_attributes') ->will($this->returnValue(false)); - $this->_quoteItemMock->expects($this->once())->method('getProduct') + $this->quoteItemMock->expects($this->once())->method('getProduct') ->will($this->returnValue($productMock)); - $this->_orderItemMock->expects($this->never())->method('setProductOptions'); - $this->_invocationChainMock->expects($this->once())->method('proceed') - ->will($this->returnValue($this->_orderItemMock)); + $this->orderItemMock->expects($this->never())->method('setProductOptions'); - $orderItem = $this->_model->aroundItemToOrderItem(array($this->_quoteItemMock), $this->_invocationChainMock); - $this->assertSame($this->_orderItemMock, $orderItem); + $orderItem = $this->model->aroundItemToOrderItem($this->subjectMock, $this->closureMock, $this->quoteItemMock); + $this->assertSame($this->orderItemMock, $orderItem); } } diff --git a/dev/tests/unit/testsuite/Magento/CacheInvalidate/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/CacheInvalidate/Model/ObserverTest.php new file mode 100644 index 00000000000..55f949dc642 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/CacheInvalidate/Model/ObserverTest.php @@ -0,0 +1,131 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_CacheInvalidate + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\CacheInvalidate\Model; + +class ObserverTest extends \PHPUnit_Framework_TestCase +{ + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\CacheInvalidate\Model\Observer */ + protected $_model; + + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Event\Observer */ + protected $_observerMock; + + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\HTTP\Adapter\Curl */ + protected $_curlMock; + + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\PageCache\Model\Config */ + protected $_configMock; + + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\CacheInvalidate\Helper\Data */ + protected $_helperMock; + + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Object\ */ + protected $_observerObject; + + /** + * Set up all mocks and data for test + */ + public function setUp() + { + $this->_configMock = $this->getMock('Magento\PageCache\Model\Config', ['getType'], [], '', false); + $this->_helperMock = $this->getMock('Magento\PageCache\Helper\Data', ['getUrl'], [], '', false); + $this->_curlMock = $this->getMock( + '\Magento\HTTP\Adapter\Curl', + ['setOptions', 'write', 'read', 'close'], + [], + '', + false + ); + $this->_model = new \Magento\CacheInvalidate\Model\Observer( + $this->_configMock, + $this->_helperMock, + $this->_curlMock + ); + $this->_observerMock = $this->getMock('Magento\Event\Observer', ['getEvent'], [], '', false); + $this->_observerObject = $this->getMock('\Magento\Core\Model\Store', [], [], '', false); + } + + /** + * Test case for cache invalidation + */ + public function testInvalidateVarnish() + { + $eventMock = $this->getMock('Magento\Event', ['getObject'], [], '', false); + $eventMock->expects($this->once()) + ->method('getObject') + ->will($this->returnValue($this->_observerObject)); + $this->_observerMock->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($eventMock)); + $this->_configMock->expects($this->once()) + ->method('getType') + ->will($this->returnValue(1)); + $tags = array('cache_1', 'cache_group'); + $this->_observerObject->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($tags)); + $this->sendPurgeRequest(implode('|', $tags)); + + $this->_model->invalidateVarnish($this->_observerMock); + } + + /** + * Test case for flushing all the cache + */ + public function testFlushAllCache() + { + $this->_configMock->expects($this->once()) + ->method('getType') + ->will($this->returnValue(1)); + + $this->sendPurgeRequest('.*'); + $this->_model->flushAllCache($this->_observerMock); + } + + /** + * @param array $tags + */ + protected function sendPurgeRequest($tags = array()) + { + $url = 'http://mangento.index.php'; + $httpVersion = '1.1'; + $headers = array("X-Magento-Tags-Pattern: {$tags}"); + $this->_helperMock->expects($this->any()) + ->method('getUrl') + ->with($this->equalTo('*'), array()) + ->will($this->returnValue($url)); + $this->_curlMock->expects($this->once()) + ->method('setOptions') + ->with(array(CURLOPT_CUSTOMREQUEST => 'PURGE')); + $this->_curlMock->expects($this->once()) + ->method('write') + ->with($this->equalTo(''), $this->equalTo($url), $httpVersion, $this->equalTo($headers)); + $this->_curlMock->expects($this->once()) + ->method('read'); + $this->_curlMock->expects($this->once()) + ->method('close'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Block/Category/ViewTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Block/Category/ViewTest.php new file mode 100644 index 00000000000..36287b33ad2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Block/Category/ViewTest.php @@ -0,0 +1,58 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Block\Category; + +class ViewTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Block\Category\View + */ + protected $block; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->block = $objectManager->getObject('Magento\Catalog\Block\Category\View'); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $categoryTag = array('catalog_category_1'); + $currentCatogoryMock = $this->getMock('Magento\Catalog\Model\Category', array(), array(), '', false); + $currentCatogoryMock->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($categoryTag)); + $this->block->setCurrentCategory($currentCatogoryMock); + $this->assertEquals( + $categoryTag, + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Block/NavigationTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Block/NavigationTest.php new file mode 100644 index 00000000000..483a6674593 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Block/NavigationTest.php @@ -0,0 +1,56 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Block; + +class NavigationTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Block\Navigation + */ + protected $block; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $categoryFactory = $this->getMock('Magento\Catalog\Model\CategoryFactory', array('create'), array(), '', false); + $this->block = $objectManager->getObject( + 'Magento\Catalog\Block\Navigation', + array('categoryFactory' => $categoryFactory) + ); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $this->assertEquals( + array(\Magento\Catalog\Model\Category::CACHE_TAG, \Magento\Core\Model\Store\Group::CACHE_TAG), + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/Compare/SidebarTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/Compare/SidebarTest.php new file mode 100644 index 00000000000..8c7a6bf8726 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/Compare/SidebarTest.php @@ -0,0 +1,72 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Block\Product\Compare; + +class SidebarTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Block\Product\Compare\Sidebar + */ + protected $block; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->block = $objectManager->getObject('Magento\Catalog\Block\Product\Compare\Sidebar'); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $productTag = 'catalog_product_1'; + $itemTag = 'compare_item_1'; + $itemId = 1; + + $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $product->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($productTag)); + $item = $this->getMock( + 'Magento\Catalog\Model\Product\Compare\Item', + array('getProduct', '__wakeup'), + array(), + '', + false + ); + $item->expects($this->once()) + ->method('getProduct') + ->will($this->returnValue($product)); + $this->block->setItems(array($item)); + $this->block->setCatalogCompareItemId($itemId); + $this->assertEquals( + array($productTag, $itemTag), + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ListProductTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ListProductTest.php new file mode 100644 index 00000000000..1c08d45fc5b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ListProductTest.php @@ -0,0 +1,95 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Block\Product; + +class ListProductTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Block\Product\ListProduct + */ + protected $block; + + /** + * @var \Magento\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registryMock; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->registryMock = $this->getMock('Magento\Registry', array(), array(), '', false); + $this->block = $objectManager->getObject( + 'Magento\Catalog\Block\Product\ListProduct', + array('registry' => $this->registryMock) + ); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $productTag = 'catalog_product_1'; + $categoryTag = 'catalog_category_1'; + + $product = $this->getMock( + 'Magento\Catalog\Model\Product', + array('getIdentities', '__wakeup'), + array(), + '', + false + ); + $product->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue(array($productTag))); + + $itemsCollection = new \ReflectionProperty( + 'Magento\Catalog\Block\Product\ListProduct', + '_productCollection' + ); + $itemsCollection->setAccessible(true); + $itemsCollection->setValue($this->block, array($product)); + + $currentCategory = $this->getMock('Magento\Catalog\Model\Category', array(), array(), '', false); + $currentCategory->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue(array($categoryTag))); + $layer = $this->getMock('Magento\Catalog\Model\Layer', array(), array(), '', false); + $layer->expects($this->once()) + ->method('getCurrentCategory') + ->will($this->returnValue($currentCategory)); + $this->registryMock->expects($this->once()) + ->method('registry') + ->with('current_layer') + ->will($this->returnValue($layer)); + + $this->assertEquals( + array($categoryTag, $productTag), + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/NewProductTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/NewProductTest.php new file mode 100644 index 00000000000..fa894a64780 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/NewProductTest.php @@ -0,0 +1,52 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Block\Product; + +class NewProductTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Block\Product\ListProduct + */ + protected $block; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->block = $objectManager->getObject('Magento\Catalog\Block\Product\NewProduct'); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $this->assertEquals( + array(\Magento\Catalog\Model\Product::CACHE_TAG), + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/PriceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/PriceTest.php new file mode 100644 index 00000000000..c2506087eb9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/PriceTest.php @@ -0,0 +1,58 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Block\Product; + +class PriceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Block\Product\Price + */ + protected $block; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->block = $objectManager->getObject('Magento\Catalog\Block\Product\Price'); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $productTags = array('catalog_product_1'); + $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $product->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($productTags)); + $this->block->setProduct($product); + $this->assertEquals( + $productTags, + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ProductList/RelatedTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ProductList/RelatedTest.php new file mode 100644 index 00000000000..ccf79b8272a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ProductList/RelatedTest.php @@ -0,0 +1,65 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Block\Product\ProductList; + +class RelatedTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Block\Product\ProductList\Related + */ + protected $block; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->block = $objectManager->getObject('Magento\Catalog\Block\Product\ProductList\Related'); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $productTag = 'compare_item_1'; + $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $product->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($productTag)); + + $itemsCollection = new \ReflectionProperty( + 'Magento\Catalog\Block\Product\ProductList\Related', + '_itemCollection' + ); + $itemsCollection->setAccessible(true); + $itemsCollection->setValue($this->block, array($product)); + + $this->assertEquals( + array($productTag), + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ProductList/UpsellTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ProductList/UpsellTest.php new file mode 100644 index 00000000000..12c5a1bda3b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ProductList/UpsellTest.php @@ -0,0 +1,65 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Block\Product\ProductList; + +class UpsellTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Block\Product\ProductList\Upsell + */ + protected $block; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->block = $objectManager->getObject('Magento\Catalog\Block\Product\ProductList\Upsell'); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $productTag = 'compare_item_1'; + $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $product->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($productTag)); + + $itemsCollection = new \ReflectionProperty( + 'Magento\Catalog\Block\Product\ProductList\Upsell', + '_items' + ); + $itemsCollection->setAccessible(true); + $itemsCollection->setValue($this->block, array($product)); + + $this->assertEquals( + array($productTag), + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ViewTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ViewTest.php index b37a9a9d3d4..a6ec6d7d020 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ViewTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ViewTest.php @@ -71,4 +71,21 @@ class ViewTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(true)); $this->assertEquals(false, $this->view->shouldRenderQuantity()); } + + public function testGetIdentities() + { + $productTags = array('catalog_product_1'); + $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $product->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($productTags)); + $this->registryMock->expects($this->any()) + ->method('registry') + ->with('product') + ->will($this->returnValue($product)); + $this->assertEquals( + $productTags, + $this->view->getIdentities() + ); + } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php index 5200b1b464d..9677a52ff84 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper/HandlerFactoryTest.php @@ -45,11 +45,11 @@ class HandlerFactoryTest extends \PHPUnit_Framework_TestCase { $this->setExpectedException( '\InvalidArgumentException', - '\Magento\Object does not implement ' + 'Magento\Object does not implement ' . 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface' ); $this->_objectManagerMock->expects($this->never())->method('create'); - $this->_model->create('\Magento\Object'); + $this->_model->create('Magento\Object'); } public function testCreateWithValidType() diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php index c37f7b141bc..da35cdf14fb 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/IndexerConfigDataTest.php @@ -37,9 +37,9 @@ class IndexerConfigDataTest extends \PHPUnit_Framework_TestCase protected $stateMock; /** - * @var \Magento\Code\Plugin\InvocationChain|\PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $chainMock; + protected $subjectMock; protected function setUp() { @@ -47,9 +47,7 @@ class IndexerConfigDataTest extends \PHPUnit_Framework_TestCase 'Magento\Catalog\Model\Indexer\Category\Flat\State', array('isFlatEnabled'), array(), '', false ); - $this->chainMock = $this->getMock( - 'Magento\Code\Plugin\InvocationChain', array('proceed'), array(), '', false - ); + $this->subjectMock = $this->getMock('Magento\Indexer\Model\Config\Data', array(), array(), '', false); $this->model = new \Magento\Catalog\Model\Indexer\Category\Flat\Plugin\IndexerConfigData( $this->stateMock @@ -58,23 +56,21 @@ class IndexerConfigDataTest extends \PHPUnit_Framework_TestCase /** * @param bool $isFlat - * @param array $arguments + * @param string $path + * @param mixed $default * @param array $inputData * @param array $outputData * @dataProvider aroundGetDataProvider */ - public function testAroundGet($isFlat, array $arguments, $inputData, $outputData) + public function testAroundGet($isFlat, $path, $default, $inputData, $outputData) { $this->stateMock->expects($this->once()) ->method('isFlatEnabled') ->will($this->returnValue($isFlat)); - - $this->chainMock->expects($this->once()) - ->method('proceed') - ->with($arguments) - ->will($this->returnValue($inputData)); - - $this->assertEquals($outputData, $this->model->aroundGet($arguments, $this->chainMock)); + $closureMock = function () use ($inputData) { + return $inputData; + }; + $this->assertEquals($outputData, $this->model->aroundGet($this->subjectMock, $closureMock, $path, $default)); } public function aroundGetDataProvider() @@ -95,42 +91,48 @@ class IndexerConfigDataTest extends \PHPUnit_Framework_TestCase // flat is enabled, nothing is being changed array( true, - array(), + null, + null, array('catalog_category_flat' => $flatIndexerData, 'other_indexer' => $otherIndexerData), array('catalog_category_flat' => $flatIndexerData, 'other_indexer' => $otherIndexerData), ), // flat is disabled, path is absent, flat indexer is being removed array( false, - array(), + null, + null, array('catalog_category_flat' => $flatIndexerData, 'other_indexer' => $otherIndexerData), array('other_indexer' => $otherIndexerData), ), // flat is disabled, path is null, flat indexer is being removed array( false, - array('path' => null), + null, + null, array('catalog_category_flat' => $flatIndexerData, 'other_indexer' => $otherIndexerData), array('other_indexer' => $otherIndexerData), ), // flat is disabled, path is flat indexer, flat indexer is being removed array( false, - array('path' => 'catalog_category_flat'), + 'catalog_category_flat', + null, $flatIndexerData, null, ), // flat is disabled, path is flat indexer, default is array(), flat indexer is being array() array( false, - array('path' => 'catalog_category_flat', 'default' => array()), - $flatIndexerData, + 'catalog_category_flat', array(), + $flatIndexerData, + null, ), // flat is disabled, path is other indexer, nothing is being changed array( false, - array('path' => 'other_indexer'), + 'other_indexer', + null, $otherIndexerData, $otherIndexerData, ), diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php index e39760928d8..a5195f46052 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreGroupTest.php @@ -36,20 +36,27 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase protected $stateMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Code\Plugin\InvocationChain + * @var StoreView */ - protected $pluginMock; + protected $model; /** - * @var StoreView + * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $model; + protected $subjectMock; + + /** + * @var \Closure + */ + protected $closureMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $groupMock; protected function setUp() { - $this->pluginMock = $this->getMock( - 'Magento\Code\Plugin\InvocationChain', array('proceed'), array(), '', false - ); $this->indexerMock = $this->getMockForAbstractClass( 'Magento\Indexer\Model\IndexerInterface', array(), '', false, false, true, array('getId', 'getState', '__wakeup') @@ -57,6 +64,14 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase $this->stateMock = $this->getMock( 'Magento\Catalog\Model\Indexer\Category\Flat\State', array('isFlatEnabled'), array(), '', false ); + $this->subjectMock = $this->getMock('Magento\Core\Model\Resource\Store\Group', array(), array(), '', false); + + $this->groupMock = $this->getMock( + 'Magento\Core\Model\Store\Group', array('dataHasChangedFor', 'isObjectNew', '__wakeup'), array(), '', false + ); + $this->closureMock = function () { + return false; + }; $this->model = new StoreGroup( $this->indexerMock, $this->stateMock @@ -65,89 +80,38 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase public function testAroundSave() { - $this->mockConfigFlatEnabled(); - $this->mockIndexerMethods(); - $groupMock = $this->getMock( - 'Magento\Core\Model\Store\Group', array('dataHasChangedFor', 'isObjectNew', '__wakeup'), array(), '', false - ); - $groupMock->expects($this->once()) + $this->stateMock->expects($this->once()) + ->method('isFlatEnabled') + ->will($this->returnValue(true)); + $this->indexerMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $this->indexerMock->expects($this->once()) + ->method('invalidate'); + $this->groupMock->expects($this->once()) ->method('dataHasChangedFor') ->with('root_category_id') ->will($this->returnValue(true)); - $groupMock->expects($this->once()) + $this->groupMock->expects($this->once()) ->method('isObjectNew') ->will($this->returnValue(false)); - - $arguments = array($groupMock); - $this->mockPluginProceed($arguments); - $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock)); + $this->assertFalse($this->model->aroundSave($this->subjectMock, $this->closureMock, $this->groupMock)); } public function testAroundSaveNotNew() { - $this->mockConfigFlatEnabledNever(); - $groupMock = $this->getMock( + $this->stateMock->expects($this->never()) + ->method('isFlatEnabled'); + $this->groupMock = $this->getMock( 'Magento\Core\Model\Store\Group', array('dataHasChangedFor', 'isObjectNew', '__wakeup'), array(), '', false ); - $groupMock->expects($this->once()) + $this->groupMock->expects($this->once()) ->method('dataHasChangedFor') ->with('root_category_id') ->will($this->returnValue(true)); - $groupMock->expects($this->once()) + $this->groupMock->expects($this->once()) ->method('isObjectNew') ->will($this->returnValue(true)); - - $arguments = array($groupMock); - $this->mockPluginProceed($arguments); - $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock)); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\Indexer\State - */ - protected function getStateMock() - { - $stateMock = $this->getMock( - 'Magento\Indexer\Model\Indexer\State', array('setStatus', 'save', '__wakeup'), array(), '', false - ); - $stateMock->expects($this->once()) - ->method('setStatus') - ->with('invalid') - ->will($this->returnSelf()); - $stateMock->expects($this->once()) - ->method('save') - ->will($this->returnSelf()); - - return $stateMock; - } - - protected function mockIndexerMethods() - { - $this->indexerMock->expects($this->once()) - ->method('getId') - ->will($this->returnValue(1)); - $this->indexerMock->expects($this->once()) - ->method('invalidate'); - } - - protected function mockConfigFlatEnabled() - { - $this->stateMock->expects($this->once()) - ->method('isFlatEnabled') - ->will($this->returnValue(true)); - } - - protected function mockPluginProceed($arguments, $returnValue = false) - { - $this->pluginMock->expects($this->once()) - ->method('proceed') - ->with($arguments) - ->will($this->returnValue($returnValue)); - } - - protected function mockConfigFlatEnabledNever() - { - $this->stateMock->expects($this->never()) - ->method('isFlatEnabled'); + $this->assertFalse($this->model->aroundSave($this->subjectMock, $this->closureMock, $this->groupMock)); } } \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php index 158f3ed4b02..c08b902231d 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Flat/Plugin/StoreViewTest.php @@ -36,20 +36,22 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase protected $stateMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Code\Plugin\InvocationChain + * @var StoreView */ - protected $pluginMock; + protected $model; /** - * @var StoreView + * @var \Closure */ - protected $model; + protected $closureMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; protected function setUp() { - $this->pluginMock = $this->getMock( - 'Magento\Code\Plugin\InvocationChain', array('proceed'), array(), '', false - ); $this->indexerMock = $this->getMockForAbstractClass( 'Magento\Indexer\Model\IndexerInterface', array(), '', false, false, true, array('getId', 'getState', '__wakeup') @@ -57,6 +59,10 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase $this->stateMock = $this->getMock( 'Magento\Catalog\Model\Indexer\Category\Flat\State', array('isFlatEnabled'), array(), '', false ); + $this->closureMock = function () { + return false; + }; + $this->subjectMock = $this->getMock('Magento\Core\Model\Resource\Store', array(), array(), '', false); $this->model = new StoreView( $this->indexerMock, $this->stateMock @@ -73,9 +79,7 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase $storeMock->expects($this->once()) ->method('isObjectNew') ->will($this->returnValue(true)); - $arguments = array($storeMock); - $this->mockPluginProceed($arguments); - $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock)); + $this->assertFalse($this->model->aroundSave($this->subjectMock, $this->closureMock, $storeMock)); } public function testAroundSaveHasChanged() @@ -87,9 +91,7 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase ->method('dataHasChangedFor') ->with('group_id') ->will($this->returnValue(true)); - $arguments = array($storeMock); - $this->mockPluginProceed($arguments); - $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock)); + $this->assertFalse($this->model->aroundSave($this->subjectMock, $this->closureMock, $storeMock)); } public function testAroundSaveNoNeed() @@ -102,28 +104,7 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase ->method('dataHasChangedFor') ->with('group_id') ->will($this->returnValue(false)); - $arguments = array($storeMock); - $this->mockPluginProceed($arguments); - $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock)); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\Indexer\State - */ - protected function getStateMock() - { - $stateMock = $this->getMock( - 'Magento\Indexer\Model\Indexer\State', array('setStatus', 'save', '__wakeup'), array(), '', false - ); - $stateMock->expects($this->once()) - ->method('setStatus') - ->with('invalid') - ->will($this->returnSelf()); - $stateMock->expects($this->once()) - ->method('save') - ->will($this->returnSelf()); - - return $stateMock; + $this->assertFalse($this->model->aroundSave($this->subjectMock, $this->closureMock, $storeMock)); } protected function mockIndexerMethods() @@ -147,12 +128,4 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase $this->stateMock->expects($this->never()) ->method('isFlatEnabled'); } - - protected function mockPluginProceed($arguments, $returnValue = false) - { - $this->pluginMock->expects($this->once()) - ->method('proceed') - ->with($arguments) - ->will($this->returnValue($returnValue)); - } -} \ No newline at end of file +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php index aac681a7ec9..c98c84ca5ee 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreGroupTest.php @@ -31,10 +31,15 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase protected $indexerMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Code\Plugin\InvocationChain + * @var \PHPUnit_Framework_MockObject_MockObject| */ protected $pluginMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subject; + /** * @var StoreView */ @@ -42,9 +47,6 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->pluginMock = $this->getMock( - 'Magento\Code\Plugin\InvocationChain', array('proceed'), array(), '', false - ); $this->indexerMock = $this->getMockForAbstractClass( 'Magento\Indexer\Model\IndexerInterface', array(), '', false, false, true, array('getId', 'getState', '__wakeup') @@ -52,6 +54,9 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase $this->model = new StoreGroup( $this->indexerMock ); + $this->subject = $this->getMock( + 'Magento\Core\Model\Resource\Store\Group', array(), array(), '', false + ); } /** @@ -71,9 +76,8 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase ->method('isObjectNew') ->will($this->returnValue(false)); - $arguments = array($groupMock); - $this->mockPluginProceed($arguments); - $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock)); + $proceed = $this->mockPluginProceed(); + $this->assertFalse($this->model->aroundSave($this->subject, $proceed, $groupMock)); } /** @@ -92,9 +96,8 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase ->method('isObjectNew') ->will($this->returnValue(true)); - $arguments = array($groupMock); - $this->mockPluginProceed($arguments); - $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock)); + $proceed = $this->mockPluginProceed(); + $this->assertFalse($this->model->aroundSave($this->subject, $proceed, $groupMock)); } public function changedDataProvider() @@ -125,10 +128,8 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase $groupMock->expects($this->never()) ->method('isObjectNew'); - $arguments = array($groupMock); - $this->mockPluginProceed($arguments); - $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock)); - + $proceed = $this->mockPluginProceed(); + $this->assertFalse($this->model->aroundSave($this->subject, $proceed, $groupMock)); } protected function mockIndexerMethods() @@ -140,11 +141,10 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase ->method('invalidate'); } - protected function mockPluginProceed($arguments, $returnValue = false) + protected function mockPluginProceed($returnValue = false) { - $this->pluginMock->expects($this->once()) - ->method('proceed') - ->with($arguments) - ->will($this->returnValue($returnValue)); + return function () use ($returnValue) { + return $returnValue; + }; } -} \ No newline at end of file +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreViewTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreViewTest.php index 89d37a428f2..eaf65ea22a8 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreViewTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Plugin/StoreViewTest.php @@ -31,7 +31,7 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase protected $indexerMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Code\Plugin\InvocationChain + * @var \PHPUnit_Framework_MockObject_MockObject| */ protected $pluginMock; @@ -40,11 +40,13 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase */ protected $model; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subject; + protected function setUp() { - $this->pluginMock = $this->getMock( - 'Magento\Code\Plugin\InvocationChain', array('proceed'), array(), '', false - ); $this->indexerMock = $this->getMockForAbstractClass( 'Magento\Indexer\Model\IndexerInterface', array(), '', false, false, true, array('getId', 'getState', '__wakeup') @@ -52,6 +54,9 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase $this->model = new StoreView( $this->indexerMock ); + $this->subject = $this->getMock( + 'Magento\Core\Model\Resource\Store\Group', array(), array(), '', false + ); } public function testAroundSaveNewObject() @@ -63,9 +68,8 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase $storeMock->expects($this->once()) ->method('isObjectNew') ->will($this->returnValue(true)); - $arguments = array($storeMock); - $this->mockPluginProceed($arguments); - $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock)); + $proceed = $this->mockPluginProceed(); + $this->assertFalse($this->model->aroundSave($this->subject, $proceed, $storeMock)); } public function testAroundSaveHasChanged() @@ -77,9 +81,8 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase ->method('dataHasChangedFor') ->with('group_id') ->will($this->returnValue(true)); - $arguments = array($storeMock); - $this->mockPluginProceed($arguments); - $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock)); + $proceed = $this->mockPluginProceed(); + $this->assertFalse($this->model->aroundSave($this->subject, $proceed, $storeMock)); } public function testAroundSaveNoNeed() @@ -91,9 +94,8 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase ->method('dataHasChangedFor') ->with('group_id') ->will($this->returnValue(false)); - $arguments = array($storeMock); - $this->mockPluginProceed($arguments); - $this->assertFalse($this->model->aroundSave($arguments, $this->pluginMock)); + $proceed = $this->mockPluginProceed(); + $this->assertFalse($this->model->aroundSave($this->subject, $proceed, $storeMock)); } /** @@ -124,11 +126,10 @@ class StoreViewTest extends \PHPUnit_Framework_TestCase ->method('invalidate'); } - protected function mockPluginProceed($arguments, $returnValue = false) + protected function mockPluginProceed($returnValue = false) { - $this->pluginMock->expects($this->once()) - ->method('proceed') - ->with($arguments) - ->will($this->returnValue($returnValue)); + return function () use ($returnValue) { + return $returnValue; + }; } -} \ No newline at end of file +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/ImportTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/ImportTest.php index 1c6a204645b..49497903280 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/ImportTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/ImportTest.php @@ -39,12 +39,13 @@ class ImportTest extends \PHPUnit_Framework_TestCase 'Magento\Catalog\Model\Indexer\Product\Flat\Processor', array('markIndexerAsInvalid'), array(), '', false ); + $subjectMock = $this->getMock('Magento\ImportExport\Model\Import', array(), array(), '', false); $processorMock->expects($this->once()) ->method('markIndexerAsInvalid'); $someData = array(1, 2, 3); $model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\Import($processorMock); - $this->assertEquals($someData, $model->afterImportSource($someData)); + $this->assertEquals($someData, $model->afterImportSource($subjectMock, $someData)); } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/IndexerConfigDataTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/IndexerConfigDataTest.php index 239240ef9cd..188fb93f7cb 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/IndexerConfigDataTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/IndexerConfigDataTest.php @@ -32,52 +32,48 @@ class IndexerConfigDataTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\IndexerConfigData */ - protected $_model; + protected $model; /** - * @var \Magento\Code\Plugin\InvocationChain|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Catalog\Model\Indexer\Product\Flat\State|\PHPUnit_Framework_MockObject_MockObject */ - protected $_chainMock; + protected $_stateMock; /** - * @var \Magento\Catalog\Model\Indexer\Product\Flat\State|\PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_stateMock; + protected $subjectMock; protected function setUp() { $this->_stateMock = $this->getMock( 'Magento\Catalog\Model\Indexer\Product\Flat\State', array('isFlatEnabled'), array(), '', false - ); + ); + $this->subjectMock = $this->getMock('Magento\Indexer\Model\Config\Data', array(), array(), '', false); - $this->_chainMock = $this->getMock( - 'Magento\Code\Plugin\InvocationChain', array('proceed'), array(), '', false - ); - - $this->_model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\IndexerConfigData( + $this->model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\IndexerConfigData( $this->_stateMock ); } /** - * @param $isFlat - * @param array $arguments - * @param $inputData - * @param $outputData + * @param bool $isFlat + * @param string $path + * @param mixed $default + * @param array $inputData + * @param array $outputData * @dataProvider aroundGetDataProvider */ - public function testAroundGet($isFlat, array $arguments, $inputData, $outputData) + public function testAroundGet($isFlat, $path, $default, $inputData, $outputData) { + $closureMock = function () use ($inputData) { + return $inputData; + }; $this->_stateMock->expects($this->once()) ->method('isFlatEnabled') ->will($this->returnValue($isFlat)); - $this->_chainMock->expects($this->once()) - ->method('proceed') - ->with($arguments) - ->will($this->returnValue($inputData)); - - $this->assertEquals($outputData, $this->_model->aroundGet($arguments, $this->_chainMock)); + $this->assertEquals($outputData, $this->model->aroundGet($this->subjectMock, $closureMock, $path, $default)); } public function aroundGetDataProvider() @@ -98,42 +94,48 @@ class IndexerConfigDataTest extends \PHPUnit_Framework_TestCase // flat is enabled, nothing is being changed array( true, - array(), + null, + null, array('catalog_product_flat' => $flatIndexerData, 'other_indexer' => $otherIndexerData), array('catalog_product_flat' => $flatIndexerData, 'other_indexer' => $otherIndexerData), ), // flat is disabled, path is absent, flat indexer is being removed array( false, - array(), + null, + null, array('catalog_product_flat' => $flatIndexerData, 'other_indexer' => $otherIndexerData), array('other_indexer' => $otherIndexerData), ), // flat is disabled, path is null, flat indexer is being removed array( false, - array('path' => null), + null, + null, array('catalog_product_flat' => $flatIndexerData, 'other_indexer' => $otherIndexerData), array('other_indexer' => $otherIndexerData), ), // flat is disabled, path is flat indexer, flat indexer is being removed array( false, - array('path' => 'catalog_product_flat'), + 'catalog_product_flat', + null, $flatIndexerData, null, ), // flat is disabled, path is flat indexer, default is array(), flat indexer is being array() array( false, - array('path' => 'catalog_product_flat', 'default' => array()), - $flatIndexerData, + 'catalog_product_flat', array(), + $flatIndexerData, + null, ), // flat is disabled, path is other indexer, nothing is being changed array( false, - array('path' => 'other_indexer'), + 'other_indexer', + null, $otherIndexerData, $otherIndexerData, ), diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreGroupTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreGroupTest.php index dbdd617d245..5ee5ef2d7a4 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreGroupTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreGroupTest.php @@ -32,20 +32,26 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor|\PHPUnit_Framework_MockObject_MockObject */ - protected $_processorMock; + protected $processorMock; /** * @var \Magento\Core\Model\Store\Group|\PHPUnit_Framework_MockObject_MockObject */ - protected $_storeGroupMock; + protected $storeGroupMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; protected function setUp() { - $this->_processorMock = $this->getMock( + $this->processorMock = $this->getMock( 'Magento\Catalog\Model\Indexer\Product\Flat\Processor', array('markIndexerAsInvalid'), array(), '', false ); - $this->_storeGroupMock = $this->getMock( + $this->subjectMock = $this->getMock('Magento\Core\Model\Resource\Store\Group', array(), array(), '', false); + $this->storeGroupMock = $this->getMock( 'Magento\Core\Model\Store\Group', array('getId', '__wakeup', 'dataHasChangedFor'), array(), '', false ); } @@ -57,17 +63,15 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase */ public function testBeforeSave($matcherMethod, $storeId) { - $this->_processorMock->expects($this->$matcherMethod()) + $this->processorMock->expects($this->$matcherMethod()) ->method('markIndexerAsInvalid'); - $this->_storeGroupMock->expects($this->once()) + $this->storeGroupMock->expects($this->once()) ->method('getId') ->will($this->returnValue($storeId)); - $methodArguments = array($this->_storeGroupMock); - - $model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\StoreGroup($this->_processorMock); - $this->assertEquals($methodArguments, $model->beforeSave($methodArguments)); + $model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\StoreGroup($this->processorMock); + $model->beforeSave($this->subjectMock, $this->storeGroupMock); } /** @@ -77,21 +81,19 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase */ public function testChangedWebsiteBeforeSave($matcherMethod, $websiteChanged) { - $this->_processorMock->expects($this->$matcherMethod()) + $this->processorMock->expects($this->$matcherMethod()) ->method('markIndexerAsInvalid'); - $this->_storeGroupMock->expects($this->once()) + $this->storeGroupMock->expects($this->once()) ->method('getId') ->will($this->returnValue(1)); - $this->_storeGroupMock->expects($this->once()) + $this->storeGroupMock->expects($this->once()) ->method('dataHasChangedFor')->with('root_category_id') ->will($this->returnValue($websiteChanged)); - $methodArguments = array($this->_storeGroupMock); - - $model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\StoreGroup($this->_processorMock); - $this->assertEquals($methodArguments, $model->beforeSave($methodArguments)); + $model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\StoreGroup($this->processorMock); + $model->beforeSave($this->subjectMock, $this->storeGroupMock); } /** diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreTest.php index 2056e501d00..a16f7438b9d 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Plugin/StoreTest.php @@ -32,20 +32,26 @@ class StoreTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor|\PHPUnit_Framework_MockObject_MockObject */ - protected $_processorMock; + protected $processorMock; /** * @var \Magento\Core\Model\Store|\PHPUnit_Framework_MockObject_MockObject */ - protected $_storeMock; + protected $storeMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; protected function setUp() { - $this->_processorMock = $this->getMock( + $this->processorMock = $this->getMock( 'Magento\Catalog\Model\Indexer\Product\Flat\Processor', array('markIndexerAsInvalid'), array(), '', false ); - $this->_storeMock = $this->getMock( + $this->subjectMock = $this->getMock('Magento\Core\Model\Resource\Store', array(), array(), '', false); + $this->storeMock = $this->getMock( 'Magento\Core\Model\Store', array('getId', '__wakeup', 'dataHasChangedFor'), array(), '', false ); } @@ -57,17 +63,15 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testBeforeSave($matcherMethod, $storeId) { - $this->_processorMock->expects($this->$matcherMethod()) + $this->processorMock->expects($this->$matcherMethod()) ->method('markIndexerAsInvalid'); - $this->_storeMock->expects($this->once()) + $this->storeMock->expects($this->once()) ->method('getId') ->will($this->returnValue($storeId)); - $methodArguments = array($this->_storeMock); - - $model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\Store($this->_processorMock); - $this->assertEquals($methodArguments, $model->beforeSave($methodArguments)); + $model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\Store($this->processorMock); + $model->beforeSave($this->subjectMock, $this->storeMock); } /** @@ -77,21 +81,19 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function testBeforeSaveSwitchStoreGroup($matcherMethod, $storeGroupChanged) { - $this->_processorMock->expects($this->$matcherMethod()) + $this->processorMock->expects($this->$matcherMethod()) ->method('markIndexerAsInvalid'); - $this->_storeMock->expects($this->once()) + $this->storeMock->expects($this->once()) ->method('getId') ->will($this->returnValue(1)); - $this->_storeMock->expects($this->once()) + $this->storeMock->expects($this->once()) ->method('dataHasChangedFor')->with('group_id') ->will($this->returnValue($storeGroupChanged)); - $methodArguments = array($this->_storeMock); - - $model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\Store($this->_processorMock); - $this->assertEquals($methodArguments, $model->beforeSave($methodArguments)); + $model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\Store($this->processorMock); + $model->beforeSave($this->subjectMock, $this->storeMock); } /** * @return array diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Plugin/LogTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Plugin/LogTest.php index ae1094a7e10..6ad61f43bfe 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Plugin/LogTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Plugin/LogTest.php @@ -28,25 +28,31 @@ class LogTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Catalog\Model\Plugin\Log */ - protected $_model; + protected $model; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_compareItemMock; + protected $compareItemMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_logResourceMock; + protected $logResourceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; protected function setUp() { - $this->_logResourceMock = $this->getMock('Magento\Log\Model\Resource\Log', array(), array(), '', false); - $this->_compareItemMock = $this->getMock( + $this->logResourceMock = $this->getMock('Magento\Log\Model\Resource\Log', array(), array(), '', false); + $this->compareItemMock = $this->getMock( 'Magento\Catalog\Model\Product\Compare\Item', array(), array(), '', false ); - $this->_model = new \Magento\Catalog\Model\Plugin\Log($this->_compareItemMock); + $this->subjectMock = $this->getMock('Magento\Log\Model\Resource\Log', array(), array(), '', false); + $this->model = new \Magento\Catalog\Model\Plugin\Log($this->compareItemMock); } /** @@ -54,9 +60,10 @@ class LogTest extends \PHPUnit_Framework_TestCase */ public function testAfterClean() { - $this->_compareItemMock->expects($this->once()) + $this->compareItemMock->expects($this->once()) ->method('clean'); - $this->assertEquals($this->_logResourceMock, $this->_model->afterClean($this->_logResourceMock)); + $this->assertEquals($this->logResourceMock, + $this->model->afterClean($this->subjectMock, $this->logResourceMock)); } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Plugin/QuoteItemProductOptionTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Plugin/QuoteItemProductOptionTest.php index ff8cd514118..7ffb283d799 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Plugin/QuoteItemProductOptionTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Plugin/QuoteItemProductOptionTest.php @@ -26,44 +26,48 @@ namespace Magento\Catalog\Model\Plugin; class QuoteItemProductOptionTest extends \PHPUnit_Framework_TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_quoteItemMock; + protected $quoteItemMock; /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_invocationChainMock; - - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_orderItemMock; + protected $orderItemMock; /** @var \Magento\Catalog\Model\Plugin\QuoteItemProductOption */ - protected $_model; + protected $model; + + /** + * @var \Closure + */ + protected $closureMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + protected function setUp() { - $this->_orderItemMock = $this->getMock('Magento\Sales\Model\Order\Item', array(), array(), '', false); - $this->_quoteItemMock = $this->getMock('Magento\Sales\Model\Quote\Item', array(), array(), '', false); - $this->_invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', - array(), array(), '', false); - - $this->_model = new \Magento\Catalog\Model\Plugin\QuoteItemProductOption(); + $this->orderItemMock = $this->getMock('Magento\Sales\Model\Order\Item', array(), array(), '', false); + $this->quoteItemMock = $this->getMock('Magento\Sales\Model\Quote\Item', array(), array(), '', false); + $orderItem = $this->orderItemMock; + $this->subjectMock = $this->getMock('Magento\Sales\Model\Convert\Quote', array(), array(), '', false); + $this->closureMock = function () use ($orderItem) { + return $orderItem; + }; + $this->model = new \Magento\Catalog\Model\Plugin\QuoteItemProductOption(); } public function testAroundItemToOrderItemEmptyOptions() { - $this->_invocationChainMock->expects($this->once())->method('proceed') - ->will($this->returnValue($this->_orderItemMock)); - - $this->_quoteItemMock->expects($this->exactly(2))->method('getOptions') + $this->quoteItemMock->expects($this->exactly(2))->method('getOptions') ->will($this->returnValue(array())); - $orderItem = $this->_model->aroundItemToOrderItem(array($this->_quoteItemMock), $this->_invocationChainMock); - $this->assertSame($this->_orderItemMock, $orderItem); + $orderItem = $this->model->aroundItemToOrderItem($this->subjectMock, $this->closureMock, $this->quoteItemMock); + $this->assertSame($this->orderItemMock, $orderItem); } public function testAroundItemToOrderItemWithOptions() { - $this->_invocationChainMock->expects($this->once())->method('proceed') - ->will($this->returnValue($this->_orderItemMock)); - $itemOption = $this->getMock( 'Magento\Sales\Model\Quote\Item\Option', array('getCode', '__wakeup'), @@ -71,7 +75,7 @@ class QuoteItemProductOptionTest extends \PHPUnit_Framework_TestCase '', false ); - $this->_quoteItemMock->expects($this->exactly(2))->method('getOptions') + $this->quoteItemMock->expects($this->exactly(2))->method('getOptions') ->will($this->returnValue(array($itemOption, $itemOption))); $itemOption->expects($this->at(0))->method('getCode')->will($this->returnValue('someText_8')); @@ -83,10 +87,10 @@ class QuoteItemProductOptionTest extends \PHPUnit_Framework_TestCase $productMock->expects($this->once())->method('getOptionById')->will($this->returnValue($optionMock)); - $this->_quoteItemMock->expects($this->once())->method('getProduct') + $this->quoteItemMock->expects($this->once())->method('getProduct') ->will($this->returnValue($productMock)); - $orderItem = $this->_model->aroundItemToOrderItem(array($this->_quoteItemMock), $this->_invocationChainMock); - $this->assertSame($this->_orderItemMock, $orderItem); + $orderItem = $this->model->aroundItemToOrderItem($this->subjectMock, $this->closureMock, $this->quoteItemMock); + $this->assertSame($this->orderItemMock, $orderItem); } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Compare/ItemTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Compare/ItemTest.php new file mode 100644 index 00000000000..202da38386b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Compare/ItemTest.php @@ -0,0 +1,54 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Catalog\Model\Product\Compare; + +class ItemTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Model\Product\Compare\Item + */ + protected $model; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->model = $objectManager->getObject('Magento\Catalog\Model\Product\Compare\Item'); + } + + protected function tearDown() + { + $this->model = null; + } + + public function testGetIdentities() + { + $id = 1; + $this->model->setId($id); + $this->assertEquals( + array(\Magento\Catalog\Model\Product\Compare\Item::CACHE_TAG . '_' . $id), + $this->model->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CopyConstructorFactoryTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CopyConstructorFactoryTest.php index 5f07852ba20..a6c9f15ddb4 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CopyConstructorFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CopyConstructorFactoryTest.php @@ -45,20 +45,20 @@ class CopyConstructorFactoryTest extends \PHPUnit_Framework_TestCase { $this->setExpectedException( '\InvalidArgumentException', - '\Magento\Object does not implement \Magento\Catalog\Model\Product\CopyConstructorInterface' + 'Magento\Object does not implement \Magento\Catalog\Model\Product\CopyConstructorInterface' ); $this->_objectManagerMock->expects($this->never())->method('create'); - $this->_model->create('\Magento\Object'); + $this->_model->create('Magento\Object'); } public function testCreateWithValidType() { $this->_objectManagerMock->expects($this->once()) - ->method('create')->with('\Magento\Catalog\Model\Product\CopyConstructor\Composite') + ->method('create')->with('Magento\Catalog\Model\Product\CopyConstructor\Composite') ->will($this->returnValue('object')); $this->assertEquals( 'object', - $this->_model->create('\Magento\Catalog\Model\Product\CopyConstructor\Composite') + $this->_model->create('Magento\Catalog\Model\Product\CopyConstructor\Composite') ); } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php index 6496273c32d..72649cbaa04 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php @@ -102,7 +102,6 @@ class ProductTest extends \PHPUnit_Framework_TestCase array(), array(), '', false ), $this->getMock('Magento\CatalogInventory\Model\Stock\ItemFactory', array(), array(), '', false), - $this->getMock('Magento\Catalog\Model\ProductFactory', array(), array(), '', false), $this->getMock('Magento\Catalog\Model\CategoryFactory', array(), array(), '', false), $this->getMock('Magento\Catalog\Model\Product\Option', array(), array(), '', false), $this->getMock('Magento\Catalog\Model\Product\Visibility', array(), array(), '', false), diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php index 0643c7e9f7f..a2076af181b 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php @@ -107,7 +107,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\App\Resource', array(), array(), '', false, false), $this->getMock('Magento\Eav\Model\Config', array(), array(), '', false, false), $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', array(), array(), '', false, false), - $this->getMock('Magento\Core\Model\LocaleInterface'), + $this->getMock('Magento\Locale\FormatInterface'), $this->getMock('Magento\Eav\Model\Resource\Helper', array(), array(), '', false, false), $this->getMock('Magento\Validator\UniversalFactory', array(), array(), '', false, false), $this->getMock('Magento\Core\Model\StoreManagerInterface', array(), array(), '', false), diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php index f402670523b..147486f3cba 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Eav/AttributeTest.php @@ -90,8 +90,9 @@ class AttributeTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\Core\Model\StoreManagerInterface', array(), array(), '', false), $this->getMock('Magento\Eav\Model\Resource\Helper', array(), array(), '', false), $this->getMock('Magento\Validator\UniversalFactory', array(), array(), '', false), - $this->getMock('Magento\Core\Model\LocaleInterface', array(), array(), '', false), + $this->getMock('\Magento\Stdlib\DateTime\TimezoneInterface', array(), array(), '', false), $this->getMock('Magento\Catalog\Model\ProductFactory', array(), array(), '', false), + $this->getMock('Magento\Locale\ResolverInterface', array(), array(), '', false), $this->getMock('Magento\Index\Model\Indexer', array(), array(), '', false), $this->_processor, $this->getMock('\Magento\Catalog\Helper\Product\Flat\Indexer', array(), array(), '', false), diff --git a/dev/tests/unit/testsuite/Magento/CatalogInventory/Block/QtyincrementsTest.php b/dev/tests/unit/testsuite/Magento/CatalogInventory/Block/QtyincrementsTest.php new file mode 100644 index 00000000000..8ac96292f5e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/CatalogInventory/Block/QtyincrementsTest.php @@ -0,0 +1,71 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\CatalogInventory\Block; + +class QtyincrementsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogInventory\Block\Qtyincrements + */ + protected $block; + + /** + * @var \Magento\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registryMock; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->registryMock = $this->getMock('Magento\Registry', array(), array(), '', false); + + $this->block = $objectManager->getObject( + 'Magento\CatalogInventory\Block\Qtyincrements', + array('registry' => $this->registryMock) + ); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $productTags = array('catalog_product_1'); + $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $product->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($productTags)); + $this->registryMock->expects($this->once()) + ->method('registry') + ->with('current_product') + ->will($this->returnValue($product)); + $this->assertEquals( + $productTags, + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/CatalogInventory/Block/Stockqty/DefaultStockqtyTest.php b/dev/tests/unit/testsuite/Magento/CatalogInventory/Block/Stockqty/DefaultStockqtyTest.php new file mode 100644 index 00000000000..2668f9cbc4c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/CatalogInventory/Block/Stockqty/DefaultStockqtyTest.php @@ -0,0 +1,71 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\CatalogInventory\Block\Stockqty; + +class DefaultStockqtyTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\CatalogInventory\Block\Stockqty\DefaultStockqty + */ + protected $block; + + /** + * @var \Magento\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registryMock; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->registryMock = $this->getMock('Magento\Registry', array(), array(), '', false); + + $this->block = $objectManager->getObject( + 'Magento\CatalogInventory\Block\Stockqty\DefaultStockqty', + array('registry' => $this->registryMock) + ); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $productTags = array('catalog_product_1'); + $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $product->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($productTags)); + $this->registryMock->expects($this->once()) + ->method('registry') + ->with('current_product') + ->will($this->returnValue($product)); + $this->assertEquals( + $productTags, + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Adminhtml/Stock/ItemTest.php b/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Adminhtml/Stock/ItemTest.php index 23013c95f1a..2b974584071 100644 --- a/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Adminhtml/Stock/ItemTest.php +++ b/dev/tests/unit/testsuite/Magento/CatalogInventory/Model/Adminhtml/Stock/ItemTest.php @@ -41,23 +41,11 @@ class ItemTest extends \PHPUnit_Framework_TestCase array('_construct', '_getReadAdapter', '_getWriteAdapter', 'getIdFieldName'), array(), '', false ); + $objectHelper = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_model = new \Magento\CatalogInventory\Model\Adminhtml\Stock\Item( - $this->getMock('Magento\Model\Context', array(), array(), '', false), - $this->getMock('Magento\Registry', array(), array(), '', false), - $this->getMock('Magento\Customer\Model\Session', array(), array(), '', false), - $this->getMock('Magento\Index\Model\Indexer', array(), array(), '', false), - $this->getMock('Magento\CatalogInventory\Model\Stock\Status', array(), array(), '', false), - $this->getMock('Magento\CatalogInventory\Helper\Data', array(), array(), '', false), - $this->getMock('Magento\CatalogInventory\Helper\Minsaleqty', array(), array(), '', false), - $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false), - $this->getMock('Magento\Core\Model\StoreManagerInterface', array(), array(), '', false), - $this->getMock('Magento\Core\Model\LocaleInterface', array(), array(), '', false), - $this->getMock('Magento\Math\Division', array(), array(), '', false), - $resourceMock, - $this->getMock('Magento\Data\Collection\Db', array(), array(), '', false), - array() - ); + $this->_model = $objectHelper->getObject('\Magento\CatalogInventory\Model\Adminhtml\Stock\Item', array( + 'resource' => $resourceMock + )); } public function testGetCustomerGroupId() diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php index 1439db0d80e..33a2d6f1d62 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php @@ -75,7 +75,7 @@ class RendererTest extends \PHPUnit_Framework_TestCase protected function _initProduct() { /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product */ - $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $product = $this->getMock('Magento\Catalog\Model\Product', array('getName', '__wakeup'), array(), '', false); $product->expects($this->any())->method('getName')->will($this->returnValue('Parent Product')); /** @var \Magento\Sales\Model\Quote\Item|\PHPUnit_Framework_MockObject_MockObject $item */ @@ -85,4 +85,15 @@ class RendererTest extends \PHPUnit_Framework_TestCase $this->_renderer->setItem($item); return $product; } + + public function testGetIdentities() + { + $product = $this->_initProduct(); + $this->assertEquals($product->getIdentities(), $this->_renderer->getIdentities()); + } + + public function testGetIdentitiesFromEmptyItem() + { + $this->assertEmpty($this->_renderer->getIdentities()); + } } diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php index 786bbfd2a2c..9a91e7a5fba 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php @@ -75,4 +75,24 @@ class SidebarTest extends \PHPUnit_Framework_TestCase $block->deserializeRenders('some-template|some-block|some-type'); } + + public function testGetIdentities() + { + /** @var $block \Magento\Checkout\Block\Cart\Sidebar */ + $block = $this->_objectManager->getObject('Magento\Checkout\Block\Cart\Sidebar'); + + /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product */ + $product = $this->getMock('Magento\Catalog\Model\Product', array('__wakeup'), array(), '', false); + + /** @var \Magento\Sales\Model\Quote\Item|\PHPUnit_Framework_MockObject_MockObject $item */ + $item = $this->getMock('Magento\Sales\Model\Quote\Item', array(), array(), '', false); + $item->expects($this->once())->method('getProduct')->will($this->returnValue($product)); + + /** @var \Magento\Sales\Model\Quote|\PHPUnit_Framework_MockObject_MockObject $quote */ + $quote = $this->getMock('Magento\Sales\Model\Quote', array(), array(), '', false); + $quote->expects($this->once())->method('getAllVisibleItems')->will($this->returnValue(array($item))); + + $block->setData('custom_quote', $quote); + $this->assertEquals($product->getIdentities(), $block->getIdentities()); + } } diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php index 1f8578d0c90..67e5028b343 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php @@ -60,8 +60,8 @@ class DataTest extends \PHPUnit_Framework_TestCase $checkoutSession = $this->getMock('\Magento\Checkout\Model\Session', array(), array(), '', false); - $locale = $this->getMock('\Magento\Core\Model\LocaleInterface', array(), array(), '', false); - $locale->expects($this->any())->method('date')->will($this->returnValue('Oct 02, 2013')); + $localeDate = $this->getMock('\Magento\Stdlib\DateTime\TimezoneInterface', array(), array(), '', false); + $localeDate->expects($this->any())->method('date')->will($this->returnValue('Oct 02, 2013')); $collectionFactory = $this->getMock( '\Magento\Checkout\Model\Resource\Agreement\CollectionFactory', array(), array(), '', false @@ -73,7 +73,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_helper = new Data( $context, $storeConfig, $storeManager, $checkoutSession, - $locale, $collectionFactory, $this->_transportBuilder, $this->_translator + $localeDate, $collectionFactory, $this->_transportBuilder, $this->_translator ); } diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Helper/ExpressRedirectTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Helper/ExpressRedirectTest.php new file mode 100644 index 00000000000..a71b57ebadf --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Checkout/Helper/ExpressRedirectTest.php @@ -0,0 +1,173 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Checkout\Helper; + +class ExpressRedirectTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_actionFlag; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_objectManager; + + /** + * Customer session + * + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_customerSession; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_context; + + /** + * @var \Magento\Checkout\Helper\ExpressRedirect + */ + protected $_helper; + + public function setUp() + { + $this->_actionFlag = $this->getMockBuilder('Magento\App\ActionFlag') + ->disableOriginalConstructor() + ->setMethods(['set']) + ->getMock(); + + $this->_objectManager = $this->getMockBuilder('Magento\ObjectManager') + ->disableOriginalConstructor() + ->setMethods(['get', 'setFactory', 'create', 'configure']) + ->getMock(); + + $this->_customerSession = $this->getMockBuilder('Magento\Customer\Model\Session') + ->disableOriginalConstructor() + ->setMethods(['setBeforeAuthUrl']) + ->getMock(); + + $this->_context = $this->getMockBuilder('Magento\App\Helper\Context') + ->disableOriginalConstructor() + ->getMock(); + + $this->_helper = new \Magento\Checkout\Helper\ExpressRedirect( + $this->_actionFlag, + $this->_objectManager, + $this->_customerSession, + $this->_context + ); + } + + /** + * @dataProvider redirectLoginDataProvider + * @param array $actionFlagList + * @param string|null $customerBeforeAuthUrl + * @param string|null $customerBeforeAuthUrlDefault + */ + public function testRedirectLogin($actionFlagList, $customerBeforeAuthUrl, $customerBeforeAuthUrlDefault) + { + $expressRedirectMock = $this->getMockBuilder('Magento\Checkout\Controller\Express\RedirectLoginInterface') + ->disableOriginalConstructor() + ->setMethods([ + 'getActionFlagList', + 'getResponse', + 'getCustomerBeforeAuthUrl', + 'getLoginUrl', + 'getRedirectActionName']) + ->getMock(); + $expressRedirectMock->expects($this->any()) + ->method('getActionFlagList') + ->will($this->returnValue($actionFlagList)); + + $atIndex = 0; + $actionFlagList = array_merge(array('no-dispatch' => true), $actionFlagList); + foreach ($actionFlagList as $actionKey => $actionFlag) { + $this->_actionFlag->expects($this->at($atIndex)) + ->method('set') + ->with('', $actionKey, $actionFlag); + $atIndex++; + } + + $expectedLoginUrl = 'loginURL'; + $expressRedirectMock->expects($this->once()) + ->method('getLoginUrl') + ->will($this->returnValue($expectedLoginUrl)); + + $urlMock = $this->getMockBuilder('Magento\Core\Helper\Url') + ->disableOriginalConstructor() + ->setMethods(['addRequestParam']) + ->getMock(); + $urlMock->expects($this->once()) + ->method('addRequestParam') + ->with($expectedLoginUrl, array('context' => 'checkout')) + ->will($this->returnValue($expectedLoginUrl)); + + $this->_objectManager->expects($this->once()) + ->method('get') + ->with('Magento\Core\Helper\Url') + ->will($this->returnValue($urlMock)); + + $responseMock = $this->getMockBuilder('Magento\App\Response\Http') + ->disableOriginalConstructor() + ->setMethods(['setRedirect']) + ->getMock(); + $responseMock->expects($this->once()) + ->method('setRedirect') + ->with($expectedLoginUrl); + + $expressRedirectMock->expects($this->once()) + ->method('getResponse') + ->will($this->returnValue($responseMock)); + + $expressRedirectMock->expects($this->any()) + ->method('getCustomerBeforeAuthUrl') + ->will($this->returnValue($customerBeforeAuthUrl)); + $expectedCustomerBeforeAuthUrl = !is_null($customerBeforeAuthUrl) + ? $customerBeforeAuthUrl + : $customerBeforeAuthUrlDefault; + if ($expectedCustomerBeforeAuthUrl) { + $this->_customerSession->expects($this->once()) + ->method('setBeforeAuthUrl') + ->with($expectedCustomerBeforeAuthUrl); + } + $this->_helper->redirectLogin($expressRedirectMock, $customerBeforeAuthUrlDefault); + } + + /** + * Data provider + * @return array + */ + public function redirectLoginDataProvider() + { + return array( + [[], 'beforeCustomerUrl', 'beforeCustomerUrlDEFAULT'], + [['actionKey' => true], null, 'beforeCustomerUrlDEFAULT'], + [[], 'beforeCustomerUrl', null] + ); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php index 7463263f0e5..6f9a110327c 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Model/SessionTest.php @@ -162,4 +162,105 @@ class SessionTest extends \PHPUnit_Framework_TestCase array('additional_messages') ); } + + /** + * @param bool $hasOrderId + * @param bool $hasQuoteId + * @dataProvider restoreQuoteDataProvider + */ + public function testRestoreQuote($hasOrderId, $hasQuoteId) + { + $order = $this->getMock('Magento\Sales\Model\Order', ['getId', 'loadByIncrementId', '__wakeup'], [], '', false); + $order->expects($this->once()) + ->method('getId') + ->will($this->returnValue($hasOrderId ? 'order id' : null)); + $orderFactory = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false); + $orderFactory->expects($this->once())->method('create')->will($this->returnValue($order)); + $quoteFactory = $this->getMock('Magento\Sales\Model\QuoteFactory', ['create'], [], '', false); + $storage = $this->getMock('Magento\Session\Storage', null); + $store = $this->getMock('Magento\Core\Model\Store', [], [], '', false); + $storeManager = $this->getMockForAbstractClass('Magento\Core\Model\StoreManagerInterface'); + $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); + $eventManager = $this->getMockForAbstractClass('Magento\Event\ManagerInterface'); + + /** @var Session $session */ + $session = $this->_helper->getObject( + 'Magento\Checkout\Model\Session', + [ + 'orderFactory' => $orderFactory, + 'quoteFactory' => $quoteFactory, + 'storage' => $storage, + 'storeManager' => $storeManager, + 'eventManager' => $eventManager + ] + ); + $lastOrderId = 'last order id'; + $quoteId = 'quote id'; + $anotherQuoteId = 'another quote id'; + $session->setLastRealOrderId($lastOrderId); + $session->setQuoteId($quoteId); + + if ($hasOrderId) { + $order->setQuoteId($quoteId); + $quote = $this->getMock( + 'Magento\Sales\Model\Quote', + ['getId', 'save', 'setIsActive', 'setReservedOrderId', 'load', '__wakeup'], + [], + '', + false + ); + $quote->expects($this->any()) + ->method('getId') + ->will($this->returnValue($hasQuoteId ? $anotherQuoteId : null)); + $quote->expects($this->any()) + ->method('load') + ->with($this->equalTo($quoteId)) + ->will($this->returnValue($quote)); + $quoteFactory->expects($this->once())->method('create')->will($this->returnValue($quote)); + if ($hasQuoteId) { + $eventManager->expects($this->once()) + ->method('dispatch') + ->with('restore_quote', ['order' => $order, 'quote' => $quote]); + $quote->expects($this->once()) + ->method('setIsActive') + ->with($this->equalTo(1)) + ->will($this->returnSelf()); + $quote->expects($this->once()) + ->method('setReservedOrderId') + ->with($this->isNull()) + ->will($this->returnSelf()); + $quote->expects($this->once()) + ->method('save'); + } else { + $quote->expects($this->never()) + ->method('setIsActive'); + $quote->expects($this->never()) + ->method('setReservedOrderId'); + $quote->expects($this->never()) + ->method('save'); + } + } + $result = $session->restoreQuote(); + if ($hasOrderId && $hasQuoteId) { + $this->assertNull($session->getLastRealOrderId()); + $this->assertEquals($anotherQuoteId, $session->getQuoteId()); + } else { + $this->assertEquals($lastOrderId, $session->getLastRealOrderId()); + $this->assertEquals($quoteId, $session->getQuoteId()); + } + $this->assertEquals($result, $hasOrderId && $hasQuoteId); + } + + /** + * @return array + */ + public function restoreQuoteDataProvider() + { + return array( + array(true, true), + array(true, false), + array(false, true), + array(false, false), + ); + } } diff --git a/dev/tests/unit/testsuite/Magento/Cms/Block/BlockTest.php b/dev/tests/unit/testsuite/Magento/Cms/Block/BlockTest.php new file mode 100644 index 00000000000..e78e03a232b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cms/Block/BlockTest.php @@ -0,0 +1,54 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Cms\Block; + +class BlockTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Cms\Block\Block + */ + protected $block; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->block = $objectManager->getObject('Magento\Cms\Block\Block'); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $id = 1; + $this->block->setBlockId($id); + $this->assertEquals( + array(\Magento\Cms\Model\Block::CACHE_TAG . '_' . $id), + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Cms/Block/PageTest.php b/dev/tests/unit/testsuite/Magento/Cms/Block/PageTest.php new file mode 100644 index 00000000000..18606bf8dd0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Cms/Block/PageTest.php @@ -0,0 +1,54 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Cms\Block; + +class PageTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Cms\Block\Page + */ + protected $block; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->block = $objectManager->getObject('Magento\Cms\Block\Page'); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $id = 1; + $this->block->setPageId($id); + $this->assertEquals( + array(\Magento\Cms\Model\Page::CACHE_TAG . '_' . $id), + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Code/GeneratorTest.php b/dev/tests/unit/testsuite/Magento/Code/GeneratorTest.php index 93d06afe568..2b49d305504 100644 --- a/dev/tests/unit/testsuite/Magento/Code/GeneratorTest.php +++ b/dev/tests/unit/testsuite/Magento/Code/GeneratorTest.php @@ -40,9 +40,9 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase * @var array */ protected $_expectedEntities = array( - 'factory' => \Magento\Code\Generator\Factory::ENTITY_TYPE, - 'proxy' => \Magento\Code\Generator\Proxy::ENTITY_TYPE, - 'interceptor' => \Magento\Code\Generator\Interceptor::ENTITY_TYPE, + 'factory' => \Magento\ObjectManager\Code\Generator\Factory::ENTITY_TYPE, + 'proxy' => \Magento\ObjectManager\Code\Generator\Proxy::ENTITY_TYPE, + 'interceptor' => \Magento\Interception\Code\Generator\Interceptor::ENTITY_TYPE, ); /** @@ -52,11 +52,6 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase */ protected $_model; - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Code\Generator\EntityAbstract - */ - protected $_generator; - /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Autoload\IncludePath */ @@ -75,48 +70,32 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_generator = $this->getMockForAbstractClass('Magento\Code\Generator\EntityAbstract', - array(), '', true, true, true, array('generate') - ); $this->_autoloader = $this->getMock('Magento\Autoload\IncludePath', array('getFile'), array(), '', false ); $this->_ioObjectMock = $this->getMockBuilder('\Magento\Code\Generator\Io') ->disableOriginalConstructor() ->getMock(); - $this->_filesystemMock = $this->getMockBuilder('\Magento\App\Filesystem') - ->disableOriginalConstructor() - ->getMock(); } protected function tearDown() { unset($this->_model); - unset($this->_generator); unset($this->_autoloader); } - /** - * Set generator mock to never call methods - */ - protected function _prepareGeneratorNeverCalls() - { - $this->_generator->expects($this->never()) - ->method('generate'); - } - public function testGetGeneratedEntities() { $this->_model = new \Magento\Code\Generator( - $this->_generator, $this->_autoloader, $this->_ioObjectMock, - $this->_filesystemMock + array('factory', 'proxy', 'interceptor') ); $this->assertEquals(array_values($this->_expectedEntities), $this->_model->getGeneratedEntities()); } /** + * @expectedException \Magento\Exception * @dataProvider generateValidClassDataProvider */ public function testGenerateClass($className, $entityType) @@ -126,22 +105,16 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase ->with($className . $entityType) ->will($this->returnValue(false)); - $this->_generator->expects($this->once()) - ->method('generate') - ->will($this->returnValue(true)); - $this->_model = new \Magento\Code\Generator( - $this->_generator, $this->_autoloader, $this->_ioObjectMock, - $this->_filesystemMock + array('factory' => '\Magento\ObjectManager\Code\Generator\Factory', + 'proxy' => '\Magento\ObjectManager\Code\Generator\Proxy', + 'interceptor' => '\Magento\Interception\Code\Generator\Interceptor') ); - $this->assertEquals( - \Magento\Code\Generator::GENERATION_SUCCESS, - $this->_model->generateClass($className . $entityType) - ); - $this->assertAttributeEmpty('_generator', $this->_model); + $this->_model->generateClass($className . $entityType); + } /** @@ -149,17 +122,17 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase */ public function testGenerateClassWithExistName($className, $entityType) { - $this->_prepareGeneratorNeverCalls(); $this->_autoloader->staticExpects($this->once()) ->method('getFile') ->with($className . $entityType) ->will($this->returnValue(true)); $this->_model = new \Magento\Code\Generator( - $this->_generator, $this->_autoloader, $this->_ioObjectMock, - $this->_filesystemMock + array('factory' => '\Magento\ObjectManager\Code\Generator\Factory', + 'proxy' => '\Magento\ObjectManager\Code\Generator\Proxy', + 'interceptor' => '\Magento\Interception\Code\Generator\Interceptor') ); $this->assertEquals( @@ -170,15 +143,12 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase public function testGenerateClassWithWrongName() { - $this->_prepareGeneratorNeverCalls(); $this->_autoloader->staticExpects($this->never()) ->method('getFile'); $this->_model = new \Magento\Code\Generator( - $this->_generator, $this->_autoloader, - $this->_ioObjectMock, - $this->_filesystemMock + $this->_ioObjectMock ); $this->assertEquals( @@ -195,15 +165,12 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase ->method('getFile') ->will($this->returnValue(false)); - $this->_generator->expects($this->once()) - ->method('generate') - ->will($this->returnValue(false)); - $this->_model = new \Magento\Code\Generator( - $this->_generator, $this->_autoloader, $this->_ioObjectMock, - $this->_filesystemMock + array('factory' => '\Magento\ObjectManager\Code\Generator\Factory', + 'proxy' => '\Magento\ObjectManager\Code\Generator\Proxy', + 'interceptor' => '\Magento\Interception\Code\Generator\Interceptor') ); $expectedEntities = array_values($this->_expectedEntities); diff --git a/dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleClassPluginB.php b/dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleClassPluginB.php deleted file mode 100644 index 816d81cf335..00000000000 --- a/dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleClassPluginB.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Code - * @subpackage unit_tests - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Code\Plugin\GeneratorTest; - -class SimpleClassPluginB -{ - /** - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain - * @return string - */ - public function aroundDoWork(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - return '<PluginB>' . $invocationChain->proceed($arguments) . '</PluginB>'; - } -} diff --git a/dev/tests/unit/testsuite/Magento/Code/Plugin/InvocationChainTest.php b/dev/tests/unit/testsuite/Magento/Code/Plugin/InvocationChainTest.php deleted file mode 100644 index 391ab89f03e..00000000000 --- a/dev/tests/unit/testsuite/Magento/Code/Plugin/InvocationChainTest.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Code - * @subpackage unit_tests - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Code\Plugin; - -require_once __DIR__ . '/GeneratorTest/SimpleClass.php'; -require_once __DIR__ . '/GeneratorTest/SimpleClassPluginA.php'; -require_once __DIR__ . '/GeneratorTest/SimpleClassPluginB.php'; -require_once __DIR__ . '/GeneratorTest/SimpleObjectManager.php'; - -class InvocationChainTest extends \PHPUnit_Framework_TestCase -{ - public function testProceed() - { - $invocationChain = new \Magento\Code\Plugin\InvocationChain( - new \Magento\Code\Plugin\GeneratorTest\SimpleClass(), - 'doWork', - new \Magento\Code\Plugin\GeneratorTest\SimpleObjectManager(), - array('Magento\Code\Plugin\GeneratorTest\SimpleClassPluginA', - 'Magento\Code\Plugin\GeneratorTest\SimpleClassPluginB') - ); - $this->assertEquals( - '<PluginA><PluginB>simple class return value</PluginB></PluginA>', - $invocationChain->proceed(array()) - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config/MatrixTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config/MatrixTest.php index a17dd0368ca..43609e55241 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config/MatrixTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Super/Config/MatrixTest.php @@ -34,18 +34,18 @@ class MatrixTest extends \PHPUnit_Framework_TestCase protected $_block; /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_application; + protected $_appConfig; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Locale\CurrencyInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_locale; protected function setUp() { - $this->_application = $this->getMock('Magento\Core\Model\App', array(), array(), '', false); - $this->_locale = $this->getMock('Magento\Core\Model\LocaleInterface', array(), array(), '', false); + $this->_appConfig = $this->getMock('Magento\App\ConfigInterface'); + $this->_locale = $this->getMock('Magento\Locale\CurrencyInterface', array(), array(), '', false); $data = array( - 'app' => $this->_application, - 'locale' => $this->_locale, + 'applicationConfig' => $this->_appConfig, + 'localeCurrency' => $this->_locale, 'formFactory' => $this->getMock('Magento\Data\FormFactory', array(), array(), '', false), 'productFactory' => $this->getMock('Magento\Catalog\Model\ProductFactory', array(), array(), '', false), ); @@ -58,13 +58,13 @@ class MatrixTest extends \PHPUnit_Framework_TestCase public function testRenderPrice() { - $this->_application->expects($this->once()) - ->method('getBaseCurrencyCode')->with()->will($this->returnValue('USD')); + $this->_appConfig->expects($this->once()) + ->method('getValue')->will($this->returnValue('USD')); $currency = $this->getMock('Zend_Currency', array(), array(), '', false); $currency->expects($this->once()) ->method('toCurrency')->with('100.0000')->will($this->returnValue('$100.00')); $this->_locale->expects($this->once()) - ->method('currency')->with('USD')->will($this->returnValue($currency)); + ->method('getCurrency')->with('USD')->will($this->returnValue($currency)); $this->assertEquals('$100.00', $this->_block->renderPrice(100)); } } diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/ConfigurableTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/ConfigurableTest.php index 4bb56445e1a..0e67f4d29ce 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/ConfigurableTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/ConfigurableTest.php @@ -231,4 +231,22 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase $this->productConfigMock->expects($this->once())->method('getOptions')->with($itemMock); $this->_renderer->getOptionList(); } + + public function testGetIdentities() + { + $productTags = array('catalog_product_1'); + $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $product->expects($this->exactly(2)) + ->method('getIdentities') + ->will($this->returnValue($productTags)); + $item = $this->getMock('Magento\Sales\Model\Quote\Item', array(), array(), '', false); + $item->expects($this->exactly(2)) + ->method('getProduct') + ->will($this->returnValue($product)); + $this->_renderer->setItem($item); + $this->assertEquals( + array_merge($productTags, $productTags), + $this->_renderer->getIdentities() + ); + } } diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Builder/PluginTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Builder/PluginTest.php index 1d4499b63e2..7a480e1e84d 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Builder/PluginTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Builder/PluginTest.php @@ -42,11 +42,6 @@ class PluginTest extends \PHPUnit_Framework_TestCase */ protected $configurableTypeMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $invocationChainMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -72,21 +67,26 @@ class PluginTest extends \PHPUnit_Framework_TestCase */ protected $frontendAttrMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + + /** + * @var \Closure + */ + protected $closureMock; + protected function setUp() { $this->productFactoryMock = $this->getMock('Magento\Catalog\Model\ProductFactory', array('create')); $this->configurableTypeMock = $this->getMock('Magento\ConfigurableProduct\Model\Product\Type\Configurable', array(), array(), '', false); - $this->invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); $this->requestMock = $this->getMock('Magento\App\Request\Http', array(), array(), '', false); $methods = array('setTypeId', 'getAttributes', 'addData', 'setWebsiteIds', '__wakeup'); $this->productMock = $this->getMock('Magento\Catalog\Model\Product', $methods, array(), '', false); - $this->invocationChainMock - ->expects($this->once()) - ->method('proceed') - ->with(array($this->requestMock)) - ->will($this->returnValue($this->productMock)); + $product = $this->productMock; $attributeMethods = array('getId', 'getFrontend', 'getAttributeCode', '__wakeup', 'setIsRequired', 'getIsUnique'); $this->attributeMock @@ -99,6 +99,11 @@ class PluginTest extends \PHPUnit_Framework_TestCase $this->frontendAttrMock = $this->getMock('Magento\Sales\Model\Resource\Quote\Address\Attribute\Frontend', array(), array(), '', false); + $this->subjectMock = + $this->getMock('Magento\Catalog\Controller\Adminhtml\Product\Builder', array(), array(), '', false); + $this->closureMock = function () use ($product) { + return $product; + }; $this->plugin = new \Magento\ConfigurableProduct\Controller\Adminhtml\Product\Builder\Plugin( $this->productFactoryMock, $this->configurableTypeMock @@ -191,7 +196,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase $this->assertEquals( $this->productMock, - $this->plugin->aroundBuild(array($this->requestMock), $this->invocationChainMock) + $this->plugin->aroundBuild($this->subjectMock, $this->closureMock, $this->requestMock) ); } @@ -215,7 +220,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase $this->attributeMock->expects($this->never())->method('getAttributeCode'); $this->assertEquals( $this->productMock, - $this->plugin->aroundBuild(array($this->requestMock), $this->invocationChainMock) + $this->plugin->aroundBuild($this->subjectMock, $this->closureMock, $this->requestMock) ); } @@ -235,7 +240,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase $this->attributeMock->expects($this->never())->method('getAttributeCode'); $this->assertEquals( $this->productMock, - $this->plugin->aroundBuild(array($this->requestMock), $this->invocationChainMock) + $this->plugin->aroundBuild($this->subjectMock, $this->closureMock, $this->requestMock) ); } diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php index 49e55410c8d..f902649a3f1 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php @@ -48,6 +48,11 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase */ protected $productMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + protected function setUp() { $this->productTypeMock = $this->getMock( @@ -57,6 +62,8 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase $methods = array('setNewVariationsAttributeSetId', 'setAssociatedProductIds', 'setCanSaveConfigurableAttributes', '__wakeup'); $this->productMock = $this->getMock('Magento\Catalog\Model\Product', $methods, array(), '', false); + $this->subjectMock = $this->getMock('Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper', + array(), array(), '', false); $this->plugin = new Configurable( $this->productTypeMock, $this->requestMock @@ -94,7 +101,7 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase ->with($this->productMock, $postValue)->will($this->returnValue($generatedProductIds)); $this->productMock->expects($this->once())->method('setAssociatedProductIds')->with($expectedArray); $this->productMock->expects($this->once())->method('setCanSaveConfigurableAttributes')->with(true); - $this->plugin->afterInitialize($this->productMock); + $this->plugin->afterInitialize($this->subjectMock, $this->productMock); } public function testAfterInitializeIfAttributesNotEmptyAndActionNameGenerateVariations() @@ -128,7 +135,7 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase ->method('generateSimpleProducts'); $this->productMock->expects($this->once())->method('setAssociatedProductIds')->with($associatedProductIds); $this->productMock->expects($this->once())->method('setCanSaveConfigurableAttributes')->with(true); - $this->plugin->afterInitialize($this->productMock); + $this->plugin->afterInitialize($this->subjectMock, $this->productMock); } public function testAfterInitializeIfAttributesEmpty() @@ -141,6 +148,6 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase $this->productTypeMock->expects($this->never())->method('setUsedProductAttributeIds'); $this->requestMock->expects($this->never())->method('getPost'); $this->productTypeMock->expects($this->never())->method('generateSimpleProducts'); - $this->plugin->afterInitialize($this->productMock); + $this->plugin->afterInitialize($this->subjectMock, $this->productMock); } } diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Helper/Product/Configuration/PluginTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Helper/Product/Configuration/PluginTest.php index c5cff96b6f2..8ac8f22c87e 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Helper/Product/Configuration/PluginTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Helper/Product/Configuration/PluginTest.php @@ -39,32 +39,36 @@ class PluginTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $invocationChainMock; + protected $productMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $productMock; + protected $typeInstanceMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $typeInstanceMock; + protected $subjectMock; + + /** + * @var \Closure + */ + protected $closureMock; protected function setUp() { $this->itemMock = $this->getMock('Magento\Catalog\Model\Product\Configuration\Item\ItemInterface'); - $this->invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); $this->productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); $this->typeInstanceMock = $this->getMock('Magento\ConfigurableProduct\Model\Product\Type\Configurable', array('getSelectedAttributesInfo', '__wakeup'), array(), '', false); $this->itemMock->expects($this->once())->method('getProduct')->will($this->returnValue($this->productMock)); - $this->invocationChainMock - ->expects($this->once()) - ->method('proceed') - ->with(array($this->itemMock)) - ->will($this->returnValue(array('options'))); + $this->closureMock = function () { + return array('options'); + }; + $this->subjectMock = + $this->getMock('Magento\Catalog\Helper\Product\Configuration', array(), array(), '', false); $this->plugin = new \Magento\ConfigurableProduct\Helper\Product\Configuration\Plugin(); } @@ -84,7 +88,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase ->with($this->productMock) ->will($this->returnValue(array('attributes'))); $this->assertEquals(array('attributes', 'options'), - $this->plugin->aroundGetOptions(array($this->itemMock), $this->invocationChainMock)); + $this->plugin->aroundGetOptions($this->subjectMock, $this->closureMock, $this->itemMock)); } public function testAroundGetOptionsWhenProductTypeIsSimple() @@ -96,6 +100,6 @@ class PluginTest extends \PHPUnit_Framework_TestCase $this->productMock ->expects($this->never())->method('getTypeInstance'); $this->assertEquals(array('options'), - $this->plugin->aroundGetOptions(array($this->itemMock), $this->invocationChainMock)); + $this->plugin->aroundGetOptions($this->subjectMock, $this->closureMock, $this->itemMock)); } } diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Order/Admin/Item/Plugin/ConfigurableTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Order/Admin/Item/Plugin/ConfigurableTest.php index 8a0c946dd66..7b8750f5d6f 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Order/Admin/Item/Plugin/ConfigurableTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Order/Admin/Item/Plugin/ConfigurableTest.php @@ -42,24 +42,32 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase protected $itemMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Closure */ - protected $invocationChainMock; + protected $closureMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $productMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + protected function setUp() { $this->itemMock = $this->getMock('Magento\Sales\Model\Order\Item', array('getProductType', 'getProductOptions', '__wakeup'), array(), '', false); - $this->invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); + $this->closureMock = function () { + return 'Expected'; + }; $this->productFactoryMock = $this->getMock('Magento\Catalog\Model\ProductFactory', array('create')); $this->productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $this->subjectMock = $this->getMock('Magento\Sales\Model\Order\Admin\Item', array(), array(), '', false); $this->configurable = new \Magento\ConfigurableProduct\Model\Order\Admin\Item\Plugin\Configurable( $this->productFactoryMock ); @@ -75,9 +83,8 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase ->expects($this->once()) ->method('getProductOptions') ->will($this->returnValue(array('simple_name' => 'simpleName'))); - $this->invocationChainMock->expects($this->never())->method('proceed'); $this->assertEquals('simpleName', - $this->configurable->aroundGetName(array($this->itemMock), $this->invocationChainMock)); + $this->configurable->aroundGetName($this->subjectMock, $this->closureMock, $this->itemMock)); } public function testAroundGetNameIfProductIsSimple() @@ -89,8 +96,8 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase $this->itemMock ->expects($this->never()) ->method('getProductOptions'); - $this->invocationChainMock->expects($this->once())->method('proceed')->with(array($this->itemMock)); - $this->configurable->aroundGetName(array($this->itemMock), $this->invocationChainMock); + $this->assertEquals('Expected', + $this->configurable->aroundGetName($this->subjectMock, $this->closureMock, $this->itemMock)); } public function testAroundGetSkuIfProductIsConfigurable() @@ -103,9 +110,8 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase ->expects($this->once()) ->method('getProductOptions') ->will($this->returnValue(array('simple_sku' => 'simpleName'))); - $this->invocationChainMock->expects($this->never())->method('proceed'); $this->assertEquals('simpleName', - $this->configurable->aroundGetSku(array($this->itemMock), $this->invocationChainMock) + $this->configurable->aroundGetSku($this->subjectMock, $this->closureMock, $this->itemMock) ); } @@ -118,8 +124,9 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase $this->itemMock ->expects($this->never()) ->method('getProductOptions'); - $this->invocationChainMock->expects($this->once())->method('proceed')->with(array($this->itemMock)); - $this->configurable->aroundGetSku(array($this->itemMock), $this->invocationChainMock); + $this->assertEquals('Expected', + $this->configurable->aroundGetSku($this->subjectMock, $this->closureMock, $this->itemMock) + ); } public function testAroundGetProductIdIfProductIsConfigurable() @@ -141,9 +148,8 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase ->method('getIdBySku') ->with('simpleName') ->will($this->returnValue('id')); - $this->invocationChainMock->expects($this->never())->method('proceed'); $this->assertEquals('id', - $this->configurable->aroundGetProductId(array($this->itemMock), $this->invocationChainMock) + $this->configurable->aroundGetProductId($this->subjectMock, $this->closureMock, $this->itemMock) ); } @@ -156,7 +162,7 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase $this->itemMock ->expects($this->never()) ->method('getProductOptions'); - $this->invocationChainMock->expects($this->once())->method('proceed')->with(array($this->itemMock)); - $this->configurable->aroundGetProductId(array($this->itemMock), $this->invocationChainMock); + $this->assertEquals('Expected', + $this->configurable->aroundGetProductId($this->subjectMock, $this->closureMock, $this->itemMock)); } } diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/CartConfiguration/Plugin/ConfigurableTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/CartConfiguration/Plugin/ConfigurableTest.php index f0a46bddeff..85bba8b3530 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/CartConfiguration/Plugin/ConfigurableTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/CartConfiguration/Plugin/ConfigurableTest.php @@ -32,19 +32,28 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase protected $model; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Closure */ - protected $invocationChainMock; + protected $closureMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit_invFramework_MockObject_MockObject */ protected $productMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + protected function setUp() { - $this->invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); + $this->closureMock = function () { + return 'Expected'; + }; $this->productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $this->subjectMock = + $this->getMock('Magento\Catalog\Model\Product\CartConfiguration', array(), array(), '', false); $this->model = new Configurable(); } @@ -54,22 +63,19 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase $this->productMock->expects($this->once()) ->method('getTypeId') ->will($this->returnValue(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE)); - $this->invocationChainMock->expects($this->never())->method('proceed'); $this->assertEquals( true, - $this->model->aroundIsProductConfigured(array($this->productMock, $config), $this->invocationChainMock) + $this->model->aroundIsProductConfigured($this->subjectMock, $this->closureMock, $this->productMock, $config) ); } - public function testAroundIsProductConfiguredProceedsChainInvocationWhenProductIsNotConfigurable() + public function testAroundIsProductConfiguredWhenProductIsNotConfigurable() { $config = array('super_group' => 'valid_value'); $this->productMock->expects($this->once()) ->method('getTypeId') ->will($this->returnValue('custom_product_type')); - $this->invocationChainMock->expects($this->once()) - ->method('proceed') - ->with(array($this->productMock, $config)); - $this->model->aroundIsProductConfigured(array($this->productMock, $config), $this->invocationChainMock); + $this->assertEquals('Expected', + $this->model->aroundIsProductConfigured($this->subjectMock, $this->closureMock, $this->productMock, $config)); } } diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/TypeTransitionManager/Plugin/ConfigurableTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/TypeTransitionManager/Plugin/ConfigurableTest.php index 9444bb3fd03..ab94b6ad842 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/TypeTransitionManager/Plugin/ConfigurableTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/TypeTransitionManager/Plugin/ConfigurableTest.php @@ -33,7 +33,7 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $invocationChainMock; + protected $closureMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -45,6 +45,11 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase */ protected $model; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + protected function setUp() { $this->requestMock = $this->getMock( @@ -62,7 +67,11 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase '', false ); - $this->invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); + $this->subjectMock = + $this->getMock('Magento\Catalog\Model\Product\TypeTransitionManager', array(), array(), '', false); + $this->closureMock = function () { + return 'Expected'; + }; } public function testAroundProcessProductWithProductThatCanBeTransformedToConfigurable() @@ -71,8 +80,7 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('not_empty_attribute_data')); $this->productMock->expects($this->once())->method('setTypeId') ->with(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE); - $this->invocationChainMock->expects($this->never())->method('proceed'); - $this->model->aroundProcessProduct(array($this->productMock), $this->invocationChainMock); + $this->model->aroundProcessProduct($this->subjectMock, $this->closureMock, $this->productMock); } public function testAroundProcessProductWithProductThatCannotBeTransformedToConfigurable() @@ -80,8 +88,6 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase $this->requestMock->expects($this->any())->method('getParam')->with('attributes') ->will($this->returnValue(null)); $this->productMock->expects($this->never())->method('setTypeId'); - $arguments = array($this->productMock); - $this->invocationChainMock->expects($this->once())->method('proceed')->with($arguments); - $this->model->aroundProcessProduct($arguments, $this->invocationChainMock); + $this->model->aroundProcessProduct($this->subjectMock, $this->closureMock, $this->productMock); } } diff --git a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/Validator/PluginTest.php b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/Validator/PluginTest.php index 1a64c449843..b93a1dfbdb2 100644 --- a/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/Validator/PluginTest.php +++ b/dev/tests/unit/testsuite/Magento/ConfigurableProduct/Model/Product/Validator/PluginTest.php @@ -45,11 +45,6 @@ class PluginTest extends \PHPUnit_Framework_TestCase */ protected $coreHelperMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $invocationChainMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -75,18 +70,27 @@ class PluginTest extends \PHPUnit_Framework_TestCase */ protected $proceedResult = array(1, 2, 3); + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + + /** + * @var \Closure + */ + protected $closureMock; + protected function setUp() { $this->eventManagerMock = $this->getMock('Magento\Event\Manager', array(), array(), '', false); $this->productFactoryMock = $this->getMock('Magento\Catalog\Model\ProductFactory', array('create'), array(), '', false); $this->coreHelperMock = $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false); - $this->invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); $this->productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); $this->requestMock = $this->getMock('Magento\App\Request\Http', array('getPost', 'getParam', '__wakeup'), array(), '', false); $this->responseMock = $this->getMock( - 'Magento\App\Response\Http', + 'Magento\Object', array('setError', 'setMessage', 'setAttributes'), array(), '', false); $this->arguments = array( @@ -94,8 +98,11 @@ class PluginTest extends \PHPUnit_Framework_TestCase $this->requestMock, $this->responseMock ); - $this->invocationChainMock->expects($this->once())->method('proceed')->with($this->arguments) - ->will($this->returnValue($this->proceedResult)); + $proceedResult = $this->proceedResult; + $this->closureMock = function () use ($proceedResult) { + return $proceedResult; + }; + $this->subjectMock = $this->getMock('Magento\Catalog\Model\Product\Validator', array(), array(), '', false); $this->plugin = new \Magento\ConfigurableProduct\Model\Product\Validator\Plugin( $this->eventManagerMock, $this->productFactoryMock, @@ -126,7 +133,11 @@ class PluginTest extends \PHPUnit_Framework_TestCase $this->assertEquals( $this->proceedResult, - $plugin->aroundValidate($this->arguments, $this->invocationChainMock) + $plugin->aroundValidate($this->subjectMock, + $this->closureMock, + $this->productMock, + $this->requestMock, + $this->responseMock) ); } @@ -154,7 +165,9 @@ class PluginTest extends \PHPUnit_Framework_TestCase $this->responseMock->expects($this->once())->method('setAttributes')->will($this->returnSelf()); $this->assertEquals( $this->proceedResult, - $plugin->aroundValidate($this->arguments, $this->invocationChainMock) + $plugin->aroundValidate($this->subjectMock, $this->closureMock, $this->productMock, + $this->requestMock, + $this->responseMock) ); } @@ -166,7 +179,9 @@ class PluginTest extends \PHPUnit_Framework_TestCase ->with('variations-matrix') ->will($this->returnValue(null)); $this->eventManagerMock->expects($this->never())->method('dispatch'); - $this->plugin->aroundValidate($this->arguments, $this->invocationChainMock); + $this->plugin->aroundValidate($this->subjectMock, $this->closureMock, $this->productMock, + $this->requestMock, + $this->responseMock); } } diff --git a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/DesignTest.php b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/DesignTest.php index 265b51f94e0..b6769aa4b68 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/DesignTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/DesignTest.php @@ -21,19 +21,20 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Core\App\Action\Plugin; class DesignTest extends \PHPUnit_Framework_TestCase { - public function testAroundDispatch() { + $subjectMock = $this->getMock('Magento\App\Action\Action', array(), array(), '', false); $designLoaderMock = $this->getMock('Magento\View\DesignLoader', array(), array(), '', false); - $invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); + $closureMock = function () { + return 'Expected'; + }; + $requestMock = $this->getMock('Magento\App\RequestInterface'); $plugin = new \Magento\Core\App\Action\Plugin\Design($designLoaderMock); $designLoaderMock->expects($this->once())->method('load'); - $invocationChainMock->expects($this->once())->method('proceed')->with(array()); - $plugin->aroundDispatch(array(), $invocationChainMock); + $this->assertEquals('Expected', $plugin->aroundDispatch($subjectMock, $closureMock, $requestMock)); } } diff --git a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php index 13f6b3fea34..49e36b62594 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php @@ -45,45 +45,53 @@ class InstallTest extends \PHPUnit_Framework_TestCase */ protected $_urlMock; + /** + * @var \Closure + */ + protected $closureMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_invocationChainMock; + protected $requestMock; protected function setUp() { $this->_appStateMock = $this->getMock('Magento\App\State', array(), array(), '', false); $this->_response = $this->getMock('Magento\App\ResponseInterface', array('setRedirect', 'sendResponse')); $this->_urlMock = $this->getMock('Magento\Url', array(), array(), '', false); - $this->_invocationChainMock = - $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); + $this->closureMock = function () { + return 'ExpectedValue'; + }; + $this->subjectMock = $this->getMock('Magento\App\Action\Action', array(), array(), '', false); + $this->requestMock = $this->getMock('Magento\App\RequestInterface'); $this->_plugin = new \Magento\Core\App\Action\Plugin\Install( $this->_appStateMock, $this->_response, $this->_urlMock, - $this->getMock('\Magento\App\ActionFlag', array(), array(), '', false) + $this->getMock('Magento\App\ActionFlag', array(), array(), '', false) ); } - public function testAroundDispatch() + public function testAroundDispatchWhenApplicationIsNotInstalled() { $url = 'http://example.com'; $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); $this->_urlMock->expects($this->once())->method('getUrl')->with('install')->will($this->returnValue($url)); $this->_response->expects($this->once())->method('setRedirect')->with($url); - $this->_invocationChainMock->expects($this->never())->method('proceed'); - $this->_plugin->aroundDispatch(array(), $this->_invocationChainMock); + $this->_plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock); } public function testAroundDispatchWhenApplicationIsInstalled() { $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); - $this->_invocationChainMock - ->expects($this->once()) - ->method('proceed') - ->with(array()) - ->will($this->returnValue('ExpectedValue')); - $this->_plugin->aroundDispatch(array(), $this->_invocationChainMock); + $this->assertEquals('ExpectedValue', + $this->_plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock)); } -} \ No newline at end of file +} diff --git a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/LastUrlTest.php b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/LastUrlTest.php index 2fbafb2aad3..79cad8e249b 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/LastUrlTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/LastUrlTest.php @@ -28,15 +28,18 @@ class LastUrlTest extends \PHPUnit_Framework_TestCase public function testAfterDispatch() { $session = $this->getMock('\Magento\Core\Model\Session', array('setLastUrl'), array(), '', false); + $subjectMock = $this->getMock('Magento\App\Action\Action', array(), array(), '', false); + $closureMock = function () { + return 'result'; + }; + $requestMock = $this->getMock('Magento\App\RequestInterface'); $url = $this->getMock('\Magento\Url', array(), array(), '', false); $plugin = new \Magento\Core\App\Action\Plugin\LastUrl($session, $url); $session->expects($this->once())->method('setLastUrl')->with('http://example.com'); - $invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); - $invocationChainMock->expects($this->once())->method('proceed')->will($this->returnValue('result')); $url->expects($this->once()) ->method('getUrl') ->with('*/*/*', array('_current' => true)) ->will($this->returnValue('http://example.com')); - $this->assertEquals('result', $plugin->aroundDispatch(array(), $invocationChainMock)); + $this->assertEquals('result', $plugin->aroundDispatch($subjectMock, $closureMock, $requestMock)); } -} \ No newline at end of file +} diff --git a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/StoreCheckTest.php b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/StoreCheckTest.php index 7be82522312..e5b990d9320 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/StoreCheckTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/StoreCheckTest.php @@ -40,10 +40,20 @@ class StoreCheckTest extends \PHPUnit_Framework_TestCase */ protected $_storeMock; + /** + * @var \Closure + */ + protected $closureMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_invocationChainMock; + protected $requestMock; protected function setUp() { @@ -51,23 +61,27 @@ class StoreCheckTest extends \PHPUnit_Framework_TestCase $this->_storeMock = $this->getMock('Magento\Core\Model\Store', array(), array(), '', false); $this->_storeManagerMock ->expects($this->any())->method('getStore')->will($this->returnValue($this->_storeMock)); - $this->_invocationChainMock = - $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); - $this->_invocationChainMock->expects($this->once())->method('proceed'); + $this->subjectMock = $this->getMock('Magento\App\Action\Action', array(), array(), '', false); + $this->closureMock = function () { + return 'Expected'; + }; + $this->requestMock = $this->getMock('Magento\App\RequestInterface'); $this->_plugin = new \Magento\Core\App\Action\Plugin\StoreCheck($this->_storeManagerMock); } - public function testBeforeDispatchWhenStoreNotActive() + public function testAroundDispatchWhenStoreNotActive() { $this->_storeMock->expects($this->any())->method('getIsActive')->will($this->returnValue(false)); $this->_storeManagerMock->expects($this->once())->method('throwStoreException'); - $this->_plugin->aroundDispatch(array(), $this->_invocationChainMock); + $this->assertEquals('Expected', + $this->_plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock)); } - public function testBeforeDispatchWhenStoreIsActive() + public function testAroundDispatchWhenStoreIsActive() { $this->_storeMock->expects($this->any())->method('getIsActive')->will($this->returnValue(true)); $this->_storeManagerMock->expects($this->never())->method('throwStoreException'); - $this->_plugin->aroundDispatch(array(), $this->_invocationChainMock); + $this->assertEquals('Expected', + $this->_plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock)); } -} \ No newline at end of file +} diff --git a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/DispatchExceptionHandlerTest.php b/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/DispatchExceptionHandlerTest.php index 4819d66bebe..947fb894e1f 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/DispatchExceptionHandlerTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/DispatchExceptionHandlerTest.php @@ -40,10 +40,24 @@ class DispatchExceptionHandlerTest extends \PHPUnit_Framework_TestCase */ protected $_filesystemMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + + /** + * @var \Closure + */ + protected $closureMock; + protected function setUp() { $this->_storeManagerMock = $this->getMock('\Magento\Core\Model\StoreManager', array(), array(), '', false); $this->_filesystemMock = $this->getMock('\Magento\App\Filesystem', array(), array(), '', false); + $this->closureMock = function () { + return 'Expected'; + }; + $this->subjectMock = $this->getMock('Magento\App\FrontController', array(), array(), '', false); $this->_model = new DispatchExceptionHandler( $this->_storeManagerMock, $this->_filesystemMock @@ -52,9 +66,8 @@ class DispatchExceptionHandlerTest extends \PHPUnit_Framework_TestCase public function testAroundDispatch() { - $invocationChainMock = $this->getMock('\Magento\Code\Plugin\InvocationChain', array(), array(), '', false); - $arguments = array(); - $invocationChainMock->expects($this->once())->method('proceed')->with($arguments); - $this->_model->aroundDispatch($arguments, $invocationChainMock); + $requestMock = $this->getMock('Magento\App\RequestInterface'); + $this->assertEquals('Expected', + $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $requestMock)); } } diff --git a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/InstallTest.php b/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/InstallTest.php index b089d735d39..2a9de2fefc5 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/InstallTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/InstallTest.php @@ -44,18 +44,31 @@ class InstallTest extends \PHPUnit_Framework_TestCase */ protected $_dbUpdaterMock; + /** + * @var \Closure + */ + protected $closureMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_invocationChainMock; + protected $requestMock; protected function setUp() { $this->_appStateMock = $this->getMock('\Magento\App\State', array(), array(), '', false); $this->_cacheMock = $this->getMock('\Magento\Cache\FrontendInterface'); $this->_dbUpdaterMock = $this->getMock('\Magento\Module\UpdaterInterface'); - $this->_invocationChainMock = - $this->getMock('\Magento\Code\Plugin\InvocationChain', array(), array(), '', false); + $this->closureMock = function () { + return 'Expected'; + }; + $this->requestMock = $this->getMock('Magento\App\RequestInterface'); + $this->subjectMock = $this->getMock('Magento\App\FrontController', array(), array(), '', false); $this->_model = new \Magento\Module\FrontController\Plugin\Install( $this->_appStateMock, $this->_cacheMock, @@ -65,14 +78,13 @@ class InstallTest extends \PHPUnit_Framework_TestCase public function testAroundDispatch() { - $arguments = array(); $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_cacheMock ->expects($this->once())->method('load')->with('data_upgrade')->will($this->returnValue(false)); $this->_dbUpdaterMock->expects($this->once())->method('updateScheme'); $this->_dbUpdaterMock->expects($this->once())->method('updateData'); $this->_cacheMock->expects($this->once())->method('save')->with('true', 'data_upgrade'); - $this->_invocationChainMock->expects($this->once())->method('proceed')->with($arguments); - $this->_model->aroundDispatch($arguments, $this->_invocationChainMock); + $this->assertEquals('Expected', + $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock)); } -} \ No newline at end of file +} diff --git a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/RequestPreprocessorTest.php b/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/RequestPreprocessorTest.php index bc533ef0ea5..639b0114bd4 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/RequestPreprocessorTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/RequestPreprocessorTest.php @@ -53,7 +53,7 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_invocationChainMock; + protected $closureMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -65,17 +65,23 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase */ protected $_storeMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + protected function setUp() { $this->_storeMock = $this->getMock('\Magento\Core\Model\Store', array(), array(), '', false); $this->_requestMock = $this->getMock('\Magento\App\Request\Http', array(), array(), '', false); - $this->_invocationChainMock - = $this->getMock('\Magento\Code\Plugin\InvocationChain', array(), array(), '', false); + $this->closureMock = function () { + return 'Expected'; + }; $this->_storeManagerMock = $this->getMock('\Magento\Core\Model\StoreManager', array(), array(), '', false); $this->_appStateMock = $this->getMock('\Magento\App\State', array(), array(), '', false); $this->_urlMock = $this->getMock('\Magento\Url', array(), array(), '', false); $this->_storeConfigMock = $this->getMock('\Magento\Core\Model\Store\Config', array(), array(), '', false); - + $this->subjectMock = $this->getMock('Magento\App\FrontController', array(), array(), '', false); $this->_model = new \Magento\Core\App\FrontController\Plugin\RequestPreprocessor( $this->_storeManagerMock, $this->_appStateMock, @@ -90,8 +96,9 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); $this->_requestMock->expects($this->once())->method('setDispatched')->with(false); $this->_storeConfigMock->expects($this->never())->method('getConfig'); - $this->_invocationChainMock->expects($this->once())->method('proceed')->with(array($this->_requestMock)); - $this->_model->aroundDispatch(array($this->_requestMock), $this->_invocationChainMock); + $this->assertEquals('Expected', + $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->_requestMock) + ); } public function testAroundDispatchIfInstalledAndRedirectCodeNotExist() @@ -99,9 +106,10 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->_requestMock->expects($this->once())->method('setDispatched')->with(false); $this->_storeConfigMock->expects($this->once())->method('getConfig')->with('web/url/redirect_to_base'); - $this->_invocationChainMock->expects($this->once())->method('proceed')->with(array($this->_requestMock)); $this->_requestMock->expects($this->never())->method('getRequestUri'); - $this->_model->aroundDispatch(array($this->_requestMock), $this->_invocationChainMock); + $this->assertEquals('Expected', + $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->_requestMock) + ); } public function testAroundDispatchIfInstalledAndRedirectCodeExist() @@ -115,9 +123,10 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase ->method('getStore') ->will($this->returnValue($this->_storeMock)); $this->_storeMock->expects($this->once())->method('getBaseUrl'); - $this->_invocationChainMock->expects($this->once())->method('proceed')->with(array($this->_requestMock)); $this->_requestMock->expects($this->never())->method('getRequestUri'); - $this->_model->aroundDispatch(array($this->_requestMock), $this->_invocationChainMock); + $this->assertEquals('Expected', + $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->_requestMock) + ); } public function testAroundDispatchIfBaseUrlNotExists() @@ -131,7 +140,8 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase ->expects($this->any())->method('getStore')->will($this->returnValue($this->_storeMock)); $this->_storeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue(false)); $this->_requestMock->expects($this->never())->method('getRequestUri'); - $this->_invocationChainMock->expects($this->once())->method('proceed')->with(array($this->_requestMock)); - $this->_model->aroundDispatch(array($this->_requestMock), $this->_invocationChainMock); + $this->assertEquals('Expected', + $this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->_requestMock) + ); } } diff --git a/dev/tests/unit/testsuite/Magento/Core/Controller/Response/HttpTest.php b/dev/tests/unit/testsuite/Magento/Core/Controller/Response/HttpTest.php index 6637faafe03..daf6539e698 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Controller/Response/HttpTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Controller/Response/HttpTest.php @@ -41,7 +41,9 @@ class HttpTest extends \PHPUnit_Framework_TestCase */ public function testGetHeaderExists($header) { - $response = new \Magento\App\Response\Http(); + $cookieMock = $this->getMock('\Magento\Stdlib\Cookie', array(), array(), '', false); + $contextMock = $this->getMock('Magento\App\Http\Context', array(), array(), '', false); + $response = new \Magento\App\Response\Http($cookieMock, $contextMock); $response->headersSentThrowsException = false; $response->setHeader($header['name'], $header['value'], $header['replace']); $this->assertEquals($header, $response->getHeader($header['name'])); @@ -77,7 +79,9 @@ class HttpTest extends \PHPUnit_Framework_TestCase */ public function testGetHeaderNotExists() { - $response = new \Magento\App\Response\Http(); + $cookieMock = $this->getMock('\Magento\Stdlib\Cookie', array(), array(), '', false); + $contextMock = $this->getMock('Magento\App\Http\Context', array(), array(), '', false); + $response = new \Magento\App\Response\Http($cookieMock, $contextMock); $response->headersSentThrowsException = false; $response->setHeader('Name', 'value', true); $this->assertFalse($response->getHeader('Wrong name')); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/Directory/DatabaseTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/Directory/DatabaseTest.php index 532fc2f65d4..bba205a0da0 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/Directory/DatabaseTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/Directory/DatabaseTest.php @@ -53,7 +53,7 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase protected $helperStorageDatabase; /** - * @var \Magento\Core\Model\Date |\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Stdlib\DateTime\DateTime |\PHPUnit_Framework_MockObject_MockObject */ protected $dateModelMock; @@ -101,7 +101,7 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase $this->registryMock = $this->getMock('Magento\Registry', array(), array(), '', false); $this->helperStorageDatabase = $this->getMock('Magento\Core\Helper\File\Storage\Database', array(), array(), '', false); - $this->dateModelMock = $this->getMock('Magento\Core\Model\Date', + $this->dateModelMock = $this->getMock('Magento\Stdlib\DateTime\DateTime', array(), array(), '', false); $this->applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/MediaTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/MediaTest.php index e654f5713e4..5d466c21f6e 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/MediaTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/MediaTest.php @@ -43,7 +43,7 @@ class MediaTest extends \PHPUnit_Framework_TestCase protected $_storageHelperMock; /** - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_mediaHelperMock; diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/LocaleTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/LocaleTest.php deleted file mode 100644 index 57990a547aa..00000000000 --- a/dev/tests/unit/testsuite/Magento/Core/Model/LocaleTest.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Core - * @subpackage unit_tests - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Core\Model; - -class LocaleTest extends \PHPUnit_Framework_TestCase -{ - const DEFAULT_TIME_ZONE = 'America/New_York'; - - const TIME_FORMAT_SHORT_ISO = 'h:mm a'; - - const DATETIME_FORMAT_SHORT = 'n/j/y g:i A'; - - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $_objectManager; - - /** - * @var \Magento\Core\Model\App - */ - protected $_app; - - /** - * @var \Magento\Core\Model\App - */ - protected $_storeManager; - - /** - * @var \DateTime - */ - protected $_dateTime; - - protected function setUp() - { - $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - - $this->_app = $this->getMock( - '\Magento\Core\Model\App', - array('getCache', 'getLowLevelFrontend', 'getStore'), - array(), - '', - false - ); - - $this->_storeManager = $this->getMock( - '\Magento\Core\Model\StoreManager', - array('getStore', 'getConfig'), - array(), - '', - false - ); - - $this->_dateTime = new \DateTime; - $this->_dateTime->setTimezone(new \DateTimeZone(self::DEFAULT_TIME_ZONE)); - } - - public function testFormatDate() - { - /** @var $locale \Magento\Core\Model\Locale */ - $locale = $this->_objectManager->getObject( - '\Magento\Core\Model\Locale', - $this->_getConstructArgsForDateFormatting() - ); - - $this->assertEquals( - $this->_dateTime->format(self::DATETIME_FORMAT_SHORT), - $locale->formatDate(null, 'short', true) - ); - } - - public function testFormatTime() - { - /** @var $locale \Magento\Core\Model\Locale */ - $locale = $this->_objectManager->getObject( - '\Magento\Core\Model\Locale', - $this->_getConstructArgsForDateFormatting() - ); - - $this->assertEquals( - $this->_dateTime->format(self::DATETIME_FORMAT_SHORT), $locale->formatTime(null, 'short', true) - ); - - $zendDate = new \Zend_Date($this->_dateTime->format('U')); - $this->assertEquals( - $zendDate->toString(self::TIME_FORMAT_SHORT_ISO), - $locale->formatTime($zendDate, 'short') - ); - } - - protected function _getConstructArgsForDateFormatting() - { - $this->_app->expects($this->once()) - ->method('getCache') - ->will($this->returnValue($this->_app)); - - $cache = $this->getMock('Zend_Cache_Core'); - $this->_app->expects($this->once()) - ->method('getLowLevelFrontend') - ->will($this->returnValue($cache)); - - $this->_storeManager->expects($this->once()) - ->method('getStore') - ->will($this->returnValue($this->_storeManager)); - - $this->_storeManager->expects($this->once()) - ->method('getConfig') - ->will($this->returnValue(self::DEFAULT_TIME_ZONE)); - - return array('app' => $this->_app, 'storeManager' => $this->_storeManager); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/TemplateEngine/Plugin/DebugHintsTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/TemplateEngine/Plugin/DebugHintsTest.php index 958d045c959..56b557b2927 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/TemplateEngine/Plugin/DebugHintsTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/TemplateEngine/Plugin/DebugHintsTest.php @@ -46,11 +46,17 @@ class DebugHintsTest extends \PHPUnit_Framework_TestCase */ protected $_coreData; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + protected function setUp() { $this->_objectManager = $this->getMock('Magento\ObjectManager'); $this->_storeConfig = $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false); $this->_coreData = $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false); + $this->subjectMock = $this->getMock('Magento\View\TemplateEngineFactory', array(), array(), '', false); $this->_model = new DebugHints($this->_objectManager, $this->_storeConfig, $this->_coreData); } @@ -73,7 +79,7 @@ class DebugHintsTest extends \PHPUnit_Framework_TestCase ) ->will($this->returnValue($engineDecorated)) ; - $this->assertEquals($engineDecorated, $this->_model->afterCreate($engine)); + $this->assertEquals($engineDecorated, $this->_model->afterCreate($this->subjectMock, $engine)); } public function afterCreateActiveDataProvider() @@ -94,8 +100,8 @@ class DebugHintsTest extends \PHPUnit_Framework_TestCase $this->_coreData->expects($this->any())->method('isDevAllowed')->will($this->returnValue($isDevAllowed)); $this->_setupConfigFixture($showTemplateHints, true); $this->_objectManager->expects($this->never())->method('create'); - $engine = $this->getMock('Magento\View\TemplateEngineInterface'); - $this->assertSame($engine, $this->_model->afterCreate($engine)); + $engine = $this->getMock('Magento\View\TemplateEngineInterface', array(), array(), '', false); + $this->assertSame($engine, $this->_model->afterCreate($this->subjectMock, $engine)); } public function afterCreateInactiveDataProvider() diff --git a/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php b/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php index c4c27b9600e..46ee0f6ee23 100644 --- a/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php +++ b/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php @@ -28,32 +28,38 @@ class ApplicationInitializerTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Cron\App\Cron\Plugin\ApplicationInitializer */ - protected $_model; + protected $model; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_applicationMock; + protected $applicationMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_sidResolverMock; + protected $sidResolverMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; protected function setUp() { - $this->_applicationMock = $this->getMock('Magento\AppInterface'); - $this->_sidResolverMock = $this->getMock('\Magento\Session\SidResolverInterface', array(), array(), '', false); - $this->_model = new ApplicationInitializer( - $this->_applicationMock, - $this->_sidResolverMock + $this->applicationMock = $this->getMock('Magento\AppInterface'); + $this->sidResolverMock = $this->getMock('\Magento\Session\SidResolverInterface', array(), array(), '', false); + $this->subjectMock = $this->getMock('Magento\App\Cron', array(), array(), '', false); + $this->model = new ApplicationInitializer( + $this->applicationMock, + $this->sidResolverMock ); } public function testBeforeExecutePerformsRequiredChecks() { - $this->_applicationMock->expects($this->once())->method('requireInstalledInstance'); - $this->_sidResolverMock->expects($this->once())->method('setUseSessionInUrl')->with(false); - $this->_model->beforeExecute(array()); + $this->applicationMock->expects($this->once())->method('requireInstalledInstance'); + $this->sidResolverMock->expects($this->once())->method('setUseSessionInUrl')->with(false); + $this->model->beforeLaunch($this->subjectMock); } } diff --git a/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/Plugin/LessTest.php b/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/Plugin/LessTest.php index a0800a31cc6..1df913343a2 100644 --- a/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/Plugin/LessTest.php +++ b/dev/tests/unit/testsuite/Magento/Css/PreProcessor/Cache/Plugin/LessTest.php @@ -63,12 +63,14 @@ class LessTest extends \PHPUnit_Framework_TestCase } /** - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain - * @param array $cacheManagerData + * @param \Closure $proceed + * @param $publisherFile + * @param $targetDirectory + * @param $cacheManagerData + * * @dataProvider aroundProcessDataProvider */ - public function testAroundProcess($arguments, $invocationChain, $cacheManagerData) + public function testAroundProcess(\Closure $proceed, $publisherFile, $targetDirectory, $cacheManagerData) { if (!empty($cacheManagerData)) { foreach ($cacheManagerData as $method => $info) { @@ -86,7 +88,12 @@ class LessTest extends \PHPUnit_Framework_TestCase } $this->assertInstanceOf( 'Magento\View\Publisher\CssFile', - $this->plugin->aroundProcess($arguments, $invocationChain) + $this->plugin->aroundProcess( + $this->getMock('\Magento\Css\PreProcessor\Less', array(), array(), '', false), + $proceed, + $publisherFile, + $targetDirectory + ) ); } @@ -95,6 +102,7 @@ class LessTest extends \PHPUnit_Framework_TestCase */ public function aroundProcessDataProvider() { + $dir = 'targetDirectory'; /** * Prepare first item */ @@ -103,18 +111,18 @@ class LessTest extends \PHPUnit_Framework_TestCase ->method('getSourcePath') ->will($this->returnValue(false)); - $argFirst[] = $cssFileFirst; - $expectedFirst = $this->getMock('Magento\View\Publisher\CssFile', [], [], '', false); $cssFileFirst->expects($this->once()) ->method('buildUniquePath') ->will($this->returnValue('expectedFirst')); - $invChainFirst = $this->getMock('Magento\Code\Plugin\InvocationChain', [], [], '', false); - $invChainFirst->expects($this->once()) - ->method('proceed') - ->with($this->equalTo($argFirst)) - ->will($this->returnValue($expectedFirst)); + $invChainFirst = function ( + \Magento\View\Publisher\CssFile $subject, $directory + ) use ($cssFileFirst, $dir, $expectedFirst) { + $this->assertEquals($subject, $cssFileFirst); + $this->assertEquals($directory, $dir); + return $expectedFirst; + }; /** * Prepare second item @@ -124,8 +132,9 @@ class LessTest extends \PHPUnit_Framework_TestCase ->method('getSourcePath') ->will($this->returnValue(false)); - $argSecond[] = $cssFileSecond; - $invChainSecond = $this->getMock('Magento\Code\Plugin\InvocationChain', [], [], '', false); + $invChainSecond = function () { + $this->fail('Incorrect call of procced method'); + }; /** * Prepare third item @@ -135,64 +144,78 @@ class LessTest extends \PHPUnit_Framework_TestCase ->method('getSourcePath') ->will($this->returnValue(false)); - $argThird[] = $cssFileThird; - $expectedThird = $this->getMock('Magento\View\Publisher\CssFile', [], [], '', false); - $invChainThird = $this->getMock('Magento\Code\Plugin\InvocationChain', [], [], '', false); - $invChainThird->expects($this->once()) - ->method('proceed') - ->with($this->equalTo($argThird)) - ->will($this->returnValue($expectedThird)); - - return [ - 'source path already exist' => [ - 'arguments' => $argFirst, - 'invocationChain' => $invChainFirst, + $invChainThird = function ( + \Magento\View\Publisher\CssFile $subject, $directory + ) use ($cssFileThird, $dir, $expectedThird) { + $this->assertEquals($subject, $cssFileThird); + $this->assertEquals($directory, $dir); + return $expectedThird; + }; + + return array( + 'source path already exist' => array( + 'procced' => $invChainFirst, + 'publisherFile' => $cssFileFirst, + 'targetDirectory' => $dir, 'cacheManagerData' => [], 'expected' => $expectedFirst - ], - 'cached value exists' => [ - 'arguments' => $argSecond, - 'invocationChain' => $invChainSecond, - 'cacheManagerData' => ['getCachedFile' => ['result' => $cssFileSecond]], + ), + 'cached value exists' => array( + 'procced' => $invChainSecond, + 'publisherFile' => $cssFileSecond, + 'targetDirectory' => $dir, + 'cacheManagerData' => array('getCachedFile' => array('result' => $cssFileSecond)), 'expected' => 'cached-value' - ], - 'cached value does not exist' => [ - 'arguments' => $argThird, - 'invocationChain' => $invChainThird, - 'cacheManagerData' => [ - 'getCachedFile' => ['result' => null], - 'saveCache' => ['result' => 'self'] - ], + ), + 'cached value does not exist' => array( + 'procced' => $invChainThird, + 'publisherFile' => $cssFileThird, + 'targetDirectory' => $dir, + 'cacheManagerData' => array( + 'getCachedFile' => array('result' => null), + 'saveCache' => array('result' => 'self') + ), 'expected' => $expectedThird - ], - ]; + ), + ); + } public function testAroundProcessException() { + $dir = 'targetDirectory'; $cssFile = $this->getMock('Magento\View\Publisher\CssFile', [], [], '', false); $cssFile->expects($this->once()) ->method('getSourcePath') ->will($this->returnValue(false)); - $arguments[] = $cssFile; - $this->cacheManagerMock->expects($this->once()) ->method('getCachedFile') ->will($this->returnValue(null)); $exception = new \Magento\Filesystem\FilesystemException('Test Message'); - $invocationChain = $this->getMock('Magento\Code\Plugin\InvocationChain', [], [], '', false); - $invocationChain->expects($this->once()) - ->method('proceed') - ->with($this->equalTo($arguments)) - ->will($this->throwException($exception)); + $proceed = function ( + \Magento\View\Publisher\CssFile $subject, $directory + ) use ($cssFile, $dir, $exception) { + $this->assertEquals($subject, $cssFile); + $this->assertEquals($directory, $dir); + throw $exception; + }; + $this->loggerMock->expects($this->once()) ->method('logException') ->with($this->equalTo($exception)) ->will($this->returnSelf()); - $this->assertNull($this->plugin->aroundProcess($arguments, $invocationChain)); + + $this->assertNull( + $this->plugin->aroundProcess( + $this->getMock('\Magento\Css\PreProcessor\Less', array(), array(), '', false), + $proceed, + $cssFile, + $dir + ) + ); } } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Account/CustomerTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Account/CustomerTest.php old mode 100644 new mode 100755 index 884f586fea1..f3712979c78 --- a/dev/tests/unit/testsuite/Magento/Customer/Block/Account/CustomerTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Account/CustomerTest.php @@ -28,22 +28,40 @@ class CustomerTest extends \PHPUnit_Framework_TestCase { public function testGetCustomerName() { - $customer = $this->getMock('Magento\Customer\Model\Customer', array(), array(), '', false); - $customer->expects($this->once())->method('getName')->will($this->returnValue('John Doe')); + $customerName = 'John Doe'; - $escapedName = new \stdClass(); - $escaper = $this->getMock('Magento\Escaper', array(), array(), '', false); - $escaper - ->expects($this->once())->method('escapeHtml')->with('John Doe')->will($this->returnValue($escapedName)); + $sessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + ->disableOriginalConstructor() + ->getMock(); - $context = $this->getMock('Magento\View\Element\Template\Context', array(), array(), '', false); - $context->expects($this->once())->method('getEscaper')->will($this->returnValue($escaper)); + $customer = $this->getMockBuilder('Magento\Customer\Service\V1\Dto\Customer') + ->disableOriginalConstructor() + ->getMock(); - $session = $this->getMock('Magento\Customer\Model\Session', array(), array(), '', false); - $session->expects($this->once())->method('getCustomer')->will($this->returnValue($customer)); + $customerServiceMock = $this->getMockBuilder('\Magento\Customer\Service\V1\CustomerServiceInterface') + ->disableOriginalConstructor() + ->getMock(); + $customerServiceMock->expects($this->any())->method('getCustomer')->will($this->returnValue($customer)); - $block = new \Magento\Customer\Block\Account\Customer($context, $session); + $viewHelperMock = $this->getMockBuilder('Magento\Customer\Helper\View') + ->disableOriginalConstructor() + ->getMock(); + $viewHelperMock->expects($this->any())->method('getCustomerName')->will($this->returnValue($customerName)); - $this->assertSame($escapedName, $block->getCustomerName()); + $escaperMock = $this->getMockBuilder('Magento\Escaper') + ->disableOriginalConstructor() + ->getMock(); + $escaperMock->expects($this->any())->method('escapeHtml')->with($customerName) + ->will($this->returnValue($customerName)); + + $contextMock = $this->getMockBuilder('Magento\View\Element\Template\Context') + ->disableOriginalConstructor() + ->getMock(); + $contextMock->expects($this->any())->method('getEscaper')->will($this->returnValue($escaperMock)); + + $block = new \Magento\Customer\Block\Account\Customer($contextMock, $sessionMock, $customerServiceMock, + $viewHelperMock); + + $this->assertSame($customerName, $block->getCustomerName()); } } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Account/Dashboard/InfoTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Account/Dashboard/InfoTest.php index 8115a7d0ffb..97ac995fe9f 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Block/Account/Dashboard/InfoTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Account/Dashboard/InfoTest.php @@ -38,12 +38,6 @@ class InfoTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\View\Element\Template\Context */ private $_context; - /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Session */ - private $_customerSession; - - /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\CustomerServiceInterface */ - private $_customerService; - /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\Customer */ private $_customer; @@ -64,8 +58,18 @@ class InfoTest extends \PHPUnit_Framework_TestCase /** @var Info */ private $_block; + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\CustomerCurrentServiceInterface + */ + protected $customerCurrentService; + public function setUp() { + + $this->customerCurrentService = $this->getMockForAbstractClass( + 'Magento\Customer\Service\V1\CustomerCurrentServiceInterface', + array(), '', false, true, true, array()); + $urlBuilder = $this->getMockForAbstractClass('Magento\UrlInterface', array(), '', false); $urlBuilder->expects($this->any())->method('getUrl')->will($this->returnValue(self::CHANGE_PASSWORD_URL)); @@ -79,16 +83,9 @@ class InfoTest extends \PHPUnit_Framework_TestCase $this->_context->expects($this->once())->method('getUrlBuilder')->will($this->returnValue($urlBuilder)); $this->_context->expects($this->once())->method('getLayout')->will($this->returnValue($layout)); - $this->_customerSession = $this->getMock('Magento\Customer\Model\Session', array(), array(), '', false); - $this->_customerSession->expects($this->any())->method('getId')->will($this->returnValue(self::CUSTOMER_ID)); - - $this->_customerService = $this->getMockForAbstractClass( - 'Magento\Customer\Service\V1\CustomerServiceInterface', array(), '', false - ); $this->_customer = $this->getMock('Magento\Customer\Service\V1\Dto\Customer', array(), array(), '', false); $this->_customer->expects($this->any())->method('getEmail')->will($this->returnValue(self::EMAIL_ADDRESS)); - $this->_customerService - ->expects($this->any())->method('getCustomer')->will($this->returnValue($this->_customer)); + $this->_metadataService = $this->getMockForAbstractClass( 'Magento\Customer\Service\V1\CustomerMetadataServiceInterface', array(), '', false @@ -98,12 +95,13 @@ class InfoTest extends \PHPUnit_Framework_TestCase $this->_subscriber = $this->getMock('Magento\Newsletter\Model\Subscriber', array(), array(), '', false); $this->_subscriber->expects($this->any())->method('loadByEmail')->will($this->returnSelf()); $this->_subscriberFactory - ->expects($this->any())->method('create')->will($this->returnValue($this->_subscriber)); + ->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->_subscriber)); $this->_block = new Info( $this->_context, - $this->_customerSession, - $this->_customerService, + $this->customerCurrentService, $this->_metadataService, $this->_subscriberFactory ); @@ -111,16 +109,21 @@ class InfoTest extends \PHPUnit_Framework_TestCase public function testGetCustomer() { - $this->_customer->expects($this->once())->method('getCustomerId')->will($this->returnValue(self::CUSTOMER_ID)); + + $this->customerCurrentService->expects($this->once()) + ->method('getCustomer') + ->will($this->returnValue($this->_customer)); + $customer = $this->_block->getCustomer(); - $this->assertEquals(self::CUSTOMER_ID, $customer->getCustomerId()); + $this->assertEquals($customer, $this->_customer); } public function testGetCustomerException() { - $this->_customerService + $this->customerCurrentService ->expects($this->once()) - ->method('getCustomer')->will($this->throwException(new NoSuchEntityException('customerId', 1))); + ->method('getCustomer') + ->will($this->throwException(new NoSuchEntityException('customerId', 1))); $this->assertNull($this->_block->getCustomer()); } @@ -142,6 +145,11 @@ class InfoTest extends \PHPUnit_Framework_TestCase public function testGetName( array $isVisible, $prefix, $firstname, $middlename, $lastname, $suffix, $expectedValue ) { + + $this->customerCurrentService->expects($this->once()) + ->method('getCustomer') + ->will($this->returnValue($this->_customer)); + $attributeMetadata = $this->getMock('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', array(), array(), '', false); @@ -158,18 +166,30 @@ class InfoTest extends \PHPUnit_Framework_TestCase */ foreach ($isVisible as $index => $boolean) { $attributeMetadata - ->expects($this->at($index))->method('isVisible')->will($this->returnValue($boolean)); + ->expects($this->at($index)) + ->method('isVisible') + ->will($this->returnValue($boolean)); } /** * The AttributeMetadata::{getPrefix() | getMiddlename() | getSuffix()} methods are called twice, * while getFirstname() and getLastname() are only called once. Hence the use of any() vs. once(). */ - $this->_customer->expects($this->any())->method('getPrefix')->will($this->returnValue($prefix)); - $this->_customer->expects($this->once())->method('getFirstname')->will($this->returnValue($firstname)); - $this->_customer->expects($this->any())->method('getMiddlename')->will($this->returnValue($middlename)); - $this->_customer->expects($this->once())->method('getLastname')->will($this->returnValue($lastname)); - $this->_customer->expects($this->any())->method('getSuffix')->will($this->returnValue($suffix)); + $this->_customer->expects($this->any()) + ->method('getPrefix') + ->will($this->returnValue($prefix)); + $this->_customer->expects($this->once()) + ->method('getFirstname') + ->will($this->returnValue($firstname)); + $this->_customer->expects($this->any()) + ->method('getMiddlename') + ->will($this->returnValue($middlename)); + $this->_customer->expects($this->once()) + ->method('getLastname') + ->will($this->returnValue($lastname)); + $this->_customer->expects($this->any()) + ->method('getSuffix') + ->will($this->returnValue($suffix)); $this->assertEquals($expectedValue, $this->_block->getName()); } @@ -201,6 +221,10 @@ class InfoTest extends \PHPUnit_Framework_TestCase ->method('getCustomerAttributeMetadata') ->will($this->throwException(new NoSuchEntityException('field', 'value'))); + $this->customerCurrentService->expects($this->once()) + ->method('getCustomer') + ->will($this->returnValue($this->_customer)); + /** * The AttributeMetadata::{getPrefix() | getMiddlename() | getSuffix()} methods are called twice, * while getFirstname() and getLastname() are only called once. Hence the use of any() vs. once(). diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php index 85d3f345e03..6cc9a286f03 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/DobTest.php @@ -23,7 +23,6 @@ */ namespace Magento\Customer\Block\Widget; -use Magento\Core\Model\LocaleInterface; use Magento\Exception\NoSuchEntityException; class DobTest extends \PHPUnit_Framework_TestCase @@ -62,23 +61,34 @@ class DobTest extends \PHPUnit_Framework_TestCase $frontendCache = $this->getMockForAbstractClass('Magento\Cache\FrontendInterface', [], '', false); $frontendCache->expects($this->any()) ->method('getLowLevelFrontend')->will($this->returnValue($zendCacheCore)); - $app = $this->getMock('Magento\Core\Model\App', [], [], '', false); - $app->expects($this->any())->method('getCache')->will($this->returnValue($frontendCache)); + $cache = $this->getMock('Magento\App\CacheInterface'); + $cache->expects($this->any())->method('getFrontend')->will($this->returnValue($frontendCache)); $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $locale = $objectManager - ->getObject('Magento\Core\Model\Locale', ['app' => $app, 'locale' => LocaleInterface::DEFAULT_LOCALE]); + $locale = $objectManager->getObject('\Magento\Locale', array( + 'locale' => \Magento\Locale\ResolverInterface::DEFAULT_LOCALE + )); + $localeResolver = $this->getMock('\Magento\Locale\ResolverInterface'); + $localeResolver->expects($this->any()) + ->method('getLocale') + ->will($this->returnValue($locale)); + $timezone = $objectManager + ->getObject( + '\Magento\Stdlib\DateTime\Timezone', + ['localeResolver' => $localeResolver] + ); $context = $this->getMock('Magento\View\Element\Template\Context', [], [], '', false); - $context->expects($this->any())->method('getLocale')->will($this->returnValue($locale)); + $context->expects($this->any())->method('getLocaleDate')->will($this->returnValue($timezone)); $this->_attribute = $this->getMock('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', [], [], '', false); $this->_metadataService = $this->getMockForAbstractClass( 'Magento\Customer\Service\V1\CustomerMetadataServiceInterface', [], '', false ); - $this->_metadataService - ->expects($this->any())->method('getAttributeMetadata')->will($this->returnValue($this->_attribute)); + $this->_metadataService->expects($this->any()) + ->method('getCustomerAttributeMetadata') + ->will($this->returnValue($this->_attribute)); date_default_timezone_set('America/Los_Angeles'); @@ -248,7 +258,7 @@ class DobTest extends \PHPUnit_Framework_TestCase } /** - * The LocaleInterface::DEFAULT_LOCALE is used to derive the Locale that is used to determine the + * The \Magento\Locale\ResolverInterface::DEFAULT_LOCALE is used to derive the Locale that is used to determine the * value of Dob::getDateFormat() for that Locale. */ public function testGetDateFormat() diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/GenderTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/GenderTest.php index 3e55559bd94..f096e939f06 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/GenderTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/GenderTest.php @@ -23,6 +23,7 @@ */ namespace Magento\Customer\Block\Widget; +use Magento\Customer\Service\V1\Dto\Customer; use Magento\Exception\NoSuchEntityException; class GenderTest extends \PHPUnit_Framework_TestCase @@ -31,9 +32,6 @@ class GenderTest extends \PHPUnit_Framework_TestCase const CUSTOMER_ENTITY_TYPE = 'customer'; const GENDER_ATTRIBUTE_CODE = 'gender'; - /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Eav\Model\Entity\Attribute\AbstractAttribute */ - private $_abstractAttribute; - /** * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\CustomerMetadataServiceInterface */ @@ -45,44 +43,41 @@ class GenderTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Session */ private $_customerSession; - /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Resource\Customer */ - private $_customerResource; + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\CustomerServiceInterface */ + private $_customerService; /** @var Gender */ private $_block; public function setUp() { - $this->_attribute = $this->getMock('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', [], [], '', false); - - $this->_abstractAttribute = - $this->getMockForAbstractClass( - 'Magento\Eav\Model\Entity\Attribute\AbstractAttribute', - [], '', false, true, true, ['__wakeup', 'getSource'] - ); + $this->_attribute = + $this->getMock('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', [], [], '', false); $this->_attributeMetadata = $this->getMockForAbstractClass( 'Magento\Customer\Service\V1\CustomerMetadataServiceInterface', [], '', false ); - $this->_attributeMetadata->expects($this->any())->method('getAttributeMetadata') - ->with(self::CUSTOMER_ENTITY_TYPE, self::GENDER_ATTRIBUTE_CODE) + $this->_attributeMetadata->expects($this->any())->method('getCustomerAttributeMetadata') + ->with(self::GENDER_ATTRIBUTE_CODE) ->will($this->returnValue($this->_attribute)); + $this->_customerService = + $this->getMockForAbstractClass('Magento\Customer\Service\V1\CustomerServiceInterface', [], '', false); $this->_customerSession = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->_customerResource = - $this->getMock('Magento\Customer\Model\Resource\Customer', [], [], '', false); $this->_block = new Gender( $this->getMock('Magento\View\Element\Template\Context', [], [], '', false), $this->getMock('Magento\Customer\Helper\Address', [], [], '', false), $this->_attributeMetadata, - $this->_customerSession, - $this->_customerResource + $this->_customerService, + $this->_customerSession ); } /** + * Test the Gender::isEnabled() method. + * * @param bool $isVisible Determines whether the 'gender' attribute is visible or enabled * @param bool $expectedValue The value we expect from Gender::isEnabled() * @return void @@ -96,6 +91,7 @@ class GenderTest extends \PHPUnit_Framework_TestCase } /** + * The testIsEnabled data provider. * @return array */ public function isEnabledDataProvider() @@ -116,6 +112,8 @@ class GenderTest extends \PHPUnit_Framework_TestCase } /** + * Test the Gender::isRequired() method. + * * @param bool $isRequired Determines whether the 'gender' attribute is required * @param bool $expectedValue The value we expect from Gender::isRequired() * @return void @@ -129,6 +127,7 @@ class GenderTest extends \PHPUnit_Framework_TestCase } /** + * The testIsRequired data provider. * @return array */ public function isRequiredDataProvider() @@ -148,51 +147,39 @@ class GenderTest extends \PHPUnit_Framework_TestCase $this->assertSame(false, $this->_block->isRequired()); } + /** + * Test the Gender::getCustomer() method. + * @return void + */ public function testGetCustomer() { - /** Do not include prefix, middlename, and suffix attributes when calling Customer::getName() */ - $this->_abstractAttribute->expects($this->any())->method('isVisible')->will($this->returnValue(false)); - - $config = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); - $config->expects($this->any())->method('getAttribute')->will($this->returnValue($this->_abstractAttribute)); - - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $data = ['firstname' => 'John', 'lastname' => 'Doe']; - $customerModel = $objectManager - ->getObject('Magento\Customer\Model\Customer', ['config' => $config, 'data' => $data]); + $customerDto = new Customer($data); + $this->_customerSession - ->expects($this->once())->method('getCustomer')->will($this->returnValue($customerModel)); + ->expects($this->once())->method('getCustomerId')->will($this->returnValue(1)); + $this->_customerService + ->expects($this->once())->method('getCustomer')->with(1)->will($this->returnValue($customerDto)); $customer = $this->_block->getCustomer(); - $this->assertSame($customerModel, $customer); + $this->assertSame($customerDto, $customer); - $this->assertEquals('John Doe', $customer->getName()); + $this->assertEquals('John', $customer->getFirstname()); + $this->assertEquals('Doe', $customer->getLastname()); } + /** + * Test the Gender::getGenderOptions() method. + * @return void + */ public function testGetGenderOptions() { $options = [ - [ - 'label' => __('Male'), - 'value' => 'M' - ], - [ - 'label' => __('Female'), - 'value' => 'F' - ] + ['label' => __('Male'), 'value' => 'M'], + ['label' => __('Female'), 'value' => 'F'] ]; - $this->_customerResource->expects($this->once())->method('getAttribute') - ->with(self::GENDER_ATTRIBUTE_CODE)->will($this->returnValue($this->_abstractAttribute)); - - $source = $this->getMockForAbstractClass( - 'Magento\Eav\Model\Entity\Attribute\Source\AbstractSource', [], '', false - ); - $source->expects($this->once())->method('getAllOptions')->will($this->returnValue($options)); - - $this->_abstractAttribute->expects($this->once())->method('getSource')->will($this->returnValue($source)); - + $this->_attribute->expects($this->once())->method('getOptions')->will($this->returnValue($options)); $this->assertSame($options, $this->_block->getGenderOptions()); } } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/NameTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/NameTest.php index 8a8d52a06f2..539d95b7f24 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/NameTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/NameTest.php @@ -86,7 +86,11 @@ class NameTest extends \PHPUnit_Framework_TestCase ); $this->_metadataService ->expects($this->any()) - ->method('getAttributeMetadata')->will($this->returnValue($this->_attributeMetadata)); + ->method('getCustomerAttributeMetadata')->will($this->returnValue($this->_attributeMetadata)); + $this->_metadataService + ->expects($this->any()) + ->method('getAddressAttributeMetadata')->will($this->returnValue($this->_attributeMetadata)); + $this->_block = new Name($context, $addressHelper, $this->_metadataService, $this->_customerHelper); } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php index f2b7504be65..4271ff56e58 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Block/Widget/TaxvatTest.php @@ -39,9 +39,6 @@ class TaxvatTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata */ private $_attribute; - /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Session */ - private $_customerSession; - /** @var Taxvat */ private $_block; @@ -54,17 +51,14 @@ class TaxvatTest extends \PHPUnit_Framework_TestCase $this->getMockForAbstractClass( 'Magento\Customer\Service\V1\CustomerMetadataServiceInterface', [], '', false ); - $this->_attributeMetadata->expects($this->any())->method('getAttributeMetadata') - ->with(self::CUSTOMER_ENTITY_TYPE, self::TAXVAT_ATTRIBUTE_CODE) + $this->_attributeMetadata->expects($this->any())->method('getCustomerAttributeMetadata') + ->with(self::TAXVAT_ATTRIBUTE_CODE) ->will($this->returnValue($this->_attribute)); - $this->_customerSession = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); - $this->_block = new Taxvat( $this->getMock('Magento\View\Element\Template\Context', [], [], '', false), $this->getMock('Magento\Customer\Helper\Address', [], [], '', false), - $this->_attributeMetadata, - $this->_customerSession + $this->_attributeMetadata ); } @@ -133,31 +127,4 @@ class TaxvatTest extends \PHPUnit_Framework_TestCase ->will($this->throwException(new NoSuchEntityException('field', 'value'))); $this->assertSame(false, $this->_block->isRequired()); } - - public function testGetCustomer() - { - $abstractAttribute = - $this->getMockForAbstractClass( - 'Magento\Eav\Model\Entity\Attribute\AbstractAttribute', - [], '', false, true, true, ['__wakeup'] - ); - /** Do not include prefix, middlename, and suffix attributes when calling Customer::getName() */ - $abstractAttribute->expects($this->any())->method('isVisible')->will($this->returnValue(false)); - - $config = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); - $config->expects($this->any())->method('getAttribute')->will($this->returnValue($abstractAttribute)); - - $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - - $data = ['firstname' => 'John', 'lastname' => 'Doe']; - $customerModel = $objectManager - ->getObject('Magento\Customer\Model\Customer', ['config' => $config, 'data' => $data]); - $this->_customerSession - ->expects($this->once())->method('getCustomer')->will($this->returnValue($customerModel)); - - $customer = $this->_block->getCustomer(); - $this->assertSame($customerModel, $customer); - - $this->assertEquals('John Doe', $customer->getName()); - } } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php index 179ee0b0d80..994b5106a49 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php @@ -1,7 +1,5 @@ <?php /** - * Unit test for \Magento\Customer\Controller\Adminhtml\Index controller - * * Magento * * NOTICE OF LICENSE @@ -20,16 +18,18 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @subpackage unit_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Controller\Adminhtml; + +use Magento\Customer\Service\V1\CustomerAccountServiceInterface; +use Magento\Exception\NoSuchEntityException; +use Magento\Customer\Service\V1\Dto\Customer; /** - * Class \Magento\Customer\Controller\Adminhtml\IndexTest + * Unit test for \Magento\Customer\Controller\Adminhtml\Index controller */ -namespace Magento\Customer\Controller\Adminhtml; - class IndexTest extends \PHPUnit_Framework_TestCase { /** @@ -60,6 +60,16 @@ class IndexTest extends \PHPUnit_Framework_TestCase */ protected $_objectManager; + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Customer\Service\V1\CustomerAccountServiceInterface + */ + protected $_acctServiceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Customer\Service\V1\CustomerServiceInterface + */ + protected $_customerServiceMock; + /** * Session mock instance * @@ -123,7 +133,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase $this->messageManager = $this->getMockBuilder('Magento\Message\Manager') ->disableOriginalConstructor() - ->setMethods(array('addSuccess')) + ->setMethods(array('addSuccess', 'addMessage', 'addException')) ->getMock(); $contextArgs = array( @@ -153,23 +163,33 @@ class IndexTest extends \PHPUnit_Framework_TestCase ->method('getMessageManager') ->will($this->returnValue($this->messageManager)); - $args = array('context' => $contextMock); + $this->_acctServiceMock = $this + ->getMockBuilder('Magento\Customer\Service\V1\CustomerAccountServiceInterface') + ->getMock(); + $this->_customerServiceMock = $this + ->getMockBuilder('Magento\Customer\Service\V1\CustomerServiceInterface') + ->getMock(); + + $args = [ + 'context' => $contextMock, + 'accountService' => $this->_acctServiceMock, + 'customerService' => $this->_customerServiceMock, + ]; + + $helperObjectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_testedObject = $helperObjectManager->getObject('Magento\Customer\Controller\Adminhtml\Index', $args); } - /** - * Test \Magento\Backend\Controller\Customer::resetPasswordAction() - */ public function testResetPasswordActionNoCustomer() { $redirectLink = 'http://example.com/customer/'; $this->_request->expects($this->once()) ->method('getParam') ->with($this->equalTo('customer_id'), $this->equalTo(0)) - ->will($this->returnValue(false) - ); + ->will($this->returnValue(false)); + $this->_helper->expects($this->once()) ->method('getUrl') ->with($this->equalTo('customer/index'), $this->equalTo(array())) @@ -179,10 +199,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase $this->_testedObject->resetPasswordAction(); } - /** - * Test \Magento\Backend\Controller\Customer::resetPasswordAction() - */ - public function testResetPasswordActionNoCustomerId() + public function testResetPasswordActionInvalidCustomerId() { $redirectLink = 'http://example.com/customer/'; $customerId = 1; @@ -190,15 +207,12 @@ class IndexTest extends \PHPUnit_Framework_TestCase $this->_request->expects($this->once()) ->method('getParam') ->with($this->equalTo('customer_id'), $this->equalTo(0)) - ->will($this->returnValue($customerId) - ); - - $customerMock = $this->_getCustomerMock($customerId, false); + ->will($this->returnValue($customerId)); - $this->_objectManager->expects($this->any()) - ->method('create') - ->with($this->equalTo('Magento\Customer\Model\Customer')) - ->will($this->returnValue($customerMock)); + $this->_customerServiceMock->expects($this->once()) + ->method('getCustomer') + ->with($customerId) + ->will($this->throwException(new NoSuchEntityException('customerId', $customerId))); $this->_helper->expects($this->any()) ->method('getUrl') @@ -209,85 +223,125 @@ class IndexTest extends \PHPUnit_Framework_TestCase $this->_testedObject->resetPasswordAction(); } - /** - * Test that sendPasswordReminderEmail() is called - */ - public function testResetPasswordActionSendEmail() + public function testResetPasswordActionCoreException() { $customerId = 1; - $token = 2; - $testUrl = 'http://example.com'; $this->_request->expects($this->once()) ->method('getParam') ->with($this->equalTo('customer_id'), $this->equalTo(0)) - ->will($this->returnValue($customerId) - ); + ->will($this->returnValue($customerId)); - $customerMock = $this->_getCustomerMock($customerId, true); - $customerMock->expects($this->once()) - ->method('changeResetPasswordLinkToken') - ->with($this->equalTo($token)); - $customerMock->expects($this->once()) - ->method('setResetPasswordUrl') - ->with($this->equalTo($testUrl)); - $customerMock->expects($this->once()) - ->method('sendPasswordReminderEmail'); - - $customerHelperMock = $this->getMock('Magento\Customer\Helper\Data', - array('generateResetPasswordLinkToken'), array(), '', false - ); - $customerHelperMock->expects($this->any()) - ->method('generateResetPasswordLinkToken') - ->will($this->returnValue($token)); + // Setup a core exception to return + $exception = new \Magento\Core\Exception(); + $error = new \Magento\Message\Error('Something Bad happened'); + $exception->addMessage($error); - $coreHelperMock = $this->getMockBuilder('Magento\Url') - ->disableOriginalConstructor() - ->setMethods(array('getUrl', '__wakeup')) - ->getMock(); - $coreHelperMock->expects($this->any())->method('getUrl')->will($this->returnValue($testUrl)); + $this->_customerServiceMock->expects($this->once()) + ->method('getCustomer') + ->with($customerId) + ->will($this->throwException($exception)); + + // Verify error message is set + $this->messageManager->expects($this->once()) + ->method('addMessage') + ->with($this->equalTo($error)); - $this->_objectManager->expects($this->at(0)) - ->method('create') - ->with($this->equalTo('Magento\Customer\Model\Customer')) - ->will($this->returnValue($customerMock)); + $this->_testedObject->resetPasswordAction(); + } - $this->_objectManager->expects($this->at(1)) - ->method('get') - ->with($this->equalTo('Magento\Customer\Helper\Data')) - ->will($this->returnValue($customerHelperMock)); + public function testResetPasswordActionCoreExceptionWarn() + { + $warningText = 'Warning'; + $customerId = 1; - $this->_objectManager->expects($this->at(2)) - ->method('create') - ->with($this->equalTo('Magento\UrlInterface')) - ->will($this->returnValue($coreHelperMock)); + $this->_request->expects($this->once()) + ->method('getParam') + ->with($this->equalTo('customer_id'), $this->equalTo(0)) + ->will($this->returnValue($customerId)); + + // Setup a core exception to return + $exception = new \Magento\Core\Exception($warningText); + $error = new \Magento\Message\Warning('Something Not So Bad happened'); + $exception->addMessage($error); + $this->_customerServiceMock->expects($this->once()) + ->method('getCustomer') + ->with($customerId) + ->will($this->throwException($exception)); + + // Verify Warning is converted to an Error and message text is set to exception text $this->messageManager->expects($this->once()) - ->method('addSuccess') - ->with($this->equalTo('Customer will receive an email with a link to reset password.')); + ->method('addMessage') + ->with($this->equalTo(new \Magento\Message\Error($warningText))); + $this->_testedObject->resetPasswordAction(); } - /** - * Return customer mock instance - * - * @param int $customerId - * @param null|int $returnId - * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Customer\Model\Customer - */ - protected function _getCustomerMock($customerId, $returnId = null) + public function testResetPasswordActionException() { - $customerMock = $this->getMockBuilder('Magento\Customer\Model\Customer') - ->disableOriginalConstructor() - ->setMethods(array('load', 'getId', 'changeResetPasswordLinkToken', 'setResetPasswordUrl', - 'sendPasswordReminderEmail', '__wakeup')) - ->getMock(); - $customerMock->expects($this->any()) - ->method('load') - ->with($this->equalTo($customerId)); - $customerMock->expects($this->any()) - ->method('getId') - ->will($this->returnValue($returnId)); - return $customerMock; + $customerId = 1; + + $this->_request->expects($this->once()) + ->method('getParam') + ->with($this->equalTo('customer_id'), $this->equalTo(0)) + ->will($this->returnValue($customerId)); + + // Setup a core exception to return + $exception = new \Exception('Something Really Bad happened'); + + $this->_customerServiceMock->expects($this->once()) + ->method('getCustomer') + ->with($customerId) + ->will($this->throwException($exception)); + + // Verify error message is set + $this->messageManager->expects($this->once()) + ->method('addException') + ->with($this->equalTo($exception), $this->equalTo('An error occurred while resetting customer password.')); + + $this->_testedObject->resetPasswordAction(); + } + + + public function testResetPasswordActionSendEmail() + { + $customerId = 1; + $email = "test@example.com"; + $websiteId = 1; + $redirectLink = 'http://example.com'; + + $this->_request->expects($this->once()) + ->method('getParam') + ->with($this->equalTo('customer_id'), $this->equalTo(0)) + ->will($this->returnValue($customerId)); + + $customer = new Customer(['id' => $customerId, 'email' => $email, 'website_id' => $websiteId]); + + $this->_customerServiceMock->expects($this->once()) + ->method('getCustomer') + ->with($customerId) + ->will($this->returnValue($customer)); + + // verify sendPasswordResetLink() is called + $this->_acctServiceMock->expects($this->once()) + ->method('sendPasswordResetLink') + ->with($email, $websiteId, CustomerAccountServiceInterface::EMAIL_REMINDER); + + // verify success message + $this->messageManager->expects($this->once()) + ->method('addSuccess') + ->with($this->equalTo('Customer will receive an email with a link to reset password.')); + + // verify redirect + $this->_helper->expects($this->any()) + ->method('getUrl') + ->with($this->equalTo('customer/*/edit'), $this->equalTo(['id' => $customerId, '_current' => true])) + ->will($this->returnValue($redirectLink)); + + $this->_response->expects($this->once())->method('setRedirect')->with($this->equalTo($redirectLink)); + + $this->_testedObject->resetPasswordAction(); } + } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/CustomerTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/CustomerTest.php index a296d4cff2a..1d495c22d04 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/CustomerTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/CustomerTest.php @@ -49,15 +49,15 @@ class CustomerTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Core\Model\Store\Config|\PHPUnit_Framework_MockObject_MockObject */ protected $_coreStoreConfigMock; - /** @var \Magento\Mail\Template\TransportBuilder|PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Mail\Template\TransportBuilder|\PHPUnit_Framework_MockObject_MockObject */ protected $_transportBuilderMock; - /** @var \Magento\Mail\TransportInterface|PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Mail\TransportInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_transportMock; - /** - * Set required values - */ + /** @var \Magento\Encryption\EncryptorInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $_encryptor; + protected function setUp() { $this->_website = $this->getMock('Magento\Core\Model\Website', array(), array(), '', false); @@ -74,14 +74,26 @@ class CustomerTest extends \PHPUnit_Framework_TestCase false ); $this->_transportMock = $this->getMock('Magento\Mail\TransportInterface', array(), array(), '', false); + $this->_encryptor = $this->getMock('Magento\Encryption\EncryptorInterface'); $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_model = $helper->getObject('Magento\Customer\Model\Customer', array( 'storeManager' => $this->_storeManager, 'config' => $this->_config, 'transportBuilder' => $this->_transportBuilderMock, - 'coreStoreConfig' => $this->_coreStoreConfigMock - ) - ); + 'coreStoreConfig' => $this->_coreStoreConfigMock, + 'encryptor' => $this->_encryptor, + )); + } + + public function testHashPassword() + { + $this->_encryptor + ->expects($this->once()) + ->method('getHash') + ->with('password', 'salt') + ->will($this->returnValue('hash')) + ; + $this->assertEquals('hash', $this->_model->hashPassword('password', 'salt')); } public function testSendPasswordResetConfirmationEmail() diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php new file mode 100644 index 00000000000..4ee89f60119 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Layout/DepersonalizePluginTest.php @@ -0,0 +1,266 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Customer + * @subpackage unit_tests + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Customer\Model\Layout; + +/** + * Class DepersonalizePluginTest + * + * @package Magento\Customer\Model\Layout + */ +class DepersonalizePluginTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Customer\Model\Layout\DepersonalizePluginTest + */ + protected $plugin; + + /** + * @var \Magento\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $layoutMock; + + /** + * @var \Magento\Session\SessionManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $sessionMock; + + /** + * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \Magento\Customer\Model\CustomerFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerFactoryMock; + + /** + * @var \Magento\Event\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + + /** + * @var \Magento\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Customer\Model\Customer|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerMock; + + /** + * @var \Magento\Module\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $moduleManagerMock; + + /** + * SetUp + */ + public function setUp() + { + $this->layoutMock = $this->getMock('Magento\Core\Model\Layout', array(), array(), '', false); + $this->sessionMock = $this->getMock( + 'Magento\Core\Model\Session', + array('clearStorage', 'setData', 'getData'), + array(), + '', + false + ); + $this->customerSessionMock = $this->getMock( + 'Magento\Customer\Model\Session', + array('getCustomerGroupId', 'setCustomerGroupId', 'clearStorage', 'setCustomer'), + array(), + '', + false + ); + $this->customerFactoryMock = $this->getMock( + 'Magento\Customer\Model\CustomerFactory', + array('create'), + array(), + '', + false + ); + $this->eventManagerMock = $this->getMock('Magento\Event\Manager', array(), array(), '', false); + $this->requestMock = $this->getMock('Magento\App\Request\Http', array(), array(), '', false); + $this->customerMock = $this->getMock( + 'Magento\Customer\Model\Customer', + array('setGroupId', '__wakeup'), + array(), + '', + false + ); + $this->moduleManagerMock = $this->getMock('Magento\Module\Manager', array(), array(), '', false); + + $this->customerFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->customerMock)); + + $this->plugin = new \Magento\Customer\Model\Layout\DepersonalizePlugin( + $this->layoutMock, + $this->sessionMock, + $this->customerSessionMock, + $this->customerFactoryMock, + $this->eventManagerMock, + $this->requestMock, + $this->moduleManagerMock + ); + } + + /** + * testDepersonalize + */ + public function testDepersonalize() + { + $formKey = md5('form_key'); + $expectedCustomerGroupId = 3; + $result = 'test'; + + $this->moduleManagerMock + ->expects($this->once()) + ->method('isEnabled') + ->with('Magento_PageCache') + ->will($this->returnValue(true)); + $this->requestMock + ->expects($this->once()) + ->method('isAjax') + ->will($this->returnValue(false)); + $this->layoutMock + ->expects($this->once()) + ->method('isCacheable') + ->will($this->returnValue(true)); + $this->sessionMock + ->expects($this->any()) + ->method('getData') + ->with($this->equalTo(\Magento\Data\Form\FormKey::FORM_KEY)) + ->will($this->returnValue($formKey)); + $this->customerSessionMock + ->expects($this->once()) + ->method('getCustomerGroupId') + ->will($this->returnValue($expectedCustomerGroupId)); + $this->eventManagerMock + ->expects($this->once()) + ->method('dispatch') + ->with($this->equalTo('before_session_write_close')); + $this->sessionMock + ->expects($this->once()) + ->method('clearStorage'); + $this->customerSessionMock + ->expects($this->once()) + ->method('clearStorage'); + $this->customerSessionMock + ->expects($this->once()) + ->method('setCustomerGroupId') + ->with($this->equalTo($expectedCustomerGroupId)); + $this->customerMock + ->expects($this->once()) + ->method('setGroupId') + ->with($this->equalTo($expectedCustomerGroupId)); + $this->sessionMock + ->expects($this->once()) + ->method('setData') + ->with( + $this->equalTo(\Magento\Data\Form\FormKey::FORM_KEY), + $this->equalTo($formKey) + ); + $this->customerSessionMock + ->expects($this->once()) + ->method('setCustomer') + ->with($this->equalTo($this->customerMock)); + $output = $this->plugin->afterGenerateXml($this->layoutMock, $result); + $this->assertSame($result, $output); + } + + /** + * testUsualBehaviorIsAjax + */ + public function testUsualBehaviorIsAjax() + { + $result = 'test'; + + $this->moduleManagerMock + ->expects($this->once()) + ->method('isEnabled') + ->with('Magento_PageCache') + ->will($this->returnValue(true)); + $this->requestMock + ->expects($this->once()) + ->method('isAjax') + ->will($this->returnValue(true)); + $this->layoutMock + ->expects($this->never()) + ->method('isCacheable'); + $output = $this->plugin->afterGenerateXml($this->layoutMock, $result); + $this->assertSame($result, $output); + } + + /** + * testUsualBehaviorNonCacheable + */ + public function testUsualBehaviorNonCacheable() + { + $result = 'test'; + + $this->moduleManagerMock + ->expects($this->once()) + ->method('isEnabled') + ->with('Magento_PageCache') + ->will($this->returnValue(true)); + $this->requestMock + ->expects($this->once()) + ->method('isAjax') + ->will($this->returnValue(false)); + $this->layoutMock + ->expects($this->once()) + ->method('isCacheable') + ->will($this->returnValue(false)); + $this->eventManagerMock + ->expects($this->never()) + ->method('dispatch'); + $output = $this->plugin->afterGenerateXml($this->layoutMock, $result); + $this->assertSame($result, $output); + } + + /** + * testUsualBehaviorPageCacheInNotEnabled + */ + public function testUsualBehaviorPageCacheInNotEnabled() + { + $result = 'test'; + + $this->moduleManagerMock + ->expects($this->once()) + ->method('isEnabled') + ->with('Magento_PageCache') + ->will($this->returnValue(false)); + $this->eventManagerMock + ->expects($this->never()) + ->method('dispatch'); + $output = $this->plugin->afterGenerateXml($this->layoutMock, $result); + $this->assertSame($result, $output); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php index fafcfe5391a..bd2dd8fd4be 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractDataTest.php @@ -33,8 +33,10 @@ class AbstractDataTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Customer\Model\Metadata\Form\ExtendsAbstractData */ protected $_model; - /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Core\Model\LocaleInterface */ + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Stdlib\DateTime\TimezoneInterface */ protected $_localeMock; + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Locale\ResolverInterface */ + protected $_localeResolverMock; /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Logger */ protected $_loggerMock; /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata */ @@ -49,7 +51,10 @@ class AbstractDataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_localeMock = $this->getMockBuilder('Magento\Core\Model\LocaleInterface') + $this->_localeMock = $this->getMockBuilder('Magento\Stdlib\DateTime\TimezoneInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->_localeResolverMock = $this->getMockBuilder('Magento\Locale\ResolverInterface') ->disableOriginalConstructor() ->getMock(); $this->_loggerMock = $this->getMockBuilder('Magento\Logger') @@ -66,6 +71,7 @@ class AbstractDataTest extends \PHPUnit_Framework_TestCase $this->_localeMock, $this->_loggerMock, $this->_attributeMock, + $this->_localeResolverMock, $this->_value, $this->_entityTypeCode, $this->_isAjax @@ -161,7 +167,7 @@ class AbstractDataTest extends \PHPUnit_Framework_TestCase $this->_localeMock ->expects($this->once()) ->method('getDateFormat') - ->with($this->equalTo(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT)) + ->with($this->equalTo(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT)) ->will($this->returnValue($output)); } $actual = $this->_model->dateFilterFormat($format); @@ -297,6 +303,7 @@ class AbstractDataTest extends \PHPUnit_Framework_TestCase $this->_localeMock, $this->_loggerMock, $this->_attributeMock, + $this->_localeResolverMock, $this->_value, $this->_entityTypeCode, $ajaxRequest diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractFormTestCase.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractFormTestCase.php index 81a5c2ac5c1..bed1c63db38 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractFormTestCase.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/AbstractFormTestCase.php @@ -26,9 +26,12 @@ namespace Magento\Customer\Model\Metadata\Form; /** Test Magento\Customer\Model\Metadata\Form\Multiline */ abstract class AbstractFormTestCase extends \PHPUnit_Framework_TestCase { - /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Core\Model\LocaleInterface */ + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Stdlib\DateTime\TimezoneInterface */ protected $localeMock; + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Locale\ResolverInterface */ + protected $localeResolverMock; + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Logger */ protected $loggerMock; @@ -37,7 +40,8 @@ abstract class AbstractFormTestCase extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->localeMock = $this->getMockBuilder('Magento\Core\Model\LocaleInterface')->getMock(); + $this->localeMock = $this->getMockBuilder('Magento\Stdlib\DateTime\TimezoneInterface')->getMock(); + $this->localeResolverMock = $this->getMockBuilder('Magento\Locale\ResolverInterface')->getMock(); $this->loggerMock = $this->getMockBuilder('Magento\Logger')->disableOriginalConstructor()->getMock(); $this->attributeMetadataMock = $this->getMockBuilder('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata') ->disableOriginalConstructor() diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/BooleanTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/BooleanTest.php index c705e814866..ee0437abe87 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/BooleanTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/BooleanTest.php @@ -36,7 +36,14 @@ class BooleanTest extends AbstractFormTestCase public function testGetOptionText($value, $expected) { // calling outputValue() will cause the protected method getOptionText() to be called - $boolean = new Boolean($this->localeMock, $this->loggerMock, $this->attributeMetadataMock, $value, 0); + $boolean = new Boolean( + $this->localeMock, + $this->loggerMock, + $this->attributeMetadataMock, + $this->localeResolverMock, + $value, + 0 + ); $this->assertSame($expected, $boolean->outputValue()); } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php index d0a5fb4cdce..afc5a69de0f 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/DateTest.php @@ -43,7 +43,14 @@ class DateTest extends AbstractFormTestCase $this->attributeMetadataMock->expects($this->any()) ->method('getInputFilter') ->will($this->returnValue('date')); - $this->date = new Date($this->localeMock, $this->loggerMock, $this->attributeMetadataMock, null, 0); + $this->date = new Date( + $this->localeMock, + $this->loggerMock, + $this->attributeMetadataMock, + $this->localeResolverMock, + null, + 0 + ); } public function testExtractValue() @@ -156,7 +163,14 @@ class DateTest extends AbstractFormTestCase public function testOutputValue() { $this->assertEquals(null, $this->date->outputValue()); - $date = new Date($this->localeMock, $this->loggerMock, $this->attributeMetadataMock, '2012/12/31', 0); + $date = new Date( + $this->localeMock, + $this->loggerMock, + $this->attributeMetadataMock, + $this->localeResolverMock, + '2012/12/31', + 0 + ); $this->assertEquals('2012-12-31', $date->outputValue()); } diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php index 316cef0d450..0fbd30400c6 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php @@ -329,6 +329,7 @@ class FileTest extends AbstractFormTestCase $this->localeMock, $this->loggerMock, $this->attributeMetadataMock, + $this->localeResolverMock, $value, 0, $isAjax, diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/HiddenTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/HiddenTest.php index 25b8323492d..c6ddd874f2f 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/HiddenTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/HiddenTest.php @@ -37,6 +37,7 @@ class HiddenTest extends TextTest $this->localeMock, $this->loggerMock, $this->attributeMetadataMock, + $this->localeResolverMock, $value, 0, false, diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/ImageTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/ImageTest.php index 439dfbcc0a4..4f776f76139 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/ImageTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/ImageTest.php @@ -39,6 +39,7 @@ class ImageTest extends FileTest $this->localeMock, $this->loggerMock, $this->attributeMetadataMock, + $this->localeResolverMock, $value, 0, $isAjax, diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/MultilineTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/MultilineTest.php index 0d5a0ca7000..9c6921e2989 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/MultilineTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/MultilineTest.php @@ -38,6 +38,7 @@ class MultilineTest extends TextTest $this->localeMock, $this->loggerMock, $this->attributeMetadataMock, + $this->localeResolverMock, $value, 0, false, diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/MultiselectTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/MultiselectTest.php index 3d3482732f5..b58a2d0f855 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/MultiselectTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/MultiselectTest.php @@ -44,6 +44,7 @@ class MultiselectTest extends AbstractFormTestCase $this->localeMock, $this->loggerMock, $this->attributeMetadataMock, + $this->localeResolverMock, $value, 0 ); diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/SelectTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/SelectTest.php index 82646f644f2..6d0602417af 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/SelectTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/SelectTest.php @@ -42,6 +42,7 @@ class SelectTest extends AbstractFormTestCase $this->localeMock, $this->loggerMock, $this->attributeMetadataMock, + $this->localeResolverMock, $value, 0 ); diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/TextTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/TextTest.php index c62d453c359..ca7ed060986 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/TextTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/TextTest.php @@ -48,6 +48,7 @@ class TextTest extends AbstractFormTestCase $this->localeMock, $this->loggerMock, $this->attributeMetadataMock, + $this->localeResolverMock, $value, 0, false, diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/TextareaTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/TextareaTest.php index b0a03e9ec83..df5627d5f51 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/TextareaTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/TextareaTest.php @@ -37,6 +37,7 @@ class TextareaTest extends TextTest $this->localeMock, $this->loggerMock, $this->attributeMetadataMock, + $this->localeResolverMock, $value, 0, false, diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/ValidatorTest.php index ad8b99ad017..cb68052abd3 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/ValidatorTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/ValidatorTest.php @@ -23,6 +23,8 @@ */ namespace Magento\Customer\Model\Metadata; +use Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata; + class ValidatorTest extends \PHPUnit_Framework_TestCase { /** @var Validator */ @@ -36,7 +38,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->attrDataFactoryMock = $this->getMockBuilder('Magento\Customer\Model\Metadata\ElementFactory') + $this->attrDataFactoryMock = $this->getMockBuilder('\Magento\Customer\Model\Metadata\ElementFactory') ->disableOriginalConstructor() ->getMock(); @@ -87,14 +89,15 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase */ public function testIsValid($isValid) { + $data = ['something']; $attribute = $this->getMockAttribute(); $this->mockDataModel($isValid, $attribute); $this->validator->setAttributes([$attribute]); $this->validator->setEntityType('ENTITY_TYPE'); - $this->validator->setData(['something']); + $this->validator->setData($data); $this->assertEquals($isValid, $this->validator->isValid(['ENTITY'])); $this->validator->setData([]); - $this->assertEquals($isValid, $this->validator->isValid(new \Magento\Object([]))); + $this->assertEquals($isValid, $this->validator->isValid(new \Magento\Object($data))); } public function trueFalseDataProvider() @@ -103,7 +106,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase } /** - * @return \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata + * @return \PHPUnit_Framework_MockObject_MockObject | AttributeMetadata */ protected function getMockAttribute() { @@ -121,11 +124,11 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase } /** - * @param bool $isValid - * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute + * @param bool $isValid + * @param AttributeMetadata $attribute * @return void */ - protected function mockDataModel($isValid, \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute) + protected function mockDataModel($isValid, AttributeMetadata $attribute) { $dataModel = $this->getMockBuilder('\Magento\Customer\Model\Metadata\Form\Text') ->disableOriginalConstructor() diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php index 5c12dd178b3..40929d51c18 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAccountServiceTest.php @@ -101,6 +101,11 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase */ private $_customerAddressServiceMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\UrlInterface + */ + private $_urlMock; + /** * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Helper\Data */ @@ -161,6 +166,8 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase 'isResetPasswordLinkTokenExpired', 'changeResetPasswordLinkToken', 'sendPasswordResetConfirmationEmail', + 'sendPasswordResetNotificationEmail', + 'validatePassword', ) ) ->getMock(); @@ -219,6 +226,12 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase ->method('create') ->with('Magento\Customer\Helper\Data') ->will($this->returnValue($this->_customerHelperMock)); + + $this->_urlMock = + $this->getMockBuilder('\Magento\UrlInterface') + ->disableOriginalConstructor() + ->getMock(); + } @@ -226,7 +239,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase { $this->_customerModelMock->expects($this->any()) ->method('load') - ->will($this->returnValue($this->_customerModelMock)); + ->will($this->returnSelf()); $this->_mockReturnValue( $this->_customerModelMock, @@ -250,11 +263,43 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase $customerService = $this->_createService(); - $customer = $customerService->activateAccount(self::ID, self::EMAIL_CONFIRMATION_KEY); + $customer = $customerService->activateAccount(self::ID); $this->assertEquals(self::ID, $customer->getCustomerId()); } + public function testValidateAccountConfirmationKey() + { + $this->_customerModelMock->expects($this->any()) + ->method('load') + ->will($this->returnSelf()); + + $this->_mockReturnValue( + $this->_customerModelMock, + array( + 'getId' => self::ID, + 'getConfirmation' => self::EMAIL_CONFIRMATION_KEY, + 'getAttributes' => array(), + ) + ); + + $this->_customerFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->_customerModelMock)); + + // Assertions + $this->_customerModelMock->expects($this->never()) + ->method('save'); + $this->_customerModelMock->expects($this->never()) + ->method('setConfirmation'); + + $customerService = $this->_createService(); + + $result = $customerService->validateAccountConfirmationKey(self::ID, self::EMAIL_CONFIRMATION_KEY); + + $this->assertTrue($result); + } + /** * @expectedException \Magento\Exception\StateException * @expectedExceptionCode \Magento\Exception\StateException::INVALID_STATE @@ -263,7 +308,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase { $this->_customerModelMock->expects($this->any()) ->method('load') - ->will($this->returnValue($this->_customerModelMock)); + ->will($this->returnSelf()); $this->_mockReturnValue( $this->_customerModelMock, @@ -293,7 +338,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase { $this->_customerModelMock->expects($this->any()) ->method('load') - ->will($this->returnValue($this->_customerModelMock)); + ->will($this->returnSelf()); $this->_mockReturnValue( $this->_customerModelMock, @@ -332,11 +377,11 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase * @expectedException \Magento\Exception\StateException * @expectedExceptionCode \Magento\Exception\StateException::INPUT_MISMATCH */ - public function testActivateAccountBadKey() + public function testValidateAccountConfirmationKeyBadKey() { $this->_customerModelMock->expects($this->any()) ->method('load') - ->will($this->returnValue($this->_customerModelMock)); + ->will($this->returnSelf()); $this->_mockReturnValue( $this->_customerModelMock, @@ -358,7 +403,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase $customerService = $this->_createService(); - $customerService->activateAccount(self::ID, self::EMAIL_CONFIRMATION_KEY . 'BAD'); + $customerService->validateAccountConfirmationKey(self::ID, self::EMAIL_CONFIRMATION_KEY . 'BAD'); } /** @@ -369,7 +414,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase { $this->_customerModelMock->expects($this->any()) ->method('load') - ->will($this->returnValue($this->_customerModelMock)); + ->will($this->returnSelf()); $this->_mockReturnValue( $this->_customerModelMock, @@ -445,6 +490,58 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase $customerService->authenticate(self::EMAIL, self::PASSWORD, self::WEBSITE_ID); } + public function testValidatePassword() + { + $this->_mockReturnValue( + $this->_customerModelMock, + array( + 'getId' => self::ID, + 'authenticate' => true, + 'load' => $this->_customerModelMock, + 'getAttributes' => array(), + 'validatePassword' => true, + ) + ); + + $this->_customerFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->_customerModelMock)); + + $customerService = $this->_createService(); + + $result = $customerService->validatePassword(self::ID, self::PASSWORD); + + $this->assertTrue($result); + } + + /** + * @expectedException \Magento\Exception\AuthenticationException + * @expectedExceptionMessage Password doesn't match for this account. + */ + public function testValidatePasswordWithException() + { + $this->_mockReturnValue( + $this->_customerModelMock, + array( + 'getId' => self::ID, + 'load' => $this->_customerModelMock, + 'validatePassword' => false, + ) + ); + + $this->_customerModelMock->expects($this->any()) + ->method('authenticate') + ->will($this->throwException(new \Magento\Core\Exception('exception message') )); + + $this->_customerFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->_customerModelMock)); + + $customerService = $this->_createService(); + + $customerService->validatePassword(self::ID, self::PASSWORD); + } + public function testValidateResetPasswordLinkToken() { $resetToken = 'lsdj579slkj5987slkj595lkj'; @@ -607,7 +704,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase $customerService = $this->_createService(); - $customerService->sendPasswordResetLink($email, self::WEBSITE_ID); + $customerService->sendPasswordResetLink($email, self::WEBSITE_ID, CustomerAccountServiceInterface::EMAIL_RESET); } public function testSendPasswordResetLinkBadEmailOrWebsite() @@ -631,7 +728,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase $customerService = $this->_createService(); try { - $customerService->sendPasswordResetLink($email, 0); + $customerService->sendPasswordResetLink($email, 0, CustomerAccountServiceInterface::EMAIL_RESET); $this->fail("Expected NoSuchEntityException not caught"); } catch (\Magento\Exception\NoSuchEntityException $nsee) { $this->assertSame($nsee->getCode(), \Magento\Exception\NoSuchEntityException::NO_SUCH_ENTITY); @@ -670,10 +767,10 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase $customerService = $this->_createService(); - $customerService->sendPasswordResetLink($email, self::WEBSITE_ID); + $customerService->sendPasswordResetLink($email, self::WEBSITE_ID, CustomerAccountServiceInterface::EMAIL_RESET); } - public function testResetPassword() + public function testChangePassword() { $resetToken = 'lsdj579slkj5987slkj595lkj'; $password = 'password_secret'; @@ -706,10 +803,10 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase $customerService = $this->_createService(); - $customerService->resetPassword(self::ID, $password, $resetToken); + $customerService->changePassword(self::ID, $password); } - public function testResetPasswordShortPassword() + public function testChangePasswordShortPassword() { $resetToken = 'lsdj579slkj5987slkj595lkj'; $password = ''; @@ -742,79 +839,10 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase $customerService = $this->_createService(); - $customerService->resetPassword(self::ID, $password, $resetToken); + $customerService->changePassword(self::ID, $password); } - /** - * @expectedException \Magento\Exception\StateException - * @expectedExceptionCode \Magento\Exception\StateException::EXPIRED - */ - public function testResetPasswordTokenExpired() - { - $resetToken = 'lsdj579slkj5987slkj595lkj'; - $password = 'password_secret'; - - $this->_mockReturnValue( - $this->_customerModelMock, - array( - 'getId' => self::ID, - 'load' => $this->_customerModelMock, - 'getRpToken' => $resetToken, - 'isResetPasswordLinkTokenExpired' => true, - ) - ); - $this->_customerFactoryMock->expects($this->any()) - ->method('create') - ->will($this->returnValue($this->_customerModelMock)); - - $this->_customerModelMock->expects($this->never()) - ->method('setRpToken'); - $this->_customerModelMock->expects($this->never()) - ->method('setRpTokenCreatedAt'); - $this->_customerModelMock->expects($this->never()) - ->method('setPassword'); - - $customerService = $this->_createService(); - - $customerService->resetPassword(self::ID, $password, $resetToken); - } - - /** - * @expectedException \Magento\Exception\StateException - * @expectedExceptionCode \Magento\Exception\StateException::INPUT_MISMATCH - */ - public function testResetPasswordTokenInvalid() - { - $resetToken = 'lsdj579slkj5987slkj595lkj'; - $invalidToken = $resetToken . 'invalid'; - $password = 'password_secret'; - - $this->_mockReturnValue( - $this->_customerModelMock, - array( - 'getId' => self::ID, - 'load' => $this->_customerModelMock, - 'getRpToken' => $resetToken, - 'isResetPasswordLinkTokenExpired' => false, - ) - ); - $this->_customerFactoryMock->expects($this->any()) - ->method('create') - ->will($this->returnValue($this->_customerModelMock)); - - $this->_customerModelMock->expects($this->never()) - ->method('setRpToken'); - $this->_customerModelMock->expects($this->never()) - ->method('setRpTokenCreatedAt'); - $this->_customerModelMock->expects($this->never()) - ->method('setPassword'); - - $customerService = $this->_createService(); - - $customerService->resetPassword(self::ID, $password, $invalidToken); - } - - public function testResetPasswordTokenWrongUser() + public function testChangePasswordWrongUser() { $resetToken = 'lsdj579slkj5987slkj595lkj'; $password = 'password_secret'; @@ -842,7 +870,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase $customerService = $this->_createService(); try { - $customerService->resetPassword(4200, $password, $resetToken); + $customerService->changePassword(4200, $password); $this->fail("Expected NoSuchEntityException not caught"); } catch (\Magento\Exception\NoSuchEntityException $nsee) { $this->assertSame($nsee->getCode(), \Magento\Exception\NoSuchEntityException::NO_SUCH_ENTITY); @@ -855,48 +883,6 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase } } - public function testResetPasswordTokenInvalidUserId() - { - $resetToken = 'lsdj579slkj5987slkj595lkj'; - $password = 'password_secret'; - - $this->_mockReturnValue( - $this->_customerModelMock, - array( - 'getId' => 0, - 'load' => $this->_customerModelMock, - 'getRpToken' => $resetToken, - 'isResetPasswordLinkTokenExpired' => false, - ) - ); - $this->_customerFactoryMock->expects($this->any()) - ->method('create') - ->will($this->returnValue($this->_customerModelMock)); - - $this->_customerModelMock->expects($this->never()) - ->method('setRpToken'); - $this->_customerModelMock->expects($this->never()) - ->method('setRpTokenCreatedAt'); - $this->_customerModelMock->expects($this->never()) - ->method('setPassword'); - - $customerService = $this->_createService(); - - try { - $customerService->resetPassword(0, $password, $resetToken); - $this->fail('Expected exception not thrown.'); - } catch ( InputException $e) { - $expectedParams = [ - [ - 'code' => InputException::INVALID_FIELD_VALUE, - 'fieldName' => 'customerId', - 'value' => 0, - ] - ]; - $this->assertEquals($expectedParams, $e->getParams()); - } - } - public function testSendConfirmation() { $this->_customerFactoryMock->expects($this->any()) @@ -907,7 +893,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(55)); $this->_customerModelMock->expects($this->once()) ->method('setWebsiteId') - ->will($this->returnValue($this->_customerModelMock)); + ->will($this->returnSelf()); $this->_customerModelMock->expects($this->any()) ->method('isConfirmationRequired') ->will($this->returnValue(true)); @@ -929,7 +915,7 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(0)); $this->_customerModelMock->expects($this->once()) ->method('setWebsiteId') - ->will($this->returnValue($this->_customerModelMock)); + ->will($this->returnSelf()); $customerService = $this->_createService(); try { @@ -962,12 +948,61 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase $this->_customerModelMock->expects($this->once()) ->method('setWebsiteId') ->with(2) - ->will($this->returnValue($this->_customerModelMock)); + ->will($this->returnSelf()); $customerService = $this->_createService(); $customerService->sendConfirmation('email@test.com'); } + /** + * @dataProvider testGetConfirmationStatusDataProvider + * @param string $expected The expected confirmation status. + */ + public function testGetConfirmationStatus($expected) + { + $customerId = 1234; + $this->_customerFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->_customerModelMock)); + $this->_customerModelMock->expects($this->once()) + ->method('load') + ->with($customerId) + ->will($this->returnSelf()); + $this->_customerModelMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue($customerId)); + if (CustomerAccountServiceInterface::ACCOUNT_CONFIRMED == $expected) { + $this->_customerModelMock->expects($this->once()) + ->method('getConfirmation') + ->will($this->returnValue(false)); + } else { + $this->_customerModelMock->expects($this->once()) + ->method('getConfirmation') + ->will($this->returnValue(true)); + } + if (CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_REQUIRED == $expected) { + $this->_customerModelMock->expects($this->once()) + ->method('isConfirmationRequired') + ->will($this->returnValue(true)); + } elseif (CustomerAccountServiceInterface::ACCOUNT_CONFIRMED != $expected) { + $this->_customerModelMock->expects($this->once()) + ->method('getConfirmation') + ->will($this->returnValue(false)); + } + + $customerService = $this->_createService(); + $this->assertEquals($expected, $customerService->getConfirmationStatus($customerId)); + } + + public function testGetConfirmationStatusDataProvider() + { + return [ + [CustomerAccountServiceInterface::ACCOUNT_CONFIRMED], + [CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_REQUIRED], + [CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_NOT_REQUIRED] + ]; + } + private function _setupStoreMock() { $this->_storeManagerMock = @@ -1010,9 +1045,10 @@ class CustomerAccountServiceTest extends \PHPUnit_Framework_TestCase $this->_mathRandomMock, $this->_converter, $this->_validator, - new Dto\Response\CreateCustomerAccountResponseBuilder(), + new Dto\CustomerBuilder, $this->_customerServiceMock, $this->_customerAddressServiceMock, + $this->_urlMock, $this->_objectManagerMock ); return $customerService; diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressCurrentServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressCurrentServiceTest.php new file mode 100644 index 00000000000..3be16b4097e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressCurrentServiceTest.php @@ -0,0 +1,115 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Service\V1; + + +class CustomerAddressCurrentServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Customer\Service\V1\CustomerAddressCurrentService + */ + protected $customerAddressCurrentService; + + /** + * @var \Magento\Customer\Service\V1\CustomerCurrentService|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerCurrentServiceMock; + + /** + * @var \Magento\Customer\Service\V1\CustomerAddressService|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerAddressServiceMock; + + /** + * @var \Magento\Customer\Service\V1\Dto\Address + */ + protected $customerAddressDtoMock; + + /** + * @var int + */ + protected $customerCurrentId = 100; + + /** + * Test setup + */ + public function setUp() + { + $this->customerCurrentServiceMock = $this->getMock('Magento\Customer\Service\V1\CustomerCurrentService', + array(), array(), '', false); + $this->customerAddressServiceMock = $this->getMock('Magento\Customer\Service\V1\CustomerAddressService', + array(), array(), '', false); + + $this->customerAddressCurrentService = new \Magento\Customer\Service\V1\CustomerAddressCurrentService( + $this->customerCurrentServiceMock, + $this->customerAddressServiceMock + ); + } + + /** + * Test getCustomerAddresses + */ + public function testGetCustomerAddresses() + { + $this->customerCurrentServiceMock->expects($this->once()) + ->method('getCustomerId') + ->will($this->returnValue($this->customerCurrentId)); + $this->customerAddressServiceMock->expects($this->once()) + ->method('getAddresses') + ->will($this->returnValue(array($this->customerAddressDtoMock))); + $this->assertEquals(array($this->customerAddressDtoMock), + $this->customerAddressCurrentService->getCustomerAddresses()); + } + + /** + * test getDefaultBillingAddress + */ + public function testGetDefaultBillingAddress() + { + $this->customerCurrentServiceMock->expects($this->once()) + ->method('getCustomerId') + ->will($this->returnValue($this->customerCurrentId)); + $this->customerAddressServiceMock->expects($this->once()) + ->method('getDefaultBillingAddress') + ->will($this->returnValue($this->customerAddressDtoMock)); + $this->assertEquals($this->customerAddressDtoMock, + $this->customerAddressCurrentService->getDefaultBillingAddress()); + } + + /** + * test getDefaultShippingAddress + */ + public function testGetDefaultShippingAddress() + { + $this->customerCurrentServiceMock->expects($this->once()) + ->method('getCustomerId') + ->will($this->returnValue($this->customerCurrentId)); + $this->customerAddressServiceMock->expects($this->once()) + ->method('getDefaultShippingAddress') + ->will($this->returnValue($this->customerAddressDtoMock)); + $this->assertEquals($this->customerAddressDtoMock, + $this->customerAddressCurrentService->getDefaultShippingAddress()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerCurrentServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerCurrentServiceTest.php new file mode 100644 index 00000000000..80e260f64d7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerCurrentServiceTest.php @@ -0,0 +1,166 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Service\V1; + + +class CustomerCurrentServiceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Customer\Service\V1\CustomerCurrentService + */ + protected $customerCurrentService; + + /** + * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerSessionMock; + + /** + * @var \Magento\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $layoutMock; + + /** + * @var \Magento\Customer\Service\V1\Dto\CustomerBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerDtoBuilderMock; + + /** + * @var \Magento\Customer\Service\V1\Dto\Customer|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerDtoMock; + + /** + * @var \Magento\Customer\Service\V1\CustomerService|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerServiceMock; + + /** + * @var \Magento\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Module\Manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $moduleManagerMock; + + /** + * @var \Magento\App\ViewInterface + */ + protected $viewMock; + /** + * @var int + */ + protected $customerId = 100; + + /** + * @var int + */ + protected $customerGroupId = 500; + + /** + * Test setup + */ + public function setUp() + { + $this->customerSessionMock = $this->getMock('Magento\Customer\Model\Session', + array(), array(), '', false); + $this->layoutMock = $this->getMock('Magento\Core\Model\Layout', + array(), array(), '', false); + $this->customerDtoBuilderMock = $this->getMock('Magento\Customer\Service\V1\Dto\CustomerBuilder', + array('create', 'setGroupId'), array(), '', false); + $this->customerDtoMock = $this->getMock('Magento\Customer\Service\V1\Dto\Customer', + array(), array(), '', false); + $this->customerServiceMock = $this->getMock('Magento\Customer\Service\V1\CustomerService', + array(), array(), '', false); + $this->requestMock = $this->getMock('Magento\App\Request\Http', + array(), array(), '', false); + $this->moduleManagerMock = $this->getMock('Magento\Module\Manager', + array(), array(), '', false); + $this->viewMock = $this->getMock('Magento\App\View', + array(), array(), '', false); + + $this->customerCurrentService = new \Magento\Customer\Service\V1\CustomerCurrentService( + $this->customerSessionMock, + $this->layoutMock, + $this->customerDtoBuilderMock, + $this->customerServiceMock, + $this->requestMock, + $this->moduleManagerMock, + $this->viewMock + ); + } + + /** + * test getCustomer method, method returns depersonalized customer Dto + */ + public function testGetCustomerDepersonalizeCustomerDto() + { + $this->requestMock->expects($this->once()) + ->method('isAjax') + ->will($this->returnValue(false)); + $this->layoutMock->expects($this->once()) + ->method('isCacheable') + ->will($this->returnValue(true)); + $this->viewMock->expects($this->once()) + ->method('isLayoutLoaded') + ->will($this->returnValue(true)); + $this->moduleManagerMock->expects($this->once()) + ->method('isEnabled') + ->with($this->equalTo('Magento_PageCache')) + ->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->once()) + ->method('getCustomerGroupId') + ->will($this->returnValue($this->customerGroupId)); + $this->customerDtoBuilderMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->customerDtoMock)); + $this->customerDtoBuilderMock->expects($this->once()) + ->method('setGroupId') + ->with($this->equalTo($this->customerGroupId)) + ->will($this->returnSelf()); + $this->assertEquals($this->customerDtoMock, $this->customerCurrentService->getCustomer()); + } + + /** + * test get customer method, method returns customer from service + */ + public function testGetCustomerLoadCustomerFromService() + { + $this->moduleManagerMock->expects($this->once()) + ->method('isEnabled') + ->with($this->equalTo('Magento_PageCache')) + ->will($this->returnValue(false)); + $this->customerSessionMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue($this->customerId)); + $this->customerServiceMock->expects($this->once()) + ->method('getCustomer') + ->with($this->equalTo($this->customerId)) + ->will($this->returnValue($this->customerDtoMock)); + $this->assertEquals($this->customerDtoMock, $this->customerCurrentService->getCustomer()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerServiceTest.php index 411f629f3da..7c093e44ff9 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerServiceTest.php @@ -133,6 +133,8 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase 'getRpToken', 'setRpToken', 'setRpTokenCreatedAt', + 'isDeleteable', + 'isReadonly', 'isResetPasswordLinkTokenExpired', 'changeResetPasswordLinkToken', 'sendPasswordResetConfirmationEmail', @@ -485,6 +487,44 @@ class CustomerServiceTest extends \PHPUnit_Framework_TestCase } } + /** + * Verify the isReadonly and isDeleteable methods of the Customer Service. + * + * @param string $method The method, either 'isReadonly' or 'isDeleteable' + * @param bool $isBoolean If the customer is or is not readonly/deleteable + * @param bool $expected The expected value of isReadOnly() or isDeleteable() + * + * @dataProvider isBooleanDataProvider + */ + public function testIsBoolean($method, $isBoolean, $expected) + { + $this->_mockReturnValue($this->_customerModelMock, ['getId' => self::ID]); + + $this->_customerModelMock->expects($this->once()) + ->method('load')->with(self::ID)->will($this->returnSelf()); + $this->_customerModelMock->expects($this->once())->method($method) + ->will($this->returnValue($isBoolean)); + + $this->_customerFactoryMock->expects($this->once()) + ->method('create')->will($this->returnValue($this->_customerModelMock)); + + $customerService = $this->_createService(); + $this->assertEquals($expected, $customerService->$method(self::ID)); + } + + /** + * Data provider for testIsBoolean() for checking isReadonly() and isDeleteable() + * + * @return array + */ + public function isBooleanDataProvider() + { + return [ + ['isReadonly', true, true], ['isReadonly', false, false], + ['isDeleteable', true, true], ['isDeleteable', false, false] + ]; + } + /** * @param \PHPUnit_Framework_MockObject_MockObject $mock * @param array $valueMap diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/AddressTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/AddressTest.php index ac901a21726..94f823bc2e2 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/AddressTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/Dto/AddressTest.php @@ -144,6 +144,9 @@ class AddressTest extends \PHPUnit_Framework_TestCase { $this->_fillAllFields($this->_addressBuilder); $expected = $this->_expectedValues; + $region = $expected['region']; + $expected['region'] = $region['region']; + $expected['region_id'] = 0; $this->assertEquals($expected, $this->_addressBuilder->create()->getAttributes()); } diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Plugin/ThemeCopyServiceTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Plugin/ThemeCopyServiceTest.php index 7ae71307198..d749a05f978 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Plugin/ThemeCopyServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Plugin/ThemeCopyServiceTest.php @@ -28,18 +28,24 @@ class ThemeCopyServiceTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\DesignEditor\Model\Plugin\ThemeCopyService */ - protected $_model; + protected $model; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_factoryMock; + protected $factoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; protected function setUp() { - $this->_factoryMock = $this->getMock('Magento\DesignEditor\Model\Theme\ChangeFactory', + $this->factoryMock = $this->getMock('Magento\DesignEditor\Model\Theme\ChangeFactory', array('create'), array(), '', false); - $this->_model = new \Magento\DesignEditor\Model\Plugin\ThemeCopyService($this->_factoryMock); + $this->subjectMock = $this->getMock('Magento\Theme\Model\CopyService', array(), array(), '', false); + $this->model = new \Magento\DesignEditor\Model\Plugin\ThemeCopyService($this->factoryMock); } public function testAroundCopySavesChangeTimeIfSourceThemeHasBeenAlreadyChanged() @@ -72,10 +78,10 @@ class ThemeCopyServiceTest extends \PHPUnit_Framework_TestCase '', false ); - $this->_factoryMock->expects($this->at(0)) + $this->factoryMock->expects($this->at(0)) ->method('create') ->will($this->returnValue($sourceChangeMock)); - $this->_factoryMock->expects($this->at(1)) + $this->factoryMock->expects($this->at(1)) ->method('create') ->will($this->returnValue($targetChangeMock)); @@ -101,13 +107,10 @@ class ThemeCopyServiceTest extends \PHPUnit_Framework_TestCase $targetChangeMock->expects($this->once()) ->method('save'); - $methodArguments = array($sourceThemeMock, $targetThemeMock); - $invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); - $invocationChainMock->expects($this->once()) - ->method('proceed') - ->with($methodArguments); + $closureMock = function () { - $this->_model->aroundCopy($methodArguments, $invocationChainMock); + }; + $this->model->aroundCopy($this->subjectMock, $closureMock, $sourceThemeMock, $targetThemeMock); } } diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Dhl/InternationalTest.php b/dev/tests/unit/testsuite/Magento/Dhl/Model/CarrierTest.php similarity index 85% rename from dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Dhl/InternationalTest.php rename to dev/tests/unit/testsuite/Magento/Dhl/Model/CarrierTest.php index a54c6b50dc7..e127790eaf8 100644 --- a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Dhl/InternationalTest.php +++ b/dev/tests/unit/testsuite/Magento/Dhl/Model/CarrierTest.php @@ -19,15 +19,14 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Usa * @subpackage unit_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier\Dhl; +namespace Magento\Dhl\Model; -class InternationalTest extends \PHPUnit_Framework_TestCase +class CarrierTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\TestFramework\Helper\ObjectManager @@ -40,7 +39,7 @@ class InternationalTest extends \PHPUnit_Framework_TestCase protected $_httpResponse; /** - * @var \Magento\Usa\Model\Shipping\Carrier\Dhl + * @var \Magento\Dhl\Model\Carrier */ protected $_model; @@ -56,7 +55,7 @@ class InternationalTest extends \PHPUnit_Framework_TestCase ->will($this->returnCallback(array($this, 'coreStoreConfigGetConfig'))); // xml element factory - $xmlElFactory = $this->getMockBuilder('\Magento\Usa\Model\Simplexml\ElementFactory') + $xmlElFactory = $this->getMockBuilder('\Magento\Shipping\Model\Simplexml\ElementFactory') ->disableOriginalConstructor() ->setMethods(array('create')) ->getMock(); @@ -65,8 +64,11 @@ class InternationalTest extends \PHPUnit_Framework_TestCase ->will( $this->returnCallback( function ($data) { - $oM = new \Magento\TestFramework\Helper\ObjectManager($this); - return $oM->getObject('\Magento\Usa\Model\Simplexml\Element', array('data' => $data['data'])); + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); + return $helper->getObject( + '\Magento\Shipping\Model\Simplexml\Element', + array('data' => $data['data']) + ); } ) ); @@ -125,7 +127,7 @@ class InternationalTest extends \PHPUnit_Framework_TestCase $website->expects($this->any())->method('getBaseCurrencyCode')->will($this->returnValue('USD')); $storeManager->expects($this->any())->method('getWebsite')->will($this->returnValue($website)); - $this->_model = $this->_helper->getObject('Magento\Usa\Model\Shipping\Carrier\Dhl\International', array( + $this->_model = $this->_helper->getObject('Magento\Dhl\Model\Carrier', array( 'coreStoreConfig' => $coreStoreConfig, 'xmlElFactory' => $xmlElFactory, 'rateFactory' => $rateFactory, @@ -133,7 +135,7 @@ class InternationalTest extends \PHPUnit_Framework_TestCase 'httpClientFactory' => $httpClientFactory, 'filesystem' => $filesystem, 'storeManager' => $storeManager, - 'data' => array('id' => 'dhlint', 'store' => '1') + 'data' => array('id' => 'dhl', 'store' => '1') )); } @@ -145,15 +147,15 @@ class InternationalTest extends \PHPUnit_Framework_TestCase public function coreStoreConfigGetConfig($path) { $pathMap = array( - 'carriers/dhlint/shipment_days' => 'Mon,Tue,Wed,Thu,Fri,Sat', - 'carriers/dhlint/intl_shipment_days' => 'Mon,Tue,Wed,Thu,Fri,Sat', - 'carriers/dhlint/allowed_methods' => 'IE', - 'carriers/dhlint/international_searvice' => 'IE', - 'carriers/dhlint/gateway_url' => 'https://xmlpi-ea.dhl.com/XMLShippingServlet', - 'carriers/dhlint/id' => 'some ID', - 'carriers/dhlint/password' => 'some password', - 'carriers/dhlint/content_type' => 'N', - 'carriers/dhlint/nondoc_methods' => '1,3,4,8,P,Q,E,F,H,J,M,V,Y' + 'carriers/dhl/shipment_days' => 'Mon,Tue,Wed,Thu,Fri,Sat', + 'carriers/dhl/intl_shipment_days' => 'Mon,Tue,Wed,Thu,Fri,Sat', + 'carriers/dhl/allowed_methods' => 'IE', + 'carriers/dhl/international_searvice' => 'IE', + 'carriers/dhl/gateway_url' => 'https://xmlpi-ea.dhl.com/XMLShippingServlet', + 'carriers/dhl/id' => 'some ID', + 'carriers/dhl/password' => 'some password', + 'carriers/dhl/content_type' => 'N', + 'carriers/dhl/nondoc_methods' => '1,3,4,8,P,Q,E,F,H,J,M,V,Y' ); return (isset($pathMap[$path])) ? $pathMap[$path] : null; } @@ -206,7 +208,7 @@ class InternationalTest extends \PHPUnit_Framework_TestCase */ protected function _invokePrepareShippingLabelContent(\SimpleXMLElement $xml) { - $model = $this->_helper->getObject('Magento\Usa\Model\Shipping\Carrier\Dhl\International'); + $model = $this->_helper->getObject('Magento\Dhl\Model\Carrier'); $method = new \ReflectionMethod($model, '_prepareShippingLabelContent'); $method->setAccessible(true); return $method->invoke($model, $xml); @@ -216,9 +218,9 @@ class InternationalTest extends \PHPUnit_Framework_TestCase { $this->_httpResponse->expects($this->any()) ->method('getBody') - ->will($this->returnValue(file_get_contents(__DIR__ . '/_files/success_dhlintl_response_rates.xml'))); + ->will($this->returnValue(file_get_contents(__DIR__ . '/_files/success_dhl_response_rates.xml'))); // for setRequest - $request_params = include __DIR__ . '/_files/rates_request_data_dhlintl.php'; + $request_params = include __DIR__ . '/_files/rates_request_data_dhl.php'; $request = $this->_helper->getObject('Magento\Sales\Model\Quote\Address\RateRequest', $request_params); $this->assertNotEmpty($this->_model->collectRates($request)->getAllRates()); } diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Dhl/_files/countries.xml b/dev/tests/unit/testsuite/Magento/Dhl/Model/_files/countries.xml similarity index 100% rename from dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Dhl/_files/countries.xml rename to dev/tests/unit/testsuite/Magento/Dhl/Model/_files/countries.xml diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/rates_request_data_dhl.php b/dev/tests/unit/testsuite/Magento/Dhl/Model/_files/rates_request_data_dhl.php similarity index 100% rename from dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/rates_request_data_dhl.php rename to dev/tests/unit/testsuite/Magento/Dhl/Model/_files/rates_request_data_dhl.php diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Dhl/_files/response_shipping_label.xml b/dev/tests/unit/testsuite/Magento/Dhl/Model/_files/response_shipping_label.xml similarity index 100% rename from dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Dhl/_files/response_shipping_label.xml rename to dev/tests/unit/testsuite/Magento/Dhl/Model/_files/response_shipping_label.xml diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Dhl/_files/success_dhlintl_response_rates.xml b/dev/tests/unit/testsuite/Magento/Dhl/Model/_files/success_dhl_response_rates.xml similarity index 100% rename from dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Dhl/_files/success_dhlintl_response_rates.xml rename to dev/tests/unit/testsuite/Magento/Dhl/Model/_files/success_dhl_response_rates.xml diff --git a/dev/tests/unit/testsuite/Magento/Directory/Model/Resource/Country/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Directory/Model/Resource/Country/CollectionTest.php index 3736d132af7..559dca87cf3 100644 --- a/dev/tests/unit/testsuite/Magento/Directory/Model/Resource/Country/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Directory/Model/Resource/Country/CollectionTest.php @@ -58,8 +58,8 @@ class CollectionTest extends \PHPUnit_Framework_TestCase ->will($this->returnArgument(0)); $eventManager = $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false); - $localeMock = $this->getMock('Magento\Core\Model\LocaleInterface'); - $localeMock->expects($this->any())->method('getCountryTranslation')->will($this->returnArgument(0)); + $localeListsMock = $this->getMock('Magento\Locale\ListsInterface'); + $localeListsMock->expects($this->any())->method('getCountryTranslation')->will($this->returnArgument(0)); $fetchStrategy = $this->getMockForAbstractClass('Magento\Data\Collection\Db\FetchStrategyInterface'); $entityFactory = $this->getMock('Magento\Core\Model\EntityFactory', array(), array(), '', false); @@ -71,7 +71,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase $arguments = array( 'logger' => $logger, 'eventManager' => $eventManager, - 'locale' => $localeMock, + 'localeLists' => $localeListsMock, 'fetchStrategy' => $fetchStrategy, 'entityFactory' => $entityFactory, 'coreStoreConfig' => $storeConfigMock, diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php index 91b1960d5d0..825ebeabc60 100644 --- a/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php @@ -41,11 +41,19 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase */ protected $productMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + protected function setUp() { $this->requestMock = $this->getMock('Magento\App\Request\Http', array(), array(), '', false); $this->productMock = $this->getMock('Magento\Catalog\Model\Product', array('setDownloadableData', '__wakeup'), array(), '', false); + $this->subjectMock = + $this->getMock('Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper', + array(), array(), '', false); $this->downloadablePlugin = new \Magento\Downloadable\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Downloadable( $this->requestMock @@ -60,7 +68,7 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase ->with('downloadable') ->will($this->returnValue('downloadable')); $this->productMock->expects($this->once())->method('setDownloadableData')->with('downloadable'); - $this->downloadablePlugin->afterInitialize($this->productMock); + $this->downloadablePlugin->afterInitialize($this->subjectMock, $this->productMock); } public function testAfterInitializeIfDownloadableNotExist() @@ -71,6 +79,6 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase ->with('downloadable') ->will($this->returnValue(false)); $this->productMock->expects($this->never())->method('setDownloadableData'); - $this->downloadablePlugin->afterInitialize($this->productMock); + $this->downloadablePlugin->afterInitialize($this->subjectMock, $this->productMock); } } diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Model/Product/TypeTransitionManager/Plugin/DownloadableTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Model/Product/TypeTransitionManager/Plugin/DownloadableTest.php index 69b5cac8ede..e3d2c06ad45 100644 --- a/dev/tests/unit/testsuite/Magento/Downloadable/Model/Product/TypeTransitionManager/Plugin/DownloadableTest.php +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Model/Product/TypeTransitionManager/Plugin/DownloadableTest.php @@ -31,9 +31,9 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase protected $requestMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Closure */ - protected $invocationChainMock; + protected $closureMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -45,6 +45,11 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase */ protected $model; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + protected function setUp() { $this->requestMock = $this->getMock( @@ -62,7 +67,10 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase '', false ); - $this->invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); + $this->subjectMock = + $this->getMock('Magento\Catalog\Model\Product\TypeTransitionManager', array(), array(), '', false); + $this->closureMock = function () { + }; } /** @@ -77,8 +85,7 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase $this->productMock->expects($this->once())->method('getTypeId')->will($this->returnValue($currentTypeId)); $this->productMock->expects($this->once())->method('setTypeId') ->with(\Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE); - $this->invocationChainMock->expects($this->never())->method('proceed'); - $this->model->aroundProcessProduct(array($this->productMock), $this->invocationChainMock); + $this->model->aroundProcessProduct($this->subjectMock, $this->closureMock, $this->productMock); } /** @@ -109,9 +116,7 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase $this->productMock->expects($this->any())->method('hasIsVirtual')->will($this->returnValue($isVirtual)); $this->productMock->expects($this->once())->method('getTypeId')->will($this->returnValue($currentTypeId)); $this->productMock->expects($this->never())->method('setTypeId'); - $arguments = array($this->productMock); - $this->invocationChainMock->expects($this->once())->method('proceed')->with($arguments); - $this->model->aroundProcessProduct($arguments, $this->invocationChainMock); + $this->model->aroundProcessProduct($this->subjectMock, $this->closureMock, $this->productMock); } /** diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Attribute/Data/TextTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Attribute/Data/TextTest.php index f701418a2bf..8ca5c84b428 100644 --- a/dev/tests/unit/testsuite/Magento/Eav/Model/Attribute/Data/TextTest.php +++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Attribute/Data/TextTest.php @@ -36,12 +36,11 @@ class TextTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $locale = $this->getMock('Magento\Core\Model\LocaleInterface', array(), array(), '', false, false); + $locale = $this->getMock('Magento\Stdlib\DateTime\TimezoneInterface', array(), array(), '', false, false); + $localeResolver = $this->getMock('Magento\Locale\ResolverInterface', array(), array(), '', false, false); $logger = $this->getMock('Magento\Logger', array(), array(), '', false, false); $helper = $this->getMock('Magento\Stdlib\String', array(), array(), '', false, false); - - $attributeData = array( 'store_label' => 'Test', 'attribute_code' => 'test', @@ -65,7 +64,7 @@ class TextTest extends \PHPUnit_Framework_TestCase * \PHPUnit_Framework_MockObject_MockObject */ $attribute = $this->getMock($attributeClass, array('_init'), $arguments); - $this->_model = new \Magento\Eav\Model\Attribute\Data\Text($locale, $logger, $helper); + $this->_model = new \Magento\Eav\Model\Attribute\Data\Text($locale, $logger, $localeResolver, $helper); $this->_model->setAttribute($attribute); } diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/AbstractTest.php index bcd66c206b9..6a4822aa3b2 100644 --- a/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/AbstractTest.php @@ -43,7 +43,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\App\Resource', array(), array(), '', false), $this->getMock('Magento\Eav\Model\Config', array(), array(), '', false), $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', array(), array(), '', false), - $this->getMock('Magento\Core\Model\LocaleInterface'), + $this->getMock('\Magento\Locale\FormatInterface'), $this->getMock('Magento\Eav\Model\Resource\Helper', array(), array(), '', false), $this->getMock('Magento\Validator\UniversalFactory', array(), array(), '', false), ) @@ -305,7 +305,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\App\Resource', array(), array(), '', false), $this->getMock('Magento\Eav\Model\Config', array(), array(), '', false), $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', array(), array(), '', false), - $this->getMock('Magento\Core\Model\LocaleInterface'), + $this->getMock('Magento\Locale\FormatInterface'), $this->getMock('Magento\Eav\Model\Resource\Helper', array(), array(), '', false), $this->getMock('Magento\Validator\UniversalFactory', array(), array(), '', false), array( diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/TypeTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/TypeTest.php new file mode 100644 index 00000000000..6b245030204 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/TypeTest.php @@ -0,0 +1,121 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Eav\Model\Entity; + +class TypeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Eav\Model\Entity\Type + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $contextMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $registryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $attrFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $attrSetFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $universalFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $resourceMock; + + protected function setUp() + { + $this->contextMock = $this->getMock('Magento\Model\Context', array(), array(), '', false); + $this->registryMock = $this->getMock('Magento\Registry', array(), array(), '', false); + $this->attrFactoryMock = $this->getMock('Magento\Eav\Model\Entity\AttributeFactory', + array(), array(), '', false); + $this->attrSetFactoryMock = $this->getMock('Magento\Eav\Model\Entity\Attribute\SetFactory', + array(), array(), '', false); + $this->storeFactoryMock = $this->getMock( + 'Magento\Eav\Model\Entity\StoreFactory', + array('create'), + array(), + '', + false + ); + $this->universalFactoryMock = $this->getMock('Magento\Validator\UniversalFactory', array(), array(), '', false); + $this->resourceMock = $this->getMockForAbstractClass( + 'Magento\Core\Model\Resource\Db\AbstractDb', + array(), + '', + false, + false, + true, + array('beginTransaction', 'rollBack', 'commit', 'getIdFieldName', '__wakeup') + ); + + $this->model = new Type( + $this->contextMock, + $this->registryMock, + $this->attrFactoryMock, + $this->attrSetFactoryMock, + $this->storeFactoryMock, + $this->universalFactoryMock, + $this->resourceMock + ); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Store instance cannot be created. + */ + public function testFetchNewIncrementIdRollsBackTransactionAndRethrowsExceptionIfProgramFlowIsInterrupted() + { + $this->model->setIncrementModel('\IncrementModel'); + $this->resourceMock->expects($this->once())->method('beginTransaction'); + // Interrupt program flow by exception + $exception = new \Exception('Store instance cannot be created.'); + $this->storeFactoryMock->expects($this->once())->method('create')->will($this->throwException($exception)); + $this->resourceMock->expects($this->once())->method('rollBack'); + $this->resourceMock->expects($this->never())->method('commit'); + + $this->model->fetchNewIncrementId(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Encryption/EncryptorTest.php b/dev/tests/unit/testsuite/Magento/Encryption/EncryptorTest.php index ab8323eb4ef..3a8671c7bee 100644 --- a/dev/tests/unit/testsuite/Magento/Encryption/EncryptorTest.php +++ b/dev/tests/unit/testsuite/Magento/Encryption/EncryptorTest.php @@ -27,15 +27,67 @@ namespace Magento\Encryption; class EncryptorTest extends \PHPUnit_Framework_TestCase { /** - * @var @var \Magento\Encryption\Encryptor + * @var \Magento\Encryption\Encryptor */ protected $_model; - public function testGetHash() + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_randomGenerator; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_cryptFactory; + + protected function setUp() { - $hash = $this->_getEncryptor()->getHash('password', 'some_salt_string'); + $this->_randomGenerator = $this->getMock('Magento\Math\Random', array(), array(), '', false); + $this->_cryptFactory = $this->getMock('Magento\Encryption\CryptFactory', array(), array(), '', false); + $this->_model = new Encryptor($this->_randomGenerator, $this->_cryptFactory, 'cryptKey'); + } - $this->assertEquals('a42f82cf25f63f40ff85f8c9b3ff0cb4:some_salt_string', $hash); + public function testGetHashNoSalt() + { + $this->_randomGenerator->expects($this->never())->method('getRandomString'); + $expected = '5f4dcc3b5aa765d61d8327deb882cf99'; + $actual = $this->_model->getHash('password'); + $this->assertEquals($expected, $actual); + } + + public function testGetHashSpecifiedSalt() + { + $this->_randomGenerator->expects($this->never())->method('getRandomString'); + $expected = '67a1e09bb1f83f5007dc119c14d663aa:salt'; + $actual = $this->_model->getHash('password', 'salt'); + $this->assertEquals($expected, $actual); + } + + public function testGetHashRandomSaltDefaultLength() + { + $this->_randomGenerator + ->expects($this->once()) + ->method('getRandomString') + ->with(32) + ->will($this->returnValue('-----------random_salt----------')) + ; + $expected = '7a22dd7ba57a7653cc0f6e58e9ba1aac:-----------random_salt----------'; + $actual = $this->_model->getHash('password', true); + $this->assertEquals($expected, $actual); + } + + public function testGetHashRandomSaltSpecifiedLength() + { + $this->_randomGenerator + ->expects($this->once()) + ->method('getRandomString') + ->with(11) + ->will($this->returnValue('random_salt')) + ; + $expected = 'e6730b5a977c225a86cd76025a86a6fc:random_salt'; + $actual = $this->_model->getHash('password', 11); + $this->assertEquals($expected, $actual); } /** @@ -47,8 +99,7 @@ class EncryptorTest extends \PHPUnit_Framework_TestCase */ public function testValidateHash($password, $hash, $expected) { - $actual = $this->_getEncryptor()->validateHash($password, $hash); - + $actual = $this->_model->validateHash($password, $hash); $this->assertEquals($expected, $actual); } @@ -57,8 +108,8 @@ class EncryptorTest extends \PHPUnit_Framework_TestCase return array( array('password', 'hash', false), array('password', 'hash:salt', false), - array('password', md5('password'), true), - array('password', md5('saltpassword') . ':' . 'salt', true), + array('password', '5f4dcc3b5aa765d61d8327deb882cf99', true), + array('password', '67a1e09bb1f83f5007dc119c14d663aa:salt', true), ); } @@ -72,7 +123,7 @@ class EncryptorTest extends \PHPUnit_Framework_TestCase */ public function testValidateHashException($password, $hash) { - $this->_getEncryptor()->validateHash($password, $hash); + $this->_model->validateHash($password, $hash); } public function validateHashExceptionDataProvider() @@ -90,15 +141,9 @@ class EncryptorTest extends \PHPUnit_Framework_TestCase */ public function testEncryptWithEmptyKey($key) { - $encryptor = new \Magento\Encryption\Encryptor( - $this->getMock('\Magento\Math\Random', array(), array(), '', false), - $this->getMock('Magento\Encryption\CryptFactory', array(), array(), '', false), - $key - ); - + $model = new Encryptor($this->_randomGenerator, $this->_cryptFactory, $key); $value = 'arbitrary_string'; - - $this->assertEquals($value, $encryptor->encrypt($value)); + $this->assertEquals($value, $model->encrypt($value)); } public function encryptWithEmptyKeyDataProvider() @@ -120,31 +165,17 @@ class EncryptorTest extends \PHPUnit_Framework_TestCase public function testEncrypt($value, $expected) { $crypt = $this->getMock('Magento\Encryption\Crypt', array(), array(), '', false); - $cryptFactory = $this->getMock('Magento\Encryption\CryptFactory', array(), array(), '', false); - $encryptor = new \Magento\Encryption\Encryptor( - $this->getMock('\Magento\Math\Random', array(), array(), '', false), - $cryptFactory, - 'cryptKey' - ); - - $cryptFactory->expects($this->any()) - ->method('create') - ->will($this->returnValue($crypt)); - $crypt->expects($this->any()) - ->method('encrypt') - ->with($value) - ->will($this->returnArgument(0)); - - $actual = $encryptor->encrypt($value); - + $this->_cryptFactory->expects($this->once())->method('create')->will($this->returnValue($crypt)); + $crypt->expects($this->once())->method('encrypt')->with($value)->will($this->returnArgument(0)); + $actual = $this->_model->encrypt($value); $this->assertEquals($expected, $actual); } public function encryptDataProvider() { return array( - array('value1', base64_encode('value1')), - array(true, base64_encode('1')), + array('value1', 'dmFsdWUx'), + array(true, 'MQ=='), ); } @@ -157,82 +188,40 @@ class EncryptorTest extends \PHPUnit_Framework_TestCase public function testDecrypt($value, $expected) { $crypt = $this->getMock('Magento\Encryption\Crypt', array(), array(), '', false); - $cryptFactory = $this->getMock('Magento\Encryption\CryptFactory', array(), array(), '', false); - $encryptor = new \Magento\Encryption\Encryptor( - $this->getMock('\Magento\Math\Random', array(), array(), '', false), - $cryptFactory, - 'cryptKey' - ); - - $cryptFactory->expects($this->any()) - ->method('create') - ->will($this->returnValue($crypt)); - $crypt->expects($this->any()) - ->method('decrypt') - ->with($expected) - ->will($this->returnValue($expected)); - - $actual = $encryptor->decrypt($value); - + $this->_cryptFactory->expects($this->once())->method('create')->will($this->returnValue($crypt)); + $crypt->expects($this->once())->method('decrypt')->with($expected)->will($this->returnValue($expected)); + $actual = $this->_model->decrypt($value); $this->assertEquals($expected, $actual); } public function decryptDataProvider() { return array( - array(base64_encode('value1'), 'value1'), + array('dmFsdWUx', 'value1'), ); } public function testValidateKey() { - $key = 'some_key'; - $crypt = $this->getMock('Magento\Encryption\Crypt', array(), array(), '', false); - $cryptFactory = $this->getMock('Magento\Encryption\CryptFactory', array(), array(), '', false); - $encryptor = new \Magento\Encryption\Encryptor( - $this->getMock('\Magento\Math\Random', array(), array(), '', false), - $cryptFactory, - 'cryptKey' - ); - - $cryptFactory->expects($this->any()) + $this->_cryptFactory->expects($this->once()) ->method('create') - ->with(array('key' => $key)) - ->will($this->returnValue($crypt)); - - $encryptor->validateKey($key); + ->with(array('key' => 'some_key')) + ->will($this->returnValue($crypt)) + ; + $this->assertSame($crypt, $this->_model->validateKey('some_key')); } public function testValidateKeyDefault() { - $key = null; - $crypt = $this->getMock('Magento\Encryption\Crypt', array(), array(), '', false); - $cryptFactory = $this->getMock('Magento\Encryption\CryptFactory', array(), array(), '', false); - $encryptor = new \Magento\Encryption\Encryptor( - $this->getMock('\Magento\Math\Random', array(), array(), '', false), - $cryptFactory, - 'cryptKey' - ); - - $cryptFactory->expects($this->any()) + $this->_cryptFactory->expects($this->once()) ->method('create') ->with(array('key' => 'cryptKey')) - ->will($this->returnValue($crypt)); - - $encryptor->validateKey($key); - } - - /** - * @return \Magento\Encryption\Encryptor - */ - protected function _getEncryptor() - { - return new \Magento\Encryption\Encryptor( - $this->getMock('\Magento\Math\Random', array(), array(), '', false), - $this->getMock('Magento\Encryption\CryptFactory', array(), array(), '', false), - 'cryptKey' - ); + ->will($this->returnValue($crypt)) + ; + $this->assertSame($crypt, $this->_model->validateKey(null)); + // Ensure crypt factory is invoked only once + $this->assertSame($crypt, $this->_model->validateKey(null)); } } diff --git a/dev/tests/unit/testsuite/Magento/GiftMessage/Model/Plugin/QuoteItemTest.php b/dev/tests/unit/testsuite/Magento/GiftMessage/Model/Plugin/QuoteItemTest.php index db4b721ee8e..98c011b8880 100644 --- a/dev/tests/unit/testsuite/Magento/GiftMessage/Model/Plugin/QuoteItemTest.php +++ b/dev/tests/unit/testsuite/Magento/GiftMessage/Model/Plugin/QuoteItemTest.php @@ -25,42 +25,60 @@ namespace Magento\GiftMessage\Model\Plugin; class QuoteItemTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Bundle\Model\Plugin\QuoteItem */ + /** + * @var \Magento\Bundle\Model\Plugin\QuoteItem + */ protected $_model; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_quoteItemMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteItemMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_invocationChainMock; + /** + * @var \Closure + */ + protected $closureMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_orderItemMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $orderItemMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_helperMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; protected function setUp() { - $this->_orderItemMock = $this->getMock( + $this->orderItemMock = $this->getMock( 'Magento\Sales\Model\Order\Item', array('setGiftMessageId', 'setGiftMessageAvailable', '__wakeup'), array(), '', false ); - $this->_quoteItemMock = $this->getMock( + $this->quoteItemMock = $this->getMock( 'Magento\Sales\Model\Quote\Item', array('getGiftMessageId', 'getStoreId', '__wakeup'), array(), '', false ); - $this->_invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', - array(), array(), '', false); - $this->_helperMock = $this->getMock('Magento\GiftMessage\Helper\Message', + $orderItems = $this->orderItemMock; + $this->closureMock = function () use ($orderItems) { + return $orderItems; + }; + $this->subjectMock = $this->getMock('Magento\Sales\Model\Convert\Quote', array(), array(), '', false); + $this->helperMock = $this->getMock('Magento\GiftMessage\Helper\Message', array('setGiftMessageId', 'isMessagesAvailable'), array(), '', false); - $this->_model = new \Magento\GiftMessage\Model\Plugin\QuoteItem($this->_helperMock); + $this->model = new \Magento\GiftMessage\Model\Plugin\QuoteItem($this->helperMock); } public function testAroundItemToOrderItem() @@ -69,28 +87,26 @@ class QuoteItemTest extends \PHPUnit_Framework_TestCase $giftMessageId = 1; $isMessageAvailable = true; - $this->_invocationChainMock->expects($this->once())->method('proceed') - ->will($this->returnValue($this->_orderItemMock)); - $this->_quoteItemMock->expects($this->any()) + $this->quoteItemMock->expects($this->any()) ->method('getStoreId') ->will($this->returnValue($storeId)); - $this->_quoteItemMock->expects($this->any()) + $this->quoteItemMock->expects($this->any()) ->method('getGiftMessageId') ->will($this->returnValue($giftMessageId)); - $this->_helperMock->expects($this->once())->method('isMessagesAvailable') - ->with('item', $this->_quoteItemMock, $storeId) + $this->helperMock->expects($this->once())->method('isMessagesAvailable') + ->with('item', $this->quoteItemMock, $storeId) ->will($this->returnValue($isMessageAvailable)); - $this->_orderItemMock->expects($this->once()) + $this->orderItemMock->expects($this->once()) ->method('setGiftMessageId') ->with($giftMessageId); - $this->_orderItemMock->expects($this->once()) + $this->orderItemMock->expects($this->once()) ->method('setGiftMessageAvailable') ->with($isMessageAvailable); $this->assertSame( - $this->_orderItemMock, - $this->_model->aroundItemToOrderItem(array($this->_quoteItemMock), $this->_invocationChainMock) + $this->orderItemMock, + $this->model->aroundItemToOrderItem($this->subjectMock, $this->closureMock, $this->quoteItemMock) ); } diff --git a/dev/tests/unit/testsuite/Magento/GoogleAdwords/Model/Config/Source/LanguageTest.php b/dev/tests/unit/testsuite/Magento/GoogleAdwords/Model/Config/Source/LanguageTest.php index e85bf574cdb..e0a11e9d50f 100644 --- a/dev/tests/unit/testsuite/Magento/GoogleAdwords/Model/Config/Source/LanguageTest.php +++ b/dev/tests/unit/testsuite/Magento/GoogleAdwords/Model/Config/Source/LanguageTest.php @@ -56,7 +56,7 @@ class LanguageTest extends \PHPUnit_Framework_TestCase { $this->_helperMock = $this->getMock('Magento\GoogleAdwords\Helper\Data', array(), array(), '', false); $this->_localeMock = $this->getMock('Zend_Locale', array(), array(), '', false); - $this->_localeModelMock = $this->getMock('Magento\Core\Model\LocaleInterface', array(), array(), '', false); + $this->_localeModelMock = $this->getMock('Magento\Locale\ResolverInterface', array(), array(), '', false); $this->_localeModelMock->expects($this->once())->method('getLocale') ->will($this->returnValue($this->_localeMock)); $this->_uppercaseFilterMock = $this->getMock('Magento\GoogleAdwords\Model\Filter\UppercaseTitle', array(), @@ -64,7 +64,7 @@ class LanguageTest extends \PHPUnit_Framework_TestCase $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_model = $objectManager->getObject('Magento\GoogleAdwords\Model\Config\Source\Language', array( - 'locale' => $this->_localeModelMock, + 'localeResolver' => $this->_localeModelMock, 'helper' => $this->_helperMock, 'uppercaseFilter' => $this->_uppercaseFilterMock, )); diff --git a/dev/tests/unit/testsuite/Magento/GoogleOptimizer/Block/Code/CategoryTest.php b/dev/tests/unit/testsuite/Magento/GoogleOptimizer/Block/Code/CategoryTest.php new file mode 100644 index 00000000000..4851f073673 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GoogleOptimizer/Block/Code/CategoryTest.php @@ -0,0 +1,70 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\GoogleOptimizer\Block\Code; + +class CategoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\GoogleOptimizer\Block\Code\Category + */ + protected $block; + + /** + * @var \Magento\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registry; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->registry = $this->getMock('Magento\Registry', array(), array(), '', false); + $this->block = $objectManager->getObject( + 'Magento\GoogleOptimizer\Block\Code\Category', + array('registry' => $this->registry) + ); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $categoryTags = array('catalog_category_1'); + $category = $this->getMock('Magento\Catalog\Model\Category', array(), array(), '', false); + $category->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($categoryTags)); + $this->registry->expects($this->once()) + ->method('registry') + ->with('current_category') + ->will($this->returnValue($category)); + $this->assertEquals( + $categoryTags, + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/GoogleOptimizer/Block/Code/ProductTest.php b/dev/tests/unit/testsuite/Magento/GoogleOptimizer/Block/Code/ProductTest.php new file mode 100644 index 00000000000..ac4611d576d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GoogleOptimizer/Block/Code/ProductTest.php @@ -0,0 +1,70 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\GoogleOptimizer\Block\Code; + +class ProductTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\GoogleOptimizer\Block\Code\Product + */ + protected $block; + + /** + * @var \Magento\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registry; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->registry = $this->getMock('Magento\Registry', array(), array(), '', false); + $this->block = $objectManager->getObject( + 'Magento\GoogleOptimizer\Block\Code\Product', + array('registry' => $this->registry) + ); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $productTags = array('catalog_product_1'); + $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $product->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($productTags)); + $this->registry->expects($this->once()) + ->method('registry') + ->with('current_product') + ->will($this->returnValue($product)); + $this->assertEquals( + $productTags, + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Order/Create/SidebarTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Order/Create/SidebarTest.php index c282ac2044b..c761af4bbeb 100644 --- a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Order/Create/SidebarTest.php +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Order/Create/SidebarTest.php @@ -35,23 +35,33 @@ class SidebarTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $invocationChainMock; + protected $itemMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $itemMock; + protected $productMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $productMock; + protected $subjectMock; + + /** + * @var \Closure + */ + protected $closureMock; protected function setUp() { - $this->invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); - $this->itemMock = $this->getMock('Magento\Catalog\Model\Product\Configuration\Item\ItemInterface'); + $this->itemMock = $this->getMock('Magento\Object', array('getProduct'), array(), '', false); $this->productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $this->subjectMock = + $this->getMock('Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar', + array(), array(), '', false); + $this->closureMock = function () { + return 'Expected'; + }; $this->sidebarMock = new \Magento\GroupedProduct\Block\Adminhtml\Order\Create\Sidebar(); } @@ -59,41 +69,36 @@ class SidebarTest extends \PHPUnit_Framework_TestCase { $this->itemMock->expects($this->once())->method('getProduct')->will($this->returnValue($this->productMock)); $this->productMock - ->expects($this->once()) - ->method('getTypeId') - ->will($this->returnValue(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE)); - $this->invocationChainMock->expects($this->never())->method('proceed'); + ->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE)); $this->assertEquals('', - $this->sidebarMock->aroundGetItemQty(array($this->itemMock), $this->invocationChainMock)); + $this->sidebarMock->aroundGetItemQty($this->subjectMock, $this->closureMock, $this->itemMock) + ); } public function testAroundGetItemQtyWhenProductNotGrouped() { - $arguments = array($this->itemMock); $this->itemMock->expects($this->once())->method('getProduct')->will($this->returnValue($this->productMock)); $this->productMock ->expects($this->once()) ->method('getTypeId') ->will($this->returnValue('one')); - $this->invocationChainMock->expects($this->once())->method('proceed')->with($arguments); - $this->sidebarMock->aroundGetItemQty($arguments, $this->invocationChainMock); + $this->sidebarMock->aroundGetItemQty($this->subjectMock, $this->closureMock, $this->itemMock); } public function testAroundIsConfigurationRequiredWhenProductGrouped() { - $this->invocationChainMock->expects($this->never())->method('proceed'); $this->assertEquals(true, $this->sidebarMock->aroundIsConfigurationRequired( - array(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE), - $this->invocationChainMock) + $this->subjectMock, $this->closureMock, \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) ); } public function testAroundIsConfigurationRequiredWhenProductNotGrouped() { - $arguments = array('someValue'); - $this->invocationChainMock->expects($this->once())->method('proceed')->with($arguments); - $this->sidebarMock->aroundIsConfigurationRequired($arguments, $this->invocationChainMock); + $this->assertEquals('Expected', + $this->sidebarMock->aroundIsConfigurationRequired($this->subjectMock, $this->closureMock, 'someValue')); } } diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Cart/Item/Renderer/GroupedTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Cart/Item/Renderer/GroupedTest.php index f350ffe2a45..b6252af1088 100644 --- a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Cart/Item/Renderer/GroupedTest.php +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Cart/Item/Renderer/GroupedTest.php @@ -152,4 +152,22 @@ class GroupedTest extends \PHPUnit_Framework_TestCase return ['parentProduct' => $parentProduct, 'childProduct' => $childProduct]; } + + public function testGetIdentities() + { + $productTags = array('catalog_product_1'); + $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $product->expects($this->exactly(2)) + ->method('getIdentities') + ->will($this->returnValue($productTags)); + $item = $this->getMock('Magento\Sales\Model\Quote\Item', array(), array(), '', false); + $item->expects($this->exactly(2)) + ->method('getProduct') + ->will($this->returnValue($product)); + $this->_renderer->setItem($item); + $this->assertEquals( + array_merge($productTags, $productTags), + $this->_renderer->getIdentities() + ); + } } diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Stockqty/Type/GroupedTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Stockqty/Type/GroupedTest.php new file mode 100644 index 00000000000..dcf06864054 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Stockqty/Type/GroupedTest.php @@ -0,0 +1,84 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\GroupedProduct\Block\Stockqty\Type; + +class GroupedTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\GroupedProduct\Block\Stockqty\Type\Grouped + */ + protected $block; + + /** + * @var \Magento\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected $registry; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->registry = $this->getMock('Magento\Registry', array(), array(), '', false); + $this->block = $objectManager->getObject( + 'Magento\GroupedProduct\Block\Stockqty\Type\Grouped', + array('registry' => $this->registry) + ); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $productTags = array('catalog_product_1'); + $childProduct = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $childProduct->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($productTags)); + $typeInstance = $this->getMock( + 'Magento\GroupedProduct\Model\Product\Type\Grouped', + array(), + array(), + '', + false + ); + $typeInstance->expects($this->once()) + ->method('getAssociatedProducts') + ->will($this->returnValue(array($childProduct))); + $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $product->expects($this->once()) + ->method('getTypeInstance') + ->will($this->returnValue($typeInstance)); + $this->registry->expects($this->any()) + ->method('registry') + ->with('current_product') + ->will($this->returnValue($product)); + $this->assertEquals( + $productTags, + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Controller/Adminhtml/Product/Initialization/Helper/ProductLinks/Plugin/GroupedTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Controller/Adminhtml/Product/Initialization/Helper/ProductLinks/Plugin/GroupedTest.php index fb8b489fb4a..bf6c7168286 100644 --- a/dev/tests/unit/testsuite/Magento/GroupedProduct/Controller/Adminhtml/Product/Initialization/Helper/ProductLinks/Plugin/GroupedTest.php +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Controller/Adminhtml/Product/Initialization/Helper/ProductLinks/Plugin/GroupedTest.php @@ -42,12 +42,19 @@ class GroupedTest extends \PHPUnit_Framework_TestCase */ protected $productMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + protected function setUp() { $this->requestMock = $this->getMock('Magento\App\Request\Http', array(), array(), '', false); $this->productMock= $this->getMock('Magento\Catalog\Model\Product', array('getGroupedReadonly', 'setGroupedLinkData', '__wakeup'), array(), '', false); - + $this->subjectMock = + $this->getMock('Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\ProductLinks', + array(), array(), '', false); $this->model = new Grouped($this->requestMock); } @@ -56,7 +63,9 @@ class GroupedTest extends \PHPUnit_Framework_TestCase $this->requestMock->expects($this->once())->method('getPost')->with('links')->will($this->returnValue(array())); $this->productMock->expects($this->never())->method('getGroupedReadonly'); $this->productMock->expects($this->never())->method('setGroupedLinkData'); - $this->model->afterInitializeLinks($this->productMock); + $this->assertEquals($this->productMock, + $this->model->afterInitializeLinks($this->subjectMock, $this->productMock) + ); } public function testAfterInitializeLinksRequestHasGrouped() @@ -70,7 +79,9 @@ class GroupedTest extends \PHPUnit_Framework_TestCase ->method('getGroupedReadonly') ->will($this->returnValue(false)); $this->productMock->expects($this->once())->method('setGroupedLinkData')->with(array('value')); - $this->model->afterInitializeLinks($this->productMock); + $this->assertEquals($this->productMock, + $this->model->afterInitializeLinks($this->subjectMock, $this->productMock) + ); } public function testAfterInitializeLinksProductIsReadonly() @@ -84,6 +95,8 @@ class GroupedTest extends \PHPUnit_Framework_TestCase ->method('getGroupedReadonly') ->will($this->returnValue(true)); $this->productMock->expects($this->never())->method('setGroupedLinkData'); - $this->model->afterInitializeLinks($this->productMock); + $this->assertEquals($this->productMock, + $this->model->afterInitializeLinks($this->subjectMock, $this->productMock) + ); } } diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Helper/Product/Configuration/Plugin/GroupedTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Helper/Product/Configuration/Plugin/GroupedTest.php index 3f046d0e329..9c331c1729e 100644 --- a/dev/tests/unit/testsuite/Magento/GroupedProduct/Helper/Product/Configuration/Plugin/GroupedTest.php +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Helper/Product/Configuration/Plugin/GroupedTest.php @@ -32,9 +32,9 @@ class GroupedTest extends \PHPUnit_Framework_TestCase protected $groupedConfigPlugin; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Closure */ - protected $invocationChainMock; + protected $closureMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -52,15 +52,14 @@ class GroupedTest extends \PHPUnit_Framework_TestCase protected $typeInstanceMock; /** - * @var array + * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $inputArguments; + protected $subjectMock; + protected function setUp() { $this->groupedConfigPlugin = new Grouped(); - - $this->invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); $this->itemMock = $this->getMock('Magento\Catalog\Model\Product\Configuration\Item\ItemInterface'); $this->productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); $this->typeInstanceMock = $this->getMock( @@ -75,7 +74,8 @@ class GroupedTest extends \PHPUnit_Framework_TestCase ->method('getTypeInstance') ->will($this->returnValue($this->typeInstanceMock)); - $this->inputArguments = array('item' => $this->itemMock); + $this->subjectMock = + $this->getMock('Magento\Catalog\Helper\Product\Configuration', array(), array(), '', false); } /** @@ -119,12 +119,12 @@ class GroupedTest extends \PHPUnit_Framework_TestCase ->with('associated_product_' . $associatedProductId) ->will($this->returnValue($quantityItemMock)); - $this->invocationChainMock->expects($this->once()) - ->method('proceed') - ->with($this->inputArguments) - ->will($this->returnValue(array(array('label' => 'productName', 'value' => 2)))); + $returnValue = array(array('label' => 'productName', 'value' => 2)); + $this->closureMock = function () use ($returnValue) { + return $returnValue; + }; - $result = $this->groupedConfigPlugin->aroundGetOptions($this->inputArguments, $this->invocationChainMock); + $result = $this->groupedConfigPlugin->aroundGetOptions($this->subjectMock, $this->closureMock, $this->itemMock); $expectedResult = array( array( 'label' => 'associatedProductName', @@ -154,12 +154,11 @@ class GroupedTest extends \PHPUnit_Framework_TestCase $chainCallResult = array(array('label' => 'label', 'value' => 'value')); - $this->invocationChainMock->expects($this->once()) - ->method('proceed') - ->with($this->inputArguments) - ->will($this->returnValue($chainCallResult)); + $this->closureMock = function () use ($chainCallResult) { + return $chainCallResult; + }; - $result = $this->groupedConfigPlugin->aroundGetOptions($this->inputArguments, $this->invocationChainMock); + $result = $this->groupedConfigPlugin->aroundGetOptions($this->subjectMock, $this->closureMock, $this->itemMock); $this->assertEquals($chainCallResult, $result); } @@ -174,15 +173,13 @@ class GroupedTest extends \PHPUnit_Framework_TestCase ->method('getTypeId') ->will($this->returnValue('other_product_type')); - $this->invocationChainMock->expects($this->once()) - ->method('proceed') - ->with($this->inputArguments) - ->will($this->returnValue($chainCallResult)); - + $this->closureMock = function () use ($chainCallResult) { + return $chainCallResult; + }; $this->productMock->expects($this->never()) ->method('getTypeInstance'); - $result = $this->groupedConfigPlugin->aroundGetOptions($this->inputArguments, $this->invocationChainMock); + $result = $this->groupedConfigPlugin->aroundGetOptions($this->subjectMock, $this->closureMock, $this->itemMock); $this->assertEquals($chainCallResult, $result); } } diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/GroupedTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/GroupedTest.php index e3d2bf2606d..1a73705f3f2 100644 --- a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/GroupedTest.php +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/GroupedTest.php @@ -34,17 +34,26 @@ class GroupedTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $invocationChainMock; + protected $productMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $productMock; + protected $subjectMock; + + /** + * @var \Closure + */ + protected $closureMock; protected function setUp() { - $this->invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); $this->productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $this->subjectMock = + $this->getMock('Magento\Catalog\Model\Product\CartConfiguration', array(), array(), '', false); + $this->closureMock = function () { + return 'Expected'; + }; $this->groupedPlugin = new \Magento\GroupedProduct\Model\Product\Cart\Configuration\Plugin\Grouped(); } @@ -55,10 +64,9 @@ class GroupedTest extends \PHPUnit_Framework_TestCase ->expects($this->once()) ->method('getTypeId') ->will($this->returnValue(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE)); - $this->invocationChainMock->expects($this->never())->method('proceed'); $this->assertEquals(true, - $this->groupedPlugin->aroundIsProductConfigured( - array($this->productMock, $config), $this->invocationChainMock)); + $this->groupedPlugin->aroundIsProductConfigured( $this->subjectMock, $this->closureMock, + $this->productMock, $config)); } public function testAroundIsProductConfiguredWhenProductIsNotGrouped() @@ -67,9 +75,10 @@ class GroupedTest extends \PHPUnit_Framework_TestCase $this->productMock ->expects($this->once()) ->method('getTypeId') - ->will($this->returnValue('product')); - $this->invocationChainMock->expects($this->once())->method('proceed')->with(array($this->productMock, $config)); - $this->groupedPlugin->aroundIsProductConfigured(array($this->productMock, $config), $this->invocationChainMock); + ->will($this->returnValue('product'));; + $this->assertEquals('Expected', + $this->groupedPlugin->aroundIsProductConfigured( $this->subjectMock, $this->closureMock, + $this->productMock, $config)); } } diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Type/PluginTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Type/PluginTest.php index 212fd14d9de..41def57c828 100644 --- a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Type/PluginTest.php +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Type/PluginTest.php @@ -28,7 +28,7 @@ namespace Magento\GroupedProduct\Model\Product\Type; class PluginTest extends \PHPUnit_Framework_TestCase { /** - * @var PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit_Framework_MockObject_MockObject */ protected $moduleManagerMock; @@ -37,15 +37,23 @@ class PluginTest extends \PHPUnit_Framework_TestCase */ protected $object; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + protected function setUp() { $this->moduleManagerMock = $this->getMock('\Magento\Module\Manager', array(), array(), '', false); + $this->subjectMock = $this->getMock('Magento\Catalog\Model\Product\Type', array(), array(), '', false); $this->object = new \Magento\GroupedProduct\Model\Product\Type\Plugin($this->moduleManagerMock); } public function testAfterGetOptionArray() { $this->moduleManagerMock->expects($this->any())->method('isOutputEnabled')->will($this->returnValue(false)); - $this->assertEquals(array(), $this->object->afterGetOptionArray(array('grouped' => 'test'))); + $this->assertEquals(array(), + $this->object->afterGetOptionArray($this->subjectMock, array('grouped' => 'test')) + ); } } diff --git a/dev/tests/unit/testsuite/Magento/Http/AuthenticationTest.php b/dev/tests/unit/testsuite/Magento/Http/AuthenticationTest.php index 6c8862a3121..64ea406f2a8 100644 --- a/dev/tests/unit/testsuite/Magento/Http/AuthenticationTest.php +++ b/dev/tests/unit/testsuite/Magento/Http/AuthenticationTest.php @@ -83,8 +83,10 @@ class AuthenticationTest extends \PHPUnit_Framework_TestCase public function testSetAuthenticationFailed() { - $request = $this->getMock('\Magento\App\Request\Http', array(), array(), '', false);; - $response = new \Magento\App\Response\Http(); + $request = $this->getMock('\Magento\App\Request\Http', array(), array(), '', false); + $cookieMock = $this->getMock('Magento\Stdlib\Cookie', array(), array(), '', false); + $contextMock = $this->getMock('Magento\App\Http\Context', array(), array(), '', false); + $response = new \Magento\App\Response\Http($cookieMock, $contextMock); $authentication = new \Magento\HTTP\Authentication($request, $response); $realm = uniqid(); $response->headersSentThrowsException = false; diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php index 8323f4109ae..acadfa0ce39 100644 --- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php +++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php @@ -41,7 +41,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase */ protected $_websites = array( \Magento\Core\Model\Store::DEFAULT_STORE_ID => 'admin', - 1 => 'website1', + 1 => 'website1', ); /** @@ -113,7 +113,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase $this->getMock( 'Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory', array(), array(), '', false ), - $this->getMock('Magento\Core\Model\LocaleInterface', array(), array(), '', false), + $this->getMock('Magento\Stdlib\DateTime\TimezoneInterface', array(), array(), '', false), $this->getMock('Magento\Eav\Model\Config', array(), array(), '', false), $this->getMock('Magento\Customer\Model\Resource\Customer\CollectionFactory', array(), array(), '', false), $this->getMock('Magento\ImportExport\Model\Export\Entity\Eav\CustomerFactory', array(), array(), '', false), diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/CustomerTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/CustomerTest.php index 70de1f948dc..3745defce61 100644 --- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/CustomerTest.php +++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/CustomerTest.php @@ -41,8 +41,8 @@ class CustomerTest extends \PHPUnit_Framework_TestCase * @var array */ protected $_websites = array( - \Magento\Core\Model\Store::DEFAULT_STORE_ID => 'admin', - 1 => 'website1', + \Magento\Core\Model\Store::DEFAULT_STORE_ID => 'admin', + 1 => 'website1', ); /** @@ -104,7 +104,7 @@ class CustomerTest extends \PHPUnit_Framework_TestCase $this->getMock( 'Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory', array(), array(), '', false ), - $this->getMock('Magento\Core\Model\LocaleInterface', array(), array(), '', false), + $this->getMock('Magento\Stdlib\DateTime\TimezoneInterface', array(), array(), '', false), $this->getMock('Magento\Eav\Model\Config', array(), array(), '', false), $this->getMock('Magento\Customer\Model\Resource\Customer\CollectionFactory', array(), array(), '', false), $this->_getModelDependencies() diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php index 317e6b07f3b..8b12fc1330e 100644 --- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php +++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php @@ -123,8 +123,8 @@ class CustomerCompositeTest extends \PHPUnit_Framework_TestCase $data = array( 'inlineFactory' => $inlineFactory, 'context' => $context, - 'locale' => $this->getMock('Magento\Core\Model\Locale', array(), array(), '', false), - 'dateModel' => $this->getMock('Magento\Core\Model\Date', array(), array(), '', false) + 'locale' => $this->getMock('Magento\Locale', array(), array(), '', false), + 'dateModel' => $this->getMock('Magento\Stdlib\DateTime\DateTime', array(), array(), '', false) ); $this->_coreHelper = $objectManager->getObject('Magento\Core\Helper\Data', $data); $this->_string = new \Magento\Stdlib\String; diff --git a/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/DirTest.php b/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/DirTest.php index 2a4ef97e160..c89e0d2e81e 100644 --- a/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/DirTest.php +++ b/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/DirTest.php @@ -46,6 +46,16 @@ class DirTest extends \PHPUnit_Framework_TestCase */ protected $varDirectory; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + protected function setUp() { $this->appStateMock = $this->getMock('Magento\App\State', array(), array(), '', false); @@ -58,6 +68,8 @@ class DirTest extends \PHPUnit_Framework_TestCase ->with(\Magento\App\Filesystem::VAR_DIR) ->will($this->returnValue($this->varDirectory)); $logger = $this->getMock('Magento\Logger', array(), array(), '', false); + $this->subjectMock = $this->getMock('Magento\Install\Controller\Index', array(), array(), '', false); + $this->requestMock = $this->getMock('Magento\App\RequestInterface'); $this->plugin = new \Magento\Install\App\Action\Plugin\Dir( $this->appStateMock, $filesystem, @@ -80,7 +92,7 @@ class DirTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(true)); $this->varDirectory->expects($this->exactly(count($directories))) ->method('delete'); - $this->assertEquals(array(), $this->plugin->beforeDispatch(array())); + $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock); } /** @@ -90,6 +102,6 @@ class DirTest extends \PHPUnit_Framework_TestCase { $this->appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true)); $this->varDirectory->expects($this->never())->method('read'); - $this->assertEquals(array(), $this->plugin->beforeDispatch(array())); + $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock); } } \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php b/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php index cbf3c411b2c..8a9d3c5322a 100644 --- a/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php +++ b/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php @@ -152,20 +152,40 @@ class ConsoleTest extends \PHPUnit_Framework_TestCase ->expects($this->once()) ->method($method) ->will($this->returnValue($testValue)); - $this->_outputMock->expects($this->once())->method('export')->with($testValue); + $this->_outputMock->expects($this->once())->method('readableOutput')->with($testValue); + $this->_outputMock->expects($this->once()) + ->method('prepareArray')->with($testValue)->will($this->returnArgument(0)); $this->assertEquals($this->_responseMock, $model->launch()); } public function executeShowsRequestedDataProvider() { return array( - array('show_locales', 'getAvailableLocales', 'locales'), - array('show_currencies', 'getAvailableCurrencies', 'currencies'), - array('show_timezones', 'getAvailableTimezones', 'timezones'), - array('show_install_options', 'getAvailableInstallOptions', 'install_options'), + array('show_locales', 'getAvailableLocales', array('locales')), + array('show_currencies', 'getAvailableCurrencies', array('currencies')), + array('show_timezones', 'getAvailableTimezones', array('timezones')), ); } + public function testLaunchShowsInstallOptions() + { + $required = array('required params'); + $optional = array('optional params'); + + $model = $this->_createModel(array('show_install_options' => true)); + $this->_installerMock + ->expects($this->once()) + ->method('getRequiredParams') + ->will($this->returnValue($required)); + $this->_installerMock + ->expects($this->once()) + ->method('getOptionalParams') + ->will($this->returnValue($optional)); + $this->_outputMock->expects($this->exactly(2))->method('alignArrayKeys'); + $this->_outputMock->expects($this->at(1))->method('alignArrayKeys')->with($required); + $this->assertEquals($this->_responseMock, $model->launch()); + } + public function testInstallReportsSuccessMessage() { $model = $this->_createModel(array()); diff --git a/dev/tests/unit/testsuite/Magento/Integration/Oauth/OauthTest.php b/dev/tests/unit/testsuite/Magento/Integration/Oauth/OauthTest.php index 54ffb49e64d..20c9686610c 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Oauth/OauthTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Oauth/OauthTest.php @@ -55,7 +55,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase /** @var \Zend_Oauth_Http_Utility */ private $_httpUtilityMock; - /** @var \Magento\Core\Model\Date */ + /** @var \Magento\Stdlib\DateTime\DateTime */ private $_dateMock; private $_oauthToken; @@ -130,7 +130,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->_httpUtilityMock = $this->getMockBuilder('Zend_Oauth_Http_Utility') ->setMethods(array('sign')) ->getMock(); - $this->_dateMock = $this->getMockBuilder('Magento\Core\Model\Date') + $this->_dateMock = $this->getMockBuilder('Magento\Stdlib\DateTime\DateTime') ->disableOriginalConstructor() ->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Interception/Config/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Interception/Config/ConfigTest.php index 9f38c483d58..6bf7bb1c982 100644 --- a/dev/tests/unit/testsuite/Magento/Interception/Config/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Interception/Config/ConfigTest.php @@ -39,6 +39,11 @@ class ConfigTest extends \PHPUnit_Framework_TestCase */ protected $_model; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $configScopeMock; + protected function setUp() { $readerMap = include(__DIR__ . '/../_files/reader_mock_map.php'); @@ -47,8 +52,8 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ->method('read') ->will($this->returnValueMap($readerMap)); - $configScopeMock = $this->getMock('Magento\Config\ScopeListInterface'); - $configScopeMock->expects($this->any()) + $this->configScopeMock = $this->getMock('Magento\Config\ScopeListInterface'); + $this->configScopeMock->expects($this->any()) ->method('getAllScopes') ->will($this->returnValue(array('global', 'backend', 'frontend'))); $cacheMock = $this->getMock('Magento\Cache\FrontendInterface'); @@ -57,18 +62,19 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ->method('load') ->will($this->returnValue(false)); - $omConfigMock = $this->getMock('Magento\ObjectManager\Config'); + $omConfigMock = $this->getMock('Magento\Interception\ObjectManager\Config'); $omConfigMock->expects($this->any()) - ->method('getInstanceType') + ->method('getOriginalInstanceType') ->will($this->returnArgument(0)); - $this->_model = new \Magento\Interception\Config\Config( + $definitionMock = $this->getMock('Magento\ObjectManager\Definition'); + $definitionMock->expects($this->any())->method('getClasses')->will($this->returnValue(array())); + $this->model = new \Magento\Interception\Config\Config( $readerMock, - $configScopeMock, + $this->configScopeMock, $cacheMock, new \Magento\ObjectManager\Relations\Runtime(), $omConfigMock, - null, - null, + $definitionMock, 'interception' ); } @@ -80,7 +86,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase */ public function testHasPlugins($expectedResult, $type) { - $this->assertEquals($expectedResult, $this->_model->hasPlugins($type)); + $this->assertEquals($expectedResult, $this->model->hasPlugins($type)); } public function hasPluginsDataProvider() diff --git a/dev/tests/unit/testsuite/Magento/Interception/Custom/Module/Model/ItemContainerPlugin/Simple.php b/dev/tests/unit/testsuite/Magento/Interception/Custom/Module/Model/ItemContainerPlugin/Simple.php index a12bcf30e4e..6c1f2b0876b 100644 --- a/dev/tests/unit/testsuite/Magento/Interception/Custom/Module/Model/ItemContainerPlugin/Simple.php +++ b/dev/tests/unit/testsuite/Magento/Interception/Custom/Module/Model/ItemContainerPlugin/Simple.php @@ -26,10 +26,13 @@ namespace Magento\Interception\Custom\Module\Model\ItemContainerPlugin; class Simple { /** - * @param string $invocationResult + * @param $subject + * @param $invocationResult * @return string + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterGetName($invocationResult) + public function afterGetName($subject, $invocationResult) { return $invocationResult . '|'; } diff --git a/dev/tests/unit/testsuite/Magento/Interception/Custom/Module/Model/ItemPlugin/Advanced.php b/dev/tests/unit/testsuite/Magento/Interception/Custom/Module/Model/ItemPlugin/Advanced.php index 93d22b6f157..9c8b855746f 100644 --- a/dev/tests/unit/testsuite/Magento/Interception/Custom/Module/Model/ItemPlugin/Advanced.php +++ b/dev/tests/unit/testsuite/Magento/Interception/Custom/Module/Model/ItemPlugin/Advanced.php @@ -26,21 +26,27 @@ namespace Magento\Interception\Custom\Module\Model\ItemPlugin; class Advanced { /** - * @param array $methodArguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param $subject + * @param $proceed + * @param $argument * @return string + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundGetName(array $methodArguments, \Magento\Code\Plugin\InvocationChain $invocationChain) + public function aroundGetName($subject, $proceed, $argument) { - return '[' . $invocationChain->proceed($methodArguments) . ']'; + return '[' . $proceed($argument) . ']'; } /** - * @param string $invocationResult + * @param $subject + * @param $result * @return string + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterGetName($invocationResult) + public function afterGetName($subject, $result) { - return $invocationResult . '%'; + return $result . '%'; } } diff --git a/dev/tests/unit/testsuite/Magento/Interception/Custom/Module/Model/ItemPlugin/Simple.php b/dev/tests/unit/testsuite/Magento/Interception/Custom/Module/Model/ItemPlugin/Simple.php index 44b26fe8888..459c311390d 100644 --- a/dev/tests/unit/testsuite/Magento/Interception/Custom/Module/Model/ItemPlugin/Simple.php +++ b/dev/tests/unit/testsuite/Magento/Interception/Custom/Module/Model/ItemPlugin/Simple.php @@ -26,10 +26,13 @@ namespace Magento\Interception\Custom\Module\Model\ItemPlugin; class Simple { /** - * @param string $invocationResult + * @param $subject + * @param $invocationResult * @return string + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterGetName($invocationResult) + public function afterGetName($subject, $invocationResult) { return $invocationResult . '!'; } diff --git a/dev/tests/unit/testsuite/Magento/Interception/FactoryDecoratorTest.php b/dev/tests/unit/testsuite/Magento/Interception/FactoryDecoratorTest.php deleted file mode 100644 index c9aaa6cfe81..00000000000 --- a/dev/tests/unit/testsuite/Magento/Interception/FactoryDecoratorTest.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Interception; - -class FactoryDecoratorTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $config; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $factory; - - /** - * @var FactoryDecorator - */ - private $decorator; - - protected function setUp() - { - $this->factory = $this->getMockForAbstractClass('\Magento\ObjectManager\Factory'); - $this->config = $this->getMockForAbstractClass('\Magento\Interception\Config'); - $pluginList = $this->getMockForAbstractClass('\Magento\Interception\PluginList'); - $objectManager = $this->getMockForAbstractClass('\Magento\ObjectManager'); - $this->decorator = new FactoryDecorator($this->factory, $this->config, $pluginList, $objectManager); - } - - public function testCreateDecorated() - { - $this->config->expects($this->once())->method('hasPlugins')->with('type')->will($this->returnValue(true)); - $this->config - ->expects($this->once()) - ->method('getInterceptorClassName') - ->with('type') - ->will($this->returnValue('StdClass')) - ; - $this->assertInstanceOf('StdClass', $this->decorator->create('type')); - } - - public function testCreateClean() - { - $this->config->expects($this->once())->method('hasPlugins')->with('type')->will($this->returnValue(false)); - $this->config->expects($this->never())->method('getInterceptorClassName'); - $this->factory - ->expects($this->once()) - ->method('create') - ->with('type', array(1, 2, 3)) - ->will($this->returnValue('test')) - ; - $this->assertEquals('test', $this->decorator->create('type', array(1, 2, 3))); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Interception/ObjectManager/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Interception/ObjectManager/ConfigTest.php new file mode 100644 index 00000000000..b0cb1e63c24 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Interception/ObjectManager/ConfigTest.php @@ -0,0 +1,79 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Interception\ObjectManager; + + +class ConfigTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Interception\ObjectManager\Config + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $interceptionConfig; + + protected function setUp() + { + $this->interceptionConfig = $this->getMock('\Magento\Interception\Config'); + $this->model = new Config(); + } + + public function testGetInstanceTypeReturnsInterceptorClass() + { + $this->interceptionConfig->expects($this->once()) + ->method('hasPlugins') + ->will($this->returnValue(true)); + $this->model->setInterceptionConfig($this->interceptionConfig); + + $this->assertEquals('SomeClass\Interceptor', $this->model->getInstanceType('SomeClass')); + } + + public function testGetInstanceTypeReturnsSimpleClassIfNoPluginsAreDeclared() + { + $this->model->setInterceptionConfig($this->interceptionConfig); + + $this->assertEquals('SomeClass', $this->model->getInstanceType('SomeClass')); + } + + public function testGetInstanceTypeReturnsSimpleClassIfInterceptionConfigIsNotSet() + { + $this->assertEquals('SomeClass', $this->model->getInstanceType('SomeClass')); + } + + public function testGetOriginalInstanceTypeReturnsInterceptedClass() + { + $this->interceptionConfig->expects($this->once()) + ->method('hasPlugins') + ->will($this->returnValue(true)); + $this->model->setInterceptionConfig($this->interceptionConfig); + + $this->assertEquals('SomeClass\Interceptor', $this->model->getInstanceType('SomeClass')); + $this->assertEquals('SomeClass', $this->model->getOriginalInstanceType('SomeClass')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Interception/PluginList/PluginListTest.php b/dev/tests/unit/testsuite/Magento/Interception/PluginList/PluginListTest.php index d3aa909dedc..6a7ec4b11de 100644 --- a/dev/tests/unit/testsuite/Magento/Interception/PluginList/PluginListTest.php +++ b/dev/tests/unit/testsuite/Magento/Interception/PluginList/PluginListTest.php @@ -35,7 +35,7 @@ require_once __DIR__ . '/../Custom/Module/Model/ItemPlugin/Advanced.php'; class PluginListTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Interception\Config\Config + * @var \Magento\Interception\PluginList\PluginList */ protected $_model; @@ -44,6 +44,11 @@ class PluginListTest extends \PHPUnit_Framework_TestCase */ protected $_configScopeMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_objectManagerMock; + protected function setUp() { $readerMap = include(__DIR__ . '/../_files/reader_mock_map.php'); @@ -59,10 +64,16 @@ class PluginListTest extends \PHPUnit_Framework_TestCase ->method('get') ->will($this->returnValue(false)); - $omConfigMock = $this->getMock('Magento\ObjectManager\Config'); + $omConfigMock = $this->getMock('Magento\Interception\ObjectManager\Config'); $omConfigMock->expects($this->any()) - ->method('getInstanceType') + ->method('getOriginalInstanceType') ->will($this->returnArgument(0)); + + $this->_objectManagerMock = $this->getMock('Magento\ObjectManager'); + $this->_objectManagerMock->expects($this->any())->method('get')->will($this->returnArgument(0)); + + $definitions = new \Magento\ObjectManager\Definition\Runtime(); + $this->_model = new \Magento\Interception\PluginList\PluginList( $readerMock, $this->_configScopeMock, @@ -70,28 +81,52 @@ class PluginListTest extends \PHPUnit_Framework_TestCase new \Magento\ObjectManager\Relations\Runtime(), $omConfigMock, new \Magento\Interception\Definition\Runtime(), + $this->_objectManagerMock, + $definitions, array('global'), - 'interception', - null + 'interception' + ); + } + + public function testGetPlugin() + { + $this->_configScopeMock->expects($this->any()) + ->method('getCurrentScope') + ->will($this->returnValue('backend')); + $this->_model->getNext('Magento\Interception\Custom\Module\Model\Item', 'getName'); + $this->_model->getNext('Magento\Interception\Custom\Module\Model\ItemContainer', 'getName'); + + $this->assertEquals( + 'Magento\Interception\Custom\Module\Model\ItemPlugin\Simple', + $this->_model->getPlugin('Magento\Interception\Custom\Module\Model\Item', 'simple_plugin') + ); + $this->assertEquals( + 'Magento\Interception\Custom\Module\Model\ItemPlugin\Advanced', + $this->_model->getPlugin('Magento\Interception\Custom\Module\Model\Item', 'advanced_plugin') + ); + $this->assertEquals( + 'Magento\Interception\Custom\Module\Model\ItemContainerPlugin\Simple', + $this->_model->getPlugin('Magento\Interception\Custom\Module\Model\ItemContainer', 'simple_plugin') ); } + /** - * @param array $expectedResult - * @param string $type - * @param string $method - * @param string $scenario - * @param string $scopeCode + * @param $expectedResult + * @param $type + * @param $method + * @param $scopeCode + * @param string $code * @dataProvider getPluginsDataProvider */ - public function testGetPlugins(array $expectedResult, $type, $method, $scenario, $scopeCode) + public function testGetPlugins($expectedResult, $type, $method, $scopeCode, $code = '__self') { $this->_configScopeMock->expects($this->any()) ->method('getCurrentScope') ->will($this->returnValue($scopeCode)); $this->assertEquals( $expectedResult, - $this->_model->getPlugins($type, $method, $scenario) + $this->_model->getNext($type, $method, $code) ); } @@ -102,72 +137,58 @@ class PluginListTest extends \PHPUnit_Framework_TestCase { return array( array( - array('Magento\Interception\Custom\Module\Model\ItemPlugin\Simple'), + array(4 => array('simple_plugin')), 'Magento\Interception\Custom\Module\Model\Item', 'getName', - 'after', 'global', ), array( // advanced plugin has lower sort order - array('Magento\Interception\Custom\Module\Model\ItemPlugin\Advanced', - 'Magento\Interception\Custom\Module\Model\ItemPlugin\Simple'), + array(2 => 'advanced_plugin', 4 => array('advanced_plugin')), 'Magento\Interception\Custom\Module\Model\Item', 'getName', - 'after', 'backend', ), array( - array('Magento\Interception\Custom\Module\Model\ItemPlugin\Advanced'), + // advanced plugin has lower sort order + array(4 => array('simple_plugin')), 'Magento\Interception\Custom\Module\Model\Item', 'getName', - 'around', 'backend', + 'advanced_plugin' ), array( // simple plugin is disabled in configuration for // \Magento\Interception\Custom\Module\Model\Item in frontend - array(), + null, 'Magento\Interception\Custom\Module\Model\Item', 'getName', - 'after', 'frontend', ), // test plugin inheritance array( - array('Magento\Interception\Custom\Module\Model\ItemPlugin\Simple'), + array(4 => array('simple_plugin')), 'Magento\Interception\Custom\Module\Model\Item\Enhanced', 'getName', - 'after', 'global', ), array( // simple plugin is disabled in configuration for parent - array('Magento\Interception\Custom\Module\Model\ItemPlugin\Advanced'), - 'Magento\Interception\Custom\Module\Model\Item\Enhanced', - 'getName', - 'after', - 'frontend', - ), - array( - array('Magento\Interception\Custom\Module\Model\ItemPlugin\Advanced'), + array(2 => 'advanced_plugin', 4 => array('advanced_plugin')), 'Magento\Interception\Custom\Module\Model\Item\Enhanced', 'getName', - 'around', 'frontend', ), array( - array(), + null, 'Magento\Interception\Custom\Module\Model\ItemContainer', 'getName', - 'after', 'global', ), array( - array('Magento\Interception\Custom\Module\Model\ItemContainerPlugin\Simple'), + array(4 => array('simple_plugin')), 'Magento\Interception\Custom\Module\Model\ItemContainer', 'getName', - 'after', 'backend', ), ); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Locale/Hierarchy/Config/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Locale/Hierarchy/Config/ConverterTest.php similarity index 91% rename from dev/tests/unit/testsuite/Magento/Core/Model/Locale/Hierarchy/Config/ConverterTest.php rename to dev/tests/unit/testsuite/Magento/Locale/Hierarchy/Config/ConverterTest.php index 8f5493d546b..c496a135d45 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Locale/Hierarchy/Config/ConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Locale/Hierarchy/Config/ConverterTest.php @@ -25,12 +25,12 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Locale\Hierarchy\Config; +namespace Magento\Locale\Hierarchy\Config; class ConverterTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Locale\Hierarchy\Config\Converter + * @var \Magento\Locale\Hierarchy\Config\Converter */ protected $_model; @@ -41,7 +41,7 @@ class ConverterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_model = new \Magento\Core\Model\Locale\Hierarchy\Config\Converter(); + $this->_model = new \Magento\Locale\Hierarchy\Config\Converter(); } /** diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Locale/Hierarchy/Config/FileResolverTest.php b/dev/tests/unit/testsuite/Magento/Locale/Hierarchy/Config/FileResolverTest.php similarity index 90% rename from dev/tests/unit/testsuite/Magento/Core/Model/Locale/Hierarchy/Config/FileResolverTest.php rename to dev/tests/unit/testsuite/Magento/Locale/Hierarchy/Config/FileResolverTest.php index 9ab6a9e3bc1..8731e121d56 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Locale/Hierarchy/Config/FileResolverTest.php +++ b/dev/tests/unit/testsuite/Magento/Locale/Hierarchy/Config/FileResolverTest.php @@ -21,12 +21,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Locale\Hierarchy\Config; +namespace Magento\Locale\Hierarchy\Config; class FileResolverTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Locale\Hierarchy\Config\FileResolver + * @var \Magento\Locale\Hierarchy\Config\FileResolver */ protected $_model; @@ -59,14 +59,14 @@ class FileResolverTest extends \PHPUnit_Framework_TestCase ->with('locale') ->will($this->returnValue(true)); $this->iteratorFactory = $this->getMock('Magento\Config\FileIteratorFactory', array(), array(), '', false); - $this->_model = new \Magento\Core\Model\Locale\Hierarchy\Config\FileResolver( + $this->_model = new \Magento\Locale\Hierarchy\Config\FileResolver( $filesystem, $this->iteratorFactory ); } /** - * @covers \Magento\Core\Model\Locale\Hierarchy\Config\FileResolver::get + * @covers \Magento\Locale\Hierarchy\Config\FileResolver::get */ public function testGet() { diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Locale/Hierarchy/Config/_files/custom/hierarchy_config.xml b/dev/tests/unit/testsuite/Magento/Locale/Hierarchy/Config/_files/custom/hierarchy_config.xml similarity index 100% rename from dev/tests/unit/testsuite/Magento/Core/Model/Locale/Hierarchy/Config/_files/custom/hierarchy_config.xml rename to dev/tests/unit/testsuite/Magento/Locale/Hierarchy/Config/_files/custom/hierarchy_config.xml diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Locale/Hierarchy/Config/_files/default/hierarchy_config.xml b/dev/tests/unit/testsuite/Magento/Locale/Hierarchy/Config/_files/default/hierarchy_config.xml similarity index 100% rename from dev/tests/unit/testsuite/Magento/Core/Model/Locale/Hierarchy/Config/_files/default/hierarchy_config.xml rename to dev/tests/unit/testsuite/Magento/Locale/Hierarchy/Config/_files/default/hierarchy_config.xml diff --git a/dev/tests/unit/testsuite/Magento/Locale/Hierarchy/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Locale/Hierarchy/ConfigTest.php index 7c868ff495c..f91496ffa5f 100644 --- a/dev/tests/unit/testsuite/Magento/Locale/Hierarchy/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Locale/Hierarchy/ConfigTest.php @@ -31,7 +31,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected $_model; /** - * @var \Magento\Core\Model\Locale\Hierarchy\Config\Reader + * @var \Magento\Locale\Hierarchy\Config\Reader */ protected $_configReaderMock; diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Locale/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/Locale/ValidatorTest.php similarity index 84% rename from dev/tests/unit/testsuite/Magento/Core/Model/Locale/ValidatorTest.php rename to dev/tests/unit/testsuite/Magento/Locale/ValidatorTest.php index 64cf4268bf8..234684fe3e3 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Locale/ValidatorTest.php +++ b/dev/tests/unit/testsuite/Magento/Locale/ValidatorTest.php @@ -25,23 +25,23 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Locale; +namespace Magento\Locale; class ValidatorTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Locale\Validator + * @var \Magento\Locale\Validator */ protected $_validatorModel; protected function setUp() { - $localeConfigMock = $this->getMock('Magento\Core\Model\Locale\Config', array(), array(), '', false); + $localeConfigMock = $this->getMock('Magento\Locale\ConfigInterface'); $localeConfigMock->expects($this->any()) ->method('getAllowedLocales') ->will($this->returnValue(array('en_US', 'de_DE', 'es_ES'))); - $this->_validatorModel = new \Magento\Core\Model\Locale\Validator($localeConfigMock); + $this->_validatorModel = new \Magento\Locale\Validator($localeConfigMock); } /** @@ -65,7 +65,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase * @dataProvider testIsValidDataProvider * @param string $locale * @param boolean $valid - * @covers \Magento\Core\Model\Locale\Validator::isValid + * @covers \Magento\Locale\Validator::isValid */ public function testIsValid($locale, $valid) { diff --git a/dev/tests/unit/testsuite/Magento/Log/LoggerTest.php b/dev/tests/unit/testsuite/Magento/Log/LoggerTest.php index c25cd53abd1..274a34fa746 100644 --- a/dev/tests/unit/testsuite/Magento/Log/LoggerTest.php +++ b/dev/tests/unit/testsuite/Magento/Log/LoggerTest.php @@ -61,10 +61,12 @@ class LoggerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(true)); $this->_directory->expects($this->any()) ->method('getAbsolutePath') - ->will($this->returnArgument(0)); - $this->_directory->expects($this->any()) - ->method('getRelativePath') - ->will($this->returnValue($logDir)); + ->will($this->returnCallback( + function ($path) use ($logDir) { + $path = ltrim($path, '\/'); + return $logDir . '/' . $path; + } + )); if (!is_dir($logDir)) { mkdir($logDir, 0777, true); diff --git a/dev/tests/unit/testsuite/Magento/Math/RandomTest.php b/dev/tests/unit/testsuite/Magento/Math/RandomTest.php index 90a14b59412..ead01ffb6c2 100644 --- a/dev/tests/unit/testsuite/Magento/Math/RandomTest.php +++ b/dev/tests/unit/testsuite/Magento/Math/RandomTest.php @@ -52,11 +52,6 @@ class RandomTest extends \PHPUnit_Framework_TestCase array(10, \Magento\Math\Random::CHARS_LOWERS), array(10, \Magento\Math\Random::CHARS_UPPERS), array(10, \Magento\Math\Random::CHARS_DIGITS), - array(10, \Magento\Math\Random::CHARS_SPECIALS), - array(10, \Magento\Math\Random::CHARS_PASSWORD_LOWERS), - array(10, \Magento\Math\Random::CHARS_PASSWORD_UPPERS), - array(10, \Magento\Math\Random::CHARS_PASSWORD_DIGITS), - array(10, \Magento\Math\Random::CHARS_PASSWORD_SPECIALS), array(20, \Magento\Math\Random::CHARS_LOWERS . \Magento\Math\Random::CHARS_UPPERS diff --git a/dev/tests/unit/testsuite/Magento/Module/Declaration/Reader/FilesystemTest.php b/dev/tests/unit/testsuite/Magento/Module/Declaration/Reader/FilesystemTest.php index 160a87d626f..0b625f3b6b8 100644 --- a/dev/tests/unit/testsuite/Magento/Module/Declaration/Reader/FilesystemTest.php +++ b/dev/tests/unit/testsuite/Magento/Module/Declaration/Reader/FilesystemTest.php @@ -38,8 +38,19 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase 'Magento\Module\Declaration\SchemaLocator', array(), array(), '', false ); $validationStateMock = $this->getMock('Magento\Config\ValidationStateInterface'); + + $appStateMock = $this->getMock('Magento\App\State', array(), array(), '', false); + $appStateMock->expects($this->any()) + ->method('isInstalled') + ->will($this->returnValue(true)); + + $dependencyManager = $this->getMock('Magento\Module\DependencyManagerInterface'); + $dependencyManager->expects($this->any()) + ->method('getExtendedModuleDependencies') + ->will($this->returnValue(array())); + $this->_model = new \Magento\Module\Declaration\Reader\Filesystem( - $fileResolver, $converter, $schemaLocatorMock, $validationStateMock + $fileResolver, $converter, $schemaLocatorMock, $validationStateMock, $appStateMock, $dependencyManager ); } diff --git a/dev/tests/unit/testsuite/Magento/Module/DependencyManagerTest.php b/dev/tests/unit/testsuite/Magento/Module/DependencyManagerTest.php new file mode 100644 index 00000000000..32bece568da --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Module/DependencyManagerTest.php @@ -0,0 +1,157 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Module; + +class DependencyManagerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Module\DependencyManager + */ + protected $model; + + protected function setUp() + { + $this->model = new \Magento\Module\DependencyManager(); + } + + /** + * @param array $moduleConfig + * @dataProvider checkModuleDependenciesDataProvider + * @expectedException \Exception + * @expectedExceptionMessage Module 'Module_One' depends on 'Module_Two' that is missing or not active. + */ + public function testCheckModuleDependenciesNegativeModuleMissed(array $moduleConfig) + { + $moduleConfig['dependencies']['modules'][] = 'Module_Two'; + $this->model->checkModuleDependencies($moduleConfig, array('Module_Three')); + } + + /** + * @param array $moduleConfig + * @dataProvider checkModuleDependenciesDataProvider + * @expectedException \Exception + * @expectedExceptionMessage Module 'Module_One' depends on 'custom_extension' PHP extension that is not loaded. + */ + public function testCheckModuleDependenciesNegativeExtensionMissed(array $moduleConfig) + { + $moduleConfig['dependencies']['extensions']['strict'][] = array('name' => 'custom_extension'); + $this->model->checkModuleDependencies($moduleConfig); + } + + /** + * @param array $moduleConfig + * @dataProvider checkModuleDependenciesDataProvider + * @expectedException \Exception + * @expectedExceptionMessage Module 'Module_One' depends on at least one of the following PHP extensions: ext1,ext2. + */ + public function testCheckModuleDependenciesNegativeAlternativeExtensionMissed(array $moduleConfig) + { + $moduleConfig['dependencies']['extensions']['alternatives'][] = array( + array('name' => 'ext1'), + array('name' => 'ext2'), + ); + $this->model->checkModuleDependencies($moduleConfig); + } + + /** + * return array + */ + public function checkModuleDependenciesDataProvider() + { + return array( + array( + 'moduleConfig' => array( + 'name' => 'Module_One', + 'version' => '1.0.0.0', + 'active' => true, + 'dependencies' => array( + 'modules' => array(), + 'extensions' => array( + 'strict' => array(), + 'alternatives' => array(), + ), + ), + ), + ), + ); + } + + /** + * @param array $modules + * @dataProvider getExtendedModuleDependenciesDataProvider + * @expectedException \Exception + * @expectedExceptionMessage Module 'Module_Two' cannot depend on 'Module_One' since it creates circular dependency. + */ + public function testGetExtendedModuleDependenciesNegativeCircularDependency(array $modules) + { + $modules['Module_Two']['dependencies']['modules'][] = 'Module_One'; + $this->model->getExtendedModuleDependencies('Module_One', $modules); + } + + /** + * @param array $modules + * @dataProvider getExtendedModuleDependenciesDataProvider + */ + public function testGetExtendedModuleDependenciesPositive(array $modules) + { + $this->assertEquals(array('Module_Two'), $this->model->getExtendedModuleDependencies('Module_One', $modules)); + } + + /** + * return array + */ + public function getExtendedModuleDependenciesDataProvider() + { + return array( + array( + 'modules' => array( + 'Module_One' => array( + 'name' => 'Module_One', + 'version' => '1.0.0.0', + 'active' => true, + 'dependencies' => array( + 'modules' => array('Module_Two'), + 'extensions' => array( + 'strict' => array(), + 'alternatives' => array(), + ), + ), + ), + 'Module_Two' => array( + 'name' => 'Module_Two', + 'version' => '1.0.0.0', + 'active' => true, + 'dependencies' => array( + 'modules' => array(), + 'extensions' => array( + 'strict' => array(), + 'alternatives' => array(), + ), + ), + ), + ), + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/ConfigTest.php b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/ConfigTest.php index 14399ae3cd1..da4e9a90aaf 100644 --- a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/ConfigTest.php @@ -63,4 +63,39 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->_assertFooTypeArguments($config); } -} + + public function testGetPreferenceTrimsFirstSlash() + { + $config = new Config(); + $this->assertEquals('Some\Class\Name', $config->getPreference('\Some\Class\Name')); + } + + public function testExtendIgnoresFirstSlashesOnPreferences() + { + $config = new Config(); + $config->extend(array('preferences' => array('\Some\Interface' => '\Some\Class'))); + $this->assertEquals('Some\Class', $config->getPreference('Some\Interface')); + $this->assertEquals('Some\Class', $config->getPreference('\Some\Interface')); + } + + public function testExtendIgnoresFirstShashesOnVirtualTypes() + { + $config = new Config(); + $config->extend(array('\SomeVirtualType' => array('type' => '\Some\Class'))); + $this->assertEquals('Some\Class', $config->getInstanceType('SomeVirtualType')); + } + + public function testExtendIgnoresFirstShashes() + { + $config = new Config(); + $config->extend(array('\Some\Class' => array('arguments' => array('someArgument')))); + $this->assertEquals(array('someArgument'), $config->getArguments('Some\Class')); + } + + public function testExtendIgnoresFirstShashesForSharing() + { + $config = new Config(); + $config->extend(array('\Some\Class' => array('shared' => true))); + $this->assertTrue($config->isShared('Some\Class')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/ObjectManagerTest.php b/dev/tests/unit/testsuite/Magento/ObjectManager/ObjectManagerTest.php index 4b9e28fe788..a0bf435b7ed 100644 --- a/dev/tests/unit/testsuite/Magento/ObjectManager/ObjectManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/ObjectManager/ObjectManagerTest.php @@ -474,4 +474,12 @@ class ObjectManagerTest extends \PHPUnit_Framework_TestCase $this->assertEquals('childSecondScalar', $result->secondScalar); $this->assertEquals('childOptionalScalar', $result->optionalScalar); } + + public function testGetIgnoresFirstSlash() + { + $this->assertSame( + $this->_object->get('Magento\Test\Di\Child'), + $this->_object->get('\Magento\Test\Di\Child') + ); + } } diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/BanktransferTest.php b/dev/tests/unit/testsuite/Magento/OfflinePayments/Model/BanktransferTest.php similarity index 93% rename from dev/tests/unit/testsuite/Magento/Payment/Model/Method/BanktransferTest.php rename to dev/tests/unit/testsuite/Magento/OfflinePayments/Model/BanktransferTest.php index c3c85f154d5..75c78ffec26 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/BanktransferTest.php +++ b/dev/tests/unit/testsuite/Magento/OfflinePayments/Model/BanktransferTest.php @@ -25,12 +25,12 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Model\Method; +namespace Magento\OfflinePayments\Model; class BanktransferTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Payment\Model\Method\Banktransfer + * @var \Magento\OfflinePayments\Model\Banktransfer */ protected $_object; @@ -42,7 +42,7 @@ class BanktransferTest extends \PHPUnit_Framework_TestCase $coreStoreConfig = $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false); $adapterFactoryMock = $this->getMock('Magento\Logger\AdapterFactory', array('create'), array(), '', false); - $this->_object = $objectManagerHelper->getObject('Magento\Payment\Model\Method\Banktransfer', array( + $this->_object = $objectManagerHelper->getObject('Magento\OfflinePayments\Model\Banktransfer', array( 'eventManager' => $eventManager, 'paymentData' => $paymentDataMock, 'coreStoreConfig' => $coreStoreConfig, diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/CashondeliveryTest.php b/dev/tests/unit/testsuite/Magento/OfflinePayments/Model/CashondeliveryTest.php similarity index 91% rename from dev/tests/unit/testsuite/Magento/Payment/Model/Method/CashondeliveryTest.php rename to dev/tests/unit/testsuite/Magento/OfflinePayments/Model/CashondeliveryTest.php index 748d2fab8a6..7a9921f0cf3 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/CashondeliveryTest.php +++ b/dev/tests/unit/testsuite/Magento/OfflinePayments/Model/CashondeliveryTest.php @@ -25,12 +25,12 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Payment\Model\Method; +namespace Magento\OfflinePayments\Model; class CashondeliveryTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Payment\Model\Method\Cashondelivery + * @var \Magento\OfflinePayments\Model\Cashondelivery */ protected $_object; @@ -44,7 +44,7 @@ class CashondeliveryTest extends \PHPUnit_Framework_TestCase array(), '', false); $coreStoreConfig = $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false); - $this->_object = $helper->getObject('Magento\Payment\Model\Method\Cashondelivery', array( + $this->_object = $helper->getObject('Magento\OfflinePayments\Model\Cashondelivery', array( 'eventManager' => $eventManager, 'paymentData' => $paymentDataMock, 'coreStoreConfig' => $coreStoreConfig, diff --git a/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/Field/ExportTest.php b/dev/tests/unit/testsuite/Magento/OfflineShipping/Block/Adminhtml/Form/Field/ExportTest.php similarity index 86% rename from dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/Field/ExportTest.php rename to dev/tests/unit/testsuite/Magento/OfflineShipping/Block/Adminhtml/Form/Field/ExportTest.php index 9b3597be9ad..a2e35dc00a5 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/Field/ExportTest.php +++ b/dev/tests/unit/testsuite/Magento/OfflineShipping/Block/Adminhtml/Form/Field/ExportTest.php @@ -18,14 +18,12 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Backend * @subpackage unit_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Backend\Block\System\Config\Form\Field; +namespace Magento\OfflineShipping\Block\Adminhtml\Form\Field; class ExportTest extends \PHPUnit_Framework_TestCase { @@ -36,12 +34,12 @@ class ExportTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $helperMock = $this->getMock('Magento\Backend\Helper\Data', array(), array(), '', false, false); - $helperMock->expects($this->once())->method('getUrl')->with("*/*/exportTablerates", array('website' => 1)); + $backendUrl = $this->getMock('Magento\Backend\Model\UrlInterface', array(), array(), '', false, false); + $backendUrl->expects($this->once())->method('getUrl')->with("*/*/exportTablerates", array('website' => 1)); $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_object = $objectManager->getObject('Magento\Backend\Block\System\Config\Form\Field\Export', array( - 'helper' => $helperMock) + $this->_object = $objectManager->getObject('Magento\OfflineShipping\Block\Adminhtml\Form\Field\Export', array( + 'backendUrl' => $backendUrl) ); } diff --git a/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/Field/ImportTest.php b/dev/tests/unit/testsuite/Magento/OfflineShipping/Block/Adminhtml/Form/Field/ImportTest.php similarity index 93% rename from dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/Field/ImportTest.php rename to dev/tests/unit/testsuite/Magento/OfflineShipping/Block/Adminhtml/Form/Field/ImportTest.php index 71d47fbd7aa..59455b98949 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/Field/ImportTest.php +++ b/dev/tests/unit/testsuite/Magento/OfflineShipping/Block/Adminhtml/Form/Field/ImportTest.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Backend * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -32,7 +30,7 @@ * @package Magento_Backend * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Backend\Block\System\Config\Form\Field; +namespace Magento\OfflineShipping\Block\Adminhtml\Form\Field; class ImportTest extends \PHPUnit_Framework_TestCase { @@ -54,7 +52,7 @@ class ImportTest extends \PHPUnit_Framework_TestCase ); $testData = array ('name' => 'test_name', 'html_id' => 'test_html_id'); $testHelper = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_object = $testHelper->getObject('Magento\Backend\Block\System\Config\Form\Field\Import', array( + $this->_object = $testHelper->getObject('Magento\OfflineShipping\Block\Adminhtml\Form\Field\Import', array( 'data' => $testData )); $this->_object->setForm($this->_formMock); diff --git a/dev/tests/unit/testsuite/Magento/OfflineShipping/Model/SalesRule/CalculatorTest.php b/dev/tests/unit/testsuite/Magento/OfflineShipping/Model/SalesRule/CalculatorTest.php new file mode 100644 index 00000000000..6af8e9e9992 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/OfflineShipping/Model/SalesRule/CalculatorTest.php @@ -0,0 +1,64 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_SalesRule + * @subpackage unit_tests + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\OfflineShipping\Model\SalesRule; + +class CalculatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\SalesRule\Model\Validator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_model; + + protected function setUp() + { + $this->_model = $this->getMock( + 'Magento\OfflineShipping\Model\SalesRule\Calculator', + array('_getRules', '__wakeup'), + array(), + '', + false + ); + $this->_model->expects($this->any()) + ->method('_getRules') + ->will($this->returnValue(array())); + } + + public function testProcessFreeShipping() + { + $item = $this->getMock('Magento\Sales\Model\Quote\Item', array('getAddress', '__wakeup'), array(), '', false); + $item->expects($this->once()) + ->method('getAddress') + ->will($this->returnValue(true)); + + $this->assertInstanceOf( + 'Magento\OfflineShipping\Model\SalesRule\Calculator', $this->_model->processFreeShipping($item) + ); + + return true; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Ogone/Model/ApiTest.php b/dev/tests/unit/testsuite/Magento/Ogone/Model/ApiTest.php index 5bb39be4143..81ed719277e 100644 --- a/dev/tests/unit/testsuite/Magento/Ogone/Model/ApiTest.php +++ b/dev/tests/unit/testsuite/Magento/Ogone/Model/ApiTest.php @@ -43,7 +43,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase // Test protected method via reflection $storeManager = $this->getMock('Magento\Core\Model\StoreManagerInterface', array(), array(), '', false); - $locale = $this->getMock('Magento\Core\Model\LocaleInterface', array(), array(), '', false); + $localeResolver = $this->getMock('\Magento\Locale\ResolverInterface', array(), array(), '', false); $urlBuilder = $this->getMock('Magento\UrlInterface', array(), array(), '', false); $eventManager = $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false); $string = $this->getMock('\Magento\Stdlib\String', array(), array(), '', false); @@ -52,8 +52,8 @@ class ApiTest extends \PHPUnit_Framework_TestCase $coreStoreConfig = $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false); $loggerFactory = $this->getMock('\Magento\Logger\AdapterFactory', array(), array(), '', false); $object = new \Magento\Ogone\Model\Api( - $storeManager, $paymentDataMock, $coreStoreConfig, $loggerFactory, - $eventManager, $locale, $urlBuilder, $string, $config + $eventManager, $paymentDataMock, $coreStoreConfig, $loggerFactory, + $storeManager, $localeResolver, $urlBuilder, $string, $config ); $method = new \ReflectionMethod('Magento\Ogone\Model\Api', '_translate'); diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Controller/BlockTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Controller/BlockTest.php index cd272383b19..e21da1e983b 100644 --- a/dev/tests/unit/testsuite/Magento/PageCache/Controller/BlockTest.php +++ b/dev/tests/unit/testsuite/Magento/PageCache/Controller/BlockTest.php @@ -109,12 +109,12 @@ class BlockTest extends \PHPUnit_Framework_TestCase $this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(true)); $this->requestMock->expects($this->at(1)) ->method('getParam') - ->with($this->equalTo('blocks'), $this->equalTo([])) - ->will($this->returnValue([])); + ->with($this->equalTo('blocks'), $this->equalTo('')) + ->will($this->returnValue('')); $this->requestMock->expects($this->at(2)) ->method('getParam') - ->with($this->equalTo('handles'), $this->equalTo([])) - ->will($this->returnValue([])); + ->with($this->equalTo('handles'), $this->equalTo('')) + ->will($this->returnValue('')); $result = $this->controller->renderAction(); $this->assertNull($result); } @@ -138,12 +138,12 @@ class BlockTest extends \PHPUnit_Framework_TestCase $this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(true)); $this->requestMock->expects($this->at(1)) ->method('getParam') - ->with($this->equalTo('blocks'), $this->equalTo([])) - ->will($this->returnValue($blocks)); + ->with($this->equalTo('blocks'), $this->equalTo('')) + ->will($this->returnValue(json_encode($blocks))); $this->requestMock->expects($this->at(2)) ->method('getParam') - ->with($this->equalTo('handles'), $this->equalTo([])) - ->will($this->returnValue($handles)); + ->with($this->equalTo('handles'), $this->equalTo('')) + ->will($this->returnValue(json_encode($handles))); $this->viewMock->expects($this->once()) ->method('loadLayout') ->with($this->equalTo($handles)); @@ -165,4 +165,67 @@ class BlockTest extends \PHPUnit_Framework_TestCase $this->controller->renderAction(); } + + public function testEsiAction() + { + $block = 'block'; + $handles = ['handle1', 'handle2']; + $html = 'some-html'; + $mapData = array( + array('blocks', '', json_encode([$block])), + array('handles', '', json_encode($handles)) + ); + + $blockInstance1 = $this->getMockForAbstractClass( + 'Magento\View\Element\AbstractBlock', array(), '', false, true, true, array('toHtml', 'getTtl') + ); + + $blockInstance1->expects($this->once()) + ->method('toHtml') + ->will($this->returnValue($html)); + $blockInstance1->setTtl(360); + + $this->requestMock->expects($this->any()) + ->method('getParam') + ->will($this->returnValueMap($mapData)); + + $this->viewMock->expects($this->once()) + ->method('loadLayout') + ->with($this->equalTo($handles)); + + $this->viewMock->expects($this->once()) + ->method('getLayout') + ->will($this->returnValue($this->layoutMock)); + + $this->layoutMock->expects($this->once()) + ->method('getBlock') + ->with($this->equalTo($block)) + ->will($this->returnValue($blockInstance1)); + + $this->responseMock->expects($this->once()) + ->method('appendBody') + ->with($this->equalTo($html)); + + $result = $this->controller->esiAction(); + $this->assertNull($result); + } + + public function testEsiActionBlockNotExists() + { + $handles = json_encode(array('handle1', 'handle2')); + $mapData = array( + array('blocks', '', null), + array('handles', '', $handles) + ); + + $this->requestMock->expects($this->any()) + ->method('getParam') + ->will($this->returnValueMap($mapData)); + $this->viewMock->expects($this->never()) + ->method('getLayout') + ->will($this->returnValue($this->layoutMock)); + + $result = $this->controller->esiAction(); + $this->assertNull($result); + } } diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Helper/DataTest.php index 42696863280..80a7d9be4f6 100644 --- a/dev/tests/unit/testsuite/Magento/PageCache/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/PageCache/Helper/DataTest.php @@ -37,10 +37,81 @@ namespace Magento\PageCache\Helper; */ class DataTest extends \PHPUnit_Framework_TestCase { + /** @var \Magento\PageCache\Helper\Data */ + protected $helper; + + /** @var \Magento\View\Layout\ProcessorInterface */ + protected $updateLayoutMock; + + /** @var \Magento\Theme\Model\Layout\Config */ + protected $configMock; + public function testMaxAgeCache() { // one year $age = 365 * 24 * 60 * 60; $this->assertEquals($age, \Magento\PageCache\Helper\Data::PRIVATE_MAX_AGE_CACHE); } + + /** + * test for getActualHandles function + */ + public function testGetActualHandles() + { + $this->prepareMocks(); + $layoutHandles = [ + 'handle1', + 'config_layout_handle1', + 'handle2' + ]; + $configHandles = [ + 'config_layout_handle1' + ]; + $resultHandles = [ + 'default', + 'config_layout_handle1' + ]; + + $this->updateLayoutMock->expects($this->once()) + ->method('getHandles') + ->will($this->returnValue($layoutHandles)); + $this->configMock->expects($this->once()) + ->method('getPageLayoutHandles') + ->will($this->returnValue($configHandles)); + + $this->assertEquals($resultHandles, $this->helper->getActualHandles()); + } + + protected function prepareMocks() + { + $this->configMock = $this->getMock('Magento\Theme\Model\Layout\Config', [], [], '', false); + $viewMock = $this->getMock('Magento\App\View', ['getLayout'], ['getPageLayoutHandles'], '', false); + $layoutMock = $this->getMockForAbstractClass( + 'Magento\View\LayoutInterface', + [], + '', + false, + true, + true, + ['getUpdate'] + ); + $this->updateLayoutMock = $this->getMockForAbstractClass( + 'Magento\View\Layout\ProcessorInterface', + [], + '', + false, + true, + true, + [] + ); + + $viewMock->expects($this->once()) + ->method('getLayout') + ->will($this->returnValue($layoutMock)); + $layoutMock->expects($this->once()) + ->method('getUpdate') + ->will($this->returnValue($this->updateLayoutMock)); + + $this->helper = new \Magento\PageCache\Helper\Data($this->configMock, $viewMock); + } } diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/CachePluginTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/CachePluginTest.php new file mode 100644 index 00000000000..92a86a0941f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/CachePluginTest.php @@ -0,0 +1,134 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\PageCache\Model\App\FrontController; + +class CachePluginTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\PageCache\Model\App\FrontController\CachePlugin + */ + protected $plugin; + + /** + * @var \Magento\PageCache\Model\Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $config; + + /** + * @var \Magento\App\PageCache\Version|\PHPUnit_Framework_MockObject_MockObject + */ + protected $version; + + /** + * @var \Magento\App\PageCache\Kernel|\PHPUnit_Framework_MockObject_MockObject + */ + protected $kernel; + + /** + * @var \Magento\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $response; + + /** + * @var \Magento\App\FrontControllerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $frontController; + + /** + * @var \Closure + */ + protected $closure; + + /** + * @var \Magento\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $request; + + /** + * SetUp + */ + public function setUp() + { + $this->config = $this->getMock('Magento\PageCache\Model\Config', array(), array(), '', false); + $this->version = $this->getMock('Magento\App\PageCache\Version', array(), array(), '', false); + $this->kernel = $this->getMock('Magento\App\PageCache\Kernel', array(), array(), '', false); + $this->frontController = $this->getMock('Magento\App\FrontControllerInterface', array(), array(), '', false); + $this->request = $this->getMock('Magento\App\RequestInterface', array(), array(), '', false); + $this->response = $this->getMock('Magento\App\Response\Http', array(), array(), '', false); + $response = $this->response; + $this->closure = function () use ($response) { + return $response; + }; + $this->plugin = new CachePlugin($this->config, $this->version, $this->kernel); + } + + public function testAroundDispatchProcessIfCacheMissedForBuiltIn() + { + $this->version + ->expects($this->once()) + ->method('process'); + $this->config + ->expects($this->once()) + ->method('getType') + ->will($this->returnValue(\Magento\PageCache\Model\Config::BUILT_IN)); + $this->kernel + ->expects($this->once()) + ->method('load') + ->will($this->returnValue(false)); + $this->kernel + ->expects($this->once()) + ->method('process') + ->with($this->response); + $this->plugin->aroundDispatch($this->frontController, $this->closure, $this->request); + } + + public function testAroundDispatchReturnsCacheForBuiltIn() + { + $this->version + ->expects($this->once()) + ->method('process'); + $this->config + ->expects($this->once()) + ->method('getType') + ->will($this->returnValue(\Magento\PageCache\Model\Config::BUILT_IN)); + $this->kernel + ->expects($this->once()) + ->method('load') + ->will($this->returnValue($this->response)); + $this->plugin->aroundDispatch($this->frontController, $this->closure, $this->request); + } + + public function testAroundDispatchVarnish() + { + $this->version + ->expects($this->once()) + ->method('process'); + $this->config + ->expects($this->once()) + ->method('getType') + ->will($this->returnValue(\Magento\PageCache\Model\Config::VARNISH)); + $this->plugin->aroundDispatch($this->frontController, $this->closure, $this->request); + } +} diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php deleted file mode 100644 index 9eef313212a..00000000000 --- a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php +++ /dev/null @@ -1,177 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_PageCache - * @subpackage unit_tests - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\PageCache\Model\App\FrontController; - -use Magento\PageCache\Helper\Data; - -class HeaderPluginTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\PageCache\Model\App\FrontController\HeaderPlugin - */ - protected $plugin; - - /** - * @var \Magento\Core\Model\Layout|\PHPUnit_Framework_MockObject_MockObject - */ - protected $layoutMock; - - /** - * @var \Magento\App\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $configMock; - - /** - * @var \Magento\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject - */ - protected $responseMock; - - /** - * @var \Magento\PageCache\Model\Version|\PHPUnit_Framework_MockObject_MockObject - */ - protected $versionMock; - - /** - * @var \Magento\PageCache\Helper\Data|\PHPUnit_Framework_MockObject_MockObject - */ - protected $helperMock; - - /** - * SetUp - */ - protected function setUp() - { - $this->layoutMock = $this->getMock('Magento\Core\Model\Layout', array(), array(), '', false); - $this->configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); - $this->responseMock = $this->getMock('Magento\App\Response\Http', array(), array(), '', false); - $this->versionMock = $this->getMockBuilder('Magento\PageCache\Model\Version') - ->disableOriginalConstructor() - ->getMock(); - $this->plugin = new HeaderPlugin($this->layoutMock, $this->configMock, $this->versionMock); - } - - /** - * Test if layout is not cacheable - */ - public function testAfterDispatchNotCacheable() - { - $pragma = 'no-cache'; - $cacheControl = 'no-store, no-cache, must-revalidate, max-age=0'; - - $this->layoutMock->expects($this->once()) - ->method('isPrivate') - ->will($this->returnValue(false)); - - $this->layoutMock->expects($this->once()) - ->method('isCacheable') - ->will($this->returnValue(false)); - - $this->responseMock->expects($this->at(0)) - ->method('setHeader') - ->with($this->equalTo('pragma'), $this->equalTo($pragma), $this->equalTo(true)); - $this->responseMock->expects($this->at(1)) - ->method('setHeader') - ->with($this->equalTo('cache-control'), $this->equalTo($cacheControl), $this->equalTo(true)); - $this->responseMock->expects($this->at(2)) - ->method('setHeader') - ->with($this->equalTo('expires')); - - $this->versionMock->expects($this->once())->method('process'); - - $result = $this->plugin->afterDispatch($this->responseMock); - $this->assertInstanceOf('Magento\App\ResponseInterface', $result); - } - - /** - * Testing that `cache-control` already exists - */ - public function testAfterDispatchPrivateCache() - { - $pragma = 'cache'; - $maxAge = Data::PRIVATE_MAX_AGE_CACHE; - $cacheControl = 'private, max-age=' . $maxAge; - - $this->layoutMock->expects($this->once()) - ->method('isPrivate') - ->will($this->returnValue(true)); - - $this->responseMock->expects($this->at(0)) - ->method('setHeader') - ->with($this->equalTo('pragma'), $this->equalTo($pragma), $this->equalTo(true)); - $this->responseMock->expects($this->at(1)) - ->method('setHeader') - ->with($this->equalTo('cache-control'), $this->equalTo($cacheControl), $this->equalTo(true)); - $this->responseMock->expects($this->at(2)) - ->method('setHeader') - ->with($this->equalTo('expires')); - - $this->layoutMock->expects($this->never())->method('isCacheable'); - $this->versionMock->expects($this->never())->method('process'); - - $result = $this->plugin->afterDispatch($this->responseMock); - $this->assertInstanceOf('Magento\App\ResponseInterface', $result); - } - - /** - * Test setting public headers - */ - public function testAfterDispatchPublicCache() - { - $maxAge = 120; - $pragma = 'cache'; - $cacheControl = 'public, max-age=' . $maxAge . ', s-maxage=' . $maxAge; - - $this->configMock->expects($this->once()) - ->method('getValue') - ->with($this->equalTo(\Magento\PageCache\Model\Config::XML_PAGECACHE_TTL)) - ->will($this->returnValue($maxAge)); - - $this->layoutMock->expects($this->once()) - ->method('isPrivate') - ->will($this->returnValue(false)); - - $this->layoutMock->expects($this->once()) - ->method('isCacheable') - ->will($this->returnValue(true)); - - $this->responseMock->expects($this->at(0)) - ->method('setHeader') - ->with($this->equalTo('pragma'), $this->equalTo($pragma), $this->equalTo(true)); - $this->responseMock->expects($this->at(1)) - ->method('setHeader') - ->with($this->equalTo('cache-control'), $this->equalTo($cacheControl), $this->equalTo(true)); - $this->responseMock->expects($this->at(2)) - ->method('setHeader') - ->with($this->equalTo('expires')); - - $this->versionMock->expects($this->once())->method('process'); - - $result = $this->plugin->afterDispatch($this->responseMock); - $this->assertInstanceOf('Magento\App\ResponseInterface', $result); - } -} diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/Layout/LayoutPluginTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/Layout/LayoutPluginTest.php new file mode 100644 index 00000000000..37966e9d665 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/Layout/LayoutPluginTest.php @@ -0,0 +1,151 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\PageCache\Model\Layout; + +class LayoutPluginTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\PageCache\Model\Layout\LayoutPlugin + */ + protected $model; + + /** + * @var \Magento\App\ResponseInterface + */ + protected $responseMock; + + /** + * @var \Magento\Core\Model\Layout + */ + protected $layoutMock; + + /** + * @var \Magento\App\ConfigInterface + */ + protected $configMock; + + public function setUp() + { + $this->layoutMock = $this->getMockForAbstractClass( + 'Magento\Core\Model\Layout', + [], + '', + false, + true, + true, + ['isCacheable'] + ); + $this->responseMock = $this->getMock( + '\Magento\App\Response\Http', + [], + [], + '', + false + ); + $this->configMock = $this->getMockForAbstractClass( + 'Magento\App\ConfigInterface', + [], + '', + false, + true, + true, + ['isSetFlag', 'getValue'] + ); + + $this->model = new \Magento\PageCache\Model\Layout\LayoutPlugin( + $this->layoutMock, + $this->responseMock, + $this->configMock + ); + } + + /** + * @param $layoutIsCacheable + * @dataProvider afterGenerateXmlDataProvider + */ + public function testAfterGenerateXml($layoutIsCacheable) + { + $maxAge = 180; + $result = 'test'; + + $this->layoutMock->expects($this->once()) + ->method('isCacheable') + ->will($this->returnValue($layoutIsCacheable)); + if ($layoutIsCacheable) { + $this->configMock->expects($this->once()) + ->method('getValue') + ->with(\Magento\PageCache\Model\Config::XML_PAGECACHE_TTL) + ->will($this->returnValue($maxAge)); + $this->responseMock->expects($this->once()) + ->method('setPublicHeaders') + ->with($maxAge); + } else { + $this->responseMock->expects($this->never()) + ->method('setPublicHeaders'); + } + $output = $this->model->afterGenerateXml($this->layoutMock, $result); + $this->assertSame($result, $output); + + } + + public function afterGenerateXmlDataProvider() + { + return [ + 'Layout is cache-able' => [true], + 'Layout is not cache-able' => [false] + ]; + } + + /** + * @param bool $layoutIsCacheable + * @dataProvider afterGetOutputDataProvider + */ + public function testAfterGetOutput($layoutIsCacheable) + { + $html = 'html'; + + $this->layoutMock->expects($this->once()) + ->method('isCacheable') + ->will($this->returnValue($layoutIsCacheable)); + if ($layoutIsCacheable) { + $this->responseMock->expects($this->once()) + ->method('setHeader') + ->with('X-Magento-Tags'); + } else { + $this->responseMock->expects($this->never()) + ->method('setHeader'); + } + $output = $this->model->afterGetOutput($this->layoutMock, $html); + $this->assertSame($output, $html); + } + + public function afterGetOutputDataProvider() + { + return [ + 'Layout is cache-able' => [true], + 'Layout is not cache-able' => [false] + ]; + } +} \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/ObserverTest.php new file mode 100644 index 00000000000..2578d86cfd6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/ObserverTest.php @@ -0,0 +1,210 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_PageCache + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\PageCache\Model; + +class ObserverTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\PageCache\Model\Observer */ + protected $_model; + + /** @var \Magento\Core\Model\Config */ + protected $_configMock; + + /** @var \Magento\App\PageCache\Cache */ + protected $_cacheMock; + + /** @var \Magento\View\Element\AbstractBlock */ + protected $_blockMock; + + /** @var \Magento\Core\Model\Layout */ + protected $_layoutMock; + + /** @var \Magento\Event\Observer */ + protected $_observerMock; + + /** @var \Magento\PageCache\Helper\Data */ + protected $_helperMock; + + /** @var \Magento\Object */ + protected $_transport; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Object\ */ + protected $_observerObject; + + /** + * Set up all mocks and data for test + */ + public function setUp() + { + $this->_configMock = $this->getMock('Magento\PageCache\Model\Config', ['getType'], [], '', false); + $this->_cacheMock = $this->getMock('Magento\App\PageCache\Cache', ['clean'], [], '', false); + $this->_helperMock = $this->getMock('Magento\PageCache\Helper\Data', [], [], '', false); + $this->_model = new \Magento\PageCache\Model\Observer( + $this->_configMock, + $this->_cacheMock, + $this->_helperMock + ); + $this->_observerMock = $this->getMock('Magento\Event\Observer', ['getEvent'], [], '', false); + $this->_layoutMock = $this->getMock( + 'Magento\Core\Model\Layout', + ['isCacheable', 'getBlock', 'getUpdate', 'getHandles'], + [], + '', + false + ); + $this->_blockMock = $this->getMockForAbstractClass( + 'Magento\View\Element\AbstractBlock', + [], + '', + false, + true, + true, + ['getTtl', 'isScopePrivate', 'getNameInLayout', 'getUrl'] + ); + $this->_transport = new \Magento\Object([ + 'output' => 'test output html' + ]); + $this->_observerObject = $this->getMock('\Magento\Core\Model\Store', [], [], '', false); + } + + /** + * @param bool $varnishIsEnabled + * @param bool $scopeIsPrivate + * @param int|null $blockTtl + * @param string $expectedOutput + * @dataProvider processLayoutRenderDataProvider + */ + public function testProcessLayoutRenderElement($varnishIsEnabled, $scopeIsPrivate, $blockTtl, $expectedOutput) + { + $eventMock = $this->getMock('Magento\Event', ['getLayout', 'getElementName', 'getTransport'], [], '', false); + $this->_observerMock->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($eventMock)); + $eventMock->expects($this->once()) + ->method('getLayout') + ->will($this->returnValue($this->_layoutMock)); + $eventMock->expects($this->once()) + ->method('getElementName') + ->will($this->returnValue('blockName')); + $eventMock->expects($this->once()) + ->method('getTransport') + ->will($this->returnValue($this->_transport)); + $this->_layoutMock->expects($this->once()) + ->method('isCacheable') + ->will($this->returnValue(true)); + $this->_layoutMock->expects($this->once()) + ->method('getBlock') + ->will($this->returnValue($this->_blockMock)); + $this->_layoutMock->expects($this->any()) + ->method('getUpdate') + ->will($this->returnSelf()); + $this->_layoutMock->expects($this->any()) + ->method('getHandles') + ->will($this->returnValue([])); + + if ($varnishIsEnabled) { + $this->_blockMock->setTtl($blockTtl); + $this->_blockMock->expects($this->any()) + ->method('getUrl') + ->will($this->returnValue('page_cache/block/wrapesi/with/handles/and/other/stuff')); + } + if ($scopeIsPrivate) { + $this->_blockMock->expects($this->once()) + ->method('getNameInLayout') + ->will($this->returnValue('testBlockName')); + $this->_blockMock->expects($this->once()) + ->method('isScopePrivate') + ->will($this->returnValue($scopeIsPrivate)); + } + $this->_configMock->expects($this->once()) + ->method('getType') + ->will($this->returnValue($varnishIsEnabled)); + + $this->_model->processLayoutRenderElement($this->_observerMock); + + $this->assertEquals($expectedOutput, $this->_transport['output']); + } + + /** + * Data provider for testProcessLayoutRenderElement + * + * @return array + */ + public function processLayoutRenderDataProvider() + { + return [ + 'Varnish enabled, public scope, ttl is set' => + [true, false, 360, '<esi:include src="page_cache/block/wrapesi/with/handles/and/other/stuff" />'], + 'Varnish enabled, public scope, ttl is not set' => [true, false, null, 'test output html'], + 'Varnish disabled, public scope, ttl is set' => [false, false, 360, 'test output html'], + 'Varnish disabled, public scope, ttl is not set' => [false, false, null, 'test output html'], + 'Varnish disabled, private scope, ttl is not set' => + [false, true, null, '<!-- BLOCK testBlockName -->test output html<!-- /BLOCK testBlockName -->'] + ]; + } + + /** + * Test case for cache invalidation + */ + public function testInvalidateCache() + { + $eventMock = $this->getMock('Magento\Event', ['getObject'], [], '', false); + $eventMock->expects($this->once()) + ->method('getObject') + ->will($this->returnValue($this->_observerObject)); + $this->_observerMock->expects($this->once()) + ->method('getEvent') + ->will($this->returnValue($eventMock)); + $this->_configMock->expects($this->once()) + ->method('getType') + ->will($this->returnValue(0)); + $tags = array('cache_1', 'cache_group'); + $this->_observerObject->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($tags)); + + $this->_cacheMock->expects($this->once()) + ->method('clean') + ->with($this->equalTo($tags)); + + $this->_model->invalidateCache($this->_observerMock); + } + + /** + * Test case for flushing all the cache + */ + public function testFlushAllCache() + { + $this->_configMock->expects($this->once()) + ->method('getType') + ->will($this->returnValue(0)); + + $this->_cacheMock->expects($this->once()) + ->method('clean'); + $this->_model->flushAllCache($this->_observerMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Payment/Block/Info/ContainerAbstractTest.php b/dev/tests/unit/testsuite/Magento/Payment/Block/Info/ContainerAbstractTest.php index 0e49cd75ceb..05455b442f3 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Block/Info/ContainerAbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Payment/Block/Info/ContainerAbstractTest.php @@ -40,7 +40,7 @@ class ContainerAbstractTest extends \PHPUnit_Framework_TestCase $paymentInfo = $objectManagerHelper->getObject('Magento\Payment\Model\Info'); $adapterFactoryMock = $this->getMock('Magento\Logger\AdapterFactory', array('create'), array(), '', false); - $methodInstance = $objectManagerHelper->getObject('Magento\Payment\Model\Method\Checkmo', array( + $methodInstance = $objectManagerHelper->getObject('Magento\OfflinePayments\Model\Checkmo', array( 'logAdapterFactory' => $adapterFactoryMock, )); $paymentInfo->setMethodInstance($methodInstance); diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Config/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/Config/ConverterTest.php index 0af6f70d511..a094cd5758a 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Model/Config/ConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Config/ConverterTest.php @@ -52,7 +52,7 @@ class ConverterTest extends \PHPUnit_Framework_TestCase 'SM' => 'Switch/Maestro', ), 'groups' => array( - 'paypal' => 'PayPal', + 'any_payment' => 'Any Payment', ), 'methods' => array( 'checkmo' => array( diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Config/_files/payment.xml b/dev/tests/unit/testsuite/Magento/Payment/Model/Config/_files/payment.xml index 440b90f0f1b..e20240026e3 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Model/Config/_files/payment.xml +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Config/_files/payment.xml @@ -34,8 +34,8 @@ </type> </credit_cards> <groups> - <group id="paypal"> - <label>PayPal</label> + <group id="any_payment"> + <label>Any Payment</label> </group> </groups> <methods> diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FactoryTest.php index 03dce84b72c..fc0246d3a7f 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/FactoryTest.php @@ -69,7 +69,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase /** * @expectedException \Magento\Core\Exception - * @expectedExceptionMessage WrongClass class doesn't extend \Magento\Payment\Model\Method\AbstractMethod + * @expectedExceptionMessage WrongClass class doesn't implement \Magento\Payment\Model\MethodInterface */ public function testWrongTypeException() { diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Block/Express/FormTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Block/Express/FormTest.php index f0ec49b266b..0a68f056886 100644 --- a/dev/tests/unit/testsuite/Magento/Paypal/Block/Express/FormTest.php +++ b/dev/tests/unit/testsuite/Magento/Paypal/Block/Express/FormTest.php @@ -64,6 +64,11 @@ class FormTest extends \PHPUnit_Framework_TestCase ->method('createBlock') ->with('Magento\View\Element\Template') ->will($this->returnValue($mark)); + $localeResolver = $this->getMock('Magento\Locale\ResolverInterface', array(), array(), '', false, false); + $appMock = $this->getMock('\Magento\Core\Model\App', array('getLocaleResolver'), array(), '', false); + $appMock->expects($this->any()) + ->method('getLocaleResolver') + ->will($this->returnValue($localeResolver)); $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_model = $helper->getObject( 'Magento\Paypal\Block\Express\Form', @@ -72,6 +77,7 @@ class FormTest extends \PHPUnit_Framework_TestCase 'customerSession' => $this->_customerSession, 'paypalConfigFactory' => $paypalConfigFactory, 'layout' => $layout, + 'app' => $appMock, ] ); } diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Block/PayflowExpress/FormTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Block/PayflowExpress/FormTest.php index 03f7466c6fa..51d1ebdd161 100644 --- a/dev/tests/unit/testsuite/Magento/Paypal/Block/PayflowExpress/FormTest.php +++ b/dev/tests/unit/testsuite/Magento/Paypal/Block/PayflowExpress/FormTest.php @@ -52,12 +52,18 @@ class FormTest extends \PHPUnit_Framework_TestCase ->method('createBlock') ->with('Magento\View\Element\Template') ->will($this->returnValue($mark)); + $localeResolver = $this->getMock('Magento\Locale\ResolverInterface', array(), array(), '', false, false); + $appMock = $this->getMock('\Magento\Core\Model\App', array('getLocaleResolver'), array(), '', false); + $appMock->expects($this->any()) + ->method('getLocaleResolver') + ->will($this->returnValue($localeResolver)); $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_model = $helper->getObject( 'Magento\Paypal\Block\PayflowExpress\Form', [ 'paypalConfigFactory' => $paypalConfigFactory, 'layout' => $layout, + 'app' => $appMock, ] ); } diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Helper/CheckoutTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Helper/CheckoutTest.php index 5beaabab94f..9456bee3562 100644 --- a/dev/tests/unit/testsuite/Magento/Paypal/Helper/CheckoutTest.php +++ b/dev/tests/unit/testsuite/Magento/Paypal/Helper/CheckoutTest.php @@ -124,83 +124,4 @@ class CheckoutTest extends \PHPUnit_Framework_TestCase array(false, false, false), ); } - - /** - * @param bool $hasOrderId - * @param bool $hasQuoteId - * @dataProvider restoreQuoteDataProvider - */ - public function testRestoreQuote($hasOrderId, $hasQuoteId) - { - $quote = $this->getMockBuilder('Magento\Sales\Model\Quote') - ->disableOriginalConstructor() - ->setMethods(array('getId', 'save', 'setIsActive', 'setReservedOrderId', 'load', '__wakeup')) - ->getMock(); - $order = $this->_getOrderMock($hasOrderId); - $this->_session->expects($this->once()) - ->method('getLastRealOrder') - ->will($this->returnValue($order)); - - if ($hasOrderId) { - $quoteId = 'quote id'; - $order->setQuoteId($quoteId); - $this->_quoteFactory->expects($this->once()) - ->method('create') - ->will($this->returnValue($quote)); - $quote->expects($this->once()) - ->method('getId') - ->will($this->returnValue($hasQuoteId ? 'some quote id' : null)); - $quote->expects($this->any()) - ->method('load') - ->with($this->equalTo($quoteId)) - ->will($this->returnValue($quote)); - if ($hasQuoteId) { - $quote->expects($this->once()) - ->method('setIsActive') - ->with($this->equalTo(1)) - ->will($this->returnSelf()); - $quote->expects($this->once()) - ->method('setReservedOrderId') - ->with($this->isNull()) - ->will($this->returnSelf()); - $quote->expects($this->once()) - ->method('save'); - $this->_session->expects($this->once()) - ->method('replaceQuote') - ->with($quote) - ->will($this->returnSelf()); - } else { - $quote->expects($this->never()) - ->method('setIsActive'); - $quote->expects($this->never()) - ->method('setReservedOrderId'); - $quote->expects($this->never()) - ->method('save'); - } - } - if ($hasOrderId && $hasQuoteId) { - $this->_session->expects($this->once()) - ->method('unsLastRealOrderId'); - } else { - $this->_session->expects($this->never()) - ->method('replaceQuote'); - $this->_session->expects($this->never()) - ->method('unsLastRealOrderId'); - } - $result = $this->_checkout->restoreQuote(); - $this->assertEquals($result, $hasOrderId && $hasQuoteId); - } - - /** - * @return array - */ - public function restoreQuoteDataProvider() - { - return array( - array(true, true), - array(true, false), - array(false, true), - array(false, false), - ); - } } diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Helper/DataTest.php index 28a1cc10518..5181045b6c8 100644 --- a/dev/tests/unit/testsuite/Magento/Paypal/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Paypal/Helper/DataTest.php @@ -69,19 +69,6 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expectedResult, $this->_helper->getBillingAgreementMethods($store, $quote)); } - /** - * @dataProvider getAllBillingAgreementMethodsDataProvider - * @param $paymentMethods - * @param $expectedResult - */ - public function testGetAllBillingAgreementMethods($paymentMethods, $expectedResult) - { - $this->_paymentDataMock->expects($this->any()) - ->method('getPaymentMethods') - ->will($this->returnValue($paymentMethods)); - $this->assertEquals($expectedResult, $this->_helper->getAllBillingAgreementMethods()); - } - /** * @dataProvider canManageBillingAgreementsDataProvider * @param $expectedResult @@ -109,29 +96,6 @@ class DataTest extends \PHPUnit_Framework_TestCase ); } - /** - * @return array - */ - public function getAllBillingAgreementMethodsDataProvider() - { - $methodInterfaceMock = $this->getMockBuilder('Magento\Paypal\Model\Billing\Agreement\MethodInterface') - ->getMock(); - return array( - array( - array( - 'code1' => array('model' => $methodInterfaceMock, 'title' => 'title1'), - 'code2' => array('title' => 'title2'), - 'code3' => array('model' => new \StdClass(), 'title' => 'title3'), - ), - array('code1' => 'title1') - ), - array( - array('code' => array('title' => 'title')), - array() - ) - ); - } - /** * @return array */ @@ -145,4 +109,3 @@ class DataTest extends \PHPUnit_Framework_TestCase ); } } - \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Model/ObserverTest.php new file mode 100644 index 00000000000..1073a573099 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Persistent/Model/ObserverTest.php @@ -0,0 +1,178 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Persistent\Model; + +class ObserverTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Persistent\Model\Observer + */ + protected $_model; + + /** + * @var \Magento\Event + */ + protected $_event; + + /** + * @var \Magento\Event\Observer + */ + protected $_observer; + + /** + * Customer session + * + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_customerSession; + + /** + * Persistent session + * + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_persistentSession; + + /** + * + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_messageManager; + + /** + * Url model + * + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_url; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_expressRedirectHelper; + + public function setUp() + { + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->_event = new \Magento\Event(); + $this->_observer = new \Magento\Event\Observer(); + $this->_observer->setEvent($this->_event); + + $this->_customerSession = $this->getMockBuilder('Magento\Customer\Model\Session') + ->disableOriginalConstructor() + ->setMethods(['isLoggedIn']) + ->getMock(); + + $this->_persistentSession = $this->getMockBuilder('Magento\Persistent\Helper\Session') + ->disableOriginalConstructor() + ->setMethods(['isPersistent']) + ->getMock(); + + $this->_messageManager = $this->getMockBuilder('Magento\Message\ManagerInterface') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->_url = $this->getMockBuilder('Magento\UrlInterface') + ->disableOriginalConstructor() + ->setMethods([]) + ->getMock(); + + $this->_expressRedirectHelper = $this->getMockBuilder('Magento\Checkout\Helper\ExpressRedirect') + ->disableOriginalConstructor() + ->setMethods(['redirectLogin']) + ->getMock(); + + $this->_model = $helper->getObject('Magento\Persistent\Model\Observer', array( + 'customerSession' => $this->_customerSession, + 'persistentSession' => $this->_persistentSession, + 'messageManager' => $this->_messageManager, + 'url' => $this->_url, + 'expressRedirectHelper' => $this->_expressRedirectHelper + )); + } + + public function testPreventExpressCheckoutOnline() + { + $this->_customerSession->expects($this->once()) + ->method('isLoggedIn') + ->will($this->returnValue(true)); + $this->_persistentSession->expects($this->once()) + ->method('isPersistent') + ->will($this->returnValue(true)); + $this->_model->preventExpressCheckout($this->_observer); + } + + public function testPreventExpressCheckoutEmpty() + { + $this->_customerSession->expects($this->any()) + ->method('isLoggedIn') + ->will($this->returnValue(false)); + $this->_persistentSession->expects($this->any()) + ->method('isPersistent') + ->will($this->returnValue(true)); + + $this->_event->setControllerAction(null); + $this->_model->preventExpressCheckout($this->_observer); + + $this->_event->setControllerAction(new \StdClass); + $this->_model->preventExpressCheckout($this->_observer); + + $expectedActionName = 'realAction'; + $unexpectedActionName = 'notAction'; + $request = new \Magento\Object(); + $request->setActionName($unexpectedActionName); + $expressRedirectMock = $this->getMockBuilder('Magento\Checkout\Controller\Express\RedirectLoginInterface') + ->disableOriginalConstructor() + ->setMethods([ + 'getActionFlagList', + 'getResponse', + 'getCustomerBeforeAuthUrl', + 'getLoginUrl', + 'getRedirectActionName', + 'getRequest']) + ->getMock(); + $expressRedirectMock->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($request)); + $expressRedirectMock->expects($this->any()) + ->method('getRedirectActionName') + ->will($this->returnValue($expectedActionName)); + $this->_event->setControllerAction($expressRedirectMock); + $this->_model->preventExpressCheckout($this->_observer); + + $expectedAuthUrl = 'expectedAuthUrl'; + $request->setActionName($expectedActionName); + $this->_url->expects($this->once()) + ->method('getUrl') + ->will($this->returnValue($expectedAuthUrl)); + $this->_expressRedirectHelper->expects($this->once()) + ->method('redirectLogin') + ->with($expressRedirectMock, $expectedAuthUrl); + $this->_model->preventExpressCheckout($this->_observer); + } +} + \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Plugin/PaymentTest.php b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Plugin/PaymentTest.php index c9a8cee9d94..49504d23ec8 100644 --- a/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Plugin/PaymentTest.php +++ b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Plugin/PaymentTest.php @@ -66,6 +66,12 @@ class PaymentTest extends \PHPUnit_Framework_TestCase ->with($quote) ->will($this->returnValue(true)); - $this->assertArrayHasKey('hasRecurringItems', $this->payment->afterGetOptions([])); + $this->assertArrayHasKey( + 'hasRecurringItems', + $this->payment->afterGetOptions( + $this->getMock('\Magento\Checkout\Block\Onepage\Payment', array(), array(), '', false), + [] + ) + ); } -} \ No newline at end of file +} diff --git a/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/GridTest.php b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/GridTest.php index 908cc82ed62..2373871d3cd 100644 --- a/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/GridTest.php +++ b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/GridTest.php @@ -93,7 +93,7 @@ class GridTest extends \PHPUnit_Framework_TestCase $storeManager->expects($this->once())->method('getStore') ->will($this->returnValue($store)); - $locale = $this->getMockBuilder('\Magento\Core\Model\LocaleInterface') + $locale = $this->getMockBuilder('\Magento\Stdlib\DateTime\TimezoneInterface') ->disableOriginalConstructor() ->setMethods(array('formatDate')) ->getMockForAbstractClass(); @@ -105,7 +105,7 @@ class GridTest extends \PHPUnit_Framework_TestCase 'recurringProfile' => $profile, 'registry' => $registry, 'storeManager' => $storeManager, - 'locale' => $locale + 'localeDate' => $locale ) ); $pagerBlock = $this->getMockBuilder('Magento\Theme\Block\Html\Pager') diff --git a/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/Related/Orders/GridTest.php b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/Related/Orders/GridTest.php index 488dbd44e35..6585d5a818b 100644 --- a/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/Related/Orders/GridTest.php +++ b/dev/tests/unit/testsuite/Magento/RecurringProfile/Block/Profile/Related/Orders/GridTest.php @@ -78,7 +78,7 @@ class GridTest extends \PHPUnit_Framework_TestCase $storeManager = $this->getMock('Magento\Core\Model\StoreManagerInterface'); $storeManager->expects($this->once())->method('getStore') ->will($this->returnValue($store)); - $locale = $this->getMock('\Magento\Core\Model\LocaleInterface'); + $locale = $this->getMock('\Magento\Stdlib\DateTime\TimezoneInterface'); $locale->expects($this->once())->method('formatDate') ->will($this->returnValue('11-11-1999')); $recurringCollectionFilter = $this->getMock( @@ -98,7 +98,7 @@ class GridTest extends \PHPUnit_Framework_TestCase 'registry' => $registry, 'storeManager' => $storeManager, 'collection' => $collection, - 'locale' => $locale, + 'localeDate' => $locale, 'coreHelper' => $helper, 'recurringCollectionFilter' => $recurringCollectionFilter ) diff --git a/dev/tests/unit/testsuite/Magento/Reports/Block/Product/ViewedTest.php b/dev/tests/unit/testsuite/Magento/Reports/Block/Product/ViewedTest.php new file mode 100644 index 00000000000..a5415bbde79 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Reports/Block/Product/ViewedTest.php @@ -0,0 +1,63 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Reports\Block\Product; + +class ViewedTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Reports\Block\Product\Viewed + */ + protected $block; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->block = $objectManager->getObject('Magento\Reports\Block\Product\Viewed'); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $productTags = array('catalog_product_1'); + + $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $product->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($productTags)); + + $collection = new \ReflectionProperty('Magento\Reports\Block\Product\Viewed', '_collection'); + $collection->setAccessible(true); + $collection->setValue($this->block, array($product)); + + $this->assertEquals( + $productTags, + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Reports/Model/Plugin/LogTest.php b/dev/tests/unit/testsuite/Magento/Reports/Model/Plugin/LogTest.php index 32dc5341c24..88853426f17 100644 --- a/dev/tests/unit/testsuite/Magento/Reports/Model/Plugin/LogTest.php +++ b/dev/tests/unit/testsuite/Magento/Reports/Model/Plugin/LogTest.php @@ -28,46 +28,52 @@ class LogTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Reports\Model\Plugin\Log */ - protected $_model; + protected $model; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_reportEventMock; + protected $reportEventMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_cmpProductIdxMock; + protected $cmpProductIdxMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_viewProductIdxMock; + protected $viewProductIdxMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_logResourceMock; + protected $logResourceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; protected function setUp() { - $this->_reportEventMock = $this->getMock( + $this->reportEventMock = $this->getMock( 'Magento\Reports\Model\Event', array(), array(), '', false ); - $this->_cmpProductIdxMock = $this->getMock( + $this->cmpProductIdxMock = $this->getMock( 'Magento\Reports\Model\Product\Index\Compared', array(), array(), '', false ); - $this->_viewProductIdxMock = $this->getMock( + $this->viewProductIdxMock = $this->getMock( 'Magento\Reports\Model\Product\Index\Viewed', array(), array(), '', false ); - $this->_logResourceMock = $this->getMock('Magento\Log\Model\Resource\Log', array(), array(), '', false); + $this->logResourceMock = $this->getMock('Magento\Log\Model\Resource\Log', array(), array(), '', false); - $this->_model = new \Magento\Reports\Model\Plugin\Log( - $this->_reportEventMock, - $this->_cmpProductIdxMock, - $this->_viewProductIdxMock + $this->subjectMock = $this->getMock('Magento\Log\Model\Resource\Log', array(), array(), '', false); + $this->model = new \Magento\Reports\Model\Plugin\Log( + $this->reportEventMock, + $this->cmpProductIdxMock, + $this->viewProductIdxMock ); } @@ -76,15 +82,16 @@ class LogTest extends \PHPUnit_Framework_TestCase */ public function testAfterClean() { - $this->_reportEventMock->expects($this->once()) + $this->reportEventMock->expects($this->once()) ->method('clean'); - $this->_cmpProductIdxMock->expects($this->once()) + $this->cmpProductIdxMock->expects($this->once()) ->method('clean'); - $this->_viewProductIdxMock->expects($this->once()) + $this->viewProductIdxMock->expects($this->once()) ->method('clean'); - $this->assertEquals($this->_logResourceMock, $this->_model->afterClean($this->_logResourceMock)); + $this->assertEquals($this->logResourceMock, + $this->model->afterClean($this->subjectMock, $this->logResourceMock)); } } diff --git a/dev/tests/unit/testsuite/Magento/Reports/Model/Resource/Report/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Reports/Model/Resource/Report/CollectionTest.php index 3325526b099..76914e76932 100644 --- a/dev/tests/unit/testsuite/Magento/Reports/Model/Resource/Report/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Reports/Model/Resource/Report/CollectionTest.php @@ -51,8 +51,8 @@ class CollectionTest extends \PHPUnit_Framework_TestCase $endDate = date('m/d/Y', strtotime('+3 day')); $this->_model->setInterval($startDate, $endDate); - $startDateMock = $this->getMock('Zend_Date', array(), array(), '', false); - $endDateMock = $this->getMock('Zend_Date', array(), array(), '', false); + $startDateMock = $this->getMock('Magento\Stdlib\DateTime\DateInterface', array(), array(), '', false); + $endDateMock = $this->getMock('Magento\Stdlib\DateTime\DateInterface', array(), array(), '', false); $map = array( array($startDate, null, null, $startDateMock), array($endDate, null, null, $endDateMock), diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Reorder/SidebarTest.php b/dev/tests/unit/testsuite/Magento/Sales/Block/Reorder/SidebarTest.php new file mode 100644 index 00000000000..aa1c8b6fb7e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Block/Reorder/SidebarTest.php @@ -0,0 +1,73 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Block\Reorder; + +class SidebarTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Block\Reorder\Sidebar|\PHPUnit_Framework_MockObject_MockObject + */ + protected $block; + + protected function setUp() + { + $this->block = $this->getMock('Magento\Sales\Block\Reorder\Sidebar', array('getItems'), array(), '', false); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $productTags = array('catalog_product_1'); + + $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $product->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($productTags)); + + $item = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Item', + array('getProduct', '__wakeup'), + array(), + '', + false + ); + $item->expects($this->once()) + ->method('getProduct') + ->will($this->returnValue($product)); + + $this->block->expects($this->once()) + ->method('getItems') + ->will($this->returnValue(array($item))); + + $this->assertEquals( + $productTags, + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/AbstractTest.php index 0c09320940f..6717bf273f2 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/AbstractTest.php @@ -48,7 +48,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $translate = $this->getMock('Magento\TranslateInterface', array(), array(), '', false); $filesystem = $this->getMock('Magento\App\Filesystem', array(), array(), '', false); $pdfItemsFactory = $this->getMock('Magento\Sales\Model\Order\Pdf\ItemsFactory', array(), array(), '', false); - $localeMock = $this->getMock('Magento\Core\Model\LocaleInterface', array(), array(), '', false, false); + $localeMock = $this->getMock('Magento\Stdlib\DateTime\TimezoneInterface', array(), array(), '', false, false); // Setup config file totals $configTotals = array( diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/InvoiceTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/InvoiceTest.php index 29f9ce95017..0315e6f73f3 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/InvoiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/InvoiceTest.php @@ -66,10 +66,12 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase false); $pdfItemsFactoryMock = $this->getMock('Magento\Sales\Model\Order\Pdf\ItemsFactory', array(), array(), '', false, false); - $localeMock = $this->getMock('Magento\Core\Model\LocaleInterface', array(), array(), '', false, + $localeDateMock = $this->getMock('Magento\Stdlib\DateTime\TimezoneInterface', array(), array(), '', false, false); $storeManagerMock = $this->getMock('Magento\Core\Model\StoreManagerInterface', array(), array(), '', false, false); + $localeResolverMock = $this->getMock('Magento\Locale\ResolverInterface', array(), array(), '', false, + false); $this->_model = new \Magento\Sales\Model\Order\Pdf\Invoice( $paymentDataMock, @@ -80,8 +82,9 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase $this->_pdfConfigMock, $totalFactoryMock, $pdfItemsFactoryMock, - $localeMock, + $localeDateMock, $storeManagerMock, + $localeResolverMock, array() ); } diff --git a/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php b/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php index 34d7d4437c2..051f5085e07 100644 --- a/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php +++ b/dev/tests/unit/testsuite/Magento/SalesRule/Model/ValidatorTest.php @@ -105,19 +105,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase return true; } - public function testProcessFreeShipping() - { - $item = $this->getMock('Magento\Sales\Model\Quote\Item', array('getAddress', '__wakeup'), array(), '', false); - $item->expects($this->once()) - ->method('getAddress') - ->will($this->returnValue(true)); - - $this->assertInstanceOf('Magento\SalesRule\Model\Validator', $this->model->processFreeShipping($item)); - - return true; - } - - public function testProcessWhenItemPriceIsNegativeRulesAreNotApplied() + public function testProcess() { $negativePrice = -1; diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Block/Adminhtml/Order/TrackingTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Block/Adminhtml/Order/TrackingTest.php index 8ef575dd36c..594c58ac21b 100644 --- a/dev/tests/unit/testsuite/Magento/Shipping/Block/Adminhtml/Order/TrackingTest.php +++ b/dev/tests/unit/testsuite/Magento/Shipping/Block/Adminhtml/Order/TrackingTest.php @@ -36,7 +36,7 @@ class TrackingTest extends \PHPUnit_Framework_TestCase $registry->expects($this->once())->method('registry') ->with('current_shipment')->will($this->returnValue($shipment)); - $carrier = $this->getMock('Magento\Shipping\Model\Carrier\Freeshipping', + $carrier = $this->getMock('Magento\OfflineShipping\Model\Carrier\Freeshipping', ['isTrackingAvailable', 'getConfigData'], [], '', false); $carrier->expects($this->once())->method('isTrackingAvailable')->will($this->returnValue(true)); $carrier->expects($this->once())->method('getConfigData')->with('title') diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Helper/CarrierTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Helper/CarrierTest.php new file mode 100644 index 00000000000..ed1cc9bcfe5 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Shipping/Helper/CarrierTest.php @@ -0,0 +1,91 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Shipping\Helper; + +/** + * Carrier helper test + */ +class CarrierTest extends \PHPUnit_Framework_TestCase +{ + /** + * Shipping Carrier helper + * + * @var \Magento\Shipping\Helper\Carrier + */ + protected $helper; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeConfig; + + public function setUp() + { + $this->storeConfig = $this->getMock('Magento\Core\Model\Store\ConfigInterface'); + $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->helper = $objectManagerHelper->getObject('Magento\Shipping\Helper\Carrier', [ + 'context' => $this->getMock('Magento\App\Helper\Context', [], [], '', false), + 'locale' => $this->getMock('Magento\LocaleInterface'), + 'storeConfig' => $this->storeConfig, + ]); + } + + /** + * @param array $result + * @param array $carriers + * @dataProvider getOnlineCarrierCodesDataProvider + */ + public function testGetOnlineCarrierCodes($result, $carriers) + { + $this->storeConfig->expects($this->once())->method('getConfig')->with('carriers') + ->will($this->returnValue($carriers)); + $this->assertEquals($result, $this->helper->getOnlineCarrierCodes()); + } + + /** + * Data provider + * + * @return array + */ + public function getOnlineCarrierCodesDataProvider() + { + return [ + [[], ['carrier1' => []]], + [[], ['carrier1' => ['is_online' => 0]]], + [['carrier1'], ['carrier1' => ['is_online' => 1], 'carrier2' => ['is_online' => 0]]], + ]; + } + + public function testGetCarrierConfigValue() + { + $carrierCode = 'carrier1'; + $configPath = 'title'; + $configValue = 'some title'; + $this->storeConfig->expects($this->once())->method('getConfig') + ->with(sprintf('carriers/%s/%s', $carrierCode, $configPath)) + ->will($this->returnValue($configValue)); + $this->assertEquals($configValue, $this->helper->getCarrierConfigValue($carrierCode, $configPath)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Shipping/Model/Order/TrackTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Model/Order/TrackTest.php index fc2fbbf67ee..501d0161955 100644 --- a/dev/tests/unit/testsuite/Magento/Shipping/Model/Order/TrackTest.php +++ b/dev/tests/unit/testsuite/Magento/Shipping/Model/Order/TrackTest.php @@ -30,7 +30,7 @@ class TrackTest extends \PHPUnit_Framework_TestCase { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $carrier = $this->getMock('Magento\Shipping\Model\Carrier\Freeshipping', + $carrier = $this->getMock('Magento\OfflineShipping\Model\Carrier\Freeshipping', ['setStore', 'getTrackingInfo'], [], '', false); $carrier->expects($this->once())->method('setStore')->with(''); $carrier->expects($this->once())->method('getTrackingInfo') @@ -40,7 +40,7 @@ class TrackTest extends \PHPUnit_Framework_TestCase $carrierFactory->expects($this->once())->method('create') ->will($this->returnValue($carrier)); - $shipment = $this->getMock('Magento\Shipping\Model\Carrier\Freeshipping', ['load'], [], '', false); + $shipment = $this->getMock('Magento\OfflineShipping\Model\Carrier\Freeshipping', ['load'], [], '', false); $shipment->expects($this->any())->method('load') ->will($this->returnValue($shipment)); diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Simplexml/ElementTest.php b/dev/tests/unit/testsuite/Magento/Shipping/Model/Simplexml/ElementTest.php similarity index 88% rename from dev/tests/unit/testsuite/Magento/Usa/Model/Simplexml/ElementTest.php rename to dev/tests/unit/testsuite/Magento/Shipping/Model/Simplexml/ElementTest.php index 1bac4c905e9..bb05a504ef4 100644 --- a/dev/tests/unit/testsuite/Magento/Usa/Model/Simplexml/ElementTest.php +++ b/dev/tests/unit/testsuite/Magento/Shipping/Model/Simplexml/ElementTest.php @@ -19,19 +19,18 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Usa * @subpackage unit_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Simplexml; +namespace Magento\Shipping\Model\Simplexml; class ElementTest extends \PHPUnit_Framework_TestCase { public function testXmlentities() { - $xmlElement = new \Magento\Usa\Model\Simplexml\Element('<xml></xml>'); + $xmlElement = new \Magento\Shipping\Model\Simplexml\Element('<xml></xml>'); $this->assertEquals('&copy;&', $xmlElement->xmlentities('©&')); } } diff --git a/dev/tests/unit/testsuite/Magento/Core/Filter/DateTest.php b/dev/tests/unit/testsuite/Magento/Stdlib/DateTime/Filter/DateTest.php similarity index 74% rename from dev/tests/unit/testsuite/Magento/Core/Filter/DateTest.php rename to dev/tests/unit/testsuite/Magento/Stdlib/DateTime/Filter/DateTest.php index 887b0e95600..3ba7ee60567 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Filter/DateTest.php +++ b/dev/tests/unit/testsuite/Magento/Stdlib/DateTime/Filter/DateTest.php @@ -3,16 +3,16 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Filter; +namespace Magento\Stdlib\DateTime\Filter; class DateTest extends \PHPUnit_Framework_TestCase { public function testFilter() { - $localeMock = $this->getMock('\Magento\Core\Model\LocaleInterface'); + $localeMock = $this->getMock('\Magento\Stdlib\DateTime\TimezoneInterface'); $localeMock->expects($this->once()) ->method('getDateFormat') - ->with(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT) + ->with(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT) ->will($this->returnValue('MM-dd-yyyy')); $model = new Date($localeMock); // Check that date is converted to 'yyyy-MM-dd' format diff --git a/dev/tests/unit/testsuite/Magento/Core/Filter/DateTimeTest.php b/dev/tests/unit/testsuite/Magento/Stdlib/DateTime/Filter/DateTimeTest.php similarity index 75% rename from dev/tests/unit/testsuite/Magento/Core/Filter/DateTimeTest.php rename to dev/tests/unit/testsuite/Magento/Stdlib/DateTime/Filter/DateTimeTest.php index 34703c3640c..c061891ed90 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Filter/DateTimeTest.php +++ b/dev/tests/unit/testsuite/Magento/Stdlib/DateTime/Filter/DateTimeTest.php @@ -3,16 +3,16 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Filter; +namespace Magento\Stdlib\DateTime\Filter; class DateTimeTest extends \PHPUnit_Framework_TestCase { public function testFilter() { - $localeMock = $this->getMock('\Magento\Core\Model\LocaleInterface'); + $localeMock = $this->getMock('\Magento\Stdlib\DateTime\TimezoneInterface'); $localeMock->expects($this->once()) ->method('getDateTimeFormat') - ->with(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT) + ->with(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT) ->will($this->returnValue('HH:mm:ss MM-dd-yyyy')); $model = new DateTime($localeMock); // Check that datetime is converted to 'yyyy-MM-dd HH:mm:ss' format diff --git a/dev/tests/unit/testsuite/Magento/Stdlib/DateTimeTest.php b/dev/tests/unit/testsuite/Magento/Stdlib/DateTimeTest.php index 76b6f38d9f3..f6beaddafe7 100644 --- a/dev/tests/unit/testsuite/Magento/Stdlib/DateTimeTest.php +++ b/dev/tests/unit/testsuite/Magento/Stdlib/DateTimeTest.php @@ -44,7 +44,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function testToTimestamp() { - $date = new \Zend_Date(); + $date = new \Magento\Stdlib\DateTime\Date(); $dateTime = new \Magento\Stdlib\DateTime; $this->assertEquals($date->getTimestamp(), $dateTime->toTimestamp($date)); @@ -87,7 +87,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase { // Take care when calling date here as it can be called much earlier than when testFormatDate // executes thus causing a discrepancy in the actual vs expected time. See MAGETWO-10296 - $date = new \Zend_Date(); + $date = new \Magento\Stdlib\DateTime\Date(); return array( 'null' => array(null, false, ''), 'null including Time' => array(null, true, ''), diff --git a/dev/tests/unit/testsuite/Magento/Test/Tools/Di/_files/app/code/Magento/SomeModule/Helper/Test.php b/dev/tests/unit/testsuite/Magento/Test/Tools/Di/_files/app/code/Magento/SomeModule/Helper/Test.php index f3d53b7a93f..1868518b97b 100644 --- a/dev/tests/unit/testsuite/Magento/Test/Tools/Di/_files/app/code/Magento/SomeModule/Helper/Test.php +++ b/dev/tests/unit/testsuite/Magento/Test/Tools/Di/_files/app/code/Magento/SomeModule/Helper/Test.php @@ -59,6 +59,6 @@ class Test */ public function testHelper(\Magento\SomeModule\ElementFactory $factory, array $data = array()) { - $factory->create('\Magento\SomeModule\ElementFactory', array('data' => $data)); + $factory->create('Magento\SomeModule\ElementFactory', array('data' => $data)); } } diff --git a/dev/tests/unit/testsuite/Magento/Theme/Block/Html/FooterTest.php b/dev/tests/unit/testsuite/Magento/Theme/Block/Html/FooterTest.php new file mode 100644 index 00000000000..5d3290435b9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Theme/Block/Html/FooterTest.php @@ -0,0 +1,52 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Theme\Block\Html; + +class FooterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Theme\Block\Html\Footer + */ + protected $block; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->block = $objectManager->getObject('Magento\Theme\Block\Html\Footer'); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $this->assertEquals( + array(\Magento\Core\Model\Store::CACHE_TAG, \Magento\Cms\Model\Block::CACHE_TAG), + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Ups/Helper/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Ups/Helper/ConfigTest.php new file mode 100644 index 00000000000..c24efc592b1 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Ups/Helper/ConfigTest.php @@ -0,0 +1,72 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Ups\Helper; + +/** + * Config helper Test + */ +class ConfigTest extends \PHPUnit_Framework_TestCase +{ + /** + * Ups config helper + * + * @var \Magento\Ups\Helper\Config + */ + protected $helper; + + public function setUp() + { + $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->helper = $objectManagerHelper->getObject('Magento\Ups\Helper\Config'); + } + + /** + * @param mixed $result + * @param null|string $type + * @param string $code + * @dataProvider getCodeDataProvider + */ + public function testGetData($result, $type = null, $code = null) + { + $this->assertEquals($result, $this->helper->getCode($type, $code)); + } + + /** + * Data provider + * + * @return array + */ + public function getCodeDataProvider() + { + return [ + [false], + [false, 'not-exist-type'], + [false, 'not-exist-type', 'not-exist-code'], + [false, 'action'], + [['single' => '3', 'all' => '4'], 'action', ''], + ['3', 'action', 'single'], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Dhl/_files/rates_request_data_dhlintl.php b/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Dhl/_files/rates_request_data_dhlintl.php deleted file mode 100644 index 2c1c4ffb32d..00000000000 --- a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Dhl/_files/rates_request_data_dhlintl.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -return array( - 'data' => array( - 'dest_country_id' => 'DE', - 'dest_region_id' => '82', - 'dest_region_code' => 'BER', - 'dest_street' => 'Turmstraße 17', - 'dest_city' => 'Berlin', - 'dest_postcode' => '10559', - 'dest_postal' => '10559', - 'package_value' => '5', - 'package_value_with_discount' => '5', - 'package_weight' => '5', - 'package_qty' => '1', - 'package_physical_value' => '5', - 'free_method_weight' => '5', - 'store_id' => '1', - 'website_id' => '1', - 'free_shipping' => '0', - 'limit_carrier' => null, - 'base_subtotal_incl_tax' => '5', - 'orig_country_id' => 'US', - 'country_id' => 'US', - 'region_id' => '12', - 'city'=> 'Fremont', - 'postcode' => '94538', - 'dhl_id' => 'MAGEN_8501', - 'dhl_password' => 'QR2GO1U74X', - 'dhl_account' => '799909537', - 'dhl_shipping_intl_key' => '54233F2B2C4E5C4B4C5E5A59565530554B405641475D5659', - 'girth' => null, - 'height' => null, - 'length' => null, - 'width' => null, - 'weight' => 1, - 'dhl_shipment_type' => 'P', - 'dhl_duitable' => 0, - 'dhl_duty_payment_type' => 'R', - 'dhl_content_desc' => 'Big Box', - 'limit_method' => 'IE', - 'ship_date' => '2014-01-09', - 'action' => 'RateEstimate', - 'all_items' => array() - ) -); \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/DhlTest.php b/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/DhlTest.php deleted file mode 100644 index cbde90204ad..00000000000 --- a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/DhlTest.php +++ /dev/null @@ -1,179 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Usa - * @subpackage unit_tests - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Usa\Model\Shipping\Carrier; - - -class DhlTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $_helper; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_httpResponse; - - /** - * @var \Magento\Usa\Model\Shipping\Carrier\Dhl - */ - protected $_model; - - public function setUp() - { - $this->_helper = new \Magento\TestFramework\Helper\ObjectManager($this); - - $coreStoreConfig = $this->getMockBuilder('\Magento\Core\Model\Store\Config') - ->setMethods(array('getConfigFlag', 'getConfig')) - ->disableOriginalConstructor() - ->getMock(); - $coreStoreConfig->expects($this->any()) - ->method('getConfigFlag') - ->will($this->returnValue(true)); - $coreStoreConfig->expects($this->any()) - ->method('getConfig') - ->will($this->returnCallback(array($this, 'coreStoreConfigGetConfig'))); - - // xml element factory - $xmlElFactory = $this->getMockBuilder('\Magento\Usa\Model\Simplexml\ElementFactory') - ->disableOriginalConstructor() - ->setMethods(array('create')) - ->getMock(); - $xmlElFactory->expects($this->any()) - ->method('create') - ->will( - $this->returnCallback( - function ($data) { - $oM = new \Magento\TestFramework\Helper\ObjectManager($this); - return $oM->getObject('\Magento\Usa\Model\Simplexml\Element', array('data' => $data['data'])); - } - ) - ); - - // rate factory - $rateFactory = $this->getMockBuilder('\Magento\Shipping\Model\Rate\ResultFactory') - ->disableOriginalConstructor() - ->setMethods(array('create')) - ->getMock(); - $rateResult = $this->getMockBuilder('\Magento\Shipping\Model\Rate\Result') - ->disableOriginalConstructor() - ->setMethods(null) - ->getMock(); - $rateFactory->expects($this->any()) - ->method('create') - ->will($this->returnValue($rateResult)); - - // rate method factory - $rateMethodFactory = $this->getMockBuilder('\Magento\Sales\Model\Quote\Address\RateResult\MethodFactory') - ->disableOriginalConstructor() - ->setMethods(array('create')) - ->getMock(); - $rateMethod = $this->getMockBuilder('Magento\Sales\Model\Quote\Address\RateResult\Method') - ->disableOriginalConstructor() - ->setMethods(array('setPrice')) - ->getMock(); - $rateMethod->expects($this->any()) - ->method('setPrice') - ->will($this->returnSelf()); - - $rateMethodFactory->expects($this->any()) - ->method('create') - ->will($this->returnValue($rateMethod)); - - // http client - $this->_httpResponse = $this->getMockBuilder('\Zend_Http_Response') - ->disableOriginalConstructor() - ->setMethods(array('getBody')) - ->getMock(); - - $httpClient = $this->getMockBuilder('\Zend_Http_Client') - ->disableOriginalConstructor() - ->setMethods(array('request')) - ->getMock(); - $httpClient->expects($this->any()) - ->method('request') - ->will($this->returnValue($this->_httpResponse)); - - $httpClientFactory = $this->getMockBuilder('\Zend_Http_ClientFactory') - ->disableOriginalConstructor() - ->setMethods(array('create')) - ->getMock(); - $httpClientFactory->expects($this->any()) - ->method('create') - ->will($this->returnValue($httpClient)); - - $data = array( - 'id' => 'dhl', - 'store' => '1' - ); - - $arguments = array( - 'coreStoreConfig' => $coreStoreConfig, - 'xmlElFactory' => $xmlElFactory, - 'rateFactory' => $rateFactory, - 'rateMethodFactory' => $rateMethodFactory, - 'httpClientFactory' => $httpClientFactory, - 'data' => $data - ); - - $this->_model = $this->_helper->getObject('Magento\Usa\Model\Shipping\Carrier\Dhl', $arguments); - } - - /** - * Callback function, emulates getConfig function - * @param $path - * @return null|string - */ - public function coreStoreConfigGetConfig($path) - { - switch ($path) { - case 'carriers/dhl/shipment_days': - case 'carriers/dhl/intl_shipment_days': - return 'Mon,Tue,Wed,Thu,Fri,Sat'; - case 'carriers/dhl/allowed_methods': - return 'IE'; - case 'carriers/dhl/international_searvice': - return 'IE'; - default: - return null; - } - } - - public function testCollectRates() - { - $this->_httpResponse->expects($this->any()) - ->method('getBody') - ->will($this->returnValue(file_get_contents(__DIR__ . '/_files/success_dhl_response_rates.xml'))); - // for setRequest - $request_params = include __DIR__ . '/_files/rates_request_data_dhl.php'; - $request = $this->_helper->getObject('Magento\Sales\Model\Quote\Address\RateRequest', $request_params); - - $this->assertNotEmpty($this->_model->collectRates($request)->getAllRates()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/success_dhl_response_rates.xml b/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/success_dhl_response_rates.xml deleted file mode 100644 index 4cdd62bcfe1..00000000000 --- a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/success_dhl_response_rates.xml +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ ---> - -<eCommerce action="Response" version="1.1" timestamp="2014/01/06T06:39:49" transmission_reference="A357C91E"> - <Requestor> - <ID>MAGEN_8501</ID> - <Password><![CDATA[********]]></Password> - </Requestor> - <IntlShipment action="RateEstimate" version="1.0" test="True"> - <Result> - <Code>203</Code> - <Desc>Shipment estimate successful.</Desc> - </Result> - <ShippingCredentials> - <ShippingKey>54233F2B2C4E5C4B4C5E5A59565530554B405641475D5659</ShippingKey> - <AccountNbr>799909537</AccountNbr> - </ShippingCredentials> - <EstimateDetail> - <DateGenerated>2014-01-06</DateGenerated> - <ShipDate>2014-01-06</ShipDate> - <Service> - <Code>IE</Code> - </Service> - <ServiceLevelCommitment> - <Desc>Estimated Delivery By January 8, 2014 by End of Day</Desc> - </ServiceLevelCommitment> - <RateEstimate> - <TotalChargeEstimate>22.02</TotalChargeEstimate> - <Charges> - <Charge> - <Type> - <Code>F</Code> - <Desc>Freight Charges</Desc> - </Type> - <Value>20.20</Value> - </Charge> - <Charge> - <Type> - <Code>O</Code> - <Desc>Other Charges</Desc> - </Type> - <Value>1.82</Value> - </Charge> - </Charges> - </RateEstimate> - </EstimateDetail> - </IntlShipment> -</eCommerce> \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Usa/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Usps/Helper/DataTest.php old mode 100755 new mode 100644 similarity index 89% rename from dev/tests/unit/testsuite/Magento/Usa/Helper/DataTest.php rename to dev/tests/unit/testsuite/Magento/Usps/Helper/DataTest.php index 4749cd66033..f1930302d30 --- a/dev/tests/unit/testsuite/Magento/Usa/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Usps/Helper/DataTest.php @@ -21,32 +21,29 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Helper; +namespace Magento\Usps\Helper; class DataTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Usa\Helper\Data + * @var \Magento\Usps\Helper\Data */ protected $_helperData; - /** - * - */ protected function setUp() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $arguments = array( 'context' => $this->getMock('Magento\App\Helper\Context', array(), array(), '', false), - 'locale' => $this->getMock('Magento\Core\Model\Locale', array(), array(), '', false) + 'locale' => $this->getMock('Magento\Locale', array(), array(), '', false) ); - $this->_helperData = $helper->getObject('Magento\Usa\Helper\Data', $arguments); + $this->_helperData = $helper->getObject('Magento\Usps\Helper\Data', $arguments); } /** - * @covers \Magento\Usa\Helper\Data::displayGirthValue + * @covers \Magento\Usps\Helper\Data::displayGirthValue * @dataProvider shippingMethodDataProvider */ public function testDisplayGirthValue($shippingMethod) @@ -55,7 +52,7 @@ class DataTest extends \PHPUnit_Framework_TestCase } /** - * @covers \Magento\Usa\Helper\Data::displayGirthValue + * @covers \Magento\Usps\Helper\Data::displayGirthValue */ public function testDisplayGirthValueFalse() { diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/UspsTest.php b/dev/tests/unit/testsuite/Magento/Usps/Model/CarrierTest.php similarity index 91% rename from dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/UspsTest.php rename to dev/tests/unit/testsuite/Magento/Usps/Model/CarrierTest.php index 82a5678a8d8..c93fbb8a3f7 100755 --- a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/UspsTest.php +++ b/dev/tests/unit/testsuite/Magento/Usps/Model/CarrierTest.php @@ -22,13 +22,13 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier; +namespace Magento\Usps\Model; -class UspsTest extends \PHPUnit_Framework_TestCase +class CarrierTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Usa\Model\Shipping\Carrier\Usps + * @var \Magento\Usps\Model\Carrier */ protected $_model; @@ -42,6 +42,9 @@ class UspsTest extends \PHPUnit_Framework_TestCase */ protected $_helper; + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ public function setUp() { $this->_helper = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -58,7 +61,7 @@ class UspsTest extends \PHPUnit_Framework_TestCase ->will($this->returnCallback(array($this, 'coreStoreConfigGetConfig'))); // xml element factory - $xmlElFactory = $this->getMockBuilder('\Magento\Usa\Model\Simplexml\ElementFactory') + $xmlElFactory = $this->getMockBuilder('\Magento\Shipping\Model\Simplexml\ElementFactory') ->disableOriginalConstructor() ->setMethods(array('create')) ->getMock(); @@ -67,8 +70,11 @@ class UspsTest extends \PHPUnit_Framework_TestCase ->will( $this->returnCallback( function ($data) { - $oM = new \Magento\TestFramework\Helper\ObjectManager($this); - return $oM->getObject('\Magento\Usa\Model\Simplexml\Element', array('data' => $data['data'])); + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); + return $helper->getObject( + '\Magento\Shipping\Model\Simplexml\Element', + array('data' => $data['data']) + ); } ) ); @@ -139,7 +145,7 @@ class UspsTest extends \PHPUnit_Framework_TestCase 'data' => $data ); - $this->_model = $this->_helper->getObject('\Magento\Usa\Model\Shipping\Carrier\Usps', $arguments); + $this->_model = $this->_helper->getObject('Magento\Usps\Model\Carrier', $arguments); } /** diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Usps/Source/GenericTest.php b/dev/tests/unit/testsuite/Magento/Usps/Model/Source/GenericTest.php old mode 100755 new mode 100644 similarity index 76% rename from dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Usps/Source/GenericTest.php rename to dev/tests/unit/testsuite/Magento/Usps/Model/Source/GenericTest.php index 2a37de7d773..6f14a7a32e3 --- a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/Usps/Source/GenericTest.php +++ b/dev/tests/unit/testsuite/Magento/Usps/Model/Source/GenericTest.php @@ -22,38 +22,38 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Usa\Model\Shipping\Carrier\Usps\Source; +namespace Magento\Usps\Model\Source; class GenericTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Usa\Model\Shipping\Carrier\Usps\Source\Generic + * @var \Magento\Usps\Model\Source\Generic */ protected $_generic; /** - * @var \Magento\Usa\Model\Shipping\Carrier\Usps + * @var \Magento\Usps\Model\Carrier */ protected $_uspsModel; public function setUp() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_uspsModel = $this->getMockBuilder('Magento\Usa\Model\Shipping\Carrier\Usps') + $this->_uspsModel = $this->getMockBuilder('Magento\Usps\Model\Carrier') ->setMethods(array('getCode')) ->disableOriginalConstructor() ->getMock(); $this->_generic = $helper->getObject( - 'Magento\Usa\Model\Shipping\Carrier\Usps\Source\Generic', + '\Magento\Usps\Model\Source\Generic', array('shippingUsps' => $this->_uspsModel) ); } /** * @dataProvider getCodeDataProvider - * @param $expected array - * @param $options Magento\Usa\Model\Shipping\Carrier\Usps::getCode result + * @param array$expected array + * @param array $options */ public function testToOptionArray($expected, $options) { @@ -65,13 +65,13 @@ class GenericTest extends \PHPUnit_Framework_TestCase } /** - * @return array expected result and return of Magento\Usa\Model\Shipping\Carrier\Usps::getCode + * @return array expected result and return of \Magento\Usps\Model\Carrier::getCode */ public function getCodeDataProvider() { return array( array(array(array('value' => 'Val', 'label' => 'Label')), array('Val' => 'Label')), - array(array(), false) + array(array(), false), ); } } diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/rates_request_data.php b/dev/tests/unit/testsuite/Magento/Usps/Model/_files/rates_request_data.php similarity index 99% rename from dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/rates_request_data.php rename to dev/tests/unit/testsuite/Magento/Usps/Model/_files/rates_request_data.php index 0d040ddd237..6cffa7134cb 100644 --- a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/rates_request_data.php +++ b/dev/tests/unit/testsuite/Magento/Usps/Model/_files/rates_request_data.php @@ -53,4 +53,4 @@ return array( 'length' => null, 'width' => null, ) -); \ No newline at end of file +); diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/return_shipment_request_data.php b/dev/tests/unit/testsuite/Magento/Usps/Model/_files/return_shipment_request_data.php similarity index 100% rename from dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/return_shipment_request_data.php rename to dev/tests/unit/testsuite/Magento/Usps/Model/_files/return_shipment_request_data.php diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/success_usps_response_rates.xml b/dev/tests/unit/testsuite/Magento/Usps/Model/_files/success_usps_response_rates.xml similarity index 99% rename from dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/success_usps_response_rates.xml rename to dev/tests/unit/testsuite/Magento/Usps/Model/_files/success_usps_response_rates.xml index 8f55064cc35..2a1015ccc8c 100644 --- a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/success_usps_response_rates.xml +++ b/dev/tests/unit/testsuite/Magento/Usps/Model/_files/success_usps_response_rates.xml @@ -168,4 +168,4 @@ <Rate>4.12</Rate> </Postage> </Package> -</RateV4Response> \ No newline at end of file +</RateV4Response> diff --git a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/success_usps_response_return_shipment.xml b/dev/tests/unit/testsuite/Magento/Usps/Model/_files/success_usps_response_return_shipment.xml similarity index 97% rename from dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/success_usps_response_return_shipment.xml rename to dev/tests/unit/testsuite/Magento/Usps/Model/_files/success_usps_response_return_shipment.xml index d36fe692003..7016871422e 100644 --- a/dev/tests/unit/testsuite/Magento/Usa/Model/Shipping/Carrier/_files/success_usps_response_return_shipment.xml +++ b/dev/tests/unit/testsuite/Magento/Usps/Model/_files/success_usps_response_return_shipment.xml @@ -35,4 +35,4 @@ <ToZip5>94538</ToZip5> <ToZip4>3294</ToZip4> <Postnet>94538329414</Postnet> -</SigConfirmCertifyV3.0Response> \ No newline at end of file +</SigConfirmCertifyV3.0Response> diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php index a158c286ae4..383f80cfbe3 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php @@ -54,6 +54,11 @@ class SoapTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Oauth\Oauth */ protected $_oauthServiceMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Locale\ResolverInterface + */ + protected $_localeMock; + /** * Set up Controller object. */ @@ -84,18 +89,27 @@ class SoapTest extends \PHPUnit_Framework_TestCase $this->_appStateMock = $this->getMockBuilder('Magento\App\State') ->disableOriginalConstructor() ->getMock(); - $localeMock = $this->getMockBuilder('Magento\Core\Model\Locale') + $localeMock = $this->getMockBuilder('Magento\Locale') ->disableOriginalConstructor() - ->setMethods(array('getLocale', 'getLanguage')) + ->setMethods(array('getLanguage')) ->getMock(); - $localeMock->expects($this->any())->method('getLocale')->will($this->returnValue($localeMock)); $localeMock->expects($this->any())->method('getLanguage')->will($this->returnValue('en')); + $localeResolverMock = $this->getMockBuilder('Magento\Locale\Resolver') + ->disableOriginalConstructor() + ->setMethods(array('getLocale')) + ->getMock(); + $localeResolverMock->expects($this->any())->method('getLocale')->will($this->returnValue($localeMock)); + $this->_applicationMock = $this->getMockBuilder('Magento\Core\Model\App') ->disableOriginalConstructor() ->setMethods(array('getLocale', 'isDeveloperMode')) ->getMock(); - $this->_applicationMock->expects($this->any())->method('getLocale')->will($this->returnValue($localeMock)); + + $this->_applicationMock = $this->getMockBuilder('Magento\Core\Model\App') + ->disableOriginalConstructor() + ->setMethods(array('isDeveloperMode')) + ->getMock(); $this->_applicationMock->expects($this->any())->method('isDeveloperMode')->will($this->returnValue(false)); $this->_oauthServiceMock = $this->getMockBuilder('Magento\Oauth\Oauth') @@ -115,7 +129,8 @@ class SoapTest extends \PHPUnit_Framework_TestCase $this->_errorProcessorMock, $this->_appStateMock, $this->_applicationMock, - $this->_oauthServiceMock + $this->_oauthServiceMock, + $localeResolverMock ); } diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/IntegrationServiceV1Test.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/IntegrationServiceV1Test.php index 19ac9226953..0e485d837f8 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/IntegrationServiceV1Test.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/IntegrationServiceV1Test.php @@ -34,33 +34,39 @@ class IntegrationServiceV1Test extends \PHPUnit_Framework_TestCase * * @var \Magento\Authz\Service\AuthorizationV1 */ - protected $_authzServiceMock; + protected $authzServiceMock; /** * Mock for UserIdentifier Factory * * @var \Magento\Authz\Model\UserIdentifier\Factory */ - protected $_userIdentifierFactoryMock; + protected $userIdentifierFactoryMock; /** * API setup plugin * * @var \Magento\Webapi\Model\Plugin\IntegrationServiceV1 */ - protected $_integrationV1Plugin; + protected $integrationV1Plugin; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; public function setUp() { - $this->_authzServiceMock = $this->getMockBuilder('\Magento\Authz\Service\AuthorizationV1') + $this->authzServiceMock = $this->getMockBuilder('\Magento\Authz\Service\AuthorizationV1') ->disableOriginalConstructor() ->setMethods(['removePermissions'])->getMock(); - $this->_userIdentifierFactoryMock = $this->getMockBuilder('\Magento\Authz\Model\UserIdentifier\Factory') + $this->userIdentifierFactoryMock = $this->getMockBuilder('\Magento\Authz\Model\UserIdentifier\Factory') ->disableOriginalConstructor() ->setMethods(['create'])->getMock(); - $this->_integrationV1Plugin = new \Magento\Webapi\Model\Plugin\IntegrationServiceV1( - $this->_authzServiceMock, - $this->_userIdentifierFactoryMock + $this->subjectMock = $this->getMock('Magento\Integration\Service\IntegrationV1', array(), array(), '', false); + $this->integrationV1Plugin = new \Magento\Webapi\Model\Plugin\IntegrationServiceV1( + $this->authzServiceMock, + $this->userIdentifierFactoryMock ); } @@ -76,15 +82,15 @@ class IntegrationServiceV1Test extends \PHPUnit_Framework_TestCase $userIdentifierMock = $this->getMockBuilder('\Magento\Authz\Model\UserIdentifier') ->disableOriginalConstructor() ->getMock(); - $this->_authzServiceMock->expects($this->once()) + $this->authzServiceMock->expects($this->once()) ->method('removePermissions')->with($userIdentifierMock); - $this->_userIdentifierFactoryMock->expects($this->at(0)) + $this->userIdentifierFactoryMock->expects($this->at(0)) ->method('create') ->with(UserIdentifier::USER_TYPE_INTEGRATION, 1) ->will($this->returnValue($userIdentifierMock)); - $this->_authzServiceMock->expects($this->once()) + $this->authzServiceMock->expects($this->once()) ->method('removePermissions') ->with($userIdentifierMock); - $this->_integrationV1Plugin->afterDelete($integrationsData); + $this->integrationV1Plugin->afterDelete($this->subjectMock, $integrationsData); } } \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/SetupTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/SetupTest.php index f4ea21f41c6..024d593771a 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/SetupTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Plugin/SetupTest.php @@ -33,73 +33,79 @@ class SetupTest extends \PHPUnit_Framework_TestCase * * @var \Magento\Webapi\Model\IntegrationConfig */ - protected $_integrationConfigMock; + protected $integrationConfigMock; /** * Integration service mock * * @var \Magento\Integration\Service\IntegrationV1Interface */ - protected $_integrationServiceMock; + protected $integrationServiceMock; /** * Authorization service mock * * @var \Magento\Authz\Service\AuthorizationV1 */ - protected $_authzServiceMock; + protected $authzServiceMock; /** * Mock for UserIdentifier Factory * * @var \Magento\Authz\Model\UserIdentifier\Factory */ - protected $_userIdentifierFactoryMock; + protected $userIdentifierFactoryMock; /** * API setup plugin * * @var \Magento\Webapi\Model\Plugin\Setup */ - protected $_apiSetupPlugin; + protected $apiSetupPlugin; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $subjectMock; public function setUp() { - $this->_integrationConfigMock = $this->getMockBuilder('\Magento\Webapi\Model\IntegrationConfig') + $this->integrationConfigMock = $this->getMockBuilder('\Magento\Webapi\Model\IntegrationConfig') ->disableOriginalConstructor() ->setMethods(['getIntegrations'])->getMock(); - $this->_integrationServiceMock = $this->getMockBuilder('\Magento\Integration\Service\IntegrationV1') + $this->integrationServiceMock = $this->getMockBuilder('\Magento\Integration\Service\IntegrationV1') ->disableOriginalConstructor() ->setMethods(['findByName'])->getMock(); - $this->_authzServiceMock = $this->getMockBuilder('\Magento\Authz\Service\AuthorizationV1') + $this->authzServiceMock = $this->getMockBuilder('\Magento\Authz\Service\AuthorizationV1') ->disableOriginalConstructor() ->setMethods(['grantPermissions'])->getMock(); - $this->_userIdentifierFactoryMock = $this->getMockBuilder('\Magento\Authz\Model\UserIdentifier\Factory') + $this->userIdentifierFactoryMock = $this->getMockBuilder('\Magento\Authz\Model\UserIdentifier\Factory') ->disableOriginalConstructor() ->setMethods(['create'])->getMock(); - $this->_apiSetupPlugin = new \Magento\Webapi\Model\Plugin\Setup( - $this->_integrationConfigMock, - $this->_authzServiceMock, - $this->_integrationServiceMock, - $this->_userIdentifierFactoryMock + $this->subjectMock = $this->getMock('Magento\Integration\Model\Resource\Setup', array(), array(), '', false); + $this->apiSetupPlugin = new \Magento\Webapi\Model\Plugin\Setup( + $this->integrationConfigMock, + $this->authzServiceMock, + $this->integrationServiceMock, + $this->userIdentifierFactoryMock ); } public function testAfterInitIntegrationProcessingNoIntegrations() { - $this->_integrationConfigMock->expects($this->never()) + $this->integrationConfigMock->expects($this->never()) ->method('getIntegrations'); - $this->_integrationServiceMock->expects($this->never()) + $this->integrationServiceMock->expects($this->never()) ->method('findByName'); - $this->_authzServiceMock->expects($this->never()) + $this->authzServiceMock->expects($this->never()) ->method('grantPermissions'); - $this->_userIdentifierFactoryMock->expects($this->never()) + $this->userIdentifierFactoryMock->expects($this->never()) ->method('create'); - $this->_apiSetupPlugin->afterInitIntegrationProcessing(array()); + $this->apiSetupPlugin->afterInitIntegrationProcessing($this->subjectMock, array()); } public function testAfterInitIntegrationProcessingSuccess() @@ -113,7 +119,7 @@ class SetupTest extends \PHPUnit_Framework_TestCase $testIntegration2Resource = array( 'Magento_Catalog::product_read' ); - $this->_integrationConfigMock->expects($this->once()) + $this->integrationConfigMock->expects($this->once()) ->method('getIntegrations') ->will( $this->returnValue( @@ -143,12 +149,12 @@ class SetupTest extends \PHPUnit_Framework_TestCase Integration::SETUP_TYPE => 1, )); - $this->_integrationServiceMock->expects($this->at(0)) + $this->integrationServiceMock->expects($this->at(0)) ->method('findByName') ->with('TestIntegration1') ->will($this->returnValue($integrationsData1)); - $this->_integrationServiceMock->expects($this->at(1)) + $this->integrationServiceMock->expects($this->at(1)) ->method('findByName') ->with('TestIntegration2') ->will($this->returnValue($integrationsData2)); @@ -156,7 +162,7 @@ class SetupTest extends \PHPUnit_Framework_TestCase $userIdentifierMock1 = $this->getMockBuilder('\Magento\Authz\Model\UserIdentifier') ->disableOriginalConstructor() ->getMock(); - $this->_userIdentifierFactoryMock->expects($this->at(0)) + $this->userIdentifierFactoryMock->expects($this->at(0)) ->method('create') ->with(UserIdentifier::USER_TYPE_INTEGRATION, 1) ->will($this->returnValue($userIdentifierMock1)); @@ -164,19 +170,20 @@ class SetupTest extends \PHPUnit_Framework_TestCase $userIdentifierMock2 = $this->getMockBuilder('\Magento\Authz\Model\UserIdentifier') ->disableOriginalConstructor() ->getMock(); - $this->_userIdentifierFactoryMock->expects($this->at(1)) + $this->userIdentifierFactoryMock->expects($this->at(1)) ->method('create') ->with(UserIdentifier::USER_TYPE_INTEGRATION, 2) ->will($this->returnValue($userIdentifierMock2)); - $this->_authzServiceMock->expects($this->at(0)) + $this->authzServiceMock->expects($this->at(0)) ->method('grantPermissions') ->with($userIdentifierMock1, $testIntegration1Resource); - $this->_authzServiceMock->expects($this->at(1)) + $this->authzServiceMock->expects($this->at(1)) ->method('grantPermissions') ->with($userIdentifierMock2, $testIntegration2Resource); - $this->_apiSetupPlugin->afterInitIntegrationProcessing(array('TestIntegration1', 'TestIntegration2')); + $this->apiSetupPlugin->afterInitIntegrationProcessing($this->subjectMock, + array('TestIntegration1', 'TestIntegration2')); } } diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/FaultTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/FaultTest.php index 05ec5655e40..3450298c7ed 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/FaultTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/FaultTest.php @@ -24,8 +24,6 @@ namespace Magento\Webapi\Model\Soap; -use Magento\Webapi\Model\Soap\Fault; - /** * Test SOAP fault model. */ @@ -42,14 +40,12 @@ class FaultTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Webapi\Model\Soap\Fault */ protected $_soapFault; + /** @var \PHPUnit_Framework_MockObject_MockObject*/ + protected $_localeResolverMock; + protected function setUp() { $this->_appMock = $this->getMockBuilder('Magento\Core\Model\App')->disableOriginalConstructor()->getMock(); - $localeMock = $this->getMockBuilder('Magento\Core\Model\LocaleInterface') - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $localeMock->expects($this->any())->method('getLocale')->will($this->returnValue(new \Zend_Locale('en_US'))); - $this->_appMock->expects($this->any())->method('getLocale')->will($this->returnValue($localeMock)); /** Initialize SUT. */ $message = "Soap fault reason."; $details = array('param1' => 'value1', 'param2' => 2); @@ -64,10 +60,16 @@ class FaultTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->_soapServerMock->expects($this->any())->method('generateUri')->will($this->returnValue(self::WSDL_URL)); + $this->_localeResolverMock = $this->getMockBuilder('Magento\Locale\Resolver')->disableOriginalConstructor() + ->getMock(); + $this->_localeResolverMock->expects( + $this->any())->method('getLocale')->will($this->returnValue(new \Zend_Locale('en_US'))); + $this->_soapFault = new \Magento\Webapi\Model\Soap\Fault( $this->_appMock, $this->_soapServerMock, - $webapiException + $webapiException, + $this->_localeResolverMock ); parent::setUp(); } @@ -222,7 +224,8 @@ XML; $soapFault = new \Magento\Webapi\Model\Soap\Fault( $this->_appMock, $this->_soapServerMock, - $webapiException + $webapiException, + $this->_localeResolverMock ); $actualXml = $soapFault->toXml(); $wsdlUrl = urlencode(self::WSDL_URL); diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Block/Customer/SidebarTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Block/Customer/SidebarTest.php new file mode 100644 index 00000000000..ac91ed75ccd --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Block/Customer/SidebarTest.php @@ -0,0 +1,74 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Wishlist\Block\Customer; + +class SidebarTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Wishlist\Block\Customer\Sidebar + */ + protected $block; + + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->block = $objectManager->getObject('Magento\Wishlist\Block\Customer\Sidebar'); + } + + protected function tearDown() + { + $this->block = null; + } + + public function testGetIdentities() + { + $productTags = array('catalog_product_1'); + + $product = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $product->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue($productTags)); + + $item = $this->getMock( + 'Magento\Sales\Model\Resource\Order\Item', + array('getProduct', '__wakeup'), + array(), + '', + false + ); + $item->expects($this->once()) + ->method('getProduct') + ->will($this->returnValue($product)); + + $collection = new \ReflectionProperty('Magento\Wishlist\Block\Customer\Sidebar', '_collection'); + $collection->setAccessible(true); + $collection->setValue($this->block, array($item)); + + $this->assertEquals( + $productTags, + $this->block->getIdentities() + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Controller/IndexTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Controller/IndexTest.php index 1436b776955..01513a89def 100644 --- a/dev/tests/unit/testsuite/Magento/Wishlist/Controller/IndexTest.php +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Controller/IndexTest.php @@ -54,7 +54,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase $objectManager = $this->getMock('Magento\ObjectManager'); - $locale = $this->getMock('Magento\Core\Model\Locale', [], [], '', false); + $locale = $this->getMock('Magento\Locale\Resolver', [], [], '', false); $optionCollection = $this->getMock( 'Magento\Wishlist\Model\Resource\Item\Option\Collection', @@ -84,7 +84,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase ); $mapGet = [ - ['Magento\Core\Model\LocaleInterface', $locale], + ['Magento\Locale\ResolverInterface', $locale], ['Magento\Checkout\Model\Cart', $cart], ['Magento\Catalog\Helper\Product', $product], ['Magento\Escaper', $escaper], diff --git a/dev/tools/Magento/Tools/Dependency/Circular.php b/dev/tools/Magento/Tools/Dependency/Circular.php index afeedd5ddae..de6ff0adf37 100644 --- a/dev/tools/Magento/Tools/Dependency/Circular.php +++ b/dev/tools/Magento/Tools/Dependency/Circular.php @@ -101,6 +101,10 @@ class Circular $path[] = $vertex; foreach ($this->dependencies[$vertex] as $dependency) { + if (!isset($this->dependencies[$dependency])) { + // dependency vertex is not described in basic definition + continue; + } $relations = $this->graph->getRelations(); if (isset($relations[$vertex][$dependency])) { continue; diff --git a/dev/tools/Magento/Tools/Di/Compiler/Directory.php b/dev/tools/Magento/Tools/Di/Compiler/Directory.php index 7d28e5bfe4d..b6f3856af4d 100644 --- a/dev/tools/Magento/Tools/Di/Compiler/Directory.php +++ b/dev/tools/Magento/Tools/Di/Compiler/Directory.php @@ -80,9 +80,12 @@ class Directory } /** + * Compile class definitions + * * @param string $path + * @param bool $validate */ - public function compile($path) + public function compile($path, $validate = true) { $rdi = new \RecursiveDirectoryIterator(realpath($path)); $recursiveIterator = new \RecursiveIteratorIterator($rdi, 1); @@ -97,7 +100,9 @@ class Directory require_once $item->getRealPath(); } try { - $this->_validator->validate($className); + if ($validate) { + $this->_validator->validate($className); + } $signatureReader = new \Magento\Code\Reader\ClassReader(); $this->_definitions[$className] = $signatureReader->getConstructor($className); $this->_relations[$className] = $signatureReader->getParents($className); diff --git a/dev/tools/Magento/Tools/Di/compiler.php b/dev/tools/Magento/Tools/Di/compiler.php index 3cd01512f1a..97eff30f60b 100644 --- a/dev/tools/Magento/Tools/Di/compiler.php +++ b/dev/tools/Magento/Tools/Di/compiler.php @@ -58,7 +58,6 @@ try { $compilationDirs = array( $rootDir . '/app/code', $rootDir . '/lib/Magento', - $generationDir, ); /** @var Writer\WriterInterface $logWriter Writer model for success messages */ @@ -96,7 +95,14 @@ try { null, $generationDir ); - $generator = new \Magento\Code\Generator(null, null, $generatorIo); + $generator = new \Magento\Code\Generator(null, $generatorIo, array( + \Magento\Interception\Code\Generator\Interceptor::ENTITY_TYPE + => 'Magento\Interception\Code\Generator\Interceptor', + \Magento\ObjectManager\Code\Generator\Proxy::ENTITY_TYPE + => 'Magento\ObjectManager\Code\Generator\Proxy', + \Magento\ObjectManager\Code\Generator\Factory::ENTITY_TYPE + => 'Magento\ObjectManager\Code\Generator\Factory', + )); foreach (array('php', 'additional') as $type) { sort($entities[$type]); foreach ($entities[$type] as $entityName) { @@ -149,9 +155,8 @@ try { } } - //2.1.2 Compile definitions for Proxy/Interceptor classes - $directoryCompiler->compile($generationDir); + $directoryCompiler->compile($generationDir, false); list($definitions, $relations) = $directoryCompiler->getResult(); @@ -171,9 +176,10 @@ try { $pluginScanner->addChild(new Scanner\PluginScanner(), 'di'); $pluginDefinitions = array(); $pluginList = $pluginScanner->collectEntities($files); + $pluginDefinitionList = new \Magento\Interception\Definition\Runtime(); foreach ($pluginList as $type => $entityList) { foreach ($entityList as $entity) { - $pluginDefinitions[$entity] = get_class_methods($entity); + $pluginDefinitions[$entity] = $pluginDefinitionList->getMethodList($entity); } } diff --git a/dev/tools/Magento/Tools/Migration/factory_table_names.php b/dev/tools/Magento/Tools/Migration/factory_table_names.php index 569f70d2bca..f19f4b13edb 100644 --- a/dev/tools/Magento/Tools/Migration/factory_table_names.php +++ b/dev/tools/Magento/Tools/Migration/factory_table_names.php @@ -38,7 +38,7 @@ $shortOpts = 'ehds'; $options = getopt($shortOpts); if (isset($options['h'])) { - print USAGE; + echo USAGE; exit(0); } diff --git a/dev/tools/Magento/Tools/Migration/get_aliases_map.php b/dev/tools/Magento/Tools/Migration/get_aliases_map.php index 52de2d9eb29..8973fc6dd89 100644 --- a/dev/tools/Magento/Tools/Migration/get_aliases_map.php +++ b/dev/tools/Magento/Tools/Migration/get_aliases_map.php @@ -39,7 +39,7 @@ USAGE $options = getopt('p:h'); if (isset($options['h'])) { - print USAGE; + echo USAGE; exit(0); } diff --git a/dev/tools/Magento/Tools/Migration/themes_view.php b/dev/tools/Magento/Tools/Migration/themes_view.php index 3ea1882ab26..6eae526733b 100644 --- a/dev/tools/Magento/Tools/Migration/themes_view.php +++ b/dev/tools/Magento/Tools/Migration/themes_view.php @@ -60,9 +60,9 @@ function updateFieldForTable($objectManager, $table, $col) $installer->startSetup(); $table = $installer->getTable($table); - print '-----' . "\n"; + echo '-----' . "\n"; if ($installer->getConnection()->isTableExists($table)) { - print 'Table `' . $table . "` processed\n"; + echo 'Table `' . $table . "` processed\n"; $indexList = $installer->getConnection()->getIndexList($table); $pkField = array_shift($indexList[$installer->getConnection()->getPrimaryKeyName($table)]['fields']); @@ -70,7 +70,7 @@ function updateFieldForTable($objectManager, $table, $col) $select = $installer->getConnection()->select()->from($table, array('id' => $pkField, 'content' => $col)); $result = $installer->getConnection()->fetchPairs($select); - print 'Records count: ' . count($result) . ' in table: `' . $table . "`\n"; + echo 'Records count: ' . count($result) . ' in table: `' . $table . "`\n"; $logMessages = array(); foreach ($result as $recordId => $string) { @@ -87,10 +87,10 @@ function updateFieldForTable($objectManager, $table, $col) printLog($logMessages); } } else { - print 'Table `' . $table . "` was not found\n"; + echo 'Table `' . $table . "` was not found\n"; } $installer->endSetup(); - print '-----' . "\n"; + echo '-----' . "\n"; } /** @@ -101,8 +101,8 @@ function updateFieldForTable($objectManager, $table, $col) function printLog($logMessages) { foreach ($logMessages as $stringsArray) { - print "\n"; - print implode("\n", $stringsArray); - print "\n"; + echo "\n"; + echo implode("\n", $stringsArray); + echo "\n"; } } diff --git a/downloader/lib/Magento/Connect/Frontend/CLI.php b/downloader/lib/Magento/Connect/Frontend/CLI.php index 3639c4d5d32..07fd551ab58 100644 --- a/downloader/lib/Magento/Connect/Frontend/CLI.php +++ b/downloader/lib/Magento/Connect/Frontend/CLI.php @@ -411,7 +411,7 @@ extends \Magento\Connect\Frontend if($this->isSilent()) { return; } - print $data; + echo $data; } /** diff --git a/index.php b/index.php index 8f165f8101c..48d1224c2d6 100644 --- a/index.php +++ b/index.php @@ -33,6 +33,5 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ require __DIR__ . '/app/bootstrap.php'; - $entryPoint = new \Magento\App\EntryPoint\EntryPoint(BP, $_SERVER); $entryPoint->run('Magento\App\Http'); diff --git a/lib/Cm/Cache/Backend/File.php b/lib/Cm/Cache/Backend/File.php new file mode 100644 index 00000000000..9078692c48a --- /dev/null +++ b/lib/Cm/Cache/Backend/File.php @@ -0,0 +1,719 @@ +<?php +/* +==New BSD License== + +Copyright (c) 2012, Colin Mollenhour +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. + * The name of Colin Mollenhour may not be used to endorse or promote products + derived from this software without specific prior written permission. + * The class name must remain as Cm_Cache_Backend_File. + +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 HOLDER 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. + */ + +/** + * Cm_Cache_Backend_File + * + * @copyright Copyright (c) 2013 Colin Mollenhour (http://colin.mollenhour.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Cm_Cache_Backend_File extends Zend_Cache_Backend_File +{ + + /** @var array */ + protected $_options = array( + 'cache_dir' => null, // Path to cache files + 'file_name_prefix' => 'cm', // Prefix for cache directories created + 'file_locking' => true, // Best to keep enabled + 'read_control' => false, // Use a checksum to detect corrupt data + 'read_control_type' => 'crc32', // If read_control is enabled, which checksum algorithm to use + 'hashed_directory_level' => 2, // How many characters should be used to create sub-directories + 'use_chmod' => FALSE, // Do not use chmod on files and directories (should use umask() to control permissions) + 'directory_mode' => 0770, // Filesystem permissions for created directories (requires use_chmod) + 'file_mode' => 0660, // Filesystem permissions for created files (requires use_chmod) + ); + + /** @var bool */ + protected $_isTagDirChecked; + + /** + * @param array $options + */ + public function __construct(array $options = array()) + { + // Magento-friendly cache dir + if (empty($options['cache_dir']) && class_exists('Mage', false)) { + $options['cache_dir'] = Mage::getBaseDir('cache'); + } + + // Backwards compatibility ZF 1.11 and ZF 1.12 + if (isset($options['hashed_directory_umask'])) { + $options['directory_mode'] = $options['hashed_directory_umask']; + } + if (isset($options['cache_file_umask'])) { + $options['file_mode'] = $options['cache_file_umask']; + } + + // Don't use parent constructor + while (list($name, $value) = each($options)) { + $this->setOption($name, $value); + } + + // Check cache dir + if ($this->_options['cache_dir'] !== null) { // particular case for this option + $this->setCacheDir($this->_options['cache_dir']); + } else { + $this->setCacheDir(self::getTmpDir() . DIRECTORY_SEPARATOR, false); + } + + // Validate prefix + if (isset($this->_options['file_name_prefix'])) { // particular case for this option + if (!preg_match('~^[a-zA-Z0-9_]+$~D', $this->_options['file_name_prefix'])) { + Zend_Cache::throwException('Invalid file_name_prefix : must use only [a-zA-Z0-9_]'); + } + } + + // See #ZF-4422 + if (is_string($this->_options['directory_mode'])) { + $this->_options['directory_mode'] = octdec($this->_options['directory_mode']); + } + if (is_string($this->_options['file_mode'])) { + $this->_options['file_mode'] = octdec($this->_options['file_mode']); + } + $this->_options['hashed_directory_umask'] = $this->_options['directory_mode']; + $this->_options['cache_file_umask'] = $this->_options['file_mode']; + } + + /** + * Test if a cache is available for the given id and (if yes) return it (false else) + * + * @param string $id cache id + * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested + * @return string|bool cached datas + */ + public function load($id, $doNotTestCacheValidity = false) + { + $file = $this->_file($id); + $cache = $this->_getCache($file, true); + if ( ! $cache) { + return false; + } + list($metadatas, $data) = $cache; + if ( ! $doNotTestCacheValidity && (time() > $metadatas['expire'])) { + // ?? $this->remove($id); + return false; + } + if ($this->_options['read_control']) { + $hashData = $this->_hash($data, $this->_options['read_control_type']); + $hashControl = $metadatas['hash']; + if ($hashData != $hashControl) { + // Problem detected by the read control ! + $this->_log('Zend_Cache_Backend_File::load() / read_control : stored hash and computed hash do not match'); + $this->remove($id); + return false; + } + } + return $data; + } + + /** + * Save some string datas into a cache record + * + * Note : $data is always "string" (serialization is done by the + * core not by the backend) + * + * @param string $data Datas to cache + * @param string $id Cache id + * @param array $tags Array of strings, the cache record will be tagged by each string entry + * @param bool|int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) + * @return boolean true if no problem + */ + public function save($data, $id, $tags = array(), $specificLifetime = false) + { + $file = $this->_file($id); + $path = $this->_path($id); + if ($this->_options['hashed_directory_level'] > 0) { + if (!is_writable($path)) { + // maybe, we just have to build the directory structure + $this->_recursiveMkdirAndChmod($id); + } + if (!is_writable($path)) { + return false; + } + } + if ($this->_options['read_control']) { + $hash = $this->_hash($data, $this->_options['read_control_type']); + } else { + $hash = ''; + } + $metadatas = array( + 'hash' => $hash, + 'mtime' => time(), + 'expire' => $this->_expireTime($this->getLifetime($specificLifetime)), + 'tags' => implode(',', $tags), + ); + $res = $this->_filePutContents($file, serialize($metadatas)."\n".$data); + $res = $res && $this->_updateIdsTags(array($id), $tags, 'merge'); + return $res; + } + + /** + * Remove a cache record + * + * @param string $id cache id + * @return boolean true if no problem + */ + public function remove($id) + { + $file = $this->_file($id); + $metadatas = $this->_getCache($file, false); + if ($metadatas) { + $boolRemove = $this->_remove($file); + $boolTags = $this->_updateIdsTags(array($id), explode(',', $metadatas['tags']), 'diff'); + return $boolRemove && $boolTags; + } + return false; + } + + /** + * Clean some cache records + * + * Available modes are : + * 'all' (default) => remove all cache entries ($tags is not used) + * 'old' => remove too old cache entries ($tags is not used) + * 'matchingTag' => remove cache entries matching all given tags + * ($tags can be an array of strings or a single string) + * 'notMatchingTag' => remove cache entries not matching one of the given tags + * ($tags can be an array of strings or a single string) + * 'matchingAnyTag' => remove cache entries matching any given tags + * ($tags can be an array of strings or a single string) + * + * @param string $mode + * @param array $tags + * @return boolean true if no problem + */ + public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) + { + // We use this protected method to hide the recursive stuff + clearstatcache(); + switch($mode) { + case Zend_Cache::CLEANING_MODE_ALL: + case Zend_Cache::CLEANING_MODE_OLD: + return $this->_clean($this->_options['cache_dir'], $mode); + default: + return $this->_cleanNew($mode, $tags); + } + } + + /** + * Return an array of stored tags + * + * @return array array of stored tags (string) + */ + public function getTags() + { + $prefix = $this->_tagFile(''); + $prefixLen = strlen($prefix); + $tags = array(); + foreach (@glob($prefix . '*') as $tagFile) { + $tags[] = substr($tagFile, $prefixLen); + } + return $tags; + } + + /** + * Return an array of stored cache ids which match given tags + * + * In case of multiple tags, a logical AND is made between tags + * + * @param array $tags array of tags + * @return array array of matching cache ids (string) + */ + public function getIdsMatchingTags($tags = array()) + { + return $this->_getIdsByTags(Zend_Cache::CLEANING_MODE_MATCHING_TAG, $tags); + } + + /** + * Return an array of stored cache ids which don't match given tags + * + * In case of multiple tags, a logical OR is made between tags + * + * @param array $tags array of tags + * @return array array of not matching cache ids (string) + */ + public function getIdsNotMatchingTags($tags = array()) + { + return $this->_getIdsByTags(Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG, $tags); + } + + /** + * Return an array of stored cache ids which match any given tags + * + * In case of multiple tags, a logical AND is made between tags + * + * @param array $tags array of tags + * @return array array of any matching cache ids (string) + */ + public function getIdsMatchingAnyTags($tags = array()) + { + return $this->_getIdsByTags(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, $tags); + } + + /** + * Return an array of metadatas for the given cache id + * + * The array must include these keys : + * - expire : the expire timestamp + * - tags : a string array of tags + * - mtime : timestamp of last modification time + * + * @param string $id cache id + * @return array array of metadatas (false if the cache id is not found) + */ + public function getMetadatas($id) + { + $metadatas = $this->_getCache($this->_file($id), false); + if ($metadatas) { + $metadatas['tags'] = explode(',' ,$metadatas['tags']); + } + return $metadatas; + } + + /** + * Give (if possible) an extra lifetime to the given cache id + * + * @param string $id cache id + * @param int $extraLifetime + * @return boolean true if ok + */ + public function touch($id, $extraLifetime) + { + $file = $this->_file($id); + $cache = $this->_getCache($file, true); + if (!$cache) { + return false; + } + list($metadatas, $data) = $cache; + if (time() > $metadatas['expire']) { + return false; + } + $newMetadatas = array( + 'hash' => $metadatas['hash'], + 'mtime' => time(), + 'expire' => $metadatas['expire'] + $extraLifetime, + 'tags' => $metadatas['tags'] + ); + return !! $this->_filePutContents($file, serialize($newMetadatas)."\n".$data); + } + + /** + * Get a metadatas record and optionally the data as well + * + * @param string $file Cache file + * @param bool $withData + * @return array|bool + */ + protected function _getCache($file, $withData) + { + if (!is_file($file) || ! ($fd = @fopen($file, 'rb'))) { + return false; + } + if ($this->_options['file_locking']) flock($fd, LOCK_SH); + $metadata = fgets($fd); + if ( ! $metadata) { + if ($this->_options['file_locking']) flock($fd, LOCK_UN); + fclose($fd); + return false; + } + if ($withData) { + $data = stream_get_contents($fd); + } + if ($this->_options['file_locking']) flock($fd, LOCK_UN); + fclose($fd); + $metadata = @unserialize(rtrim($metadata,"\n")); + if ($withData) { + return array($metadata, $data); + } + return $metadata; + } + + /** + * Get meta data from a cache record + * + * @param string $id Cache id + * @return array|bool Associative array of meta data + */ + protected function _getMetadatas($id) + { + return $this->_getCache($this->_file($id), false); + } + + /** + * Set a metadatas record + * + * @param string $id Cache id + * @param array $metadatas Associative array of metadatas + * @param boolean $save optional pass false to disable saving to file + * @return boolean True if no problem + */ + protected function _setMetadatas($id, $metadatas, $save = true) + { + // TODO - implement for unit tests ___expire method + return true; + } + + /** + * Return the complete directory path of a filename (including hashedDirectoryStructure) + * + * Uses multiple letters for a single-level hash rather than multiple levels + * + * @param string $id Cache id + * @param boolean $parts if true, returns array of directory parts instead of single string + * @return string|array Complete directory path + */ + protected function _path($id, $parts = false) + { + $partsArray = array(); + $root = $this->_options['cache_dir']; + $prefix = $this->_options['file_name_prefix']; + if ($this->_options['hashed_directory_level']>0) { + $hash = hash('adler32', $id); + $root = $root . $prefix . '--' . substr($hash, -$this->_options['hashed_directory_level']) . DIRECTORY_SEPARATOR; + $partsArray[] = $root; + } + if ($parts) { + return $partsArray; + } else { + return $root; + } + } + + /** + * Clean some cache records (protected method used for recursive stuff) + * + * Available modes are : + * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) + * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) + * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags + * ($tags can be an array of strings or a single string) + * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} + * ($tags can be an array of strings or a single string) + * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags + * ($tags can be an array of strings or a single string) + * + * @param string $dir Directory to clean + * @param string $mode Clean mode + * @param array $tags + * @throws Zend_Cache_Exception + * @return boolean True if no problem + */ + protected function _clean($dir, $mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) + { + if (!is_dir($dir)) { + return false; + } + $result = true; + $glob = @glob($dir . $this->_options['file_name_prefix'] . '--*'); + if ($glob === false) { + return true; + } + foreach ($glob as $file) { + if (is_file($file)) { + if ($mode == Zend_Cache::CLEANING_MODE_ALL) { + $result = @unlink($file) && $result; + continue; + } + + $id = $this->_fileNameToId(basename($file)); + $_file = $this->_file($id); + if ($file != $_file) { + @unlink($file); + continue; + } + $metadatas = $this->_getCache($file, false); + if ( ! $metadatas) { + @unlink($file); + continue; + } + if ($mode == Zend_Cache::CLEANING_MODE_OLD) { + if (time() > $metadatas['expire']) { + $result = $this->_remove($file) && $result; + $result = $this->_updateIdsTags(array($id), explode(',', $metadatas['tags']), 'diff') && $result; + } + continue; + } else { + Zend_Cache::throwException('Invalid mode for clean() method.'); + } + } + if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) { + // Recursive call + $result = $this->_clean($file . DIRECTORY_SEPARATOR, $mode) && $result; + if ($mode == 'all') { + // if mode=='all', we try to drop the structure too + @rmdir($file); + } + } + } + if ($mode == 'all') { + foreach (glob($this->_tagFile('*')) as $tagFile) { + @unlink($tagFile); + } + } + return $result; + } + + /** + * Clean some cache records (protected method used for recursive stuff) + * + * Available modes are : + * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) + * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) + * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags + * ($tags can be an array of strings or a single string) + * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} + * ($tags can be an array of strings or a single string) + * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags + * ($tags can be an array of strings or a single string) + * + * @param string $mode Clean mode + * @param array $tags Array of tags + * @throws Zend_Cache_Exception + * @return boolean True if no problem + */ + protected function _cleanNew($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) + { + $result = true; + $ids = $this->_getIdsByTags($mode, $tags); + foreach ($ids as $id) { + $idFile = $this->_file($id); + if (is_file($idFile)) { + $result = $result && $this->_remove($idFile); + } + } + switch($mode) + { + case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: + foreach ($tags as $tag) { + $tagFile = $this->_tagFile($tag); + if (is_file($tagFile)) { + $result = $result && $this->_remove($tagFile); + } + } + break; + case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: + case Zend_Cache::CLEANING_MODE_MATCHING_TAG: + $this->_updateIdsTags($ids, $tags, 'diff'); + break; + } + return $result; + } + + /** + * @param string $mode + * @param array $tags + * @return array + */ + protected function _getIdsByTags($mode, $tags) + { + $ids = array(); + switch($mode) { + case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: + $ids = $this->getIds(); + if ($tags) { + foreach ($tags as $tag) { + if ( ! $ids) { + break; // early termination optimization + } + $ids = array_diff($ids, $this->_getTagIds($tag)); + } + } + break; + case Zend_Cache::CLEANING_MODE_MATCHING_TAG: + if ($tags) { + $tag = array_shift($tags); + $ids = $this->_getTagIds($tag); + foreach ($tags as $tag) { + if ( ! $ids) { + break; // early termination optimization + } + $ids = array_intersect($ids, $this->_getTagIds($tag)); + } + $ids = array_unique($ids); + } + break; + case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: + foreach ($tags as $tag) { + $ids = array_merge($ids,$this->_getTagIds($tag)); + } + $ids = array_unique($ids); + break; + } + return $ids; + } + + /** + * Make and return a file name (with path) + * + * @param string $id Cache id + * @return string File name (with path) + */ + protected function _tagFile($id) + { + $path = $this->_tagPath(); + $fileName = $this->_idToFileName($id); + return $path . $fileName; + } + + /** + * Return the complete directory path where tags are stored + * + * @return string Complete directory path + */ + protected function _tagPath() + { + $path = $this->_options['cache_dir'] . DIRECTORY_SEPARATOR . $this->_options['file_name_prefix']. '-tags' . DIRECTORY_SEPARATOR; + if ( ! $this->_isTagDirChecked) { + if ( ! is_dir($path)) { + if (@mkdir($path, $this->_options['use_chmod'] ? $this->_options['directory_mode'] : 0777) && $this->_options['use_chmod']) { + @chmod($path, $this->_options['directory_mode']); // see #ZF-320 (this line is required in some configurations) + } + } + $this->_isTagDirChecked = true; + } + return $path; + } + + /** + * @param string|resource $tag + * @return array + */ + protected function _getTagIds($tag) + { + if (is_resource($tag)) { + $ids = stream_get_contents($tag); + } else { + $ids = @file_get_contents($this->_tagFile($tag)); + } + if( ! $ids) { + return array(); + } + $ids = trim(substr($ids, 0, strrpos($ids, "\n"))); + return $ids ? explode("\n", $ids) : array(); + } + + /** + * @param array $ids + * @param array $tags + * @param string $mode + * @return bool + */ + protected function _updateIdsTags($ids, $tags, $mode) + { + $result = true; + foreach($tags as $tag) { + $file = $this->_tagFile($tag); + if (file_exists($file)) { + /* + * Next code is commented because it's produce bug + * Bug about removing cache ids but in some case cache ids is empty, but related tags is removed + */ +// if ( ! $ids && $mode == 'diff') { +// $result = $this->_remove($file); +// } + if ($mode == 'diff' || (rand(1,100) == 1 && filesize($file) > 4096)) { + $file = $this->_tagFile($tag); + if ( ! ($fd = fopen($file, 'rb+'))) { + $result = false; + continue; + } + if ($this->_options['file_locking']) flock($fd, LOCK_EX); + if ($mode == 'diff') { + $_ids = array_diff($this->_getTagIds($fd), $ids); + } else { // if ($mode == 'merge') + $_ids = array_merge($this->_getTagIds($fd), $ids); + } + fseek($fd, 0); + ftruncate($fd, 0); + $result = fwrite($fd, implode("\n", array_unique($_ids))."\n") && $result; + if ($this->_options['file_locking']) flock($fd, LOCK_UN); + fclose($fd); + } + else { + $result = file_put_contents($file, implode("\n", $ids)."\n", FILE_APPEND | ($this->_options['file_locking'] ? LOCK_EX : 0)) && $result; + } + } else if ($mode == 'merge') { + $result = $this->_filePutContents($file, implode("\n", $ids)."\n") && $result; + } + } + return $result; + } + + /** + * Put the given string into the given file + * + * @param string $file File complete path + * @param string $string String to put in file + * @return boolean true if no problem + */ + protected function _filePutContents($file, $string) + { + $result = @file_put_contents($file, $string, $this->_options['file_locking'] ? LOCK_EX : 0); + if ($result && $this->_options['use_chmod']) { + @chmod($file, $this->_options['file_mode']); + } + return $result; + } + + /** + * Make the directory structure for the given id + * + * @param string $id cache id + * @return boolean true + */ + protected function _recursiveMkdirAndChmod($id) + { + if ($this->_options['hashed_directory_level'] <=0) { + return true; + } + $partsArray = $this->_path($id, true); + foreach ($partsArray as $part) { + if (!is_dir($part)) { + @mkdir($part, $this->_options['use_chmod'] ? $this->_options['directory_mode'] : 0777); + if ($this->_options['use_chmod']) { + @chmod($part, $this->_options['directory_mode']); // see #ZF-320 (this line is required in some configurations) + } + } + } + return true; + } + + /** + * For unit testing only + * @param $id + */ + public function ___expire($id) + { + $metadata = $this->_getMetadatas($id); + $this->touch($id, 1 - $metadata['expire']); + } + +} \ No newline at end of file diff --git a/lib/Cm/Cache/Backend/Redis.php b/lib/Cm/Cache/Backend/Redis.php new file mode 100644 index 00000000000..e969cda0bff --- /dev/null +++ b/lib/Cm/Cache/Backend/Redis.php @@ -0,0 +1,912 @@ +<?php +/* +==New BSD License== + +Copyright (c) 2013, Colin Mollenhour +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. + * The name of Colin Mollenhour may not be used to endorse or promote products + derived from this software without specific prior written permission. + * The class name must remain as Cm_Cache_Backend_Redis. + +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 HOLDER 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. + */ + +/** + * Redis adapter for Zend_Cache + * + * @copyright Copyright (c) 2013 Colin Mollenhour (http://colin.mollenhour.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @author Colin Mollenhour (http://colin.mollenhour.com) + */ +class Cm_Cache_Backend_Redis extends Zend_Cache_Backend implements Zend_Cache_Backend_ExtendedInterface +{ + + const SET_IDS = 'zc:ids'; + const SET_TAGS = 'zc:tags'; + + const PREFIX_KEY = 'zc:k:'; + const PREFIX_TAG_IDS = 'zc:ti:'; + + const FIELD_DATA = 'd'; + const FIELD_MTIME = 'm'; + const FIELD_TAGS = 't'; + const FIELD_INF = 'i'; + + const MAX_LIFETIME = 2592000; /* Redis backend limit */ + const COMPRESS_PREFIX = ":\x1f\x8b"; + const DEFAULT_CONNECT_TIMEOUT = 2.5; + const DEFAULT_CONNECT_RETRIES = 1; + + const LUA_SAVE_SH1 = '1617c9fb2bda7d790bb1aaa320c1099d81825e64'; + const LUA_CLEAN_SH1 = '1dc59e493285befe678c480c8f10f1a7cc352c71'; + const LUA_GC_SH1 = 'c00416b970f1aa6363b44965d4cf60ee99a6f065'; + + /** @var Credis_Client */ + protected $_redis; + + /** @var bool */ + protected $_notMatchingTags = FALSE; + + /** @var int */ + protected $_lifetimelimit = self::MAX_LIFETIME; /* Redis backend limit */ + + /** @var int */ + protected $_compressTags = 1; + + /** @var int */ + protected $_compressData = 1; + + /** @var int */ + protected $_compressThreshold = 20480; + + /** @var string */ + protected $_compressionLib; + + /** @var bool */ + protected $_useLua = false; + + /** + * Contruct Zend_Cache Redis backend + * @param array $options + * @return \Cm_Cache_Backend_Redis + */ + public function __construct($options = array()) + { + if ( empty($options['server']) ) { + Zend_Cache::throwException('Redis \'server\' not specified.'); + } + + if ( empty($options['port']) && substr($options['server'],0,1) != '/' ) { + Zend_Cache::throwException('Redis \'port\' not specified.'); + } + + $port = isset($options['port']) ? $options['port'] : NULL; + $timeout = isset($options['timeout']) ? $options['timeout'] : self::DEFAULT_CONNECT_TIMEOUT; + $persistent = isset($options['persistent']) ? $options['persistent'] : ''; + $this->_redis = new Credis_Client($options['server'], $port, $timeout, $persistent); + + if ( isset($options['force_standalone']) && $options['force_standalone']) { + $this->_redis->forceStandalone(); + } + + $connectRetries = isset($options['connect_retries']) ? (int)$options['connect_retries'] : self::DEFAULT_CONNECT_RETRIES; + $this->_redis->setMaxConnectRetries($connectRetries); + + if ( ! empty($options['read_timeout']) && $options['read_timeout'] > 0) { + $this->_redis->setReadTimeout((float) $options['read_timeout']); + } + + if ( ! empty($options['password'])) { + $this->_redis->auth($options['password']) or Zend_Cache::throwException('Unable to authenticate with the redis server.'); + } + + // Always select database on startup in case persistent connection is re-used by other code + if (empty($options['database'])) { + $options['database'] = 0; + } + $this->_redis->select( (int) $options['database']) or Zend_Cache::throwException('The redis database could not be selected.'); + + if ( isset($options['notMatchingTags']) ) { + $this->_notMatchingTags = (bool) $options['notMatchingTags']; + } + + if ( isset($options['compress_tags'])) { + $this->_compressTags = (int) $options['compress_tags']; + } + + if ( isset($options['compress_data'])) { + $this->_compressData = (int) $options['compress_data']; + } + + if ( isset($options['lifetimelimit'])) { + $this->_lifetimelimit = (int) min($options['lifetimelimit'], self::MAX_LIFETIME); + } + + if ( isset($options['compress_threshold'])) { + $this->_compressThreshold = (int) $options['compress_threshold']; + } + + if ( isset($options['automatic_cleaning_factor']) ) { + $this->_options['automatic_cleaning_factor'] = (int) $options['automatic_cleaning_factor']; + } else { + $this->_options['automatic_cleaning_factor'] = 0; + } + + if ( isset($options['compression_lib']) ) { + $this->_compressionLib = $options['compression_lib']; + } + else if ( function_exists('snappy_compress') ) { + $this->_compressionLib = 'snappy'; + } + else if ( function_exists('lz4_compress')) { + $this->_compressionLib = 'l4z'; + } + else if ( function_exists('lzf_compress') ) { + $this->_compressionLib = 'lzf'; + } + else { + $this->_compressionLib = 'gzip'; + } + $this->_compressPrefix = substr($this->_compressionLib,0,2).self::COMPRESS_PREFIX; + + if (isset($options['use_lua'])) { + $this->_useLua = (bool) $options['use_lua']; + } + } + + /** + * Load value with given id from cache + * + * @param string $id Cache id + * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested + * @return bool|string + */ + public function load($id, $doNotTestCacheValidity = false) + { + $data = $this->_redis->hGet(self::PREFIX_KEY.$id, self::FIELD_DATA); + if ($data === NULL) { + return FALSE; + } + return $this->_decodeData($data); + } + + /** + * Test if a cache is available or not (for the given id) + * + * @param string $id Cache id + * @return bool|int False if record is not available or "last modified" timestamp of the available cache record + */ + public function test($id) + { + $mtime = $this->_redis->hGet(self::PREFIX_KEY.$id, self::FIELD_MTIME); + return ($mtime ? $mtime : FALSE); + } + + /** + * Save some string datas into a cache record + * + * Note : $data is always "string" (serialization is done by the + * core not by the backend) + * + * @param string $data Datas to cache + * @param string $id Cache id + * @param array $tags Array of strings, the cache record will be tagged by each string entry + * @param bool|int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) + * @throws CredisException + * @return boolean True if no problem + */ + public function save($data, $id, $tags = array(), $specificLifetime = false) + { + if(!is_array($tags)) + $tags = $tags ? array($tags) : array(); + else + $tags = array_flip(array_flip($tags)); + + $lifetime = $this->getLifetime($specificLifetime); + + if ($this->_useLua) { + $sArgs = array( + self::PREFIX_KEY, + self::FIELD_DATA, + self::FIELD_TAGS, + self::FIELD_MTIME, + self::FIELD_INF, + self::SET_TAGS, + self::PREFIX_TAG_IDS, + self::SET_IDS, + $id, + $this->_encodeData($data, $this->_compressData), + $this->_encodeData(implode(',',$tags), $this->_compressTags), + time(), + $lifetime ? 0 : 1, + min($lifetime, self::MAX_LIFETIME), + $this->_notMatchingTags ? 1 : 0 + ); + + $res = $this->_redis->evalSha(self::LUA_SAVE_SH1, $tags, $sArgs); + if (is_null($res)) { + $script = + "local oldTags = redis.call('HGET', ARGV[1]..ARGV[9], ARGV[3]) ". + "redis.call('HMSET', ARGV[1]..ARGV[9], ARGV[2], ARGV[10], ARGV[3], ARGV[11], ARGV[4], ARGV[12], ARGV[5], ARGV[13]) ". + "if (ARGV[13] == '0') then ". + "redis.call('EXPIRE', ARGV[1]..ARGV[9], ARGV[14]) ". + "end ". + "if next(KEYS) ~= nil then ". + "redis.call('SADD', ARGV[6], unpack(KEYS)) ". + "for _, tagname in ipairs(KEYS) do ". + "redis.call('SADD', ARGV[7]..tagname, ARGV[9]) ". + "end ". + "end ". + "if (ARGV[15] == '1') then ". + "redis.call('SADD', ARGV[8], ARGV[9]) ". + "end ". + "if (oldTags ~= false) then ". + "return oldTags ". + "else ". + "return '' ". + "end"; + $res = $this->_redis->eval($script, $tags, $sArgs); + } + + // Process removed tags if cache entry already existed + if ($res) { + $oldTags = explode(',', $this->_decodeData($res)); + if ($remTags = ($oldTags ? array_diff($oldTags, $tags) : FALSE)) + { + // Update the id list for each tag + foreach($remTags as $tag) + { + $this->_redis->sRem(self::PREFIX_TAG_IDS . $tag, $id); + } + } + } + + return TRUE; + } + + // Get list of tags previously assigned + $oldTags = $this->_decodeData($this->_redis->hGet(self::PREFIX_KEY.$id, self::FIELD_TAGS)); + $oldTags = $oldTags ? explode(',', $oldTags) : array(); + + $this->_redis->pipeline()->multi(); + + // Set the data + $result = $this->_redis->hMSet(self::PREFIX_KEY.$id, array( + self::FIELD_DATA => $this->_encodeData($data, $this->_compressData), + self::FIELD_TAGS => $this->_encodeData(implode(',',$tags), $this->_compressTags), + self::FIELD_MTIME => time(), + self::FIELD_INF => $lifetime ? 0 : 1, + )); + if( ! $result) { + throw new CredisException("Could not set cache key $id"); + } + + // Set expiration if specified + if ($lifetime) { + $this->_redis->expire(self::PREFIX_KEY.$id, min($lifetime, self::MAX_LIFETIME)); + } + + // Process added tags + if ($tags) + { + // Update the list with all the tags + $this->_redis->sAdd( self::SET_TAGS, $tags); + + // Update the id list for each tag + foreach($tags as $tag) + { + $this->_redis->sAdd(self::PREFIX_TAG_IDS . $tag, $id); + } + } + + // Process removed tags + if ($remTags = ($oldTags ? array_diff($oldTags, $tags) : FALSE)) + { + // Update the id list for each tag + foreach($remTags as $tag) + { + $this->_redis->sRem(self::PREFIX_TAG_IDS . $tag, $id); + } + } + + // Update the list with all the ids + if($this->_notMatchingTags) { + $this->_redis->sAdd(self::SET_IDS, $id); + } + + $this->_redis->exec(); + + return TRUE; + } + + /** + * Remove a cache record + * + * @param string $id Cache id + * @return boolean True if no problem + */ + public function remove($id) + { + // Get list of tags for this id + $tags = explode(',', $this->_decodeData($this->_redis->hGet(self::PREFIX_KEY.$id, self::FIELD_TAGS))); + + $this->_redis->pipeline()->multi(); + + // Remove data + $this->_redis->del(self::PREFIX_KEY.$id); + + // Remove id from list of all ids + if($this->_notMatchingTags) { + $this->_redis->sRem( self::SET_IDS, $id ); + } + + // Update the id list for each tag + foreach($tags as $tag) { + $this->_redis->sRem(self::PREFIX_TAG_IDS . $tag, $id); + } + + $result = $this->_redis->exec(); + + return (bool) $result[0]; + } + + /** + * @param array $tags + */ + protected function _removeByNotMatchingTags($tags) + { + $ids = $this->getIdsNotMatchingTags($tags); + if($ids) + { + $this->_redis->pipeline()->multi(); + + // Remove data + $this->_redis->del( $this->_preprocessIds($ids)); + + // Remove ids from list of all ids + if($this->_notMatchingTags) { + $this->_redis->sRem( self::SET_IDS, $ids); + } + + $this->_redis->exec(); + } + } + + /** + * @param array $tags + */ + protected function _removeByMatchingTags($tags) + { + $ids = $this->getIdsMatchingTags($tags); + if($ids) + { + $this->_redis->pipeline()->multi(); + + // Remove data + $this->_redis->del( $this->_preprocessIds($ids)); + + // Remove ids from list of all ids + if($this->_notMatchingTags) { + $this->_redis->sRem( self::SET_IDS, $ids); + } + + $this->_redis->exec(); + } + } + + /** + * @param array $tags + */ + protected function _removeByMatchingAnyTags($tags) + { + if ($this->_useLua) { + $pTags = $this->_preprocessTagIds($tags); + $sArgs = array(self::PREFIX_KEY, self::SET_TAGS, self::SET_IDS, ($this->_notMatchingTags ? 1 : 0)); + if ( ! $this->_redis->evalSha(self::LUA_CLEAN_SH1, $pTags, $sArgs)) { + $script = + "local keysToDel = redis.call('SUNION', unpack(KEYS)) ". + "for _, keyname in ipairs(keysToDel) do ". + "redis.call('DEL', ARGV[1]..keyname) ". + "if (ARGV[4] == '1') then ". + "redis.call('SREM', ARGV[3], keyname) ". + "end ". + "end ". + "redis.call('DEL', unpack(KEYS)) ". + "redis.call('SREM', ARGV[2], unpack(KEYS)) ". + "return true"; + $this->_redis->eval($script, $pTags, $sArgs); + } + return; + } + + $ids = $this->getIdsMatchingAnyTags($tags); + + $this->_redis->pipeline()->multi(); + + if($ids) + { + // Remove data + $this->_redis->del( $this->_preprocessIds($ids)); + + // Remove ids from list of all ids + if($this->_notMatchingTags) { + $this->_redis->sRem( self::SET_IDS, $ids); + } + } + + // Remove tag id lists + $this->_redis->del( $this->_preprocessTagIds($tags)); + + // Remove tags from list of tags + $this->_redis->sRem( self::SET_TAGS, $tags); + + $this->_redis->exec(); + } + + /** + * Clean up tag id lists since as keys expire the ids remain in the tag id lists + */ + protected function _collectGarbage() + { + // Clean up expired keys from tag id set and global id set + + if ($this->_useLua) { + $sArgs = array(self::PREFIX_KEY, self::SET_TAGS, self::SET_IDS, self::PREFIX_TAG_IDS, ($this->_notMatchingTags ? 1 : 0)); + $allTags = (array) $this->_redis->sMembers(self::SET_TAGS); + $tagsCount = count($allTags); + $counter = 0; + $tagsBatch = array(); + foreach ($allTags as $tag) { + $tagsBatch[] = $tag; + $counter++; + if (count($tagsBatch) == 10 || $counter == $tagsCount ) { + if ( ! $this->_redis->evalSha(self::LUA_GC_SH1, $tagsBatch, $sArgs)) { + $script = + "local tagKeys = {} ". + "local expired = {} ". + "local expiredCount = 0 ". + "local notExpiredCount = 0 ". + "for _, tagName in ipairs(KEYS) do ". + "tagKeys = redis.call('SMEMBERS', ARGV[4]..tagName) ". + "for __, keyName in ipairs(tagKeys) do ". + "if (redis.call('EXISTS', ARGV[1]..keyName) == 0) then ". + "expiredCount = expiredCount + 1 ". + "expired[expiredCount] = keyName ". + /* Redis Lua scripts have a hard limit of 8000 parameters per command */ + "if (expiredCount == 7990) then ". + "redis.call('SREM', ARGV[4]..tagName, unpack(expired)) ". + "if (ARGV[5] == '1') then ". + "redis.call('SREM', ARGV[3], unpack(expired)) ". + "end ". + "expiredCount = 0 ". + "expired = {} ". + "end ". + "else ". + "notExpiredCount = notExpiredCount + 1 ". + "end ". + "end ". + "if (expiredCount > 0) then ". + "redis.call('SREM', ARGV[4]..tagName, unpack(expired)) ". + "if (ARGV[5] == '1') then ". + "redis.call('SREM', ARGV[3], unpack(expired)) ". + "end ". + "end ". + "if (notExpiredCount == 0) then ". + "redis.call ('DEL', ARGV[4]..tagName) ". + "redis.call ('SREM', ARGV[2], tagName) ". + "end ". + "expired = {} ". + "expiredCount = 0 ". + "notExpiredCount = 0 ". + "end ". + "return true"; + $this->_redis->eval($script, $tagsBatch, $sArgs); + } + $tagsBatch = array(); + /* Give Redis some time to handle other requests */ + usleep(20000); + } + } + return; + } + + $exists = array(); + $tags = (array) $this->_redis->sMembers(self::SET_TAGS); + foreach($tags as $tag) + { + // Get list of expired ids for each tag + $tagMembers = $this->_redis->sMembers(self::PREFIX_TAG_IDS . $tag); + $numTagMembers = count($tagMembers); + $expired = array(); + $numExpired = $numNotExpired = 0; + if($numTagMembers) { + while ($id = array_pop($tagMembers)) { + if( ! isset($exists[$id])) { + $exists[$id] = $this->_redis->exists(self::PREFIX_KEY.$id); + } + if ($exists[$id]) { + $numNotExpired++; + } + else { + $numExpired++; + $expired[] = $id; + + // Remove incrementally to reduce memory usage + if (count($expired) % 100 == 0 && $numNotExpired > 0) { + $this->_redis->sRem( self::PREFIX_TAG_IDS . $tag, $expired); + if($this->_notMatchingTags) { // Clean up expired ids from ids set + $this->_redis->sRem( self::SET_IDS, $expired); + } + $expired = array(); + } + } + } + if( ! count($expired)) continue; + } + + // Remove empty tags or completely expired tags + if ($numExpired == $numTagMembers) { + $this->_redis->del(self::PREFIX_TAG_IDS . $tag); + $this->_redis->sRem(self::SET_TAGS, $tag); + } + // Clean up expired ids from tag ids set + else if (count($expired)) { + $this->_redis->sRem( self::PREFIX_TAG_IDS . $tag, $expired); + if($this->_notMatchingTags) { // Clean up expired ids from ids set + $this->_redis->sRem( self::SET_IDS, $expired); + } + } + unset($expired); + } + + // Clean up global list of ids for ids with no tag + if($this->_notMatchingTags) { + // TODO + } + } + + /** + * Clean some cache records + * + * Available modes are : + * 'all' (default) => remove all cache entries ($tags is not used) + * 'old' => runs _collectGarbage() + * 'matchingTag' => supported + * 'notMatchingTag' => supported + * 'matchingAnyTag' => supported + * + * @param string $mode Clean mode + * @param array $tags Array of tags + * @throws Zend_Cache_Exception + * @return boolean True if no problem + */ + public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) + { + if( $tags && ! is_array($tags)) { + $tags = array($tags); + } + + try { + if ($mode == Zend_Cache::CLEANING_MODE_ALL) { + return $this->_redis->flushDb(); + } + if ($mode == Zend_Cache::CLEANING_MODE_OLD) { + $this->_collectGarbage(); + return TRUE; + } + if ( ! count($tags)) { + return TRUE; + } + switch ($mode) + { + case Zend_Cache::CLEANING_MODE_MATCHING_TAG: + + $this->_removeByMatchingTags($tags); + break; + + case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: + + $this->_removeByNotMatchingTags($tags); + break; + + case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: + + $this->_removeByMatchingAnyTags($tags); + break; + + default: + Zend_Cache::throwException('Invalid mode for clean() method: '.$mode); + } + } catch (CredisException $e) { + Zend_Cache::throwException('Error cleaning cache by mode '.$mode.': '.$e->getMessage(), $e); + } + return TRUE; + } + + /** + * Return true if the automatic cleaning is available for the backend + * + * @return boolean + */ + public function isAutomaticCleaningAvailable() + { + return TRUE; + } + + /** + * Set the frontend directives + * + * @param array $directives Assoc of directives + * @throws Zend_Cache_Exception + * @return void + */ + public function setDirectives($directives) + { + parent::setDirectives($directives); + $lifetime = $this->getLifetime(false); + if ($lifetime > self::MAX_LIFETIME) { + Zend_Cache::throwException('Redis backend has a limit of 30 days (2592000 seconds) for the lifetime'); + } + } + + /** + * Return an array of stored cache ids + * + * @return array array of stored cache ids (string) + */ + public function getIds() + { + if($this->_notMatchingTags) { + return (array) $this->_redis->sMembers(self::SET_IDS); + } else { + $keys = $this->_redis->keys(self::PREFIX_KEY . '*'); + $prefixLen = strlen(self::PREFIX_KEY); + foreach($keys as $index => $key) { + $keys[$index] = substr($key, $prefixLen); + } + return $keys; + } + } + + /** + * Return an array of stored tags + * + * @return array array of stored tags (string) + */ + public function getTags() + { + return (array) $this->_redis->sMembers(self::SET_TAGS); + } + + /** + * Return an array of stored cache ids which match given tags + * + * In case of multiple tags, a logical AND is made between tags + * + * @param array $tags array of tags + * @return array array of matching cache ids (string) + */ + public function getIdsMatchingTags($tags = array()) + { + if ($tags) { + return (array) $this->_redis->sInter( $this->_preprocessTagIds($tags) ); + } + return array(); + } + + /** + * Return an array of stored cache ids which don't match given tags + * + * In case of multiple tags, a negated logical AND is made between tags + * + * @param array $tags array of tags + * @return array array of not matching cache ids (string) + */ + public function getIdsNotMatchingTags($tags = array()) + { + if( ! $this->_notMatchingTags) { + Zend_Cache::throwException("notMatchingTags is currently disabled."); + } + if ($tags) { + return (array) $this->_redis->sDiff( self::SET_IDS, $this->_preprocessTagIds($tags) ); + } + return (array) $this->_redis->sMembers( self::SET_IDS ); + } + + /** + * Return an array of stored cache ids which match any given tags + * + * In case of multiple tags, a logical OR is made between tags + * + * @param array $tags array of tags + * @return array array of any matching cache ids (string) + */ + public function getIdsMatchingAnyTags($tags = array()) + { + if ($tags) { + return (array) $this->_redis->sUnion( $this->_preprocessTagIds($tags)); + } + return array(); + } + + /** + * Return the filling percentage of the backend storage + * + * @throws Zend_Cache_Exception + * @return int integer between 0 and 100 + */ + public function getFillingPercentage() + { + return 0; + } + + /** + * Return an array of metadatas for the given cache id + * + * The array must include these keys : + * - expire : the expire timestamp + * - tags : a string array of tags + * - mtime : timestamp of last modification time + * + * @param string $id cache id + * @return array array of metadatas (false if the cache id is not found) + */ + public function getMetadatas($id) + { + list($tags, $mtime, $inf) = $this->_redis->hMGet(self::PREFIX_KEY.$id, array(self::FIELD_TAGS, self::FIELD_MTIME, self::FIELD_INF)); + if( ! $mtime) { + return FALSE; + } + $tags = explode(',', $this->_decodeData($tags)); + $expire = $inf === '1' ? FALSE : time() + $this->_redis->ttl(self::PREFIX_KEY.$id); + + return array( + 'expire' => $expire, + 'tags' => $tags, + 'mtime' => $mtime, + ); + } + + /** + * Give (if possible) an extra lifetime to the given cache id + * + * @param string $id cache id + * @param int $extraLifetime + * @return boolean true if ok + */ + public function touch($id, $extraLifetime) + { + list($inf) = $this->_redis->hGet(self::PREFIX_KEY.$id, self::FIELD_INF); + if ($inf === '0') { + $expireAt = time() + $this->_redis->ttl(self::PREFIX_KEY.$id) + $extraLifetime; + return (bool) $this->_redis->expireAt(self::PREFIX_KEY.$id, $expireAt); + } + return false; + } + + /** + * Return an associative array of capabilities (booleans) of the backend + * + * The array must include these keys : + * - automatic_cleaning (is automating cleaning necessary) + * - tags (are tags supported) + * - expired_read (is it possible to read expired cache records + * (for doNotTestCacheValidity option for example)) + * - priority does the backend deal with priority when saving + * - infinite_lifetime (is infinite lifetime can work with this backend) + * - get_list (is it possible to get the list of cache ids and the complete list of tags) + * + * @return array associative of with capabilities + */ + public function getCapabilities() + { + return array( + 'automatic_cleaning' => ($this->_options['automatic_cleaning_factor'] > 0), + 'tags' => true, + 'expired_read' => false, + 'priority' => false, + 'infinite_lifetime' => true, + 'get_list' => true, + ); + } + + /** + * @param string $data + * @param int $level + * @throws CredisException + * @return string + */ + protected function _encodeData($data, $level) + { + if ($level && strlen($data) >= $this->_compressThreshold) { + switch($this->_compressionLib) { + case 'snappy': $data = snappy_compress($data); break; + case 'lzf': $data = lzf_compress($data); break; + case 'l4z': $data = lz4_compress($data,($level > 1 ? true : false)); break; + case 'gzip': $data = gzcompress($data, $level); break; + } + if( ! $data) { + throw new CredisException("Could not compress cache data."); + } + return $this->_compressPrefix.$data; + } + return $data; + } + + /** + * @param bool|string $data + * @return string + */ + protected function _decodeData($data) + { + if (substr($data,2,3) == self::COMPRESS_PREFIX) { + switch(substr($data,0,2)) { + case 'sn': return snappy_uncompress(substr($data,5)); + case 'lz': return lzf_decompress(substr($data,5)); + case 'l4': return lz4_uncompress(substr($data,5)); + case 'gz': case 'zc': return gzuncompress(substr($data,5)); + } + } + return $data; + } + + /** + * @param $item + * @param $index + * @param $prefix + */ + protected function _preprocess(&$item, $index, $prefix) + { + $item = $prefix . $item; + } + + /** + * @param $ids + * @return array + */ + protected function _preprocessIds($ids) + { + array_walk($ids, array($this, '_preprocess'), self::PREFIX_KEY); + return $ids; + } + + /** + * @param $tags + * @return array + */ + protected function _preprocessTagIds($tags) + { + array_walk($tags, array($this, '_preprocess'), self::PREFIX_TAG_IDS); + return $tags; + } + + /** + * Required to pass unit tests + * + * @param string $id + * @return void + */ + public function ___expire($id) + { + $this->_redis->del(self::PREFIX_KEY.$id); + } + +} \ No newline at end of file diff --git a/lib/Magento/App/ActionInterface.php b/lib/Magento/App/ActionInterface.php index f93ecec51fe..a02490427f2 100644 --- a/lib/Magento/App/ActionInterface.php +++ b/lib/Magento/App/ActionInterface.php @@ -34,4 +34,11 @@ interface ActionInterface * @return ResponseInterface */ public function dispatch(RequestInterface $request); + + /** + * Get Response object + * + * @return ResponseInterface + */ + public function getResponse(); } diff --git a/lib/Magento/App/Cache/Frontend/Factory.php b/lib/Magento/App/Cache/Frontend/Factory.php index 6360e37eb3d..bf28bb2739c 100644 --- a/lib/Magento/App/Cache/Frontend/Factory.php +++ b/lib/Magento/App/Cache/Frontend/Factory.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -69,7 +67,7 @@ class Factory * * @var string */ - protected $_defaultBackend = 'File'; + protected $_defaultBackend = 'Cm_Cache_Backend_File'; /** * Options for default backend @@ -276,13 +274,12 @@ class Factory } } } - if (!$backendType) { $backendType = $this->_defaultBackend; - foreach ($this->_backendOptions as $option => $value) { - if (!array_key_exists($option, $options)) { - $options[$option] = $value; - } + } + foreach ($this->_backendOptions as $option => $value) { + if (!array_key_exists($option, $options)) { + $options[$option] = $value; } } diff --git a/lib/Magento/App/Cache/Proxy.php b/lib/Magento/App/Cache/Proxy.php index 15d6d55da21..8017c9c285b 100644 --- a/lib/Magento/App/Cache/Proxy.php +++ b/lib/Magento/App/Cache/Proxy.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/lib/Magento/App/Cache/Type/AccessProxy.php b/lib/Magento/App/Cache/Type/AccessProxy.php index 8d56d98a083..a2fb394f995 100644 --- a/lib/Magento/App/Cache/Type/AccessProxy.php +++ b/lib/Magento/App/Cache/Type/AccessProxy.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/lib/Magento/App/Cache/Type/Block.php b/lib/Magento/App/Cache/Type/Block.php index 186788ca529..4604ae540d6 100644 --- a/lib/Magento/App/Cache/Type/Block.php +++ b/lib/Magento/App/Cache/Type/Block.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/lib/Magento/App/Cache/Type/Collection.php b/lib/Magento/App/Cache/Type/Collection.php index bd244275b8c..b180797a23a 100644 --- a/lib/Magento/App/Cache/Type/Collection.php +++ b/lib/Magento/App/Cache/Type/Collection.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/lib/Magento/App/Cache/Type/Config.php b/lib/Magento/App/Cache/Type/Config.php index 732ab11fb38..35185e20849 100644 --- a/lib/Magento/App/Cache/Type/Config.php +++ b/lib/Magento/App/Cache/Type/Config.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/lib/Magento/App/Cache/Type/Layout.php b/lib/Magento/App/Cache/Type/Layout.php index 89cc69835d9..720a43c2dd3 100644 --- a/lib/Magento/App/Cache/Type/Layout.php +++ b/lib/Magento/App/Cache/Type/Layout.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/lib/Magento/App/Cache/Type/Translate.php b/lib/Magento/App/Cache/Type/Translate.php index 2696cc3a4ea..70bde1b2c1d 100644 --- a/lib/Magento/App/Cache/Type/Translate.php +++ b/lib/Magento/App/Cache/Type/Translate.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/lib/Magento/App/EntryPoint/EntryPoint.php b/lib/Magento/App/EntryPoint/EntryPoint.php index 15b73061158..c9485b899cc 100644 --- a/lib/Magento/App/EntryPoint/EntryPoint.php +++ b/lib/Magento/App/EntryPoint/EntryPoint.php @@ -86,8 +86,8 @@ class EntryPoint implements EntryPointInterface if (isset($this->_parameters[state::PARAM_MODE]) && $this->_parameters[State::PARAM_MODE] == State::MODE_DEVELOPER ) { - print $exception->getMessage() . "\n\n"; - print $exception->getTraceAsString(); + echo $exception->getMessage() . "\n\n"; + echo $exception->getTraceAsString(); } else { $message = "Error happened during application run.\n"; try { @@ -98,7 +98,7 @@ class EntryPoint implements EntryPointInterface } catch (\Exception $e) { $message .= "Could not write error message to log. Please use developer mode to see the message.\n"; } - print $message; + echo $message; } } } diff --git a/lib/Magento/App/FrontController.php b/lib/Magento/App/FrontController.php index 2104418dd76..e94a4098eec 100644 --- a/lib/Magento/App/FrontController.php +++ b/lib/Magento/App/FrontController.php @@ -58,6 +58,7 @@ class FrontController implements FrontControllerInterface $actionInstance = $router->match($request); if ($actionInstance) { $request->setDispatched(true); + $actionInstance->getResponse()->setNoCacheHeaders(); $response = $actionInstance->dispatch($request); break; } @@ -73,8 +74,6 @@ class FrontController implements FrontControllerInterface if ($routingCycleCounter > 100) { throw new \LogicException('Front controller reached 100 router match iterations'); } - $response->setHeader('cache-control', 'no-store, no-cache, must-revalidate, max-age=0', true); - $response->setHeader('pragma', 'no-cache', true); return $response; } } diff --git a/lib/Magento/App/FrontController/Plugin/Clickjacking.php b/lib/Magento/App/FrontController/Plugin/Clickjacking.php index 07b0d198fb3..b02a6d9e801 100644 --- a/lib/Magento/App/FrontController/Plugin/Clickjacking.php +++ b/lib/Magento/App/FrontController/Plugin/Clickjacking.php @@ -30,10 +30,13 @@ class Clickjacking /** * Process response * + * @param \Magento\App\FrontController $subject * @param \Magento\App\ResponseInterface $response + * * @return \Magento\App\ResponseInterface + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterDispatch(\Magento\App\ResponseInterface $response) + public function afterDispatch(\Magento\App\FrontController $subject, \Magento\App\ResponseInterface $response) { if (!$response->getHeader('X-Frame-Options')) { $response->setHeader('X-Frame-Options', 'SAMEORIGIN'); diff --git a/lib/Magento/App/Helper/AbstractHelper.php b/lib/Magento/App/Helper/AbstractHelper.php index cafbc26e698..7237569ecfb 100644 --- a/lib/Magento/App/Helper/AbstractHelper.php +++ b/lib/Magento/App/Helper/AbstractHelper.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -64,11 +62,6 @@ abstract class AbstractHelper */ protected $_logger; - /** - * @var \Magento\Core\Model\App - */ - protected $_app; - /** * @var \Magento\UrlInterface */ @@ -100,7 +93,6 @@ abstract class AbstractHelper $this->_moduleManager = $context->getModuleManager(); $this->_logger = $context->getLogger(); $this->_request = $context->getRequest(); - $this->_app = $context->getApp(); $this->_urlBuilder = $context->getUrlBuilder(); $this->_httpHeader = $context->getHttpHeader(); $this->_eventManager = $context->getEventManager(); diff --git a/lib/Magento/App/Helper/Context.php b/lib/Magento/App/Helper/Context.php index 3021f8edfd5..3e73af0dd14 100644 --- a/lib/Magento/App/Helper/Context.php +++ b/lib/Magento/App/Helper/Context.php @@ -57,11 +57,6 @@ class Context implements \Magento\ObjectManager\ContextInterface */ protected $_cacheConfig; - /** - * @var \Magento\Core\Model\App - */ - protected $_app; - /** * @var \Magento\UrlInterface */ @@ -84,7 +79,6 @@ class Context implements \Magento\ObjectManager\ContextInterface * @param \Magento\App\RequestInterface $httpRequest * @param \Magento\Cache\ConfigInterface $cacheConfig * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Core\Model\App $app * @param \Magento\UrlInterface $urlBuilder * @param \Magento\HTTP\Header $httpHeader * @param \Magento\HTTP\PhpEnvironment\RemoteAddress $remoteAddress @@ -98,7 +92,6 @@ class Context implements \Magento\ObjectManager\ContextInterface \Magento\App\RequestInterface $httpRequest, \Magento\Cache\ConfigInterface $cacheConfig, \Magento\Event\ManagerInterface $eventManager, - \Magento\Core\Model\App $app, \Magento\UrlInterface $urlBuilder, \Magento\HTTP\Header $httpHeader, \Magento\HTTP\PhpEnvironment\RemoteAddress $remoteAddress @@ -109,7 +102,6 @@ class Context implements \Magento\ObjectManager\ContextInterface $this->_cacheConfig = $cacheConfig; $this->_eventManager = $eventManager; $this->_logger = $logger; - $this->_app = $app; $this->_urlBuilder = $urlBuilder; $this->_httpHeader = $httpHeader; $this->_remoteAddress = $remoteAddress; @@ -131,14 +123,6 @@ class Context implements \Magento\ObjectManager\ContextInterface return $this->_moduleManager; } - /** - * @return \Magento\Core\Model\App - */ - public function getApp() - { - return $this->_app; - } - /** * @return \Magento\UrlInterface */ diff --git a/app/code/Magento/Backend/Model/Config/Source/Currency.php b/lib/Magento/App/Http/Context.php similarity index 62% rename from app/code/Magento/Backend/Model/Config/Source/Currency.php rename to lib/Magento/App/Http/Context.php index 41ad819e540..5c1309e2455 100644 --- a/app/code/Magento/Backend/Model/Config/Source/Currency.php +++ b/lib/Magento/App/Http/Context.php @@ -18,43 +18,53 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Backend * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Backend\Model\Config\Source; +namespace Magento\App\Http; -class Currency implements \Magento\Option\ArrayInterface +/** + * Context data for requests + */ +class Context { /** + * Data storage + * * @var array */ - protected $_options; + protected $data = array(); /** - * @var \Magento\Core\Model\LocaleInterface + * Data setter + * + * @param string $name + * @param mixed $value */ - protected $_locale; + public function setValue($name, $value) + { + $this->data[$name] = $value; + } /** - * @param \Magento\Core\Model\LocaleInterface $locale + * Data getter + * + * @param string $name + * @return mixed */ - public function __construct(\Magento\Core\Model\LocaleInterface $locale) + public function getValue($name) { - $this->_locale = $locale; + return isset($this->data[$name]) ? $this->data[$name] : null; } /** + * Return all data + * * @return array */ - public function toOptionArray() + public function getData() { - if (!$this->_options) { - $this->_options = $this->_locale->getOptionCurrencies(); - } - $options = $this->_options; - return $options; + return $this->data; } } diff --git a/lib/Magento/App/ObjectManagerFactory.php b/lib/Magento/App/ObjectManagerFactory.php index 671544dca20..85c4945d220 100644 --- a/lib/Magento/App/ObjectManagerFactory.php +++ b/lib/Magento/App/ObjectManagerFactory.php @@ -49,7 +49,7 @@ class ObjectManagerFactory * * @var string */ - protected $_configClassName = '\Magento\ObjectManager\Config\Config'; + protected $_configClassName = 'Magento\Interception\ObjectManager\Config'; /** * Create object manager @@ -106,7 +106,12 @@ class ObjectManagerFactory 'Magento\App\Arguments' => $appArguments, 'Magento\App\Filesystem\DirectoryList' => $directoryList, 'Magento\Filesystem\DirectoryList' => $directoryList, + 'Magento\ObjectManager\Relations' => $relations, + 'Magento\Interception\Definition' => $definitionFactory->createPluginDefinition(), + 'Magento\ObjectManager\Config' => $diConfig, + 'Magento\ObjectManager\Definition' => $definitions, 'Magento\Stdlib\BooleanUtils' => $booleanUtils, + $configClass => $diConfig, )); $argFactory->setObjectManager($objectManager); @@ -122,25 +127,8 @@ class ObjectManagerFactory ); $objectManager->get('Magento\Config\ScopeInterface')->setCurrentScope('global'); $objectManager->get('Magento\App\Resource')->setCache($objectManager->get('Magento\App\CacheInterface')); - - $relations = $definitionFactory->createRelations(); - - $interceptionConfig = $objectManager->create('Magento\Interception\Config\Config', array( - 'relations' => $relations, - 'omConfig' => $diConfig, - 'classDefinitions' => $definitions instanceof \Magento\ObjectManager\Definition\Compiled - ? $definitions - : null, - )); - - $pluginList = $this->_createPluginList($objectManager, $relations, $definitionFactory, $diConfig, $definitions); - - $factory = $objectManager->create('Magento\Interception\FactoryDecorator', array( - 'factory' => $factory, - 'config' => $interceptionConfig, - 'pluginList' => $pluginList - )); - $objectManager->setFactory($factory); + $interceptionConfig = $objectManager->get('Magento\Interception\Config\Config'); + $diConfig->setInterceptionConfig($interceptionConfig); $this->configureDirectories($objectManager); diff --git a/lib/Magento/App/PageCache/Cache.php b/lib/Magento/App/PageCache/Cache.php new file mode 100644 index 00000000000..9aea75863c5 --- /dev/null +++ b/lib/Magento/App/PageCache/Cache.php @@ -0,0 +1,35 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\App\PageCache; + +/** + * Cache model for builtin cache + */ +class Cache extends \Magento\App\Cache +{ + /** + * @var string + */ + protected $_frontendIdentifier = 'page_cache'; +} diff --git a/lib/Magento/App/PageCache/Identifier.php b/lib/Magento/App/PageCache/Identifier.php new file mode 100644 index 00000000000..37c4c28a6b0 --- /dev/null +++ b/lib/Magento/App/PageCache/Identifier.php @@ -0,0 +1,54 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\App\PageCache; + +/** + * Page unique identifier + */ +class Identifier +{ + /** + * @var string + */ + protected $value; + + /** + * @param \Magento\App\Request\Http $request + */ + public function __construct(\Magento\App\Request\Http $request) + { + $data = array($request->getRequestUri(), $request->get(\Magento\App\Response\Http::COOKIE_VARY_STRING)); + $this->value = md5(serialize($data)); + } + + /** + * Return unique page identifier + * + * @return string + */ + public function getValue() + { + return $this->value; + } +} diff --git a/lib/Magento/App/PageCache/Kernel.php b/lib/Magento/App/PageCache/Kernel.php new file mode 100644 index 00000000000..46e747b6438 --- /dev/null +++ b/lib/Magento/App/PageCache/Kernel.php @@ -0,0 +1,97 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\App\PageCache; + +/** + * Builtin cache processor + */ +class Kernel +{ + /** + * @var Cache + */ + protected $cache; + + /** + * @var Identifier + */ + protected $identifier; + + /** + * @var \Magento\App\Request\Http + */ + protected $request; + + /** + * @param Cache $cache + * @param Identifier $identifier + * @param \Magento\App\Request\Http $request + */ + public function __construct( + \Magento\App\PageCache\Cache $cache, + \Magento\App\PageCache\Identifier $identifier, + \Magento\App\Request\Http $request + ) { + $this->cache = $cache; + $this->identifier = $identifier; + $this->request = $request; + } + + /** + * Load response from cache + * + * @return \Magento\App\Response\Http|false + */ + public function load() + { + if ($this->request->isGet() || $this->request->isHead()) { + return unserialize($this->cache->load($this->identifier->getValue())); + } + return false; + } + + /** + * Modify and cache application response + * + * @param \Magento\App\Response\Http $response + */ + public function process(\Magento\App\Response\Http $response) + { + if (preg_match('/public.*s-maxage=(\d+)/', $response->getHeader('Cache-Control')['value'], $matches)) { + $maxAge = $matches[1]; + $response->setNoCacheHeaders(); + if ($response->getHttpResponseCode() == 200 && ($this->request->isGet() || $this->request->isHead())) { + $tagsHeader = $response->getHeader('X-Magento-Tags'); + $tags = $tagsHeader ? explode(',', $tagsHeader['value']) : array(); + + $response->clearHeader('Set-Cookie'); + $response->clearHeader('X-Magento-Tags'); + if (!headers_sent()) { + header_remove('Set-Cookie'); + } + $this->cache->save(serialize($response), $this->identifier->getValue(), $tags, $maxAge); + } + } + } +} diff --git a/app/code/Magento/PageCache/Model/Version.php b/lib/Magento/App/PageCache/Version.php similarity index 74% rename from app/code/Magento/PageCache/Model/Version.php rename to lib/Magento/App/PageCache/Version.php index 4c54215b69f..6ea3841a3a9 100644 --- a/app/code/Magento/PageCache/Model/Version.php +++ b/lib/Magento/App/PageCache/Version.php @@ -23,14 +23,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\PageCache\Model; - -use Magento\App\Request\Http; -use Magento\Stdlib\Cookie; +namespace Magento\App\PageCache; /** * Class Version - * @package Magento\PageCache\Model + * + * @package Magento\App\PageCache */ class Version { @@ -47,45 +45,35 @@ class Version /** * Cookie * - * @var Cookie + * @var \Magento\Stdlib\Cookie */ - private $cookie; + protected $cookie; /** * Request * - * @var Http + * @var \Magento\App\Request\Http */ - private $request; + protected $request; /** - * @param Cookie $cookie - * @param Http $request + * @param \Magento\Stdlib\Cookie $cookie + * @param \Magento\App\Request\Http $request */ public function __construct( - Cookie $cookie, - Http $request + \Magento\Stdlib\Cookie $cookie, + \Magento\App\Request\Http $request ) { $this->cookie = $cookie; $this->request = $request; } - /** - * Increment private content version cookie (for user to pull new private content) - * - * @return void - */ - private function set() - { - $this->cookie->set(self::COOKIE_NAME, $this->generateValue(), self::COOKIE_PERIOD, '/'); - } - /** * Generate unique version identifier * * @return string */ - private function generateValue() + protected function generateValue() { return md5(rand() . time()); } @@ -101,7 +89,7 @@ class Version public function process() { if ($this->request->isPost()) { - $this->set(); + $this->cookie->set(self::COOKIE_NAME, $this->generateValue(), self::COOKIE_PERIOD, '/'); } } } diff --git a/lib/Magento/App/Request/Http.php b/lib/Magento/App/Request/Http.php index 2422c32c07e..75ed3c7c5ac 100644 --- a/lib/Magento/App/Request/Http.php +++ b/lib/Magento/App/Request/Http.php @@ -588,4 +588,12 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\App\Request $this->getRequestedControllerName() . $delimiter . $this->getRequestedActionName(); } + + /** + * @return array + */ + public function __sleep() + { + return array(); + } } diff --git a/lib/Magento/App/Response/Http.php b/lib/Magento/App/Response/Http.php index c898e46c57e..89e7e0ebaa9 100644 --- a/lib/Magento/App/Response/Http.php +++ b/lib/Magento/App/Response/Http.php @@ -33,11 +33,24 @@ class Http extends \Zend_Controller_Response_Http implements \Magento\App\Respon const COOKIE_VARY_STRING = 'X-Magento-Vary'; /** - * Response vary identifiers - * - * @var array + * @var \Magento\Stdlib\Cookie + */ + protected $cookie; + + /** + * @var \Magento\App\Http\Context + */ + protected $context; + + /** + * @param \Magento\Stdlib\Cookie $cookie + * @param \Magento\App\Http\Context $context */ - protected $vary; + public function __construct(\Magento\Stdlib\Cookie $cookie, \Magento\App\Http\Context $context) + { + $this->cookie = $cookie; + $this->context = $context; + } /** * Get header value by name. @@ -58,44 +71,76 @@ class Http extends \Zend_Controller_Response_Http implements \Magento\App\Respon } /** - * Set vary identifier - * - * @param string $name - * @param string|array $value - * @return $this + * Send Vary coookie */ - public function setVary($name, $value) + public function sendVary() { - if (is_array($value)) { - $value = serialize($value); + $data = array_filter($this->context->getData()); + if ($data) { + ksort($data); + $vary = sha1(serialize($data)); + $this->cookie->set(self::COOKIE_VARY_STRING, $vary, null, '/'); } - $this->vary[$name] = $value; - return $this; } /** * Send the response, including all headers, rendering exceptions if so * requested. - * - * @return void */ public function sendResponse() { - setcookie(self::COOKIE_VARY_STRING, $this->getVaryString(), null, '/'); + $this->sendVary(); parent::sendResponse(); } /** - * Returns hash of varies + * Set headers for public cache + * Accepts the time-to-live (max-age) parameter + * + * @param int $ttl + * @throws \InvalidArgumentException + */ + public function setPublicHeaders($ttl) + { + if (!$ttl) { + throw new \InvalidArgumentException('time to live is a mandatory parameter for set public headers'); + } + $this->setHeader('pragma', 'cache', true); + $this->setHeader('cache-control', 'public, max-age=' . $ttl . ', s-maxage=' . $ttl, true); + $this->setHeader('expires', gmdate('D, d M Y H:i:s T', strtotime('+' . $ttl . ' seconds')), true); + } + + /** + * Set headers for private cache * - * @return string + * @param int $ttl + * @throws \InvalidArgumentException */ - public function getVaryString() + public function setPrivateHeaders($ttl) { - if (!empty($this->vary)) { - ksort($this->vary); + if (!$ttl) { + throw new \InvalidArgumentException('time to live is a mandatory parameter for set private headers'); } + $this->setHeader('pragma', 'cache', true); + $this->setHeader('cache-control', 'private, max-age=' . $ttl, true); + $this->setHeader('expires', gmdate('D, d M Y H:i:s T', strtotime('+' . $ttl . ' seconds')), true); + } + + /** + * Set headers for no-cache responses + */ + public function setNoCacheHeaders() + { + $this->setHeader('pragma', 'no-cache', true); + $this->setHeader('cache-control', 'no-store, no-cache, must-revalidate, max-age=0', true); + $this->setHeader('expires', gmdate('D, d M Y H:i:s T', strtotime('-1 year')), true); + } - return sha1(serialize($this->vary)); + /** + * @return array + */ + public function __sleep() + { + return array('_body', '_exceptions', '_headers', '_headersRaw', '_httpResponseCode', 'context', 'cookie'); } } diff --git a/lib/Magento/App/View.php b/lib/Magento/App/View.php index 74d4ce8a7da..a63bf9a0b8a 100644 --- a/lib/Magento/App/View.php +++ b/lib/Magento/App/View.php @@ -301,4 +301,14 @@ class View implements ViewInterface { $this->_isLayoutLoaded = $value; } + + /** + * Returns is layout loaded + * + * @return bool + */ + public function isLayoutLoaded() + { + return $this->_isLayoutLoaded; + } } diff --git a/lib/Magento/App/ViewInterface.php b/lib/Magento/App/ViewInterface.php index 80c87c5da8b..dc8494e4ad0 100644 --- a/lib/Magento/App/ViewInterface.php +++ b/lib/Magento/App/ViewInterface.php @@ -102,4 +102,10 @@ interface ViewInterface */ public function setIsLayoutLoaded($value); + /** + * Returns is layout loaded + * + * @return bool + */ + public function isLayoutLoaded(); } diff --git a/lib/Magento/AppInterface.php b/lib/Magento/AppInterface.php index f9720856346..6eac71a6ef2 100644 --- a/lib/Magento/AppInterface.php +++ b/lib/Magento/AppInterface.php @@ -79,13 +79,6 @@ interface AppInterface */ public function getDistroLocaleCode(); - /** - * Retrieve application locale object - * - * @return \Magento\Core\Model\LocaleInterface - */ - public function getLocale(); - /** * Retrieve layout object * @@ -107,13 +100,6 @@ interface AppInterface */ public function getConfig(); - /** - * Retrieve front controller object - * - * @return \Magento\App\FrontController - */ - public function getFrontController(); - /** * Get core cache model * diff --git a/lib/Magento/Cache/Frontend/Decorator/Profiler.php b/lib/Magento/Cache/Frontend/Decorator/Profiler.php index 898ca3baa6d..f196362dad5 100644 --- a/lib/Magento/Cache/Frontend/Decorator/Profiler.php +++ b/lib/Magento/Cache/Frontend/Decorator/Profiler.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/lib/Magento/Code/Generator.php b/lib/Magento/Code/Generator.php index bac451c7f1d..e78b2a44848 100644 --- a/lib/Magento/Code/Generator.php +++ b/lib/Magento/Code/Generator.php @@ -32,11 +32,6 @@ class Generator const GENERATION_ERROR = 'error'; const GENERATION_SKIP = 'skip'; - /** - * @var \Magento\Code\Generator\EntityAbstract - */ - protected $_generator; - /** * @var \Magento\Autoload\IncludePath */ @@ -50,29 +45,24 @@ class Generator /** * @var string[] */ - protected $_generatedEntities = array( - \Magento\Code\Generator\Factory::ENTITY_TYPE, - \Magento\Code\Generator\Proxy::ENTITY_TYPE, - \Magento\Code\Generator\Interceptor::ENTITY_TYPE, - ); + protected $_generatedEntities; /** - * @param Generator\EntityAbstract $generator * @param \Magento\Autoload\IncludePath $autoloader * @param Generator\Io $ioObject - * @param \Magento\App\Filesystem $filesystem + * @param array $generatedEntities */ public function __construct( - \Magento\Code\Generator\EntityAbstract $generator = null, \Magento\Autoload\IncludePath $autoloader = null, \Magento\Code\Generator\Io $ioObject = null, - \Magento\App\Filesystem $filesystem = null + array $generatedEntities = array() ) { - //todo: remove $filesystem from constructor - $this->_generator = $generator; - $this->_autoloader = $autoloader ? : new \Magento\Autoload\IncludePath(); - $this->_ioObject = $ioObject ? : new \Magento\Code\Generator\Io( - new \Magento\Filesystem\Driver\File(), $this->_autoloader); + $this->_autoloader = $autoloader ? : new \Magento\Autoload\IncludePath(); + $this->_ioObject = $ioObject ? : new \Magento\Code\Generator\Io( + new \Magento\Filesystem\Driver\File(), + $this->_autoloader + ); + $this->_generatedEntities = $generatedEntities; } /** @@ -86,16 +76,19 @@ class Generator } /** + * Generate Class + * * @param string $className - * @return string const + * @return string * @throws \Magento\Exception + * @throws \InvalidArgumentException */ public function generateClass($className) { // check if source class a generated entity $entity = null; $entityName = null; - foreach ($this->_generatedEntities as $entityType) { + foreach ($this->_generatedEntities as $entityType => $generatorClass) { $entitySuffix = ucfirst($entityType); // if $className string ends on $entitySuffix substring if (strrpos($className, $entitySuffix) === strlen($className) - strlen($entitySuffix)) { @@ -115,55 +108,16 @@ class Generator return self::GENERATION_SKIP; } - // generate class file - $this->_initGenerator($entity, $entityName, $className); - if (!$this->_generator->generate()) { - $errors = $this->_generator->getErrors(); + if (!isset($this->_generatedEntities[$entity])) { + throw new \InvalidArgumentException('Unknown generation entity.'); + } + $generatorClass = $this->_generatedEntities[$entity]; + $generator = new $generatorClass($entityName, $className, $this->_ioObject); + if (!$generator->generate()) { + $errors = $generator->getErrors(); throw new \Magento\Exception(implode(' ', $errors)); } - // remove generator - $this->_generator = null; - return self::GENERATION_SUCCESS; } - - /** - * Get generator by entity type - * - * @param string $entity - * @param string $sourceClassName - * @param string $resultClassName - * @return \Magento\Code\Generator\EntityAbstract|\Magento\Code\Generator\Factory|\Magento\Code\Generator\Proxy - * @throws \InvalidArgumentException - */ - protected function _initGenerator($entity, $sourceClassName, $resultClassName) - { - if (!$this->_generator) { - switch ($entity) { - case \Magento\Code\Generator\Factory::ENTITY_TYPE: - $this->_generator = new \Magento\Code\Generator\Factory($sourceClassName, $resultClassName, - $this->_ioObject - ); - break; - case \Magento\Code\Generator\Proxy::ENTITY_TYPE: - $this->_generator = new \Magento\Code\Generator\Proxy($sourceClassName, $resultClassName, - $this->_ioObject - ); - break; - case \Magento\Code\Generator\Interceptor::ENTITY_TYPE: - $this->_generator = new \Magento\Code\Generator\Interceptor($sourceClassName, $resultClassName, - $this->_ioObject - ); - break; - default: - throw new \InvalidArgumentException('Unknown generation entity.'); - break; - } - } else { - $this->_generator->init($sourceClassName, $resultClassName); - } - - return $this->_generator; - } } diff --git a/lib/Magento/Code/Generator/Interceptor.php b/lib/Magento/Code/Generator/Interceptor.php deleted file mode 100644 index c78ff822a34..00000000000 --- a/lib/Magento/Code/Generator/Interceptor.php +++ /dev/null @@ -1,336 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Code - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Code\Generator; - -class Interceptor extends \Magento\Code\Generator\EntityAbstract -{ - /** - * Entity type - */ - const ENTITY_TYPE = 'interceptor'; - - /** - * @param string $modelClassName - * @return string - */ - protected function _getDefaultResultClassName($modelClassName) - { - return $modelClassName . '_' . ucfirst(static::ENTITY_TYPE); - } - - /** - * Returns list of properties for class generator - * - * @return array - */ - protected function _getClassProperties() - { - return array( - array( - 'name' => '_factory', - 'visibility' => 'protected', - 'docblock' => array( - 'shortDescription' => 'Object Manager factory', - 'tags' => array( - array('name' => 'var', 'description' => '\Magento\ObjectManager\Factory') - ) - ), - ), - array( - 'name' => '_objectManager', - 'visibility' => 'protected', - 'docblock' => array( - 'shortDescription' => 'Object Manager instance', - 'tags' => array( - array('name' => 'var', 'description' => '\Magento\ObjectManager') - ) - ), - ), - array( - 'name' => '_subjectType', - 'visibility' => 'protected', - 'docblock' => array( - 'shortDescription' => 'Subject type', - 'tags' => array( - array('name' => 'var', 'description' => 'string') - ) - ), - ), - array( - 'name' => '_subject', - 'visibility' => 'protected', - 'docblock' => array( - 'shortDescription' => 'Subject', - 'tags' => array( - array('name' => 'var', 'description' => '\\' . $this->_getSourceClassName()) - ) - ), - ), - array( - 'name' => '_pluginList', - 'visibility' => 'protected', - 'docblock' => array( - 'shortDescription' => 'List of plugins', - 'tags' => array( - array('name' => 'var', 'description' => '\Magento\Interception\PluginList') - ) - ), - ), - array( - 'name' => '_arguments', - 'visibility' => 'protected', - 'docblock' => array( - 'shortDescription' => 'Subject constructor arguments', - 'tags' => array( - array('name' => 'var', 'description' => 'array') - ) - ), - ), - ); - } - - /** - * Get default constructor definition for generated class - * - * @return array - */ - protected function _getDefaultConstructorDefinition() - { - return array( - 'name' => '__construct', - 'parameters' => array( - array('name' => 'factory', 'type' => '\Magento\ObjectManager\Factory'), - array('name' => 'objectManager', 'type' => '\Magento\ObjectManager\ObjectManager'), - array('name' => 'subjectType'), - array('name' => 'pluginList', 'type' => '\Magento\Interception\PluginList'), - array('name' => 'arguments', 'type' => 'array'), - ), - 'body' => "\$this->_factory = \$factory;" - . "\n\$this->_objectManager = \$objectManager;" - . "\n\$this->_subjectType = \$subjectType;" - . "\n\$this->_pluginList = \$pluginList;" - . "\n\$this->_arguments = \$arguments;", - 'docblock' => array( - 'shortDescription' => 'Interceptor constructor', - 'tags' => array( - array( - 'name' => 'param', - 'description' => '\Magento\ObjectManager\Factory $factory', - ), - array( - 'name' => 'param', - 'description' => '\Magento\ObjectManager\ObjectManager $objectManager', - ), - array( - 'name' => 'param', - 'description' => 'string $subjectType', - ), - array( - 'name' => 'param', - 'description' => '\Magento\Interception\PluginList $pluginList', - ), - array( - 'name' => 'param', - 'description' => 'array $arguments', - ), - ), - ), - ); - } - - /** - * Returns list of methods for class generator - * - * @return array - */ - protected function _getClassMethods() - { - $methods = array($this->_getDefaultConstructorDefinition()); - $methods[] = array( - 'name' => '_getSubject', - 'visibility' => 'protected', - 'body' => 'if (is_null($this->_subject)) {' - . "\n \$this->_subject = \$this->_factory->create(\$this->_subjectType, \$this->_arguments);" - . "\n}" - . "\nreturn \$this->_subject;", - 'docblock' => array( - 'shortDescription' => 'Retrieve subject', - 'tags' => array( - array('name' => 'return', 'description' => 'mixed'), - ) - ), - ); - $methods[] = array( - 'name'=> '_invoke', - 'visibility' => 'protected', - 'parameters' => array( - array('name' => 'methodName'), - array('name' => 'methodArguments', 'type' => 'array'), - ), - 'body' => $this->_getInvokeMethodBody(), - 'docblock' => array( - 'shortDescription' => 'Invoke method', - 'tags' => array( - array('name' => 'param', 'description' => 'string $methodName'), - array('name' => 'param', 'description' => 'array $methodArguments'), - array('name' => 'return', 'description' => 'mixed'), - ), - ), - ); - $methods[] = array( - 'name' => '__sleep', - 'body' => "\$this->_getSubject();\nreturn array('_subject', '_subjectType');", - 'docblock' => array( - 'tags' => array( - array( - 'name' => 'return', 'description' => 'array', - ) - ), - ), - ); - $methods[] = array( - 'name' => '__clone', - 'body' => "\$this->_subject = clone \$this->_getSubject();", - 'docblock' => array( - 'shortDescription' => 'Clone subject instance', - ), - ); - $methods[] = array( - 'name' => '__wakeup', - 'docblock' => array( - 'shortDescription' => 'Retrieve ObjectManager from the global scope', - ), - 'body' => '$this->_objectManager = \Magento\App\ObjectManager::getInstance();' - . "\n\$this->_pluginList = \$this->_objectManager->get('Magento\Interception\PluginList');", - ); - - $reflectionClass = new \ReflectionClass($this->_getSourceClassName()); - $publicMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC); - foreach ($publicMethods as $method) { - if (!($method->isConstructor() || $method->isFinal() || $method->isStatic() || $method->isDestructor()) - && !in_array($method->getName(), array('__sleep', '__wakeup', '__clone')) - ) { - $methods[] = $this->_getMethodInfo($method); - } - } - - return $methods; - } - - /** - * Retrieve body of the _invoke method - * - * @return string - */ - protected function _getInvokeMethodBody() - { - return "\$beforeMethodName = 'before' . \$methodName;" - . "\nforeach (\$this->_pluginList->getPlugins(\$this->_subjectType, \$methodName, 'before') as \$plugin) {" - . "\n \$methodArguments = \$this->_objectManager->get(\$plugin)" - . "\n ->\$beforeMethodName(\$methodArguments);" - . "\n}" - . "\n\$invocationChain = new \Magento\Code\Plugin\InvocationChain(" - . "\n \$this->_getSubject()," - . "\n \$methodName," - . "\n \$this->_objectManager," - . "\n \$this->_pluginList->getPlugins(\$this->_subjectType, \$methodName, 'around')" - . "\n);" - . "\n\$invocationResult = \$invocationChain->proceed(\$methodArguments);" - . "\n\$afterMethodName = 'after' . \$methodName;" - . "\n\$afterPlugins = array_reverse(" - . "\n \$this->_pluginList->getPlugins(\$this->_subjectType, \$methodName, 'after')" - . "\n);" - . "\nforeach (\$afterPlugins as \$plugin) {" - . "\n \$invocationResult = \$this->_objectManager->get(\$plugin)" - . "\n ->\$afterMethodName(\$invocationResult);" - . "\n}" - . "\nreturn \$invocationResult;"; - } - - /** - * Retrieve method info - * - * @param \ReflectionMethod $method - * @return array - */ - protected function _getMethodInfo(\ReflectionMethod $method) - { - $parameters = array(); - foreach ($method->getParameters() as $parameter) { - $parameters[] = $this->_getMethodParameterInfo($parameter); - } - - $methodInfo = array( - 'name' => $method->getName(), - 'parameters' => $parameters, - 'body' => "return \$this->_invoke('{$method->getName()}', func_get_args());", - 'docblock' => array( - 'shortDescription' => '{@inheritdoc}', - ), - ); - - return $methodInfo; - } - - /** - * Generate resulting class source code - * - * @return string - */ - protected function _generateCode() - { - $typeName = $this->_getFullyQualifiedClassName($this->_getSourceClassName()); - $reflection = new \ReflectionClass($typeName); - - if ($reflection->isInterface()) { - $this->_classGenerator->setImplementedInterfaces(array($typeName)); - } else { - $this->_classGenerator->setExtendedClass($typeName); - } - return parent::_generateCode(); - } - - /** - * {@inheritdoc} - */ - protected function _validateData() - { - $result = parent::_validateData(); - - if ($result) { - $sourceClassName = $this->_getSourceClassName(); - $resultClassName = $this->_getResultClassName(); - - if ($resultClassName !== $sourceClassName . '\\Interceptor') { - $this->_addError('Invalid Interceptor class name [' - . $resultClassName . ']. Use ' . $sourceClassName . '\\Interceptor' - ); - $result = false; - } - } - return $result; - } -} diff --git a/lib/Magento/Code/Plugin/InvocationChain.php b/lib/Magento/Code/Plugin/InvocationChain.php deleted file mode 100644 index 78c9427b90d..00000000000 --- a/lib/Magento/Code/Plugin/InvocationChain.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @category Magento - * @package Magento_Code - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Code\Plugin; - -class InvocationChain -{ - /** - * Original instance whose behavior is decorated by plugins - * - * @var mixed - */ - protected $_subject; - - /** - * Name of the method to invoke - * - * @var string - */ - protected $_methodName; - - /** - * @var \Magento\ObjectManager - */ - protected $_objectManager; - - /** - * List of the plugins - * - * @var array - */ - protected $_pluginList; - - /** - * @param mixed $subject - * @param string $methodName - * @param \Magento\ObjectManager $objectManager - * @param array $pluginList - */ - public function __construct($subject, $methodName, \Magento\ObjectManager $objectManager, array $pluginList) - { - $this->_subject = $subject; - $this->_methodName = $methodName; - $this->_objectManager = $objectManager; - $this->_pluginList = $pluginList; - } - - /** - * Propagate invocation through the chain - * - * @param array $arguments - * @return mixed - */ - public function proceed(array $arguments) - { - if (count($this->_pluginList)) { - $aroundMethodName = 'around' . ucfirst($this->_methodName); - return $this->_objectManager->get(array_shift($this->_pluginList))->$aroundMethodName($arguments, $this); - } - return call_user_func_array(array($this->_subject, $this->_methodName), $arguments); - } -} diff --git a/lib/Magento/Connect/Frontend/CLI.php b/lib/Magento/Connect/Frontend/CLI.php index 41497c13052..5f0c8e18145 100644 --- a/lib/Magento/Connect/Frontend/CLI.php +++ b/lib/Magento/Connect/Frontend/CLI.php @@ -103,7 +103,7 @@ extends \Magento\Connect\Frontend $methodMap = array( 'list-upgrades'=> 'outputUpgrades', 'list-available' => 'outputChannelsPackages', - 'list-installed' => 'writeInstalledList', + 'list-installed' => 'writeInstalledList', 'package-dependencies' => 'outputPackageDeps', 'list-files' => 'outputPackageContents', 'config-help' => 'outputConfigHelp', @@ -129,9 +129,9 @@ extends \Magento\Connect\Frontend public function outputDeleted($data) { if(!count($data['data'])) { - return; - } - $this->writeln($data['title']); + return; + } + $this->writeln($data['title']); foreach($data['data'] as $row) { $this->writeln("$row[0]/$row[1]"); } @@ -154,7 +154,7 @@ extends \Magento\Connect\Frontend $this->writeln(); $this->writeln($data['title_aliases']); foreach($aliases as $k=>$v) { - $this->writeln("$k => $v"); + $this->writeln("$k => $v"); } } @@ -324,7 +324,7 @@ extends \Magento\Connect\Frontend foreach($data['data'] as $channel=>$packages) { $title = sprintf($data['channel-title'], $channel); $c = count($packages); - $totalCount += $c; + $totalCount += $c; if(!$c) { continue; } @@ -419,7 +419,7 @@ extends \Magento\Connect\Frontend if($this->isSilent()) { return; } - print $data; + echo $data; } /** diff --git a/lib/Magento/Css/PreProcessor/Cache/Plugin/ImportCleaner.php b/lib/Magento/Css/PreProcessor/Cache/Plugin/ImportCleaner.php index 907009d48bb..59c66d0b969 100644 --- a/lib/Magento/Css/PreProcessor/Cache/Plugin/ImportCleaner.php +++ b/lib/Magento/Css/PreProcessor/Cache/Plugin/ImportCleaner.php @@ -47,12 +47,13 @@ class ImportCleaner } /** - * @param array $arguments - * @return array + * @param \Magento\View\Asset\MergeService $subject + * + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeCleanMergedJsCss(array $arguments) + public function beforeCleanMergedJsCss(\Magento\View\Asset\MergeService $subject) { $this->importStorage->clearMaps(); - return $arguments; } } diff --git a/lib/Magento/Css/PreProcessor/Cache/Plugin/InstructionPreProcessor.php b/lib/Magento/Css/PreProcessor/Cache/Plugin/InstructionPreProcessor.php index 73123813ed6..14eedf527eb 100644 --- a/lib/Magento/Css/PreProcessor/Cache/Plugin/InstructionPreProcessor.php +++ b/lib/Magento/Css/PreProcessor/Cache/Plugin/InstructionPreProcessor.php @@ -48,14 +48,18 @@ class InstructionPreProcessor /** * Add to cache all pre-processed files that are related to initial less file * - * @param \Magento\Less\PreProcessor\File\FileList $fileList - * @return \Magento\Less\PreProcessor\File\FileList + * @param \Magento\Less\PreProcessor $subject + * @param array $fileList + * + * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterProcessLessInstructions($fileList) + public function afterProcessLessInstructions(\Magento\Less\PreProcessor $subject, $fileList) { foreach ($fileList as $lessFile) { $this->cacheManager->addToCache(Cache::IMPORT_CACHE, $lessFile); } + return $fileList; } } diff --git a/lib/Magento/Css/PreProcessor/Cache/Plugin/Less.php b/lib/Magento/Css/PreProcessor/Cache/Plugin/Less.php index fe1d56eacb6..8435a2857a2 100644 --- a/lib/Magento/Css/PreProcessor/Cache/Plugin/Less.php +++ b/lib/Magento/Css/PreProcessor/Cache/Plugin/Less.php @@ -56,20 +56,25 @@ class Less } /** - * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain - * @return string|null + * @param \Magento\Css\PreProcessor\Less $subject + * @param \Closure $proceed + * @param \Magento\View\Publisher\FileInterface $publisherFile + * @param string $targetDirectory + * + * @return \Magento\View\Publisher\FileInterface|null|string + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundProcess(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) - { - /** @var \Magento\View\Publisher\CssFile $publicationFile */ - $publicationFile = $arguments[0]; - - if ($publicationFile->getSourcePath()) { - return $invocationChain->proceed($arguments); + public function aroundProcess( + \Magento\Css\PreProcessor\Less $subject, + \Closure $proceed, + \Magento\View\Publisher\FileInterface $publisherFile, + $targetDirectory + ) { + if ($publisherFile->getSourcePath()) { + return $proceed($publisherFile, $targetDirectory); } - $this->cacheManager->initializeCacheByType(Cache::IMPORT_CACHE, $publicationFile); + $this->cacheManager->initializeCacheByType(Cache::IMPORT_CACHE, $publisherFile); $cachedFile = $this->cacheManager->getCachedFile(Cache::IMPORT_CACHE); if ($cachedFile instanceof \Magento\View\Publisher\FileInterface) { @@ -78,7 +83,7 @@ class Less try { /** @var \Magento\View\Publisher\FileInterface $result */ - $result = $invocationChain->proceed($arguments); + $result = $proceed($publisherFile, $targetDirectory); $this->cacheManager->saveCache(Cache::IMPORT_CACHE, $result); } catch (Filesystem\FilesystemException $e) { $this->logger->logException($e); diff --git a/lib/Magento/Interception/CodeGenerator.php b/lib/Magento/Currency.php similarity index 63% rename from lib/Magento/Interception/CodeGenerator.php rename to lib/Magento/Currency.php index 34624b23142..24bbbe975f3 100644 --- a/lib/Magento/Interception/CodeGenerator.php +++ b/lib/Magento/Currency.php @@ -1,7 +1,5 @@ <?php /** - * Interceptor class generator - * * Magento * * NOTICE OF LICENSE @@ -20,17 +18,12 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Interception; -interface CodeGenerator +namespace Magento; + +class Currency extends \Zend_Currency implements \Magento\CurrencyInterface { - /** - * Generate interceptor class name - * - * @param string $interceptorClassName - */ - public function generate($interceptorClassName); } diff --git a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespaceFactory.php b/lib/Magento/CurrencyFactory.php similarity index 70% rename from dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespaceFactory.php rename to lib/Magento/CurrencyFactory.php index 0148755ddb3..c5188457fe0 100644 --- a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceClassWithoutNamespaceFactory.php +++ b/lib/Magento/CurrencyFactory.php @@ -1,7 +1,5 @@ <?php /** - * Factory class for \Magento\Code\GeneratorTest\SourceClassWithoutNamespace - * * Magento * * NOTICE OF LICENSE @@ -20,36 +18,31 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Code\GeneratorTest; -class SourceClassWithoutNamespaceFactory +namespace Magento; + +class CurrencyFactory { /** - * Object Manager instance - * * @var \Magento\ObjectManager */ protected $_objectManager = null; /** - * Instance name to create - * * @var string */ protected $_instanceName = null; /** - * Factory constructor - * * @param \Magento\ObjectManager $objectManager * @param string $instanceName */ public function __construct( \Magento\ObjectManager $objectManager, - $instanceName = 'Magento\Code\GeneratorTest\SourceClassWithoutNamespace' + $instanceName = 'Magento\CurrencyInterface' ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; @@ -59,7 +52,7 @@ class SourceClassWithoutNamespaceFactory * Create class instance with specified parameters * * @param array $data - * @return \Magento\Code\GeneratorTest\SourceClassWithoutNamespace + * @return \Magento\CurrencyInterface */ public function create(array $data = array()) { diff --git a/lib/Magento/CurrencyInterface.php b/lib/Magento/CurrencyInterface.php new file mode 100644 index 00000000000..59e80f76bce --- /dev/null +++ b/lib/Magento/CurrencyInterface.php @@ -0,0 +1,268 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento; + +interface CurrencyInterface +{ + + /** + * Returns a localized currency string + * + * @param integer|float $value OPTIONAL Currency value + * @param array $options OPTIONAL options to set temporary + * @throws \Zend_Currency_Exception When the value is not a number + * @return string + */ + public function toCurrency($value = null, array $options = array()); + + /** + * Sets the formating options of the localized currency string + * If no parameter is passed, the standard setting of the + * actual set locale will be used + * + * @param array $options (Optional) Options to set + * @return \Magento\CurrencyInterface + */ + public function setFormat(array $options = array()); + + /** + * Returns the actual or details of other currency symbols, + * when no symbol is available it returns the currency shortname (f.e. FIM for Finnian Mark) + * + * @param string $currency (Optional) Currency name + * @param string|\Magento\Locale $locale (Optional) Locale to display informations + * @return string + */ + public function getSymbol($currency = null, $locale = null); + + /** + * Returns the actual or details of other currency shortnames + * + * @param string $currency OPTIONAL Currency's name + * @param string|\Magento\Locale $locale OPTIONAL The locale + * @return string + */ + public function getShortName($currency = null, $locale = null); + + /** + * Returns the actual or details of other currency names + * + * @param string $currency (Optional) Currency's short name + * @param string|\Magento\Locale $locale (Optional) The locale + * @return string + */ + public function getName($currency = null, $locale = null); + + /** + * Returns a list of regions where this currency is or was known + * + * @param string $currency OPTIONAL Currency's short name + * @throws \Zend_Currency_Exception When no currency was defined + * @return array List of regions + */ + public function getRegionList($currency = null); + + /** + * Returns a list of currencies which are used in this region + * a region name should be 2 charachters only (f.e. EG, DE, US) + * If no region is given, the actual region is used + * + * @param string $region OPTIONAL Region to return the currencies for + * @return array List of currencies + */ + public function getCurrencyList($region = null); + + /** + * Returns the actual currency name + * + * @return string + */ + public function toString(); + + /** + * Returns the set cache + * + * @return \Zend_Cache_Core The set cache + */ + public static function getCache(); + + /** + * Sets a cache for \Magento\Currency + * + * @param \Zend_Cache_Core $cache Cache to set + * @return void + */ + public static function setCache(\Zend_Cache_Core $cache); + + /** + * Returns true when a cache is set + * + * @return boolean + */ + public static function hasCache(); + + /** + * Removes any set cache + * + * @return void + */ + public static function removeCache(); + /** + * Clears all set cache data + * + * @param string $tag Tag to clear when the default tag name is not used + * @return void + */ + public static function clearCache($tag = null); + + /** + * Sets a new locale for data retrievement + * Example: 'de_XX' will be set to 'de' because 'de_XX' does not exist + * 'xx_YY' will be set to 'root' because 'xx' does not exist + * + * @param string|\Magento\Locale $locale (Optional) Locale for parsing input + * @throws \Zend_Currency_Exception When the given locale does not exist + * @return $this + */ + public function setLocale($locale = null); + + /** + * Returns the actual set locale + * + * @return string + */ + public function getLocale(); + /** + * Returns the value + * + * @return float + */ + public function getValue(); + + /** + * Adds a currency + * + * @param float|integer|\Magento\CurrencyInterface $value Add this value to currency + * @param string|\Magento\CurrencyInterface $currency The currency to add + * @return \Magento\CurrencyInterface + */ + public function setValue($value, $currency = null); + + /** + * Adds a currency + * + * @param float|integer|\Magento\CurrencyInterface $value Add this value to currency + * @param string|\Magento\CurrencyInterface $currency The currency to add + * @return \Magento\CurrencyInterface + */ + public function add($value, $currency = null); + + /** + * Substracts a currency + * + * @param float|integer|\Magento\CurrencyInterface $value Substracts this value from currency + * @param string|\Magento\CurrencyInterface $currency The currency to substract + * @return \Magento\CurrencyInterface + */ + public function sub($value, $currency = null); + + /** + * Divides a currency + * + * @param float|integer|\Magento\CurrencyInterface $value Divides this value from currency + * @param string|\Magento\CurrencyInterface $currency The currency to divide + * @return \Magento\CurrencyInterface + */ + public function div($value, $currency = null); + + /** + * Multiplies a currency + * + * @param float|integer|\Magento\CurrencyInterface $value Multiplies this value from currency + * @param string|\Magento\CurrencyInterface $currency The currency to multiply + * @return \Magento\CurrencyInterface + */ + public function mul($value, $currency = null); + + /** + * Calculates the modulo from a currency + * + * @param float|integer|\Magento\CurrencyInterface $value Calculate modulo from this value + * @param string|\Magento\CurrencyInterface $currency The currency to calculate the modulo + * @return \Magento\CurrencyInterface + */ + public function mod($value, $currency = null); + + /** + * Compares two currencies + * + * @param float|integer|\Magento\CurrencyInterface $value Compares the currency with this value + * @param string|\Magento\CurrencyInterface $currency The currency to compare this value from + * @return \Magento\CurrencyInterface + */ + public function compare($value, $currency = null); + + /** + * Returns true when the two currencies are equal + * + * @param float|integer|\Magento\CurrencyInterface $value Compares the currency with this value + * @param string|\Magento\CurrencyInterface $currency The currency to compare this value from + * @return boolean + */ + public function equals($value, $currency = null); + + /** + * Returns true when the currency is more than the given value + * + * @param float|integer|\Magento\CurrencyInterface $value Compares the currency with this value + * @param string|\Magento\CurrencyInterface $currency The currency to compare this value from + * @return boolean + */ + public function isMore($value, $currency = null); + + /** + * Returns true when the currency is less than the given value + * + * @param float|integer|\Magento\CurrencyInterface $value Compares the currency with this value + * @param string|\Magento\CurrencyInterface $currency The currency to compare this value from + * @return boolean + */ + public function isLess($value, $currency = null); + + /** + * Returns the set service class + * + * @return \Zend_Service + */ + public function getService(); + + /** + * Sets a new exchange service + * + * @param string|\Magento\CurrencyInterface_CurrencyInterface $service Service class + * @return \Magento\CurrencyInterface + */ + public function setService($service); +} diff --git a/lib/Magento/DB/Adapter/AdapterInterface.php b/lib/Magento/DB/Adapter/AdapterInterface.php index af6317b2ce3..c44d6b4cace 100644 --- a/lib/Magento/DB/Adapter/AdapterInterface.php +++ b/lib/Magento/DB/Adapter/AdapterInterface.php @@ -661,7 +661,7 @@ interface AdapterInterface /** * Format Date to internal database date format * - * @param int|string|Zend_Date $date + * @param int|string|\Magento\Stdlib\DateTime\DateInterface $date * @param boolean $includeTime * @return \Zend_Db_Expr */ diff --git a/lib/Magento/DB/Adapter/Pdo/Mysql.php b/lib/Magento/DB/Adapter/Pdo/Mysql.php index 9e89b0b9f07..7d2d4040ae8 100644 --- a/lib/Magento/DB/Adapter/Pdo/Mysql.php +++ b/lib/Magento/DB/Adapter/Pdo/Mysql.php @@ -331,7 +331,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface /** * Convert date to DB format * - * @param int|string|\Zend_Date $date + * @param int|string|\Magento\Stdlib\DateTime\DateInterface $date * @return \Zend_Db_Expr */ public function convertDate($date) @@ -342,7 +342,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface /** * Convert date and time to DB format * - * @param int|string|\Zend_Date $datetime + * @param int|string|\Magento\Stdlib\DateTime\DateInterface $datetime * @return \Zend_Db_Expr */ public function convertDateTime($datetime) @@ -2694,7 +2694,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface /** * Format Date to internal database date format * - * @param int|string|\Zend_Date $date + * @param int|string|\Magento\Stdlib\DateTime\DateInterface $date * @param bool $includeTime * @return \Zend_Db_Expr */ diff --git a/lib/Magento/Data/Form/Element/Date.php b/lib/Magento/Data/Form/Element/Date.php index 3abff8db747..66d6eea82f3 100644 --- a/lib/Magento/Data/Form/Element/Date.php +++ b/lib/Magento/Data/Form/Element/Date.php @@ -39,7 +39,7 @@ use Magento\Stdlib\DateTime; class Date extends AbstractElement { /** - * @var \Zend_Date + * @var \Magento\Stdlib\DateTime\Date */ protected $_value; @@ -84,8 +84,8 @@ class Date extends AbstractElement /** * Set date value - * If \Zend_Date instance is provided instead of value, other params will be ignored. - * Format and locale must be compatible with \Zend_Date + * If \Magento\Stdlib\DateTime\Date instance is provided instead of value, other params will be ignored. + * Format and locale must be compatible with \Magento\Stdlib\DateTime\Date * * @param mixed $value * @param string $format @@ -98,13 +98,13 @@ class Date extends AbstractElement $this->_value = ''; return $this; } - if ($value instanceof \Zend_Date) { + if ($value instanceof \Magento\Stdlib\DateTime\DateInterface) { $this->_value = $value; return $this; } if (preg_match('/^[0-9]+$/', $value)) { - $this->_value = new \Zend_Date($this->_toTimestamp($value)); - //$this->_value = new \Zend_Date((int)value); + $this->_value = new \Magento\Stdlib\DateTime\Date($this->_toTimestamp($value)); + //$this->_value = new \Magento\Stdlib\DateTime\Date((int)value); return $this; } // last check, if input format was set @@ -121,7 +121,7 @@ class Date extends AbstractElement } } try { - $this->_value = new \Zend_Date($value, $format, $locale); + $this->_value = new \Magento\Stdlib\DateTime\Date($value, $format, $locale); } catch (\Exception $e) { $this->_value = ''; } @@ -132,7 +132,7 @@ class Date extends AbstractElement * Get date value as string. * Format can be specified, or it will be taken from $this->getFormat() * - * @param string $format (compatible with \Zend_Date) + * @param string $format (compatible with \Magento\Stdlib\DateTime\Date * @return string */ public function getValue($format = null) @@ -149,7 +149,7 @@ class Date extends AbstractElement /** * Get value instance, if any * - * @return \Zend_Date + * @return \Magento\Stdlib\DateTime\Date */ public function getValueInstance() { @@ -162,8 +162,8 @@ class Date extends AbstractElement /** * Output the input field and assign calendar instance to it. * In order to output the date: - * - the value must be instantiated (\Zend_Date) - * - output format must be set (compatible with \Zend_Date) + * - the value must be instantiated (\Magento\Stdlib\DateTime\Date) + * - output format must be set (compatible with \Magento\Stdlib\DateTime\Date) * * @throws \Exception * @return string diff --git a/lib/Magento/Data/Form/Filter/Date.php b/lib/Magento/Data/Form/Filter/Date.php index 0cbcb0cecd7..47c192455ff 100644 --- a/lib/Magento/Data/Form/Filter/Date.php +++ b/lib/Magento/Data/Form/Filter/Date.php @@ -53,7 +53,7 @@ class Date implements \Magento\Data\Form\Filter\FilterInterface /** * Initialize filter * - * @param string $format \Zend_Date input/output format + * @param string $format \Magento\Stdlib\DateTime\Date input/output format * @param \Zend_Locale $locale */ public function __construct($format = null, $locale = null) diff --git a/lib/Magento/Encryption/Encryptor.php b/lib/Magento/Encryption/Encryptor.php index 6ec40339e5c..866a7ce9a5f 100644 --- a/lib/Magento/Encryption/Encryptor.php +++ b/lib/Magento/Encryption/Encryptor.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -36,6 +34,11 @@ class Encryptor implements EncryptorInterface */ const PARAM_CRYPT_KEY = 'crypt.key'; + /** + * Default length of salt in bytes + */ + const DEFAULT_SALT_LENGTH = 32; + /** * @var \Magento\Math\Random */ @@ -77,9 +80,10 @@ class Encryptor implements EncryptorInterface * Generate a [salted] hash. * * $salt can be: - * false - a random will be generated - * integer - a random with specified length will be generated - * string + * false - salt is not used + * true - random salt of the default length will be generated + * integer - random salt of specified length will be generated + * string - actual salt value to be used * * @param string $password * @param bool|int|string $salt @@ -87,10 +91,16 @@ class Encryptor implements EncryptorInterface */ public function getHash($password, $salt = false) { + if ($salt === false) { + return $this->hash($password); + } + if ($salt === true) { + $salt = self::DEFAULT_SALT_LENGTH; + } if (is_integer($salt)) { $salt = $this->_randomGenerator->getRandomString($salt); } - return $salt === false ? $this->hash($password) : $this->hash($salt . $password) . ':' . $salt; + return $this->hash($salt . $password) . ':' . $salt; } /** @@ -158,7 +168,7 @@ class Encryptor implements EncryptorInterface /** * Return crypt model, instantiate if it is empty * - * @param string $key + * @param string|null $key NULL value means usage of the default key specified on constructor * @return \Magento\Encryption\Crypt */ public function validateKey($key) @@ -169,7 +179,7 @@ class Encryptor implements EncryptorInterface /** * Instantiate crypt model * - * @param string $key + * @param string|null $key NULL value means usage of the default key specified on constructor * @return \Magento\Encryption\Crypt */ protected function _getCrypt($key = null) diff --git a/lib/Magento/Encryption/EncryptorInterface.php b/lib/Magento/Encryption/EncryptorInterface.php index 400d51c7038..ac675880f46 100644 --- a/lib/Magento/Encryption/EncryptorInterface.php +++ b/lib/Magento/Encryption/EncryptorInterface.php @@ -32,12 +32,13 @@ interface EncryptorInterface * Generate a [salted] hash. * * $salt can be: - * false - a random will be generated - * integer - a random with specified length will be generated - * string + * false - salt is not used + * true - random salt of the default length will be generated + * integer - random salt of specified length will be generated + * string - actual salt value to be used * * @param string $password - * @param mixed $salt + * @param bool|int|string $salt * @return string */ public function getHash($password, $salt = false); diff --git a/lib/Magento/Error/Handler.php b/lib/Magento/Error/Handler.php index 0c3bdc9251a..796af8e668d 100644 --- a/lib/Magento/Error/Handler.php +++ b/lib/Magento/Error/Handler.php @@ -61,10 +61,10 @@ class Handler implements HandlerInterface */ public function processException(\Exception $exception, array $params = array()) { - print '<pre>'; - print $exception->getMessage() . "\n\n"; - print $exception->getTraceAsString(); - print '</pre>'; + echo '<pre>'; + echo $exception->getMessage() . "\n\n"; + echo $exception->getTraceAsString(); + echo '</pre>'; } /** diff --git a/lib/Magento/HTTP/Adapter/Curl.php b/lib/Magento/HTTP/Adapter/Curl.php index 2ad0fe5b1b4..6184d890726 100644 --- a/lib/Magento/HTTP/Adapter/Curl.php +++ b/lib/Magento/HTTP/Adapter/Curl.php @@ -76,15 +76,15 @@ class Curl implements \Zend_Http_Client_Adapter_Interface */ protected function _applyConfig() { - if (empty($this->_config)) { - return $this; - } - // apply additional options to cURL foreach ($this->_options as $option => $value) { curl_setopt($this->_getResource(), $option, $value); } + if (empty($this->_config)) { + return $this; + } + $verifyPeer = isset($this->_config['verifypeer']) ? $this->_config['verifypeer'] : true; curl_setopt($this->_getResource(), CURLOPT_SSL_VERIFYPEER, $verifyPeer); diff --git a/lib/Magento/Image/AdapterFactory.php b/lib/Magento/Image/AdapterFactory.php index 8626382efc1..f3fe3a7b75a 100644 --- a/lib/Magento/Image/AdapterFactory.php +++ b/lib/Magento/Image/AdapterFactory.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/lib/Magento/Interception/Chain.php b/lib/Magento/Interception/Chain.php new file mode 100644 index 00000000000..c46ebcaba78 --- /dev/null +++ b/lib/Magento/Interception/Chain.php @@ -0,0 +1,38 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Interception; + +interface Chain +{ + /** + * @param string $type + * @param string $method + * @param string $subject + * @param array $arguments + * @param string $previousPluginCode + * @return mixed + */ + public function invokeNext($type, $method, $subject, array $arguments, $previousPluginCode = null); +} diff --git a/lib/Magento/Interception/Chain/Chain.php b/lib/Magento/Interception/Chain/Chain.php new file mode 100644 index 00000000000..970f0d1191a --- /dev/null +++ b/lib/Magento/Interception/Chain/Chain.php @@ -0,0 +1,91 @@ +<?php +/** + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Interception\Chain; + +use Magento\Interception\Definition; +use Magento\Interception\PluginList; + +class Chain implements \Magento\Interception\Chain +{ + /** + * @var \Magento\Interception\PluginList + */ + protected $pluginList; + + /** + * @param PluginList $pluginList + */ + public function __construct(PluginList $pluginList) + { + $this->pluginList = $pluginList; + } + + /** + * Invoke next plugin in chain + * + * @param string $type + * @param string $method + * @param string $previousPluginCode + * @param $subject + * @param $arguments + * @return mixed|void + */ + public function invokeNext($type, $method, $subject, array $arguments, $previousPluginCode = null) + { + $pluginInfo = $this->pluginList->getNext($type, $method, $previousPluginCode); + $capMethod = ucfirst($method); + $result = null; + if (isset($pluginInfo[Definition::LISTENER_BEFORE])) { + foreach ($pluginInfo[Definition::LISTENER_BEFORE] as $code) { + $beforeResult = call_user_func_array( + array($this->pluginList->getPlugin($type, $code), 'before' . $capMethod), + array_merge(array($subject), $arguments) + ); + if ($beforeResult) { + $arguments = $beforeResult; + } + } + } + if (isset($pluginInfo[Definition::LISTENER_AROUND])) { + $chain = $this; + $code = $pluginInfo[Definition::LISTENER_AROUND]; + $next = function() use ($chain, $type, $method, $subject, $code) { + return $chain->invokeNext($type, $method, $subject, func_get_args(), $code); + }; + $result = call_user_func_array( + array($this->pluginList->getPlugin($type, $code), 'around' . $capMethod), + array_merge(array($subject, $next), $arguments) + ); + } else { + $result = $subject->___callParent($method, $arguments); + } + if (isset($pluginInfo[Definition::LISTENER_AFTER])) { + foreach ($pluginInfo[Definition::LISTENER_AFTER] as $code) { + $result = $this->pluginList->getPlugin($type, $code)->{'after' . $capMethod}($subject, $result); + } + } + return $result; + } +} diff --git a/lib/Magento/Interception/Code/Generator/Interceptor.php b/lib/Magento/Interception/Code/Generator/Interceptor.php new file mode 100644 index 00000000000..cdad6b67190 --- /dev/null +++ b/lib/Magento/Interception/Code/Generator/Interceptor.php @@ -0,0 +1,302 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Interception\Code\Generator; + +class Interceptor extends \Magento\Code\Generator\EntityAbstract +{ + /** + * Entity type + */ + const ENTITY_TYPE = 'interceptor'; + + /** + * @param string $modelClassName + * @return string + */ + protected function _getDefaultResultClassName($modelClassName) + { + return $modelClassName . '_' . ucfirst(static::ENTITY_TYPE); + } + + /** + * Returns list of properties for class generator + * + * @return array + */ + protected function _getClassProperties() + { + return array( + array( + 'name' => 'pluginLocator', + 'visibility' => 'protected', + 'docblock' => array( + 'shortDescription' => 'Object Manager instance', + 'tags' => array( + array('name' => 'var', 'description' => '\Magento\ObjectManager') + ) + ), + ), + array( + 'name' => 'pluginList', + 'visibility' => 'protected', + 'docblock' => array( + 'shortDescription' => 'List of plugins', + 'tags' => array( + array('name' => 'var', 'description' => '\Magento\Interception\PluginList') + ) + ), + ), + array( + 'name' => 'chain', + 'visibility' => 'protected', + 'docblock' => array( + 'shortDescription' => 'Invocation chain', + 'tags' => array( + array('name' => 'var', 'description' => '\Magento\Interception\Chain') + ) + ), + ), + array( + 'name' => 'subjectType', + 'visibility' => 'protected', + 'docblock' => array( + 'shortDescription' => 'Subject type name', + 'tags' => array( + array('name' => 'var', 'description' => 'string') + ) + ), + ), + ); + } + + /** + * Get default constructor definition for generated class + * + * @return array + */ + protected function _getDefaultConstructorDefinition() + { + $reflectionClass = new \ReflectionClass($this->_getSourceClassName()); + $constructor = $reflectionClass->getConstructor(); + $parameters = array(); + if ($constructor) { + foreach ($constructor->getParameters() as $parameter) { + $parameters[] = $this->_getMethodParameterInfo($parameter); + } + } + + return array( + 'name' => '__construct', + 'parameters' => array_merge(array( + array('name' => 'pluginLocator', 'type' => '\Magento\ObjectManager'), + array('name' => 'pluginList', 'type' => '\Magento\Interception\PluginList'), + array('name' => 'chain', 'type' => '\Magento\Interception\Chain'), + ), $parameters), + 'body' => "\$this->pluginLocator = \$pluginLocator;\n" + . "\$this->pluginList = \$pluginList;\n" + . "\$this->chain = \$chain;\n" + . "\$this->subjectType = get_parent_class(\$this);\n" + . (count($parameters) ? "parent::__construct({$this->_getParameterList($parameters)});" : '') + ); + } + + /** + * Returns list of methods for class generator + * + * @return mixed + */ + protected function _getClassMethods() + { + $methods = array($this->_getDefaultConstructorDefinition()); + + $methods[] = array( + 'name' => '___callParent', + 'parameters' => array( + array('name' => 'method', 'type' => 'string'), + array('name' => 'arguments', 'type' => 'array'), + ), + 'body' => 'return call_user_func_array(array(\'parent\', $method), $arguments);' + ); + + $methods[] = array( + 'name' => '__sleep', + 'body' => "if (method_exists(get_parent_class(\$this), '__sleep')) {\n" + . " return parent::__sleep();\n" + . "} else {\n" + . " return array_keys(get_class_vars(get_parent_class(\$this)));\n" + . "}\n" + ); + + $methods[] = array( + 'name' => '__wakeup', + 'body' => "\$this->pluginLocator = \\Magento\\App\\ObjectManager::getInstance();\n" + . "\$this->pluginList = \$this->pluginLocator->get('Magento\\Interception\\PluginList');\n" + . "\$this->chain = \$this->pluginLocator->get('Magento\\Interception\\Chain');\n" + . "\$this->subjectType = get_parent_class(\$this);\n" + ); + + $methods[] = array( + 'name' => '___call', + 'visibility' => 'protected', + 'parameters' => array( + array('name' => 'method', 'type' => 'string'), + array('name' => 'arguments', 'type' => 'array'), + array('name' => 'pluginInfo', 'type' => 'array'), + ), + 'body' => "\$capMethod = ucfirst(\$method);\n" + . "\$result = null;\n" + . "if (isset(\$pluginInfo[\\Magento\\Interception\\Definition::LISTENER_BEFORE])) {\n" + . " foreach (\$pluginInfo[\\Magento\\Interception\\Definition::LISTENER_BEFORE] as \$code) {\n" + . " \$beforeResult = call_user_func_array(\n" + . " array(\$this->pluginList->getPlugin(\$this->subjectType, \$code), 'before'" + . ". \$capMethod), array_merge(array(\$this), \$arguments)\n" + . " );\n" + . " if (\$beforeResult) {\n" + . " \$arguments = \$beforeResult;\n" + . " }\n" + . " }\n" + . "}\n" + . "if (isset(\$pluginInfo[\\Magento\\Interception\\Definition::LISTENER_AROUND])) {\n" + . " \$chain = \$this->chain;\n" + . " \$type = \$this->subjectType;\n" + . " \$subject = \$this;\n" + . " \$code = \$pluginInfo[\\Magento\\Interception\\Definition::LISTENER_AROUND];\n" + . " \$next = function () use (\$chain, \$type, \$method, \$subject, \$code) {\n" + . " return \$chain->invokeNext(\$type, \$method, \$subject, func_get_args(), \$code);\n" + . " };\n" + . " \$result = call_user_func_array(\n" + . " array(\$this->pluginList->getPlugin(\$this->subjectType, \$code), 'around' . \$capMethod),\n" + . " array_merge(array(\$this, \$next), \$arguments)\n" + . " );\n" + . "} else {\n" + . " \$result = call_user_func_array(array('parent', \$method), \$arguments);\n" + . "}\n" + . "if (isset(\$pluginInfo[\\Magento\\Interception\\Definition::LISTENER_AFTER])) {\n" + . " foreach (\$pluginInfo[\\Magento\\Interception\\Definition::LISTENER_AFTER] as \$code) {\n" + . " \$result = \$this->pluginList->getPlugin(\$this->subjectType, \$code)\n" + . " ->{'after' . \$capMethod}(\$this, \$result);\n" + . " }\n" + . "}\n" + . "return \$result;\n" + ); + + $reflectionClass = new \ReflectionClass($this->_getSourceClassName()); + $publicMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC); + foreach ($publicMethods as $method) { + if (!($method->isConstructor() || $method->isFinal() || $method->isStatic() || $method->isDestructor()) + && !in_array($method->getName(), array('__sleep', '__wakeup', '__clone')) + ) { + $methods[] = $this->_getMethodInfo($method); + } + } + + return $methods; + } + + /** + * Retrieve method info + * + * @param \ReflectionMethod $method + * @return array + */ + protected function _getMethodInfo(\ReflectionMethod $method) + { + $parameters = array(); + foreach ($method->getParameters() as $parameter) { + $parameters[] = $this->_getMethodParameterInfo($parameter); + } + + $methodInfo = array( + 'name' => $method->getName(), + 'parameters' => $parameters, + 'body' => "\$pluginInfo = \$this->pluginList->getNext(\$this->subjectType, '{$method->getName()}');\n" + . "if (!\$pluginInfo) {\n" + . " return parent::{$method->getName()}({$this->_getParameterList($parameters)});\n" + . "} else {\n" + . " return \$this->___call('{$method->getName()}', func_get_args(), \$pluginInfo);\n" + . "}", + 'docblock' => array( + 'shortDescription' => '{@inheritdoc}', + ), + ); + + return $methodInfo; + } + + /** + * @param array $parameters + * @return string + */ + protected function _getParameterList(array $parameters) + { + return implode( + ', ', + array_map( + function($item) { + return "$" . $item['name']; + }, + $parameters + ) + ); + } + + /** + * Generate resulting class source code + * + * @return string + */ + protected function _generateCode() + { + $typeName = $this->_getFullyQualifiedClassName($this->_getSourceClassName()); + $reflection = new \ReflectionClass($typeName); + + if ($reflection->isInterface()) { + $this->_classGenerator->setImplementedInterfaces(array($typeName)); + } else { + $this->_classGenerator->setExtendedClass($typeName); + } + return parent::_generateCode(); + } + + /** + * {@inheritdoc} + */ + protected function _validateData() + { + $result = parent::_validateData(); + + if ($result) { + $sourceClassName = $this->_getSourceClassName(); + $resultClassName = $this->_getResultClassName(); + + if ($resultClassName !== $sourceClassName . '\\Interceptor') { + $this->_addError('Invalid Interceptor class name [' + . $resultClassName . ']. Use ' . $sourceClassName . '\\Interceptor' + ); + $result = false; + } + } + return $result; + } +} diff --git a/lib/Magento/Interception/Code/InterfaceValidator.php b/lib/Magento/Interception/Code/InterfaceValidator.php new file mode 100644 index 00000000000..5412b44d348 --- /dev/null +++ b/lib/Magento/Interception/Code/InterfaceValidator.php @@ -0,0 +1,234 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Interception\Code; + +class InterfaceValidator +{ + const METHOD_BEFORE = 'before'; + const METHOD_AROUND = 'around'; + const METHOD_AFTER = 'after'; + + /** + * Arguments reader model + * + * @var \Magento\Code\Reader\ArgumentsReader + */ + protected $_argumentsReader; + + /** + * @param \Magento\Code\Reader\ArgumentsReader $argumentsReader + */ + public function __construct(\Magento\Code\Reader\ArgumentsReader $argumentsReader = null) + { + $this->_argumentsReader = $argumentsReader ?: new \Magento\Code\Reader\ArgumentsReader(); + } + + /** + * Validate plugin interface + * + * @param string $pluginClass + * @param string $interceptedType + * + * @return void + * @throws ValidatorException + */ + public function validate($pluginClass, $interceptedType) + { + $interceptedType = '\\' . trim($interceptedType, '\\'); + $pluginClass = '\\' . trim($pluginClass, '\\'); + $plugin = new \ReflectionClass($pluginClass); + $type = new \ReflectionClass($interceptedType); + + $pluginMethods = array(); + foreach ($plugin->getMethods(\ReflectionMethod::IS_PUBLIC) as $pluginMethod) { + /** @var $pluginMethod \ReflectionMethod */ + $originMethodName = $this->getOriginMethodName($pluginMethod->getName()); + if (is_null($originMethodName)) { + continue; + } + if (!$type->hasMethod($originMethodName)) { + throw new ValidatorException( + 'Incorrect interface in ' . $pluginClass + . '. There is no method [ ' . $originMethodName . ' ] in ' . $interceptedType . ' interface' + ); + } + $originMethod = $type->getMethod($originMethodName); + + $pluginMethodParameters = $this->getMethodParameters($pluginMethod); + $originMethodParameters = $this->getMethodParameters($originMethod); + + $methodType = $this->getMethodType($pluginMethod->getName()); + + $subject = array_shift($pluginMethodParameters); + if (!$this->_argumentsReader->isCompatibleType($subject['type'], $interceptedType) + || is_null($subject['type']) + ) { + throw new ValidatorException( + 'Invalid [' . $subject['type'] . '] $' . $subject['name'] + . ' type in ' . $pluginClass . '::' . $pluginMethod->getName() + . '. It must be compatible with ' + . $interceptedType + ); + } + + switch ($methodType) { + case self::METHOD_BEFORE: + $this->validateMethodsParameters( + $pluginMethodParameters, $originMethodParameters, $pluginClass, $pluginMethod->getName() + ); + break; + case self::METHOD_AROUND: + $proceed = array_shift($pluginMethodParameters); + if (!$this->_argumentsReader->isCompatibleType($proceed['type'], '\\Closure')) { + throw new ValidatorException( + 'Invalid [' . $proceed['type'] . '] $' . $proceed['name'] + . ' type in ' . $pluginClass . '::' . $pluginMethod->getName() + . '. It must be compatible with \\Closure' + ); + } + $this->validateMethodsParameters( + $pluginMethodParameters, $originMethodParameters, $pluginClass, $pluginMethod->getName() + ); + break; + case self::METHOD_AFTER: + if (count($pluginMethodParameters) > 1) { + throw new ValidatorException( + 'Invalid method signature. Detected extra parameters' + . ' in ' . $pluginClass . '::' . $pluginMethod->getName() + ); + } + break; + } + + } + } + + /** + * Validate methods parameters compatibility + * + * @param array $pluginParameters + * @param array $originParameters + * @param string $class + * @param string $method + * + * @return void + * @throws ValidatorException + */ + protected function validateMethodsParameters(array $pluginParameters, array $originParameters, $class, $method) + { + if (count($pluginParameters) != count($originParameters)) { + throw new ValidatorException( + 'Invalid method signature. Invalid method parameters count' + . ' in ' . $class . '::' . $method + ); + } + foreach ($pluginParameters as $position => $data) { + if (!$this->_argumentsReader->isCompatibleType($data['type'], $originParameters[$position]['type'])) { + throw new ValidatorException( + 'Incompatible parameter type [' . $data['type'] + . ' $' . $data['name'] . ']' + . ' in ' . $class . '::' . $method + . '. It must be compatible with ' . $originParameters[$position]['type'] + + ); + } + } + } + + /** + * Get parameters type + * + * @param \ReflectionParameter $parameter + * + * @return string + */ + protected function getParametersType(\ReflectionParameter $parameter) + { + $parameterClass = $parameter->getClass(); + $type = $parameterClass ? '\\' . $parameterClass->getName() : ($parameter->isArray() ? 'array' : null); + return $type; + } + + /** + * Get intercepted method name + * + * @param string $pluginMethodName + * + * @return string|null + */ + protected function getOriginMethodName($pluginMethodName) + { + switch ($this->getMethodType($pluginMethodName)) { + case self::METHOD_BEFORE: + case self::METHOD_AROUND: + return lcfirst(substr($pluginMethodName, 6)); + + case self::METHOD_AFTER: + return lcfirst(substr($pluginMethodName, 5)); + + default: + return null; + } + } + + /** + * Get method type + * + * @param string $pluginMethodName + * + * @return null|string + */ + protected function getMethodType($pluginMethodName) + { + if (substr($pluginMethodName, 0, 6) == self::METHOD_BEFORE) { + return self::METHOD_BEFORE; + } elseif (substr($pluginMethodName, 0, 6) == self::METHOD_AROUND) { + return self::METHOD_AROUND; + } elseif (substr($pluginMethodName, 0, 5) == self::METHOD_AFTER) { + return self::METHOD_AFTER; + } + + return null; + } + + /** + * Get method parameters + * + * @param \ReflectionMethod $method + * + * @return array + */ + protected function getMethodParameters(\ReflectionMethod $method) + { + $output = array(); + foreach ($method->getParameters() as $parameter) { + $output[$parameter->getPosition()] = array( + 'name' => $parameter->getName(), + 'type' => $this->getParametersType($parameter), + ); + } + return $output; + } +} diff --git a/app/code/Magento/Usa/sql/usa_setup/install-1.6.0.0.php b/lib/Magento/Interception/Code/ValidatorException.php similarity index 91% rename from app/code/Magento/Usa/sql/usa_setup/install-1.6.0.0.php rename to lib/Magento/Interception/Code/ValidatorException.php index 5728a0e1c76..e274e4d65bc 100644 --- a/app/code/Magento/Usa/sql/usa_setup/install-1.6.0.0.php +++ b/lib/Magento/Interception/Code/ValidatorException.php @@ -18,9 +18,13 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Interception\Code; + +class ValidatorException extends \Exception +{ + +} diff --git a/lib/Magento/Interception/CodeGenerator/CodeGenerator.php b/lib/Magento/Interception/CodeGenerator/CodeGenerator.php deleted file mode 100644 index 7e912860dae..00000000000 --- a/lib/Magento/Interception/CodeGenerator/CodeGenerator.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** - * Interceptor generator. Used to automatically create Interception classes for intercepted classes - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Interception\CodeGenerator; - -class CodeGenerator - implements \Magento\Interception\CodeGenerator -{ - /** - * Class generator - * - * @var \Magento\Code\Generator - */ - protected $_generator; - - /** - * @param \Magento\Code\Generator $generator - */ - public function __construct(\Magento\Code\Generator $generator = null) - { - $this->_generator = $generator ?: new \Magento\Code\Generator(); - } - - /** - * {@inheritdoc} - */ - public function generate($interceptorClass) - { - $this->_generator->generateClass($interceptorClass); - } -} diff --git a/lib/Magento/Interception/Config.php b/lib/Magento/Interception/Config.php index 32d9ffb79a7..54727f38cd7 100644 --- a/lib/Magento/Interception/Config.php +++ b/lib/Magento/Interception/Config.php @@ -27,10 +27,6 @@ namespace Magento\Interception; interface Config { - const BEFORE_SCENARIO = 1; - const AFTER_SCENARIO = 2; - const AROUND_SCENARIO = 3; - /** * Check whether type has configured plugins * @@ -38,12 +34,4 @@ interface Config * @return bool */ public function hasPlugins($type); - - /** - * Generate interceptor class name - * - * @param string $type - * @return string - */ - public function getInterceptorClassName($type); } diff --git a/lib/Magento/Interception/Config/Config.php b/lib/Magento/Interception/Config/Config.php index 69dc9043204..b46b87d04e7 100644 --- a/lib/Magento/Interception/Config/Config.php +++ b/lib/Magento/Interception/Config/Config.php @@ -41,13 +41,6 @@ class Config implements \Magento\Interception\Config */ protected $_relations; - /** - * Interceptor generator - * - * @var \Magento\Interception\CodeGenerator - */ - protected $_codeGenerator; - /** * List of interceptable classes * @@ -88,9 +81,8 @@ class Config implements \Magento\Interception\Config * @param \Magento\Config\ScopeListInterface $scopeList * @param \Magento\Cache\FrontendInterface $cache * @param \Magento\ObjectManager\Relations $relations - * @param \Magento\ObjectManager\Config $omConfig - * @param \Magento\ObjectManager\Definition\Compiled $classDefinitions - * @param \Magento\Interception\CodeGenerator $codeGenerator + * @param \Magento\Interception\ObjectManager\Config $omConfig + * @param \Magento\ObjectManager\Definition $classDefinitions * @param string $cacheId */ public function __construct( @@ -98,14 +90,12 @@ class Config implements \Magento\Interception\Config \Magento\Config\ScopeListInterface $scopeList, \Magento\Cache\FrontendInterface $cache, \Magento\ObjectManager\Relations $relations, - \Magento\ObjectManager\Config $omConfig, - \Magento\ObjectManager\Definition\Compiled $classDefinitions = null, - \Magento\Interception\CodeGenerator $codeGenerator = null, + \Magento\Interception\ObjectManager\Config $omConfig, + \Magento\ObjectManager\Definition $classDefinitions, $cacheId = 'interception' ) { $this->_omConfig = $omConfig; $this->_relations = $relations; - $this->_codeGenerator = $codeGenerator; $this->_classDefinitions = $classDefinitions; $this->_cache = $cache; $this->_cacheId = $cacheId; @@ -119,15 +109,17 @@ class Config implements \Magento\Interception\Config foreach ($scopeList->getAllScopes() as $scope) { $config = array_replace_recursive($config, $this->_reader->read($scope)); } + unset($config['preferences']); foreach ($config as $typeName => $typeConfig) { if (!empty($typeConfig['plugins'])) { - $this->_intercepted[$typeName] = true; + $this->_intercepted[ltrim($typeName, '\\')] = true; } } - if ($classDefinitions) { - foreach ($classDefinitions->getClasses() as $class) { - $this->hasPlugins($class); - } + foreach ($config as $typeName => $typeConfig) { + $this->hasPlugins(ltrim($typeName, '\\')); + } + foreach ($classDefinitions->getClasses() as $class) { + $this->hasPlugins($class); } $this->_cache->save(serialize($this->_intercepted), $this->_cacheId); } @@ -142,7 +134,7 @@ class Config implements \Magento\Interception\Config protected function _inheritInterception($type) { if (!isset($this->_intercepted[$type])) { - $realType = $this->_omConfig->getInstanceType($type); + $realType = $this->_omConfig->getOriginalInstanceType($type); if ($type !== $realType) { if ($this->_inheritInterception($realType)) { $this->_intercepted[$type] = true; @@ -169,16 +161,4 @@ class Config implements \Magento\Interception\Config { return isset($this->_intercepted[$type]) ? $this->_intercepted[$type] : $this->_inheritInterception($type); } - - /** - * {@inheritdoc} - */ - public function getInterceptorClassName($type) - { - $className = $this->_omConfig->getInstanceType($type) . '\Interceptor'; - if ($this->_codeGenerator && !class_exists($className)) { - $this->_codeGenerator->generate($className); - } - return $className; - } } diff --git a/lib/Magento/Interception/Definition.php b/lib/Magento/Interception/Definition.php index caf705a1acf..c93902c9461 100644 --- a/lib/Magento/Interception/Definition.php +++ b/lib/Magento/Interception/Definition.php @@ -27,6 +27,10 @@ namespace Magento\Interception; interface Definition { + const LISTENER_BEFORE = 1; + const LISTENER_AROUND = 2; + const LISTENER_AFTER = 4; + /** * Retrieve list of methods * diff --git a/lib/Magento/Interception/Definition/Runtime.php b/lib/Magento/Interception/Definition/Runtime.php index 6f88846871d..785439ef598 100644 --- a/lib/Magento/Interception/Definition/Runtime.php +++ b/lib/Magento/Interception/Definition/Runtime.php @@ -30,6 +30,26 @@ use Magento\Interception\Definition; class Runtime implements Definition { + /** + * @var array + */ + protected $_typesByPrefixes = array( + 'befor' => self::LISTENER_BEFORE, + 'aroun' => self::LISTENER_AROUND, + 'after' => self::LISTENER_AFTER + ); + + /** + * Plugin method service prefix lengths + * + * @var array + */ + protected $prefixLengths = array( + self::LISTENER_BEFORE => 6, + self::LISTENER_AROUND => 6, + self::LISTENER_AFTER => 5 + ); + /** * Retrieve list of methods * @@ -38,6 +58,19 @@ class Runtime implements Definition */ public function getMethodList($type) { - return get_class_methods($type); + $methods = array(); + $allMethods = get_class_methods($type); + if ($allMethods) { + foreach($allMethods as $method) { + $prefix = substr($method, 0, 5); + if (isset($this->_typesByPrefixes[$prefix])) { + $methodName = \lcfirst(substr($method, $this->prefixLengths[$this->_typesByPrefixes[$prefix]])); + $methods[$methodName] = isset($methods[$methodName]) + ? ($methods[$methodName] | $this->_typesByPrefixes[$prefix]) + : $this->_typesByPrefixes[$prefix]; + } + } + } + return $methods; } } diff --git a/lib/Magento/Interception/FactoryDecorator.php b/lib/Magento/Interception/FactoryDecorator.php deleted file mode 100644 index 5c3b9a8b97b..00000000000 --- a/lib/Magento/Interception/FactoryDecorator.php +++ /dev/null @@ -1,102 +0,0 @@ -<?php -/** - * Object manager factory decorator. Wraps intercepted objects by Interceptor instance - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 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: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Interception; - -use Magento\ObjectManager; -use Magento\Interception\Config; -use Magento\Interception\PluginList; -use Magento\ObjectManager\Factory; - -class FactoryDecorator implements Factory -{ - /** - * Configurable factory - * - * @var Factory - */ - protected $_factory; - - /** - * Object manager - * - * @var ObjectManager - */ - protected $_objectManager; - - /** - * Object manager config - * - * @var Config - */ - protected $_config; - - /** - * List of plugins configured for instance - * - * @var PluginList - */ - protected $_pluginList; - - /** - * @param Factory $factory - * @param Config $config - * @param PluginList $pluginList - * @param ObjectManager $objectManager - */ - public function __construct( - Factory $factory, - Config $config, - PluginList $pluginList, - ObjectManager $objectManager - ) { - $this->_factory = $factory; - $this->_pluginList = $pluginList; - $this->_objectManager = $objectManager; - $this->_config = $config; - } - - /** - * Create instance of requested type with requested arguments - * - * @param string $type - * @param array $arguments - * @return object - */ - public function create($type, array $arguments = array()) - { - if ($this->_config->hasPlugins($type)) { - $interceptorClass = $this->_config->getInterceptorClassName($type); - return new $interceptorClass( - $this->_factory, - $this->_objectManager, - $type, - $this->_pluginList, - $arguments - ); - } - return $this->_factory->create($type, $arguments); - } -} diff --git a/lib/Magento/Interception/ObjectManager/Config.php b/lib/Magento/Interception/ObjectManager/Config.php new file mode 100644 index 00000000000..d0b99f95f34 --- /dev/null +++ b/lib/Magento/Interception/ObjectManager/Config.php @@ -0,0 +1,70 @@ +<?php +/** + * ObjectManager config with interception processing + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Interception\ObjectManager; + +class Config extends \Magento\ObjectManager\Config\Config +{ + /** + * @var \Magento\Interception\Config + */ + protected $interceptionConfig; + + /** + * Set Interception config + * + * @param \Magento\Interception\Config $interceptionConfig + */ + public function setInterceptionConfig(\Magento\Interception\Config $interceptionConfig) + { + $this->interceptionConfig = $interceptionConfig; + } + + /** + * Retrieve instance type with interception processing + * + * @param string $instanceName + * @return string + */ + public function getInstanceType($instanceName) + { + $type = parent::getInstanceType($instanceName); + if ($this->interceptionConfig && $this->interceptionConfig->hasPlugins($instanceName)) { + return $type . '\\Interceptor'; + } + return $type; + } + + /** + * Retrieve instance type without interception processing + * + * @param string $instanceName + * @return string + */ + public function getOriginalInstanceType($instanceName) + { + return parent::getInstanceType($instanceName); + } +} diff --git a/lib/Magento/Interception/PluginList.php b/lib/Magento/Interception/PluginList.php index 6bf2b6e8ad0..78de4309cc0 100644 --- a/lib/Magento/Interception/PluginList.php +++ b/lib/Magento/Interception/PluginList.php @@ -28,12 +28,21 @@ namespace Magento\Interception; interface PluginList { /** - * Retrieve list of plugins listening for method + * Retrieve next plugins in chain * * @param string $type * @param string $method - * @param string $scenario + * @param string $code * @return array */ - public function getPlugins($type, $method, $scenario); + public function getNext($type, $method, $code = null); + + /** + * Retrieve plugin instance by code + * + * @param string $type + * @param string $code + * @return mixed + */ + public function getPlugin($type, $code); } diff --git a/lib/Magento/Interception/PluginList/PluginList.php b/lib/Magento/Interception/PluginList/PluginList.php index 12daf60ac99..0c819720259 100644 --- a/lib/Magento/Interception/PluginList/PluginList.php +++ b/lib/Magento/Interception/PluginList/PluginList.php @@ -31,13 +31,28 @@ use Magento\Config\CacheInterface; use Magento\Config\Data\Scoped; use Magento\Interception\Definition; use Magento\Interception\PluginList as InterceptionPluginList; -use Magento\ObjectManager\Config; +use Magento\Interception\ObjectManager\Config; use Magento\ObjectManager\Relations; -use Magento\ObjectManager\Definition\Compiled; +use Magento\ObjectManager\Definition as ClassDefinitions; +use Magento\ObjectManager; use Zend\Soap\Exception\InvalidArgumentException; class PluginList extends Scoped implements InterceptionPluginList { + /** + * Inherited plugin data + * + * @var array + */ + protected $_inherited; + + /** + * Inherited plugin data, preprocessed for read + * + * @var array + */ + protected $_processed; + /** * Type config * @@ -62,16 +77,19 @@ class PluginList extends Scoped implements InterceptionPluginList /** * List of interceptable application classes * - * @var Compiled + * @var ClassDefinitions */ protected $_classDefinitions; /** - * Scope inheritance scheme - * - * @var string[] + * @var \Magento\ObjectManager */ - protected $_scopePriorityScheme = array('global'); + protected $_objectManager; + + /** + * @var array + */ + protected $_pluginInstances = array(); /** * @param ReaderInterface $reader @@ -80,9 +98,10 @@ class PluginList extends Scoped implements InterceptionPluginList * @param Relations $relations * @param Config $omConfig * @param Definition $definitions - * @param string[] $scopePriorityScheme + * @param ObjectManager $objectManager + * @param ClassDefinitions $classDefinitions + * @param array $scopePriorityScheme * @param string $cacheId - * @param Compiled $classDefinitions */ public function __construct( ReaderInterface $reader, @@ -91,9 +110,10 @@ class PluginList extends Scoped implements InterceptionPluginList Relations $relations, Config $omConfig, Definition $definitions, - array $scopePriorityScheme, - $cacheId = 'plugins', - Compiled $classDefinitions = null + ObjectManager $objectManager, + ClassDefinitions $classDefinitions, + array $scopePriorityScheme = array('global'), + $cacheId = 'plugins' ) { parent::__construct($reader, $configScope, $cache, $cacheId); $this->_omConfig = $omConfig; @@ -101,6 +121,7 @@ class PluginList extends Scoped implements InterceptionPluginList $this->_definitions = $definitions; $this->_classDefinitions = $classDefinitions; $this->_scopePriorityScheme = $scopePriorityScheme; + $this->_objectManager = $objectManager; } /** @@ -113,8 +134,8 @@ class PluginList extends Scoped implements InterceptionPluginList */ protected function _inheritPlugins($type) { - if (!isset($this->_data['inherited'][$type])) { - $realType = $this->_omConfig->getInstanceType($type); + if (!array_key_exists($type, $this->_inherited)) { + $realType = $this->_omConfig->getOriginalInstanceType($type); if ($realType !== $type) { $plugins = $this->_inheritPlugins($realType); @@ -132,36 +153,47 @@ class PluginList extends Scoped implements InterceptionPluginList } else { $plugins = array(); } - if (isset($this->_data[$type]['plugins'])) { + if (isset($this->_data[$type])) { if (!$plugins) { - $plugins = $this->_data[$type]['plugins']; + $plugins = $this->_data[$type]; } else { - $plugins = array_replace_recursive($plugins, $this->_data[$type]['plugins']); + $plugins = array_replace_recursive($plugins, $this->_data[$type]); } } - uasort($plugins, array($this, '_sort')); - if (count($plugins)) { - $this->_data['inherited'][$type] = $plugins; + $this->_inherited[$type] = null; + if (is_array($plugins) && count($plugins)) { + uasort($plugins, array($this, '_sort')); + $this->_inherited[$type] = $plugins; + $lastPerMethod = array(); foreach ($plugins as $key => $plugin) { // skip disabled plugins if (isset($plugin['disabled']) && $plugin['disabled']) { unset($plugins[$key]); continue; } - $pluginType = $this->_omConfig->getInstanceType($plugin['instance']); + $pluginType = $this->_omConfig->getOriginalInstanceType($plugin['instance']); if (!class_exists($pluginType)) { throw new InvalidArgumentException('Plugin class ' . $pluginType . ' doesn\'t exist'); } - foreach ($this->_definitions->getMethodList($pluginType) as $pluginMethod) { - $this->_data['processed'][$type][$pluginMethod][] = $plugin['instance']; + foreach ($this->_definitions->getMethodList($pluginType) as $pluginMethod => $methodTypes) { + $current = isset($lastPerMethod[$pluginMethod]) ? $lastPerMethod[$pluginMethod] : '__self'; + $currentKey = $type . '_'. $pluginMethod . '_' . $current; + if ($methodTypes & Definition::LISTENER_AROUND) { + $this->_processed[$currentKey][Definition::LISTENER_AROUND] = $key; + $lastPerMethod[$pluginMethod] = $key; + } + if ($methodTypes & Definition::LISTENER_BEFORE) { + $this->_processed[$currentKey][Definition::LISTENER_BEFORE][] = $key; + } + if ($methodTypes & Definition::LISTENER_AFTER) { + $this->_processed[$currentKey][Definition::LISTENER_AFTER][] = $key; + } } } - } else { - $this->_data['inherited'][$type] = null; } return $plugins; } - return $this->_data['inherited'][$type]; + return $this->_inherited[$type]; } /** @@ -186,25 +218,38 @@ class PluginList extends Scoped implements InterceptionPluginList } /** - * {@inheritdoc} + * Retrieve plugin Instance + * + * @param string $type + * @param string $code + * @return mixed + */ + public function getPlugin($type, $code) + { + if (!isset($this->_pluginInstances[$type][$code])) { + $this->_pluginInstances[$type][$code] = $this->_objectManager->get( + $this->_inherited[$type][$code]['instance'] + ); + } + return $this->_pluginInstances[$type][$code]; + } + + /** + * Retrieve next plugins in chain * * @param string $type * @param string $method - * @param string $scenario + * @param string $code * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - public function getPlugins($type, $method, $scenario) + public function getNext($type, $method, $code = '__self') { $this->_loadScopedData(); - $pluginMethodName = $scenario . ucfirst($method); - $realType = $this->_omConfig->getInstanceType($type); - if (!isset($this->_data['inherited'][$realType])) { + if (!array_key_exists($type, $this->_inherited)) { $this->_inheritPlugins($type); } - return isset($this->_data['processed'][$realType][$pluginMethodName]) - ? $this->_data['processed'][$realType][$pluginMethodName] - : array(); + $key = $type . '_' . lcfirst($method) . '_' . $code; + return isset($this->_processed[$key]) ? $this->_processed[$key] : null; } /** @@ -223,32 +268,60 @@ class PluginList extends Scoped implements InterceptionPluginList $cacheId = implode('|', $this->_scopePriorityScheme) . "|" . $this->_cacheId; $data = $this->_cache->load($cacheId); if ($data) { - $this->_data = unserialize($data); + list($this->_data, $this->_inherited, $this->_processed) = unserialize($data); foreach ($this->_scopePriorityScheme as $scope) { $this->_loadedScopes[$scope] = true; } } else { + $virtualTypes = array(); foreach ($this->_scopePriorityScheme as $scopeCode) { if (false == isset($this->_loadedScopes[$scopeCode])) { $data = $this->_reader->read($scopeCode); + unset($data['preferences']); if (!count($data)) { continue; } - unset($this->_data['inherited']); - unset($this->_data['processed']); + $this->_inherited = array(); + $this->_processed = array(); $this->merge($data); $this->_loadedScopes[$scopeCode] = true; + foreach ($data as $class => $config) { + if (isset($config['type'])) { + $virtualTypes[] = $class; + } + } } if ($scopeCode == $scope) { break; } } - if ($this->_classDefinitions) { - foreach ($this->_classDefinitions->getClasses() as $class) { - $this->_inheritPlugins($class); - } + foreach ($virtualTypes as $class) { + $this->_inheritPlugins(ltrim($class, '\\')); + } + foreach ($this->_classDefinitions->getClasses() as $class) { + $this->_inheritPlugins($class); + } + $this->_cache->save(serialize(array($this->_data, $this->_inherited, $this->_processed)), $cacheId); + } + $this->_pluginInstances = array(); + } + } + + /** + * Merge configuration + * + * @param array $config + */ + public function merge(array $config) + { + foreach ($config as $type => $typeConfig) { + if (isset($typeConfig['plugins'])) { + $type = ltrim($type, '\\'); + if (isset($this->_data[$type])) { + $this->_data[$type] = array_replace_recursive($this->_data[$type], $typeConfig['plugins']); + } else { + $this->_data[$type] = $typeConfig['plugins']; } - $this->_cache->save(serialize($this->_data), $cacheId); } } } diff --git a/dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleClass.php b/lib/Magento/Locale.php similarity index 79% rename from dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleClass.php rename to lib/Magento/Locale.php index 482745ec24f..8f2ca1991c4 100644 --- a/dev/tests/unit/testsuite/Magento/Code/Plugin/GeneratorTest/SimpleClass.php +++ b/lib/Magento/Locale.php @@ -18,21 +18,19 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Code - * @subpackage unit_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Code\Plugin\GeneratorTest; -class SimpleClass +namespace Magento; + +class Locale extends \Zend_Locale implements \Magento\LocaleInterface { /** - * @return string + * {@inheritdoc} */ - public function doWork() + public function __construct($locale = null) { - return 'simple class return value'; + parent::__construct($locale); } -} +} \ No newline at end of file diff --git a/app/code/Magento/Core/Model/Locale/Config.php b/lib/Magento/Locale/Config.php similarity index 96% rename from app/code/Magento/Core/Model/Locale/Config.php rename to lib/Magento/Locale/Config.php index a9594c78341..32877d6124c 100644 --- a/app/code/Magento/Core/Model/Locale/Config.php +++ b/lib/Magento/Locale/Config.php @@ -18,14 +18,12 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Locale; +namespace Magento\Locale; -class Config +class Config implements \Magento\Locale\ConfigInterface { /** * List of allowed locales @@ -130,22 +128,18 @@ class Config } /** - * Get list pre-configured allowed locales - * - * @return array + * @inheritdoc */ public function getAllowedLocales() { - return $this->_allowedLocales; + return $this->_allowedLocales; } /** - * Get list pre-configured allowed currencies - * - * @return array + * @inheritdoc */ public function getAllowedCurrencies() { - return $this->_allowedCurrencies; + return $this->_allowedCurrencies; } } diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Dutypaymenttype.php b/lib/Magento/Locale/ConfigInterface.php similarity index 75% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Dutypaymenttype.php rename to lib/Magento/Locale/ConfigInterface.php index 0da63e29363..a1cf20994fe 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Dhl/Source/Dutypaymenttype.php +++ b/lib/Magento/Locale/ConfigInterface.php @@ -18,21 +18,24 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Locale; - -namespace Magento\Usa\Model\Shipping\Carrier\Dhl\Source; - -class Dutypaymenttype extends \Magento\Usa\Model\Shipping\Carrier\Dhl\Source\Generic +interface ConfigInterface { /** - * Carrier code + * Get list pre-configured allowed locales + * + * @return array + */ + public function getAllowedLocales(); + + /** + * Get list pre-configured allowed currencies * - * @var string + * @return array */ - protected $_code = 'dutypayment_type'; + public function getAllowedCurrencies(); } diff --git a/lib/Magento/Locale/Currency.php b/lib/Magento/Locale/Currency.php new file mode 100644 index 00000000000..3979b007302 --- /dev/null +++ b/lib/Magento/Locale/Currency.php @@ -0,0 +1,114 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Locale; + +class Currency implements \Magento\Locale\CurrencyInterface +{ + /** + * @var array + */ + protected static $_currencyCache = array(); + + /** + * Core event manager proxy + * + * @var \Magento\Event\ManagerInterface + */ + protected $_eventManager = null; + + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + + /** + * @var \Magento\CurrencyFactory + */ + protected $_currencyFactory; + + /** + * @param \Magento\Event\ManagerInterface $eventManager + * @param ResolverInterface $localeResolver + * @param \Magento\CurrencyFactory $currencyFactory + */ + public function __construct( + \Magento\Event\ManagerInterface $eventManager, + \Magento\Locale\ResolverInterface $localeResolver, + \Magento\CurrencyFactory $currencyFactory + ) { + $this->_eventManager = $eventManager; + $this->_localeResolver = $localeResolver; + $this->_currencyFactory = $currencyFactory; + } + + /** + * Retrieve currency code + * + * @return string + */ + public function getDefaultCurrency() + { + return \Magento\Locale\CurrencyInterface::DEFAULT_CURRENCY; + } + + /** + * Create \Zend_Currency object for current locale + * + * @param string $currency + * @return \Magento\Currency + */ + public function getCurrency($currency) + { + \Magento\Profiler::start('locale/currency'); + if (!isset(self::$_currencyCache[$this->_localeResolver->getLocaleCode()][$currency])) { + $options = array(); + try { + $currencyObject = $this->_currencyFactory->create(array( + 'options' => $currency, + 'locale' => $this->_localeResolver->getLocale(), + )); + } catch (\Exception $e) { + $currencyObject = $this->_currencyFactory->create(array( + 'options' => $this->getDefaultCurrency(), + 'locale' => $this->_localeResolver->getLocale(), + )); + $options['name'] = $currency; + $options['currency'] = $currency; + $options['symbol'] = $currency; + } + + $options = new \Magento\Object($options); + $this->_eventManager->dispatch('currency_display_options_forming', array( + 'currency_options' => $options, + 'base_code' => $currency + )); + + $currencyObject->setFormat($options->toArray()); + self::$_currencyCache[$this->_localeResolver->getLocaleCode()][$currency] = $currencyObject; + } + \Magento\Profiler::stop('locale/currency'); + return self::$_currencyCache[$this->_localeResolver->getLocaleCode()][$currency]; + } +} diff --git a/lib/Magento/Locale/CurrencyInterface.php b/lib/Magento/Locale/CurrencyInterface.php new file mode 100644 index 00000000000..517cfd44f16 --- /dev/null +++ b/lib/Magento/Locale/CurrencyInterface.php @@ -0,0 +1,53 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Locale; + +interface CurrencyInterface +{ + /** + * Default currency + */ + const DEFAULT_CURRENCY = 'USD'; + + /** + * XML path to installed currencies + */ + const XML_PATH_ALLOW_CURRENCIES_INSTALLED = 'system/currency/installed'; + + /** + * Retrieve currency code + * + * @return string + */ + public function getDefaultCurrency(); + + /** + * Create \Magento\Currency object for current locale + * + * @param string $currency + * @return \Magento\Currency + */ + public function getCurrency($currency); +} diff --git a/lib/Magento/Locale/Format.php b/lib/Magento/Locale/Format.php new file mode 100644 index 00000000000..1b77461e0c6 --- /dev/null +++ b/lib/Magento/Locale/Format.php @@ -0,0 +1,147 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Locale; + +class Format implements \Magento\Locale\FormatInterface +{ + /** + * @var \Magento\BaseScopeResolverInterface + */ + protected $_scopeResolver; + + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + + /** + * @param \Magento\BaseScopeResolverInterface $scopeResolver + * @param ResolverInterface $localeResolver + */ + public function __construct( + \Magento\BaseScopeResolverInterface $scopeResolver, + \Magento\Locale\ResolverInterface $localeResolver + ) { + $this->_scopeResolver = $scopeResolver; + $this->_localeResolver = $localeResolver; + } + + /** + * Returns the first found number from an string + * Parsing depends on given locale (grouping and decimal) + * + * Examples for input: + * ' 2345.4356,1234' = 23455456.1234 + * '+23,3452.123' = 233452.123 + * ' 12343 ' = 12343 + * '-9456km' = -9456 + * '0' = 0 + * '2 054,10' = 2054.1 + * '2'054.52' = 2054.52 + * '2,46 GB' = 2.46 + * + * @param string|float|int $value + * @return float|null + */ + public function getNumber($value) + { + if (is_null($value)) { + return null; + } + + if (!is_string($value)) { + return floatval($value); + } + + //trim spaces and apostrophes + $value = str_replace(array('\'', ' '), '', $value); + + $separatorComa = strpos($value, ','); + $separatorDot = strpos($value, '.'); + + if ($separatorComa !== false && $separatorDot !== false) { + if ($separatorComa > $separatorDot) { + $value = str_replace('.', '', $value); + $value = str_replace(',', '.', $value); + } else { + $value = str_replace(',', '', $value); + } + } elseif ($separatorComa !== false) { + $value = str_replace(',', '.', $value); + } + + return floatval($value); + } + + /** + * Functions returns array with price formatting info + * + * @return array + */ + public function getPriceFormat() + { + $format = \Zend_Locale_Data::getContent($this->_localeResolver->getLocaleCode(), 'currencynumber'); + $symbols = \Zend_Locale_Data::getList($this->_localeResolver->getLocaleCode(), 'symbols'); + + $pos = strpos($format, ';'); + if ($pos !== false){ + $format = substr($format, 0, $pos); + } + $format = preg_replace("/[^0\#\.,]/", "", $format); + $totalPrecision = 0; + $decimalPoint = strpos($format, '.'); + if ($decimalPoint !== false) { + $totalPrecision = (strlen($format) - (strrpos($format, '.')+1)); + } else { + $decimalPoint = strlen($format); + } + $requiredPrecision = $totalPrecision; + $t = substr($format, $decimalPoint); + $pos = strpos($t, '#'); + if ($pos !== false){ + $requiredPrecision = strlen($t) - $pos - $totalPrecision; + } + + if (strrpos($format, ',') !== false) { + $group = ($decimalPoint - strrpos($format, ',') - 1); + } else { + $group = strrpos($format, '.'); + } + $integerRequired = (strpos($format, '.') - strpos($format, '0')); + + $result = array( + //TODO: change interface + 'pattern' => $this->_scopeResolver->getScope()->getCurrentCurrency()->getOutputFormat(), + 'precision' => $totalPrecision, + 'requiredPrecision' => $requiredPrecision, + 'decimalSymbol' => $symbols['decimal'], + 'groupSymbol' => $symbols['group'], + 'groupLength' => $group, + 'integerRequired' => $integerRequired + ); + + return $result; + } +} diff --git a/lib/Magento/Locale/FormatInterface.php b/lib/Magento/Locale/FormatInterface.php new file mode 100644 index 00000000000..3a30fcb9847 --- /dev/null +++ b/lib/Magento/Locale/FormatInterface.php @@ -0,0 +1,56 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Locale; + +interface FormatInterface +{ + /** + * Returns the first found number from an string + * Parsing depends on given locale (grouping and decimal) + * + * Examples for input: + * ' 2345.4356,1234' = 23455456.1234 + * '+23,3452.123' = 233452.123 + * ' 12343 ' = 12343 + * '-9456km' = -9456 + * '0' = 0 + * '2 054,10' = 2054.1 + * '2'054.52' = 2054.52 + * '2,46 GB' = 2.46 + * + * @param string|float|int $value + * @return float|null + */ + public function getNumber($value); + + /** + * Functions returns array with price formatting info for js function + * formatCurrency in js/varien/js.js + * + * @return array + */ + public function getPriceFormat(); + +} diff --git a/app/code/Magento/Core/Model/Locale/Hierarchy/Config/Converter.php b/lib/Magento/Locale/Hierarchy/Config/Converter.php similarity index 98% rename from app/code/Magento/Core/Model/Locale/Hierarchy/Config/Converter.php rename to lib/Magento/Locale/Hierarchy/Config/Converter.php index 94c9f1b7115..5ae38dbb8bf 100644 --- a/app/code/Magento/Core/Model/Locale/Hierarchy/Config/Converter.php +++ b/lib/Magento/Locale/Hierarchy/Config/Converter.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Locale\Hierarchy\Config; +namespace Magento\Locale\Hierarchy\Config; class Converter implements \Magento\Config\ConverterInterface { diff --git a/app/code/Magento/Core/Model/Locale/Hierarchy/Config/FileResolver.php b/lib/Magento/Locale/Hierarchy/Config/FileResolver.php similarity index 97% rename from app/code/Magento/Core/Model/Locale/Hierarchy/Config/FileResolver.php rename to lib/Magento/Locale/Hierarchy/Config/FileResolver.php index a41576b2da2..901cb5ce591 100644 --- a/app/code/Magento/Core/Model/Locale/Hierarchy/Config/FileResolver.php +++ b/lib/Magento/Locale/Hierarchy/Config/FileResolver.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Locale\Hierarchy\Config; +namespace Magento\Locale\Hierarchy\Config; class FileResolver implements \Magento\Config\FileResolverInterface { diff --git a/app/code/Magento/Core/Model/Locale/Hierarchy/Config/Reader.php b/lib/Magento/Locale/Hierarchy/Config/Reader.php similarity index 87% rename from app/code/Magento/Core/Model/Locale/Hierarchy/Config/Reader.php rename to lib/Magento/Locale/Hierarchy/Config/Reader.php index 9e38bcac62a..2a3655158fa 100644 --- a/app/code/Magento/Core/Model/Locale/Hierarchy/Config/Reader.php +++ b/lib/Magento/Locale/Hierarchy/Config/Reader.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Locale\Hierarchy\Config; +namespace Magento\Locale\Hierarchy\Config; class Reader extends \Magento\Config\Reader\Filesystem { @@ -45,9 +45,9 @@ class Reader extends \Magento\Config\Reader\Filesystem * @param string $defaultScope */ public function __construct( - \Magento\Core\Model\Locale\Hierarchy\Config\FileResolver $fileResolver, - \Magento\Core\Model\Locale\Hierarchy\Config\Converter $converter, - \Magento\Core\Model\Locale\Hierarchy\Config\SchemaLocator $schemaLocator, + \Magento\Locale\Hierarchy\Config\FileResolver $fileResolver, + \Magento\Locale\Hierarchy\Config\Converter $converter, + \Magento\Locale\Hierarchy\Config\SchemaLocator $schemaLocator, \Magento\Config\ValidationStateInterface $validationState, $fileName = 'config.xml', $idAttributes = array(), diff --git a/app/code/Magento/Core/Model/Locale/Hierarchy/Config/SchemaLocator.php b/lib/Magento/Locale/Hierarchy/Config/SchemaLocator.php similarity index 97% rename from app/code/Magento/Core/Model/Locale/Hierarchy/Config/SchemaLocator.php rename to lib/Magento/Locale/Hierarchy/Config/SchemaLocator.php index 04809d7463b..c81adf7bfc2 100644 --- a/app/code/Magento/Core/Model/Locale/Hierarchy/Config/SchemaLocator.php +++ b/lib/Magento/Locale/Hierarchy/Config/SchemaLocator.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Locale\Hierarchy\Config; +namespace Magento\Locale\Hierarchy\Config; class SchemaLocator implements \Magento\Config\SchemaLocatorInterface { diff --git a/lib/Magento/Locale/Lists.php b/lib/Magento/Locale/Lists.php new file mode 100644 index 00000000000..f65bd783d1b --- /dev/null +++ b/lib/Magento/Locale/Lists.php @@ -0,0 +1,291 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Locale; + +class Lists implements \Magento\Locale\ListsInterface +{ + /** + * @var \Magento\App\State + */ + protected $_appState; + + /** + * @var \Magento\BaseScopeResolverInterface + */ + protected $_scopeResolver; + + /** + * @var \Magento\Locale\ConfigInterface + */ + protected $_config; + + /** + * @var \Magento\AppInterface + */ + protected $_app; + + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + + /** + * @var string + */ + protected $_currencyInstalled; + + /** + * @param \Magento\App\State $appState + * @param \Magento\BaseScopeResolverInterface $scopeResolver + * @param \Magento\Locale\ConfigInterface $config + * @param \Magento\AppInterface $app + * @param \Magento\Locale\ResolverInterface $localeResolver + * @param string $currencyInstalled + * @param string $locale + */ + public function __construct( + \Magento\App\State $appState, + \Magento\BaseScopeResolverInterface $scopeResolver, + \Magento\Locale\ConfigInterface $config, + \Magento\AppInterface $app, + \Magento\Locale\ResolverInterface $localeResolver, + $currencyInstalled, + $locale = null + ) { + $this->_appState = $appState; + $this->_scopeResolver = $scopeResolver; + $this->_config = $config; + $this->_app = $app; + $this->_localeResolver = $localeResolver; + $this->_localeResolver->setLocale($locale); + $this->_currencyInstalled = $currencyInstalled; + } + + /** + * @inheritdoc + */ + public function getOptionLocales() + { + return $this->_getOptionLocales(); + } + + /** + * @inheritdoc + */ + public function getTranslatedOptionLocales() + { + return $this->_getOptionLocales(true); + } + + /** + * Get options array for locale dropdown + * + * @param bool $translatedName translation flag + * @return array + */ + protected function _getOptionLocales($translatedName = false) + { + $options = array(); + $locales = $this->_localeResolver->getLocale()->getLocaleList(); + $languages = $this->_localeResolver->getLocale()->getTranslationList( + 'language', $this->_localeResolver->getLocale() + ); + $countries = $this->_localeResolver->getLocale() + ->getTranslationList('territory', $this->_localeResolver->getLocale(), 2); + + $allowed = $this->_config->getAllowedLocales(); + foreach (array_keys($locales) as $code) { + if (strstr($code, '_')) { + if (!in_array($code, $allowed)) { + continue; + } + $data = explode('_', $code); + if (!isset($languages[$data[0]]) || !isset($countries[$data[1]])) { + continue; + } + if ($translatedName) { + $label = ucwords($this->_localeResolver->getLocale()->getTranslation($data[0], 'language', $code)) + . ' (' + . $this->_localeResolver->getLocale()->getTranslation($data[1], 'country', $code) + . ') / ' + . $languages[$data[0]] . ' (' . $countries[$data[1]] . ')'; + } else { + $label = $languages[$data[0]] . ' (' . $countries[$data[1]] . ')'; + } + $options[] = array( + 'value' => $code, + 'label' => $label + ); + } + } + return $this->_sortOptionArray($options); + } + + /** + * @inheritdoc + */ + public function getOptionTimezones() + { + $options= array(); + $zones = $this->getTranslationList('windowstotimezone'); + ksort($zones); + foreach ($zones as $code => $name) { + $name = trim($name); + $options[] = array( + 'label' => empty($name) ? $code : $name . ' (' . $code . ')', + 'value' => $code, + ); + } + return $this->_sortOptionArray($options); + } + + /** + * @inheritdoc + */ + public function getOptionWeekdays($preserveCodes = false, $ucFirstCode = false) + { + $options= array(); + $days = $this->getTranslationList('days'); + $days = $preserveCodes ? $days['format']['wide'] : array_values($days['format']['wide']); + foreach ($days as $code => $name) { + $options[] = array( + 'label' => $name, + 'value' => $ucFirstCode ? ucfirst($code) : $code, + ); + } + return $options; + } + + /** + * @inheritdoc + */ + public function getOptionCountries() + { + $options = array(); + $countries = $this->getCountryTranslationList(); + + foreach ($countries as $code=>$name) { + $options[] = array( + 'label' => $name, + 'value' => $code, + ); + } + return $this->_sortOptionArray($options); + } + + /** + * @inheritdoc + */ + public function getOptionCurrencies() + { + $currencies = $this->getTranslationList('currencytoname'); + $options = array(); + $allowed = $this->_getAllowedCurrencies(); + + foreach ($currencies as $name => $code) { + if (!in_array($code, $allowed)) { + continue; + } + + $options[] = array( + 'label' => $name, + 'value' => $code, + ); + } + return $this->_sortOptionArray($options); + } + + /** + * Retrieve array of allowed currencies + * + * @return array + */ + protected function _getAllowedCurrencies() + { + if ($this->_appState->isInstalled()) { + $allowed = explode(',', $this->_scopeResolver->getScope() + ->getConfig($this->_currencyInstalled) + ); + } else { + $allowed = $this->_config->getAllowedCurrencies(); + } + return $allowed; + } + + /** + * @inheritdoc + */ + public function getOptionAllCurrencies() + { + $currencies = $this->getTranslationList('currencytoname'); + $options = array(); + foreach ($currencies as $name=>$code) { + $options[] = array( + 'label' => $name, + 'value' => $code, + ); + } + return $this->_sortOptionArray($options); + } + + /** + * @param array $option + * @return array + */ + protected function _sortOptionArray($option) + { + $data = array(); + foreach ($option as $item) { + $data[$item['value']] = $item['label']; + } + asort($data); + $option = array(); + foreach ($data as $key => $label) { + $option[] = array( + 'value' => $key, + 'label' => $label + ); + } + return $option; + } + + /** + * @inheritdoc + */ + public function getTranslationList($path = null, $value = null) + { + return $this->_localeResolver->getLocale() + ->getTranslationList($path, $this->_localeResolver->getLocale(), $value); + } + + /** + * @inheritdoc + */ + public function getCountryTranslation($value) + { + return $this->_localeResolver->getLocale() + ->getTranslation($value, 'country', $this->_localeResolver->getLocale()); + } +} diff --git a/lib/Magento/Locale/ListsInterface.php b/lib/Magento/Locale/ListsInterface.php new file mode 100644 index 00000000000..45c7c3abe85 --- /dev/null +++ b/lib/Magento/Locale/ListsInterface.php @@ -0,0 +1,99 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Locale; + +interface ListsInterface +{ + /** + * Get options array for locale dropdown in current locale + * + * @return array + */ + public function getOptionLocales(); + + /** + * Get translated to original locale options array for locale dropdown + * + * @return array + */ + public function getTranslatedOptionLocales(); + + /** + * Retrieve timezone option list + * + * @return array + */ + public function getOptionTimezones(); + + /** + * Retrieve days of week option list + * + * @param bool $preserveCodes + * @param bool $ucFirstCode + * + * @return array + */ + public function getOptionWeekdays($preserveCodes = false, $ucFirstCode = false); + + /** + * Retrieve country option list + * + * @return array + */ + public function getOptionCountries(); + + /** + * Retrieve currency option list + * + * @return array + */ + public function getOptionCurrencies(); + + /** + * Retrieve all currency option list + * + * @return array + */ + public function getOptionAllCurrencies(); + + /** + * Returns localized informations as array, supported are several + * types of information. + * For detailed information about the types look into the documentation + * + * @param string $path (Optional) Type of information to return + * @param string $value (Optional) Value for detail list + * @return array Array with the wished information in the given language + */ + public function getTranslationList($path = null, $value = null); + + /** + * Returns the localized country name + * + * @param $value string Name to get detailed information about + * @return array + */ + public function getCountryTranslation($value); +} diff --git a/lib/Magento/Locale/Resolver.php b/lib/Magento/Locale/Resolver.php new file mode 100644 index 00000000000..a07e462d656 --- /dev/null +++ b/lib/Magento/Locale/Resolver.php @@ -0,0 +1,207 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Locale; + +class Resolver implements \Magento\Locale\ResolverInterface +{ + /** + * Default locale code + * + * @var string + */ + protected $_defaultLocale; + + /** + * Locale object + * + * @var \Magento\LocaleInterface + */ + protected $_locale; + + /** + * Locale code + * + * @var string + */ + protected $_localeCode; + + /** + * @var \Magento\Locale\ScopeConfigInterface + */ + protected $_scopeConfig; + + /** + * @var \Magento\AppInterface + */ + protected $_app; + + /** + * Emulated locales stack + * + * @var array + */ + protected $_emulatedLocales = array(); + + /** + * @var \Magento\LocaleFactory + */ + protected $_localeFactory; + + /** + * @param \Magento\Locale\ScopeConfigInterface $scopeConfig + * @param \Magento\AppInterface $app + * @param \Magento\LocaleFactory $localeFactory + * @param string $defaultLocalePath + * @param mixed $locale + */ + public function __construct( + \Magento\Locale\ScopeConfigInterface $scopeConfig, + \Magento\AppInterface $app, + \Magento\LocaleFactory $localeFactory, + $defaultLocalePath, + $locale = null + ) { + $this->_app = $app; + $this->_scopeConfig = $scopeConfig; + $this->_localeFactory = $localeFactory; + $this->_defaultLocalePath = $defaultLocalePath; + $this->setLocale($locale); + } + + /** + * {@inheritdoc} + */ + public function getDefaultLocalePath() + { + return $this->_defaultLocalePath; + } + + /** + * {@inheritdoc} + */ + public function setDefaultLocale($locale) + { + $this->_defaultLocale = $locale; + return $this; + } + + /** + * {@inheritdoc} + */ + public function getDefaultLocale() + { + if (!$this->_defaultLocale) { + $locale = $this->_scopeConfig->getConfig($this->getDefaultLocalePath()); + if (!$locale) { + $locale = \Magento\Locale\ResolverInterface::DEFAULT_LOCALE; + } + $this->_defaultLocale = $locale; + } + return $this->_defaultLocale; + } + + /** + * {@inheritdoc} + */ + public function setLocale($locale = null) + { + if (($locale !== null) && is_string($locale)) { + $this->_localeCode = $locale; + } else { + $this->_localeCode = $this->getDefaultLocale(); + } + return $this; + } + + /** + * {@inheritdoc} + */ + public function getLocale() + { + if (!$this->_locale) { + \Zend_Locale_Data::setCache($this->_app->getCache()->getLowLevelFrontend()); + $this->_locale = $this->_localeFactory->create(array('locale' => $this->getLocaleCode())); + } elseif ($this->_locale->__toString() != $this->_localeCode) { + $this->setLocale($this->_localeCode); + } + + return $this->_locale; + } + + /** + * {@inheritdoc} + */ + public function getLocaleCode() + { + if ($this->_localeCode === null) { + $this->setLocale(); + } + return $this->_localeCode; + } + + /** + * {@inheritdoc} + */ + public function setLocaleCode($code) + { + $this->_localeCode = $code; + $this->_locale = null; + return $this; + } + + /** + * {@inheritdoc} + */ + public function emulate($scopeId) + { + $result = null; + if ($scopeId) { + $this->_emulatedLocales[] = clone $this->getLocale(); + $this->_locale = $this->_localeFactory->create(array( + 'locale' => $this->_scopeConfig->getConfig($this->getDefaultLocalePath(), $scopeId) + )); + $this->_localeCode = $this->_locale->toString(); + $result = $this->_localeCode; + } else { + $this->_emulatedLocales[] = false; + } + return $result; + } + + /** + * {@inheritdoc} + */ + public function revert() + { + $result = null; + $locale = array_pop($this->_emulatedLocales); + if ($locale) { + $this->_locale = $locale; + $this->_localeCode = $this->_locale->toString(); + $result = $this->_localeCode; + } + return $result; + } +} diff --git a/lib/Magento/Locale/ResolverInterface.php b/lib/Magento/Locale/ResolverInterface.php new file mode 100644 index 00000000000..e22488c2400 --- /dev/null +++ b/lib/Magento/Locale/ResolverInterface.php @@ -0,0 +1,100 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Locale; + +interface ResolverInterface +{ + /** + * Default locale + */ + const DEFAULT_LOCALE = 'en_US'; + + /** + * Return path to default locale + * + * @return string + */ + public function getDefaultLocalePath(); + + /** + * Set default locale code + * + * @param string $locale + * @return \Magento\Locale\ResolverInterface + */ + public function setDefaultLocale($locale); + + /** + * Retrieve default locale code + * + * @return string + */ + public function getDefaultLocale(); + + /** + * Set locale + * + * @param string $locale + * @return \Magento\Locale\ResolverInterface + */ + public function setLocale($locale = null); + + /** + * Retrieve locale object + * + * @return \Magento\LocaleInterface + */ + public function getLocale(); + + /** + * Retrieve locale code + * + * @return string + */ + public function getLocaleCode(); + + /** + * Specify current locale code + * + * @param string $code + * @return \Magento\Locale\ResolverInterface + */ + public function setLocaleCode($code); + + /** + * Push current locale to stack and replace with locale from specified store + * + * @param int $scopeId + * @return string|null + */ + public function emulate($scopeId); + + /** + * Get last locale, used before last emulation + * + * @return string|null + */ + public function revert(); +} diff --git a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceInterfaceWithoutNamespace.php b/lib/Magento/Locale/ScopeConfigInterface.php similarity index 71% rename from dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceInterfaceWithoutNamespace.php rename to lib/Magento/Locale/ScopeConfigInterface.php index ffe41d879ac..b675a8fb655 100644 --- a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/SourceInterfaceWithoutNamespace.php +++ b/lib/Magento/Locale/ScopeConfigInterface.php @@ -18,23 +18,29 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Code - * @subpackage unit_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Code\GeneratorTest; -interface SourceInterfaceWithoutNamespace - extends \Magento\Code\GeneratorTest\ParentInterfaceWithoutNamespace +namespace Magento\Locale; + +interface ScopeConfigInterface { /** - * Do some work with params + * Retrieve scope config value * - * @param $param1 - * @param array $param2 + * @param string $path + * @param mixed $scope * @return mixed */ - public function doWorkWithParams($param1, array $param2); + public function getConfig($path, $scope = null); + + /** + * Retrieve scope config flag + * + * @param string $path + * @param mixed $scope + * @return bool + */ + public function getConfigFlag($path, $scope = null); } diff --git a/app/code/Magento/Core/Model/Locale/Validator.php b/lib/Magento/Locale/Validator.php similarity index 88% rename from app/code/Magento/Core/Model/Locale/Validator.php rename to lib/Magento/Locale/Validator.php index 5c562032ad8..399c535e4cb 100644 --- a/app/code/Magento/Core/Model/Locale/Validator.php +++ b/lib/Magento/Locale/Validator.php @@ -31,21 +31,21 @@ * @package Magento_Core * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Core\Model\Locale; +namespace Magento\Locale; class Validator { /** - * @var \Magento\Core\Model\Locale\Config + * @var \Magento\Locale\ConfigInterface */ protected $_localeConfig; /** * Constructor * - * @param \Magento\Core\Model\Locale\Config $localeConfig + * @param \Magento\Locale\ConfigInterface $localeConfig */ - public function __construct(\Magento\Core\Model\Locale\Config $localeConfig) + public function __construct(\Magento\Locale\ConfigInterface $localeConfig) { $this->_localeConfig = $localeConfig; } diff --git a/lib/Magento/LocaleFactory.php b/lib/Magento/LocaleFactory.php new file mode 100644 index 00000000000..24f0a369404 --- /dev/null +++ b/lib/Magento/LocaleFactory.php @@ -0,0 +1,61 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento; + +class LocaleFactory +{ + /** + * @var \Magento\ObjectManager + */ + protected $_objectManager = null; + + /** + * @var string + */ + protected $_instanceName = null; + + /** + * @param \Magento\ObjectManager $objectManager + * @param string $instanceName + */ + public function __construct( + \Magento\ObjectManager $objectManager, + $instanceName = 'Magento\LocaleInterface' + ) { + $this->_objectManager = $objectManager; + $this->_instanceName = $instanceName; + } + + /** + * Create class instance with specified parameters + * + * @param array $data + * @return \Magento\LocaleInterface + */ + public function create(array $data = array()) + { + return $this->_objectManager->create($this->_instanceName, $data); + } +} diff --git a/lib/Magento/LocaleInterface.php b/lib/Magento/LocaleInterface.php new file mode 100644 index 00000000000..75f1527af03 --- /dev/null +++ b/lib/Magento/LocaleInterface.php @@ -0,0 +1,337 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento; + +interface LocaleInterface +{ + /** + * Serialization Interface + * + * @return string + */ + public function serialize(); + + /** + * Returns a string representation of the object + * + * @return string + */ + public function toString(); + + /** + * Returns a string representation of the object + * Alias for toString + * + * @return string + */ + public function __toString(); + + /** + * Return the default locale + * + * @return array Returns an array of all locale string + */ + public static function getDefault(); + + /** + * Sets a new default locale which will be used when no locale can be detected + * If provided you can set a quality between 0 and 1 (or 2 and 100) + * which represents the percent of quality the browser + * requested within HTTP + * + * @param string|\Magento\LocaleInterface $locale Locale to set + * @param float $quality The quality to set from 0 to 1 + * @throws \Zend_Locale_Exception When a autolocale was given + * @throws \Zend_Locale_Exception When a unknown locale was given + * @return void + */ + public static function setDefault($locale, $quality = 1); + + /** + * Expects the Systems standard locale + * + * For Windows: + * f.e.: LC_COLLATE=C;LC_CTYPE=German_Austria.1252;LC_MONETARY=C + * would be recognised as de_AT + * + * @return array + */ + public static function getEnvironment(); + + /** + * Return an array of all accepted languages of the client + * Expects RFC compilant Header !! + * + * The notation can be : + * de,en-UK-US;q=0.5,fr-FR;q=0.2 + * + * @return array - list of accepted languages including quality + */ + public static function getBrowser(); + + /** + * Sets a new locale + * + * @param string|\Magento\LocaleInterface $locale (Optional) New locale to set + * @return void + */ + public function setLocale($locale = null); + + /** + * Returns the language part of the locale + * + * @return string + */ + public function getLanguage(); + + /** + * Returns the region part of the locale if available + * + * @return string|false - Regionstring + */ + public function getRegion(); + + /** + * Return the accepted charset of the client + * + * @return string + */ + public static function getHttpCharset(); + + /** + * Returns true if both locales are equal + * + * @param \Zend_Locale $object Locale to check for equality + * @return boolean + */ + public function equals(\Zend_Locale $object); + + /** + * Returns localized informations as array, supported are several + * types of informations. + * For detailed information about the types look into the documentation + * + * @param string $path (Optional) Type of information to return + * @param string|\Magento\LocaleInterface $locale (Optional) Locale|Language for which this informations should be returned + * @param string $value (Optional) Value for detail list + * @return array Array with the wished information in the given language + */ + public static function getTranslationList($path = null, $locale = null, $value = null); + + /** + * Returns an array with the name of all languages translated to the given language + * + * @param string|\Magento\LocaleInterface $locale (Optional) Locale for language translation + * @return array + * @deprecated + */ + public static function getLanguageTranslationList($locale = null); + + /** + * Returns an array with the name of all scripts translated to the given language + * + * @param string|\Magento\LocaleInterface $locale (Optional) Locale for script translation + * @return array + * @deprecated + */ + public static function getScriptTranslationList($locale = null); + + /** + * Returns an array with the name of all countries translated to the given language + * + * @param string|\Magento\LocaleInterface $locale (Optional) Locale for country translation + * @return array + * @deprecated + */ + public static function getCountryTranslationList($locale = null); + + /** + * Returns an array with the name of all territories translated to the given language + * All territories contains other countries. + * + * @param string|\Magento\LocaleInterface $locale (Optional) Locale for territory translation + * @return array + * @deprecated + */ + public static function getTerritoryTranslationList($locale = null); + + /** + * Returns a localized information string, supported are several types of informations. + * For detailed information about the types look into the documentation + * + * @param string $value Name to get detailed information about + * @param string $path (Optional) Type of information to return + * @param string|\Magento\LocaleInterface $locale (Optional) Locale|Language for which this informations should be returned + * @return string|false The wished information in the given language + */ + public static function getTranslation($value = null, $path = null, $locale = null); + + /** + * Returns the localized language name + * + * @param string $value Name to get detailed information about + * @param string $locale (Optional) Locale for language translation + * @return array + * @deprecated + */ + public static function getLanguageTranslation($value, $locale = null); + + /** + * Returns the localized script name + * + * @param string $value Name to get detailed information about + * @param string $locale (Optional) locale for script translation + * @return array + * @deprecated + */ + public static function getScriptTranslation($value, $locale = null); + + /** + * Returns the localized country name + * + * @param string $value Name to get detailed information about + * @param string|\Magento\LocaleInterface $locale (Optional) Locale for country translation + * @return array + * @deprecated + */ + public static function getCountryTranslation($value, $locale = null); + + /** + * Returns the localized territory name + * All territories contains other countries. + * + * @param string $value Name to get detailed information about + * @param string|\Magento\LocaleInterface $locale (Optional) Locale for territory translation + * @return array + * @deprecated + */ + public static function getTerritoryTranslation($value, $locale = null); + + /** + * Returns an array with translated yes strings + * + * @param string|\Magento\LocaleInterface $locale (Optional) Locale for language translation (defaults to $this locale) + * @return array + */ + public static function getQuestion($locale = null); + + /** + * Checks if a locale identifier is a real locale or not + * Examples: + * "en_XX" refers to "en", which returns true + * "XX_yy" refers to "root", which returns false + * + * @param string|\Magento\LocaleInterface $locale Locale to check for + * @param boolean $strict (Optional) If true, no rerouting will be done when checking + * @param boolean $compatible (DEPRECATED) Only for internal usage, brakes compatibility mode + * @return boolean If the locale is known dependend on the settings + */ + public static function isLocale($locale, $strict = false, $compatible = true); + + /** + * Finds the proper locale based on the input + * Checks if it exists, degrades it when necessary + * Detects registry locale and when all fails tries to detect a automatic locale + * Returns the found locale as string + * + * @param string $locale + * @throws \Zend_Locale_Exception When the given locale is no locale or the autodetection fails + * @return string + */ + public static function findLocale($locale = null); + + /** + * Returns the expected locale for a given territory + * + * @param string $territory Territory for which the locale is being searched + * @return string|null Locale string or null when no locale has been found + */ + public static function getLocaleToTerritory($territory); + + /** + * Returns a list of all known locales where the locale is the key + * Only real locales are returned, the internal locales 'root', 'auto', 'browser' + * and 'environment' are suppressed + * + * @return array List of all Locales + */ + public static function getLocaleList(); + + /** + * Returns the set cache + * + * @return \Zend_Cache_Core The set cache + */ + public static function getCache(); + + /** + * Sets a cache + * + * @param \Zend_Cache_Core $cache Cache to set + * @return void + */ + public static function setCache(\Zend_Cache_Core $cache); + + /** + * Returns true when a cache is set + * + * @return boolean + */ + public static function hasCache(); + + /** + * Removes any set cache + * + * @return void + */ + public static function removeCache(); + + /** + * Clears all set cache data + * + * @param string $tag Tag to clear when the default tag name is not used + * @return void + */ + public static function clearCache($tag = null); + + /** + * Disables the set cache + * + * @param boolean $flag True disables any set cache, default is false + * @return void + */ + public static function disableCache($flag); + + /** + * Search the locale automatically and return all used locales + * ordered by quality + * + * Standard Searchorder is Browser, Environment, Default + * + * @param string $searchorder (Optional) Searchorder + * @return array Returns an array of all detected locales + */ + public static function getOrder($order = null); +} diff --git a/lib/Magento/Math/Random.php b/lib/Magento/Math/Random.php index e4e32e5386a..12ca1a2ad1e 100644 --- a/lib/Magento/Math/Random.php +++ b/lib/Magento/Math/Random.php @@ -28,29 +28,13 @@ namespace Magento\Math; */ class Random { - const CHARS_LOWERS = 'abcdefghijklmnopqrstuvwxyz'; - const CHARS_UPPERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - const CHARS_DIGITS = '0123456789'; - const CHARS_SPECIALS = '!$*+-.=?@^_|~'; - const CHARS_PASSWORD_LOWERS = 'abcdefghjkmnpqrstuvwxyz'; - const CHARS_PASSWORD_UPPERS = 'ABCDEFGHJKLMNPQRSTUVWXYZ'; - const CHARS_PASSWORD_DIGITS = '23456789'; - const CHARS_PASSWORD_SPECIALS = '!$*-.=?@_'; - - /** - * Permission level to deny access - */ - const RULE_PERM_DENY = 0; - - /** - * Permission level to inherit access from parent role - */ - const RULE_PERM_INHERIT = 1; - - /** - * Permission level to allow access + /**#@+ + * Frequently used character classes */ - const RULE_PERM_ALLOW = 2; + const CHARS_LOWERS = 'abcdefghijklmnopqrstuvwxyz'; + const CHARS_UPPERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + const CHARS_DIGITS = '0123456789'; + /**#@-*/ /** * Get random string diff --git a/lib/Magento/Module/Declaration/Reader/Filesystem.php b/lib/Magento/Module/Declaration/Reader/Filesystem.php index 560c494ccb5..8efa6b330e2 100644 --- a/lib/Magento/Module/Declaration/Reader/Filesystem.php +++ b/lib/Magento/Module/Declaration/Reader/Filesystem.php @@ -28,7 +28,9 @@ namespace Magento\Module\Declaration\Reader; use Magento\Module\Declaration\FileResolver; use Magento\Module\Declaration\Converter\Dom; use Magento\Module\Declaration\SchemaLocator; +use Magento\Module\DependencyManagerInterface; use Magento\Config\ValidationStateInterface; +use Magento\App\State; class Filesystem extends \Magento\Config\Reader\Filesystem { @@ -39,6 +41,16 @@ class Filesystem extends \Magento\Config\Reader\Filesystem */ protected $_allowedModules; + /** + * @var \Magento\App\State + */ + protected $appState; + + /** + * @var \Magento\Module\DependencyManagerInterface + */ + protected $dependencyManager; + /** * @var array */ @@ -54,6 +66,8 @@ class Filesystem extends \Magento\Config\Reader\Filesystem * @param Dom $converter * @param SchemaLocator $schemaLocator * @param ValidationStateInterface $validationState + * @param State $appState + * @param DependencyManagerInterface $dependencyManager * @param string $fileName * @param array $idAttributes * @param string $domDocumentClass @@ -65,6 +79,8 @@ class Filesystem extends \Magento\Config\Reader\Filesystem Dom $converter, SchemaLocator $schemaLocator, ValidationStateInterface $validationState, + State $appState, + DependencyManagerInterface $dependencyManager, $fileName = 'module.xml', $idAttributes = array(), $domDocumentClass = 'Magento\Config\Dom', @@ -82,6 +98,8 @@ class Filesystem extends \Magento\Config\Reader\Filesystem $defaultScope ); $this->_allowedModules = $allowedModules; + $this->appState = $appState; + $this->dependencyManager = $dependencyManager; } /** @@ -90,8 +108,11 @@ class Filesystem extends \Magento\Config\Reader\Filesystem public function read($scope = null) { $activeModules = $this->_filterActiveModules(parent::read($scope)); - foreach ($activeModules as $moduleConfig) { - $this->_checkModuleDependencies($moduleConfig, $activeModules); + + if ($this->appState->isInstalled()) { + foreach ($activeModules as $moduleConfig) { + $this->dependencyManager->checkModuleDependencies($moduleConfig, $activeModules); + } } return $this->_sortModules($activeModules); } @@ -115,86 +136,6 @@ class Filesystem extends \Magento\Config\Reader\Filesystem return $activeModules; } - /** - * Check dependencies of the given module - * - * @param array $moduleConfig - * @param array $activeModules - * @return void - * @throws \Exception - */ - protected function _checkModuleDependencies(array $moduleConfig, array $activeModules) - { - // Check that required modules are active - foreach ($moduleConfig['dependencies']['modules'] as $moduleName) { - if (!isset($activeModules[$moduleName])) { - throw new \Exception( - "Module '{$moduleConfig['name']}' depends on '{$moduleName}' that is missing or not active." - ); - } - } - // Check that required extensions are loaded - foreach ($moduleConfig['dependencies']['extensions']['strict'] as $extensionData) { - $extensionName = $extensionData['name']; - $minVersion = isset($extensionData['minVersion']) ? $extensionData['minVersion'] : null; - if (!$this->_isPhpExtensionLoaded($extensionName, $minVersion)) { - throw new \Exception( - "Module '{$moduleConfig['name']}' depends on '{$extensionName}' PHP extension that is not loaded." - ); - } - } - foreach ($moduleConfig['dependencies']['extensions']['alternatives'] as $altExtensions) { - $this->_checkAlternativeExtensions($moduleConfig['name'], $altExtensions); - } - } - - /** - * Check if at least one of the extensions is loaded - * - * @param string $moduleName - * @param array $altExtensions - * @return void - * @throws \Exception - */ - protected function _checkAlternativeExtensions($moduleName, array $altExtensions) - { - $extensionNames = array(); - foreach ($altExtensions as $extensionData) { - $extensionName = $extensionData['name']; - $minVersion = isset($extensionData['minVersion']) ? $extensionData['minVersion'] : null; - if ($this->_isPhpExtensionLoaded($extensionName, $minVersion)) { - return; - } - $extensionNames[] = $extensionName; - } - if (!empty($extensionNames)) { - throw new \Exception( - "Module '{$moduleName}' depends on at least one of the following PHP extensions: " - . implode(',', $extensionNames) . '.' - ); - } - return; - } - - /** - * Check if required version of PHP extension is loaded - * - * @param string $extensionName - * @param string|null $minVersion - * @return boolean - */ - protected function _isPhpExtensionLoaded($extensionName, $minVersion = null) - { - if (extension_loaded($extensionName)) { - if (is_null($minVersion)) { - return true; - } elseif (version_compare($minVersion, phpversion($extensionName), '<=')) { - return true; - } - } - return false; - } - /** * Sort module declarations based on module dependencies * @@ -213,7 +154,7 @@ class Filesystem extends \Magento\Config\Reader\Filesystem foreach ($modules as $moduleName => $value) { $moduleDependencyMap[] = array( 'moduleName' => $moduleName, - 'dependencies' => $this->_getExtendedModuleDependencies($moduleName, $modules), + 'dependencies' => $this->dependencyManager->getExtendedModuleDependencies($moduleName, $modules), ); } @@ -236,32 +177,4 @@ class Filesystem extends \Magento\Config\Reader\Filesystem return $sortedModules; } - - /** - * Recursively identify all module dependencies and detect circular ones - * - * @param string $moduleName - * @param array $modules - * @param array $usedModules - * @return array - * @throws \Exception - */ - protected function _getExtendedModuleDependencies($moduleName, array $modules, array $usedModules = array()) - { - $usedModules[] = $moduleName; - $dependencyList = $modules[$moduleName]['dependencies']['modules']; - foreach ($dependencyList as $relatedModuleName) { - if (in_array($relatedModuleName, $usedModules)) { - throw new \Exception( - "Module '$moduleName' cannot depend on '$relatedModuleName' since it creates circular dependency." - ); - } - if (empty($modules[$relatedModuleName])) { - continue; - } - $relatedDependencies = $this->_getExtendedModuleDependencies($relatedModuleName, $modules, $usedModules); - $dependencyList = array_unique(array_merge($dependencyList, $relatedDependencies)); - } - return $dependencyList; - } } diff --git a/lib/Magento/Module/DependencyManager.php b/lib/Magento/Module/DependencyManager.php new file mode 100644 index 00000000000..c2c109335da --- /dev/null +++ b/lib/Magento/Module/DependencyManager.php @@ -0,0 +1,141 @@ +<?php +/** + * Dependency manager, checks if all dependencies on modules and extensions are satisfied + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Module; + +class DependencyManager implements DependencyManagerInterface +{ + /** + * Check dependencies of the given module + * + * @param array $moduleConfig + * @param array $activeModules + * @return void + * @throws \Exception + */ + public function checkModuleDependencies(array $moduleConfig, array $activeModules = array()) + { + // Check that required modules are active + if ($activeModules) { + foreach ($moduleConfig['dependencies']['modules'] as $moduleName) { + if (!isset($activeModules[$moduleName])) { + throw new \Exception( + "Module '{$moduleConfig['name']}' depends on '{$moduleName}' that is missing or not active." + ); + } + } + } + + // Check that required extensions are loaded + foreach ($moduleConfig['dependencies']['extensions']['strict'] as $extensionData) { + $extensionName = $extensionData['name']; + $minVersion = isset($extensionData['minVersion']) ? $extensionData['minVersion'] : null; + if (!$this->_isPhpExtensionLoaded($extensionName, $minVersion)) { + throw new \Exception( + "Module '{$moduleConfig['name']}' depends on '{$extensionName}' PHP extension that is not loaded." + ); + } + } + foreach ($moduleConfig['dependencies']['extensions']['alternatives'] as $altExtensions) { + $this->_checkAlternativeExtensions($moduleConfig['name'], $altExtensions); + } + } + + + /** + * Recursively identify all module dependencies and detect circular ones + * + * @param string $moduleName + * @param array $modules + * @param array $usedModules + * @return array + * @throws \Exception + */ + public function getExtendedModuleDependencies($moduleName, array $modules, array $usedModules = array()) + { + $usedModules[] = $moduleName; + $dependencyList = $modules[$moduleName]['dependencies']['modules']; + foreach ($dependencyList as $relatedModuleName) { + if (in_array($relatedModuleName, $usedModules)) { + throw new \Exception( + "Module '$moduleName' cannot depend on '$relatedModuleName' since it creates circular dependency." + ); + } + if (empty($modules[$relatedModuleName])) { + continue; + } + $relatedDependencies = $this->getExtendedModuleDependencies($relatedModuleName, $modules, $usedModules); + $dependencyList = array_unique(array_merge($dependencyList, $relatedDependencies)); + } + return $dependencyList; + } + + /** + * Check if at least one of the extensions is loaded + * + * @param string $moduleName + * @param array $altExtensions + * @return void + * @throws \Exception + */ + protected function _checkAlternativeExtensions($moduleName, array $altExtensions) + { + $extensionNames = array(); + foreach ($altExtensions as $extensionData) { + $extensionName = $extensionData['name']; + $minVersion = isset($extensionData['minVersion']) ? $extensionData['minVersion'] : null; + if ($this->_isPhpExtensionLoaded($extensionName, $minVersion)) { + return; + } + $extensionNames[] = $extensionName; + } + if (!empty($extensionNames)) { + throw new \Exception( + "Module '{$moduleName}' depends on at least one of the following PHP extensions: " + . implode(',', $extensionNames) . '.' + ); + } + return; + } + + /** + * Check if required version of PHP extension is loaded + * + * @param string $extensionName + * @param string|null $minVersion + * @return boolean + */ + protected function _isPhpExtensionLoaded($extensionName, $minVersion = null) + { + if (extension_loaded($extensionName)) { + if (is_null($minVersion)) { + return true; + } elseif (version_compare($minVersion, phpversion($extensionName), '<=')) { + return true; + } + } + return false; + } +} diff --git a/lib/Magento/Module/DependencyManagerInterface.php b/lib/Magento/Module/DependencyManagerInterface.php new file mode 100644 index 00000000000..a3acf65a870 --- /dev/null +++ b/lib/Magento/Module/DependencyManagerInterface.php @@ -0,0 +1,51 @@ +<?php +/** + * Dependency manager, checks if all dependencies on modules and extensions are satisfied + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Module; + +interface DependencyManagerInterface +{ + /** + * Check dependencies of the given module + * + * @param array $moduleConfig + * @param array $activeModules + * @return void + * @throws \Exception + */ + public function checkModuleDependencies(array $moduleConfig, array $activeModules = array()); + + + /** + * Recursively identify all module dependencies and detect circular ones + * + * @param string $moduleName + * @param array $modules + * @param array $usedModules + * @return array + * @throws \Exception + */ + public function getExtendedModuleDependencies($moduleName, array $modules, array $usedModules = array()); +} diff --git a/lib/Magento/Module/FrontController/Plugin/Install.php b/lib/Magento/Module/FrontController/Plugin/Install.php index afdee09c7d4..d6a7d59ae08 100644 --- a/lib/Magento/Module/FrontController/Plugin/Install.php +++ b/lib/Magento/Module/FrontController/Plugin/Install.php @@ -28,7 +28,6 @@ namespace Magento\Module\FrontController\Plugin; use Magento\Cache\FrontendInterface; use Magento\Module\UpdaterInterface; use Magento\App\State; -use Magento\Code\Plugin\InvocationChain; class Install { @@ -63,17 +62,23 @@ class Install } /** - * @param array $arguments - * @param InvocationChain $invocationChain - * @return mixed + * @param \Magento\App\FrontController $subject + * @param callable $proceed + * @param \Magento\App\RequestInterface $request + * + * @return \Magento\App\ResponseInterface + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundDispatch($arguments, InvocationChain $invocationChain) - { + public function aroundDispatch( + \Magento\App\FrontController $subject, + \Closure $proceed, + \Magento\App\RequestInterface $request + ) { if ($this->_appState->isInstalled() && !$this->_cache->load('data_upgrade')) { $this->_dbUpdater->updateScheme(); $this->_dbUpdater->updateData(); $this->_cache->save('true', 'data_upgrade'); } - return $invocationChain->proceed($arguments); + return $proceed($request); } } diff --git a/lib/Magento/Mview/View/StateInterface.php b/lib/Magento/Mview/View/StateInterface.php index 2e29805d71b..93d54a19b09 100644 --- a/lib/Magento/Mview/View/StateInterface.php +++ b/lib/Magento/Mview/View/StateInterface.php @@ -127,7 +127,7 @@ interface StateInterface /** * Set state updated time * - * @param string|int|\Zend_Date $updated + * @param string|int|\Magento\Stdlib\DateTime\DateInterface $updated * @return \Magento\Mview\View\StateInterface */ public function setUpdated($updated); diff --git a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/ParentInterfaceWithoutNamespace.php b/lib/Magento/Object/IdentityInterface.php similarity index 80% rename from dev/tests/integration/testsuite/Magento/Code/GeneratorTest/ParentInterfaceWithoutNamespace.php rename to lib/Magento/Object/IdentityInterface.php index 61b92f405c9..b6151c6cc3c 100644 --- a/dev/tests/integration/testsuite/Magento/Code/GeneratorTest/ParentInterfaceWithoutNamespace.php +++ b/lib/Magento/Object/IdentityInterface.php @@ -18,20 +18,21 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Code - * @subpackage unit_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Code\GeneratorTest; +namespace Magento\Object; -interface ParentInterfaceWithoutNamespace +/** + * Interface IdentityInterface + * @package Magento\Object + */ +interface IdentityInterface { /** - * Do some work + * Return unique ID(s) for each object in system * - * @return int + * @return array */ - public function doWork(); -} + public function getIdentities(); +} \ No newline at end of file diff --git a/lib/Magento/ObjectManager.php b/lib/Magento/ObjectManager.php index 3f2fd4a0138..85accaf15ec 100644 --- a/lib/Magento/ObjectManager.php +++ b/lib/Magento/ObjectManager.php @@ -28,15 +28,6 @@ namespace Magento; interface ObjectManager { - /** - * Set factory - * - * @param ObjectManager\Factory $factory - * - * @return void - */ - public function setFactory(ObjectManager\Factory $factory); - /** * Create new object instance * diff --git a/lib/Magento/Code/Generator/Factory.php b/lib/Magento/ObjectManager/Code/Generator/Factory.php similarity index 99% rename from lib/Magento/Code/Generator/Factory.php rename to lib/Magento/ObjectManager/Code/Generator/Factory.php index 869e321891e..5eac499ba93 100644 --- a/lib/Magento/Code/Generator/Factory.php +++ b/lib/Magento/ObjectManager/Code/Generator/Factory.php @@ -23,8 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - -namespace Magento\Code\Generator; +namespace Magento\ObjectManager\Code\Generator; class Factory extends \Magento\Code\Generator\EntityAbstract { diff --git a/lib/Magento/Code/Generator/Proxy.php b/lib/Magento/ObjectManager/Code/Generator/Proxy.php similarity index 99% rename from lib/Magento/Code/Generator/Proxy.php rename to lib/Magento/ObjectManager/Code/Generator/Proxy.php index 28ac6095edb..62f488a9893 100644 --- a/lib/Magento/Code/Generator/Proxy.php +++ b/lib/Magento/ObjectManager/Code/Generator/Proxy.php @@ -1,5 +1,7 @@ <?php /** + * Proxy generator + * * Magento * * NOTICE OF LICENSE @@ -18,13 +20,11 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Code * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Code\Generator; +namespace Magento\ObjectManager\Code\Generator; class Proxy extends \Magento\Code\Generator\EntityAbstract { diff --git a/lib/Magento/ObjectManager/Config/Config.php b/lib/Magento/ObjectManager/Config/Config.php index 9d690d1c4df..546645fe2e9 100644 --- a/lib/Magento/ObjectManager/Config/Config.php +++ b/lib/Magento/ObjectManager/Config/Config.php @@ -78,20 +78,6 @@ class Config implements \Magento\ObjectManager\Config */ protected $_nonShared = array(); - /** - * Plugin configuration - * - * @var array - */ - protected $_plugins = array(); - - /** - * Merged plugin config - * - * @var array - */ - protected $_mergedPlugins = array(); - /** * List of relations * @@ -187,6 +173,7 @@ class Config implements \Magento\ObjectManager\Config */ public function getPreference($type) { + $type = ltrim($type, '\\'); $preferencePath = array(); while (isset($this->_preferences[$type])) { if (isset($preferencePath[$this->_preferences[$type]])) { @@ -252,12 +239,15 @@ class Config implements \Magento\ObjectManager\Config foreach ($configuration as $key => $curConfig) { switch ($key) { case 'preferences': - $this->_preferences = array_replace($this->_preferences, $curConfig); + foreach ($curConfig as $for => $to) { + $this->_preferences[ltrim($for, '\\')] = ltrim($to, '\\'); + } break; default: + $key = ltrim($key, '\\'); if (isset($curConfig['type'])) { - $this->_virtualTypes[$key] = $curConfig['type']; + $this->_virtualTypes[$key] = ltrim($curConfig['type'], '\\'); } if (isset($curConfig['arguments'])) { if (!empty($this->_mergedArguments)) { diff --git a/lib/Magento/ObjectManager/DefinitionFactory.php b/lib/Magento/ObjectManager/DefinitionFactory.php index 87f172ce173..9da64cb252a 100644 --- a/lib/Magento/ObjectManager/DefinitionFactory.php +++ b/lib/Magento/ObjectManager/DefinitionFactory.php @@ -29,6 +29,8 @@ namespace Magento\ObjectManager; use \Magento\Filesystem\DriverInterface; use \Magento\ObjectManager\Definition\Runtime; use \Magento\ObjectManager\Relations; +use \Magento\ObjectManager\Code\Generator; +use \Magento\Interception\Code\Generator as InterceptionGenerator; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -118,7 +120,11 @@ class DefinitionFactory $autoloader, $this->_generationDir ); - $generator = new \Magento\Code\Generator(null, $autoloader, $generatorIo); + $generator = new \Magento\Code\Generator($autoloader, $generatorIo, array( + Generator\Factory::ENTITY_TYPE => '\Magento\ObjectManager\Code\Generator\Factory', + Generator\Proxy::ENTITY_TYPE => '\Magento\ObjectManager\Code\Generator\Proxy', + InterceptionGenerator\Interceptor::ENTITY_TYPE => '\Magento\Interception\Code\Generator\Interceptor', + )); $autoloader = new \Magento\Code\Generator\Autoloader($generator); spl_autoload_register(array($autoloader, 'load')); diff --git a/lib/Magento/ObjectManager/ObjectManager.php b/lib/Magento/ObjectManager/ObjectManager.php index 6f2c232cd5d..6f095df0b9c 100644 --- a/lib/Magento/ObjectManager/ObjectManager.php +++ b/lib/Magento/ObjectManager/ObjectManager.php @@ -62,17 +62,6 @@ class ObjectManager implements \Magento\ObjectManager $this->_sharedInstances['Magento\ObjectManager'] = $this; } - /** - * Set creation factory - * - * @param Factory $factory - * @return void - */ - public function setFactory(Factory $factory) - { - $this->_factory = $factory; - } - /** * Create new object instance * diff --git a/lib/Magento/Service/Entity/AbstractDtoBuilder.php b/lib/Magento/Service/Entity/AbstractDtoBuilder.php index 079594c1648..a3679621061 100644 --- a/lib/Magento/Service/Entity/AbstractDtoBuilder.php +++ b/lib/Magento/Service/Entity/AbstractDtoBuilder.php @@ -96,8 +96,8 @@ abstract class AbstractDtoBuilder */ public function mergeDtoWithArray(AbstractDto $dto, array $data) { - $this->_data = array_merge($dto->__toArray(), $data); - return $this->create(); + $newData = array_merge($dto->__toArray(), $data); + return $this->populateWithArray($newData)->create(); } /** diff --git a/lib/Magento/Stdlib/Cookie.php b/lib/Magento/Stdlib/Cookie.php index f938f233eef..03f0d8ba7ba 100644 --- a/lib/Magento/Stdlib/Cookie.php +++ b/lib/Magento/Stdlib/Cookie.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/lib/Magento/Stdlib/DateTime.php b/lib/Magento/Stdlib/DateTime.php index cb77a420de3..eeeeef176c8 100644 --- a/lib/Magento/Stdlib/DateTime.php +++ b/lib/Magento/Stdlib/DateTime.php @@ -56,12 +56,12 @@ class DateTime * Convert date to UNIX timestamp * Returns current UNIX timestamp if date is true * - * @param \Zend_Date|bool $date + * @param \Magento\Stdlib\DateTime\DateInterface|bool $date * @return int */ public function toTimestamp($date) { - if ($date instanceof \Zend_Date) { + if ($date instanceof \Magento\Stdlib\DateTime\DateInterface) { return $date->getTimestamp(); } @@ -97,7 +97,7 @@ class DateTime return $this->now(!$includeTime); } - if ($date instanceof \Zend_Date) { + if ($date instanceof \Magento\Stdlib\DateTime\DateInterface) { if ($includeTime) { return $date->toString(self::DATETIME_INTERNAL_FORMAT); } else { diff --git a/lib/Magento/Stdlib/DateTime/Date.php b/lib/Magento/Stdlib/DateTime/Date.php new file mode 100644 index 00000000000..e6a4658270c --- /dev/null +++ b/lib/Magento/Stdlib/DateTime/Date.php @@ -0,0 +1,47 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Stdlib\DateTime; + +class Date extends \Zend_Date implements \Magento\Stdlib\DateTime\DateInterface +{ + /** + * Generates the standard date object, could be a unix timestamp, localized date, + * string, integer, array and so on. Also parts of dates or time are supported + * Always set the default timezone: http://php.net/date_default_timezone_set + * For example, in your bootstrap: date_default_timezone_set('America/Los_Angeles'); + * For detailed instructions please look in the docu. + * + * @param string|integer|\Magento\Stdlib\DateTime\DateInterface|array $date OPTIONAL Date value or value + * of date part to set, depending on $part. If null the actual time is set + * @param string $part OPTIONAL Defines the input format of $date + * @param string|\Magento\Stdlib\DateTime\DateInterface $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface + * @throws Zend_Date_Exception + */ + public function __construct($date = null, $part = null, $locale = null) + { + parent::__construct($date, $part, $locale); + } +} diff --git a/lib/Magento/Stdlib/DateTime/DateFactory.php b/lib/Magento/Stdlib/DateTime/DateFactory.php new file mode 100644 index 00000000000..f53eb3d1f4d --- /dev/null +++ b/lib/Magento/Stdlib/DateTime/DateFactory.php @@ -0,0 +1,61 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Stdlib\DateTime; + +class DateFactory +{ + /** + * @var \Magento\ObjectManager + */ + protected $_objectManager = null; + + /** + * @var string + */ + protected $_instanceName = null; + + /** + * @param \Magento\ObjectManager $objectManager + * @param string $instanceName + */ + public function __construct( + \Magento\ObjectManager $objectManager, + $instanceName = 'Magento\Stdlib\DateTime\DateInterface' + ) { + $this->_objectManager = $objectManager; + $this->_instanceName = $instanceName; + } + + /** + * Create class instance with specified parameters + * + * @param array $data + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public function create(array $data = array()) + { + return $this->_objectManager->create($this->_instanceName, $data); + } +} diff --git a/lib/Magento/Stdlib/DateTime/DateInterface.php b/lib/Magento/Stdlib/DateTime/DateInterface.php new file mode 100644 index 00000000000..1b78c3d40f8 --- /dev/null +++ b/lib/Magento/Stdlib/DateTime/DateInterface.php @@ -0,0 +1,1304 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Stdlib\DateTime; + +interface DateInterface +{ + /** + * Sets class wide options, if no option was given, the actual set options will be returned + * + * @param array $options \Options to set + * @throws \Zend_Date_Exception + * @return array of options if no option was given + */ + public static function setOptions(array $options = array()); + + /** + * Returns this object's internal UNIX timestamp (equivalent to \Zend_Date::TIMESTAMP). + * If the timestamp is too large for integers, then the return value will be a string. + * This function does not return the timestamp as an object. + * Use clone() or copyPart() instead. + * + * @return integer|string UNIX timestamp + */ + public function getTimestamp(); + + /** + * Sets a new timestamp + * + * @param integer|string|array|\Magento\Stdlib\DateTime\DateInterface $timestamp Timestamp to set + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function setTimestamp($timestamp); + + /** + * Adds a timestamp + * + * @param integer|string|array|\Magento\Stdlib\DateTime\DateInterface $timestamp Timestamp to add + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function addTimestamp($timestamp); + + /** + * Subtracts a timestamp + * + * @param integer|string|array|\Magento\Stdlib\DateTime\DateInterface $timestamp Timestamp to sub + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function subTimestamp($timestamp); + + /** + * Compares two timestamps, returning the difference as integer + * + * @param integer|string|array|\Magento\Stdlib\DateTime\DateInterface $timestamp Timestamp to compare + * @return integer 0 = equal, 1 = later, -1 = earlier + * @throws \Zend_Date_Exception + */ + public function compareTimestamp($timestamp); + + /** + * Returns a string representation of the object + * Supported format tokens are: + * G - era, y - year, Y - ISO year, M - month, w - week of year, D - day of year, d - day of month + * E - day of week, e - number of weekday (1-7), h - hour 1-12, H - hour 0-23, m - minute, s - second + * A - milliseconds of day, z - timezone, Z - timezone offset, S - fractional second, a - period of day + * + * Additionally format tokens but non ISO conform are: + * SS - day suffix, eee - php number of weekday(0-6), ddd - number of days per month + * l - Leap year, B - swatch internet time, I - daylight saving time, X - timezone offset in seconds + * r - RFC2822 format, U - unix timestamp + * + * Not supported ISO tokens are + * u - extended year, Q - quarter, q - quarter, L - stand alone month, W - week of month + * F - day of week of month, g - modified julian, c - stand alone weekday, k - hour 0-11, K - hour 1-24 + * v - wall zone + * + * @param string $format OPTIONAL Rule for formatting output. If null the default date format is used + * @param string $type OPTIONAL Type for the format string which overrides the standard setting + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return string + */ + public function toString($format = null, $type = null, $locale = null); + + /** + * Returns a string representation of the date which is equal with the timestamp + * + * @return string + */ + public function __toString(); + + /** + * Returns a integer representation of the object + * But returns false when the given part is no value f.e. Month-Name + * + * @param string|integer|\Magento\Stdlib\DateTime\DateInterface $part OPTIONAL Defines the date or datepart to return as integer + * @return integer|false + */ + public function toValue($part = null); + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(); + + /** + * Returns a representation of a date or datepart + * This could be for example a localized monthname, the time without date, + * the era or only the fractional seconds. There are about 50 different supported date parts. + * For a complete list of supported datepart values look into the docu + * + * @param string $part OPTIONAL Part of the date to return, if null the timestamp is returned + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return string date or datepart + */ + public function get($part = null, $locale = null); + + /** + * Counts the exact year number + * < 70 - 2000 added, >70 < 100 - 1900, others just returned + * + * @param integer $value year number + * @return integer Number of year + */ + public static function getFullYear($value); + + /** + * Sets the given date as new date or a given datepart as new datepart returning the new datepart + * This could be for example a localized dayname, the date without time, + * the month or only the seconds. There are about 50 different supported date parts. + * For a complete list of supported datepart values look into the docu + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $date Date or datepart to set + * @param string $part OPTIONAL Part of the date to set, if null the timestamp is set + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return $this Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function set($date, $part = null, $locale = null); + + /** + * Adds a date or datepart to the existing date, by extracting $part from $date, + * and modifying this object by adding that part. The $part is then extracted from + * this object and returned as an integer or numeric string (for large values, or $part's + * corresponding to pre-defined formatted date strings). + * This could be for example a ISO 8601 date, the hour the monthname or only the minute. + * There are about 50 different supported date parts. + * For a complete list of supported datepart values look into the docu. + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $date Date or datepart to add + * @param string $part OPTIONAL Part of the date to add, if null the timestamp is added + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return $this Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function add($date, $part = \Zend_Date::TIMESTAMP, $locale = null); + + /** + * Subtracts a date from another date. + * This could be for example a RFC2822 date, the time, + * the year or only the timestamp. There are about 50 different supported date parts. + * For a complete list of supported datepart values look into the docu + * Be aware: Adding -2 Months is not equal to Subtracting 2 Months !!! + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $date Date or datepart to subtract + * @param string $part OPTIONAL Part of the date to sub, if null the timestamp is subtracted + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return $this Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function sub($date, $part = \Zend_Date::TIMESTAMP, $locale = null); + + /** + * Compares a date or datepart with the existing one. + * Returns -1 if earlier, 0 if equal and 1 if later. + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $date Date or datepart to compare with the date object + * @param string $part OPTIONAL Part of the date to compare, if null the timestamp is subtracted + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return integer 0 = equal, 1 = later, -1 = earlier + * @throws \Zend_Date_Exception + */ + public function compare($date, $part = \Zend_Date::TIMESTAMP, $locale = null); + + /** + * Returns a new instance of \Magento\Stdlib\DateTime\DateInterface with the selected part copied. + * To make an exact copy, use PHP's clone keyword. + * For a complete list of supported date part values look into the docu. + * If a date part is copied, all other date parts are set to standard values. + * For example: If only YEAR is copied, the returned date object is equal to + * 01-01-YEAR 00:00:00 (01-01-1970 00:00:00 is equal to timestamp 0) + * If only HOUR is copied, the returned date object is equal to + * 01-01-1970 HOUR:00:00 (so $this contains a timestamp equal to a timestamp of 0 plus HOUR). + * + * @param string $part Part of the date to compare, if null the timestamp is subtracted + * @param string|\Zend_Locale $locale OPTIONAL New object's locale. No adjustments to timezone are made. + * @return \Magento\Stdlib\DateTime\DateInterface New clone with requested part + */ + public function copyPart($part, $locale = null); + + /** + * Internal function, returns the offset of a given timezone + * + * @param string $zone + * @return integer + */ + public function getTimezoneFromString($zone); + + /** + * Returns true when both date objects or date parts are equal. + * For example: + * 15.May.2000 <-> 15.June.2000 Equals only for Day or Year... all other will return false + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $date Date or datepart to equal with + * @param string $part OPTIONAL Part of the date to compare, if null the timestamp is used + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return boolean + * @throws \Zend_Date_Exception + */ + public function equals($date, $part = \Zend_Date::TIMESTAMP, $locale = null); + + /** + * Returns if the given date or datepart is earlier + * For example: + * 15.May.2000 <-> 13.June.1999 will return true for day, year and date, but not for month + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $date Date or datepart to compare with + * @param string $part OPTIONAL Part of the date to compare, if null the timestamp is used + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return boolean + * @throws \Zend_Date_Exception + */ + public function isEarlier($date, $part = null, $locale = null); + + /** + * Returns if the given date or datepart is later + * For example: + * 15.May.2000 <-> 13.June.1999 will return true for month but false for day, year and date + * Returns if the given date is later + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $date Date or datepart to compare with + * @param string $part OPTIONAL Part of the date to compare, if null the timestamp is used + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return boolean + * @throws \Zend_Date_Exception + */ + public function isLater($date, $part = null, $locale = null); + + /** + * Returns only the time of the date as new \Magento\Stdlib\DateTime\Date object + * For example: + * 15.May.2000 10:11:23 will return a dateobject equal to 01.Jan.1970 10:11:23 + * + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public function getTime($locale = null); + + /** + * Sets a new time for the date object. Format defines how to parse the time string. + * Also a complete date can be given, but only the time is used for setting. + * For example: dd.MMMM.yyTHH:mm' and 'ss sec'-> 10.May.07T25:11 and 44 sec => 1h11min44sec + 1 day + * Returned is the new date object and the existing date is left as it was before + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $time Time to set + * @param string $format OPTIONAL Timeformat for parsing input + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function setTime($time, $format = null, $locale = null); + + /** + * Adds a time to the existing date. Format defines how to parse the time string. + * If only parts are given the other parts are set to 0. + * If no format is given, the standardformat of this locale is used. + * For example: HH:mm:ss -> 10 -> +10 hours + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $time Time to add + * @param string $format OPTIONAL Timeformat for parsing input + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function addTime($time, $format = null, $locale = null); + + /** + * Subtracts a time from the existing date. Format defines how to parse the time string. + * If only parts are given the other parts are set to 0. + * If no format is given, the standardformat of this locale is used. + * For example: HH:mm:ss -> 10 -> -10 hours + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $time Time to sub + * @param string $format OPTIONAL Timeformat for parsing input + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid inteface + * @throws \Zend_Date_Exception + */ + public function subTime($time, $format = null, $locale = null); + + /** + * Compares the time from the existing date. Format defines how to parse the time string. + * If only parts are given the other parts are set to default. + * If no format us given, the standardformat of this locale is used. + * For example: HH:mm:ss -> 10 -> 10 hours + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $time Time to compare + * @param string $format OPTIONAL Timeformat for parsing input + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return integer 0 = equal, 1 = later, -1 = earlier + * @throws \Zend_Date_Exception + */ + public function compareTime($time, $format = null, $locale = null); + + /** + * Returns a clone of $this, with the time part set to 00:00:00. + * + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public function getDate($locale = null); + + /** + * Sets a new date for the date object. Format defines how to parse the date string. + * Also a complete date with time can be given, but only the date is used for setting. + * For example: MMMM.yy HH:mm-> May.07 22:11 => 01.May.07 00:00 + * Returned is the new date object and the existing time is left as it was before + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $date Date to set + * @param string $format OPTIONAL Date format for parsing + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function setDate($date, $format = null, $locale = null); + + /** + * Adds a date to the existing date object. Format defines how to parse the date string. + * If only parts are given the other parts are set to 0. + * If no format is given, the standardformat of this locale is used. + * For example: MM.dd.YYYY -> 10 -> +10 months + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $date Date to add + * @param string $format OPTIONAL Date format for parsing input + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function addDate($date, $format = null, $locale = null); + + /** + * Subtracts a date from the existing date object. Format defines how to parse the date string. + * If only parts are given the other parts are set to 0. + * If no format is given, the standardformat of this locale is used. + * For example: MM.dd.YYYY -> 10 -> -10 months + * Be aware: Subtracting 2 months is not equal to Adding -2 months !!! + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $date Date to sub + * @param string $format OPTIONAL Date format for parsing input + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function subDate($date, $format = null, $locale = null); + + /** + * Compares the date from the existing date object, ignoring the time. + * Format defines how to parse the date string. + * If only parts are given the other parts are set to 0. + * If no format is given, the standardformat of this locale is used. + * For example: 10.01.2000 => 10.02.1999 -> false + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $date Date to compare + * @param string $format OPTIONAL Date format for parsing input + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return integer 0 = equal, 1 = later, -1 = earlier + * @throws \Zend_Date_Exception + */ + public function compareDate($date, $format = null, $locale = null); + + /** + * Returns the full ISO 8601 date from the date object. + * Always the complete ISO 8601 specifiction is used. If an other ISO date is needed + * (ISO 8601 defines several formats) use toString() instead. + * This function does not return the ISO date as object. Use copy() instead. + * + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return string + */ + public function getIso($locale = null); + + /** + * Sets a new date for the date object. Not given parts are set to default. + * Only supported ISO 8601 formats are accepted. + * For example: 050901 -> 01.Sept.2005 00:00:00, 20050201T10:00:30 -> 01.Feb.2005 10h00m30s + * Returned is the new date object + * + * @param string|integer|\Magento\Stdlib\DateTime\DateInterface $date ISO Date to set + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function setIso($date, $locale = null); + + /** + * Adds a ISO date to the date object. Not given parts are set to default. + * Only supported ISO 8601 formats are accepted. + * For example: 050901 -> + 01.Sept.2005 00:00:00, 10:00:00 -> +10h + * Returned is the new date object + * + * @param string|integer|\Magento\Stdlib\DateTime\DateInterface $date ISO Date to add + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function addIso($date, $locale = null); + + /** + * Subtracts a ISO date from the date object. Not given parts are set to default. + * Only supported ISO 8601 formats are accepted. + * For example: 050901 -> - 01.Sept.2005 00:00:00, 10:00:00 -> -10h + * Returned is the new date object + * + * @param string|integer|\Magento\Stdlib\DateTime\DateInterface $date ISO Date to sub + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function subIso($date, $locale = null); + + /** + * Compares a ISO date with the date object. Not given parts are set to default. + * Only supported ISO 8601 formats are accepted. + * For example: 050901 -> - 01.Sept.2005 00:00:00, 10:00:00 -> -10h + * Returns if equal, earlier or later + * + * @param string|integer|\Magento\Stdlib\DateTime\DateInterface $date ISO Date to sub + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return integer 0 = equal, 1 = later, -1 = earlier + * @throws \Zend_Date_Exception + */ + public function compareIso($date, $locale = null); + + /** + * Returns a RFC 822 compilant datestring from the date object. + * This function does not return the RFC date as object. Use copy() instead. + * + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return string + */ + public function getArpa($locale = null); + + /** + * Sets a RFC 822 date as new date for the date object. + * Only RFC 822 compilant date strings are accepted. + * For example: Sat, 14 Feb 09 00:31:30 +0100 + * Returned is the new date object + * + * @param string|integer|\Magento\Stdlib\DateTime\DateInterface $date RFC 822 to set + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function setArpa($date, $locale = null); + + /** + * Adds a RFC 822 date to the date object. + * ARPA messages are used in emails or HTTP Headers. + * Only RFC 822 compilant date strings are accepted. + * For example: Sat, 14 Feb 09 00:31:30 +0100 + * Returned is the new date object + * + * @param string|integer|\Magento\Stdlib\DateTime\DateInterface $date RFC 822 Date to add + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function addArpa($date, $locale = null); + + /** + * Subtracts a RFC 822 date from the date object. + * ARPA messages are used in emails or HTTP Headers. + * Only RFC 822 compilant date strings are accepted. + * For example: Sat, 14 Feb 09 00:31:30 +0100 + * Returned is the new date object + * + * @param string|integer|\Magento\Stdlib\DateTime\DateInterface $date RFC 822 Date to sub + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function subArpa($date, $locale = null); + + /** + * Compares a RFC 822 compilant date with the date object. + * ARPA messages are used in emails or HTTP Headers. + * Only RFC 822 compilant date strings are accepted. + * For example: Sat, 14 Feb 09 00:31:30 +0100 + * Returns if equal, earlier or later + * + * @param string|integer|\Magento\Stdlib\DateTime\DateInterface $date RFC 822 Date to sub + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return integer 0 = equal, 1 = later, -1 = earlier + * @throws \Zend_Date_Exception + */ + public function compareArpa($date, $locale = null); + + /** + * Returns the time of sunrise for this date and a given location as new date object + * For a list of cities and correct locations use the class \Zend_Date_Cities + * + * @param $location array - location of sunrise + * ['horizon'] -> civil, nautic, astronomical, effective (default) + * ['longitude'] -> longitude of location + * ['latitude'] -> latitude of location + * @return \Magento\Stdlib\DateTime\DateInterface + * @throws \Zend_Date_Exception + */ + public function getSunrise($location); + + /** + * Returns the time of sunset for this date and a given location as new date object + * For a list of cities and correct locations use the class \Zend_Date_Cities + * + * @param $location array - location of sunset + * ['horizon'] -> civil, nautic, astronomical, effective (default) + * ['longitude'] -> longitude of location + * ['latitude'] -> latitude of location + * @return \Magento\Stdlib\DateTime\DateInterface + * @throws \Zend_Date_Exception + */ + public function getSunset($location); + + /** + * Returns an array with the sunset and sunrise dates for all horizon types + * For a list of cities and correct locations use the class \Zend_Date_Cities + * + * @param $location array - location of suninfo + * ['horizon'] -> civil, nautic, astronomical, effective (default) + * ['longitude'] -> longitude of location + * ['latitude'] -> latitude of location + * @return array - [sunset|sunrise][effective|civil|nautic|astronomic] + * @throws \Zend_Date_Exception + */ + public function getSunInfo($location); + + /** + * Check a given year for leap year. + * + * @param integer|array|\Magento\Stdlib\DateTime\DateInterface $year Year to check + * @return boolean + */ + public static function checkLeapYear($year); + + /** + * Returns true, if the year is a leap year. + * + * @return boolean + */ + public function isLeapYear(); + + /** + * Returns if the set date is todays date + * + * @return boolean + */ + public function isToday(); + + /** + * Returns if the set date is yesterdays date + * + * @return boolean + */ + public function isYesterday(); + + /** + * Returns if the set date is tomorrows date + * + * @return boolean + */ + public function isTomorrow(); + + /** + * Returns the actual date as new date object + * + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public static function now($locale = null); + + /** + * Returns only the year from the date object as new object. + * For example: 10.May.2000 10:30:00 -> 01.Jan.2000 00:00:00 + * + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public function getYear($locale = null); + + /** + * Sets a new year + * If the year is between 0 and 69, 2000 will be set (2000-2069) + * If the year if between 70 and 99, 1999 will be set (1970-1999) + * 3 or 4 digit years are set as expected. If you need to set year 0-99 + * use set() instead. + * Returned is the new date object + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $date Year to set + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function setYear($year, $locale = null); + + /** + * Adds the year to the existing date object + * If the year is between 0 and 69, 2000 will be added (2000-2069) + * If the year if between 70 and 99, 1999 will be added (1970-1999) + * 3 or 4 digit years are added as expected. If you need to add years from 0-99 + * use add() instead. + * Returned is the new date object + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $date Year to add + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function addYear($year, $locale = null); + + /** + * Subs the year from the existing date object + * If the year is between 0 and 69, 2000 will be subtracted (2000-2069) + * If the year if between 70 and 99, 1999 will be subtracted (1970-1999) + * 3 or 4 digit years are subtracted as expected. If you need to subtract years from 0-99 + * use sub() instead. + * Returned is the new date object + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $date Year to sub + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function subYear($year, $locale = null); + + /** + * Compares the year with the existing date object, ignoring other date parts. + * For example: 10.03.2000 -> 15.02.2000 -> true + * Returns if equal, earlier or later + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $year Year to compare + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return integer 0 = equal, 1 = later, -1 = earlier + * @throws \Zend_Date_Exception + */ + public function compareYear($year, $locale = null); + + /** + * Returns only the month from the date object as new object. + * For example: 10.May.2000 10:30:00 -> 01.May.1970 00:00:00 + * + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Zend_Date + */ + public function getMonth($locale = null); + + /** + * Sets a new month + * The month can be a number or a string. Setting months lower than 0 and greater then 12 + * will result in adding or subtracting the relevant year. (12 months equal one year) + * If a localized monthname is given it will be parsed with the default locale or the optional + * set locale. + * Returned is the new date object + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $month Month to set + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function setMonth($month, $locale = null); + + /** + * Adds months to the existing date object. + * The month can be a number or a string. Adding months lower than 0 and greater then 12 + * will result in adding or subtracting the relevant year. (12 months equal one year) + * If a localized monthname is given it will be parsed with the default locale or the optional + * set locale. + * Returned is the new date object + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $month Month to add + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function addMonth($month, $locale = null); + + /** + * Subtracts months from the existing date object. + * The month can be a number or a string. Subtracting months lower than 0 and greater then 12 + * will result in adding or subtracting the relevant year. (12 months equal one year) + * If a localized monthname is given it will be parsed with the default locale or the optional + * set locale. + * Returned is the new date object + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $month Month to sub + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function subMonth($month, $locale = null); + + /** + * Compares the month with the existing date object, ignoring other date parts. + * For example: 10.03.2000 -> 15.03.1950 -> true + * Returns if equal, earlier or later + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $month Month to compare + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return integer 0 = equal, 1 = later, -1 = earlier + * @throws \Zend_Date_Exception + */ + public function compareMonth($month, $locale = null); + + /** + * Returns the day as new date object + * Example: 20.May.1986 -> 20.Jan.1970 00:00:00 + * + * @param $locale string|\Zend_Locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public function getDay($locale = null); + + /** + * Sets a new day + * The day can be a number or a string. Setting days lower then 0 or greater than the number of this months days + * will result in adding or subtracting the relevant month. + * If a localized dayname is given it will be parsed with the default locale or the optional + * set locale. + * Returned is the new date object + * Example: setDay('Montag', 'de_AT'); will set the monday of this week as day. + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $month Day to set + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function setDay($day, $locale = null); + + /** + * Adds days to the existing date object. + * The day can be a number or a string. Adding days lower then 0 or greater than the number of this months days + * will result in adding or subtracting the relevant month. + * If a localized dayname is given it will be parsed with the default locale or the optional + * set locale. + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $month Day to add + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function addDay($day, $locale = null); + + /** + * Subtracts days from the existing date object. + * The day can be a number or a string. Subtracting days lower then 0 or greater than the number of this months days + * will result in adding or subtracting the relevant month. + * If a localized dayname is given it will be parsed with the default locale or the optional + * set locale. + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $month Day to sub + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function subDay($day, $locale = null); + + /** + * Compares the day with the existing date object, ignoring other date parts. + * For example: 'Monday', 'en' -> 08.Jan.2007 -> 0 + * Returns if equal, earlier or later + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $day Day to compare + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return integer 0 = equal, 1 = later, -1 = earlier + * @throws \Zend_Date_Exception + */ + public function compareDay($day, $locale = null); + + /** + * Returns the weekday as new date object + * Weekday is always from 1-7 + * Example: 09-Jan-2007 -> 2 = Tuesday -> 02-Jan-1970 (when 02.01.1970 is also Tuesday) + * + * @param $locale string|\Zend_Locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public function getWeekday($locale = null); + + /** + * Sets a new weekday + * The weekday can be a number or a string. If a localized weekday name is given, + * then it will be parsed as a date in $locale (defaults to the same locale as $this). + * Returned is the new date object. + * Example: setWeekday(3); will set the wednesday of this week as day. + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $month Weekday to set + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function setWeekday($weekday, $locale = null); + + /** + * Adds weekdays to the existing date object. + * The weekday can be a number or a string. + * If a localized dayname is given it will be parsed with the default locale or the optional + * set locale. + * Returned is the new date object + * Example: addWeekday(3); will add the difference of days from the beginning of the month until + * wednesday. + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $month Weekday to add + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function addWeekday($weekday, $locale = null); + + /** + * Subtracts weekdays from the existing date object. + * The weekday can be a number or a string. + * If a localized dayname is given it will be parsed with the default locale or the optional + * set locale. + * Returned is the new date object + * Example: subWeekday(3); will subtract the difference of days from the beginning of the month until + * wednesday. + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $month Weekday to sub + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function subWeekday($weekday, $locale = null); + + /** + * Compares the weekday with the existing date object, ignoring other date parts. + * For example: 'Monday', 'en' -> 08.Jan.2007 -> 0 + * Returns if equal, earlier or later + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $weekday Weekday to compare + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return integer 0 = equal, 1 = later, -1 = earlier + * @throws \Zend_Date_Exception + */ + public function compareWeekday($weekday, $locale = null); + + /** + * Returns the day of year as new date object + * Example: 02.Feb.1986 10:00:00 -> 02.Feb.1970 00:00:00 + * + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public function getDayOfYear($locale = null); + + /** + * Sets a new day of year + * The day of year is always a number. + * Returned is the new date object + * Example: 04.May.2004 -> setDayOfYear(10) -> 10.Jan.2004 + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $day Day of Year to set + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function setDayOfYear($day, $locale = null); + + /** + * Adds a day of year to the existing date object. + * The day of year is always a number. + * Returned is the new date object + * Example: addDayOfYear(10); will add 10 days to the existing date object. + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $day Day of Year to add + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function addDayOfYear($day, $locale = null); + + /** + * Subtracts a day of year from the existing date object. + * The day of year is always a number. + * Returned is the new date object + * Example: subDayOfYear(10); will subtract 10 days from the existing date object. + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $day Day of Year to sub + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function subDayOfYear($day, $locale = null); + + /** + * Compares the day of year with the existing date object. + * For example: compareDayOfYear(33) -> 02.Feb.2007 -> 0 + * Returns if equal, earlier or later + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $day Day of Year to compare + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return integer 0 = equal, 1 = later, -1 = earlier + * @throws \Zend_Date_Exception + */ + public function compareDayOfYear($day, $locale = null); + + /** + * Returns the hour as new date object + * Example: 02.Feb.1986 10:30:25 -> 01.Jan.1970 10:00:00 + * + * @param $locale string|\Zend_Locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public function getHour($locale = null); + + /** + * Sets a new hour + * The hour is always a number. + * Returned is the new date object + * Example: 04.May.1993 13:07:25 -> setHour(7); -> 04.May.1993 07:07:25 + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $hour Hour to set + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function setHour($hour, $locale = null); + + /** + * Adds hours to the existing date object. + * The hour is always a number. + * Returned is the new date object + * Example: 04.May.1993 13:07:25 -> addHour(12); -> 05.May.1993 01:07:25 + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $hour Hour to add + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function addHour($hour, $locale = null); + + /** + * Subtracts hours from the existing date object. + * The hour is always a number. + * Returned is the new date object + * Example: 04.May.1993 13:07:25 -> subHour(6); -> 05.May.1993 07:07:25 + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $hour Hour to sub + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function subHour($hour, $locale = null); + + /** + * Compares the hour with the existing date object. + * For example: 10:30:25 -> compareHour(10) -> 0 + * Returns if equal, earlier or later + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $hour Hour to compare + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return integer 0 = equal, 1 = later, -1 = earlier + * @throws \Zend_Date_Exception + */ + public function compareHour($hour, $locale = null); + + /** + * Returns the minute as new date object + * Example: 02.Feb.1986 10:30:25 -> 01.Jan.1970 00:30:00 + * + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public function getMinute($locale = null); + + /** + * Sets a new minute + * The minute is always a number. + * Returned is the new date object + * Example: 04.May.1993 13:07:25 -> setMinute(29); -> 04.May.1993 13:29:25 + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $minute Minute to set + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function setMinute($minute, $locale = null); + + /** + * Adds minutes to the existing date object. + * The minute is always a number. + * Returned is the new date object + * Example: 04.May.1993 13:07:25 -> addMinute(65); -> 04.May.1993 13:12:25 + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $minute Minute to add + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function addMinute($minute, $locale = null); + + /** + * Subtracts minutes from the existing date object. + * The minute is always a number. + * Returned is the new date object + * Example: 04.May.1993 13:07:25 -> subMinute(9); -> 04.May.1993 12:58:25 + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $minute Minute to sub + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function subMinute($minute, $locale = null); + + /** + * Compares the minute with the existing date object. + * For example: 10:30:25 -> compareMinute(30) -> 0 + * Returns if equal, earlier or later + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $minute Hour to compare + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return integer 0 = equal, 1 = later, -1 = earlier + * @throws \Zend_Date_Exception + */ + public function compareMinute($minute, $locale = null); + + /** + * Returns the second as new date object + * Example: 02.Feb.1986 10:30:25 -> 01.Jan.1970 00:00:25 + * + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public function getSecond($locale = null); + + /** + * Sets new seconds to the existing date object. + * The second is always a number. + * Returned is the new date object + * Example: 04.May.1993 13:07:25 -> setSecond(100); -> 04.May.1993 13:08:40 + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $second Second to set + * @param string|\Zend_Locale $locale (Optional) Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function setSecond($second, $locale = null); + + /** + * Adds seconds to the existing date object. + * The second is always a number. + * Returned is the new date object + * Example: 04.May.1993 13:07:25 -> addSecond(65); -> 04.May.1993 13:08:30 + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $second Second to add + * @param string|\Zend_Locale $locale (Optional) Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function addSecond($second, $locale = null); + + /** + * Subtracts seconds from the existing date object. + * The second is always a number. + * Returned is the new date object + * Example: 04.May.1993 13:07:25 -> subSecond(10); -> 04.May.1993 13:07:15 + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $second Second to sub + * @param string|\Zend_Locale $locale (Optional) Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function subSecond($second, $locale = null); + + /** + * Compares the second with the existing date object. + * For example: 10:30:25 -> compareSecond(25) -> 0 + * Returns if equal, earlier or later + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $second Second to compare + * @param string|\Zend_Locale $locale (Optional) Locale for parsing input + * @return integer 0 = equal, 1 = later, -1 = earlier + * @throws \Zend_Date_Exception + */ + public function compareSecond($second, $locale = null); + + + /** + * Returns the precision for fractional seconds + * + * @return integer + */ + public function getFractionalPrecision(); + + + /** + * Sets a new precision for fractional seconds + * + * @param integer $precision Precision for the fractional datepart 3 = milliseconds + * @throws \Zend_Date_Exception + * @return $this Provides fluid interface + */ + public function setFractionalPrecision($precision); + + /** + * Returns the milliseconds of the date object + * + * @return string + */ + public function getMilliSecond(); + + /** + * Sets new milliseconds for the date object + * Example: setMilliSecond(550, 2) -> equals +5 Sec +50 MilliSec + * + * @param integer|\Magento\Stdlib\DateTime\DateInterface $milli (Optional) Millisecond to set, when null the actual millisecond is set + * @param integer $precision (Optional) Fraction precision of the given milliseconds + * @return $this Provides fluid interface + */ + public function setMilliSecond($milli = null, $precision = null); + + + /** + * Adds milliseconds to the date object + * + * @param integer|\Magento\Stdlib\DateTime\DateInterface $milli (Optional) Millisecond to add, when null the actual millisecond is added + * @param integer $precision (Optional) Fractional precision for the given milliseconds + * @return $this Provides fluid interface + */ + public function addMilliSecond($milli = null, $precision = null); + + + /** + * Subtracts a millisecond + * + * @param integer|\Magento\Stdlib\DateTime\DateInterface $milli (Optional) Millisecond to sub, when null the actual millisecond is subtracted + * @param integer $precision (Optional) Fractional precision for the given milliseconds + * @return $this Provides fluid interface + */ + public function subMilliSecond($milli = null, $precision = null); + + /** + * Compares only the millisecond part, returning the difference + * + * @param integer|\Magento\Stdlib\DateTime\DateInterface $milli OPTIONAL Millisecond to compare, when null the actual millisecond is compared + * @param integer $precision OPTIONAL Fractional precision for the given milliseconds + * @throws \Zend_Date_Exception On invalid input + * @return integer 0 = equal, 1 = later, -1 = earlier + */ + public function compareMilliSecond($milli = null, $precision = null); + + /** + * Returns the week as new date object using monday as beginning of the week + * Example: 12.Jan.2007 -> 08.Jan.1970 00:00:00 + * + * @param $locale string|\Zend_Locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public function getWeek($locale = null); + + /** + * Sets a new week. The week is always a number. The day of week is not changed. + * Returned is the new date object + * Example: 09.Jan.2007 13:07:25 -> setWeek(1); -> 02.Jan.2007 13:07:25 + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $week Week to set + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function setWeek($week, $locale = null); + + /** + * Adds a week. The week is always a number. The day of week is not changed. + * Returned is the new date object + * Example: 09.Jan.2007 13:07:25 -> addWeek(1); -> 16.Jan.2007 13:07:25 + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $week Week to add + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function addWeek($week, $locale = null); + + /** + * Subtracts a week. The week is always a number. The day of week is not changed. + * Returned is the new date object + * Example: 09.Jan.2007 13:07:25 -> subWeek(1); -> 02.Jan.2007 13:07:25 + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $week Week to sub + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return \Magento\Stdlib\DateTime\DateInterface Provides fluid interface + * @throws \Zend_Date_Exception + */ + public function subWeek($week, $locale = null); + + /** + * Compares only the week part, returning the difference + * Returned is the new date object + * Returns if equal, earlier or later + * Example: 09.Jan.2007 13:07:25 -> compareWeek(2); -> 0 + * + * @param string|integer|array|\Magento\Stdlib\DateTime\DateInterface $week Week to compare + * @param string|\Zend_Locale $locale OPTIONAL Locale for parsing input + * @return integer 0 = equal, 1 = later, -1 = earlier + */ + public function compareWeek($week, $locale = null); + + /** + * Sets a new standard locale for the date object. + * This locale will be used for all functions + * Returned is the really set locale. + * Example: 'de_XX' will be set to 'de' because 'de_XX' does not exist + * 'xx_YY' will be set to 'root' because 'xx' does not exist + * + * @param string|\Zend_Locale $locale (Optional) Locale for parsing input + * @throws \Zend_Date_Exception When the given locale does not exist + * @return $this Provides fluent interface + */ + public function setLocale($locale = null); + + /** + * Returns the actual set locale + * + * @return string + */ + public function getLocale(); + + /** + * Checks if the given date is a real date or datepart. + * Returns false if a expected datepart is missing or a datepart exceeds its possible border. + * But the check will only be done for the expected dateparts which are given by format. + * If no format is given the standard dateformat for the actual locale is used. + * f.e. 30.February.2007 will return false if format is 'dd.MMMM.YYYY' + * + * @param string|array|\Magento\Stdlib\DateTime\DateInterface $date Date to parse for correctness + * @param string $format (Optional) Format for parsing the date string + * @param string|\Zend_Locale $locale (Optional) Locale for parsing date parts + * @return boolean True when all date parts are correct + */ + public static function isDate($date, $format = null, $locale = null); + + /** + * Sets a new timezone for calculation of $this object's gmt offset. + * For a list of supported timezones look here: http://php.net/timezones + * If no timezone can be detected or the given timezone is wrong UTC will be set. + * + * @param string $zone OPTIONAL timezone for date calculation; defaults to date_default_timezone_get() + * @return \Zend_Date_DateObject Provides fluent interface + * @throws \Zend_Date_Exception + */ + public function setTimezone($zone = null); + + /** + * Return the timezone of $this object. + * The timezone is initially set when the object is instantiated. + * + * @return string actual set timezone string + */ + public function getTimezone(); + + /** + * Return the offset to GMT of $this object's timezone. + * The offset to GMT is initially set when the object is instantiated using the currently, + * in effect, default timezone for PHP functions. + * + * @return integer seconds difference between GMT timezone and timezone when object was instantiated + */ + public function getGmtOffset(); +} diff --git a/app/code/Magento/Core/Model/Date.php b/lib/Magento/Stdlib/DateTime/DateTime.php similarity index 90% rename from app/code/Magento/Core/Model/Date.php rename to lib/Magento/Stdlib/DateTime/DateTime.php index 8f03e113532..660069c5ed7 100644 --- a/app/code/Magento/Core/Model/Date.php +++ b/lib/Magento/Stdlib/DateTime/DateTime.php @@ -28,9 +28,9 @@ * * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Core\Model; +namespace Magento\Stdlib\DateTime; -class Date +class DateTime { /** * Current config offset in seconds @@ -40,17 +40,17 @@ class Date private $_offset = 0; /** - * @var LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** - * @param LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate */ - public function __construct(LocaleInterface $locale) + public function __construct(\Magento\Stdlib\DateTime\TimezoneInterface $localeDate) { - $this->_locale = $locale; - $this->_offset = $this->calculateOffset($locale->getConfigTimezone()); + $this->_localeDate = $localeDate; + $this->_offset = $this->calculateOffset($this->_localeDate->getConfigTimezone()); } /** @@ -134,7 +134,7 @@ class Date // strtotime() unable to parse string (it's not a date or has incorrect format) return false; } - $date = $this->_locale->date($result); + $date = $this->_localeDate->date($result); $timestamp = $date->get(\Zend_Date::TIMESTAMP) - $date->get(\Zend_Date::TIMEZONE_SECS); unset($date); return $timestamp; @@ -158,7 +158,7 @@ class Date $result = strtotime($input); } } - $date = $this->_locale->date($result); + $date = $this->_localeDate->date($result); $timestamp = $date->get(\Zend_Date::TIMESTAMP) + $date->get(\Zend_Date::TIMEZONE_SECS); unset($date); return $timestamp; diff --git a/app/code/Magento/Core/Filter/Date.php b/lib/Magento/Stdlib/DateTime/Filter/Date.php similarity index 53% rename from app/code/Magento/Core/Filter/Date.php rename to lib/Magento/Stdlib/DateTime/Filter/Date.php index 6a7e94b34b2..61af9643143 100644 --- a/app/code/Magento/Core/Filter/Date.php +++ b/lib/Magento/Stdlib/DateTime/Filter/Date.php @@ -2,15 +2,29 @@ /** * Date filter. Converts date from localized to internal format. * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * @todo move this class to library when locale interface is moved - */ -namespace Magento\Core\Filter; -use Magento\Core\Model\LocaleInterface; +namespace Magento\Stdlib\DateTime\Filter; class Date implements \Zend_Filter_Interface { @@ -29,13 +43,16 @@ class Date implements \Zend_Filter_Interface protected $_normalToLocalFilter; /** - * @param LocaleInterface $locale + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ + protected $_localeDate; + public function __construct( - LocaleInterface $locale + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate ) { + $this->_localeDate = $localeDate; $this->_localToNormalFilter = new \Zend_Filter_LocalizedToNormalized(array( - 'date_format' => $locale->getDateFormat(LocaleInterface::FORMAT_TYPE_SHORT) + 'date_format' => $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT) )); $this->_normalToLocalFilter = new \Zend_Filter_NormalizedToLocalized(array( 'date_format' => \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT diff --git a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Mode.php b/lib/Magento/Stdlib/DateTime/Filter/DateTime.php similarity index 55% rename from app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Mode.php rename to lib/Magento/Stdlib/DateTime/Filter/DateTime.php index bb7c7f2857b..44264194c20 100644 --- a/app/code/Magento/Usa/Model/Shipping/Carrier/Ups/Source/Mode.php +++ b/lib/Magento/Stdlib/DateTime/Filter/DateTime.php @@ -1,5 +1,7 @@ <?php /** + * Date/Time filter. Converts datetime from localized to internal format. + * * Magento * * NOTICE OF LICENSE @@ -18,32 +20,26 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Usa * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * UPS (UPS XML) mode source model - * - * @deprecated since 1.7.0.0 - * @category Magento - * @package Magento_Usa - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\Usa\Model\Shipping\Carrier\Ups\Source; +namespace Magento\Stdlib\DateTime\Filter; -class Mode implements \Magento\Option\ArrayInterface +class DateTime extends Date { /** - * {@inheritdoc} + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate */ - public function toOptionArray() - { - return array( - array('value' => '1', 'label' => __('Live')), - array('value' => '0', 'label' => __('Development')), - ); + public function __construct( + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate + ) { + parent::__construct($localeDate); + $this->_localToNormalFilter = new \Zend_Filter_LocalizedToNormalized(array( + 'date_format' => $this->_localeDate->getDateTimeFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT) + )); + $this->_normalToLocalFilter = new \Zend_Filter_NormalizedToLocalized(array( + 'date_format' => \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT + )); } } diff --git a/lib/Magento/Stdlib/DateTime/Timezone.php b/lib/Magento/Stdlib/DateTime/Timezone.php new file mode 100644 index 00000000000..da092b0e825 --- /dev/null +++ b/lib/Magento/Stdlib/DateTime/Timezone.php @@ -0,0 +1,305 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Stdlib\DateTime; + +class Timezone implements \Magento\Stdlib\DateTime\TimezoneInterface +{ + /** + * @var array + */ + protected $_allowedFormats = array( + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_FULL, + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_LONG, + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM, + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT + ); + + /** + * @var \Magento\BaseScopeResolverInterface + */ + protected $_scopeResolver; + + /** + * @var \Magento\Stdlib\DateTime + */ + protected $_dateTime; + + /** + * @var \Magento\Stdlib\DateTime\DateFactory + */ + protected $_dateFactory; + + protected $_defaultTimezonePath; + + /** + * @param \Magento\BaseScopeResolverInterface $scopeResolver + * @param \Magento\Locale\ResolverInterface $localeResolver + * @param \Magento\Stdlib\DateTime $dateTime + * @param DateFactory $dateFactory + * @param string $defaultTimezonePath + */ + function __construct( + \Magento\BaseScopeResolverInterface $scopeResolver, + \Magento\Locale\ResolverInterface $localeResolver, + \Magento\Stdlib\DateTime $dateTime, + \Magento\Stdlib\DateTime\DateFactory $dateFactory, + $defaultTimezonePath + ) { + $this->_scopeResolver = $scopeResolver; + $this->_localeResolver = $localeResolver; + $this->_dateTime = $dateTime; + $this->_dateFactory = $dateFactory; + $this->_defaultTimezonePath = $defaultTimezonePath; + } + + /** + * {@inheritdoc} + */ + public function getDefaultTimezonePath() + { + return $this->_defaultTimezonePath; + } + + /** + * {@inheritdoc} + */ + public function getDefaultTimezone() + { + return \Magento\Stdlib\DateTime\TimezoneInterface::DEFAULT_TIMEZONE; + } + + /** + * {@inheritdoc} + */ + public function getConfigTimezone() + { + return $this->_scopeResolver->getScope()->getConfig('general/locale/timezone'); + } + + /** + * {@inheritdoc} + */ + public function getDateFormat($type = null) + { + return $this->_getTranslation($type, 'date'); + } + + /** + * {@inheritdoc} + */ + public function getDateFormatWithLongYear() + { + return preg_replace('/(?<!y)yy(?!y)/', 'yyyy', + $this->_getTranslation(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT, 'date')); + } + + /** + * {@inheritdoc} + */ + public function getTimeFormat($type = null) + { + return $this->_getTranslation($type, 'time'); + } + + /** + * {@inheritdoc} + */ + public function getDateTimeFormat($type) + { + return $this->getDateFormat($type) . ' ' . $this->getTimeFormat($type); + } + + /** + * {@inheritdoc} + */ + public function date($date = null, $part = null, $locale = null, $useTimezone = true) + { + if (is_null($locale)) { + $locale = $this->_localeResolver->getLocale(); + } + + if (empty($date)) { + // $date may be false, but \Magento\Stdlib\DateTime\DateInterface uses strict compare + $date = null; + } + $date = $this->_dateFactory->create(array( + 'date' => $date, + 'part' => $part, + 'locale' => $locale, + )); + if ($useTimezone) { + $timezone = $this->_scopeResolver->getScope() + ->getConfig($this->getDefaultTimezonePath()); + if ($timezone) { + $date->setTimezone($timezone); + } + } + + return $date; + } + + /** + * {@inheritdoc} + */ + public function scopeDate($scope=null, $date=null, $includeTime=false) + { + $timezone = $this->_scopeResolver->getScope($scope) + ->getConfig($this->getDefaultTimezonePath()); + $date = $this->_dateFactory->create(array( + 'date' => $date, + 'part' => null, + 'locale' => $this->_localeResolver->getLocale(), + )); + $date->setTimezone($timezone); + if (!$includeTime) { + $date->setHour(0) + ->setMinute(0) + ->setSecond(0); + } + return $date; + } + + /** + * {@inheritdoc} + */ + public function formatDate( + $date = null, $format = \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT, $showTime = false + ) { + if (!in_array($format, $this->_allowedFormats, true)) { + return $date; + } + if (!($date instanceof \Magento\Stdlib\DateTime\DateInterface) && $date && !strtotime($date)) { + return ''; + } + if (is_null($date)) { + $date = $this->date( + gmdate('U'), + null, + null + ); + } elseif (!$date instanceof \Magento\Stdlib\DateTime\DateInterface) { + $date = $this->date(strtotime($date), null, null); + } + + if ($showTime) { + $format = $this->getDateTimeFormat($format); + } else { + $format = $this->getDateFormat($format); + } + + return $date->toString($format); + } + + /** + * {@inheritdoc} + */ + public function formatTime( + $time = null, $format = \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT, $showDate = false + ) { + if (!in_array($format, $this->_allowedFormats, true)) { + return $time; + } + + if (is_null($time)) { + $date = $this->date(time()); + } elseif ($time instanceof \Magento\Stdlib\DateTime\DateInterface) { + $date = $time; + } else { + $date = $this->date(strtotime($time)); + } + + if ($showDate) { + $format = $this->getDateTimeFormat($format); + } else { + $format = $this->getTimeFormat($format); + } + + return $date->toString($format); + } + + /** + * {@inheritdoc} + */ + public function utcDate($scope, $date, $includeTime = false, $format = null) + { + $dateObj = $this->scopeDate($scope, $date, $includeTime); + $dateObj->set($date, $format); + $dateObj->setTimezone(\Magento\Stdlib\DateTime\TimezoneInterface::DEFAULT_TIMEZONE); + return $dateObj; + } + + /** + * {@inheritdoc} + */ + public function scopeTimeStamp($scope=null) + { + $timezone = $this->_scopeResolver->getScope($scope) + ->getConfig($this->getDefaultTimezonePath()); + $currentTimezone = @date_default_timezone_get(); + @date_default_timezone_set($timezone); + $date = date('Y-m-d H:i:s'); + @date_default_timezone_set($currentTimezone); + return strtotime($date); + } + + /** + * {@inheritdoc} + */ + public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null) + { + if (!$scope instanceof \Magento\BaseScopeInterface) { + $scope = $this->_scopeResolver->getScope($scope); + } + + $scopeTimeStamp = $this->scopeTimeStamp($scope); + $fromTimeStamp = strtotime($dateFrom); + $toTimeStamp = strtotime($dateTo); + if ($dateTo) { + // fix date YYYY-MM-DD 00:00:00 to YYYY-MM-DD 23:59:59 + $toTimeStamp += 86400; + } + + $result = false; + if (!$this->_dateTime->isEmptyDate($dateFrom) && $scopeTimeStamp < $fromTimeStamp) { + } elseif (!$this->_dateTime->isEmptyDate($dateTo) && $scopeTimeStamp > $toTimeStamp) { + } else { + $result = true; + } + return $result; + } + + /** + * Returns a localized information string, supported are several types of informations. + * For detailed information about the types look into the documentation + * + * @param string $value Name to get detailed information about + * @param string $path (Optional) Type of information to return + * @return string|false The wished information in the given language + */ + protected function _getTranslation($value = null, $path = null) + { + return $this->_localeResolver->getLocale()->getTranslation($value, $path, $this->_localeResolver->getLocale()); + } +} diff --git a/lib/Magento/Stdlib/DateTime/TimezoneInterface.php b/lib/Magento/Stdlib/DateTime/TimezoneInterface.php new file mode 100644 index 00000000000..ecfc4441449 --- /dev/null +++ b/lib/Magento/Stdlib/DateTime/TimezoneInterface.php @@ -0,0 +1,169 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Stdlib\DateTime; + +interface TimezoneInterface +{ + /** + * Default timezone + */ + const DEFAULT_TIMEZONE = 'UTC'; + + /** + * Date and time format codes + */ + const FORMAT_TYPE_FULL = 'full'; + const FORMAT_TYPE_LONG = 'long'; + const FORMAT_TYPE_MEDIUM= 'medium'; + const FORMAT_TYPE_SHORT = 'short'; + + /** + * Return path to default timezone + * + * @return string + */ + public function getDefaultTimezonePath(); + + /** + * Retrieve timezone code + * + * @return string + */ + public function getDefaultTimezone(); + + /** + * Retrieve ISO date format + * + * @param string $type + * @return string + */ + public function getDateFormat($type = null); + + /** + * Retrieve short date format with 4-digit year + * + * @return string + */ + public function getDateFormatWithLongYear(); + + /** + * Retrieve ISO time format + * + * @param string $type + * @return string + */ + public function getTimeFormat($type = null); + + /** + * Retrieve ISO datetime format + * + * @param string $type + * @return string + */ + public function getDateTimeFormat($type); + + /** + * Create \Magento\Stdlib\DateTime\DateInterface object for current locale + * + * @param mixed $date + * @param string $part + * @param string|Zend_Locale $locale + * @param bool $useTimezone + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public function date($date = null, $part = null, $locale = null, $useTimezone = true); + + /** + * Create \Magento\Stdlib\DateTime\DateInterface object with date converted to scope timezone and scope Locale + * + * @param mixed $scope Information about scope + * @param string|integer|\Magento\Stdlib\DateTime\DateInterface|array|null $date date in UTC + * @param boolean $includeTime flag for including time to date + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public function scopeDate($scope = null, $date = null, $includeTime=false); + + /** + * Create \Magento\Stdlib\DateTime\DateInterface object with date converted from scope's timezone + * to UTC time zone. Date can be passed in format of scope's locale + * or in format which was passed as parameter. + * + * @param mixed $scope Information about scope + * @param string|integer|\Magento\Stdlib\DateTime\DateInterface|array|null $date date in scope's timezone + * @param boolean $includeTime flag for including time to date + * @param null|string $format + * @return \Magento\Stdlib\DateTime\DateInterface + */ + public function utcDate($scope, $date, $includeTime = false, $format = null); + + /** + * Get scope timestamp + * Timestamp will be built with scope timezone settings + * + * @param mixed $scope + * @return int + */ + public function scopeTimeStamp($scope = null); + /** + * Format date using current locale options and time zone. + * + * @param \Magento\Stdlib\DateTime\DateInterface|null $date + * @param string $format + * @param bool $showTime + * @return string + */ + public function formatDate( + $date = null, $format = \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT, $showTime = false + ); + + /** + * Format time using current locale options + * + * @param \Magento\Stdlib\DateTime\DateInterface|null $time + * @param string $format + * @param bool $showDate + * @return string + */ + public function formatTime( + $time = null, $format = \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT, $showDate = false + ); + + /** + * Gets the scope config timezone + * + * @return string + */ + public function getConfigTimezone(); + + /** + * Checks if current date of the given scope (in the scope timezone) is within the range + * + * @param int|string|\Magento\BaseScopeInterface $scope + * @param string|null $dateFrom + * @param string|null $dateTo + * @return bool + */ + public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null); +} diff --git a/lib/Magento/Translate.php b/lib/Magento/Translate.php index 7511e2a75f5..f3b948f11f4 100644 --- a/lib/Magento/Translate.php +++ b/lib/Magento/Translate.php @@ -170,9 +170,9 @@ class Translate implements \Magento\TranslateInterface protected $_translateResource; /** - * @var \Magento\AppInterface + * @var \Magento\Locale\ResolverInterface */ - protected $_app; + protected $_locale; /** * @var \Magento\App\State @@ -189,6 +189,13 @@ class Translate implements \Magento\TranslateInterface */ protected $directory; + /** + * Event manager + * + * @var \Magento\Event\ManagerInterface + */ + protected $_eventManager; + /** * @param \Magento\View\DesignInterface $viewDesign * @param \Magento\Locale\Hierarchy\Config $config @@ -200,9 +207,10 @@ class Translate implements \Magento\TranslateInterface * @param \Magento\Module\Dir\Reader $modulesReader * @param \Magento\BaseScopeResolverInterface $scopeResolver * @param \Magento\Translate\ResourceInterface $translate - * @param \Magento\AppInterface $app + * @param \Magento\Locale\ResolverInterface $locale * @param \Magento\App\State $appState * @param \Magento\App\Filesystem $filesystem + * @param \Magento\Event\ManagerInterface $eventManager * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -217,9 +225,10 @@ class Translate implements \Magento\TranslateInterface \Magento\Module\Dir\Reader $modulesReader, \Magento\BaseScopeResolverInterface $scopeResolver, \Magento\Translate\ResourceInterface $translate, - \Magento\AppInterface $app, + \Magento\Locale\ResolverInterface $locale, \Magento\App\State $appState, - \Magento\App\Filesystem $filesystem + \Magento\App\Filesystem $filesystem, + \Magento\Event\ManagerInterface $eventManager ) { $this->_viewDesign = $viewDesign; $this->_localeHierarchy = $config->getHierarchy(); @@ -231,10 +240,11 @@ class Translate implements \Magento\TranslateInterface $this->_modulesReader = $modulesReader; $this->_scopeResolver = $scopeResolver; $this->_translateResource = $translate; - $this->_app = $app; + $this->_locale = $locale; $this->_appState = $appState; $this->filesystem = $filesystem; $this->directory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::ROOT_DIR); + $this->_eventManager = $eventManager; } /** @@ -507,7 +517,7 @@ class Translate implements \Magento\TranslateInterface protected function getLocale() { if (null === $this->_localeCode) { - $this->_localeCode = $this->_app->getLocale()->getLocaleCode(); + $this->_localeCode = $this->_locale->getLocaleCode(); } return $this->_localeCode; } @@ -684,4 +694,26 @@ class Translate implements \Magento\TranslateInterface } return $this->_inlineInterface; } + + /** + * This method initializes the Translate object for this instance. + * + * @param string $localeCode + * @param string|null $area + * @return \Magento\TranslateInterface + */ + public function initLocale($localeCode, $area = null) + { + $this->setLocale($localeCode); + + $dispatchResult = new \Magento\Object(array( + 'inline_type' => null + )); + $this->_eventManager->dispatch('translate_initialization_before', array( + 'translate_object' => $this, + 'result' => $dispatchResult + )); + $this->init($area, $dispatchResult, true); + return $this; + } } diff --git a/lib/Magento/Translate/Locale/Resolver/Plugin.php b/lib/Magento/Translate/Locale/Resolver/Plugin.php new file mode 100644 index 00000000000..bb0edc099e8 --- /dev/null +++ b/lib/Magento/Translate/Locale/Resolver/Plugin.php @@ -0,0 +1,75 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Framework + * @subpackage Translate + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Magento translate abstract adapter + */ +namespace Magento\Translate\Locale\Resolver; + +class Plugin +{ + /** + * @var \Magento\TranslateInterface + */ + protected $_translate; + + /** + * @param \Magento\TranslateInterface $translate + */ + function __construct(\Magento\TranslateInterface $translate) + { + $this->_translate = $translate; + } + + /** + * @param \Magento\Locale\ResolverInterface $subject + * @param string|null $localeCode + */ + public function afterEmulate(\Magento\Locale\ResolverInterface $subject, $localeCode) + { + $this->_init($localeCode); + } + + /** + * @param \Magento\Locale\ResolverInterface $subject + * @param string|null $localeCode + */ + public function afterRevert(\Magento\Locale\ResolverInterface $subject, $localeCode) + { + $this->_init($localeCode); + } + + /** + * @param string|null $localeCode + */ + protected function _init($localeCode) + { + if (!is_null($localeCode)) { + $this->_translate->initLocale($localeCode); + } + } +} diff --git a/lib/Magento/TranslateInterface.php b/lib/Magento/TranslateInterface.php index 4c48fbd3c98..b3284f49576 100644 --- a/lib/Magento/TranslateInterface.php +++ b/lib/Magento/TranslateInterface.php @@ -83,4 +83,13 @@ interface TranslateInterface * @return string */ public function translate($args); + + /** + * This method initializes the Translate object for this instance. + * + * @param string $localeCode + * @param string|null $area + * @return \Magento\TranslateInterface + */ + public function initLocale($localeCode, $area = null); } diff --git a/lib/Magento/Url.php b/lib/Magento/Url.php index 94d5eb5662b..1f70bdd9b9b 100644 --- a/lib/Magento/Url.php +++ b/lib/Magento/Url.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/Magento/Url/Validator.php b/lib/Magento/Url/Validator.php similarity index 100% rename from app/code/Magento/Url/Validator.php rename to lib/Magento/Url/Validator.php diff --git a/lib/Magento/Validator/Object.php b/lib/Magento/Validator/Object.php index c75d48995b9..caff95dde21 100644 --- a/lib/Magento/Validator/Object.php +++ b/lib/Magento/Validator/Object.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/lib/Magento/View/Block/IdentityInterface.php b/lib/Magento/View/Block/IdentityInterface.php new file mode 100644 index 00000000000..4dfc12b6294 --- /dev/null +++ b/lib/Magento/View/Block/IdentityInterface.php @@ -0,0 +1,38 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 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: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\View\Block; + +/** + * Interface IdentityInterface + * @package Magento\View\Block + */ +interface IdentityInterface +{ + /** + * Return identifiers for produced content + * + * @return array + */ + public function getIdentities(); +} \ No newline at end of file diff --git a/lib/Magento/View/Element/AbstractBlock.php b/lib/Magento/View/Element/AbstractBlock.php index e334749e399..ce063c4e916 100644 --- a/lib/Magento/View/Element/AbstractBlock.php +++ b/lib/Magento/View/Element/AbstractBlock.php @@ -163,11 +163,9 @@ abstract class AbstractBlock extends \Magento\Object implements BlockInterface protected $filterManager; /** - * Locale - * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * The property is used to define content-scope of block. Can be private or public. @@ -177,6 +175,13 @@ abstract class AbstractBlock extends \Magento\Object implements BlockInterface */ protected $_isScopePrivate; + /** + * This property is for defining of tome to live for a block. + * + * @var int + */ + public $ttl; + /** * Constructor * @@ -195,15 +200,13 @@ abstract class AbstractBlock extends \Magento\Object implements BlockInterface $this->_session = $context->getSession(); $this->_sidResolver = $context->getSidResolver(); $this->_storeConfig = $context->getStoreConfig(); - $this->_frontController = $context->getFrontController(); $this->_viewUrl = $context->getViewUrl(); $this->_viewConfig = $context->getViewConfig(); $this->_cacheState = $context->getCacheState(); $this->_logger = $context->getLogger(); - $this->_app = $context->getApp(); $this->_escaper = $context->getEscaper(); $this->filterManager = $context->getFilterManager(); - $this->_locale = $context->getLocale(); + $this->_localeDate = $context->getLocaleDate(); $this->_isScopePrivate = false; parent::__construct($data); $this->_construct(); @@ -722,7 +725,6 @@ abstract class AbstractBlock extends \Magento\Object implements BlockInterface * @param array $params * @return string */ - public function getViewFileUrl($file = null, array $params = array()) { try { @@ -755,9 +757,9 @@ abstract class AbstractBlock extends \Magento\Object implements BlockInterface * @return string */ public function formatDate( - $date = null, $format = \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT, $showTime = false + $date = null, $format = \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT, $showTime = false ) { - return $this->_locale->formatDate($date, $format, $showTime); + return $this->_localeDate->formatDate($date, $format, $showTime); } /** @@ -769,9 +771,9 @@ abstract class AbstractBlock extends \Magento\Object implements BlockInterface * @return string */ public function formatTime( - $time = null, $format = \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT, $showDate = false + $time = null, $format = \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT, $showDate = false ) { - return $this->_locale->formatTime($time, $format, $showDate); + return $this->_localeDate->formatTime($time, $format, $showDate); } /** @@ -802,9 +804,9 @@ abstract class AbstractBlock extends \Magento\Object implements BlockInterface /** * Escape html entities * - * @param string|array $data - * @param array|null $allowedTags - * @return string + * @param string|array $data + * @param array|null $allowedTags + * @return string */ public function escapeHtml($data, $allowedTags = null) { diff --git a/lib/Magento/View/Element/Context.php b/lib/Magento/View/Element/Context.php index 1d52aaffeb0..5d1ec8fef0d 100644 --- a/lib/Magento/View/Element/Context.php +++ b/lib/Magento/View/Element/Context.php @@ -105,13 +105,6 @@ class Context implements \Magento\ObjectManager\ContextInterface */ protected $_storeConfig; - /** - * Front controller - * - * @var \Magento\App\FrontController - */ - protected $_frontController; - /** * View URL * @@ -140,13 +133,6 @@ class Context implements \Magento\ObjectManager\ContextInterface */ protected $_logger; - /** - * Application - * - * @var \Magento\Core\Model\App - */ - protected $_app; - /** * Escaper * @@ -162,11 +148,9 @@ class Context implements \Magento\ObjectManager\ContextInterface protected $_filterManager; /** - * Locale - * - * @var \Magento\Core\Model\LocaleInterface + * @var \Magento\Stdlib\DateTime\TimezoneInterface */ - protected $_locale; + protected $_localeDate; /** * Constructor @@ -181,15 +165,13 @@ class Context implements \Magento\ObjectManager\ContextInterface * @param \Magento\Session\SessionManagerInterface $session * @param \Magento\Session\SidResolverInterface $sidResolver * @param \Magento\Core\Model\Store\Config $storeConfig - * @param \Magento\App\FrontController $frontController * @param \Magento\View\Url $viewUrl * @param \Magento\View\ConfigInterface $viewConfig * @param \Magento\App\Cache\StateInterface $cacheState * @param \Magento\Logger $logger - * @param \Magento\Core\Model\App $app * @param \Magento\Escaper $escaper * @param \Magento\Filter\FilterManager $filterManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -206,15 +188,13 @@ class Context implements \Magento\ObjectManager\ContextInterface \Magento\Session\SessionManagerInterface $session, \Magento\Session\SidResolverInterface $sidResolver, \Magento\Core\Model\Store\Config $storeConfig, - \Magento\App\FrontController $frontController, \Magento\View\Url $viewUrl, \Magento\View\ConfigInterface $viewConfig, \Magento\App\Cache\StateInterface $cacheState, \Magento\Logger $logger, - \Magento\Core\Model\App $app, \Magento\Escaper $escaper, \Magento\Filter\FilterManager $filterManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, array $data = array() ) { $this->_request = $request; @@ -227,15 +207,13 @@ class Context implements \Magento\ObjectManager\ContextInterface $this->_session = $session; $this->_sidResolver = $sidResolver; $this->_storeConfig = $storeConfig; - $this->_frontController = $frontController; $this->_viewUrl = $viewUrl; $this->_viewConfig = $viewConfig; $this->_cacheState = $cacheState; $this->_logger = $logger; - $this->_app = $app; $this->_escaper = $escaper; $this->_filterManager = $filterManager; - $this->_locale = $locale; + $this->_localeDate = $localeDate; } /** @@ -268,16 +246,6 @@ class Context implements \Magento\ObjectManager\ContextInterface return $this->_eventManager; } - /** - * Get front controller - * - * @return \Magento\App\FrontController - */ - public function getFrontController() - { - return $this->_frontController; - } - /** * Get layout * @@ -388,16 +356,6 @@ class Context implements \Magento\ObjectManager\ContextInterface return $this->_logger; } - /** - * Get application - * - * @return \Magento\Core\Model\App - */ - public function getApp() - { - return $this->_app; - } - /** * Get escaper * @@ -419,12 +377,10 @@ class Context implements \Magento\ObjectManager\ContextInterface } /** - * Get locale - * - * @return \Magento\Core\Model\LocaleInterface + * @return \Magento\Stdlib\DateTime\TimezoneInterface */ - public function getLocale() + public function getLocaleDate() { - return $this->_locale; + return $this->_localeDate; } } diff --git a/lib/Magento/View/Element/Html/Calendar.php b/lib/Magento/View/Element/Html/Calendar.php index a6b50b29f12..97eef9d0701 100644 --- a/lib/Magento/View/Element/Html/Calendar.php +++ b/lib/Magento/View/Element/Html/Calendar.php @@ -34,7 +34,7 @@ class Calendar extends \Magento\View\Element\Template /** * Date model * - * @var \Magento\Core\Model\Date + * @var \Magento\Stdlib\DateTime\DateTime */ protected $_date; @@ -45,22 +45,30 @@ class Calendar extends \Magento\View\Element\Template */ protected $encoder; + /** + * @var \Magento\Locale\ResolverInterface + */ + protected $_localeResolver; + /** * Constructor * * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Core\Model\Date $date + * @param \Magento\Stdlib\DateTime\DateTime $date * @param \Magento\Json\EncoderInterface $encoder + * @param \Magento\Locale\ResolverInterface $localeResolver * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, - \Magento\Core\Model\Date $date, + \Magento\Stdlib\DateTime\DateTime $date, \Magento\Json\EncoderInterface $encoder, + \Magento\Locale\ResolverInterface $localeResolver, array $data = array() ) { $this->_date = $date; $this->encoder = $encoder; + $this->_localeResolver = $localeResolver; parent::__construct($context, $data); } @@ -71,7 +79,7 @@ class Calendar extends \Magento\View\Element\Template */ protected function _toHtml() { - $localeCode = $this->_locale->getLocaleCode(); + $localeCode = $this->_localeResolver->getLocaleCode(); // get days names $days = \Zend_Locale_Data::getList($localeCode, 'days'); @@ -105,12 +113,14 @@ class Calendar extends \Magento\View\Element\Template $this->assign( 'defaultFormat', $this->encoder->encode( - $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM) + $this->_localeDate->getDateFormat(\Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM) ) ); $this->assign( 'toolTipFormat', - $this->encoder->encode($this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_LONG)) + $this->encoder->encode($this->_localeDate->getDateFormat( + \Magento\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_LONG + )) ); // get days and months for en_US locale - calendar will parse exactly in this locale @@ -143,6 +153,6 @@ class Calendar extends \Magento\View\Element\Template */ public function getStoreTimestamp($store = null) { - return $this->_locale->storeTimeStamp($store); + return $this->_localeDate->scopeTimeStamp($store); } } diff --git a/lib/Magento/View/Element/Template/Context.php b/lib/Magento/View/Element/Template/Context.php index 96f70e37594..fd6a322a2b5 100644 --- a/lib/Magento/View/Element/Template/Context.php +++ b/lib/Magento/View/Element/Template/Context.php @@ -72,15 +72,13 @@ class Context extends \Magento\View\Element\Context * @param \Magento\Session\SessionManagerInterface $session * @param \Magento\Session\SidResolverInterface $sidResolver * @param \Magento\Core\Model\Store\Config $storeConfig - * @param \Magento\App\FrontController $frontController * @param \Magento\View\Url $viewUrl * @param \Magento\View\ConfigInterface $viewConfig * @param \Magento\App\Cache\StateInterface $cacheState * @param \Magento\Logger $logger - * @param \Magento\Core\Model\App $app * @param \Magento\Escaper $escaper * @param \Magento\Filter\FilterManager $filterManager - * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\App\Filesystem $filesystem * @param \Magento\View\FileSystem $viewFileSystem * @param \Magento\View\TemplateEnginePool $enginePool @@ -101,15 +99,13 @@ class Context extends \Magento\View\Element\Context \Magento\Session\SessionManagerInterface $session, \Magento\Session\SidResolverInterface $sidResolver, \Magento\Core\Model\Store\Config $storeConfig, - \Magento\App\FrontController $frontController, \Magento\View\Url $viewUrl, \Magento\View\ConfigInterface $viewConfig, \Magento\App\Cache\StateInterface $cacheState, \Magento\Logger $logger, - \Magento\Core\Model\App $app, \Magento\Escaper $escaper, \Magento\Filter\FilterManager $filterManager, - \Magento\Core\Model\LocaleInterface $locale, + \Magento\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\App\Filesystem $filesystem, \Magento\View\FileSystem $viewFileSystem, \Magento\View\TemplateEnginePool $enginePool, @@ -128,15 +124,13 @@ class Context extends \Magento\View\Element\Context $session, $sidResolver, $storeConfig, - $frontController, $viewUrl, $viewConfig, $cacheState, $logger, - $app, $escaper, $filterManager, - $locale, + $localeDate, $data ); diff --git a/pub/errors/processor.php b/pub/errors/processor.php index 62cd5f55e85..18dbdc4eb0e 100644 --- a/pub/errors/processor.php +++ b/pub/errors/processor.php @@ -269,7 +269,9 @@ class Error_Processor $isSecure = (!empty($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] != 'off'); $url = ($isSecure ? 'https://' : 'http://') . $host; - if (!empty($_SERVER['SERVER_PORT']) && !in_array($_SERVER['SERVER_PORT'], array(80, 433))) { + if (!empty($_SERVER['SERVER_PORT']) && !in_array($_SERVER['SERVER_PORT'], array(80, 433)) + && !preg_match('/.*?\:[0-9]+$/', $url) + ) { $url .= ':' . $_SERVER['SERVER_PORT']; } return $url; @@ -488,9 +490,9 @@ class Error_Processor $this->_setReportUrl(); if (headers_sent()) { - print '<script type="text/javascript">'; - print "window.location.href = '{$this->reportUrl}';"; - print '</script>'; + echo '<script type="text/javascript">'; + echo "window.location.href = '{$this->reportUrl}';"; + echo '</script>'; exit; } } diff --git a/pub/lib/mage/validation.js b/pub/lib/mage/validation.js index a1981b83d0c..18c75a3321c 100644 --- a/pub/lib/mage/validation.js +++ b/pub/lib/mage/validation.js @@ -1045,8 +1045,8 @@ }); return result; }, function() { - return $.mage.__("Maximum length of this field must be equal or less than %s symbols.") - .replace('%s', this.attrLength); + return $.mage.__("Maximum length of this field must be equal or less than %1 symbols.") + .replace('%1', this.attrLength); } ], 'required-entry': [ diff --git a/pub/lib/mage/validation/dob-rule.js b/pub/lib/mage/validation/dob-rule.js index 3bd6f5bdb09..455742e68a5 100644 --- a/pub/lib/mage/validation/dob-rule.js +++ b/pub/lib/mage/validation/dob-rule.js @@ -55,13 +55,13 @@ } if (year < 1900 || year > curYear) { this.dobErrorMessage = - $.mage.__('Please enter a valid year (1900-%d).').replace('%d', curYear.toString()); + $.mage.__('Please enter a valid year (1900-%1).').replace('%1', curYear.toString()); return false; } var validateDayInMonth = new Date(year, month, 0).getDate(); if (day < 1 || day > validateDayInMonth) { this.dobErrorMessage = - $.mage.__('Please enter a valid day (1-%d).').replace('%d', validateDayInMonth.toString()); + $.mage.__('Please enter a valid day (1-%1).').replace('%1', validateDayInMonth.toString()); return false; } var today = new Date(), diff --git a/pub/lib/varien/js.js b/pub/lib/varien/js.js index e3d33954f23..c520f6159d2 100644 --- a/pub/lib/varien/js.js +++ b/pub/lib/varien/js.js @@ -465,7 +465,7 @@ Varien.DateElement.prototype = { if (day<1 || day>countDaysInMonth) { errorType = 'day'; - error = 'Please enter a valid day (1-%d).'; + error = 'Please enter a valid day (1-%1).'; } else if (month<1 || month>12) { errorType = 'month'; error = 'Please enter a valid month (1-12).'; @@ -494,7 +494,7 @@ Varien.DateElement.prototype = { error = jQuery.mage.__(error); } if (!valueError) { - this.advice.innerHTML = error.replace('%d', countDaysInMonth); + this.advice.innerHTML = error.replace('%1', countDaysInMonth); } else { this.advice.innerHTML = this.errorTextModifier(error); } @@ -517,9 +517,9 @@ Varien.DateElement.prototype = { return (year>=1900 && year<=this.curyear); }, validateDataErrorType: 'year', - validateDataErrorText: 'Please enter a valid year (1900-%d).', + validateDataErrorText: 'Please enter a valid year (1900-%1).', errorTextModifier: function(text) { - return text.replace('%d', this.curyear); + return text.replace('%1', this.curyear); }, setDateRange: function(minDate, maxDate) { this.minDate = minDate; -- GitLab