Skip to content

Commit

Permalink
update: add support for Pimcore 11 (#30)
Browse files Browse the repository at this point in the history
* update: add support for Pimcore 11

* update Pimcore requirement to ^10.5

* ci: remove PHP 8.2 + lowest from test matrix
  • Loading branch information
lukadschaak authored Oct 16, 2023
1 parent e3ed5d8 commit e1ad411
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: PHP Setup
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2

- name: Validate composer.json
run: composer validate --strict
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ jobs:
matrix:
include:
- php-version: "8.1"
dependencies: "lowest"
dependencies: "lowest" # Pimcore 10.5.0
- php-version: "8.1"
dependencies: "highest"
dependencies: "highest" # Pimcore 11.*
- php-version: "8.2"
dependencies: "highest" # Pimcore 11.*

steps:
- name: Git Checkout
Expand All @@ -38,5 +40,9 @@ jobs:
with:
dependency-versions: ${{ matrix.dependencies }}

- name: Add Pimcore Admin UI
run: composer require --dev pimcore/admin-ui-classic-bundle --no-interaction
if: matrix.dependencies == 'highest'

- name: Execute tests
run: composer tests
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
/composer.lock
/vendor/

# Docker Compose
/compose.override.yaml

# PHP-CS-Fixer
.php-cs-fixer.cache
/.php-cs-fixer.cache

# PHPUnit
.phpunit.result.cache
/reports/
/.phpunit.result.cache
/.phpunit.cache/
/reports/

# Reveal JS
/public/reveal.js-master/
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
timeout: 10s

php:
image: pimcore/pimcore:php8.1-v1.3
image: pimcore/pimcore:php8.2-latest
volumes:
- ./:/var/www/html/
environment:
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
}
},
"require": {
"php": "~8.1",
"pimcore/pimcore": "^10.0",
"symfony/config": "^5.3",
"symfony/console": "^5.3",
"symfony/dependency-injection": "^5.3",
"symfony/event-dispatcher": "^5.2",
"symfony/finder": "^5.2",
"symfony/http-kernel": "^5.3"
"php": "~8.1.0 || ~8.2.0",
"pimcore/pimcore": "^10.5 || ^11.0",
"symfony/config": "^5.3 || ^6.0",
"symfony/console": "^5.3 || ^6.0",
"symfony/dependency-injection": "^5.3 || ^6.0",
"symfony/event-dispatcher": "^5.2 || ^6.0",
"symfony/finder": "^5.2 || ^6.0",
"symfony/http-kernel": "^5.3 || ^6.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.11",
Expand Down
36 changes: 20 additions & 16 deletions config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
services:
_defaults:
autowire: true
autoconfigure: true
bind:
$revealJsPublicPath: '/bundles/neustapimcorepresentation/reveal.js-master'
_defaults:
autowire: true
autoconfigure: true
bind:
$revealJsPublicPath: '/bundles/neustapimcorepresentation/reveal.js-master'

Neusta\Pimcore\PresentationBundle\Controller\:
resource: '../src/Controller'
public: true
tags: ['controller.service_arguments']
Neusta\Pimcore\PresentationBundle\Controller\:
resource: '../src/Controller'
public: true
tags: [ 'controller.service_arguments' ]

Neusta\Pimcore\PresentationBundle\Renderer\SimplePresentationRenderer: ~
Neusta\Pimcore\PresentationBundle\Renderer\PresentationRenderer:
alias: Neusta\Pimcore\PresentationBundle\Renderer\SimplePresentationRenderer
Neusta\Pimcore\PresentationBundle\Renderer\SimpleSlideRenderer: ~
Neusta\Pimcore\PresentationBundle\Renderer\SlideRenderer:
alias: Neusta\Pimcore\PresentationBundle\Renderer\SimpleSlideRenderer
Neusta\Pimcore\PresentationBundle\Twig\PresentationExtension: ~
Neusta\Pimcore\PresentationBundle\EventListener\:
resource: '../src/EventListener'
tags: [ 'kernel.event_listener' ]

Neusta\Pimcore\PresentationBundle\Renderer\SimplePresentationRenderer: ~
Neusta\Pimcore\PresentationBundle\Renderer\PresentationRenderer:
alias: Neusta\Pimcore\PresentationBundle\Renderer\SimplePresentationRenderer
Neusta\Pimcore\PresentationBundle\Renderer\SimpleSlideRenderer: ~
Neusta\Pimcore\PresentationBundle\Renderer\SlideRenderer:
alias: Neusta\Pimcore\PresentationBundle\Renderer\SimpleSlideRenderer
Neusta\Pimcore\PresentationBundle\Twig\PresentationExtension: ~
24 changes: 24 additions & 0 deletions src/EventListener/AdminAssetsListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php declare(strict_types=1);

namespace Neusta\Pimcore\PresentationBundle\EventListener;

use Pimcore\Event\BundleManager\PathsEvent;
use Pimcore\Event\BundleManagerEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class AdminAssetsListener implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
BundleManagerEvents::JS_PATHS => 'onJsPaths',
];
}

public function onJsPaths(PathsEvent $event): void
{
$event->setPaths(array_merge($event->getPaths(), [
'/bundles/presentation/js/pimcore/startup.js',
]));
}
}
10 changes: 2 additions & 8 deletions src/NeustaPimcorePresentationBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Neusta\Pimcore\PresentationBundle;

use Pimcore\Extension\Bundle\AbstractPimcoreBundle;
use Pimcore\Extension\Bundle\Installer\InstallerInterface;
use Pimcore\Extension\Bundle\Traits\PackageVersionTrait;

class NeustaPimcorePresentationBundle extends AbstractPimcoreBundle
Expand All @@ -14,14 +15,7 @@ public function getPath(): string
return \dirname(__DIR__);
}

public function getJsPaths()
{
return [
'/bundles/presentation/js/pimcore/startup.js',
];
}

public function getInstaller()
public function getInstaller(): ?InstallerInterface
{
return new Installer();
}
Expand Down
4 changes: 3 additions & 1 deletion src/Renderer/SimpleSlideRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public function renderSlide(Document $slide): string
{
$slideMarkup = $this->renderDocument($slide);
foreach ($slide->getChildren() as $subSlide) {
$slideMarkup .= $this->renderSlide($subSlide);
if ($subSlide) {
$slideMarkup .= $this->renderSlide($subSlide);
}
}

return $slideMarkup;
Expand Down
12 changes: 7 additions & 5 deletions tests/Renderer/SimplePresentationRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Neusta\Pimcore\PresentationBundle\Renderer\SimplePresentationRenderer;
use Neusta\Pimcore\PresentationBundle\Renderer\SlideRenderer;
use PHPUnit\Framework\TestCase;
use Pimcore\Model\Document\Listing;
use Pimcore\Model\Document\PageSnippet;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
Expand Down Expand Up @@ -32,9 +33,11 @@ protected function setUp(): void
public function renderPresentationWithoutSlidesRendersNothing(): void
{
$presentation = $this->prophesize(PageSnippet::class);
$documentListing = new Listing();
$documentListing->setData([]);
$presentation
->getChildren()
->willReturn([]);
->willReturn($documentListing);

$renderedPresentation = $this->presentationRenderer->renderPresentation($presentation->reveal());

Expand All @@ -53,12 +56,11 @@ public function eachSlideOfPresentationIsForwardedToSlideRenderer(): void
$slide2 = $this->createSlideMock();

$presentation = $this->prophesize(PageSnippet::class);
$documentListing = new Listing();
$documentListing->setData([$slide1, $slide2]);
$presentation
->getChildren()
->willReturn([
$slide1,
$slide2,
]);
->willReturn($documentListing);

$this->slideRenderer
->renderSlide($slide1)
Expand Down

0 comments on commit e1ad411

Please sign in to comment.