Added missing modules, including some as submodules.
[yaffs-website] / web / modules / contrib / inline_entity_form / src / Form / NodeInlineForm.php
1 <?php
2
3 namespace Drupal\inline_entity_form\Form;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\Core\StringTranslation\StringTranslationTrait;
7
8 /**
9  * Node inline form handler.
10  */
11 class NodeInlineForm extends EntityInlineForm {
12
13   use StringTranslationTrait;
14
15   /**
16    * {@inheritdoc}
17    */
18   public function getEntityTypeLabels() {
19     $labels = [
20       'singular' => $this->t('node'),
21       'plural' => $this->t('nodes'),
22     ];
23     return $labels;
24   }
25
26   /**
27    * {@inheritdoc}
28    */
29   public function getTableFields($bundles) {
30     $fields = parent::getTableFields($bundles);
31
32     $fields['status'] = [
33       'type' => 'field',
34       'label' => $this->t('Status'),
35       'weight' => 100,
36       'display_options' => [
37         'settings' => [
38           'format' => 'custom',
39           'format_custom_false' => $this->t('Unpublished'),
40           'format_custom_true' => $this->t('Published'),
41         ],
42       ],
43     ];
44
45     return $fields;
46   }
47
48   /**
49    * {@inheritdoc}
50    */
51   public function entityForm(array $entity_form, FormStateInterface $form_state) {
52     $entity_form = parent::entityForm($entity_form, $form_state);
53     // Remove the "Revision log" textarea,  it can't be disabled in the
54     // form display and doesn't make sense in the inline form context.
55     $entity_form['revision_log']['#access'] = FALSE;
56
57     return $entity_form;
58   }
59
60 }