3 namespace Drupal\layout_builder;
5 use Drupal\Component\Plugin\PluginInspectionInterface;
6 use Drupal\Core\Access\AccessibleInterface;
7 use Symfony\Component\Routing\RouteCollection;
10 * Defines an interface for Section Storage type plugins.
13 * Layout Builder is currently experimental and should only be leveraged by
14 * experimental modules and development releases of contributed modules.
15 * See https://www.drupal.org/core/experimental for more information.
17 interface SectionStorageInterface extends SectionListInterface, PluginInspectionInterface, AccessibleInterface {
20 * Returns an identifier for this storage.
23 * The unique identifier for this storage.
25 public function getStorageId();
28 * Returns the type of this storage.
30 * Used in conjunction with the storage ID.
33 * The type of storage.
35 public function getStorageType();
38 * Sets the section list on the storage.
40 * @param \Drupal\layout_builder\SectionListInterface $section_list
46 * This should only be called during section storage instantiation.
48 public function setSectionList(SectionListInterface $section_list);
51 * Derives the section list from the storage ID.
54 * The storage ID, see ::getStorageId().
56 * @return \Drupal\layout_builder\SectionListInterface
59 * @throws \InvalidArgumentException
60 * Thrown if the ID is invalid.
63 * This should only be called during section storage instantiation.
65 public function getSectionListFromId($id);
68 * Provides the routes needed for Layout Builder UI.
70 * Allows the plugin to add or alter routes during the route building process.
71 * \Drupal\layout_builder\Routing\LayoutBuilderRoutesTrait is provided for the
72 * typical use case of building a standard Layout Builder UI.
74 * @param \Symfony\Component\Routing\RouteCollection $collection
75 * The route collection.
77 * @see \Drupal\Core\Routing\RoutingEvents::ALTER
79 public function buildRoutes(RouteCollection $collection);
82 * Gets the URL used when redirecting away from the Layout Builder UI.
84 * @return \Drupal\Core\Url
87 public function getRedirectUrl();
90 * Gets the URL used to display the Layout Builder UI.
93 * (optional) The link relationship type, for example: 'view' or 'disable'.
96 * @return \Drupal\Core\Url
99 public function getLayoutBuilderUrl($rel = 'view');
102 * Configures the plugin based on route values.
104 * @param mixed $value
106 * @param mixed $definition
107 * The parameter definition provided in the route options.
108 * @param string $name
109 * The name of the parameter.
110 * @param array $defaults
111 * The route defaults array.
113 * @return string|null
114 * The section storage ID if it could be extracted, NULL otherwise.
117 * This should only be called during section storage instantiation.
119 public function extractIdFromRoute($value, $definition, $name, array $defaults);
122 * Provides any available contexts for the object using the sections.
124 * @return \Drupal\Core\Plugin\Context\ContextInterface[]
125 * The array of context objects.
127 public function getContexts();
130 * Gets the label for the object using the sections.
133 * The label, or NULL if there is no label defined.
135 public function label();
138 * Saves the sections.
141 * SAVED_NEW or SAVED_UPDATED is returned depending on the operation
144 public function save();