/**
  * {@inheritdoc}
  */
 public function save(\Magento\Eav\Api\Data\AttributeInterface $attribute)
 {
     try {
         $this->eavResource->save($attribute);
     } catch (\Exception $e) {
         throw new StateException(__('Cannot save attribute'));
     }
     return $attribute;
 }
 /**
  * {@inheritdoc}
  */
 public function delete($entityType, $attributeCode, $optionId)
 {
     if (empty($attributeCode)) {
         throw new InputException(__('Empty attribute code'));
     }
     $attribute = $this->attributeRepository->get($entityType, $attributeCode);
     if (!$attribute->usesSource()) {
         throw new StateException(__('Attribute %1 doesn\'t have any option', $attributeCode));
     }
     if (!$attribute->getSource()->getOptionText($optionId)) {
         throw new NoSuchEntityException(__('Attribute %1 does not contain option with Id %2', $attribute->getId(), $optionId));
     }
     $removalMarker = ['option' => ['value' => [$optionId => []], 'delete' => [$optionId => '1']]];
     $attribute->addData($removalMarker);
     try {
         $this->resourceModel->save($attribute);
     } catch (\Exception $e) {
         throw new StateException(__('Cannot save attribute %1', $attributeCode));
     }
     return true;
 }