init
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\ImageManager\Model\Source;
|
||||
|
||||
use Esun\ImageManager\Model\ResourceModel\Category\CollectionFactory;
|
||||
use Magento\Framework\Data\OptionSourceInterface;
|
||||
|
||||
class CategoryOptions implements OptionSourceInterface
|
||||
{
|
||||
public function __construct(private readonly CollectionFactory $collectionFactory)
|
||||
{
|
||||
}
|
||||
|
||||
public function toOptionArray(): array
|
||||
{
|
||||
$options = [];
|
||||
$collection = $this->collectionFactory->create()
|
||||
->setOrder('sort_order', 'ASC')
|
||||
->setOrder('name', 'ASC');
|
||||
foreach ($collection as $category) {
|
||||
$options[] = [
|
||||
'value' => (int) $category->getId(),
|
||||
'label' => (string) $category->getData('name'),
|
||||
];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\ImageManager\Model\Source;
|
||||
|
||||
use Magento\Framework\Data\OptionSourceInterface;
|
||||
|
||||
class StatusOptions implements OptionSourceInterface
|
||||
{
|
||||
public function toOptionArray(): array
|
||||
{
|
||||
return [
|
||||
['value' => 1, 'label' => __('Enabled')],
|
||||
['value' => 0, 'label' => __('Disabled')],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user