Loading cloud.routing.yml +9 −0 Changes for cloud.routing.yml: 9 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -282,6 +282,15 @@ entity.cloud_store.list_update: type: 'entity:cloud_store_type' converter: 'paramconverter.entity' # Clour Store REST API. entity.cloud_store.entity.count: path: '/cloud_dashboard/{entity_type_id}/entity/count' defaults: _controller: '\Drupal\cloud\Controller\CloudStoreController::getEntityCount' methods: [GET] requirements: _permission: 'list cloud store' # Cloud Admin Settings. cloud.settings: path: '/admin/config/services/cloud/settings' Loading src/Controller/CloudStoreController.php +21 −0 Changes for src/Controller/CloudStoreController.php: 21 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Route; /** Loading Loading @@ -329,4 +330,24 @@ class CloudStoreController extends ControllerBase implements ContainerInjectionI return AccessResult::neutral(); } /** * Get count of Cloud Store Resources. * * @param string $bundle * The bundle ID. * * @return \Symfony\Component\HttpFoundation\JsonResponse * The JSON response. */ public function getEntityCount(string $bundle): JsonResponse { $ids = $this->entityTypeManager() ->getStorage('cloud_store') ->getQuery() ->accessCheck(TRUE) ->condition('type', $bundle) ->execute(); return new JsonResponse(['count' => count($ids)]); } } Loading
cloud.routing.yml +9 −0 Changes for cloud.routing.yml: 9 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -282,6 +282,15 @@ entity.cloud_store.list_update: type: 'entity:cloud_store_type' converter: 'paramconverter.entity' # Clour Store REST API. entity.cloud_store.entity.count: path: '/cloud_dashboard/{entity_type_id}/entity/count' defaults: _controller: '\Drupal\cloud\Controller\CloudStoreController::getEntityCount' methods: [GET] requirements: _permission: 'list cloud store' # Cloud Admin Settings. cloud.settings: path: '/admin/config/services/cloud/settings' Loading
src/Controller/CloudStoreController.php +21 −0 Changes for src/Controller/CloudStoreController.php: 21 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Route; /** Loading Loading @@ -329,4 +330,24 @@ class CloudStoreController extends ControllerBase implements ContainerInjectionI return AccessResult::neutral(); } /** * Get count of Cloud Store Resources. * * @param string $bundle * The bundle ID. * * @return \Symfony\Component\HttpFoundation\JsonResponse * The JSON response. */ public function getEntityCount(string $bundle): JsonResponse { $ids = $this->entityTypeManager() ->getStorage('cloud_store') ->getQuery() ->accessCheck(TRUE) ->condition('type', $bundle) ->execute(); return new JsonResponse(['count' => count($ids)]); } }