Chris@14
|
1 <?php
|
Chris@14
|
2
|
Chris@14
|
3 namespace Drupal\layout_builder;
|
Chris@14
|
4
|
Chris@14
|
5 use Drupal\Component\Plugin\PluginInspectionInterface;
|
Chris@14
|
6 use Symfony\Component\Routing\RouteCollection;
|
Chris@14
|
7
|
Chris@14
|
8 /**
|
Chris@14
|
9 * Defines an interface for Section Storage type plugins.
|
Chris@14
|
10 *
|
Chris@14
|
11 * @internal
|
Chris@14
|
12 * Layout Builder is currently experimental and should only be leveraged by
|
Chris@14
|
13 * experimental modules and development releases of contributed modules.
|
Chris@14
|
14 * See https://www.drupal.org/core/experimental for more information.
|
Chris@14
|
15 */
|
Chris@14
|
16 interface SectionStorageInterface extends SectionListInterface, PluginInspectionInterface {
|
Chris@14
|
17
|
Chris@14
|
18 /**
|
Chris@14
|
19 * Returns an identifier for this storage.
|
Chris@14
|
20 *
|
Chris@14
|
21 * @return string
|
Chris@14
|
22 * The unique identifier for this storage.
|
Chris@14
|
23 */
|
Chris@14
|
24 public function getStorageId();
|
Chris@14
|
25
|
Chris@14
|
26 /**
|
Chris@14
|
27 * Returns the type of this storage.
|
Chris@14
|
28 *
|
Chris@14
|
29 * Used in conjunction with the storage ID.
|
Chris@14
|
30 *
|
Chris@14
|
31 * @return string
|
Chris@14
|
32 * The type of storage.
|
Chris@14
|
33 */
|
Chris@14
|
34 public function getStorageType();
|
Chris@14
|
35
|
Chris@14
|
36 /**
|
Chris@14
|
37 * Sets the section list on the storage.
|
Chris@14
|
38 *
|
Chris@14
|
39 * @param \Drupal\layout_builder\SectionListInterface $section_list
|
Chris@14
|
40 * The section list.
|
Chris@14
|
41 *
|
Chris@14
|
42 * @return $this
|
Chris@14
|
43 *
|
Chris@14
|
44 * @internal
|
Chris@14
|
45 * This should only be called during section storage instantiation.
|
Chris@14
|
46 */
|
Chris@14
|
47 public function setSectionList(SectionListInterface $section_list);
|
Chris@14
|
48
|
Chris@14
|
49 /**
|
Chris@14
|
50 * Derives the section list from the storage ID.
|
Chris@14
|
51 *
|
Chris@14
|
52 * @param string $id
|
Chris@14
|
53 * The storage ID, see ::getStorageId().
|
Chris@14
|
54 *
|
Chris@14
|
55 * @return \Drupal\layout_builder\SectionListInterface
|
Chris@14
|
56 * The section list.
|
Chris@14
|
57 *
|
Chris@14
|
58 * @throws \InvalidArgumentException
|
Chris@14
|
59 * Thrown if the ID is invalid.
|
Chris@14
|
60 *
|
Chris@14
|
61 * @internal
|
Chris@14
|
62 * This should only be called during section storage instantiation.
|
Chris@14
|
63 */
|
Chris@14
|
64 public function getSectionListFromId($id);
|
Chris@14
|
65
|
Chris@14
|
66 /**
|
Chris@14
|
67 * Provides the routes needed for Layout Builder UI.
|
Chris@14
|
68 *
|
Chris@14
|
69 * Allows the plugin to add or alter routes during the route building process.
|
Chris@14
|
70 * \Drupal\layout_builder\Routing\LayoutBuilderRoutesTrait is provided for the
|
Chris@14
|
71 * typical use case of building a standard Layout Builder UI.
|
Chris@14
|
72 *
|
Chris@14
|
73 * @param \Symfony\Component\Routing\RouteCollection $collection
|
Chris@14
|
74 * The route collection.
|
Chris@14
|
75 *
|
Chris@14
|
76 * @see \Drupal\Core\Routing\RoutingEvents::ALTER
|
Chris@14
|
77 */
|
Chris@14
|
78 public function buildRoutes(RouteCollection $collection);
|
Chris@14
|
79
|
Chris@14
|
80 /**
|
Chris@14
|
81 * Gets the URL used when redirecting away from the Layout Builder UI.
|
Chris@14
|
82 *
|
Chris@14
|
83 * @return \Drupal\Core\Url
|
Chris@14
|
84 * The URL object.
|
Chris@14
|
85 */
|
Chris@14
|
86 public function getRedirectUrl();
|
Chris@14
|
87
|
Chris@14
|
88 /**
|
Chris@14
|
89 * Gets the URL used to display the Layout Builder UI.
|
Chris@14
|
90 *
|
Chris@14
|
91 * @return \Drupal\Core\Url
|
Chris@14
|
92 * The URL object.
|
Chris@14
|
93 */
|
Chris@14
|
94 public function getLayoutBuilderUrl();
|
Chris@14
|
95
|
Chris@14
|
96 /**
|
Chris@14
|
97 * Configures the plugin based on route values.
|
Chris@14
|
98 *
|
Chris@14
|
99 * @param mixed $value
|
Chris@14
|
100 * The raw value.
|
Chris@14
|
101 * @param mixed $definition
|
Chris@14
|
102 * The parameter definition provided in the route options.
|
Chris@14
|
103 * @param string $name
|
Chris@14
|
104 * The name of the parameter.
|
Chris@14
|
105 * @param array $defaults
|
Chris@14
|
106 * The route defaults array.
|
Chris@14
|
107 *
|
Chris@14
|
108 * @return string|null
|
Chris@14
|
109 * The section storage ID if it could be extracted, NULL otherwise.
|
Chris@14
|
110 *
|
Chris@14
|
111 * @internal
|
Chris@14
|
112 * This should only be called during section storage instantiation.
|
Chris@14
|
113 */
|
Chris@14
|
114 public function extractIdFromRoute($value, $definition, $name, array $defaults);
|
Chris@14
|
115
|
Chris@14
|
116 /**
|
Chris@14
|
117 * Provides any available contexts for the object using the sections.
|
Chris@14
|
118 *
|
Chris@14
|
119 * @return \Drupal\Core\Plugin\Context\ContextInterface[]
|
Chris@14
|
120 * The array of context objects.
|
Chris@14
|
121 */
|
Chris@14
|
122 public function getContexts();
|
Chris@14
|
123
|
Chris@14
|
124 /**
|
Chris@14
|
125 * Gets the label for the object using the sections.
|
Chris@14
|
126 *
|
Chris@14
|
127 * @return string
|
Chris@14
|
128 * The label, or NULL if there is no label defined.
|
Chris@14
|
129 */
|
Chris@14
|
130 public function label();
|
Chris@14
|
131
|
Chris@14
|
132 /**
|
Chris@14
|
133 * Saves the sections.
|
Chris@14
|
134 *
|
Chris@14
|
135 * @return int
|
Chris@14
|
136 * SAVED_NEW or SAVED_UPDATED is returned depending on the operation
|
Chris@14
|
137 * performed.
|
Chris@14
|
138 */
|
Chris@14
|
139 public function save();
|
Chris@14
|
140
|
Chris@14
|
141 }
|