Newer
Older
Angie Byron
committed
<?php
namespace Drupal\contact\Entity;
Angie Byron
committed
use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
Alex Pott
committed
use Drupal\contact\ContactFormInterface;
use Drupal\Core\Url;
Angie Byron
committed
/**
Alex Pott
committed
* Defines the contact form entity.
Angie Byron
committed
*
Alex Pott
committed
* @ConfigEntityType(
Alex Pott
committed
* id = "contact_form",
* label = @Translation("Contact form"),
Alex Pott
committed
* handlers = {
Alex Pott
committed
* "access" = "Drupal\contact\ContactFormAccessControlHandler",
* "list_builder" = "Drupal\contact\ContactFormListBuilder",
Alex Pott
committed
* "add" = "Drupal\contact\ContactFormEditForm",
* "edit" = "Drupal\contact\ContactFormEditForm",
Alex Pott
committed
* "delete" = "Drupal\Core\Entity\EntityDeleteForm"
Angie Byron
committed
* },
Alex Pott
committed
* config_prefix = "form",
* admin_permission = "administer contact forms",
Alex Pott
committed
* bundle_of = "contact_message",
Angie Byron
committed
* entity_keys = {
* "id" = "id",
Dries Buytaert
committed
* "label" = "label"
Alex Pott
committed
* },
* links = {
* "delete-form" = "/admin/structure/contact/manage/{contact_form}/delete",
Alex Pott
committed
* "edit-form" = "/admin/structure/contact/manage/{contact_form}",
* "collection" = "/admin/structure/contact",
Angie Byron
committed
* "canonical" = "/contact/{contact_form}",
* },
* config_export = {
* "id",
* "label",
* "recipients",
* "reply",
* "weight",
* "message",
* "redirect",
Angie Byron
committed
* }
* )
*/
Alex Pott
committed
class ContactForm extends ConfigEntityBundleBase implements ContactFormInterface {
Angie Byron
committed
/**
Alex Pott
committed
* The form ID.
Angie Byron
committed
*
* @var string
*/
protected $id;
Angie Byron
committed
/**
* The human-readable label of the category.
Angie Byron
committed
*
* @var string
*/
protected $label;
Angie Byron
committed
/**
* The message displayed to user on form submission.
*
* @var string
*/
protected $message;
Angie Byron
committed
/**
* List of recipient email addresses.
Angie Byron
committed
*
* @var array
*/
protected $recipients = [];
Angie Byron
committed
/**
* The path to redirect to on form submission.
*
* @var string
*/
protected $redirect;
Angie Byron
committed
/**
* An auto-reply message.
Angie Byron
committed
*
* @var string
*/
protected $reply = '';
Angie Byron
committed
/**
* The weight of the category.
Angie Byron
committed
*
* @var int
*/
protected $weight = 0;
/**
* {@inheritdoc}
*/
public function getMessage() {
return $this->message;
}
/**
* {@inheritdoc}
*/
public function setMessage($message) {
$this->message = $message;
return $this;
}
/**
* {@inheritdoc}
*/
public function getRecipients() {
return $this->recipients;
}
/**
* {@inheritdoc}
*/
public function setRecipients($recipients) {
$this->recipients = $recipients;
return $this;
}
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/**
* {@inheritdoc}
*/
public function getRedirectPath() {
return $this->redirect;
}
/**
* {@inheritdoc}
*/
public function getRedirectUrl() {
if ($this->redirect) {
$url = Url::fromUserInput($this->redirect);
}
else {
$url = Url::fromRoute('<front>');
}
return $url;
}
/**
* {@inheritdoc}
*/
public function setRedirectPath($redirect) {
$this->redirect = $redirect;
return $this;
}
/**
* {@inheritdoc}
*/
public function getReply() {
return $this->reply;
}
/**
* {@inheritdoc}
*/
public function setReply($reply) {
$this->reply = $reply;
return $this;
}
/**
* {@inheritdoc}
*/
public function getWeight() {
return $this->weight;
}
/**
* {@inheritdoc}
*/
public function setWeight($weight) {
$this->weight = $weight;
return $this;
}