Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
EZP-29742: Implement permissions for Content/Create in Content item v…
…iew (#713) * EZP-29742: Implement permissions for Content/Create in Content item view * EZP-29742: Implement permissions for Content/Create in Content item view - refactor for assign section * EZP-29742: Implement permissions for Content/Create in Content item view - part 1 * EZP-29742: Implement permissions for Content/Create in Content item view - choice loaders * EZP-29742: Implement permissions for Content/Create in Content item view - content create policy in UDW
- Loading branch information
1 parent
54fe958
commit deb399f
Showing
22 changed files
with
1,018 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
EzSystems\EzPlatformAdminUi\Form\SubmitHandler: ~ | ||
|
||
EzSystems\EzPlatformAdminUi\Form\Factory\FormFactory: ~ | ||
|
||
EzSystems\EzPlatformAdminUi\Form\DataMapper\: | ||
resource: '../../../lib/Form/DataMapper' | ||
|
||
EzSystems\EzPlatformAdminUi\Form\Type\: | ||
resource: '../../../lib/Form/Type' | ||
|
||
EzSystems\EzPlatformAdminUi\Form\EventListener\: | ||
resource: '../../../lib/Form/EventListener' | ||
|
||
EzSystems\EzPlatformAdminUi\Form\Type\Extension\Content\ContentEditTypeExtension: | ||
tags: | ||
- { name: form.type_extension, extended_type: EzSystems\RepositoryForms\Form\Type\Content\ContentEditType } | ||
|
||
EzSystems\EzPlatformAdminUi\Form\Type\Policy\PolicyChoiceType: | ||
arguments: | ||
$policyMap: "%ezpublish.api.role.policy_map%" | ||
|
||
EzSystems\EzPlatformAdminUi\Form\Type\Content\Draft\ContentCreateType: | ||
arguments: | ||
$contentTypeChoiceLoader: '@EzSystems\EzPlatformAdminUi\Form\Type\ChoiceList\Loader\PermissionAwareContentTypeChoiceLoader' | ||
$languageChoiceLoader: '@EzSystems\EzPlatformAdminUi\Form\Type\ChoiceList\Loader\PermissionAwareLanguageChoiceLoader' | ||
|
||
EzSystems\EzPlatformAdminUi\Form\Type\ChoiceList\Loader\ContentTypeChoiceLoader: ~ | ||
|
||
EzSystems\EzPlatformAdminUi\Form\Type\ChoiceList\Loader\LanguageChoiceLoader: | ||
arguments: | ||
$siteAccessLanguages: '$languages$' | ||
|
||
EzSystems\EzPlatformAdminUi\Form\Type\ChoiceList\Loader\PermissionAwareContentTypeChoiceLoader: | ||
arguments: | ||
$decorated: '@EzSystems\EzPlatformAdminUi\Form\Type\ChoiceList\Loader\ContentTypeChoiceLoader' | ||
$module: 'content' | ||
$function: 'create' | ||
|
||
EzSystems\EzPlatformAdminUi\Form\Type\ChoiceList\Loader\PermissionAwareLanguageChoiceLoader: | ||
arguments: | ||
$decorated: '@EzSystems\EzPlatformAdminUi\Form\Type\ChoiceList\Loader\LanguageChoiceLoader' | ||
$module: 'content' | ||
$function: 'create' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
EzSystems\EzPlatformAdminUi\Permission\PermissionChecker: ~ | ||
|
||
EzSystems\EzPlatformAdminUi\Permission\PermissionCheckerInterface: | ||
alias: EzSystems\EzPlatformAdminUi\Permission\PermissionChecker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,3 +101,7 @@ form:not(.form-inline) { | |
position: absolute; | ||
} | ||
} | ||
|
||
.ez-content-create[readonly] { | ||
pointer-events: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/lib/Form/Type/ChoiceList/Loader/ContentTypeChoiceLoader.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace EzSystems\EzPlatformAdminUi\Form\Type\ChoiceList\Loader; | ||
|
||
use eZ\Publish\API\Repository\ContentTypeService; | ||
use Symfony\Component\Form\ChoiceList\ArrayChoiceList; | ||
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; | ||
|
||
class ContentTypeChoiceLoader implements ChoiceLoaderInterface | ||
{ | ||
/** @var \eZ\Publish\API\Repository\ContentTypeService */ | ||
protected $contentTypeService; | ||
|
||
/** | ||
* @param \eZ\Publish\API\Repository\ContentTypeService $contentTypeService | ||
*/ | ||
public function __construct(ContentTypeService $contentTypeService) | ||
{ | ||
$this->contentTypeService = $contentTypeService; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getChoiceList(): array | ||
{ | ||
$contentTypes = []; | ||
$contentTypeGroups = $this->contentTypeService->loadContentTypeGroups(); | ||
foreach ($contentTypeGroups as $contentTypeGroup) { | ||
$contentTypes[$contentTypeGroup->identifier] = $this->contentTypeService->loadContentTypes($contentTypeGroup); | ||
} | ||
|
||
return $contentTypes; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function loadChoiceList($value = null) | ||
{ | ||
$choices = $this->getChoiceList(); | ||
|
||
return new ArrayChoiceList($choices, $value); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function loadChoicesForValues(array $values, $value = null) | ||
{ | ||
// Optimize | ||
$values = array_filter($values); | ||
if (empty($values)) { | ||
return []; | ||
} | ||
|
||
// If no callable is set, values are the same as choices | ||
if (null === $value) { | ||
return $values; | ||
} | ||
|
||
return $this->loadChoiceList($value)->getChoicesForValues($values); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function loadValuesForChoices(array $choices, $value = null) | ||
{ | ||
// Optimize | ||
$choices = array_filter($choices); | ||
if (empty($choices)) { | ||
return []; | ||
} | ||
|
||
// If no callable is set, choices are the same as values | ||
if (null === $value) { | ||
return $choices; | ||
} | ||
|
||
return $this->loadChoiceList($value)->getValuesForChoices($choices); | ||
} | ||
} |
Oops, something went wrong.