annotate core/modules/layout_builder/src/SectionStorageInterface.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents af1871eacc83
children
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@18 7 use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
Chris@18 8 use Drupal\Core\Plugin\ContextAwarePluginInterface;
Chris@18 9 use Drupal\Core\Session\AccountInterface;
Chris@14 10 use Symfony\Component\Routing\RouteCollection;
Chris@14 11
Chris@14 12 /**
Chris@14 13 * Defines an interface for Section Storage type plugins.
Chris@14 14 */
Chris@18 15 interface SectionStorageInterface extends SectionListInterface, PluginInspectionInterface, ContextAwarePluginInterface, AccessibleInterface {
Chris@14 16
Chris@14 17 /**
Chris@14 18 * Returns an identifier for this storage.
Chris@14 19 *
Chris@14 20 * @return string
Chris@14 21 * The unique identifier for this storage.
Chris@14 22 */
Chris@14 23 public function getStorageId();
Chris@14 24
Chris@14 25 /**
Chris@14 26 * Returns the type of this storage.
Chris@14 27 *
Chris@14 28 * Used in conjunction with the storage ID.
Chris@14 29 *
Chris@14 30 * @return string
Chris@14 31 * The type of storage.
Chris@14 32 */
Chris@14 33 public function getStorageType();
Chris@14 34
Chris@14 35 /**
Chris@14 36 * Derives the section list from the storage ID.
Chris@14 37 *
Chris@14 38 * @param string $id
Chris@14 39 * The storage ID, see ::getStorageId().
Chris@14 40 *
Chris@14 41 * @return \Drupal\layout_builder\SectionListInterface
Chris@14 42 * The section list.
Chris@14 43 *
Chris@14 44 * @throws \InvalidArgumentException
Chris@14 45 * Thrown if the ID is invalid.
Chris@14 46 *
Chris@14 47 * @internal
Chris@14 48 * This should only be called during section storage instantiation.
Chris@18 49 *
Chris@18 50 * @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. The
Chris@18 51 * section list should be derived from context. See
Chris@18 52 * https://www.drupal.org/node/3016262.
Chris@14 53 */
Chris@14 54 public function getSectionListFromId($id);
Chris@14 55
Chris@14 56 /**
Chris@14 57 * Provides the routes needed for Layout Builder UI.
Chris@14 58 *
Chris@14 59 * Allows the plugin to add or alter routes during the route building process.
Chris@14 60 * \Drupal\layout_builder\Routing\LayoutBuilderRoutesTrait is provided for the
Chris@14 61 * typical use case of building a standard Layout Builder UI.
Chris@14 62 *
Chris@14 63 * @param \Symfony\Component\Routing\RouteCollection $collection
Chris@14 64 * The route collection.
Chris@14 65 *
Chris@14 66 * @see \Drupal\Core\Routing\RoutingEvents::ALTER
Chris@14 67 */
Chris@14 68 public function buildRoutes(RouteCollection $collection);
Chris@14 69
Chris@14 70 /**
Chris@14 71 * Gets the URL used when redirecting away from the Layout Builder UI.
Chris@14 72 *
Chris@14 73 * @return \Drupal\Core\Url
Chris@14 74 * The URL object.
Chris@14 75 */
Chris@14 76 public function getRedirectUrl();
Chris@14 77
Chris@14 78 /**
Chris@14 79 * Gets the URL used to display the Layout Builder UI.
Chris@14 80 *
Chris@17 81 * @param string $rel
Chris@17 82 * (optional) The link relationship type, for example: 'view' or 'disable'.
Chris@17 83 * Defaults to 'view'.
Chris@17 84 *
Chris@14 85 * @return \Drupal\Core\Url
Chris@14 86 * The URL object.
Chris@14 87 */
Chris@17 88 public function getLayoutBuilderUrl($rel = 'view');
Chris@14 89
Chris@14 90 /**
Chris@14 91 * Configures the plugin based on route values.
Chris@14 92 *
Chris@14 93 * @param mixed $value
Chris@14 94 * The raw value.
Chris@14 95 * @param mixed $definition
Chris@14 96 * The parameter definition provided in the route options.
Chris@14 97 * @param string $name
Chris@14 98 * The name of the parameter.
Chris@14 99 * @param array $defaults
Chris@14 100 * The route defaults array.
Chris@14 101 *
Chris@14 102 * @return string|null
Chris@14 103 * The section storage ID if it could be extracted, NULL otherwise.
Chris@14 104 *
Chris@14 105 * @internal
Chris@14 106 * This should only be called during section storage instantiation.
Chris@18 107 *
Chris@18 108 * @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0.
Chris@18 109 * \Drupal\layout_builder\SectionStorageInterface::deriveContextsFromRoute()
Chris@18 110 * should be used instead. See https://www.drupal.org/node/3016262.
Chris@14 111 */
Chris@14 112 public function extractIdFromRoute($value, $definition, $name, array $defaults);
Chris@14 113
Chris@14 114 /**
Chris@18 115 * Derives the available plugin contexts from route values.
Chris@18 116 *
Chris@18 117 * This should only be called during section storage instantiation,
Chris@18 118 * specifically for use by the routing system. For all non-routing usages, use
Chris@18 119 * \Drupal\Component\Plugin\ContextAwarePluginInterface::getContextValue().
Chris@18 120 *
Chris@18 121 * @param mixed $value
Chris@18 122 * The raw value.
Chris@18 123 * @param mixed $definition
Chris@18 124 * The parameter definition provided in the route options.
Chris@18 125 * @param string $name
Chris@18 126 * The name of the parameter.
Chris@18 127 * @param array $defaults
Chris@18 128 * The route defaults array.
Chris@14 129 *
Chris@14 130 * @return \Drupal\Core\Plugin\Context\ContextInterface[]
Chris@18 131 * The available plugin contexts.
Chris@18 132 *
Chris@18 133 * @see \Drupal\Core\ParamConverter\ParamConverterInterface::convert()
Chris@14 134 */
Chris@18 135 public function deriveContextsFromRoute($value, $definition, $name, array $defaults);
Chris@18 136
Chris@18 137 /**
Chris@18 138 * Gets contexts for use during preview.
Chris@18 139 *
Chris@18 140 * When not in preview, ::getContexts() will be used.
Chris@18 141 *
Chris@18 142 * @return \Drupal\Core\Plugin\Context\ContextInterface[]
Chris@18 143 * The plugin contexts suitable for previewing.
Chris@18 144 */
Chris@18 145 public function getContextsDuringPreview();
Chris@14 146
Chris@14 147 /**
Chris@14 148 * Gets the label for the object using the sections.
Chris@14 149 *
Chris@14 150 * @return string
Chris@14 151 * The label, or NULL if there is no label defined.
Chris@14 152 */
Chris@14 153 public function label();
Chris@14 154
Chris@14 155 /**
Chris@14 156 * Saves the sections.
Chris@14 157 *
Chris@14 158 * @return int
Chris@14 159 * SAVED_NEW or SAVED_UPDATED is returned depending on the operation
Chris@14 160 * performed.
Chris@14 161 */
Chris@14 162 public function save();
Chris@14 163
Chris@18 164 /**
Chris@18 165 * Determines if this section storage is applicable for the current contexts.
Chris@18 166 *
Chris@18 167 * @param \Drupal\Core\Cache\RefinableCacheableDependencyInterface $cacheability
Chris@18 168 * Refinable cacheability object, typically provided by the section storage
Chris@18 169 * manager. When implementing this method, populate $cacheability with any
Chris@18 170 * information that affects whether this storage is applicable.
Chris@18 171 *
Chris@18 172 * @return bool
Chris@18 173 * TRUE if this section storage is applicable, FALSE otherwise.
Chris@18 174 *
Chris@18 175 * @internal
Chris@18 176 * This method is intended to be called by
Chris@18 177 * \Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface::findByContext().
Chris@18 178 *
Chris@18 179 * @see \Drupal\Core\Cache\RefinableCacheableDependencyInterface
Chris@18 180 */
Chris@18 181 public function isApplicable(RefinableCacheableDependencyInterface $cacheability);
Chris@18 182
Chris@18 183 /**
Chris@18 184 * Overrides \Drupal\Component\Plugin\PluginInspectionInterface::getPluginDefinition().
Chris@18 185 *
Chris@18 186 * @return \Drupal\layout_builder\SectionStorage\SectionStorageDefinition
Chris@18 187 * The section storage definition.
Chris@18 188 */
Chris@18 189 public function getPluginDefinition();
Chris@18 190
Chris@18 191 /**
Chris@18 192 * Overrides \Drupal\Core\Access\AccessibleInterface::access().
Chris@18 193 *
Chris@18 194 * @ingroup layout_builder_access
Chris@18 195 */
Chris@18 196 public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE);
Chris@18 197
Chris@14 198 }