Skip to content

v2.0.0

Compare
Choose a tag to compare
@robertvanlienden robertvanlienden released this 20 Jan 18:12
c413217

What's Changed

Because of fact that the image relation on the MenuItem model has been removed, we've decided to consider this release as a API change.

The reason we've decided to remove the image from an MenuItem is because we almost never use the image feature.
99% of the situations where we install this module , we've extended MenuItem to remove the image...

Since release 2.0.0 we do this the other way; A menu item doen not have a image, but of course you can extend a MenuItem model to add your own images.

Update from 1.* to 2.*

Situation; You remove the image by an extension on MenuItem

Please remove remove the code that removes the Image field from your MenuItemExtension.
For the rest; in this situation, you can safely update to 2.*.

Situation; You use the MenuItem image from 1.*

In this situation, you need to create a extension on MenuItem.
The following snippets is an simple example how to "restore" the Image property when upgrading to 2.*, you can use this as reference when upgrading;

app/src/Extensions/MenuItemExtension.php

<?php

namespace App\Extensions;

use SilverStripe\Assets\Image;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DataExtension;

class MenuItemExtension extends DataExtension
{
    private static $has_one = [
        'Image' => Image::class,
    ];

    private static $owns = [
        'Image',
    ];

    public function updateCMSFields(FieldList $fields)
    {
        $fields->addFieldToTab('Root.Main', $fields->dataFieldByName('Image')->setFolderName('Menus')->setDescription('Optional image, can be used in some templates.'));

        parent::updateCMSFields($fields);
    }

}

mysite.yml

---
Name: mysite
---
TheWebmen\Menustructure\Model\MenuItem:
  extensions:
    - App\Extensions\MenuItemExtension

Full Changelog: 1.1.0...2.0.0