class HeartbeatService in Heartbeat 8
Class HeartbeatService.
@package Drupal\heartbeat
Hierarchy
- class \Drupal\heartbeat\HeartbeatService
Expanded class hierarchy of HeartbeatService
11 files declare their use of HeartbeatService
- HeartbeatBlock.php in src/
Plugin/ Block/ HeartbeatBlock.php - HeartbeatBlockDeriver.php in src/
Plugin/ Derivative/ HeartbeatBlockDeriver.php - HeartbeatEventSubscriber.php in src/
EventSubscriber/ HeartbeatEventSubscriber.php - HeartbeatFeedBlock.php in src/
Plugin/ Block/ HeartbeatFeedBlock.php - HeartbeatFeedForm.php in src/
Form/ HeartbeatFeedForm.php
1 string reference to 'HeartbeatService'
1 service uses HeartbeatService
File
- src/
HeartbeatService.php, line 12
Namespace
Drupal\heartbeatView source
class HeartbeatService {
/**
* Drupal\Core\Entity\EntityTypeManager definition.
*
* @var \Drupal\Core\Entity\EntityTypeManager
*/
protected $entityTypeManager;
/**
* Drupal\Core\Entity\Query\QueryFactory definition.
*
* @var \Drupal\Core\Entity\Query\QueryFactory
*/
protected $entityQuery;
/**
* Constructor.
* @param EntityTypeManager $entity_type_manager
* @param QueryFactory $entity_query
*/
public function __construct(EntityTypeManager $entity_type_manager, QueryFactory $entity_query) {
$this->entityTypeManager = $entity_type_manager;
$this->entityQuery = $entity_query;
}
public function loadAll() {
$entities = $this->entityQuery
->get("heartbeat")
->execute();
return $this->entityTypeManager
->getStorage("heartbeat")
->loadMultiple($entities);
}
public function load($id) {
return $this->entityTypeManager
->getStorage("heartbeat")
->load($id);
}
public function loadByType($type) {
return $this->entityTypeManager
->getStorage("heartbeat")
->loadMultiple($this->entityQuery
->get('heartbeat')
->condition('type', $type)
->execute());
}
public function loadByTypes($types) {
return $this->entityTypeManager
->getStorage("heartbeat")
->loadMultiple($this->entityQuery
->get('heartbeat')
->condition('type', $types, 'IN')
->sort('created', 'DESC')
->execute());
}
public function loadByNid($nid) {
return $this->entityTypeManager
->getStorage('heartbeat')
->load($this->entityQuery
->get('heartbeat')
->condition('nid', $nid)
->sort('created', 'DESC')
->execute());
}
public function loadByUid($uid) {
$hid = $this->entityQuery
->get('heartbeat')
->condition('uid', $uid)
->condition('status', 1)
->sort('created', 'DESC')
->range(0, 1)
->execute();
return $this->entityTypeManager
->getStorage('heartbeat')
->load(array_values($hid)[0]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HeartbeatService:: |
protected | property | Drupal\Core\Entity\Query\QueryFactory definition. | |
HeartbeatService:: |
protected | property | Drupal\Core\Entity\EntityTypeManager definition. | |
HeartbeatService:: |
public | function | ||
HeartbeatService:: |
public | function | ||
HeartbeatService:: |
public | function | ||
HeartbeatService:: |
public | function | ||
HeartbeatService:: |
public | function | ||
HeartbeatService:: |
public | function | ||
HeartbeatService:: |
public | function | Constructor. |