-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from NVision-Commerce-Solutions/CORE-1
Core 1
- Loading branch information
Showing
14 changed files
with
307 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Commerce365\Core\Block\Adminhtml; | ||
|
||
use Commerce365\Core\Service\Module\VersionInterface; | ||
use Magento\Backend\Block\Template; | ||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use Magento\Framework\Data\Form\Element\Renderer\RendererInterface; | ||
use Magento\Framework\Exception\ValidatorException; | ||
|
||
class Version extends Template implements RendererInterface | ||
{ | ||
protected $_template = 'Commerce365_Core::system/config/version.phtml'; | ||
private VersionInterface $moduleVersion; | ||
|
||
/** | ||
* @param Context $context | ||
* @param VersionInterface $version | ||
*/ | ||
public function __construct(Context $context, VersionInterface $version) | ||
{ | ||
parent::__construct($context); | ||
$this->moduleVersion = $version; | ||
} | ||
|
||
/** | ||
* @return array[] | ||
*/ | ||
public function getModuleVersionInfo(): array | ||
{ | ||
return [ | ||
$this->moduleVersion->getPackageName() => [ | ||
'label' => $this->moduleVersion->getLabelName()?: $this->moduleVersion->getModuleName(), | ||
'version' => $this->moduleVersion->getVersion() | ||
] | ||
]; | ||
} | ||
|
||
/** | ||
* @param AbstractElement $element | ||
* @return string | ||
* @throws ValidatorException | ||
*/ | ||
public function render(AbstractElement $element): string | ||
{ | ||
return $this->fetchView($this->getTemplateFile()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Commerce365\Core\Model\Command; | ||
|
||
use Magento\Framework\App\ResourceConnection; | ||
|
||
class GetCustomerEmailById | ||
{ | ||
private ResourceConnection $resourceConnection; | ||
|
||
public function __construct(ResourceConnection $resourceConnection) | ||
{ | ||
$this->resourceConnection = $resourceConnection; | ||
} | ||
|
||
/** | ||
* @param $customerId | ||
* @return string | ||
*/ | ||
public function execute($customerId) | ||
{ | ||
$connection = $this->resourceConnection->getConnection(); | ||
$tableName = $this->resourceConnection->getTableName('customer_entity'); | ||
$select = $connection->select()->from($tableName, ['email']) | ||
->where('entity_id = ?', $customerId); | ||
|
||
return $connection->fetchOne($select); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Commerce365\Core\Service\Module; | ||
|
||
use Magento\Framework\Module\PackageInfoFactory; | ||
use Magento\Framework\Module\PackageInfo; | ||
|
||
class Version implements VersionInterface | ||
{ | ||
private PackageInfo $packageInfo; | ||
private string $packageName; | ||
private string $labelName; | ||
|
||
/** | ||
* @param PackageInfoFactory $packageInfoFactory | ||
* @param string $packageName | ||
* @param string $labelName | ||
*/ | ||
public function __construct(PackageInfoFactory $packageInfoFactory, string $packageName, string $labelName = '') | ||
{ | ||
$this->packageInfo = $packageInfoFactory->create(); | ||
$this->packageName = $packageName; | ||
$this->labelName = $labelName; | ||
} | ||
|
||
public function getVersion(): string | ||
{ | ||
return $this->packageInfo->getVersion($this->getModuleName()); | ||
} | ||
|
||
public function getModuleName(): ?string | ||
{ | ||
return $this->packageInfo->getModuleName($this->packageName); | ||
} | ||
|
||
public function getPackageName(): string | ||
{ | ||
return $this->packageName; | ||
} | ||
|
||
public function getLabelName(): ?string | ||
{ | ||
return $this->labelName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Commerce365\Core\Service\Module; | ||
|
||
interface VersionInterface | ||
{ | ||
public function getVersion(): string; | ||
|
||
public function getModuleName(): ?string; | ||
|
||
public function getPackageName(): string; | ||
|
||
public function getLabelName(): ?string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Commerce365\Core\Setup\Patch\Data; | ||
|
||
use Magento\Framework\Setup\ModuleDataSetupInterface; | ||
use Magento\Framework\Setup\Patch\DataPatchInterface; | ||
|
||
class ChangeParentCustomerAttributeLabel implements DataPatchInterface | ||
{ | ||
private ModuleDataSetupInterface $moduleDataSetup; | ||
|
||
public function __construct(ModuleDataSetupInterface $moduleDataSetup) | ||
{ | ||
$this->moduleDataSetup = $moduleDataSetup; | ||
} | ||
|
||
public function getAliases(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public static function getDependencies(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function apply() | ||
{ | ||
$this->moduleDataSetup->startSetup(); | ||
|
||
$this->moduleDataSetup->getConnection()->update( | ||
$this->moduleDataSetup->getTable('eav_attribute'), | ||
['frontend_label' => 'Parent Customer'], | ||
['attribute_code = ?' => 'parent_customer_id'] | ||
); | ||
|
||
$this->moduleDataSetup->endSetup(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Commerce365\Core\Ui\Component\Listing\Column; | ||
|
||
use Commerce365\Core\Model\Command\GetCustomerEmailById; | ||
use Magento\Backend\Model\UrlInterface; | ||
use Magento\Framework\View\Element\UiComponent\ContextInterface; | ||
use Magento\Framework\View\Element\UiComponentFactory; | ||
use Magento\Ui\Component\Listing\Columns\Column; | ||
|
||
class ParentCustomer extends Column | ||
{ | ||
private GetCustomerEmailById $getCustomerEmailById; | ||
private UrlInterface $url; | ||
|
||
public function __construct( | ||
ContextInterface $context, | ||
UiComponentFactory $uiComponentFactory, | ||
GetCustomerEmailById $getCustomerEmailById, | ||
UrlInterface $url, | ||
array $components = [], | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $uiComponentFactory, $components, $data); | ||
$this->getCustomerEmailById = $getCustomerEmailById; | ||
$this->url = $url; | ||
} | ||
/** | ||
* Prepare Data Source | ||
* | ||
* @param array $dataSource | ||
* @return array | ||
*/ | ||
public function prepareDataSource(array $dataSource) | ||
{ | ||
if (isset($dataSource['data']['items'])) { | ||
foreach ($dataSource['data']['items'] as & $item) | ||
{ | ||
if (empty($item['parent_customer_id'])) { | ||
continue; | ||
} | ||
$email = $this->getCustomerEmailById->execute($item['parent_customer_id']); | ||
if (!$email) { | ||
continue; | ||
} | ||
|
||
$url = $this->url->getUrl('customer/index/edit', ['id' => $item['parent_customer_id']]); | ||
$item[$this->getData('name')] = '<a href="' . $url . '">' . $email . '</a>'; | ||
} | ||
} | ||
return $dataSource; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
$getList = $block->getModuleVersionInfo(); | ||
foreach ($getList as $key => $list) :?> | ||
<?= | ||
$label = null; | ||
$version = null; | ||
if (array_key_exists('label', $list)) { | ||
$label = $list['label']; | ||
} | ||
if (array_key_exists('version', $list)) { | ||
$version = $list['version']; | ||
} | ||
?> | ||
<div class="version-notice"> | ||
<p> | ||
<b><label><?= $label. ":"; ?></label></b> | ||
<strong style="color: #ef672f; line-height:34px;"><?= $version ?><?= (isset($edition)) ? ' '. $edition : '' ?></strong> | ||
</p> | ||
</div> | ||
<?php | ||
endforeach; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.