By kenneth, Fri, 04/01/2022 - 15:21

Prob. there are better ways or alternatives, but the next way works for me!

A route definition:

keboca.another_route:
  path: '/something/else'
  defaults:
    uri: '/valid_uri'
    _controller: '\Drupal\keboca\Controller\KController::forward'

The trick happens here:

By kenneth, Mon, 02/28/2022 - 12:02
gitback() {
 BRANCH_NAME=${1:-$(git branch --show-current)}

 git checkout  dev &&
 git pull origin dev &&
 git remote prune origin &&
 git branch -D "$BRANCH_NAME" &&
 git remote show origin &&
 git status
}

alias git-back='gitback'

 

By kenneth, Fri, 12/03/2021 - 09:14

function findAspectRatio(int $width, int $height) {
  // search for greatest common divisor
  $greatestCommonDivisor = static function ($width, $height) use (&$greatestCommonDivisor) {
    return ($width % $height) ? $greatestCommonDivisor($height, $width % $height) : $height;
  };

  $divisor = $greatestCommonDivisor($width, $height);

  return $width / $divisor . ':' . $height / $divisor;
}

 

By kenneth, Mon, 11/08/2021 - 11:14
(function ($, Drupal, drupalSettings) {
   'use strict';  
    
   Drupal.behaviors.my_behavior =  {
    attach: function (context, settings) {
      $(document, context).once('my_behavior').each( function() {
        myInit();
      });
    }
  }
} (jQuery, Drupal, drupalSettings));

 

By kenneth, Wed, 09/09/2020 - 11:21
$node = \Drupal::routeMatch()->getParameter('node');
if ($node instanceof \Drupal\node\NodeInterface) {
  $nid = $node->id();
}

 

By kenneth, Mon, 09/07/2020 - 10:04

Few months ago I wrote an article about an implementation over a D7 site I was working on. A friend of mine told me, "Hey, D7 is dead already, why are you still doing those projects".