Newer
Older
<?php
/**
* @file
Angie Byron
committed
* Definition of Drupal\comment\Plugin\Core\Entity\Comment.
Angie Byron
committed
namespace Drupal\comment\Plugin\Core\Entity;
use Drupal\Core\Entity\EntityNG;
use Drupal\Core\Entity\Annotation\EntityType;
Angie Byron
committed
use Drupal\Core\Annotation\Translation;
use Drupal\comment\CommentInterface;
/**
* Defines the comment entity class.
Angie Byron
committed
*
* @EntityType(
Angie Byron
committed
* id = "comment",
* label = @Translation("Comment"),
Angie Byron
committed
* bundle_label = @Translation("Content type"),
Angie Byron
committed
* module = "comment",
* controllers = {
* "storage" = "Drupal\comment\CommentStorageController",
* "access" = "Drupal\comment\CommentAccessController",
* "render" = "Drupal\comment\CommentRenderController",
* "form" = {
* "default" = "Drupal\comment\CommentFormController"
* },
* "translation" = "Drupal\comment\CommentTranslationController"
Angie Byron
committed
* },
* base_table = "comment",
* uri_callback = "comment_uri",
* fieldable = TRUE,
Angie Byron
committed
* translatable = TRUE,
* route_base_path = "admin/structure/types/manage/{bundle}/comment",
* bundle_prefix = "comment_node_",
Angie Byron
committed
* entity_keys = {
* "id" = "cid",
* "bundle" = "node_type",
* "label" = "subject",
* "uuid" = "uuid"
* }
* )
class Comment extends EntityNG implements CommentInterface {
/**
* The comment ID.
*
* @todo Rename to 'id'.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
*/
public $cid;
Dries Buytaert
committed
/**
* The comment UUID.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
Dries Buytaert
committed
*/
public $uuid;
/**
* The parent comment ID if this is a reply to a comment.
*
* @todo: Rename to 'parent_id'.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
*/
public $pid;
Angie Byron
committed
/**
* The ID of the node to which the comment is attached.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
Angie Byron
committed
*/
public $nid;
/**
* The comment language code.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
public $langcode;
/**
* The comment title.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
*/
public $subject;
/**
* The comment author ID.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
public $uid;
/**
* The comment author's name.
*
* For anonymous authors, this is the value as typed in the comment form.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
public $name;
/**
* The comment author's e-mail address.
*
* For anonymous authors, this is the value as typed in the comment form.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
*/
public $mail;
/**
* The comment author's home page address.
*
* For anonymous authors, this is the value as typed in the comment form.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
*/
public $homepage;
/**
* The comment author's hostname.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
public $hostname;
/**
* The time that the comment was created.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
*/
public $created;
/**
* The time that the comment was last edited.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
*/
public $changed;
/**
* A boolean field indicating whether the comment is published.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
*/
public $status;
/**
* The alphadecimal representation of the comment's place in a thread.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
*/
public $thread;
/**
* The comment node type.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
*/
public $node_type;
/**
* The comment 'new' marker for the current user.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
*/
public $new;
/**
* The plain data values of the contained properties.
*
* Define default values.
*
* @var array
*/
protected $values = array(
'langcode' => array(LANGUAGE_DEFAULT => array(0 => array('value' => LANGUAGE_NOT_SPECIFIED))),
'name' => array(LANGUAGE_DEFAULT => array(0 => array('value' => ''))),
Dries Buytaert
committed
'uid' => array(LANGUAGE_DEFAULT => array(0 => array('target_id' => 0))),
);
/**
* Initialize the object. Invoked upon construction and wake up.
*/
protected function init() {
parent::init();
// We unset all defined properties, so magic getters apply.
unset($this->cid);
unset($this->uuid);
unset($this->pid);
unset($this->nid);
unset($this->subject);
unset($this->uid);
unset($this->name);
unset($this->mail);
unset($this->homepage);
unset($this->hostname);
unset($this->created);
unset($this->changed);
unset($this->status);
unset($this->thread);
unset($this->node_type);
unset($this->new);
}
/**
* Implements Drupal\Core\Entity\EntityInterface::id().
public function id() {
return $this->get('cid')->value;