如何正确安装SonataDoctrineMongoDBAdminBundle?

2024-04-13

我真的很紧张,因为缺乏足够的资源来安装 SonataDoctrineMongoDBAdminBundle 及其依赖项,例如 sonataUserBundle。我已经尝试安装这个捆绑包 15 天了。我一次又一次地做了奏鸣曲官方页面上所说的一切。但它不能正常工作。将 sonataUserBundle 扩展为 ApplicationUserBundle 后,我的最终文档是:

User.php

<?php

/**
 * This file is part of the <name> project.
 *
 * (c) <yourname> <youremail>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Application\Sonata\UserBundle\Document;

use Sonata\UserBundle\Document\BaseUser as BaseUser;

/**
 * This file has been generated by the EasyExtends bundle ( http://sonata-project.org/bundles/easy-extends )
 *
 * References :
 *   working with object : http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/working-with-objects.html
 *
 * @author <yourname> <youremail>
 */
class User extends BaseUser
{
    /**
     * @var integer $id
     */
    protected $id;

    /**
     * Get id
     *
     * @return integer $id
     */
    public function getId()
    {
        return $this->id;
    }
}

组.php

<?php

/**
 * This file is part of the <name> project.
 *
 * (c) <yourname> <youremail>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Application\Sonata\UserBundle\Document;

use Sonata\UserBundle\Document\BaseGroup as BaseGroup;

/**
 * This file has been generated by the EasyExtends bundle ( http://sonata-project.org/bundles/easy-extends )
 *
 * References :
 *   working with object : http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/working-with-objects.html
 *
 * @author <yourname> <youremail>
 */
class Group extends BaseGroup
{
    /**
     * @var integer $id
     */
    protected $id;

    /**
     * Get id
     *
     * @return integer $id
     */
    public function getId()
    {
        return $this->id;
    }
}

配置.yml

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

framework:
    #esi:             ~
    translator:      { fallback: %locale% }
    secret:          %secret%
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_requirements: %kernel.debug%
    form:            ~
    csrf_protection: ~
    validation:      { enable_annotations: true }
    templating:
        engines: ['twig']
        #assets_version: SomeVersionScheme
    default_locale:  "%locale%"
    trusted_proxies: ~
    session:         ~
    fragments:       ~

# 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

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

doctrine_mongodb:
    connections:
        default:
            server: mongodb://localhost:27017
            options: {}
    default_database: test_database
    document_managers:
        default:
            auto_mapping: true


# app/config/config.yml
sonata_block:
    default_contexts: [cms]
    blocks:
        sonata.admin.block.admin_list:
            contexts:   [admin]

        #sonata.admin_doctrine_orm.block.audit:
        #    contexts:   [admin]

        sonata.block.service.text:
        sonata.block.service.rss:

        # Some specific block from the SonataMediaBundle
        #sonata.media.block.media:
        #sonata.media.block.gallery:
        #sonata.media.block.feature_media:      


sonata_user:
    security_acl: false
    manager_type: mongodb # can be orm or mongodb

sonata_admin:
    security:
        handler: sonata.admin.security.handler.role

    title:      Sonatas Project
    title_logo: /bundles/sonataadmin/logo_title.png
    templates:
        # default global templates
        layout:  SonataAdminBundle::standard_layout.html.twig
        ajax:    SonataAdminBundle::ajax_layout.html.twig
        dashboard: SonataAdminBundle:Core:dashboard.html.twig

        # default actions templates, should extend a global templates
        list:    SonataAdminBundle:CRUD:list.html.twig
        show:    SonataAdminBundle:CRUD:show.html.twig
        edit:    SonataAdminBundle:CRUD:edit.html.twig

    dashboard:
        blocks:
            # display a dashboard block
            - { position: left, type: sonata.admin.block.admin_list }

            # Customize this part to add new block configuration
            - { position: right, type: sonata.block.service.text, settings: { content: "<h2>Welcome to the Sonata Admin</h2> <p>This is a <code>sonata.block.service.text</code> from the Block Bundle, you can create and add new block in these area by configuring the <code>sonata_admin</code> section.</p> <br /> For instance, here a RSS feed parser (<code>sonata.block.service.rss</code>):"} }
            - { position: right, type: sonata.block.service.rss, settings: { title: Sonata Project's Feeds, url: http://sonata-project.org/blog/archive.rss }}

    # set to true to persist filter settings per admin module in the user's session

fos_user:
    db_driver:      mongodb # can be orm or odm
    firewall_name:  main
    user_class:     Application\Sonata\UserBundle\Document\User

    group:
        group_class: Application\Sonata\UserBundle\Document\Group 

安全.yml

jms_security_extra:
    secure_all_services: false
    expressions: true

security:

    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    role_hierarchy:
        ROLE_ADMIN:       [ROLE_USER, ROLE_SONATA_ADMIN]
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
        SONATA:
            - ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT  # if you are using acl then this line must be commented

    providers:
        fos_userbundle:
            id: fos_user.user_manager

    firewalls:
        # -> custom firewall for the admin area of the URL
        admin:
            switch_user:        true
            context:            user
            pattern:            /admin(.*)
            form_login:
                provider:       fos_userbundle
                login_path:     /admin/login
                use_forward:    false
                check_path:     /admin/login_check
                failure_path:   null
                use_referer:    true
            logout:
                path:           /admin/logout
                target:         /admin/login

            anonymous:    true
        # -> end custom configuration

        # defaut login area for standard users
        main:
            switch_user:        true
            context:            user
            pattern:            .*
            form_login:
                provider:       fos_userbundle
                login_path:     /login
                use_forward:    false
                check_path:     /login_check
                failure_path:   null
            logout:             true
            anonymous:          true

    access_control:
        # URL of FOSUserBundle which need to be available to anonymous users
        - { path: ^/_wdt, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/_profiler, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }

        # -> custom access control for the admin area of the URL
        - { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/login-check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        # -> end

        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }

        # Secured part of the site
        # This config requires being logged for the whole site and having the admin role for the admin part.
        # Change these rules to adapt them to your needs
        - { path: ^/admin, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }
        - { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }  

毕竟我跑了:

php app/console fos:user:create --super-admin

该任务告诉我用户创建成功。然后我检查我的 mongodb,只有一条包含 3 个字段的记录。

这是输出:

> db.fos_user_user.findOne();
{
    "_id" : 1,
    "createdAt" : ISODate("2013-05-25T19:43:52Z"),
    "updatedAt" : ISODate("2013-05-25T19:43:52Z"),
    "gender" : "u"
}

正如您所看到的,奏鸣曲或 fos 的文档文件中没有指向用户名或密码或其他字段。我安装了 SonataDoctrineORMAdminBundle 来查看 SonataAdminBundle 是否有任何问题,但它的工作方式就像 mysql 的魅力一样。

我变得如此疯狂。请告诉我,使用 mongoDB 安装 sonataAdminBundle 的正确方法是什么?

感谢您的关注。


似乎继承映射工作不正常,我按照说明进行操作,但它导致了同样的问题。我通过将对 BaseUser 的引用更改为 FOS\UserBundle 提供的类来修复它

# Application\Sonata\UserBundle\Document\User.php

namespace Application\Sonata\UserBundle\Document;

//use Sonata\UserBundle\Document\BaseUser as BaseUser;
use FOS\UserBundle\Document\User as BaseUser;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何正确安装SonataDoctrineMongoDBAdminBundle? 的相关文章

随机推荐

  • 在多个生命周期中运行 Maven 目标

    我有一个情况 我想在验证阶段和报告阶段运行 cobertura 插件 我有两个配置文件 它们都应该运行 cobertura 插件 但在配置文件 A 中 我只想创建 xml html 输出 但在配置文件 B 中 我将生成包含这些结果的完整站点
  • Selenium C# DefaultWait IgnoreExceptionTypes 不起作用

    我在等待 WebElement 可单击时使用 DefaultWait 尽管 TargetIncationException 是等待期间要忽略的异常列表中的异常之一 但在达到超时期限之前 我仍然有测试因该异常而失败 这不是我所期望的 publ
  • Linux下如何用C实现定时器的回调函数

    我已经在许多论坛上搜索了几天可能的解决方案 但没有运气 我在这里发布我的问题 非常感谢您的回复 主意 使用脚本控制灯光 Linux下C语言 应用场景 我有三盏灯 红 蓝 绿 脚本有控制它们的时间表 例如 从现在起10秒后 亮红灯2秒 从现在
  • 组合框 - 键入选择,然后单击焦点外 - 不会选择键入的项目

    我的组合框有问题 我有一个事件处理程序OnClick它根据选择的项目刷新数据 问题是当这种情况发生时 下拉组合框列出各种选项 在键盘上键入以查找匹配的项目 组合框更改此选择并调用OnClick event 由于此选择 事件 我的屏幕刷新 单
  • 如何使用reactJs根据背景颜色更改字体颜色

    我的容器有动态背景 它将由用户更改 因此我需要根据背景颜色设置文本颜色 例如 我设置容器的黑色背景 然后我需要为文本设置白色 我正在为我的应用程序使用 ReactJs 和材料 UI 库 请建议一些好的路径 请参阅下面的示例代码 import
  • 尝试加载方向变化的新视图

    我正在尝试在 Xcode 中创建一个应用程序 当手机从一个方向旋转到另一个方向时 该应用程序将切换到新视图 这是 switchviewcontroller h 文件代码 import
  • 下标变量

    有没有什么方法可以强制 Mathematica 独立于无下标变量来处理下标变量 进一步来说 比如说 我有以下定义 Subscript b 1 1 2 Subscript b 2 3 4 b Join Subscript b 1 Subscr
  • VS .Net:在安装程序项目中发布“来自 的主要输出”的构建事件

    我在项目中使用以下构建后操作 将库合并到我的应用程序中 IF ConfigurationName Debug GOTO end cp TargetPath TargetDir app unmerged exe del TargetPath
  • 将对象序列化为 XML

    我有一个继承的 C 类 我已经成功地 构建 了该对象 但我需要将对象序列化为 XML 有简单的方法吗 看起来该类已设置为序列化 但我不确定如何获取 XML 表示形式 我的类定义如下 System CodeDom Compiler Gener
  • ARC 是否保留无主引用的计数?

    ARC 是否保留对对象的无主引用的计数 那么 如果一个对象的强引用计数达到 0 并且该对象的无主引用计数 gt 0 则该对象将被取消初始化但不会被取消分配 只有当强引用计数和无主引用计数达到 0 时 它才会被释放 我在 Medium 上的一
  • GCC 错误:非命名空间范围中的显式专业化

    我正在尝试移植以下代码 我知道该标准不允许在非名称空间范围内显式专业化 我应该使用重载 但我只是找不到在这种特殊情况下应用此技术的方法 class VarData public template lt typename T gt bool
  • vs2008/vs2010 在 TextBox 中是否有插入符位置更改事件?

    我需要留意文本框内的插入符号位置 有这方面的活动吗 我不想为此使用计时器 例如 每 10 毫秒检查一次位置是否发生变化 我正在使用 Windows 窗体 本机 Windows 控件不会为此生成通知 尝试解决此限制会带来痛苦 您只是无法分辨插
  • 一次性返回所有可枚举的yield return;不循环

    我有以下函数来获取卡的验证错误 我的问题涉及处理 GetErrors 两种方法具有相同的返回类型IEnumerable
  • git:小型项目工作

    我目前正在尝试遵循 Pro Git 书中提到的基于小型项目的工作组 http progit org book ch5 2 html http progit org book ch5 2 html 所以 这是我的设置 Live Website
  • EF4 CTP5 自引用分层实体映射

    好吧 这应该很容易 但我一直在抓狂 这是我的 POCO 与机器零件有关 因此零件可以包含在父零件中 public class Part public int ID get set public string Name get set pub
  • 如何更新数组范围变量中的值?

    我有一个存储存档的作用域变量 viewScope MY SCOPE new Array viewScope MY SCOPE push id0 0 true viewScope MY SCOPE push id1 1 false viewS
  • 扩展 std 命名空间被视为未定义行为的原因是什么?

    为什么要添加名字std命名空间未定义的行为 显而易见的答案是 因为标准是这么说的 例如在 C 14 命名空间 std 17 6 4 2 1 1 中 如果 C 程序向命名空间添加声明或定义 则其行为是未定义的std或到一个 命名空间内的命名空
  • 以编程方式在片段之间切换

    我想在 1 个活动中的 2 个片段之间切换 因此另一个片段应始终替换当前片段 但我找不到我的错误 我的主要活动 Override protected void onCreate Bundle savedInstanceState super
  • 键入lattice命令后图形不显示

    我安装了这个包lattice 并输入xyplot 没有错误消息 但也没有显示图表 我尝试切换到plot 而且效果很好 知道为什么会这样吗 谢谢你 尝试这个 require lattice require stats Depth lt equ
  • 如何正确安装SonataDoctrineMongoDBAdminBundle?

    我真的很紧张 因为缺乏足够的资源来安装 SonataDoctrineMongoDBAdminBundle 及其依赖项 例如 sonataUserBundle 我已经尝试安装这个捆绑包 15 天了 我一次又一次地做了奏鸣曲官方页面上所说的一切