Paragraphs Editor
EditBufferInterface.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
7 /**
8  * Stores paragraph edits.
9  *
10  * The edit buffer is used to store paragraphs that are embedded in the editor's
11  * markup but have not yet been saved to the database. We keep unsaved entities
12  * in a persistent edit buffer until the entire content tree is saved.
13  */
15 
16  /**
17  * Gets the id of the user the buffer belongs to.
18  *
19  * The owner of the buffer is the content author who created it (the one who
20  * is doing the editing). Keepng track of the user allows us to enforce that
21  * only a user who created a buffer can retrieve its contents.
22  *
23  * @return int
24  * The user id of the user that created the buffer.
25  */
26  public function getUser();
27 
28  /**
29  * Gets the id of the context this buffer belongs to.
30  *
31  * @return string
32  * The buffer's context id.
33  */
34  public function getContextString();
35 
36  /**
37  * Adds an edit buffer item to this edit buffer.
38  *
39  * @param \Drupal\paragraphs_editor\EditBuffer\EditBufferItemInterface $item
40  * The item to be added.
41  *
42  * @return \Drupal\paragraphs_editor\EditBuffer\EditBufferInterface
43  * $this for call chaining.
44  */
45  public function setItem(EditBufferItemInterface $item);
46 
47  /**
48  * Retrieves an item from the buffer.
49  *
50  * @param string $paragraph_uuid
51  * The uuid of the paragraph who's edits should be retrieved.
52  *
53  * @return \Drupal\paragraphs_editor\EditBuffer\EditBufferItemInterface
54  * The retrieved edit buffer item.
55  */
56  public function getItem($paragraph_uuid);
57 
58  /**
59  * Creates a new edit buffer item for a paragraph.
60  *
61  * @param \Drupal\paragraphs\ParagraphInterface $paragraph
62  * The paragraph to create the item for.
63  *
64  * @return \Drupal\paragraphs_editor\EditBuffer\EditBufferItemInterface
65  * The newly created edit buffer item.
66  */
67  public function createItem(ParagraphInterface $paragraph);
68 
69  /**
70  * Sets the persistent cache that will store this buffer.
71  *
72  * Since edit buffers need to live across ajax requests, we store them in a
73  * persistent (database) cache.
74  *
75  * @return \Drupal\paragraphs_editor\EditBuffer\EditBufferCacheInterface
76  * The persistent cache to store the edit buffer in.
77  */
78  public function setCache(EditBufferCacheInterface $buffer_cache);
79 
80  /**
81  * Saves the edit buffer to the persistent cache.
82  */
83  public function save();
84 
85  /**
86  * Sets the id of the buffer that is the parent of this buffer.
87  *
88  * This is used to track when related buffers need to be destroyed. If a
89  * parent buffer is destroyed, it's children should also be destroyed.
90  *
91  * @param string $context_string
92  * The parent buffer id.
93  */
94  public function tagParentBuffer($context_string);
95 
96  /**
97  * Gets the id of the buffer that is the parent of this buffer.
98  *
99  * @see tagParentBuffer
100  *
101  * @return string
102  * The parent buffer id.
103  */
104  public function getParentBufferTag();
105 
106  /**
107  * Sets a buffer as child of this buffer.
108  *
109  * @param string $context_string
110  * The child buffer id.
111  *
112  * @see tagParentBuffer
113  */
114  public function addChildBufferTag($context_string);
115 
116  /**
117  * Gets a list of child buffer ids.
118  *
119  * @see tagParentBuffer
120  *
121  * @return array
122  * An array of ids of child buffers.
123  */
124  public function getChildBufferTags();
125 
126  /**
127  * Gets the properties of the buffer as an array.
128  *
129  * @return array
130  * An array of the buffer properties.
131  */
132  public function toArray();
133 
134  /**
135  * Creates a copy of the buffer.
136  *
137  * Note that this does not duplicate every edit inside the buffer. It simply
138  * creates an exact copy of this buffer with a new id. The new copy should
139  * therefore replace the original buffer.
140  *
141  * @param string $context_string
142  * The id for the buffer that will be created.
143  *
144  * @return \Drupal\paragraphs_editor\EditBuffer\EditBufferInterface
145  * The newly created buffer.
146  */
147  public function createCopy($context_string);
148 
149 }
setCache(EditBufferCacheInterface $buffer_cache)