سؤال

When I try to use the argument setSubClasses in my services definition, the name of the subclass added to the Admin has a letter removed

Here's my definition

sonata.admin.question:
    class: Hippy\ScavengerHuntBundle\Admin\QuestionAdmin
    tags:
        - { name: sonata.admin, manager_type: orm, group: "Questions", label: "Question" }
    arguments:
        - ~
        - Hippy\ScavengerHuntBundle\Entity\Question
        - ~
    calls:
        - [ setTranslationDomain, [HippyScavengerHuntBundle]]
        - [ setSubClasses, [{lettersInOrderQuestion : "Hippy\ScavengerHuntBundle\Entity\LettersInOrderQuestion"}]]

In my admin class, under the configureFormFields method, I put the following line and the result was quite surprising:

var_dump($this->getSubClasses());

The result:

array (size=1)
  'lettersInOrderQuestion' => string 'Hippy\ScavengerHuntBundle\Entity
ettersInOrderQuestion' (length=56)

It looks like the "\L" got removed somehow... normally, it would be Entity\LettersInOrderQuestion not EntityettersInOrderQuestion

هل كانت مفيدة؟

المحلول

Don't put your namespace around the namespace. Therefore, you should write the following :

{lettersInOrderQuestion : Hippy\ScavengerHuntBundle\Entity\LettersInOrderQuestion}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top