translitFilter = $translitFilter; } /** * Resource initialization * * @return void * @codeCoverageIgnore */ protected function _construct() { $this->_init(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Group::class); } /** * Checks if current attribute group exists * * @return bool * @codeCoverageIgnore */ public function itemExists() { return $this->_getResource()->itemExists($this); } /** * Delete groups * * @return $this * @codeCoverageIgnore */ public function deleteGroups() { return $this->_getResource()->deleteGroups($this); } /** * Processing object before save data * * @return $this */ public function beforeSave() { if (!$this->getAttributeGroupCode()) { $groupName = $this->getAttributeGroupName(); if ($groupName) { $attributeGroupCode = trim( preg_replace( '/[^a-z0-9]+/', '-', $this->translitFilter->filter(strtolower($groupName)) ), '-' ); if (empty($attributeGroupCode)) { // in the following code md5 is not used for security purposes $attributeGroupCode = md5($groupName); } $this->setAttributeGroupCode($attributeGroupCode); } } return parent::beforeSave(); } /** * {@inheritdoc} * @codeCoverageIgnoreStart */ public function getAttributeGroupId() { return $this->getData(self::GROUP_ID); } /** * {@inheritdoc} */ public function getAttributeGroupName() { return $this->getData(self::GROUP_NAME); } /** * {@inheritdoc} */ public function getAttributeSetId() { return $this->getData(self::ATTRIBUTE_SET_ID); } /** * {@inheritdoc} */ public function setAttributeGroupId($attributeGroupId) { return $this->setData(self::GROUP_ID, $attributeGroupId); } /** * {@inheritdoc} */ public function setAttributeGroupName($attributeGroupName) { return $this->setData(self::GROUP_NAME, $attributeGroupName); } /** * {@inheritdoc} */ public function setAttributeSetId($attributeSetId) { return $this->setData(self::ATTRIBUTE_SET_ID, $attributeSetId); } /** * {@inheritdoc} * * @return \Magento\Eav\Api\Data\AttributeGroupExtensionInterface|null */ public function getExtensionAttributes() { return $this->_getExtensionAttributes(); } /** * {@inheritdoc} * * @param \Magento\Eav\Api\Data\AttributeGroupExtensionInterface $extensionAttributes * @return $this */ public function setExtensionAttributes( \Magento\Eav\Api\Data\AttributeGroupExtensionInterface $extensionAttributes ) { return $this->_setExtensionAttributes($extensionAttributes); } //@codeCoverageIgnoreEnd }