Sharp Context

Sharp provide a way to grab some request context values in the application code.

Ask for context

The class handling the context is Code16\Sharp\Http\Context\CurrentSharpRequest, which is a singleton. So at any point in the request, you can get it via:


or with the global helper:


Here's a quick example:

class MyForm extends SharpForm
    function buildFormFields()

The context is often useful in a Form situation to display or hide fields depending on the instance status (creation, update), or in a Validator to add an ID exception in a "unique" rule.


entityKey(): string

Grab the current entity key.

isEntityList(): bool

isShow(): bool

isForm(): bool

Find out the current page type.

isUpdate(): bool

isCreation(): bool

In Form case, check the current status.

instanceId(): string

In Form and Show cases, grab the instance id.

Returns a Collection of Code16\Sharp\Http\Context\Util\BreadcrumbItems

getCurrentBreadcrumbItem(): BreadcrumbItem

Get the current breadcrumb item.

getPreviousShowFromBreadcrumbItems(?string $entityKey = null): ?BreadcrumbItem

Get (if existing) the closest Show in the breadcrumb.


Get the value of a Global Filter: see the Global Filter documentation to know more about this feature.

Last Updated:
Contributors: philippe