1 | <?php |
||
27 | trait EntityCreateMethods |
||
28 | { |
||
29 | |||
30 | /** |
||
31 | * Handle the add entity request |
||
32 | */ |
||
33 | public function add() |
||
67 | |||
68 | /** |
||
69 | * Get the create successful entity message |
||
70 | * |
||
71 | * @param EntityInterface $entity |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | protected function getCreateSuccessMessage(EntityInterface $entity) |
||
81 | |||
82 | /** |
||
83 | * Redirect after successful entity creation |
||
84 | * |
||
85 | * @param EntityInterface $entity |
||
86 | * |
||
87 | * @return $this|ControllerInterface|static |
||
88 | */ |
||
89 | protected function redirectFromCreated(EntityInterface $entity) |
||
95 | |||
96 | /** |
||
97 | * Get update service |
||
98 | * |
||
99 | * @return EntityUpdateService |
||
100 | */ |
||
101 | abstract public function getUpdateService(); |
||
102 | |||
103 | /** |
||
104 | * @return FormInterface|EntityForm |
||
105 | */ |
||
106 | abstract function getForm(); |
||
107 | |||
108 | /** |
||
109 | * Get invalid form data message |
||
110 | * |
||
111 | * @param \Exception $caught |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | abstract protected function getGeneralErrorMessage(\Exception $caught); |
||
116 | |||
117 | /** |
||
118 | * Get invalid form data message |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | abstract protected function getInvalidFormDataMessage(); |
||
123 | |||
124 | /** |
||
125 | * Sets a value to be used by render |
||
126 | * |
||
127 | * The key argument can be an associative array with values to be set |
||
128 | * or a string naming the passed value. If an array is given then the |
||
129 | * value will be ignored. |
||
130 | * |
||
131 | * Those values must be set in the request attributes so they can be used |
||
132 | * latter by any other middle ware in the stack. |
||
133 | * |
||
134 | * @param string|array $key |
||
135 | * @param mixed $value |
||
136 | * |
||
137 | * @return ControllerInterface |
||
138 | */ |
||
139 | abstract public function set($key, $value = null); |
||
140 | |||
141 | /** |
||
142 | * Redirects the flow to another route/path |
||
143 | * |
||
144 | * @param string $path the route or path to redirect to |
||
145 | * |
||
146 | * @return ControllerInterface|self|$this |
||
147 | */ |
||
148 | abstract public function redirect($path); |
||
149 | |||
150 | /** |
||
151 | * Add an error flash message |
||
152 | * |
||
153 | * @param string $message |
||
154 | * @return self |
||
155 | */ |
||
156 | abstract public function addErrorMessage($message); |
||
157 | |||
158 | /** |
||
159 | * Add a success flash message |
||
160 | * |
||
161 | * @param string $message |
||
162 | * @return self |
||
163 | */ |
||
164 | abstract public function addSuccessMessage($message); |
||
165 | |||
166 | /** |
||
167 | * Returns the translation for the provided message |
||
168 | * |
||
169 | * @param string $message |
||
170 | * @param string $domain |
||
171 | * @param string $locale |
||
172 | * |
||
173 | * @return string |
||
174 | */ |
||
175 | abstract public function translate( |
||
178 | |||
179 | /** |
||
180 | * Get entity singular name used on controller actions |
||
181 | * |
||
182 | * @return string |
||
183 | */ |
||
184 | abstract protected function getEntityNameSingular(); |
||
185 | } |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.