Skip to content

Instantly share code, notes, and snippets.

View Oleksii909's full-sized avatar
👍
Focusing on drupal

Oleksii Bondarenko Oleksii909

👍
Focusing on drupal
View GitHub Profile
package mac
import (
"context"
"fmt"
"log"
"network-chesswork/utilities"
"os"
"os/signal"
"sync"
🌞 Morning 74 commits ████████▏░░░░░░░░░░░░ 38.7%
🌆 Daytime 42 commits ████▌░░░░░░░░░░░░░░░░ 22.0%
🌃 Evening 11 commits █▏░░░░░░░░░░░░░░░░░░░ 5.8%
🌙 Night 64 commits ███████░░░░░░░░░░░░░░ 33.5%
@Oleksii909
Oleksii909 / Drupal8HorizontalTabs.php
Created May 19, 2023 07:35 — forked from normanlolx/Drupal8HorizontalTabs.php
How to create horizontal tabs programmatically in Drupal 8, requires Field Group module
<?php
// How to create horizontal tabs programmatically in Drupal 8, requires Field Group module
$form = array();
$form['my_field'] = array(
'#type' => 'horizontal_tabs',
'#tree' => TRUE,
'#prefix' => '<div id="unique-wrapper">',
'#suffix' => '</div>',
);
$items = array(
@Oleksii909
Oleksii909 / SiteLogoBlock.php
Created July 29, 2021 08:40 — forked from normanlolx/SiteLogoBlock.php
Drupal 8 file upload block
<?php
namespace Drupal\mymodule\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\file\Entity\File;
use Drupal\file\FileUsage\FileUsageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@Oleksii909
Oleksii909 / ImageRenderExampleBlockByURI.php
Created July 28, 2021 15:26 — forked from jerbob92/ImageRenderExampleBlockByURI.php
Render image into a block Drupal 8 Example by URI
<?php
/**
* @file
* Contains Drupal\mymodule\Plugin\Block\ImageRenderExampleBlockByURI.
*/
namespace Drupal\mymodule\Plugin\Block;
use Drupal\Core\Block\BlockBase;
@Oleksii909
Oleksii909 / Blocks.md
Created December 12, 2020 16:55 — forked from bdlangton/Blocks.md
Drupal 8 programmatic solutions

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

$block_manager = \Drupal::service('plugin.manager.block');
// Enable Devel module and go to /devel/php
$nodes = \Drupal::entityQuery("node")
->condition('created', strtotime('-30 days'), '<=')
->execute();
$storage_handler = \Drupal::entityTypeManager()->getStorage("node");
// $entities = $storage_handler->loadMultiple(); // Delete ALL nodes.
$entities = $storage_handler->loadMultiple($nodes);
$storage_handler->delete($entities);