|
| 1 | +<?php declare(strict_types=1); |
| 2 | +namespace PackageFactory\AtomicFusion\PresentationObjects\Command; |
| 3 | + |
| 4 | +/* |
| 5 | + * This file is part of the PackageFactory.AtomicFusion.PresentationObjects package |
| 6 | + */ |
| 7 | + |
| 8 | +use Neos\Flow\Annotations as Flow; |
| 9 | +use Neos\Flow\Cli\CommandController; |
| 10 | +use PackageFactory\AtomicFusion\PresentationObjects\Domain\Component\ComponentGenerator; |
| 11 | +use PackageFactory\AtomicFusion\PresentationObjects\Domain\Value\ValueGenerator; |
| 12 | + |
| 13 | +/** |
| 14 | + * The command controller for kickstarting PresentationObject components |
| 15 | + */ |
| 16 | +class ComponentCommandController extends CommandController |
| 17 | +{ |
| 18 | + /** |
| 19 | + * @Flow\Inject |
| 20 | + * @var ComponentGenerator |
| 21 | + */ |
| 22 | + protected $componentGenerator; |
| 23 | + |
| 24 | + /** |
| 25 | + * @Flow\Inject |
| 26 | + * @var ValueGenerator |
| 27 | + */ |
| 28 | + protected $valueGenerator; |
| 29 | + |
| 30 | + /** |
| 31 | + * Create a new PresentationObject component and factory |
| 32 | + * |
| 33 | + * This command will create an <b>interface</b>, a <b>value object</b> and a |
| 34 | + * <b>factory</b> under in the chosen component namespace. It'll also register |
| 35 | + * the factory for later use in Fusion. |
| 36 | + * |
| 37 | + * The remaining arguments of this command are interpreted as a list of |
| 38 | + * <b>property descriptors</b> which consist of a property name and a type name |
| 39 | + * separated by a colon (e.g.: "title:string"). |
| 40 | + * |
| 41 | + * The following values are allowed for types: |
| 42 | + * |
| 43 | + * * string, int, float, bool |
| 44 | + * * Value class names created with <u>component:kickstartvalue</u> in the same |
| 45 | + * component namespace |
| 46 | + * * Component class names created with <u>component:kickstart</u> in the same |
| 47 | + * package |
| 48 | + * * ImageSource |
| 49 | + * * Uri |
| 50 | + * |
| 51 | + * @param string $name The name of the new component |
| 52 | + * @param null|string $packageKey Package key of an optional target package, if not set the configured default package or the first available site package will be used |
| 53 | + * @return void |
| 54 | + */ |
| 55 | + public function kickStartCommand(string $name, ?string $packageKey = null): void |
| 56 | + { |
| 57 | + $this->componentGenerator->generateComponent($name, $this->request->getExceedingArguments(), $packageKey); |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Create a new pseudo-enum value object |
| 62 | + * |
| 63 | + * This command will create a <b>value object</b> for a pseudo-enum under in the |
| 64 | + * chosen component namespace and under the provided name. It'll also create a |
| 65 | + * co-located <b>exception</b> class that will be used when validation for the |
| 66 | + * pseudo-enum fails. |
| 67 | + * |
| 68 | + * Additionally, a <b>datasource</b> for use in SelectBoxEditors will be created |
| 69 | + * in the Application namespace of your chosen package. |
| 70 | + * |
| 71 | + * @param string $componentName The name of the component the new pseudo-enum belongs to |
| 72 | + * @param string $name The name of the new pseudo-enum |
| 73 | + * @param string $type The type of the new pseudo-enum (must be one of: "string", "int") |
| 74 | + * @param array|string[] $values A comma-separated list of values for the new pseudo-enum |
| 75 | + * @param null|string $packageKey Package key of an optional target package, if not set the configured default package or the first available site package will be used |
| 76 | + * @return void |
| 77 | + */ |
| 78 | + public function kickStartValueCommand(string $componentName, string $name, string $type, array $values = [], ?string $packageKey = null): void |
| 79 | + { |
| 80 | + $this->valueGenerator->generateValue($componentName, $name, $type, $values, $packageKey); |
| 81 | + } |
| 82 | +} |
0 commit comments