Skip to content

Commit

Permalink
Merge pull request #2800 from spryker/feature/core-1303-cms-page-preview
Browse files Browse the repository at this point in the history
CORE-1303 CMS Page Preview
  • Loading branch information
dereuromark authored Oct 5, 2017
2 parents fdda992 + 301946e commit 6867a2f
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Spryker/Shared/Customer/Transfer/customer.transfer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
<property name="isGuest" type="bool" />
<property name="locale" type="Locale" />
<property name="anonymizedAt" type="string" />
<property name="fkUser" type="int" />
<property name="username" type="string" />
</transfer>

<transfer name="CustomerError">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
24 changes: 24 additions & 0 deletions src/Spryker/Zed/Customer/CustomerDependencyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -76,6 +77,7 @@ public function provideCommunicationLayerDependencies(Container $container)
};

$container = $this->addStore($container);
$container = $this->addCustomerTransferExpanderPlugins($container);

return $container;
}
Expand Down Expand Up @@ -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 [];
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
*/

namespace Spryker\Zed\Customer\Dependency\Plugin;

use Generated\Shared\Transfer\CustomerTransfer;

interface CustomerTransferExpanderPluginInterface
{

/**
* Specification
* - Expands the provided customer transfer object's data and returns the modified object.
*
* @api
*
* @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer
*
* @return \Generated\Shared\Transfer\CustomerTransfer
*/
public function expandTransfer(CustomerTransfer $customerTransfer);

}
6 changes: 6 additions & 0 deletions src/Spryker/Zed/Customer/Presentation/View/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
<th>{{ 'Registered at' | trans }}</th>
<td>{{ customer.createdAt | formatDateTime }}</td>
</tr>
{% if customer.username is defined %}
<tr>
<th>{{ 'Zed Account Reference' | trans }}</th>
<td><a href="{{ url('/user/edit/update', {'id-user': customer.fkUser}) }}">{{ customer.username }}</a></td>
</tr>
{% endif %}
</tbody>
<tfoot>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 6867a2f

Please sign in to comment.