Skip to content

Commit ab3be84

Browse files
author
Akimov, Alexander(aakimov)
committed
Merge pull request #371 from magento-folks/temporary_updates
[Folks] Sprint 81
2 parents afd8827 + e77eeed commit ab3be84

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

app/code/Magento/CatalogRule/Model/CatalogRuleRepository.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\Exception\NoSuchEntityException;
1010
use Magento\Framework\Exception\CouldNotDeleteException;
1111
use Magento\Framework\Exception\CouldNotSaveException;
12+
use \Magento\Framework\Exception\ValidatorException;
1213

1314
class CatalogRuleRepository implements \Magento\CatalogRule\Api\CatalogRuleRepositoryInterface
1415
{
@@ -51,7 +52,10 @@ public function save(Data\RuleInterface $rule)
5152
try {
5253
$this->ruleResource->save($rule);
5354
unset($this->rules[$rule->getId()]);
54-
} catch (\Exception $e) {
55+
} catch (ValidatorException $e) {
56+
throw new CouldNotSaveException(__($e->getMessage()));
57+
}
58+
catch (\Exception $e) {
5559
throw new CouldNotSaveException(__('Unable to save rule %1', $rule->getRuleId()));
5660
}
5761
return $rule;
@@ -63,7 +67,7 @@ public function save(Data\RuleInterface $rule)
6367
public function get($ruleId)
6468
{
6569
if (!isset($this->rules[$ruleId])) {
66-
/** @var \Magento\CatalogRule\Model\RuleFactory $rule */
70+
/** @var \Magento\CatalogRule\Model\Rule $rule */
6771
$rule = $this->ruleFactory->create();
6872

6973
/* TODO: change to resource model after entity manager will be fixed */
@@ -84,6 +88,8 @@ public function delete(Data\RuleInterface $rule)
8488
try {
8589
$this->ruleResource->delete($rule);
8690
unset($this->rules[$rule->getId()]);
91+
} catch (ValidatorException $e) {
92+
throw new CouldNotSaveException(__($e->getMessage()));
8793
} catch (\Exception $e) {
8894
throw new CouldNotDeleteException(__('Unable to remove rule %1', $rule->getRuleId()));
8995
}

app/code/Magento/CatalogRule/Model/ResourceModel/Rule.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,28 +287,31 @@ public function save(\Magento\Framework\Model\AbstractModel $object)
287287
}
288288

289289
/**
290-
* Delete the object
291-
*
292-
* @param \Magento\Framework\Model\AbstractModel $object
290+
* @param AbstractModel $object
293291
* @return $this
294292
* @throws \Exception
295293
*/
296-
public function delete(AbstractModel $object)
294+
public function delete(\Magento\Framework\Model\AbstractModel $object)
297295
{
296+
//TODO: add object relation processor support (MAGETWO-49297)
298297
$this->transactionManager->start($this->getConnection());
299298
try {
300299
$object->beforeDelete();
301300
$this->_beforeDelete($object);
302-
$this->entityManager->delete('Magento\CatalogRule\Api\Data\RuleInterface', $object);
301+
$this->entityManager->delete(
302+
'Magento\CatalogRule\Api\Data\RuleInterface',
303+
$object
304+
);
303305
$this->_afterDelete($object);
304306
$object->isDeleted(true);
305307
$object->afterDelete();
306308
$this->transactionManager->commit();
307309
$object->afterDeleteCommit();
308-
} catch (\Exception $exception) {
310+
} catch (\Exception $e) {
309311
$this->transactionManager->rollBack();
310-
throw $exception;
312+
throw $e;
311313
}
314+
312315
return $this;
313316
}
314317
}

lib/internal/Magento/Framework/App/etc/routes.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
</xs:documentation>
137137
</xs:annotation>
138138
<xs:restriction base="xs:string">
139-
<xs:pattern value="[A-Za-z0-9_\-]{3,}" />
139+
<xs:pattern value="[A-Za-z0-9_\-]{1,}" />
140140
</xs:restriction>
141141
</xs:simpleType>
142142
</xs:schema>

lib/internal/Magento/Framework/App/etc/routes_merged.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
</xs:documentation>
137137
</xs:annotation>
138138
<xs:restriction base="xs:string">
139-
<xs:pattern value="[A-Za-z0-9_\-]{3,}" />
139+
<xs:pattern value="[A-Za-z0-9_\-]{1,}" />
140140
</xs:restriction>
141141
</xs:simpleType>
142142
</xs:schema>

0 commit comments

Comments
 (0)