Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Example] Integrate custom entity into the administration interface #84

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

niklasnatter
Copy link
Contributor

@niklasnatter niklasnatter commented Nov 2, 2020

What's in this PR?

This PR demonstrates how to integrate an entity into the administration interface of Sulu. The example implements a simple Event entity that consists of a name, a start-date and an end-date. The entity is persisted using Doctrine and the API for managing the entity is implemented using a Symfony controller.

Have a look at the Extend Admin UI documentation for more information about the changes in this PR.

Screenshot 2020-10-27 at 16 37 37

To apply the changes, the schema of the database needs to be updated by executing bin/console doctrine:schema:update --force. Furthermore, the permissions for the Event entity need to be added to the User user role via the administration interface.

@niklasnatter niklasnatter marked this pull request as draft November 2, 2020 08:53
@niklasnatter niklasnatter added the Example Example implementations label Nov 2, 2020
@niklasnatter niklasnatter force-pushed the example/custom-entity branch 3 times, most recently from 2138884 to 19b7d58 Compare November 9, 2020 13:35
@niklasnatter niklasnatter force-pushed the example/custom-entity branch 2 times, most recently from 9f4a7f0 to 4653f9f Compare November 30, 2020 16:00
{
if ($this->securityChecker->hasPermission(Event::SECURITY_CONTEXT, PermissionTypes::EDIT)) {
$rootNavigationItem = new NavigationItem('app.events');
$rootNavigationItem->setIcon('su-calendar');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Available icons are documented in the Sulu Javascript Docs.

<list xmlns="http://schemas.sulu.io/list-builder/list">
<key>events</key>

<properties>
Copy link
Contributor Author

@niklasnatter niklasnatter Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List configurations can include fields of associated entities by defining <join> tags. An example can be found in the list configuration of the built-in contact entity.

@niklasnatter niklasnatter force-pushed the example/custom-entity branch 2 times, most recently from 737467e to 2f49214 Compare February 3, 2021 10:18
<entity-name>App\Entity\Event</entity-name>
</property>

<property name="startDate" visibility="yes" translation="app.start_date" type="date">
Copy link
Contributor Author

@niklasnatter niklasnatter Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Available values for the type attribute of <property> tags are printed to the development console of the browser when an invalid type such as invalid-property-type is used in a list configuration.

>
<key>event_details</key>

<properties>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The form view can be structured by using <section> tags in the form configuration. An example can be found in the form configuration of the built-in contact entity.

</meta>
</property>

<property name="startDate" type="date" colspan="6">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Available values for the type attribute of <property> tags are printed to the development console of the browser when an invalid type such as invalid-property-type is used in a form configuration.

@niklasnatter niklasnatter force-pushed the example/custom-entity branch from 66a3d03 to 18cd7be Compare June 20, 2022 17:42
@sulu sulu deleted a comment from alexander-schranz Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Example Example implementations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant