Skip to content

Migration guide

Migrate to 0.15

Add bundles

  • ResourceBundle
  • RevisionBundle

Use new Type system

  • Action
  • Filter

Menu config children change to items Menu config role change to permission Menu config type: base change to type: link

Migrate sylius resources

  • Migrate resources $ enhavo migrate-enhavo-resource config/packages/sylius_resource.yml src/config/routes/admin templates
  • Update services with Regex ([a-z]+).factory.([a-z_]+) => $1.$2.factory
  • Update services with Regex ([a-z]+).repository.([a-z_]+) => $1.$2.repository
  • Update parameters with Regex ([a-z_]+).model.([a-z_]+).class => $1.$2.model.class
  • Update parameters with Regex ([a-z_]+).factory.([a-z_]+).class => $1.$2.factory.class
  • Update parameters with Regex ([a-z_]+).repository.([a-z_]+).class => $1.$2.repository.class

Config

  • add config/packages/vite.yaml
  • add config/packages/area.yaml
  • add config/packages/vue.yaml
  • update access_control in config/packages/security.yaml
  • update config/packages/assets.yaml

Vite

.env

VITE_THEME_PORT="5142"
VITE_ADMIN_PORT="15142"

package.json

"type": "module",

Migrate to 0.14

Add doctrine migrations

php
    public function up(Schema $schema): void
    {
        $this->addSql("UPDATE routing_route SET variablePattern = '' WHERE variablePattern IS NULL");
        $this->addSql("UPDATE media_file SET library = 0 WHERE library IS NULL");
        $this->addSql("UPDATE media_file SET parameters = 'a:0:{}' WHERE parameters = 'N;'");
    }

Add #[Groups(['endpoint.block'])] to your block properties

# security.yaml
IS_AUTHENTICATED_ANONYMOUSLY to PUBLIC_ACCESS

Add interface to user LegacyPasswordAuthenticatedUserInterface

Migrate to 0.13

Search metadata: index instead of property

Migrate to 0.12

1. config/routes/enhavo_user.yaml file

2. config/packages/security.yaml file

Migrate to 0.11

1. assets/enhavo folder

  • Remove assets/services
  • Add Entrypoints to assets/enhavo/entrypoint*
  • DI Container to assets/enhavo/container.yaml with d.ts file
  • Change tsconfig es5 -> es6
  • Add babelconfig .babelrc

2. Remove swiftmailer

  • Remove swiftmailer from bundles.php
  • Remove swiftmailer configs

3. Check Events

  • Use common ResourceEvents instead of specific sylius events (Should use only if controller based)

Migrate to 0.10

1. Change asset path to lowercase (Classname is still CamelCase)

Check all your file under assets and your [webpack.config.js]{.title-ref}`

js
const EnhavoEncore = require('@enhavo/core/EnhavoEncore');
const AppPackage = require('@enhavo/app/encore/AppPackage');
const AppThemePackage = require('@enhavo/app/encore/AppThemePackage');
const FormPackage = require('@enhavo/form/encore/FormPackage');

2. Change your security.yaml

yaml
security:
    encoders:
        Symfony\Component\Security\Core\User\User: plaintext
        Enhavo\Bundle\UserBundle\Model\UserInterface: sha512

    providers:
        entity_user_provider:
            entity:
                class: Enhavo\Bundle\UserBundle\Model\User

    firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        admin:
            user_checker: Enhavo\Bundle\UserBundle\Security\UserChecker
            guard:
                authenticators:
                    - Enhavo\Bundle\UserBundle\Security\Authentication\FormLoginAuthenticator
            pattern:  ^/admin/.*
            context: user
            form_login:
                provider:       entity_user_provider
                login_path:     /admin/login
                use_forward:    false
                check_path:     /admin/login/check
                failure_path:   /admin/login
                default_target_path: /admin
            logout:
                path:   /admin/logout
                target: /admin/login
            anonymous:  true

        user:
            user_checker: Enhavo\Bundle\UserBundle\Security\UserChecker
            guard:
                authenticators:
                    - Enhavo\Bundle\UserBundle\Security\Authentication\FormLoginAuthenticator

            pattern: ^/user/.*
            context: user
            form_login:
                provider:       entity_user_provider
                login_path:     /user/login
                use_forward:    false
                check_path:     /user/login/check
                failure_path:   /user/login
                default_target_path: /user/profile
            logout:
                path:   /user/logout
                target: /user/login
            anonymous:  true

        main:
            pattern: .*
            context: user
            user_checker: Enhavo\Bundle\UserBundle\Security\UserChecker
            form_login:
                provider:       entity_user_provider
                login_path:     /user/login
                use_forward:    false
                check_path:     /user/login/check
                failure_path:   /user/login
                default_target_path: /user/profile
            logout:
                path:   /user/logout
                target: /
            anonymous:  true

    access_control:
        - { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/login/check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/reset-password/.+, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/, role: ROLE_ADMIN }

        - { path: ^/user/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/user/login/check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/user/registration/.+, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/user/reset-password/.+, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/user/, role: ROLE_USER }

Migrate to 0.9

1. Add this line at the end of assets/enhavo/form.ts

js
Application.getView().checkUrl();

2. Create registry file assets/enhavo/registry/widget.ts

import RegistryPackage from "@enhavo/core/RegistryPackage";
import ApplicationInterface from "@enhavo/app/ApplicationInterface";
import AppWidgetRegistryPackage from "@enhavo/app/Toolbar/Widget/WidgetRegistryPackage";

export default class ViewRegistryPackage extends RegistryPackage
{
    constructor(application: ApplicationInterface) {
        super();
        this.registerPackage(new AppWidgetRegistryPackage(application));
    }
}

3. Add widget registry to assets/enhavo/main.ts

// Add import line
import WidgetRegistryPackage from "./registry/widget";

// Add register package line before load
Application.getWidgetRegistry().registerPackage(new WidgetRegistryPackage(Application));

Application.getVueLoader().load(() => import("@enhavo/app/Main/Components/MainComponent.vue"));

4. Rename routing manager service id enhavo_routing.manager.route to FQCN Enhavo\Bundle\RoutingBundle\Manager\RouteManager

5. Rename property to properties for route PrefixGenerator type.

yaml
enhavo_routing:
    classes:
        App\MyEntity:
            generators:
                prefix:
                    type: prefix
                    # before
                    property: title
                    # now
                    properties: title

6. If the action component create-action was used, you have to migrate it to open-action. `

The action type create is not affected.

7. Add form registry to assets/enhavo/index.ts

// Add import line
import FormRegistryPackage from "./registry/form";

// Add register package line before load
Application.getFormRegistry().registerPackage(new FormRegistryPackage(Application));

Application.getVueLoader().load(() => import("@enhavo/app/Index/Components/IndexComponent.vue"));

8. Add resource parameter to Action

This changes only may apply if you have this functions define by your own

// change this line
public function getPermission(array $options);

// to this line
public function getPermission(array $options, $resource = null);


// change this line
public function isHidden(array $options);

// to this line
public function isHidden(array $options, $resource = null);

9. Update your webpack.config.js.

The way how to include other bundles and configure your webpack/encore has changed. Just use the following lines if you never edit your webpack.config.js . If you edit this file before, you need to add the configs inside the js callbacks.

js
const EnhavoEncore = require('@enhavo/core/EnhavoEncore');
const AppPackage = require('@enhavo/app/Encore/EncoreRegistryPackage');
const FormPackage = require('@enhavo/form/Encore/EncoreRegistryPackage');
const MediaPackage = require('@enhavo/media/Encore/EncoreRegistryPackage');
const DashboardPackage = require('@enhavo/dashboard/Encore/EncoreRegistryPackage');
const UserPackage = require('@enhavo/user/Encore/EncoreRegistryPackage');

EnhavoEncore
  // register packages
  .register(new AppPackage())
  .register(new FormPackage())
  .register(new MediaPackage())
  .register(new DashboardPackage())
  .register(new UserPackage())
;

EnhavoEncore.add('enhavo', (Encore) => {
  // custom encore config
  // Encore.enableBuildNotifications();
});

EnhavoEncore.add('theme', (Encore) => {
  Encore
    // add theme entry and config
    .addEntry('base', './assets/theme/base')
});

module.exports = EnhavoEncore.export();

10. Enhavo\Bundle\NewsletterBundle\Provider\ProviderInterface changed

Return a test receiver with parameters now.

php
// before
public function getTestParameters(): array;

// after
public function getTestReceivers(NewsletterInterface $newsletter): array;

11. Newsletter template parameters changed.

The parameter parameters is now receiver.parameters

12. Delete all enhavo config files config/packages/enhavo_*

If you have other contents in that files then import yaml files from it's bundle. You may keep that changes. If you include search or translation configs, you can keep that lines as well but change it to yaml instead of yml

13. Update your routes.

Download this zip file </_static/download/migrate-routes-0.9.zip>{.interpreted-text role="download"} and overwrite the files in config/routes if they exists. Note that the file in your project probably named *.yml instead of *.yaml. If you made changes to the file before you have to merge the file yourself.

14. Delete file config/routes/enhavo_taxonomy.yaml if exists

15. Update BatchTypes to the new Type Component if you add custom batches.

16. Add packages to your composer.json

If you use dev-master as version in your composer.json, you have to add following packages to prevent minimum stability violence. If you are not use dev-master you can skip this step.

json
"dependencies": {
  "enhavo/doctrine-extension-bundle": "dev-master",
  "enhavo/metadata": "dev-master",
  "enhavo/type": "dev-master",
  // other packages
}

17. The DoctrineExtendListener has removed. You have to add metadata information to all your entities which extend from enhavo.

Check the Extend from resource </guides/resource/extend-from-resource>{.interpreted-text role="doc"} guide for more information. Notice that before the discrName was extend. If you add some other name, beware to also provide some Doctrine Migrations to update the discr column. If you don't know, if and for what resource you have to put the extends configuration. Just search for model inside config/packages/* and see where you redefine a model. At least for this models you have to provide the configuration.

18. Rename strategy type route to routable for Router.

yaml
enhavo_routing:
    classes:
        App\MyEntity:
            router:
                default:
                    # before
                    type: route
                    # now
                    type: routable

Migrate to 0.8

Providing a small guide to upgrade to enhavo 0.8. This guide is not complete and covers only the most common update steps.

Enhavo upgrade tasks

  • Update Grid entities to Blocks entities (Entities extends from AbstractBlock)
  • Update Grid factories to Blocks factories (Factories extend from AbstractBlockFactory)
  • Update Grid types to Blocks types (Types extend from AbstractBlockType)
  • Update Block form type (Extends from default AbstractType)
  • Update Grid content references (Using NodeInterface)
  • Migrate Grid data to block data structure (Using Doctrine migrations)
  • Rename Grid entities to Block (Optional)
  • Copy asset entrypoints structure (Copy also registry folder)
  • Migrate and add enhavo configs
  • Migrate and add enhavo routings
  • Migrate custom admin assets to webpack (Important for Version <0.7)
  • Update or create webpack.config.js
  • Require separate enhavo packages by composer
  • Use symfony 4 config and routing structure
  • Set language in config under enhavp_app.locale

Symfony upgrade tasks

  • Use Symfony 4 directory structure
  • Migrate config
  • Use FQCN for Form types
  • Remove getName and use getBlockPrefix for Form types
  • Inject private services
  • Update service definitions
  • Add Kernel
  • Add tag console.command to command services (Create service if not exists)