By admin, 11 July, 2024 Inject StreamWrapperManager use Drupal\Core\StreamWrapper\StreamWrapperManager; /** * The Stream Wrapper Manager. */ protected StreamWrapperManager $streamWrapperManager; /** * {@inheritdoc} */ public Tags dependency injection
By admin, 25 June, 2024 Use DeprecationHelper for compatibility Call to deprecated method renderPlain() of class Drupal\Core\Render\Renderer in drupal:10.3.0 and is removed from drupal:12.0.0. Tags deprecation
By admin, 25 June, 2024 Phpstan: ignore some identifier // @phpstan-ignore class.notFound Tags phpstan
By admin, 1 May, 2024 Add css class to body with node type /** * Implements hook_preprocess_HOOK(). */ function MYTHEME_preprocess_html(&$variables) { /** @var \Drupal\node\Entity\NodeType $node_type_entity */ $node_type_entity = \Drupal::routeMatch()->getParameter('node_type'); if ($node_type_entit Tags preprocess
By admin, 1 May, 2024 Attach photoswipe library to form $form['#attached']['library'][] = 'photoswipe/photoswipe.init'; $template = ['#theme' => 'photoswipe_container']; $form['#attached']['drupalSettings']['photoswipe']['container'] = \Drupal::service('renderer')->renderP Tags form photoswipe
By admin, 5 April, 2024 Drupal Commerce 2 on paid event <?php declare(strict_types=1); namespace Drupal\MYMODULE\EventSubscriber; use Drupal\commerce_order\Event\OrderEvent; Tags commerce event
By admin, 4 April, 2024 Override admin template defined in a contrib module /** * Implements hook_theme(). */ function MY_MODULE_theme($existing, $type, $theme, $path) { return [ 'commerce_order__admin' => [ 'template' => 'commerce-order--admin-custom', ], ]; } Tags template theme
By admin, 3 April, 2024 Inject TimeInterface use Drupal\Component\Datetime\TimeInterface; /** * The controller constructor. */ public function __construct( private readonly TimeInterface $datetimeTime, ) {} Tags dependency injection
By admin, 28 March, 2024 Install partial config drush config-import --partial --source=modules/custom/MYMODULE/config/install/ Tags config drush
By admin, 28 March, 2024 Convert date to another format $new_date = date('d.m.Y', strtotime($existing_date)); Tags date php