|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * @file |
| 5 | + * Contains \Drupal\dropzonejs\Events\DropzoneMediaEntityCreateEvent. |
| 6 | + */ |
| 7 | + |
| 8 | +namespace Drupal\dropzonejs\Events; |
| 9 | + |
| 10 | +use Drupal\Core\Form\FormStateInterface; |
| 11 | +use Drupal\file\FileInterface; |
| 12 | +use Drupal\media_entity\MediaInterface; |
| 13 | +use Symfony\Component\EventDispatcher\Event; |
| 14 | + |
| 15 | +/** |
| 16 | + * Represents Media Entity creation as an event when using DropzoneJS. |
| 17 | + */ |
| 18 | +class DropzoneMediaEntityCreateEvent extends Event { |
| 19 | + |
| 20 | + /** |
| 21 | + * The media entity being created. |
| 22 | + * |
| 23 | + * @var \Drupal\media_entity\MediaInterface |
| 24 | + */ |
| 25 | + protected $mediaEntity; |
| 26 | + |
| 27 | + /** |
| 28 | + * The file that will be used for the media entity. |
| 29 | + * |
| 30 | + * @var \Drupal\file\FileInterface |
| 31 | + */ |
| 32 | + protected $file; |
| 33 | + |
| 34 | + /** |
| 35 | + * The form that contains the Dropzone element. |
| 36 | + * |
| 37 | + * @var array |
| 38 | + */ |
| 39 | + protected $form; |
| 40 | + |
| 41 | + /** |
| 42 | + * The form state. |
| 43 | + * |
| 44 | + * @var \Drupal\Core\Form\FormStateInterface |
| 45 | + */ |
| 46 | + protected $formState; |
| 47 | + |
| 48 | + /** |
| 49 | + * The Dropzone form element. |
| 50 | + * |
| 51 | + * @var array |
| 52 | + */ |
| 53 | + protected $element; |
| 54 | + |
| 55 | + /** |
| 56 | + * DropzoneMediaEntityCreateEvent constructor. |
| 57 | + * |
| 58 | + * @param \Drupal\media_entity\MediaInterface $media_entity |
| 59 | + * The media entity being created. |
| 60 | + * @param \Drupal\file\FileInterface $file |
| 61 | + * The file that will be used for the media entity. |
| 62 | + * @param $form |
| 63 | + * The form that contains the Dropzone element. |
| 64 | + * @param \Drupal\Core\Form\FormStateInterface $form_state |
| 65 | + * The form state. |
| 66 | + * @param $element |
| 67 | + * The Dropzone form element. |
| 68 | + */ |
| 69 | + public function __construct(MediaInterface $media_entity, FileInterface $file, $form, FormStateInterface $form_state, $element) { |
| 70 | + $this->mediaEntity = $media_entity; |
| 71 | + $this->file = $file; |
| 72 | + $this->form = $form; |
| 73 | + $this->formState = $form_state; |
| 74 | + $this->element = $element; |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * Get the media entity. |
| 79 | + * |
| 80 | + * @return \Drupal\media_entity\MediaInterface |
| 81 | + */ |
| 82 | + public function getMediaEntity() { |
| 83 | + return $this->mediaEntity; |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Set the media entity. |
| 88 | + * |
| 89 | + * @param \Drupal\media_entity\MediaInterface $media_entity |
| 90 | + * The updated media entity. |
| 91 | + */ |
| 92 | + public function setMediaEntity(MediaInterface $media_entity) { |
| 93 | + $this->mediaEntity = $media_entity; |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * Get the file for the media entity. |
| 98 | + * |
| 99 | + * @return \Drupal\file\FileInterface |
| 100 | + */ |
| 101 | + public function getFile() { |
| 102 | + return $this->file; |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * Get the form that contains the Dropzone element. |
| 107 | + * |
| 108 | + * @return array |
| 109 | + */ |
| 110 | + public function getForm() { |
| 111 | + return $this->form; |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * Get the form state. |
| 116 | + * |
| 117 | + * @return \Drupal\Core\Form\FormStateInterface |
| 118 | + */ |
| 119 | + public function getFormState() { |
| 120 | + return $this->formState; |
| 121 | + } |
| 122 | + |
| 123 | + /** |
| 124 | + * Set the form state. |
| 125 | + * |
| 126 | + * @param \Drupal\Core\Form\FormStateInterface $form_state |
| 127 | + * The updated form state. |
| 128 | + */ |
| 129 | + public function setFormState(FormStateInterface $form_state) { |
| 130 | + $this->formState = $form_state; |
| 131 | + } |
| 132 | + |
| 133 | + /** |
| 134 | + * Get the Dropzone form element. |
| 135 | + * |
| 136 | + * @return array |
| 137 | + */ |
| 138 | + public function getElement() { |
| 139 | + return $this->element; |
| 140 | + } |
| 141 | + |
| 142 | + /** |
| 143 | + * Set the Dropzone form element. |
| 144 | + * |
| 145 | + * @param $element |
| 146 | + * The updated form element. |
| 147 | + */ |
| 148 | + public function setElement($element) { |
| 149 | + $this->element = $element; |
| 150 | + } |
| 151 | + |
| 152 | +} |
0 commit comments