|
5 | 5 | namespace PHPModelGenerator\PropertyProcessor\Decorator\Property;
|
6 | 6 |
|
7 | 7 | use PHPMicroTemplate\Render;
|
| 8 | +use PHPModelGenerator\Exception\Object\NestedObjectException; |
8 | 9 | use PHPModelGenerator\Model\GeneratorConfiguration;
|
9 | 10 | use PHPModelGenerator\Model\Property\PropertyInterface;
|
| 11 | +use PHPModelGenerator\Model\Validator\PropertyValidator; |
| 12 | +use PHPModelGenerator\Utils\RenderHelper; |
10 | 13 |
|
11 | 14 | /**
|
12 | 15 | * Class ObjectInstantiationDecorator
|
@@ -43,17 +46,21 @@ public function __construct(string $className, GeneratorConfiguration $generator
|
43 | 46 | /**
|
44 | 47 | * @inheritdoc
|
45 | 48 | */
|
46 |
| - public function decorate(string $input, PropertyInterface $property): string |
| 49 | + public function decorate(string $input, PropertyInterface $property, bool $nestedProperty): string |
47 | 50 | {
|
48 |
| - $template = $this->generatorConfiguration->collectErrors() |
49 |
| - ? 'ObjectInstantiationDecoratorErrorRegistry.phptpl' |
50 |
| - : 'ObjectInstantiationDecoratorDirectException.phptpl'; |
51 |
| - |
52 | 51 | return static::$renderer->renderTemplate(
|
53 |
| - DIRECTORY_SEPARATOR . 'Decorator' . DIRECTORY_SEPARATOR . $template, |
| 52 | + DIRECTORY_SEPARATOR . 'Decorator' . DIRECTORY_SEPARATOR . 'ObjectInstantiationDecorator.phptpl', |
54 | 53 | [
|
55 | 54 | 'input' => $input,
|
56 | 55 | 'className' => $this->className,
|
| 56 | + 'nestedProperty' => $nestedProperty, |
| 57 | + 'viewHelper' => new RenderHelper($this->generatorConfiguration), |
| 58 | + 'generatorConfiguration' => $this->generatorConfiguration, |
| 59 | + 'nestedValidator' => new PropertyValidator( |
| 60 | + '', |
| 61 | + NestedObjectException::class, |
| 62 | + [$property->getName(), '&$instantiationException'] |
| 63 | + ), |
57 | 64 | ]
|
58 | 65 | );
|
59 | 66 | }
|
|
0 commit comments