-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into rm-unused-raml
# Conflicts: # docs/api/rest_api/rest_api_reference/input/ez_original.raml
- Loading branch information
Showing
257 changed files
with
2,252 additions
and
1,119 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
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
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
12 changes: 12 additions & 0 deletions
12
code_samples/back_office/limitation/config/append_to_services.yaml
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,12 @@ | ||
services: | ||
App\Security\Limitation\CustomLimitationType: | ||
tags: | ||
- { name: 'ibexa.permissions.limitation_type', alias: 'CustomLimitation' } | ||
|
||
App\Security\Limitation\Mapper\CustomLimitationFormMapper: | ||
tags: | ||
- { name: 'ibexa.admin_ui.limitation.mapper.form', limitationType: 'CustomLimitation' } | ||
|
||
App\Security\Limitation\Mapper\CustomLimitationValueMapper: | ||
tags: | ||
- { name: 'ibexa.admin_ui.limitation.mapper.value', limitationType: 'CustomLimitation' } |
5 changes: 5 additions & 0 deletions
5
code_samples/back_office/limitation/config/packages/ibexa_security.yaml
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,5 @@ | ||
ibexa: | ||
system: | ||
default: | ||
limitation_value_templates: | ||
- { template: '@ibexadesign/limitation/custom_limitation_value.html.twig', priority: 0 } |
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,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App; | ||
|
||
use App\Security\MyPolicyProvider; | ||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Kernel as BaseKernel; | ||
|
||
class Kernel extends BaseKernel | ||
{ | ||
use MicroKernelTrait; | ||
|
||
protected function build(ContainerBuilder $container): void | ||
{ | ||
// Retrieve "ibexa" container extension | ||
/** @var \Ibexa\Bundle\Core\DependencyInjection\IbexaCoreExtension $IbexaExtension */ | ||
$ibexaExtension = $container->getExtension('ibexa'); | ||
// Add the policy provider | ||
$ibexaExtension->addPolicyProvider(new MyPolicyProvider()); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
code_samples/back_office/limitation/src/Resources/config/policies.yaml
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,4 @@ | ||
# src/Resources/config/policies.yaml | ||
custom_module: | ||
custom_function_1: ~ | ||
custom_function_2: [CustomLimitation] |
82 changes: 82 additions & 0 deletions
82
code_samples/back_office/limitation/src/Security/Limitation/CustomLimitationType.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,82 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Limitation; | ||
|
||
use Ibexa\Contracts\Core\Limitation\Type; | ||
use Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException; | ||
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; | ||
use Ibexa\Contracts\Core\Repository\Values\User\Limitation; | ||
use Ibexa\Contracts\Core\Repository\Values\User\UserReference; | ||
use Ibexa\Contracts\Core\Repository\Values\ValueObject; | ||
use Ibexa\Core\Base\Exceptions\InvalidArgumentType; | ||
use Ibexa\Core\FieldType\ValidationError; | ||
|
||
class CustomLimitationType implements Type | ||
{ | ||
public function acceptValue(Limitation $limitationValue): void | ||
{ | ||
if (!$limitationValue instanceof CustomLimitationValue) { | ||
throw new InvalidArgumentType( | ||
'$limitationValue', | ||
FieldGroupLimitation::class, | ||
$limitationValue | ||
); | ||
} | ||
} | ||
|
||
/** @return \Ibexa\Core\FieldType\ValidationError[] */ | ||
public function validate(Limitation $limitationValue): array | ||
{ | ||
$validationErrors = []; | ||
if (!array_key_exists('value', $limitationValue->limitationValues)) { | ||
$validationErrors[] = new ValidationError("limitationValues['value'] is missing."); | ||
} elseif (!is_bool($limitationValue->limitationValues['value'])) { | ||
$validationErrors[] = new ValidationError("limitationValues['value'] is not a boolean."); | ||
} | ||
|
||
return $validationErrors; | ||
} | ||
|
||
public function buildValue(array $limitationValues): CustomLimitationValue | ||
{ | ||
$value = false; | ||
if (array_key_exists('value', $limitationValues)) { | ||
$value = $limitationValues['value']; | ||
} elseif (count($limitationValues)) { | ||
$value = (bool)$limitationValues[0]; | ||
} | ||
|
||
return new CustomLimitationValue(['limitationValues' => ['value' => $value]]); | ||
} | ||
|
||
/** | ||
* @param \Ibexa\Contracts\Core\Repository\Values\ValueObject[]|null $targets | ||
* | ||
* @return bool|null | ||
*/ | ||
public function evaluate(Limitation $value, UserReference $currentUser, ValueObject $object, array $targets = null): ?bool | ||
{ | ||
if (!$value instanceof CustomLimitationValue) { | ||
throw new InvalidArgumentException('$value', 'Must be of type: CustomLimitationValue'); | ||
} | ||
|
||
if ($value->limitationValues['value']) { | ||
return Type::ACCESS_GRANTED; | ||
} | ||
|
||
// If the limitation value is not set to `true`, then $currentUser, $object and/or $targets could be challenged to determine if the access is granted or not; Here or elsewhere. When passing the baton, a limitation can return Type::ACCESS_ABSTAIN | ||
return Type::ACCESS_DENIED; | ||
} | ||
|
||
public function getCriterion(Limitation $value, UserReference $currentUser): CriterionInterface | ||
{ | ||
throw new NotImplementedException(__METHOD__); | ||
} | ||
|
||
public function valueSchema(): void | ||
{ | ||
throw new NotImplementedException(__METHOD__); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
code_samples/back_office/limitation/src/Security/Limitation/CustomLimitationValue.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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Limitation; | ||
|
||
use Ibexa\Contracts\Core\Repository\Values\User\Limitation; | ||
|
||
class CustomLimitationValue extends Limitation | ||
{ | ||
public function getIdentifier(): string | ||
{ | ||
return 'CustomLimitation'; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...ples/back_office/limitation/src/Security/Limitation/Mapper/CustomLimitationFormMapper.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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Limitation\Mapper; | ||
|
||
use Ibexa\AdminUi\Limitation\LimitationFormMapperInterface; | ||
use Ibexa\AdminUi\Translation\Extractor\LimitationTranslationExtractor; | ||
use Ibexa\Contracts\Core\Repository\Values\User\Limitation; | ||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | ||
use Symfony\Component\Form\FormInterface; | ||
|
||
class CustomLimitationFormMapper implements LimitationFormMapperInterface | ||
{ | ||
public function mapLimitationForm(FormInterface $form, Limitation $data): void | ||
{ | ||
$form->add('limitationValues', CheckboxType::class, [ | ||
'label' => LimitationTranslationExtractor::identifierToLabel($data->getIdentifier()), | ||
'required' => false, | ||
'data' => $data->limitationValues['value'], | ||
'property_path' => 'limitationValues[value]', | ||
]); | ||
} | ||
|
||
public function getFormTemplate(): string | ||
{ | ||
return '@ibexadesign/limitation/custom_limitation_form.html.twig'; | ||
} | ||
|
||
public function filterLimitationValues(Limitation $limitation): void | ||
{ | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...les/back_office/limitation/src/Security/Limitation/Mapper/CustomLimitationValueMapper.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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security\Limitation\Mapper; | ||
|
||
use Ibexa\AdminUi\Limitation\LimitationValueMapperInterface; | ||
use Ibexa\Contracts\Core\Repository\Values\User\Limitation; | ||
|
||
class CustomLimitationValueMapper implements LimitationValueMapperInterface | ||
{ | ||
public function mapLimitationValue(Limitation $limitation): bool | ||
{ | ||
return $limitation->limitationValues['value']; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
code_samples/back_office/limitation/src/Security/MyPolicyProvider.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,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Security; | ||
|
||
use Ibexa\Bundle\Core\DependencyInjection\Security\PolicyProvider\YamlPolicyProvider; | ||
|
||
class MyPolicyProvider extends YamlPolicyProvider | ||
{ | ||
/** @returns string[] */ | ||
protected function getFiles(): array | ||
{ | ||
return [ | ||
__DIR__ . '/../Resources/config/policies.yaml', | ||
]; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...back_office/limitation/templates/themes/admin/limitation/custom_limitation_form.html.twig
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,3 @@ | ||
{# templates/themes/admin/limitation/custom_limitation_form.html.twig #} | ||
{{ form_label(form.limitationValues) }} | ||
{{ form_widget(form.limitationValues) }} |
4 changes: 4 additions & 0 deletions
4
..._office/limitation/templates/themes/standard/limitation/custom_limitation_value.html.twig
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,4 @@ | ||
{# templates/themes/standard/limitation/custom_limitation_value.html.twig #} | ||
{% block ez_limitation_customlimitation_value %} | ||
<span style="color: {{ values ? 'green' : 'red' }};">{{ values ? 'Yes' : 'No' }}</span> | ||
{% endblock %} |
4 changes: 4 additions & 0 deletions
4
code_samples/back_office/limitation/translations/forms.en.yaml
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,4 @@ | ||
role.policy.custom_module: 'Custom module' | ||
role.policy.custom_module.all_functions: 'Custom module / All functions' | ||
role.policy.custom_module.custom_function_1: 'Custom module / Function #1' | ||
role.policy.custom_module.custom_function_2: 'Custom module / Function #2' |
1 change: 1 addition & 0 deletions
1
code_samples/back_office/limitation/translations/ibexa_content_forms_policies.en.yaml
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 @@ | ||
policy.limitation.identifier.customlimitation: 'Custom limitation' |
Oops, something went wrong.