File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
modules/apigee_edge_teams/src/Entity Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,18 @@ public function form(array $form, FormStateInterface $form_state) {
199199 '#default_value ' => $ team ->id (),
200200 ];
201201
202+ // The parent form adds an 'email' field. We modify it here.
203+ if (isset ($ form ['email ' ])) {
204+ $ form ['email ' ]['widget ' ][0 ]['value ' ]['#title ' ] = $ this ->t ('Team Administrator Email ' );
205+ $ form ['email ' ]['widget ' ][0 ]['value ' ]['#description ' ] = $ this ->t ('The email address of the team administrator. ' );
206+ $ form ['email ' ]['widget ' ][0 ]['value ' ]['#required ' ] = TRUE ;
207+
208+ // For non-Apigee X, the email is stored as an attribute.
209+ if (!$ this ->orgController ->isOrganizationApigeeX ()) {
210+ $ default_email = !$ team ->isNew () ? $ team ->getAttribute (static ::ADMIN_EMAIL_ATTRIBUTE ) : $ this ->currentUser ->getEmail ();
211+ $ form ['email ' ]['widget ' ][0 ]['value ' ]['#default_value ' ] = $ default_email ;
212+ }
213+ }
202214 return $ form ;
203215 }
204216
Original file line number Diff line number Diff line change @@ -307,6 +307,22 @@ public function setChannelId(string $channelId): void {
307307 $ this ->decorated ->setChannelId ($ channelId );
308308 }
309309
310+ /**
311+ * {@inheritdoc}
312+ */
313+ public function getEmail (): ?string
314+ {
315+ return $ this ->decorated ->getEmail ();
316+ }
317+
318+ /**
319+ * {@inheritdoc}
320+ */
321+ public function setEmail (string $ email ): void
322+ {
323+ $ this ->decorated ->setEmail ($ email );
324+ }
325+
310326 /**
311327 * {@inheritdoc}
312328 */
@@ -330,6 +346,19 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
330346 ->setLabel (t ("@team name " , ['@team ' => $ team_singular_label ]))
331347 ->setRequired (TRUE );
332348
349+ if (self ::isApigeeX ()) {
350+ $ definitions ['email ' ]
351+ ->setDisplayOptions ('view ' , [
352+ 'label ' => 'inline ' ,
353+ 'weight ' => 1 ,
354+ ])
355+ ->setDisplayOptions ('form ' , [
356+ 'weight ' => 1 ,
357+ ])
358+ ->setLabel (t ("Email " ))
359+ ->setRequired (FALSE );
360+ }
361+
333362 $ definitions ['status ' ]
334363 ->setDisplayOptions ('view ' , [
335364 'label ' => 'inline ' ,
You can’t perform that action at this time.
0 commit comments