You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Documentation/05_Kickstarter.md
+28-93Lines changed: 28 additions & 93 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ For more information on this pattern, have a look at this excellent article: htt
28
28
./flow component:kickstartenum \
29
29
Vendor.Site:Headline \
30
30
HeadlineLook string \
31
-
--values=REGULAR,HERO
31
+
--values=regular,hero
32
32
```
33
33
34
34
> **Hint:** Components are namespaced, defaulting to "Component". The component name "Vendor.Site:Headline" thus will be evaluated as "Vendor.Site:Component.Headline".
@@ -40,10 +40,10 @@ For more information on this pattern, have a look at this excellent article: htt
40
40
41
41
This is the central pseudo-enum class. It consists of:
42
42
43
-
* A set of constants that represent the enum values
44
-
* Static factory methods that are named like the enum values
43
+
* A set of constants that represent the enum cases
44
+
* Static factory methods that are named like the enum cases
45
45
*`getIs*` methods to identify a value both in PHP and Neos.Eel
46
-
* A static `getValues` method to retrieve a list of all possible enum values
46
+
* A static `cases` method to retrieve a list of all possible enum cases
47
47
* A `getValue` method that will return the value of the enum instance as your chosen type
48
48
* A `__toString` method for string casting
49
49
@@ -62,8 +62,13 @@ use Neos\Flow\Annotations as Flow;
62
62
*/
63
63
final class HeadlineLook
64
64
{
65
-
const LOOK_REGULAR = 'REGULAR';
66
-
const LOOK_HERO = 'HERO';
65
+
const LOOK_REGULAR = 'regular';
66
+
const LOOK_HERO = 'hero';
67
+
68
+
/**
69
+
* @var array<string,self>|self[]
70
+
*/
71
+
private static array $instances = [];
67
72
68
73
private string $value;
69
74
@@ -72,23 +77,27 @@ final class HeadlineLook
72
77
$this->value = $value;
73
78
}
74
79
75
-
public static function fromString(string $string): self
The exception in this file will be thrown, when the pseudo-enum is initialized with an invalid value (which could happen, when `::fromString` is called).
138
+
The exception in this file will be thrown, when the pseudo-enum is initialized with an invalid value (which could happen, when `::from` is called).
130
139
131
140
```php
132
141
<?php
@@ -150,80 +159,6 @@ final class HeadlineLookIsInvalid extends \DomainException
150
159
}
151
160
```
152
161
153
-
#### HeadlineLookProvider.php
154
-
155
-
This file contains a data provider to use the enum values for SelectBoxes in the Neos backend UI.
156
-
157
-
```php
158
-
<?php
159
-
namespace Vendor\Site\Application;
160
-
161
-
/*
162
-
* This file is part of the Vendor.Site package.
163
-
*/
164
-
165
-
use Neos\ContentRepository\Domain\Model\NodeInterface;
166
-
use Neos\Flow\Annotations as Flow;
167
-
use Neos\Flow\I18n\Translator;
168
-
use Neos\Neos\Service\DataSource\AbstractDataSource;
169
-
use Neos\Eel\ProtectedContextAwareInterface;
170
-
use Vendor\Site\Presentation\Component\Headline\HeadlineLook;
171
-
172
-
class HeadlineLookProvider extends AbstractDataSource implements ProtectedContextAwareInterface
This command creates all patterns needed for a component. It takes the name of the component and a list of property descriptors which consist of a property name and a type name separated by a colon.
0 commit comments