One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
/* Setting up codebase */ | |
mkdir d7d8mod | |
cd d7d8mod | |
ddev config | |
ddev start | |
ddev composer create drupal/recommended-project | |
cp web/sites/default/default.settings.php web/sites/default/settings.php | |
ddev config | |
ddev restart | |
ddev . drush site-install --account-pass=admin |
<?php | |
$date = DrupalDateTime::createFromFormat(DATETIME_DATETIME_STORAGE_FORMAT, 'datetime string', DATETIME_STORAGE_TIMEZONE); | |
$date->setTimeZone(new DateTimeZone(drupal_get_user_timezone())); | |
$date->format('d.m.Y H:i'); |
$image = \Drupal::service('image.factory')->get($file->getFileUri()); | |
$image_style = \Drupal\image\Entity\ImageStyle::load('gallery_large'); | |
// Set source image dimensions. | |
$dimensions = [ | |
'width' => $image->getWidth(), | |
'height' => $image->getHeight(), | |
]; | |
// After calling this, the $dimensions array will contain new dimensions. | |
$image_style->transformDimensions($dimensions, $file->getFileUri()); |
<?php | |
namespace Drupal\flysystem_s3; | |
use Aws\CacheInterface; | |
use Drupal\Core\Cache\CacheBackendInterface; | |
/** | |
* A Drupal cache adapter for use with the AWS PHP SDK. | |
*/ |
/** | |
* Implements hook_file_insert(). | |
*/ | |
public function postSave(EntityStorageInterface $storage, $update = TRUE) { | |
parent::postSave($storage, $update); | |
// Save file metadata. | |
if (!empty($this->metadata)) { | |
if ($update) { | |
db_delete('file_metadata')->condition('fid', $this->id())->execute(); | |
} |
This section is for your verification before submitting a PR. Remove this before submitting:
Git hooks need to have executable file permissions. If one isn't running for you, try:
chmod -R 755 .git/hooks/YOURHOOKNAME
<?php | |
// By term tids | |
$query = \Drupal::entityQuery('node') | |
->condition('type', 'YOUR_NODE_TYPE') | |
->condition('status', 1) | |
->condition('field_TERMFIELDNAME.entity.tid', $array_of_tids, 'IN'); | |
$nids = $query->execute(); | |
// By term names |
// Drupal 7 | |
if (path_is_admin(current_path())) { | |
// Do stuff on admin pages. | |
} | |
// Drupal 8 | |
$is_admin = \Drupal::service('router.admin_context')->isAdminRoute(); | |
if (!$is_admin) { | |
// Do stuff on admin pages. | |
} |