1

当我尝试请求在奏鸣曲中列出对象时出现此错误:

您请求了一个不存在的服务“”。

这是我的 config.yml:

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.xml }

framework:
    #esi:             ~
    #translator:      { fallback: %locale% }
    translator:      ~
    secret:          %secret%
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_parameters: %kernel.debug%
    form:            true
    csrf_protection: true
    validation:      { enable_annotations: true }
    templating:      { engines: ['twig'] } #assets_version: SomeVersionScheme
    default_locale:  %locale%
    trust_proxy_headers: false # Should Request object should trust proxy headers (X_FORWARDED_FOR/HTTP_CLIENT_IP)
    session:         ~

# Twig Configuration
twig:
    debug:            %kernel.debug%
    strict_variables: %kernel.debug%

# Assetic Configuration
assetic:
    debug:          %kernel.debug%
    use_controller: false
    bundles:        [ ]
    #java: /usr/bin/java
    filters:
        cssrewrite: ~
        #closure:
        #    jar: %kernel.root_dir%/Resources/java/compiler.jar
        #yui_css:
        #    jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar

# Doctrine Configuration
doctrine:
    dbal:
        driver:   %database_driver%
        host:     %database_host%
        port:     %database_port%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%
        charset:  UTF8

    orm:
        auto_generate_proxy_classes: %kernel.debug%
        auto_mapping: true

# Swiftmailer Configuration
swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%
    spool:     { type: memory }

fos_user:
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
    firewall_name: main
    user_class: Sports\UserBundle\Entity\User
    registration:
        confirmation:
            enabled:    true
    from_email:
        address: tirengarfio@gmail.com
        sender_name: Javier Garcia


sonata_admin:
    title:      Sonata Project
    title_logo: /bundles/sonataadmin/logo_title.png

这是我的 services.xml:

<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/dic/services/services-1.0.xsd">
    <services>
       <service id="sonata.admin.tag_admin" class="Sonata\DefaultBundle\Admin\TagAdmin">
          <tag name="sonata.admin" manager_type="orm" group="Posts" label="Blog"/>
          <argument />
          <argument>Sonata\DefaultBundle\Admin\TagAdmin</argument>
          <argument>SonataAdminBundle:CRUD</argument>
          <call method="setTranslationDomain">
              <argument>fjaksa</argument>
          </call>
      </service>
   </services>
</container>
4

1 回答 1

0

此错误意味着您没有为当前控制器“”服务(控制器也是空的^_^)

在 stackoverflow 上搜索示例有十几个示例!

也许这项服务会起作用:

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
   <service id="sonata.admin.tag_admin" class="Sonata\DefaultBundle\Admin\TagAdmin">
      <tag name="sonata.admin" manager_type="orm" group="Posts" label="Blog"/>
      <argument />
      <argument>Sonata\DefaultBundle\Admin\TagAdmin</argument>
      <argument />
      <call method="setTranslationDomain">
          <argument>fjaksa</argument>
      </call>
  </service>

于 2016-10-24T11:15:32.337 回答