comparison core/modules/contact/src/Entity/ContactForm.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children a9cd425dd02b
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 <?php
2
3 namespace Drupal\contact\Entity;
4
5 use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
6 use Drupal\contact\ContactFormInterface;
7 use Drupal\Core\Url;
8
9 /**
10 * Defines the contact form entity.
11 *
12 * @ConfigEntityType(
13 * id = "contact_form",
14 * label = @Translation("Contact form"),
15 * handlers = {
16 * "access" = "Drupal\contact\ContactFormAccessControlHandler",
17 * "list_builder" = "Drupal\contact\ContactFormListBuilder",
18 * "form" = {
19 * "add" = "Drupal\contact\ContactFormEditForm",
20 * "edit" = "Drupal\contact\ContactFormEditForm",
21 * "delete" = "Drupal\Core\Entity\EntityDeleteForm"
22 * }
23 * },
24 * config_prefix = "form",
25 * admin_permission = "administer contact forms",
26 * bundle_of = "contact_message",
27 * entity_keys = {
28 * "id" = "id",
29 * "label" = "label"
30 * },
31 * links = {
32 * "delete-form" = "/admin/structure/contact/manage/{contact_form}/delete",
33 * "edit-form" = "/admin/structure/contact/manage/{contact_form}",
34 * "collection" = "/admin/structure/contact",
35 * "canonical" = "/contact/{contact_form}",
36 * },
37 * config_export = {
38 * "id",
39 * "label",
40 * "recipients",
41 * "reply",
42 * "weight",
43 * "message",
44 * "redirect",
45 * }
46 * )
47 */
48 class ContactForm extends ConfigEntityBundleBase implements ContactFormInterface {
49
50 /**
51 * The form ID.
52 *
53 * @var string
54 */
55 protected $id;
56
57 /**
58 * The human-readable label of the category.
59 *
60 * @var string
61 */
62 protected $label;
63
64 /**
65 * The message displayed to user on form submission.
66 *
67 * @var string
68 */
69 protected $message;
70
71 /**
72 * List of recipient email addresses.
73 *
74 * @var array
75 */
76 protected $recipients = [];
77
78 /**
79 * The path to redirect to on form submission.
80 *
81 * @var string
82 */
83 protected $redirect;
84
85 /**
86 * An auto-reply message.
87 *
88 * @var string
89 */
90 protected $reply = '';
91
92 /**
93 * The weight of the category.
94 *
95 * @var int
96 */
97 protected $weight = 0;
98
99 /**
100 * {@inheritdoc}
101 */
102 public function getMessage() {
103 return $this->message;
104 }
105
106 /**
107 * {@inheritdoc}
108 */
109 public function setMessage($message) {
110 $this->message = $message;
111 return $this;
112 }
113
114 /**
115 * {@inheritdoc}
116 */
117 public function getRecipients() {
118 return $this->recipients;
119 }
120
121 /**
122 * {@inheritdoc}
123 */
124 public function setRecipients($recipients) {
125 $this->recipients = $recipients;
126 return $this;
127 }
128
129 /**
130 * {@inheritdoc}
131 */
132 public function getRedirectPath() {
133 return $this->redirect;
134 }
135
136 /**
137 * {@inheritdoc}
138 */
139 public function getRedirectUrl() {
140 if ($this->redirect) {
141 $url = Url::fromUserInput($this->redirect);
142 }
143 else {
144 $url = Url::fromRoute('<front>');
145 }
146 return $url;
147 }
148
149 /**
150 * {@inheritdoc}
151 */
152 public function setRedirectPath($redirect) {
153 $this->redirect = $redirect;
154 return $this;
155 }
156
157 /**
158 * {@inheritdoc}
159 */
160 public function getReply() {
161 return $this->reply;
162 }
163
164 /**
165 * {@inheritdoc}
166 */
167 public function setReply($reply) {
168 $this->reply = $reply;
169 return $this;
170 }
171
172 /**
173 * {@inheritdoc}
174 */
175 public function getWeight() {
176 return $this->weight;
177 }
178
179 /**
180 * {@inheritdoc}
181 */
182 public function setWeight($weight) {
183 $this->weight = $weight;
184 return $this;
185 }
186
187 }