$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);
$block_manager = \Drupal::service('plugin.manager.block');
if($node) { | |
// we have a node, so use headline in hero, or fall back to node title | |
if($node->field_hero_section && $node->field_hero_section->getValue() && $node->field_hero_section->getValue()[0]) { | |
$paragraph = $node->field_hero_section->getValue()[0]; | |
$paragraph_entity = \Drupal\paragraphs\Entity\Paragraph::load( $paragraph['target_id'] ); | |
return $paragraph_entity->field_headline->value; | |
} else { | |
return $node->getTitle(); | |
} | |
} |
<?php | |
/** | |
* Set redis configuration. | |
*/ | |
/** @see: https://docs.platform.sh/frameworks/drupal8/redis.html */ | |
if (extension_loaded('redis')) { | |
// Set Redis as the default backend for any cache bin not otherwise specified. | |
// $settings['cache']['default'] = 'cache.backend.redis'; |
<?php | |
/** | |
* Implements hook_form_alter(). | |
*/ | |
function MYMODULE_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { | |
$view_names = array('my_view_name'); | |
$view = $form_state->getStorage('view'); | |
if ($form_id == 'views_exposed_form' && in_array($view['view']->id(), $view_names)) { | |
// Do some shilzzle. |
<?php | |
/** | |
* @file | |
* Contains various helper functions. | |
*/ | |
use Drupal\taxonomy\Entity\Term; | |
/** |
<?php | |
/** | |
* @file | |
* Contains \Drupal\my_contact\Form\ContactForm. | |
*/ | |
namespace Drupal\my_contact\Form; | |
use Drupal\Core\Form\FormBase; | |
use Drupal\Core\Form\FormStateInterface; |
<?php | |
namespace Drupal\my_module\Services; | |
use Drupal\Core\Config\ConfigFactory; | |
/** | |
* Class MyService. | |
* | |
* @package Drupal\my_module\Services |
<?php | |
/** | |
* @file | |
* Defines a dropdown widget for integer fields. | |
*/ | |
namespace Drupal\nba_content_core\Plugin\Field\FieldWidget; | |
use Drupal\Core\Field\FieldFilteredMarkup; | |
use Drupal\Core\Field\FieldItemListInterface; |
<?php | |
use Drupal\file\Entity\File; | |
// public://images/blah.jpg | |
$drupal_file_uri = File::load($fid)->getFileUri(); | |
// /sites/default/files/images/blah.jpg | |
$image_path = file_url_transform_relative(file_create_url($drupal_file_uri)); |