Skip to content

Commit

Permalink
Added LanguageLimitationController
Browse files Browse the repository at this point in the history
  • Loading branch information
ciastektk committed Sep 1, 2023
1 parent a58190d commit 48b235a
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/bundle/Controller/Permission/LanguageLimitationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Bundle\AdminUi\Controller\Permission;

use Ibexa\AdminUi\Permission\PermissionLimitationResolverInterface;
use Ibexa\Contracts\AdminUi\Controller\Controller;
use Ibexa\Contracts\Core\Repository\ContentService;
use Ibexa\Contracts\Core\Repository\LocationService;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;

final class LanguageLimitationController extends Controller
{
private ContentService $contentService;

private LocationService $locationService;

private PermissionLimitationResolverInterface $permissionLimitationResolver;

public function __construct(
ContentService $contentService,
LocationService $locationService,
PermissionLimitationResolverInterface $permissionLimitationResolver
) {
$this->contentService = $contentService;
$this->locationService = $locationService;
$this->permissionLimitationResolver = $permissionLimitationResolver;
}

public function loadLanguageLimitationsForContentAction(
int $contentId,
?int $versionId = null,
?int $locationId = null
): Response {
$versionInfo = $this->contentService->loadVersionInfoById($contentId, $versionId);

if (null === $locationId) {
$locationId = $versionInfo->getContentInfo()->getMainLocationId();
}

return new JsonResponse(
$this->permissionLimitationResolver->getLanguageLimitations(
$versionInfo,
$this->locationService->loadLocation($locationId)
)
);
}
}
14 changes: 14 additions & 0 deletions src/bundle/Resources/config/routing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -958,3 +958,17 @@ ibexa.asset.upload_image:
defaults:
_controller: 'Ibexa\Bundle\AdminUi\Controller\AssetController::uploadImageAction'
methods: [POST]

#
# Permissions
#

ibexa.permission.limitation.language:
path: permission/limitation/language/{contentId}/{versionId}/{locationId}
options:
expose: true
defaults:
versionId: null
locationId: null
_controller: 'Ibexa\Bundle\AdminUi\Controller\Permission\LanguageLimitationController::loadLanguageLimitationsForContentAction'
methods: [GET]
6 changes: 6 additions & 0 deletions src/bundle/Resources/config/services/controllers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,9 @@ services:
autowire: true

Ibexa\Bundle\AdminUi\Controller\User\InvitationController: ~

Ibexa\Bundle\AdminUi\Controller\Permission\LanguageLimitationController:
parent: Ibexa\Contracts\AdminUi\Controller\Controller
autowire: true
tags:
- controller.service_arguments

0 comments on commit 48b235a

Please sign in to comment.