We’re rewarding the question askers & reputations are being recalculated! Read more.
6

The created date is stored in the node_field_data table as a UNIX timestamp in a cloumn called created. Here's the code you would use to fetch the nodes that has been created X days ago, using a direct select query. $day = 86400; // One day in seconds. $days = 3; // The amount of days ago to fetch from. $nids = \Drupal::database()->select('...


3

If you go into your Drupal database you should find a table called 'node_field_data'. In this table there is a column labeled 'created'. That will be your Unix timestamp for when the node was created.


3

hook_entity_presave() is called for every entity being saved which means that, since that hook_entity_presave() implementation is saving an entity, it is being invoked twice. Using method_exists() is generally wrong, as in PHP is generally preferable to check if the object is an instance of a class implementing an interface or a class extending another ...


2

hook_entity_presave() runs when any entity is inserted or saved; thus, it runs twice in your case, since you have a Node and a Webform entity being saved. You would have to add a conditional to check the entity type as @berramou's answer suggests. Alternatively, you could use hook_ENTITY_TYPE_presave() and target the node. /* * Implements ...


2

If you want the hook_entity_presave() to only focus on nodes and not on webforms, you can check the entity type like in the following code. /** * Implements hook_entity_presave(). */ function YourModule_entity_presave(Drupal\Core\Entity\EntityInterface $entity) { if ($entity->getEntityTypeId() == 'node') { // Do you webform creation code here ...


1

To get the full objects in your twig file, you could have done this: $ids = \Drupal::entityQuery('chemical') ->condition('tid', $tid) ->execute(); $controller = \Drupal::entityManager()->getStorage('chemical'); $entities = $controller->loadMultiple($ids); $output[] = [ '#theme' => 'chemical_taxonomy', '#chemicals' => $entities, ]; ...


Only top voted, non community-wiki answers of a minimum length are eligible