From ffcd967d784d213a6ffd323b68e0db6a9a4d5751 Mon Sep 17 00:00:00 2001 From: Karoly Gerner Date: Tue, 5 Sep 2017 17:37:23 +0000 Subject: [PATCH 1/5] CORE-1303 Customer-user connection handling on Zed UI --- .../Customer/Transfer/customer.transfer.xml | 2 ++ .../Controller/ViewController.php | 17 ++++++++++++ .../CustomerCommunicationFactory.php | 8 ++++++ .../Customer/CustomerDependencyProvider.php | 24 +++++++++++++++++ ...ustomerTransferExpanderPluginInterface.php | 27 +++++++++++++++++++ .../Zed/Customer/Presentation/View/index.twig | 6 +++++ 6 files changed, 84 insertions(+) create mode 100644 src/Spryker/Zed/Customer/Dependency/Plugin/CustomerTransferExpanderPluginInterface.php diff --git a/src/Spryker/Shared/Customer/Transfer/customer.transfer.xml b/src/Spryker/Shared/Customer/Transfer/customer.transfer.xml index f7dcb077..65eb1884 100644 --- a/src/Spryker/Shared/Customer/Transfer/customer.transfer.xml +++ b/src/Spryker/Shared/Customer/Transfer/customer.transfer.xml @@ -67,6 +67,8 @@ + + diff --git a/src/Spryker/Zed/Customer/Communication/Controller/ViewController.php b/src/Spryker/Zed/Customer/Communication/Controller/ViewController.php index 3ad21a4a..54ccbd92 100644 --- a/src/Spryker/Zed/Customer/Communication/Controller/ViewController.php +++ b/src/Spryker/Zed/Customer/Communication/Controller/ViewController.php @@ -83,6 +83,23 @@ protected function loadCustomerTransfer($idCustomer) $customerTransfer = $this->createCustomerTransfer(); $customerTransfer->setIdCustomer($idCustomer); $customerTransfer = $this->getFacade()->getCustomer($customerTransfer); + $customerTransfer = $this->applyCustomerTransferExpanderPlugins($customerTransfer); + + return $customerTransfer; + } + + /** + * @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer + * + * @return \Generated\Shared\Transfer\CustomerTransfer + */ + protected function applyCustomerTransferExpanderPlugins(CustomerTransfer $customerTransfer) + { + $expanderPlugins = $this->getFactory()->getCustomerTransferExpanderPlugins(); + foreach ($expanderPlugins as $expanderPlugin) { + $customerTransfer = $expanderPlugin->expandTransfer($customerTransfer); + } + return $customerTransfer; } diff --git a/src/Spryker/Zed/Customer/Communication/CustomerCommunicationFactory.php b/src/Spryker/Zed/Customer/Communication/CustomerCommunicationFactory.php index 20bdb69e..3b42d05f 100644 --- a/src/Spryker/Zed/Customer/Communication/CustomerCommunicationFactory.php +++ b/src/Spryker/Zed/Customer/Communication/CustomerCommunicationFactory.php @@ -121,4 +121,12 @@ protected function getStore() return $this->getProvidedDependency(CustomerDependencyProvider::STORE); } + /** + * @return \Spryker\Zed\Customer\Dependency\Plugin\CustomerTransferExpanderPluginInterface[] + */ + public function getCustomerTransferExpanderPlugins() + { + return $this->getProvidedDependency(CustomerDependencyProvider::PLUGINS_CUSTOMER_TRANSFER_EXPANDER); + } + } diff --git a/src/Spryker/Zed/Customer/CustomerDependencyProvider.php b/src/Spryker/Zed/Customer/CustomerDependencyProvider.php index 71714734..940097fd 100644 --- a/src/Spryker/Zed/Customer/CustomerDependencyProvider.php +++ b/src/Spryker/Zed/Customer/CustomerDependencyProvider.php @@ -27,6 +27,7 @@ class CustomerDependencyProvider extends AbstractBundleDependencyProvider const STORE = 'store'; const PLUGINS_CUSTOMER_ANONYMIZER = 'PLUGINS_CUSTOMER_ANONYMIZER'; + const PLUGINS_CUSTOMER_TRANSFER_EXPANDER = 'PLUGINS_CUSTOMER_TRANSFER_EXPANDER'; /** * @param \Spryker\Zed\Kernel\Container $container @@ -76,6 +77,7 @@ public function provideCommunicationLayerDependencies(Container $container) }; $container = $this->addStore($container); + $container = $this->addCustomerTransferExpanderPlugins($container); return $container; } @@ -116,4 +118,26 @@ protected function addStore(Container $container) return $container; } + /** + * @param \Spryker\Zed\Kernel\Container $container + * + * @return \Spryker\Zed\Kernel\Container + */ + public function addCustomerTransferExpanderPlugins(Container $container) + { + $container[static::PLUGINS_CUSTOMER_TRANSFER_EXPANDER] = function (Container $container) { + return $this->getCustomerTransferExpanderPlugins(); + }; + + return $container; + } + + /** + * @return \Spryker\Zed\Customer\Dependency\Plugin\CustomerTransferExpanderPluginInterface[] + */ + protected function getCustomerTransferExpanderPlugins() + { + return []; + } + } diff --git a/src/Spryker/Zed/Customer/Dependency/Plugin/CustomerTransferExpanderPluginInterface.php b/src/Spryker/Zed/Customer/Dependency/Plugin/CustomerTransferExpanderPluginInterface.php new file mode 100644 index 00000000..b40d51b6 --- /dev/null +++ b/src/Spryker/Zed/Customer/Dependency/Plugin/CustomerTransferExpanderPluginInterface.php @@ -0,0 +1,27 @@ +{{ 'Registered at' | trans }} {{ customer.createdAt | formatDateTime }} + {% if customer.username is defined %} + + {{ 'auth.email' | trans }} + {{ customer.username }} + + {% endif %} From 9cbf34ff4293c71d3785cdd26c4b91fec849414f Mon Sep 17 00:00:00 2001 From: Karoly Gerner Date: Wed, 6 Sep 2017 16:23:45 +0000 Subject: [PATCH 2/5] CORE-1303 fixing JS file and variable namings, adding bridges, adding api documentation, fixing preview button to appear in group, fixing labels, moving business logic to business layer --- .../Plugin/CustomerTransferExpanderPluginInterface.php | 2 +- src/Spryker/Zed/Customer/Presentation/View/index.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Spryker/Zed/Customer/Dependency/Plugin/CustomerTransferExpanderPluginInterface.php b/src/Spryker/Zed/Customer/Dependency/Plugin/CustomerTransferExpanderPluginInterface.php index b40d51b6..2679d71c 100644 --- a/src/Spryker/Zed/Customer/Dependency/Plugin/CustomerTransferExpanderPluginInterface.php +++ b/src/Spryker/Zed/Customer/Dependency/Plugin/CustomerTransferExpanderPluginInterface.php @@ -14,7 +14,7 @@ interface CustomerTransferExpanderPluginInterface /** * Specification - * TODO: add doc + * - Expands the provided customer transfer object's data and returns the modified object. * * @api * diff --git a/src/Spryker/Zed/Customer/Presentation/View/index.twig b/src/Spryker/Zed/Customer/Presentation/View/index.twig index 53089edf..24b74760 100644 --- a/src/Spryker/Zed/Customer/Presentation/View/index.twig +++ b/src/Spryker/Zed/Customer/Presentation/View/index.twig @@ -69,7 +69,7 @@ {% if customer.username is defined %} - {{ 'auth.email' | trans }} + {{ 'E-mail' | trans }} {{ customer.username }} {% endif %} From 011efb7c2850f3178d3557979b74cf53267ca298 Mon Sep 17 00:00:00 2001 From: Karoly Gerner Date: Thu, 7 Sep 2017 18:47:39 +0000 Subject: [PATCH 3/5] CORE-1303 Moving plugins into their proper places, updating dependencies accordingly --- src/Spryker/Zed/Customer/Presentation/View/index.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spryker/Zed/Customer/Presentation/View/index.twig b/src/Spryker/Zed/Customer/Presentation/View/index.twig index 24b74760..83775441 100644 --- a/src/Spryker/Zed/Customer/Presentation/View/index.twig +++ b/src/Spryker/Zed/Customer/Presentation/View/index.twig @@ -69,7 +69,7 @@ {% if customer.username is defined %} - {{ 'E-mail' | trans }} + {{ 'User E-mail' | trans }} {{ customer.username }} {% endif %} From 16cd691c47e32a364aa92909365d831c7f6412a9 Mon Sep 17 00:00:00 2001 From: Karoly Gerner Date: Wed, 13 Sep 2017 14:26:54 +0000 Subject: [PATCH 4/5] CORE-1303 Renaming view field, fixing titles on Zed UI, renaming button titles, restricting available customer selection to unassigned customers only, adding breadcrumb to customer user management --- src/Spryker/Zed/Customer/Presentation/View/index.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spryker/Zed/Customer/Presentation/View/index.twig b/src/Spryker/Zed/Customer/Presentation/View/index.twig index 83775441..c03d36d7 100644 --- a/src/Spryker/Zed/Customer/Presentation/View/index.twig +++ b/src/Spryker/Zed/Customer/Presentation/View/index.twig @@ -69,7 +69,7 @@ {% if customer.username is defined %} - {{ 'User E-mail' | trans }} + {{ 'Zed Account Reference' | trans }} {{ customer.username }} {% endif %} From 301946e29eef084916508e32728a66f63aeb9732 Mon Sep 17 00:00:00 2001 From: Karoly Gerner Date: Thu, 5 Oct 2017 09:26:12 +0000 Subject: [PATCH 5/5] CORE-1303 Restricting data helper have methods type with array --- .../Shared/Customer/_support/Helper/CustomerDataHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/SprykerTest/Shared/Customer/_support/Helper/CustomerDataHelper.php b/tests/SprykerTest/Shared/Customer/_support/Helper/CustomerDataHelper.php index 5c2440f8..5783e4d5 100644 --- a/tests/SprykerTest/Shared/Customer/_support/Helper/CustomerDataHelper.php +++ b/tests/SprykerTest/Shared/Customer/_support/Helper/CustomerDataHelper.php @@ -27,7 +27,7 @@ class CustomerDataHelper extends Module * * @return \Generated\Shared\Transfer\CustomerTransfer */ - public function haveCustomer($override = []) + public function haveCustomer(array $override = []) { $customerTransfer = (new CustomerBuilder($override)) ->withBillingAddress()