How to use add method of storage class

Best Atoum code snippet using storage.add

LayoutBuilder.php

Source:LayoutBuilder.php Github

copy

Full Screen

...131 * @param \Drupal\layout_builder\SectionStorageInterface $section_storage132 * The section storage.133 */134 protected function prepareLayout(SectionStorageInterface $section_storage) {135 // If the layout has pending changes, add a warning.136 if ($this->layoutTempstoreRepository->has($section_storage)) {137 $this->messenger->addWarning($this->t('You have unsaved changes.'));138 }139 // If the layout is an override that has not yet been overridden, copy the140 // sections from the corresponding default.141 elseif ($section_storage instanceof OverridesSectionStorageInterface && !$section_storage->isOverridden()) {142 $sections = $section_storage->getDefaultSectionStorage()->getSections();143 foreach ($sections as $section) {144 $section_storage->appendSection($section);145 }146 $this->layoutTempstoreRepository->set($section_storage);147 }148 }149 /**150 * Builds a link to add a new section at a given delta.151 *152 * @param \Drupal\layout_builder\SectionStorageInterface $section_storage153 * The section storage.154 * @param int $delta155 * The delta of the section to splice.156 *157 * @return array158 * A render array for a link.159 */160 protected function buildAddSectionLink(SectionStorageInterface $section_storage, $delta) {161 $storage_type = $section_storage->getStorageType();162 $storage_id = $section_storage->getStorageId();163 // If the delta and the count are the same, it is either the end of the164 // layout or an empty layout.165 if ($delta === count($section_storage)) {166 if ($delta === 0) {167 $title = $this->t('Add section');168 }169 else {170 $title = $this->t('Add section <span class="visually-hidden">at end of layout</span>');171 }172 }173 // If the delta and the count are different, it is either the beginning of174 // the layout or in between two sections.175 else {176 if ($delta === 0) {177 $title = $this->t('Add section <span class="visually-hidden">at start of layout</span>');178 }179 else {180 $title = $this->t('Add section <span class="visually-hidden">between @first and @second</span>', ['@first' => $delta, '@second' => $delta + 1]);181 }182 }183 return [184 'link' => [185 '#type' => 'link',186 '#title' => $title,187 '#url' => Url::fromRoute('layout_builder.choose_section',188 [189 'section_storage_type' => $storage_type,190 'section_storage' => $storage_id,191 'delta' => $delta,192 ],193 [194 'attributes' => [195 'class' => [196 'use-ajax',197 'layout-builder__link',198 'layout-builder__link--add',199 ],200 'data-dialog-type' => 'dialog',201 'data-dialog-renderer' => 'off_canvas',202 ],203 ]204 ),205 ],206 '#type' => 'container',207 '#attributes' => [208 'class' => ['layout-builder__add-section'],209 'data-layout-builder-highlight-id' => $this->sectionAddHighlightId($delta),210 ],211 ];212 }213 /**214 * Builds the render array for the layout section while editing.215 *216 * @param \Drupal\layout_builder\SectionStorageInterface $section_storage217 * The section storage.218 * @param int $delta219 * The delta of the section.220 *221 * @return array222 * The render array for a given section.223 */224 protected function buildAdministrativeSection(SectionStorageInterface $section_storage, $delta) {225 $storage_type = $section_storage->getStorageType();226 $storage_id = $section_storage->getStorageId();227 $section = $section_storage->getSection($delta);228 $layout = $section->getLayout();229 $layout_settings = $section->getLayoutSettings();230 $section_label = !empty($layout_settings['label']) ? $layout_settings['label'] : $this->t('Section @section', ['@section' => $delta + 1]);231 $build = $section->toRenderArray($this->getAvailableContexts($section_storage), TRUE);232 $layout_definition = $layout->getPluginDefinition();233 $region_labels = $layout_definition->getRegionLabels();234 foreach ($layout_definition->getRegions() as $region => $info) {235 if (!empty($build[$region])) {236 foreach (Element::children($build[$region]) as $uuid) {237 $build[$region][$uuid]['#attributes']['class'][] = 'js-layout-builder-block';238 $build[$region][$uuid]['#attributes']['class'][] = 'layout-builder-block';239 $build[$region][$uuid]['#attributes']['data-layout-block-uuid'] = $uuid;240 $build[$region][$uuid]['#attributes']['data-layout-builder-highlight-id'] = $this->blockUpdateHighlightId($uuid);241 $build[$region][$uuid]['#contextual_links'] = [242 'layout_builder_block' => [243 'route_parameters' => [244 'section_storage_type' => $storage_type,245 'section_storage' => $storage_id,246 'delta' => $delta,247 'region' => $region,248 'uuid' => $uuid,249 ],250 // Add metadata about the current operations available in251 // contextual links. This will invalidate the client-side cache of252 // links that were cached before the 'move' link was added.253 // @see layout_builder.links.contextual.yml254 'metadata' => [255 'operations' => 'move:update:remove',256 ],257 ],258 ];259 }260 }261 $build[$region]['layout_builder_add_block']['link'] = [262 '#type' => 'link',263 // Add one to the current delta since it is zero-indexed.264 '#title' => $this->t('Add block <span class="visually-hidden">in @section, @region region</span>', ['@section' => $section_label, '@region' => $region_labels[$region]]),265 '#url' => Url::fromRoute('layout_builder.choose_block',266 [267 'section_storage_type' => $storage_type,268 'section_storage' => $storage_id,269 'delta' => $delta,270 'region' => $region,271 ],272 [273 'attributes' => [274 'class' => [275 'use-ajax',276 'layout-builder__link',277 'layout-builder__link--add',278 ],279 'data-dialog-type' => 'dialog',280 'data-dialog-renderer' => 'off_canvas',281 ],282 ]283 ),284 ];285 $build[$region]['layout_builder_add_block']['#type'] = 'container';286 $build[$region]['layout_builder_add_block']['#attributes'] = [287 'class' => ['layout-builder__add-block'],288 'data-layout-builder-highlight-id' => $this->blockAddHighlightId($delta, $region),289 ];290 $build[$region]['layout_builder_add_block']['#weight'] = 1000;291 $build[$region]['#attributes']['data-region'] = $region;292 $build[$region]['#attributes']['class'][] = 'layout-builder__region';293 $build[$region]['#attributes']['class'][] = 'js-layout-builder-region';294 $build[$region]['#attributes']['role'] = 'group';295 $build[$region]['#attributes']['aria-label'] = $this->t('@region region in @section', [296 '@region' => $info['label'],297 '@section' => $section_label,298 ]);299 // Get weights of all children for use by the region label.300 $weights = array_map(function ($a) {301 return isset($a['#weight']) ? $a['#weight'] : 0;302 }, $build[$region]);303 // The region label is made visible when the move block dialog is open.304 $build[$region]['region_label'] = [305 '#type' => 'container',306 '#attributes' => [307 'class' => ['layout__region-info', 'layout-builder__region-label'],308 // A more detailed version of this information is already read by309 // screen readers, so this label can be hidden from them.310 'aria-hidden' => TRUE,311 ],312 '#markup' => $this->t('Region: @region', ['@region' => $info['label']]),313 // Ensures the region label is displayed first.314 '#weight' => min($weights) - 1,315 ];316 }317 $build['#attributes']['data-layout-update-url'] = Url::fromRoute('layout_builder.move_block', [318 'section_storage_type' => $storage_type,319 'section_storage' => $storage_id,320 ])->toString();321 $build['#attributes']['data-layout-delta'] = $delta;322 $build['#attributes']['class'][] = 'layout-builder__layout';323 $build['#attributes']['data-layout-builder-highlight-id'] = $this->sectionUpdateHighlightId($delta);324 return [325 '#type' => 'container',326 '#attributes' => [327 'class' => ['layout-builder__section'],328 'role' => 'group',329 'aria-label' => $section_label,330 ],331 'remove' => [332 '#type' => 'link',333 '#title' => $this->t('Remove @section', ['@section' => $section_label]),334 '#url' => Url::fromRoute('layout_builder.remove_section', [335 'section_storage_type' => $storage_type,336 'section_storage' => $storage_id,337 'delta' => $delta,338 ]),339 '#attributes' => [340 'class' => [341 'use-ajax',342 'layout-builder__link',343 'layout-builder__link--remove',344 ],345 'data-dialog-type' => 'dialog',346 'data-dialog-renderer' => 'off_canvas',347 ],348 ],349 // The section label is added to sections without a "Configure section"350 // link, and is only visible when the move block dialog is open.351 'section_label' => [352 '#markup' => $this->t('<span class="layout-builder__section-label" aria-hidden="true">@section</span>', ['@section' => $section_label]),353 '#access' => !$layout instanceof PluginFormInterface,354 ],355 'configure' => [356 '#type' => 'link',357 '#title' => $this->t('Configure @section', ['@section' => $section_label]),358 '#access' => $layout instanceof PluginFormInterface,359 '#url' => Url::fromRoute('layout_builder.configure_section', [360 'section_storage_type' => $storage_type,361 'section_storage' => $storage_id,362 'delta' => $delta,363 ]),...

Full Screen

Full Screen

LayoutBuilderController.php

Source:LayoutBuilderController.php Github

copy

Full Screen

...101 * @param bool $is_rebuilding102 * Indicates if the layout is rebuilding.103 */104 protected function prepareLayout(SectionStorageInterface $section_storage, $is_rebuilding) {105 // Only add sections if the layout is new and empty.106 if (!$is_rebuilding && $section_storage->count() === 0) {107 $sections = [];108 // If this is an empty override, copy the sections from the corresponding109 // default.110 if ($section_storage instanceof OverridesSectionStorageInterface) {111 $sections = $section_storage->getDefaultSectionStorage()->getSections();112 }113 // For an empty layout, begin with a single section of one column.114 if (!$sections) {115 $sections[] = new Section('layout_onecol');116 }117 foreach ($sections as $section) {118 $section_storage->appendSection($section);119 }120 $this->layoutTempstoreRepository->set($section_storage);121 }122 }123 /**124 * Builds a link to add a new section at a given delta.125 *126 * @param \Drupal\layout_builder\SectionStorageInterface $section_storage127 * The section storage.128 * @param int $delta129 * The delta of the section to splice.130 *131 * @return array132 * A render array for a link.133 */134 protected function buildAddSectionLink(SectionStorageInterface $section_storage, $delta) {135 $storage_type = $section_storage->getStorageType();136 $storage_id = $section_storage->getStorageId();137 return [138 'link' => [139 '#type' => 'link',140 '#title' => $this->t('Add Section'),141 '#url' => Url::fromRoute('layout_builder.choose_section',142 [143 'section_storage_type' => $storage_type,144 'section_storage' => $storage_id,145 'delta' => $delta,146 ],147 [148 'attributes' => [149 'class' => ['use-ajax', 'add-section__link'],150 'data-dialog-type' => 'dialog',151 'data-dialog-renderer' => 'off_canvas',152 ],153 ]154 ),155 ],156 '#type' => 'container',157 '#attributes' => [158 'class' => ['add-section'],159 ],160 ];161 }162 /**163 * Builds the render array for the layout section while editing.164 *165 * @param \Drupal\layout_builder\SectionStorageInterface $section_storage166 * The section storage.167 * @param int $delta168 * The delta of the section.169 *170 * @return array171 * The render array for a given section.172 */173 protected function buildAdministrativeSection(SectionStorageInterface $section_storage, $delta) {174 $storage_type = $section_storage->getStorageType();175 $storage_id = $section_storage->getStorageId();176 $section = $section_storage->getSection($delta);177 $layout = $section->getLayout();178 $build = $section->toRenderArray($this->getAvailableContexts($section_storage), TRUE);179 $layout_definition = $layout->getPluginDefinition();180 foreach ($layout_definition->getRegions() as $region => $info) {181 if (!empty($build[$region])) {182 foreach ($build[$region] as $uuid => $block) {183 $build[$region][$uuid]['#attributes']['class'][] = 'draggable';184 $build[$region][$uuid]['#attributes']['data-layout-block-uuid'] = $uuid;185 $build[$region][$uuid]['#contextual_links'] = [186 'layout_builder_block' => [187 'route_parameters' => [188 'section_storage_type' => $storage_type,189 'section_storage' => $storage_id,190 'delta' => $delta,191 'region' => $region,192 'uuid' => $uuid,193 ],194 ],195 ];196 }197 }198 $build[$region]['layout_builder_add_block']['link'] = [199 '#type' => 'link',200 '#title' => $this->t('Add Block'),201 '#url' => Url::fromRoute('layout_builder.choose_block',202 [203 'section_storage_type' => $storage_type,204 'section_storage' => $storage_id,205 'delta' => $delta,206 'region' => $region,207 ],208 [209 'attributes' => [210 'class' => ['use-ajax', 'add-block__link'],211 'data-dialog-type' => 'dialog',212 'data-dialog-renderer' => 'off_canvas',213 ],214 ]215 ),216 ];217 $build[$region]['layout_builder_add_block']['#type'] = 'container';218 $build[$region]['layout_builder_add_block']['#attributes'] = ['class' => ['add-block']];219 $build[$region]['layout_builder_add_block']['#weight'] = 1000;220 $build[$region]['#attributes']['data-region'] = $region;221 $build[$region]['#attributes']['class'][] = 'layout-builder--layout__region';222 }223 $build['#attributes']['data-layout-update-url'] = Url::fromRoute('layout_builder.move_block', [224 'section_storage_type' => $storage_type,225 'section_storage' => $storage_id,226 ])->toString();227 $build['#attributes']['data-layout-delta'] = $delta;228 $build['#attributes']['class'][] = 'layout-builder--layout';229 return [230 '#type' => 'container',231 '#attributes' => [232 'class' => ['layout-section'],233 ],234 'configure' => [235 '#type' => 'link',236 '#title' => $this->t('Configure section'),237 '#access' => $layout instanceof PluginFormInterface,238 '#url' => Url::fromRoute('layout_builder.configure_section', [239 'section_storage_type' => $storage_type,240 'section_storage' => $storage_id,241 'delta' => $delta,242 ]),243 '#attributes' => [244 'class' => ['use-ajax', 'configure-section'],245 'data-dialog-type' => 'dialog',246 'data-dialog-renderer' => 'off_canvas',247 ],248 ],249 'remove' => [250 '#type' => 'link',251 '#title' => $this->t('Remove section'),252 '#url' => Url::fromRoute('layout_builder.remove_section', [253 'section_storage_type' => $storage_type,254 'section_storage' => $storage_id,255 'delta' => $delta,256 ]),257 '#attributes' => [258 'class' => ['use-ajax', 'remove-section'],259 'data-dialog-type' => 'dialog',260 'data-dialog-renderer' => 'off_canvas',261 ],262 ],263 'layout-section' => $build,264 ];265 }266 /**267 * Saves the layout.268 *269 * @param \Drupal\layout_builder\SectionStorageInterface $section_storage270 * The section storage.271 *272 * @return \Symfony\Component\HttpFoundation\RedirectResponse273 * A redirect response.274 */275 public function saveLayout(SectionStorageInterface $section_storage) {276 $section_storage->save();277 $this->layoutTempstoreRepository->delete($section_storage);278 if ($section_storage instanceof OverridesSectionStorageInterface) {279 $this->messenger->addMessage($this->t('The layout override has been saved.'));280 }281 else {282 $this->messenger->addMessage($this->t('The layout has been saved.'));283 }284 return new RedirectResponse($section_storage->getRedirectUrl()->setAbsolute()->toString());285 }286 /**287 * Cancels the layout.288 *289 * @param \Drupal\layout_builder\SectionStorageInterface $section_storage290 * The section storage.291 *292 * @return \Symfony\Component\HttpFoundation\RedirectResponse293 * A redirect response.294 */295 public function cancelLayout(SectionStorageInterface $section_storage) {296 $this->layoutTempstoreRepository->delete($section_storage);297 $this->messenger->addMessage($this->t('The changes to the layout have been discarded.'));298 return new RedirectResponse($section_storage->getRedirectUrl()->setAbsolute()->toString());299 }300}...

Full Screen

Full Screen

add

Using AI Code Generation

copy

Full Screen

1$storage->add($key, $value, $ttl);2$storage->get($key);3$storage->remove($key);4$storage->clear();5$storage->has($key);6$storage->getKeys();7$storage->getValues();8$storage->getTTL($key);9$storage->setTTL($key, $ttl);10$storage->getMetadata($key);11$storage->setMetadata($key, $metadata);12$storage->getMetadatas();13$storage->setMetadatas($metadatas);14$storage->getCapacity();15$storage->setCapacity($capacity);16$storage->getRemaining();17$storage->isFull();18$storage->isPersistent();19$storage->getDriver();

Full Screen

Full Screen

add

Using AI Code Generation

copy

Full Screen

1$storage = new Storage();2$storage->add("one",1);3$storage->add("two",2);4$storage->add("three",3);5$storage->add("four",4);6$storage->add("five",5);7$storage->add("six",6);8$storage->add("seven",7);9$storage->add("eight",8);10$storage->add("nine",9);11$storage->add("ten",10);12$storage->add("eleven",11);13$storage->add("twelve",12);14$storage->add("thirteen",13);15$storage->add("fourteen",14);16$storage->add("fifteen",15);17$storage->add("sixteen",16);18$storage->add("seventeen",17);19$storage->add("eighteen",18);20$storage->add("nineteen",19);21$storage->add("twenty",20);22$storage->add("twentyone",21);23$storage->add("twentytwo",22);24$storage->add("twentythree",23);25$storage->add("twentyfour",24);26$storage->add("twentyfive",25);27$storage->add("twentysix",26);28$storage->add("twentyseven",27);29$storage->add("twentyeight",28);30$storage->add("twentynine",29);31$storage->add("thirty",30);32$storage->add("thirtyone",31);33$storage->add("thirtytwo",32);34$storage->add("thirtythree",33);35$storage->add("thirtyfour",34);36$storage->add("thirtyfive",35);37$storage->add("thirtysix",36);38$storage->add("thirtyseven",37);39$storage->add("thirtyeight",38);40$storage->add("thirtynine",39);41$storage->add("forty",40);42$storage->add("fortyone",41);43$storage->add("fortytwo",42);44$storage->add("fortythree",43);45$storage->add("fortyfour",44);46$storage->add("fortyfive",45);47$storage->add("fortysix",46);48$storage->add("fortyseven",47);49$storage->add("fortyeight

Full Screen

Full Screen

add

Using AI Code Generation

copy

Full Screen

1$storage->add('foo', 'bar');2$storage->get('foo');3$storage->delete('foo');4$storage->has('foo');5$storage->clear();6$storage->count();7$storage->add('foo', 'bar');8$storage->get('foo');9$storage->delete('foo');10$storage->has('foo');11$storage->clear();12$storage->count();13$storage->add('foo', 'bar');14$storage->get('foo');15$storage->delete('foo');16$storage->has('foo');17$storage->clear();18$storage->count();19$storage->add('foo', 'bar');20$storage->get('foo');21$storage->delete('foo');22$storage->has('foo');23$storage->clear();24$storage->count();25$storage->add('foo', 'bar');26$storage->get('foo');27$storage->delete('foo');28$storage->has('foo');

Full Screen

Full Screen

add

Using AI Code Generation

copy

Full Screen

1$storage->add('key','value');2$storage->get('key');3$storage->add('key','value');4$storage->get('key');5$storage->add('key','value');6$storage->get('key');7$storage->add('key','value');8$storage->get('key');9$storage->add('key','value');10$storage->get('key');11$storage->add('key','value');12$storage->get('key');13$storage->add('key','value');14$storage->get('key');15$storage->add('key','value');16$storage->get('key');17$storage->add('key','value');18$storage->get('key');19$storage->add('key','value');

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger add code on LambdaTest Cloud Grid

Execute automation tests with add on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful