cacheflush-8.x-1.x-dev/modules/cacheflush_entity/cacheflush_entity.module

modules/cacheflush_entity/cacheflush_entity.module
<?php

/**
 * @file
 * Cacheflush Entity API.
 */

/**
 * Constructs a new entity object, without permanently saving it.
 *
 * @param array $values
 *   Values of the entity to be created.
 *
 * @return object
 *   New cacheflush entity.
 *
 * @throws \Exception
 *   Throws exception if exists.
 */
function cacheflush_create(array $values = []) {
  return \Drupal::entityTypeManager()
    ->getStorage('cacheflush')
    ->create($values);
}

/**
 * Loads cacheflush entity by ID.
 *
 * @param mixed $id
 *   The entity ID to be loaded.
 *
 * @return null||\Drupal\Core\Entity\EntityInterface
 *   The entity object or NULL if there is no entity with the given ID.
 *
 * @throws \Exception
 *   Throws exception if exists.
 */
function cacheflush_load($id) {
  return \Drupal::entityTypeManager()->getStorage('cacheflush')->load($id);
}

/**
 * Loads multiple cacheflush entities from the database.
 *
 * @param array $ids
 *   (optional) An array of entity IDs. If omitted, all entities are loaded.
 *
 * @return null||array\Drupal\Core\Entity\EntityInterface
 *   An array of entity objects indexed by their IDs.
 *   Returns an empty array if no matching entities are found.
 *
 * @throws \Exception
 *   Throws exception if exists.
 */
function cacheflush_load_multiple(array $ids = NULL) {
  return \Drupal::entityTypeManager()
    ->getStorage('cacheflush')
    ->loadMultiple($ids);
}

/**
 * Load entities by their property values.
 *
 * @param array $values
 *   An associative array where the keys are the property names and the
 *   values are the values those properties must have.
 *
 * @return null||array\Drupal\Core\Entity\EntityInterface
 *   An array of entity objects indexed by their ids.
 *
 * @throws \Exception
 *   Throws exception if exists.
 */
function cacheflush_load_multiple_by_properties(array $values = []) {
  return \Drupal::entityTypeManager()
    ->getStorage('cacheflush')
    ->loadByProperties($values);
}

/**
 * Deletes a single entity by ID.
 *
 * @param mixed $id
 *   The ID of entity to be deleted.
 *
 * @throws \Exception
 *   Throws exception if exists.
 */
function cacheflush_delete($id) {
  $controller = \Drupal::entityTypeManager()->getStorage('cacheflush');
  $entities = $controller->load($id);
  $entities->delete();
}

/**
 * Deletes all entities from ID list.
 *
 * @param array $ids
 *   The list of entity IDs.
 *
 * @throws \Exception
 *   Throws exception if exists.
 */
function cacheflush_delete_multiple(array $ids) {
  $controller = \Drupal::entityTypeManager()->getStorage('cacheflush');
  $entities = $controller->loadMultiple($ids);
  $controller->delete($entities);
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc