This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.parent { display: grid; } | |
.child { grid-area: 1/1; } | |
Instead of: | |
.parent { position: relative } | |
.child { position: absolute; top: 0; left: 0; width: 100%; height: 100% } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\custom_module\Controller; | |
use Drupal\Core\Controller\ControllerBase; | |
use Symfony\Component\DependencyInjection\ContainerInterface; | |
use Drupal\Core\Pager\PagerManagerInterface; | |
class ListNonDrupalItems extends ControllerBase { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This is leading zeros: | |
$n = 10; // The desired end number | |
$numbers = range(1, $n); | |
$numbersWithLeadingZeros = array_map(function ($number) { | |
return sprintf('%02d', $number); | |
}, $numbers); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This should replace the DisplayPracticeTimes function. | |
$startTime = strtotime('08:00'); | |
$endTime = strtotime('21:00'); | |
$increment = 30 * 60; // 30 minutes in seconds | |
$times = array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Load a Node | |
use Drupal\node\Entity\Node; | |
$node = Node::load($nid); | |
// Load Multiple Nodes | |
use Drupal\node\Entity\Node; | |
$nodes = Node::loadMultiple($nids); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Contains various helper functions. | |
*/ | |
use Drupal\taxonomy\Entity\Term; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Token related hook implementations. | |
*/ | |
use Drupal\Core\Render\BubbleableMetadata; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Including a link: | |
$link = Link::fromTextAndUrl($this->t('Bootstrap Documentation'), Url::fromUri('https://getbootstrap.com/docs/3.4/css/#grid-example-mixed-complete', ['attributes' => ['target' => '_blank']]))->toString(); | |
'#description' => $this->t('When this option is selected, clearfix divs will be used to "clear" the columns as needed per device size (see %bootstrap_docs). Please note this option applies only when "Single row" is selected for the "Number of columns per view row" option.', | |
['%bootstrap_docs' => $link]), | |
The most common placeholder is probably @variable. This placeholder runs static::placeholderEscape() on the text before replacing it. | |
You may also use %variable, which runs placeholderEscape() on the text similar to @ placeholders. Using this placeholder will also create <em> tags around the placeholder values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\my_module\Services; | |
use Drupal\Core\Config\ConfigFactory; | |
/** | |
* Class MyService. | |
* | |
* @package Drupal\my_module\Services |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Autoload Url and Link classes. | |
use Drupal\Core\Url; | |
use Drupal\Core\Link; | |
/** | |
* External link | |
*/ | |
$url = Url::fromUri('https://colorfield.be'); |
NewerOlder