Skip to content

Commit 24447b3

Browse files
committed
MAGETWO-71761: Resolve fatal error in repository generator #10601
1 parent 8ec8e92 commit 24447b3

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ protected function _getDefaultConstructorDefinition()
214214
/**
215215
* Returns get() method
216216
*
217-
* @return string
217+
* @return array
218218
*/
219219
protected function _getGetMethod()
220220
{
@@ -223,13 +223,15 @@ protected function _getGetMethod()
223223
/** @var ParameterReflection $parameterReflection */
224224
$parameterReflection = $methodReflection->getParameters()[0];
225225
$body = "if (!\$id) {\n"
226-
. " throw new \\" . InputException::class . "(__('ID required'));\n"
226+
. " throw new \\" . InputException::class . "(new \\Magento\\Framework\\Phrase('ID required'));\n"
227227
. "}\n"
228228
. "if (!isset(\$this->registry[\$id])) {\n"
229229
. " \$entity = \$this->" . $this->_getSourcePersistorPropertyName()
230230
. "->loadEntity(\$id);\n"
231231
. " if (!\$entity->getId()) {\n"
232-
. " throw new \\" . NoSuchEntityException::class . "(__('Requested entity doesn\\'t exist'));\n"
232+
. " throw new \\" . NoSuchEntityException::class . "(\n"
233+
. " new \\Magento\\Framework\\Phrase('Requested entity doesn\\'t exist')\n"
234+
. " );\n"
233235
. " }\n"
234236
. " \$this->registry[\$id] = \$entity;\n"
235237
. "}\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
@@ -67,12 +67,14 @@ class SampleRepository implements SampleRepositoryInterface
6767
public function get($id)
6868
{
6969
if (!$id) {
70-
throw new \Magento\Framework\Exception\InputException(__('ID required'));
70+
throw new \Magento\Framework\Exception\InputException(new \Magento\Framework\Phrase('ID required'));
7171
}
7272
if (!isset($this->registry[$id])) {
7373
$entity = $this->sampleInterfacePersistor->loadEntity($id);
7474
if (!$entity->getId()) {
75-
throw new \Magento\Framework\Exception\NoSuchEntityException(__('Requested entity doesn\'t exist'));
75+
throw new \Magento\Framework\Exception\NoSuchEntityException(
76+
new \Magento\Framework\Phrase('Requested entity doesn\'t exist')
77+
);
7678
}
7779
$this->registry[$id] = $entity;
7880
}

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
@@ -67,12 +67,14 @@ class TSampleRepository implements TSampleRepositoryInterface
6767
public function get(int $id) : \Magento\Framework\ObjectManager\Code\Generator\TSampleInterface
6868
{
6969
if (!$id) {
70-
throw new \Magento\Framework\Exception\InputException(__('ID required'));
70+
throw new \Magento\Framework\Exception\InputException(new \Magento\Framework\Phrase('ID required'));
7171
}
7272
if (!isset($this->registry[$id])) {
7373
$entity = $this->tSampleInterfacePersistor->loadEntity($id);
7474
if (!$entity->getId()) {
75-
throw new \Magento\Framework\Exception\NoSuchEntityException(__('Requested entity doesn\'t exist'));
75+
throw new \Magento\Framework\Exception\NoSuchEntityException(
76+
new \Magento\Framework\Phrase('Requested entity doesn\'t exist')
77+
);
7678
}
7779
$this->registry[$id] = $entity;
7880
}

0 commit comments

Comments
 (0)