$query = \Drupal::entityQuery('node');
$new_articles = $query->condition('type', 'article')
->condition('status', 1) // Only return the newest 10 articles
->sort('created', 'DESC')
->pager(10)
->execute();
$not_quite_as_new_articles = $query->condition('type', 'article')
->condition('status', 1) // Only return the next newest 10 articles
->sort('created', 'DESC')
->range(10, 10)
->execute();
$query = \Drupal::entityQuery('user');
$time = time();
$yesterday = $time - 60*60*24;
$new_user_count = $query->condition('created', $yesterday, '>=')
->count()
->execute();
$query = \Drupal::entityQuery('user');
$time = time();
$yesterday = $time - 60*60*24;
$new_users = $query->condition('created', $yesterday, '>=')
->sort('created', 'DESC')
->execute();
$query = \Drupal::entityQuery('node');
$untagged_articles = $query->condition('type', 'article')
->notExists('field_tags')
->execute();
$query = \Drupal::entityQuery('node');
$query = \Drupal::service('entity.query');
// To get a list of published articles
$node_ids = $query->get('node')
->condition('type', 'article')
->condition('status', 1)
->execute();
// To find all users with the Administrator role.
$admin_user_ids = $query->get('user')
->condition('roles', 'Administrator', 'CONTAINS')
->execute();
$fid = 36; // File Id value
$file_storage = \Drupal::entityTypeManager()->getStorage('file');
$file = $file_storage->load($fid);
$query = \Drupal::entityQuery('node')
->condition('type', 'article'),
->condition('field_foo', 'bar');
$nids = $query->execute();
$nodes = $node_storage->loadMultiple($nids);
foreach ($nodes as $n) {
echo $n->title->value; // "titles"
// do whatever you would do with a node object (set fields, save, etc.)
$n->set('title', "Test Title");
$n->save();
}
$nid =36; // node id
$node_storage = \Drupal::entityTypeManager()->getStorage('node');
$node = $node_storage->load($nid);
echo $node->id(); // 36
Get the list of outdated modules:
composer outdated "drupal/*"
Install module update:
composer update drupal/module_name --with-dependencies
Then, run the database updates /update.php & Clear the drupal cache :)
Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleSet Generator.php
php.ini and set memory limit
memory_limit=-1
Problem solved :)
Instagram Without API
Could not reach Instagram server
Recent comments
$host =…