Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony sonata admin bundle without entity

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?

like image 910
falinsky Avatar asked Dec 27 '13 18:12

falinsky


1 Answers

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:

  1. The Admin service’s code (defaults to the service’s name)
  2. The model which this Admin class maps (required)
  3. 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.

like image 72
Shawn Avatar answered Sep 19 '22 16:09

Shawn