0

I'm following documentation for adding custom entities in Sulu:

https://docs.sulu.io/en/2.2/book/extend-admin.html#list-configuration-and-controller

and it describes how to create XML file that additionally describes my custom entity type, but it's not mentioned where to place that file and how to name it?

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

    <properties>
        <property name="id" visibility="no" translation="sulu_admin.id">
            <field-name>id</field-name>
            <entity-name>App\Entity\Event</entity-name>
        </property>

...

So how to name and where to place that XML file please?

MilanG
  • 6,994
  • 2
  • 35
  • 64

1 Answers1

1

Theoretically you can place such files wherever you want, as long as you configure the paths of those directories, so that sulu knows, where it can find it. But sulu automatically configures config/forms/ as directory to search for forms and config/lists/ for lists. So in most cases you should use those directories. Using other directories is just necessary, if you want to create forms or lists in a custom bundle.

About the naming, it's recommended to name the file the same as the list key, in your case events.xml

Luca Rath-Heel
  • 210
  • 1
  • 8
  • Great. I also found your example here: https://github.com/sulu/sulu-demo/blob/master/config/lists/albums.xml so I figured it out by "my self", but generally, would be helpful to have things like that as part of documentation. – MilanG May 10 '21 at 11:47
  • 1
    Thanks for your feedback! Yes I totally agree, there are some parts of sulu which could be documented better. We know that and we are always very happy to review pull requests from our community to fix such things – Luca Rath-Heel May 10 '21 at 12:19
  • One suggestion is that when ever you provide some code you should also provide rules (or hints) how to name the file and where to place it. Another suggestion is to use variables / labels built of at least 2 words in your examples. I.e. if your variable is "event" and mine is "news event" I don't know should I name it "news-event", "news_event" or "newsEvent" or something else. Maybe its obvious for some people, but not for all. – MilanG May 11 '21 at 07:24