Skip to content

Commit

Permalink
Merge pull request magento#4132 from magento-trigger/MAGETWO-99324-tr…
Browse files Browse the repository at this point in the history
…igger

- reverting backward incompatible changes
  • Loading branch information
irenelagno authored Apr 29, 2019
2 parents 4992141 + 715eca8 commit 1e230b1
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
namespace Magento\Catalog\Model\ResourceModel;

use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
use Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface;

/**
* Catalog entity abstract model
Expand Down Expand Up @@ -43,18 +39,16 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Factory $modelFactory
* @param array $data
* @param UniqueValidationInterface|null $uniqueValidator
*/
public function __construct(
\Magento\Eav\Model\Entity\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Factory $modelFactory,
$data = [],
UniqueValidationInterface $uniqueValidator = null
$data = []
) {
$this->_storeManager = $storeManager;
$this->_modelFactory = $modelFactory;
parent::__construct($context, $data, $uniqueValidator);
parent::__construct($context, $data);
}

/**
Expand Down Expand Up @@ -94,7 +88,7 @@ protected function _isApplicableAttribute($object, $attribute)
/**
* Check whether attribute instance (attribute, backend, frontend or source) has method and applicable
*
* @param AbstractAttribute|AbstractBackend|AbstractFrontend|AbstractSource $instance
* @param AbstractAttribute|\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend|\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend|\Magento\Eav\Model\Entity\Attribute\Source\AbstractSource $instance
* @param string $method
* @param array $args array of arguments
* @return boolean
Expand Down
15 changes: 5 additions & 10 deletions app/code/Magento/Catalog/Model/ResourceModel/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Magento\Catalog\Model\ResourceModel\Product\Website\Link as ProductWebsiteLink;
use Magento\Framework\App\ObjectManager;
use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer;
use Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface;

/**
* Product entity resource model
Expand Down Expand Up @@ -102,7 +101,6 @@ class Product extends AbstractResource
* @param \Magento\Catalog\Model\Product\Attribute\DefaultAttributes $defaultAttributes
* @param array $data
* @param TableMaintainer|null $tableMaintainer
* @param UniqueValidationInterface|null $uniqueValidator
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
Expand All @@ -117,8 +115,7 @@ public function __construct(
\Magento\Eav\Model\Entity\TypeFactory $typeFactory,
\Magento\Catalog\Model\Product\Attribute\DefaultAttributes $defaultAttributes,
$data = [],
TableMaintainer $tableMaintainer = null,
UniqueValidationInterface $uniqueValidator = null
TableMaintainer $tableMaintainer = null
) {
$this->_categoryCollectionFactory = $categoryCollectionFactory;
$this->_catalogCategory = $catalogCategory;
Expand All @@ -130,8 +127,7 @@ public function __construct(
$context,
$storeManager,
$modelFactory,
$data,
$uniqueValidator
$data
);
$this->connectionName = 'catalog';
$this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()->get(TableMaintainer::class);
Expand Down Expand Up @@ -661,7 +657,7 @@ public function save(\Magento\Framework\Model\AbstractModel $object)
}

/**
* Retrieve entity manager object.
* Retrieve entity manager object
*
* @return \Magento\Framework\EntityManager\EntityManager
*/
Expand All @@ -675,7 +671,7 @@ private function getEntityManager()
}

/**
* Retrieve ProductWebsiteLink object.
* Retrieve ProductWebsiteLink object
*
* @deprecated 101.1.0
* @return ProductWebsiteLink
Expand All @@ -686,7 +682,7 @@ private function getProductWebsiteLink()
}

/**
* Retrieve CategoryLink object.
* Retrieve CategoryLink object
*
* @deprecated 101.1.0
* @return \Magento\Catalog\Model\ResourceModel\Product\CategoryLink
Expand All @@ -702,7 +698,6 @@ private function getProductCategoryLink()

/**
* Extends parent method to be appropriate for product.
*
* Store id is required to correctly identify attribute value we are working with.
*
* @inheritdoc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

<!--Go to Product edit page-->
<amOnPage url="{{AdminProductEditPage.url($$createSimpleProduct.id$$)}}" stepKey="goToProductEditPage"/>
<waitForPageLoad stepKey="waitForPageLoad"/>
<!--Click on attribute dropdown-->
<click selector="{{AdminProductFormSection.customAttributeDropdownField($$createDropdownProductAttribute.attribute[attribute_code]$$)}}" stepKey="clickOnAttributeDropdown"/>
<!--Check attribute dropdown options-->
Expand Down
26 changes: 8 additions & 18 deletions app/code/Magento/Eav/Model/Entity/AbstractEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
use Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface;
use Magento\Framework\App\Config\Element;
use Magento\Framework\DataObject;
use Magento\Framework\DB\Adapter\DuplicateException;
Expand Down Expand Up @@ -218,21 +217,12 @@ abstract class AbstractEntity extends AbstractResource implements EntityInterfac
*/
protected $objectRelationProcessor;

/**
* @var UniqueValidationInterface
*/
private $uniqueValidator;

/**
* @param Context $context
* @param array $data
* @param UniqueValidationInterface|null $uniqueValidator
*/
public function __construct(
Context $context,
$data = [],
UniqueValidationInterface $uniqueValidator = null
) {
public function __construct(Context $context, $data = [])
{
$this->_eavConfig = $context->getEavConfig();
$this->_resource = $context->getResource();
$this->_attrSetEntity = $context->getAttributeSetEntity();
Expand All @@ -241,8 +231,6 @@ public function __construct(
$this->_universalFactory = $context->getUniversalFactory();
$this->transactionManager = $context->getTransactionManager();
$this->objectRelationProcessor = $context->getObjectRelationProcessor();
$this->uniqueValidator = $uniqueValidator ?:
ObjectManager::getInstance()->get(UniqueValidationInterface::class);
parent::__construct();
$properties = get_object_vars($this);
foreach ($data as $key => $value) {
Expand Down Expand Up @@ -511,7 +499,6 @@ public function addAttributeByScope(AbstractAttribute $attribute, $entity = null
/**
* Get attributes by scope
*
* @param string $suffix
* @return array
*/
private function getAttributesByScope($suffix)
Expand Down Expand Up @@ -982,8 +969,12 @@ public function checkAttributeUniqueValue(AbstractAttribute $attribute, $object)

$data = $connection->fetchCol($select, $bind);

if ($object->getData($entityIdField)) {
return $this->uniqueValidator->validate($attribute, $object, $this, $entityIdField, $data);
$objectId = $object->getData($entityIdField);
if ($objectId) {
if (isset($data[0])) {
return $data[0] == $objectId;
}
return true;
}

return !count($data);
Expand Down Expand Up @@ -1995,7 +1986,6 @@ public function afterDelete(DataObject $object)

/**
* Load attributes for object
*
* If the object will not pass all attributes for this entity type will be loaded
*
* @param array $attributes
Expand Down

This file was deleted.

34 changes: 0 additions & 34 deletions app/code/Magento/Eav/Model/Entity/Attribute/UniqueValidator.php

This file was deleted.

1 change: 0 additions & 1 deletion app/code/Magento/Eav/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Eav\Model\Entity\Setup\PropertyMapperInterface" type="Magento\Eav\Model\Entity\Setup\PropertyMapper\Composite" />
<preference for="Magento\Eav\Model\Entity\AttributeLoaderInterface" type="Magento\Eav\Model\Entity\AttributeLoader" />
<preference for="Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface" type="Magento\Eav\Model\Entity\Attribute\UniqueValidator" />
<preference for="Magento\Eav\Api\Data\AttributeInterface" type="Magento\Eav\Model\Entity\Attribute" />
<preference for="Magento\Eav\Api\AttributeRepositoryInterface" type="Magento\Eav\Model\AttributeRepository" />
<preference for="Magento\Eav\Api\Data\AttributeGroupInterface" type="Magento\Eav\Model\Entity\Attribute\Group" />
Expand Down

0 comments on commit 1e230b1

Please sign in to comment.