Skip to content

Upgrading from 5.x to 6.x

This version brings more breaking changes than the previous ones, since we decided to clean up old code parts and to fully embrace PHP 7.x type hinting.

Laravel 7+ and php 7.4+ required

It's not a BC, but still, minimal requirements are now these.

Type hinting everywhere

In order to reinforce the API, we decided to use PHP type hinting everywhere (well, almost everywhere). This means that you'll have to add parameters and return types on EntityLists, Forms, Shows, Filters, Commands, EntityStates...

Sharp URLs changed

Not sure it's really a BC, unless you use direct links to a Sharp EntityList, Show, or Form in a notification for instance. Anyways all URLs changed as a consequence of the new breadcrumb feature.

LinkToEntity must be replaced by LinkTo[XXX] classes

The 5.0 LinkToEntity class has been removed in favor of:

  • LinkToEntityList
  • LinkToForm
  • LinkToShowPage
  • LinkToSingleForm
  • LinkToSingleShowPage

See related documentation.

This method is now expecting a LinkTo[XXX] instance.

php
    SharpPanelWidget::make("activeSpaceships")
        ->setInlineTemplate("<h1>{{count}}</h1> spaceships in activity")
        ->setLink(LinkToEntityList::make("spaceship"));
    SharpPanelWidget::make("activeSpaceships")
        ->setInlineTemplate("<h1>{{count}}</h1> spaceships in activity")
        ->setLink(LinkToEntityList::make("spaceship"));

In order to use the new LinkTo[XXX] classes, the Closure is now expected to either return a string (URL) or a LinkTo[XXX] instance.

php
    SharpOrderedListWidget::make("widget")
        ->buildItemLink(function($item) {
            return LinkToEntityList::make("entity")->addFilter("type", $item['id']); 
        });
    SharpOrderedListWidget::make("widget")
        ->buildItemLink(function($item) {
            return LinkToEntityList::make("entity")->addFilter("type", $item['id']); 
        });

SharpContext was removed in favor of CurrentSharpRequest

The Code16\Sharp\Http\Context\SharpContext class and the Code16\Sharp\Http\WithSharpContext trait were removed. If you need to know the current context, use the new Code16\Sharp\Http\Context\CurrentSharpRequest class, documented here.

Deprecated filter classes were removed

EntityListFilter, EntityListMultipleFilter, EntityListRequiredFilter, DashboardFilter, DashboardRequiredFilter, DashboardMultipleFilter, which were deprecated in 5.x, were removed (and replaced by EntityLostSelectFilter, EntityListSelectMultipleFilter, EntityListSelectRequiredFilter ...).

SharpUploadModelAttributeTransformer class was removed

I was used to EntityList as an attribute transformer in EntityList, for SharpUploadModel. In 6.x, you should used in replacement:

-⁠>setCustomTransformer("picture", (new SharpUploadModelThumbnailUrlTransformer(100))-⁠>renderAsImageTag())

sharp_markdown_thumbnails() helper is now deprecated

Replaced by sharp_markdown_embedded_files(), to take benefit of the feature of file embeds in the Markdown field (see documentation).

EntityState color const are deprecated

PRIMARY_COLOR, SECONDARY_COLOR, ... are deprecated. For the primary color, use the new config config('sharp.theme.primary_color').

For other legacy colors, replace with the following hex code:

ConstColor Hex
PRIMARY_COLOR"#5596E6"
SECONDARY_COLOR"#FD7400"
GRAY_COLOR"#8C9BA5"
LIGHTGRAY_COLOR"#EFF2F5"
DARKGRAY_COLOR"#394B54"

Released under the MIT License.