Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 0a81148

Browse files
committed
MAGETWO-80201: [2.2.x] - Resolve fatal error in repository generator #10601
1 parent 7ca7002 commit 0a81148

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

app/code/Magento/Bundle/Model/OptionRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public function save(
208208
}
209209
} else {
210210
if (!$existingOption->getOptionId()) {
211-
throw new NoSuchEntityException('Requested option doesn\'t exist');
211+
throw new NoSuchEntityException(__('Requested option doesn\'t exist'));
212212
}
213213

214214
$option->setData(array_merge($existingOption->getData(), $option->getData()));

lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,15 @@ protected function _getGetMethod()
226226
/** @var ParameterReflection $parameterReflection */
227227
$parameterReflection = $methodReflection->getParameters()[0];
228228
$body = "if (!\$id) {\n"
229-
. " throw new \\" . InputException::class . "('ID required');\n"
229+
. " throw new \\" . InputException::class . "(new \\Magento\\Framework\\Phrase('ID required'));\n"
230230
. "}\n"
231231
. "if (!isset(\$this->registry[\$id])) {\n"
232232
. " \$entity = \$this->" . $this->_getSourcePersistorPropertyName()
233233
. "->loadEntity(\$id);\n"
234234
. " if (!\$entity->getId()) {\n"
235-
. " throw new \\" . NoSuchEntityException::class . "('Requested entity doesn\\'t exist');\n"
235+
. " throw new \\" . NoSuchEntityException::class . "(\n"
236+
. " new \\Magento\\Framework\\Phrase('Requested entity doesn\\'t exist')\n"
237+
. " );\n"
236238
. " }\n"
237239
. " \$this->registry[\$id] = \$entity;\n"
238240
. "}\n"

lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/_files/SampleRepository.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ class SampleRepository implements SampleRepositoryInterface
7171
public function get($id)
7272
{
7373
if (!$id) {
74-
throw new \Magento\Framework\Exception\InputException('ID required');
74+
throw new \Magento\Framework\Exception\InputException(new \Magento\Framework\Phrase('ID required'));
7575
}
7676
if (!isset($this->registry[$id])) {
7777
$entity = $this->sampleInterfacePersistor->loadEntity($id);
7878
if (!$entity->getId()) {
79-
throw new \Magento\Framework\Exception\NoSuchEntityException('Requested entity doesn\'t exist');
79+
throw new \Magento\Framework\Exception\NoSuchEntityException(
80+
new \Magento\Framework\Phrase('Requested entity doesn\'t exist')
81+
);
8082
}
8183
$this->registry[$id] = $entity;
8284
}

lib/internal/Magento/Framework/ObjectManager/Test/Unit/Code/Generator/_files/TSampleRepository.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ class TSampleRepository implements TSampleRepositoryInterface
7171
public function get(int $id) : \Magento\Framework\ObjectManager\Code\Generator\TSampleInterface
7272
{
7373
if (!$id) {
74-
throw new \Magento\Framework\Exception\InputException('ID required');
74+
throw new \Magento\Framework\Exception\InputException(new \Magento\Framework\Phrase('ID required'));
7575
}
7676
if (!isset($this->registry[$id])) {
7777
$entity = $this->tSampleInterfacePersistor->loadEntity($id);
7878
if (!$entity->getId()) {
79-
throw new \Magento\Framework\Exception\NoSuchEntityException('Requested entity doesn\'t exist');
79+
throw new \Magento\Framework\Exception\NoSuchEntityException(
80+
new \Magento\Framework\Phrase('Requested entity doesn\'t exist')
81+
);
8082
}
8183
$this->registry[$id] = $entity;
8284
}

0 commit comments

Comments
 (0)