Important

You are browsing the documentation for version 3.1 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.

See our Release Process documentation for more information on the currently supported and upcoming releases.

Content Providers

OroPlatform is a hybrid application that supports JS navigation, but it still renders a lot on server side. Usually when a user changes the current page, the application reloads only the content part, so there are parts that not required to be rendered on sever side for each request. To allow a developer to include partial content in the hash navigation response, content providers were introduced.

Content Provider Implementation

To implement a content provider, you need to implement OroBundleUIBundleContentProviderContentProviderInterface and register your class as a service with tag oro_ui.content_provider. The alias attribute of this tag is required and it is used to specify a unique name of the content provider.

Optional Providers

By default, all content providers are enabled but if content generated by your provider is optional, you can pass the enabled: false attribute to the tag of provider’s service definition. After that, the content will not be added to response, but optional providers ca be enabled if you pass their names through request parameter _enableContentProviders.

Twig

When a page is loaded for the first time, its content is mostly rendered by twig. To get content from the content providers from the twig template, oro_ui_content_provider_manager global variable was added. It contains an instance of OroBundleUIBundleContentProviderContentProviderManager.

Example:

Getting an array of all flash:

1{% set contentProviderContent = oro_ui_content_provider_manager.getContent(['flashMessages'])|first %}