Skip to content

Commit fcf6262

Browse files
committed
Merge remote-tracking branch 'origin/4.6' into IBX-9737-installation-only-4.6
2 parents 9a46431 + 4930ad3 commit fcf6262

File tree

9 files changed

+145
-69
lines changed

9 files changed

+145
-69
lines changed

.github/workflows/code_samples.yaml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,22 @@ jobs:
2222
extensions: "pdo_sqlite, gd"
2323
tools: cs2pr
2424

25-
- name: Add composer keys for private packagist
26-
run: |
27-
composer config http-basic.updates.ibexa.co $SATIS_NETWORK_KEY $SATIS_NETWORK_TOKEN
28-
composer config github-oauth.github.com $TRAVIS_GITHUB_TOKEN
29-
env:
30-
SATIS_NETWORK_KEY: ${{ secrets.SATIS_NETWORK_KEY }}
31-
SATIS_NETWORK_TOKEN: ${{ secrets.SATIS_NETWORK_TOKEN }}
32-
TRAVIS_GITHUB_TOKEN: ${{ secrets.TRAVIS_GITHUB_TOKEN }}
25+
- name: Generate token
26+
id: generate_token
27+
uses: actions/create-github-app-token@v2
28+
with:
29+
app-id: ${{ secrets.AUTOMATION_CLIENT_ID }}
30+
private-key: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
31+
owner: ${{ github.repository_owner }}
32+
33+
- name: Add composer keys for private packagist
34+
run: |
35+
composer config --global http-basic.updates.ibexa.co $SATIS_NETWORK_KEY $SATIS_NETWORK_TOKEN
36+
composer config --global github-oauth.github.com $GITHUB_TOKEN
37+
env:
38+
SATIS_NETWORK_KEY: ${{ secrets.SATIS_NETWORK_KEY }}
39+
SATIS_NETWORK_TOKEN: ${{ secrets.SATIS_NETWORK_TOKEN }}
40+
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
3341

3442
- uses: ramsey/composer-install@v3
3543
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ __pycache__/*
77
composer.lock
88
tools/php-cs-fixer/vendor
99
node_modules/
10+
auth.json
1011
.yarn
1112
yarn.lock
1213
docs/css/*.map
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace App\Controller;
4+
5+
use App\Security\Limitation\CustomLimitationValue;
6+
use Ibexa\Contracts\AdminUi\Controller\Controller;
7+
use Ibexa\Contracts\AdminUi\Permission\PermissionCheckerInterface;
8+
use Ibexa\Contracts\Core\Repository\PermissionResolver;
9+
use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute;
10+
use Symfony\Component\HttpFoundation\Request;
11+
use Symfony\Component\HttpFoundation\Response;
12+
13+
class CustomController extends Controller
14+
{
15+
// ...
16+
/** @var \Ibexa\Contracts\Core\Repository\PermissionResolver */
17+
private $permissionResolver;
18+
19+
/** @var \Ibexa\Contracts\AdminUi\Permission\PermissionCheckerInterface */
20+
private $permissionChecker;
21+
22+
public function __construct(
23+
// ...,
24+
PermissionResolver $permissionResolver,
25+
PermissionCheckerInterface $permissionChecker
26+
) {
27+
// ...
28+
$this->permissionResolver = $permissionResolver;
29+
$this->permissionChecker = $permissionChecker;
30+
}
31+
32+
// Controller actions...
33+
public function customAction(Request $request): Response
34+
{
35+
// ...
36+
if ($this->getCustomLimitationValue()) {
37+
// Action only for user having the custom limitation checked
38+
}
39+
40+
return new Response('<html><body>...</body></html>');
41+
}
42+
43+
private function getCustomLimitationValue(): bool
44+
{
45+
$hasAccess = $this->permissionResolver->hasAccess('custom_module', 'custom_function_2');
46+
47+
if (is_bool($hasAccess)) {
48+
return $hasAccess;
49+
}
50+
51+
$customLimitationValues = $this->permissionChecker->getRestrictions(
52+
$hasAccess,
53+
CustomLimitationValue::class
54+
);
55+
56+
return $customLimitationValues['value'] ?? false;
57+
}
58+
59+
public function performAccessCheck(): void
60+
{
61+
parent::performAccessCheck();
62+
$this->denyAccessUnlessGranted(new Attribute('custom_module', 'custom_function_2'));
63+
}
64+
}

code_samples/back_office/limitation/src/Security/Limitation/Mapper/CustomLimitationValueMapper.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99

1010
class CustomLimitationValueMapper implements LimitationValueMapperInterface
1111
{
12-
public function mapLimitationValue(Limitation $limitation): bool
12+
/**
13+
* @return array<bool>
14+
*/
15+
public function mapLimitationValue(Limitation $limitation): array
1316
{
14-
return $limitation->limitationValues['value'];
17+
return [$limitation->limitationValues['value']];
1518
}
1619
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{# templates/themes/standard/limitation/custom_limitation_value.html.twig #}
22
{% block ez_limitation_customlimitation_value %}
3-
<span style="color: {{ values ? 'green' : 'red' }};">{{ values ? 'Yes' : 'No' }}</span>
3+
{% set is_set = values | first %}
4+
<span style="color: {{ is_set ? 'green' : 'red' }};">{{ is_set ? 'Yes' : 'No' }}</span>
45
{% endblock %}

code_samples/back_office/notifications/src/Notification/MyRenderer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ public function generateUrl(Notification $notification): ?string
3939
return null;
4040
}
4141

42-
}
43-
4442
public function getTypeLabel(): string
4543
{
4644
return /** @Desc("Workflow stage changed") */

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
"ibexa/tree-builder": "~4.6.x-dev",
7272
"ibexa/discounts": "~4.6.x-dev",
7373
"ibexa/discounts-codes": "~4.6.x-dev",
74-
"ibexa/product-catalog-symbol-attribute": "~4.6.x-dev"
74+
"ibexa/product-catalog-symbol-attribute": "~4.6.x-dev",
75+
"ibexa/messenger": "~4.6.x-dev"
7576
},
7677
"scripts": {
7778
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",

docs/permissions/custom_policies.md

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -251,54 +251,6 @@ For example, `translations/ibexa_content_forms_policies.en.yaml`:
251251
Check if current user has this custom limitation set to true from a custom controller:
252252

253253
```php
254-
<?php declare(strict_types=1);
255-
256-
namespace App\Controller;
257-
258-
use Ibexa\Contracts\AdminUi\Controller\Controller;
259-
use Ibexa\Contracts\AdminUi\Permission\PermissionCheckerInterface;
260-
use Ibexa\Contracts\Core\Repository\PermissionResolver;
261-
use Symfony\Component\HttpFoundation\Request;
262-
use Symfony\Component\HttpFoundation\Response;
263-
264-
class CustomController extends Controller
265-
{
266-
// ...
267-
/** @var PermissionResolver */
268-
private $permissionResolver;
269-
270-
/** @var PermissionCheckerInterface */
271-
private $permissionChecker;
272-
273-
public function __construct(
274-
// ...,
275-
PermissionResolver $permissionResolver,
276-
PermissionCheckerInterface $permissionChecker
277-
)
278-
{
279-
// ...
280-
$this->permissionResolver = $permissionResolver;
281-
$this->permissionChecker = $permissionChecker;
282-
}
254+
[[= include_file('code_samples/back_office/limitation/src/Controller/CustomController.php') =]]
283255

284-
// Controller actions...
285-
public function customAction(Request $request): Response {
286-
// ...
287-
if ($this->getCustomLimitationValue()) {
288-
// Action only for user having the custom limitation checked
289-
}
290-
}
291-
292-
private function getCustomLimitationValue(): bool {
293-
$customLimitationValues = $this->permissionChecker->getRestrictions($this->permissionResolver->hasAccess('custom_module', 'custom_function_2'), CustomLimitationValue::class);
294-
295-
return $customLimitationValues['value'] ?? false;
296-
}
297-
298-
public function performAccessCheck()
299-
{
300-
parent::performAccessCheck();
301-
$this->denyAccessUnlessGranted(new Attribute('custom_module', 'custom_function_2'));
302-
}
303-
}
304256
```

phpstan-baseline.neon

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,6 @@ parameters:
234234
count: 1
235235
path: code_samples/back_office/limitation/src/Security/Limitation/Mapper/CustomLimitationFormMapper.php
236236

237-
-
238-
message: '#^Return type \(bool\) of method App\\Security\\Limitation\\Mapper\\CustomLimitationValueMapper\:\:mapLimitationValue\(\) should be compatible with return type \(array\<mixed\>\) of method Ibexa\\AdminUi\\Limitation\\LimitationValueMapperInterface\:\:mapLimitationValue\(\)$#'
239-
identifier: method.childReturnType
240-
count: 1
241-
path: code_samples/back_office/limitation/src/Security/Limitation/Mapper/CustomLimitationValueMapper.php
242-
243237
-
244238
message: '#^Method App\\Security\\MyPolicyProvider\:\:getFiles\(\) return type has no value type specified in iterable type array\.$#'
245239
identifier: missingType.iterableValue
@@ -258,6 +252,24 @@ parameters:
258252
count: 1
259253
path: code_samples/back_office/menu/menu_item/src/EventSubscriber/MyMenuSubscriber.php
260254

255+
-
256+
message: '#^Access to an undefined property App\\Notification\\ListRenderer\:\:\$translator\.$#'
257+
identifier: property.notFound
258+
count: 1
259+
path: code_samples/back_office/notifications/src/Notification/ListRenderer.php
260+
261+
-
262+
message: '#^Access to an undefined property App\\Notification\\MyRenderer\:\:\$translator\.$#'
263+
identifier: property.notFound
264+
count: 1
265+
path: code_samples/back_office/notifications/src/Notification/MyRenderer.php
266+
267+
-
268+
message: '#^Undefined variable\: \$templateToExtend$#'
269+
identifier: variable.undefined
270+
count: 1
271+
path: code_samples/back_office/notifications/src/Notification/MyRenderer.php
272+
261273
-
262274
message: '#^Cannot call method getValue\(\) on Ibexa\\Contracts\\FieldTypePage\\FieldType\\LandingPage\\Model\\Attribute\|null\.$#'
263275
identifier: method.nonObject
@@ -588,6 +600,42 @@ parameters:
588600
count: 1
589601
path: code_samples/front/shop/storefront/src/EventSubscriber/BreadcrumbsMenuSubscriber.php
590602

603+
-
604+
message: '#^Call to method addCriterion\(\) on an unknown class Ibexa\\Contracts\\Core\\Repository\\Values\\NotificationQuery\.$#'
605+
identifier: class.notFound
606+
count: 3
607+
path: code_samples/notifications/Src/Query/search.php
608+
609+
-
610+
message: '#^Instantiated class DateCreated not found\.$#'
611+
identifier: class.notFound
612+
count: 1
613+
path: code_samples/notifications/Src/Query/search.php
614+
615+
-
616+
message: '#^Instantiated class Ibexa\\Contracts\\Core\\Repository\\Values\\NotificationQuery not found\.$#'
617+
identifier: class.notFound
618+
count: 1
619+
path: code_samples/notifications/Src/Query/search.php
620+
621+
-
622+
message: '#^Instantiated class Status not found\.$#'
623+
identifier: class.notFound
624+
count: 1
625+
path: code_samples/notifications/Src/Query/search.php
626+
627+
-
628+
message: '#^Instantiated class Type not found\.$#'
629+
identifier: class.notFound
630+
count: 1
631+
path: code_samples/notifications/Src/Query/search.php
632+
633+
-
634+
message: '#^Variable \$this might not be defined\.$#'
635+
identifier: variable.undefined
636+
count: 1
637+
path: code_samples/notifications/Src/Query/search.php
638+
591639
-
592640
message: '#^Method App\\Block\\Attribute\\MyStringAttributeMapper\:\:map\(\) has parameter \$constraints with no value type specified in iterable type array\.$#'
593641
identifier: missingType.iterableValue

0 commit comments

Comments
 (0)