Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony 5 compatibility and Switch to SyliusThemeBundle #19

Merged
merged 15 commits into from
Nov 19, 2020

Conversation

mario-fehr
Copy link
Contributor

@mario-fehr mario-fehr commented Aug 26, 2020

Q A
Bug fix? no
New feature? no
BC breaks? yes
Deprecations? no
Fixed tickets fixes #17
Related issues/PRs #17
License MIT

What's in this PR?

This PR removes LiipThemeBundle dependency and added SyliusThemeBundle to have Symfony 5 compatibility.

BC Breaks/Deprecations

Due to the exchange of bundles, the folder structure must be adapted and the configuration exchanged for old projects.

To Do

  • Update Tests
  • Update Upgrade.md
  • Update Dokumentation

@mario-fehr mario-fehr changed the title Feature/symfony5 Symfony 5 compatibility and Switch to SyliusThemeBundle Aug 26, 2020
@mario-fehr
Copy link
Contributor Author

@danrot @alexander-schranz Alex told me to open a PR to show my work so far testing the SyliusThemeBundle in combination with Sulu. But I need some help with the test and pipline.

@danrot
Copy link
Contributor

danrot commented Aug 28, 2020

@mfehr94 But otherwise it is already working as expected? If it is only about the tests you can get back to me some day in the office, that's probably the easiest way to fix that 🙂

@JKetelaar
Copy link

JKetelaar commented Sep 23, 2020

We're using this in our development environment. Seems to work perfectly!

For anyone who wants to have a workaround for Symfony 5 & Theme support:
composer.json

    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/mfehr94/SuluThemeBundle"
        }
    ]

...

    "require": {
        "sulu/theme-bundle": "dev-feature/symfony5"
    }

@JKetelaar
Copy link

After testing this, it does cause issues when editing a page from the Sulu admin. I will provide a stacktrace later today.

@dsb-hannes-flaig
Copy link

dsb-hannes-flaig commented Oct 29, 2020

Ive followed @JKetelaar approach and added the Bundle to a fresh Sulu skeleton made with composer create-project sulu/skeleton cms_sulu_skeleton -n.

Problem
When trying to save a page in the admin panel, the preview area does not show a preview but instead displays a symfony error:
grafik

Stacktrace:

TypeError:
Argument 1 passed to Sylius\Bundle\ThemeBundle\Repository\InMemoryThemeRepository::findOneByName() must be of the type string, null given, called in /var/www/fly/cms_sulu_skeleton/vendor/sulu/theme-bundle/EventListener/SetThemeEventListener.php on line 63

  at vendor/sylius/theme-bundle/src/Repository/InMemoryThemeRepository.php:42
  at Sylius\Bundle\ThemeBundle\Repository\InMemoryThemeRepository->findOneByName(null)
     (vendor/sulu/theme-bundle/EventListener/SetThemeEventListener.php:63)
  at Sulu\Bundle\ThemeBundle\EventListener\SetThemeEventListener->setActiveThemeOnPreviewPreRender(object(PreRenderEvent), 'sulu.preview.pre-render', object(EventDispatcher))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:270)
  at Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}(object(PreRenderEvent), 'sulu.preview.pre-render', object(EventDispatcher))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:230)
  at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(Closure)), 'sulu.preview.pre-render', object(PreRenderEvent))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:59)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(PreRenderEvent), 'sulu.preview.pre-render')
     (vendor/sulu/sulu/src/Sulu/Bundle/PreviewBundle/Preview/Renderer/PreviewRenderer.php:173)
  at Sulu\Bundle\PreviewBundle\Preview\Renderer\PreviewRenderer->render(object(PageDocument), '10334765-80cb-4cb1-aec5-dac045963da6', 'example', 'en', false, -1)
     (vendor/sulu/sulu/src/Sulu/Bundle/PreviewBundle/Preview/Preview.php:140)
  at Sulu\Bundle\PreviewBundle\Preview\Preview->render('2c3502e7ea458d8cd27fa865fa651f72', 'example', 'en', -1)
     (vendor/sulu/sulu/src/Sulu/Bundle/PreviewBundle/Controller/PreviewController.php:77)
  at Sulu\Bundle\PreviewBundle\Controller\PreviewController->renderAction(object(Request))
     (vendor/symfony/http-kernel/HttpKernel.php:157)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:79)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:196)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:66) 

@alexander-schranz
Copy link
Member

@SirCoffeeMonkey Thank you for report. Did you configure the <theme> in your webspace.xml? Can you debug what $event->getAttribute('webspace') does return?

@mario-fehr
Copy link
Contributor Author

@SirCoffeeMonkey if you have <theme> configured, you need to make shure that you match the naming convention of the SyliusThemeBundle. https://github.com/Sylius/SyliusThemeBundle/blob/master/docs/theme_configuration_reference.md
So if we take this example it must look like this <theme>vendor/sylius-theme</theme> Unfortiantly the naming convention for the theme name must be composer style with a slash for example vendor/sylius-theme or massive/crimson-theme

@mario-fehr
Copy link
Contributor Author

mario-fehr commented Oct 29, 2020

Addition to that your theme need a composer.json (it is possible to change the file name by config) file with the theme infos https://github.com/Sylius/SyliusThemeBundle/blob/master/docs/index.md.

My sylius_theme.yaml looks like this:

    sources:
        filesystem:
            filename: theme.json // default: composer.json
            directories:
                - "%kernel.project_dir%/themes"

and the theme.json file in my themes/CrimsonTheme folder like this:

  "name": "massive/crimson-theme",
  "authors": [
    {
      "name": "Mario Fehr",
    }
  ],
  "extra": {
    "sylius-theme": {
      "title": "Crimson Theme"
    }
  }
}

@dsb-hannes-flaig
Copy link

dsb-hannes-flaig commented Oct 29, 2020

@alexander-schranz thank you for your swift response. I forgot to properly configure the sylius theme bundle. i have added following line to my webspace.xml:
<theme>test/test-theme</theme>
Then i added the following lines to the config/packages/sylius_theme.yaml (which you have to manually create):

sylius_theme:
  sources:
    filesystem:
      directories:
        - "%kernel.project_dir%/themes"

Finally i created following folder structure:
<ProjectDir>/themes/YourTheme
and added a composer.json in the YourTheme directory, with the following content:

{
  "name" : "test/test-theme",
  "extra": {
    "sylius-theme": {
      "title": "Test Theme"
    }
  }
}

For more details as to what can be configured in the theme composer.json you can refer to the links @mfehr94 kindly provided.

Now it is running and no longer throwing any errors 👍 😁
Thank you for putting me on the right path.

Copy link
Member

@alexander-schranz alexander-schranz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Prokyonn Some markdown syntax change requests.

UPGRADE.md Outdated Show resolved Hide resolved
UPGRADE.md Outdated Show resolved Hide resolved
UPGRADE.md Outdated Show resolved Hide resolved
UPGRADE.md Outdated Show resolved Hide resolved
@Prokyonn Prokyonn marked this pull request as ready for review November 12, 2020 09:25
UPGRADE.md Outdated
@@ -0,0 +1,105 @@
# Upgrade

## 2.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a new major release as 3.0

Copy link
Member

@alexander-schranz alexander-schranz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would focus the UPGRADE on a specific theme example.

phpunit.xml.dist Outdated
@@ -16,4 +16,14 @@
</exclude>
</whitelist>
</filter>

<php>
<env name="SYMFONY_PHPUNIT_VERSION" value="8.5.9"/>
Copy link
Member

@alexander-schranz alexander-schranz Nov 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as using the phpunit bridge 8 is enough that the newest phpunit bridge is always installed. ^8.5.9 would only be required when we require phpunit package in the composer.json.

Suggested change
<env name="SYMFONY_PHPUNIT_VERSION" value="8.5.9"/>
<env name="SYMFONY_PHPUNIT_VERSION" value="8.5.9"/>

UPGRADE.md Outdated
composer remove liip/theme-bundle --no-update

# Install new theme-bundle
composer require sylius/theme-bundle
Copy link
Member

@alexander-schranz alexander-schranz Nov 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add sulu/theme-bundle update here:

Suggested change
composer require sylius/theme-bundle
composer require sylius/theme-bundle:"^2.0" --no-update
composer require sulu/theme-bundle:"^3.0" --with-dependencies


## 3.0

### Switch from LiipThemeBundle to SyliusThemeBundle
Copy link
Member

@alexander-schranz alexander-schranz Nov 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lsmith77 Parts of this UPGRADE.md could be used in the LiipThemeBundle docs when the project will be marked as abandoned.

├── bin
├── config
├── ...
├── templates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would directly use themes folder here like its in the sylius documentation

@mario-fehr
Copy link
Contributor Author

@Prokyonn thanks for fixing the tests and dokumentationen

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated

### Configure your themes

Every theme must have its own configuration file in form of a `composer.json`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use composer.json or theme.json in the examples?

UPGRADE.md Outdated Show resolved Hide resolved
Prokyonn and others added 2 commits November 12, 2020 15:33
Co-authored-by: nnatter <niklas.natter@gmail.com>
README.md Show resolved Hide resolved
@alexander-schranz alexander-schranz merged commit 5a926a9 into sulu:master Nov 19, 2020
@alexander-schranz
Copy link
Member

Thank you @mfehr94 @Prokyonn !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Symfony 5 compatibility and Switch to SyliusThemeBundle
7 participants