1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- /**
- * Customer region attribute source
- *
- * @author Magento Core Team <core@magentocommerce.com>
- */
- namespace Magento\Customer\Model\ResourceModel\Address\Attribute\Source;
- class Region extends \Magento\Eav\Model\Entity\Attribute\Source\Table
- {
- /**
- * @var \Magento\Directory\Model\ResourceModel\Region\CollectionFactory
- */
- protected $_regionsFactory;
- /**
- * @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory
- * @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory $attrOptionFactory
- * @param \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionsFactory
- */
- public function __construct(
- \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory,
- \Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory $attrOptionFactory,
- \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionsFactory
- ) {
- $this->_regionsFactory = $regionsFactory;
- parent::__construct($attrOptionCollectionFactory, $attrOptionFactory);
- }
- /**
- * @inheritdoc
- */
- public function getAllOptions($withEmpty = true, $defaultValues = false)
- {
- if (!$this->_options) {
- $this->_options = $this->_createRegionsCollection()->load()->toOptionArray();
- }
- return $this->_options;
- }
- /**
- * @return \Magento\Directory\Model\ResourceModel\Region\Collection
- */
- protected function _createRegionsCollection()
- {
- return $this->_regionsFactory->create();
- }
- }
|