Skip to content

Commit 28b38cb

Browse files
authored
Merge pull request #57 from emodric/master
Adapt to Ibexa v4
2 parents e81aa9f + ead6c3e commit 28b38cb

20 files changed

+183
-164
lines changed

.github/workflows/tests.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
pull_request: ~
8+
9+
jobs:
10+
tests:
11+
name: ${{ matrix.php }} / ${{ matrix.symfony }}
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
php: ['7.4', '8.0', '8.1']
18+
symfony: ['~5.4.0']
19+
deps: ['normal']
20+
include:
21+
- php: '7.4'
22+
symfony: '~5.4.0'
23+
deps: 'low'
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: ${{ matrix.php }}
30+
coverage: none
31+
32+
- run: composer --version
33+
- run: composer validate --strict
34+
35+
# Install Flex as a global dependency to enable usage of extra.symfony.require
36+
# while keeping Flex recipes from applying
37+
- run: composer global require --no-scripts symfony/flex
38+
39+
- run: composer config extra.symfony.require ${{ matrix.symfony }}
40+
41+
-
42+
run: composer update --prefer-dist
43+
if: ${{ matrix.deps != 'low' }}
44+
45+
-
46+
run: composer update --prefer-dist --prefer-lowest --prefer-stable
47+
if: ${{ matrix.deps == 'low' }}
48+
49+
- run: vendor/bin/phpunit --colors=always

.travis.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Lolautruche\EzCoreExtraBundle\DependencyInjection;
1313

14-
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\Configuration as SiteAccessConfiguration;
14+
use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\Configuration as SiteAccessConfiguration;
1515
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1616

1717
class Configuration extends SiteAccessConfiguration

DependencyInjection/EzCoreExtraExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Lolautruche\EzCoreExtraBundle\DependencyInjection;
1313

14-
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor;
14+
use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor;
1515
use Lolautruche\EzCoreExtraBundle\View\ViewParameterProviderInterface;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\Config\FileLocator;

EventListener/ViewTemplateListener.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111

1212
namespace Lolautruche\EzCoreExtraBundle\EventListener;
1313

14-
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\DynamicSettingParserInterface;
15-
use eZ\Publish\API\Repository\Repository;
16-
use eZ\Publish\Core\MVC\ConfigResolverInterface;
17-
use eZ\Publish\Core\MVC\Symfony\Event\PreContentViewEvent;
18-
use eZ\Publish\Core\MVC\Symfony\MVCEvents;
19-
use eZ\Publish\Core\MVC\Symfony\View\ContentValueView;
20-
use eZ\Publish\Core\MVC\Symfony\View\ContentView;
21-
use eZ\Publish\Core\MVC\Symfony\View\LocationValueView;
14+
use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\DynamicSettingParserInterface;
15+
use Ibexa\Contracts\Core\Repository\Repository;
16+
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
17+
use Ibexa\Core\MVC\Symfony\Event\PreContentViewEvent;
18+
use Ibexa\Core\MVC\Symfony\MVCEvents;
19+
use Ibexa\Core\MVC\Symfony\View\ContentValueView;
20+
use Ibexa\Core\MVC\Symfony\View\ContentView;
21+
use Ibexa\Core\MVC\Symfony\View\LocationValueView;
2222
use Lolautruche\EzCoreExtraBundle\Exception\MissingParameterProviderException;
2323
use Lolautruche\EzCoreExtraBundle\View\ConfigurableView;
2424
use Lolautruche\EzCoreExtraBundle\View\ExpressionLanguage;
@@ -82,7 +82,7 @@ public function addParameterProvider(ViewParameterProviderInterface $provider, $
8282

8383
public function onPreContentView(PreContentViewEvent $event)
8484
{
85-
/** @var \eZ\Publish\Core\MVC\Symfony\View\ContentView $view */
85+
/** @var \Ibexa\Core\MVC\Symfony\View\ContentView $view */
8686
$view = $event->getContentView();
8787
$configHash = $view->getConfigHash();
8888
if (!isset($configHash['params']) || !is_array($configHash['params'])) {
@@ -134,7 +134,7 @@ public function onPreContentView(PreContentViewEvent $event)
134134
}
135135

136136
/**
137-
* @param \eZ\Publish\Core\MVC\Symfony\View\ContentView $view
137+
* @param \Ibexa\Core\MVC\Symfony\View\ContentView $view
138138
* @return ConfigurableView
139139
*/
140140
private function generateConfigurableView(ContentView $view)

README.md

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# EzCoreExtraBundle
22

3-
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/4c330566-a5a9-45c1-82a5-00d781f355a0/mini.png)](https://insight.sensiolabs.com/projects/4c330566-a5a9-45c1-82a5-00d781f355a0)
4-
[![Build Status](https://travis-ci.org/lolautruche/EzCoreExtraBundle.svg)](http://travis-ci.org/lolautruche/EzCoreExtraBundle)
5-
6-
Adds extra features to eZ Platform.
3+
Adds extra features to Ibexa Platform.
74

85
## Compatibility
9-
* `master` branch is **only compatible with eZ Platform v3**
6+
* `master` branch is **only compatible with Ibexa Platform v4**
7+
* `v3.x` branch is **only compatible with eZ Platform v3**
108
* `v2.x` is **only compatible with eZ Platform v1 and v2**
119
* `1.0` branch is compatible with both eZ Platform *and* eZ Publish 5.4/2014.11.
1210

@@ -17,7 +15,7 @@ Adds extra features to eZ Platform.
1715
This avoids you to create custom controllers when you need to add a few simple variables to your view.
1816

1917
```yaml
20-
ezpublish:
18+
ibexa:
2119
system:
2220
my_siteaccess:
2321
location_view:
@@ -28,9 +26,6 @@ Adds extra features to eZ Platform.
2826
# Following keys will be injected as variables into configured template
2927
osTypes: [osx, linux, losedows]
3028
secret: %secret%
31-
# Parameters resolved by config resolver
32-
# See https://doc.ez.no/display/EZP/Dynamic+settings+injection
33-
default_ttl: $content.default_ttl$
3429
# Using a parameter provider, for more complex usecases.
3530
my_provider: {"provider": "my_param_provider"}
3631

@@ -55,17 +50,19 @@ Adds extra features to eZ Platform.
5550
* **[Simplified authorization checks](Resources/doc/simplified_auth_checks.md)**
5651
5752
Simplifies calls to `$this->isGranted()` from inside controllers and `is_granted()` from within templates when checking
58-
against eZ inner permission system (module/function/valueObject).
53+
against Ibexa inner permission system (module/function/valueObject).
5954

6055
```
6156

6257
## Requirements
63-
EzCoreExtraBundle currently works eZ Platform v1, v2 and v3 (kernel v6, v7 and v8).
58+
EzCoreExtraBundle currently works eZ Platform v1, v2 and v3 (kernel v6, v7 and v8), and Ibexa Platform v4.
6459

6560
> If you're using eZ publish 5.4/2014.11 or Netgen variant, look at `1.1` branch and/or `v1.x` releases.
6661
6762
> If you're using eZ Platform v1 or v2, look at `2.x` branch and/or `v2.x` releases.
6863
64+
> If you're using eZ Platform v3, look at `3.x` branch and/or `v3.x` releases.
65+
6966
## Installation
7067
This bundle is available on [Packagist](https://packagist.org/packages/lolautruche/ez-core-extra-bundle).
7168
You can install it using Composer.
@@ -76,20 +73,7 @@ composer require lolautruche/ez-core-extra-bundle
7673

7774
Then add it to your application:
7875

79-
> `EzCoreExtraBundle` **MUST** be instanciated **AFTER** eZ bundles.
80-
81-
```php
82-
// ezpublish/EzPublishKernel.php
83-
84-
public function registerBundles()
85-
{
86-
$bundles = [
87-
// ...
88-
new Lolautruche\EzCoreExtraBundle\EzCoreExtraBundle(),
89-
// ...
90-
];
91-
}
92-
```
76+
> `EzCoreExtraBundle` **MUST** be instanciated **AFTER** Ibexa bundles.
9377
9478
## Documentation
9579
See [Resources/doc/](Resources/doc)

Resources/config/services.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ services:
44
ez_core_extra.view_template_listener:
55
class: Lolautruche\EzCoreExtraBundle\EventListener\ViewTemplateListener
66
arguments:
7-
- "@ezpublish.config.resolver"
8-
- "@ezpublish.config.dynamic_setting.parser"
9-
- "@ezpublish.api.repository"
7+
- "@ibexa.config.resolver"
8+
- "@Ibexa\\Bundle\\Core\\DependencyInjection\\Configuration\\SiteAccessAware\\DynamicSettingParser"
9+
- "@ibexa.api.repository"
1010
- "@ez_core_extra.view.expression_language"
1111

1212
tags:
@@ -16,16 +16,16 @@ services:
1616
public: false
1717
class: Lolautruche\EzCoreExtraBundle\Templating\Twig\TwigGlobalsExtension
1818
arguments:
19-
- '@ezpublish.config.resolver'
19+
- '@ibexa.config.resolver'
2020
tags:
2121
- { name: twig.extension }
2222

2323
ez_core_extra.security.simplified_core_voter:
2424
public: false
2525
class: Lolautruche\EzCoreExtraBundle\Security\Voter\SimplifiedCoreVoter
2626
arguments:
27-
- "@ezpublish.security.voter.core"
28-
- "@ezpublish.security.voter.value_object"
27+
- "@Ibexa\\Core\\MVC\\Symfony\\Security\\Authorization\\Voter\\CoreVoter"
28+
- "@Ibexa\\Core\\MVC\\Symfony\\Security\\Authorization\\Voter\\ValueObjectVoter"
2929
tags:
3030
- { name: "security.voter" }
3131

Resources/doc/simplified_auth_checks.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Simplified authorization checks
22

3-
This feature simplifies the way you check authorization with eZ inner ACL system, using
3+
This feature simplifies the way you check authorization with Ibexa inner ACL system, using
44
`module/function` and optionnaly a value object (e.g. a content object).
55

66
Without eZCoreExtraBundle, when one want to check if a user has access to a module/function like
@@ -9,8 +9,8 @@ Without eZCoreExtraBundle, when one want to check if a user has access to a modu
99
```php
1010
namespace Acme\Controller;
1111

12-
use eZ\Bundle\EzPublishCoreBundle\Controller;
13-
use eZ\Publish\Core\MVC\Symfony\Security\Authorization\Attribute as AuthorizationAttribute;
12+
use Ibexa\Bundle\Core\Controller;
13+
use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute as AuthorizationAttribute;
1414

1515
class MyController extends Controller
1616
{
@@ -38,36 +38,36 @@ In order to check access for a `module`/`function` pair, instead of instantiatin
3838
object, just use the following syntax:
3939

4040
```
41-
ez:<module>:<function>
41+
ibexa:<module>:<function>
4242
```
4343

4444
Taking the example from the introduction, it will be:
4545

4646
```php
4747
namespace Acme\Controller;
4848

49-
use eZ\Bundle\EzPublishCoreBundle\Controller;
49+
use Ibexa\Bundle\Core\Controller;
5050

5151
class MyController extends Controller
5252
{
5353
public function fooAction()
5454
{
5555
// ...
56-
$accessGranted = $this->isGranted('ez:content:read');
56+
$accessGranted = $this->isGranted('ibexa:content:read');
5757

5858
// Or with an actual content
59-
$accessGranted = $this->isGranted('ez:content:read', $myContent);
59+
$accessGranted = $this->isGranted('ibexa:content:read', $myContent);
6060
}
6161
}
6262
```
6363

6464
In a template, the syntax will be:
6565

6666
```jinja
67-
{% set accessGranted = is_granted('ez:content:read') %}
67+
{% set accessGranted = is_granted('ibexa:content:read') %}
6868
6969
{# Or with an actual content #}
70-
{% set accessGranted = is_granted('ez:content:read', my_content) %}
70+
{% set accessGranted = is_granted('ibexa:content:read', my_content) %}
7171
```
7272

7373
Et voilà :-)

Resources/doc/template_variables_injection.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Typical use cases are access to:
1717
This features adds the possibility to define Twig global variables depending on the current SiteAccess.
1818
These global variables will be available in every templates.
1919

20-
It also adds a [generic subscriber to `ezpublish.pre_content_view` event](https://doc.ez.no/display/EZP/Parameters+injection+in+content+views),
21-
bound to the template selection rules, so that you can inject configured parameters in the selected view.
20+
It also adds a generic subscriber to `ezpublish.pre_content_view` event, bound to the template selection rules,
21+
so that you can inject configured parameters in the selected view.
2222

2323

2424
## Context aware Twig global variables
@@ -57,31 +57,23 @@ You can inject several types of parameters:
5757

5858
* Plain parameters, which values are directly defined in the configuration (including arrays, hashes, booleans…)
5959
* Parameter references from the ServiceContainer (e.g. `%my.parameter%`)
60-
* [Dynamic settings](https://doc.ez.no/display/EZP/Dynamic+settings+injection) (aka *siteaccess aware parameters*,
61-
using `$<paramName>[;<namespace>[;<scope>]]$` syntax)
6260
* [Expressions](view_parameters_expressions.md) (for dynamic injection with ExpressionLanguage)
6361
* [Parameters provider services](view_parameters_providers.md) (for more dynamic injection using custom reusable services)
6462

6563
### Example
6664
This feature would allow to configure a content/location/block view the following way:
6765

6866
```yaml
69-
# ezplatform.yml
70-
ezpublish:
67+
ibexa:
7168
system:
7269
my_siteaccess:
7370
location_view:
7471
full:
7572
article_test:
76-
template: "@ezdesign/full/article_test.html.twig"
73+
template: "@ibexadesign/full/article_test.html.twig"
7774
params:
7875
osTypes: [osx, linux, losedows]
7976
secret: "%secret%"
80-
# Parameters resolved by config resolver
81-
# Supported syntax for parameters: $<paramName>[;<namespace>[;<scope>]]$
82-
# e.g. full syntax: $my_setting;custom_namespace;my_siteaccess$
83-
# See https://doc.ez.no/display/EZP/Dynamic+settings+injection
84-
default_ttl: "$content.default_ttl$"
8577
match:
8678
Id\Location: 144
8779
```
@@ -98,7 +90,7 @@ The view template would then be like:
9890
{% extends "pagelayout.html.twig" %}
9991
10092
{% block content %}
101-
<h1>{{ ez_render_field(content, 'title') }}</h1>
93+
<h1>{{ ibexa_render_field(content, 'title') }}</h1>
10294
10395
<p><strong>Secret:</strong> {{ secret }}</p>
10496

0 commit comments

Comments
 (0)