12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Customer\Model\Customer\Attribute\Backend;
- /**
- * Website attribute backend
- *
- * @author Magento Core Team <core@magentocommerce.com>
- */
- class Website extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
- {
- /**
- * @var \Magento\Store\Model\StoreManagerInterface
- */
- protected $_storeManager;
- /**
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
- */
- public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager)
- {
- $this->_storeManager = $storeManager;
- }
- /**
- * Before save
- *
- * @param \Magento\Framework\DataObject $object
- * @return $this
- */
- public function beforeSave($object)
- {
- if ($object->getId()) {
- return $this;
- }
- if (!$object->hasData('website_id')) {
- $object->setData('website_id', $this->_storeManager->getStore()->getWebsiteId());
- }
- return $this;
- }
- }
|