Symfony sonata admin bundle without entity

php, sonata-admin, symfony

Solution

In the documentation found here: http://sonata-project.org/bundles/admin/master/doc/reference/getting_started.html

It looks like in the create an admin section that #2 requires a model:

- The Admin service’s code (defaults to the service’s name)

- The model which this Admin class maps (required)

- The controller that will handle the administration actions (defaults to SonataAdminBundle:CRUDController)

The sample shows the service setup with manager_type as an ORM:

# Acme/DemoBundle/Resources/config/admin.yml
services:
    sonata.admin.post:
        class: Acme\DemoBundle\Admin\PostAdmin
        tags:
            - { name: sonata.admin, manager_type: orm, group: "Content", label: "Post" }
        arguments:
            - ~
            - Acme\DemoBundle\Entity\Post
            - ~
        calls:
            - [ setTranslationDomain, [AcmeDemoBundle]]

Now in general symfony doesn't set hard requirements on what a model is. It can be doctrine or something custom you build. In the case of services it is just an object. I don't see anywhere in the documentation says that you need a database.

Problem

Is there the way to use sonata admin bundle without entity - so without doctrine? I need to list files on some directory, this list is not stored in database. The first approach I tried was to declare my own Model manager, but there are some places which require doctrine queries etc. I know, that there is document manager for mongo and sonata mongo admin, but in my case it's not so helpful. Any ideas?

Original source

Related problems