3 namespace Drupal\layout_builder;
5 use Drupal\Component\Plugin\PluginInspectionInterface;
6 use Symfony\Component\Routing\RouteCollection;
9 * Defines an interface for Section Storage type plugins.
12 * Layout Builder is currently experimental and should only be leveraged by
13 * experimental modules and development releases of contributed modules.
14 * See https://www.drupal.org/core/experimental for more information.
16 interface SectionStorageInterface extends SectionListInterface, PluginInspectionInterface {
19 * Returns an identifier for this storage.
22 * The unique identifier for this storage.
24 public function getStorageId();
27 * Returns the type of this storage.
29 * Used in conjunction with the storage ID.
32 * The type of storage.
34 public function getStorageType();
37 * Sets the section list on the storage.
39 * @param \Drupal\layout_builder\SectionListInterface $section_list
45 * This should only be called during section storage instantiation.
47 public function setSectionList(SectionListInterface $section_list);
50 * Derives the section list from the storage ID.
53 * The storage ID, see ::getStorageId().
55 * @return \Drupal\layout_builder\SectionListInterface
58 * @throws \InvalidArgumentException
59 * Thrown if the ID is invalid.
62 * This should only be called during section storage instantiation.
64 public function getSectionListFromId($id);
67 * Provides the routes needed for Layout Builder UI.
69 * Allows the plugin to add or alter routes during the route building process.
70 * \Drupal\layout_builder\Routing\LayoutBuilderRoutesTrait is provided for the
71 * typical use case of building a standard Layout Builder UI.
73 * @param \Symfony\Component\Routing\RouteCollection $collection
74 * The route collection.
76 * @see \Drupal\Core\Routing\RoutingEvents::ALTER
78 public function buildRoutes(RouteCollection $collection);
81 * Gets the URL used when redirecting away from the Layout Builder UI.
83 * @return \Drupal\Core\Url
86 public function getRedirectUrl();
89 * Gets the URL used to display the Layout Builder UI.
91 * @return \Drupal\Core\Url
94 public function getLayoutBuilderUrl();
97 * Configures the plugin based on route values.
101 * @param mixed $definition
102 * The parameter definition provided in the route options.
103 * @param string $name
104 * The name of the parameter.
105 * @param array $defaults
106 * The route defaults array.
108 * @return string|null
109 * The section storage ID if it could be extracted, NULL otherwise.
112 * This should only be called during section storage instantiation.
114 public function extractIdFromRoute($value, $definition, $name, array $defaults);
117 * Provides any available contexts for the object using the sections.
119 * @return \Drupal\Core\Plugin\Context\ContextInterface[]
120 * The array of context objects.
122 public function getContexts();
125 * Gets the label for the object using the sections.
128 * The label, or NULL if there is no label defined.
130 public function label();
133 * Saves the sections.
136 * SAVED_NEW or SAVED_UPDATED is returned depending on the operation
139 public function save();