-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ghost dependency with Smile_RetailerOffer #18
- Loading branch information
Fanny DECLERCK
committed
Jul 15, 2019
1 parent
db7f169
commit 7e48fb7
Showing
2 changed files
with
116 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\Retailer | ||
* @author Fanny DECLERCK <[email protected]> | ||
* @copyright 2019 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
namespace Smile\Retailer\Ui\Component\Form\Retailer; | ||
|
||
use Magento\Framework\Data\OptionSourceInterface; | ||
use Magento\Framework\App\RequestInterface; | ||
use Smile\Retailer\Model\ResourceModel\Retailer\CollectionFactory; | ||
|
||
/** | ||
* Source Model for Retailer Picker | ||
* | ||
* @category Smile | ||
* @package Smile\Retailer | ||
* @author Fanny DECLERCK <[email protected]> | ||
*/ | ||
class Options implements OptionSourceInterface | ||
{ | ||
/** | ||
* @var \Smile\Retailer\Model\ResourceModel\Retailer\CollectionFactory | ||
*/ | ||
protected $retailerCollectionFactory; | ||
|
||
/** | ||
* @var RequestInterface | ||
*/ | ||
protected $request; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $retailersList; | ||
|
||
/** | ||
* @param CollectionFactory $retailerCollectionFactory The Retailer Collection Factory | ||
* @param RequestInterface $request The application request | ||
*/ | ||
public function __construct( | ||
CollectionFactory $retailerCollectionFactory, | ||
RequestInterface $request | ||
) { | ||
$this->retailerCollectionFactory = $retailerCollectionFactory; | ||
$this->request = $request; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function toOptionArray() | ||
{ | ||
return $this->getRetailerList(); | ||
} | ||
|
||
/** | ||
* Retrieve retailer tree | ||
* | ||
* @return array | ||
*/ | ||
protected function getRetailerList() | ||
{ | ||
if ($this->retailersList === null) { | ||
$this->retailersList = []; | ||
$storeId = $this->request->getParam('store'); | ||
|
||
/* @var $collection \Smile\Seller\Model\ResourceModel\Seller\Collection */ | ||
$collection = $this->retailerCollectionFactory->create(); | ||
|
||
$collection | ||
->addAttributeToSelect(['name', 'is_active']) | ||
->setStoreId($storeId); | ||
|
||
foreach ($collection as $retailer) { | ||
$this->retailersList[$retailer->getId()] = [ | ||
'value' => $retailer->getId(), | ||
'is_active' => $retailer->getIsActive(), | ||
'label' => $retailer->getName(), | ||
]; | ||
} | ||
} | ||
|
||
return $this->retailersList; | ||
} | ||
} |
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,24 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Smile_Retailer Adminhtml dependency injection configuration. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\Retailer | ||
* @author Fanny DECLERCK <[email protected]> | ||
* @copyright 2019 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<type name="Smile\Retailer\Ui\Component\Form\Retailer\Options"> | ||
<arguments> | ||
<argument name="retailerCollectionFactory" xsi:type="object">Smile\Retailer\Model\ResourceModel\Retailer\CollectionFactory</argument> | ||
</arguments> | ||
</type> | ||
</config> |