Paragraphs Editor
EditBufferItem.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
7 /**
8  * Wraps paragraph edits with the buffer that will store those edits.
9  */
11 
12  /**
13  * The wrapped entity, containing any edits.
14  *
15  * @var \Drupal\paragraphs\ParagraphInterface
16  */
17  protected $entity;
18 
19  /**
20  * The buffer that will be used to store the edits.
21  *
22  * @var \Drupal\paragraphs_editor\EditBuffer\EditBufferInterface
23  */
24  protected $buffer;
25 
26  /**
27  * Creates an edit buffer item.
28  *
29  * @param \Drupal\paragraphs\ParagraphInterface $entity
30  * The entity to wrap.
31  * @param \Drupal\paragraphs_editor\EditBuffer\EditBufferInterface $buffer
32  * The buffer that will store edits.
33  */
34  public function __construct(ParagraphInterface $entity, EditBufferInterface $buffer) {
35  $this->entity = $entity;
36  $this->buffer = $buffer;
37  }
38 
39  /**
40  * {@inheritdoc}
41  */
42  public function getEntity() {
43  return $this->entity;
44  }
45 
46  /**
47  * {@inheritdoc}
48  */
49  public function overwrite(ParagraphInterface $entity) {
50  $this->entity = $entity;
51  }
52 
53  /**
54  * {@inheritdoc}
55  */
56  public function save() {
57  $this->buffer->setItem($this)->save();
58  }
59 
60 }
__construct(ParagraphInterface $entity, EditBufferInterface $buffer)