annotate core/modules/layout_builder/src/SectionStorageInterface.php @ 17:129ea1e6d783

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