123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace Drupal\heartbeat;
- use Drupal\Core\Entity\ContentEntityType;
- use Drupal\Core\Entity\EntityTypeManager;
- use Drupal\Core\Entity\EntityTypeBundleInfo;
- use Drupal\Core\Entity\Query\QueryFactory;
- class HeartbeatTypeServices {
-
- protected $entityTypeManager;
-
- protected $entityTypeBundleInfo;
-
- protected $entityQuery;
-
- public function __construct(EntityTypeManager $entityTypeManager, EntityTypeBundleInfo $entityTypeBundleInfo, QueryFactory $entity_query) {
- $this->entityTypeManager = $entityTypeManager;
- $this->entityTypeBundleInfo = $entityTypeBundleInfo;
- $this->entityQuery = $entity_query;
- }
- public function getTypes() {
- return $this->entityQuery->get('heartbeat_type')->sort('weight', 'ASC')->execute();
- }
- public function load($id) {
- return $this->entityTypeManager->getStorage('heartbeat_type')->load($id);
- }
- public function getEntityBundles(ContentEntityType $entity) {
- return $this->entityTypeBundleInfo->getBundleInfo($entity->id());
- }
- }
|