You are here

protected function PostForm::configureViewMode in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::configureViewMode()
  2. 8.2 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::configureViewMode()
  3. 8.3 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::configureViewMode()
  4. 8.4 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::configureViewMode()
  5. 8.5 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::configureViewMode()
  6. 8.6 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::configureViewMode()
  7. 8.7 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::configureViewMode()
  8. 8.8 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::configureViewMode()
  9. 10.3.x modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::configureViewMode()
  10. 10.0.x modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::configureViewMode()
  11. 10.1.x modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::configureViewMode()
  12. 10.2.x modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::configureViewMode()

Configures the view mode when an existing entity is being edited.

Uses the default view mode for community posts, the group view mode for posts placed in a group and the profile view mode for posts placed on someone's profile.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The form state used to render this form.

1 call to PostForm::configureViewMode()
PostForm::buildForm in modules/social_features/social_post/src/Form/PostForm.php
Form constructor.

File

modules/social_features/social_post/src/Form/PostForm.php, line 68

Class

PostForm
Form controller for Post edit forms.

Namespace

Drupal\social_post\Form

Code

protected function configureViewMode(FormStateInterface $form_state) {
  $view_mode = $this->postViewDefault;
  if ($this->entity
    ->hasField('field_recipient_user') && !$this->entity
    ->get('field_recipient_user')
    ->isEmpty()) {
    $view_mode = $this->postViewProfile;
  }
  elseif ($this->entity
    ->hasField('field_recipient_group') && !$this->entity
    ->get('field_recipient_group')
    ->isEmpty()) {
    $view_mode = $this->postViewGroup;
  }
  $display = EntityFormDisplay::load($view_mode);
  $this
    ->setFormDisplay($display, $form_state);
}