php
You have a private files folder. The path could be set in settings.php like this:
settings.php
$settings['file_private_path'] = $app_root . '/../private_files/files';
Git status tells you the private files folder is untracked and you want to prevent data loss. This could be achieved by ignoring the folder in gitignore.
.gitignore
# Ignore private_files
/private_files/
05.05.2026 | Michael Ebert
Ignore private files folder in .gitignore and set the path in settings.php
settings-stage.php
/**
* Send mails via php_mail
*/
$config['system.mail']['interface']['default'] = 'php_mail';
01.03.2024 | Michael Ebert
Environment based mail handler override in settings.php
Breadcrumb_builder_custom.php
/**
* {@inheritdoc}
*/
public function applies(RouteMatchInterface $route_match) {
return $route_match->getRouteName() == 'commerce_cart.page';
}
/**
* {@inheritdoc}
*/
public function build(RouteMatchInterface $route_match) {
// Node ID from shop
$node = $this->entityTypeManager->getStorage('node')->load(3337);
$breadcrumb = new Breadcrumb();
$breadcrumb->addLink(Link::createFromRoute($this->t('Home'), '<front>'));
$breadcrumb->addLink(Link::fromTextAndUrl($node->getTitle(), $node->toUrl()));
return $breadcrumb;
}
10.07.2025 | Lothar Ferreira Neumann, Mathias Grab
Manipulate breadcrumbs with custom logic
clear_cache.php
<?php
apcu_clear_cache();
opcache_reset();
13.11.2025 | Nikolas Kopp
Clear APC & Opcache
PipelineWebhookEventResource.php
$event = new PipelineEvent($data, $project);
$this->eventDispatcher->dispatch($event, 'webhook');
$this->eventDispatcher->dispatch($event, 'webhook.' . $event->type());
$this->eventDispatcher->dispatch($event, 'webhook.' . $event->type() . '.' . $event->status());
01.04.2025 | Marc Hitscherich, Dominik Wille
Dispatch multiple pipeline events based on more specific contexts
SomeClass.php
// Cache per scope.
$build['#cache']['keys'][] = $this->scope;
25.08.2023 | Dominik Wille
Drupal cache keys - cache items per specified value
RouteSubscriber.php
<?php
namespace Drupal\scp_base\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
// Make sure profile pages are not admin pages, in order to load the right
// translation.
if ($route = $collection->get('profile.user_page.single')) {
$route->setOption('_admin_route', FALSE);
}
}
}
13.11.2025 | Pascal Crott
Prevent the user profile from being displayed in backend theme using RouteSubscriber
RouteSubscriber.php
<?php
namespace Drupal\layout_builder_collapse_categories\Routing;
use Drupal\Core\Routing\RoutingEvents;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
use Drupal\layout_builder_collapse_categories\Controller\ChooseBlockController;
/**
* Override the controller for layout_builder.move_block.
*/
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[RoutingEvents::ALTER] = ['onAlterRoutes', -1000];
return $events;
}
/**
* {@inheritdoc}
*/
public function alterRoutes(RouteCollection $collection) {
// Add a decorator for the choose_block conroller
if ($route = $collection->get('layout_builder.choose_block')) {
$defaults = $route->getDefaults();
$route->setOption('original_controller', substr($defaults['_controller'], 0, strpos($defaults['_controller'], '::')));
$defaults['_controller'] = ChooseBlockController::class . '::build';
$route->setDefaults($defaults);
}
}
}
ChooseBlockController.php
<?php
namespace Drupal\layout_builder_collapse_categories\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\layout_builder\SectionStorageInterface;
use Drupal\Core\Controller\ControllerResolverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ChooseBlockController extends ControllerBase {
/**
* The original ChooseBlockController
*
* @var \Drupal\layout_builder\Controller\ChooseBlockController $originalController
*/
protected $originalController;
/**
* @param \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver
*/
public function __construct(ControllerResolverInterface $controller_resolver, RouteMatchInterface $route_match) {
$original_controller_class = $route_match->getRouteObject()->getOption('original_controller');
$this->originalController = $controller_resolver->getControllerFromDefinition($original_controller_class);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('controller_resolver'),
$container->get('current_route_match')
);
}
public function build(SectionStorageInterface $section_storage, $delta, $region) {
$build = $this->originalController->build($section_storage, $delta, $region);
foreach ($build['block_categories'] as &$category) {
if (isset($category['#open'])) {
$category['#open'] = FALSE;
}
}
return $build;
}
}
16.07.2026 | Dominik Wille
Controller decorator
If you want to extend a class with static methods, don't use self:: since it will scope the static method to the extended class.
FooElement.php
// $options = self::getPluginOptions($element)
$options = static::getPluginOptions($element)
10.03.2023 | Fabian Alleblas, Dominik Wille