..我用Systfony 2.3.5使用FOSUSer Bundel和PUGXMultiUser Bundle做这个项目是什么家伙我想使用SonataAdmin Bundle但是在配置之后有关于Menu的这个问题,我在仪表板中看不到..这是配置,你认为我错过了什么!!
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: @PokTVBundle/Resources/config/admin.yml }
framework:
#esi: ~
translator: { fallback: %locale% }
secret: %secret%
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_proxies: ~
session: ~
fragments: ~
http_method_override: true
# 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
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: %kernel.root_dir%/data/data.db3
# path: %database_path%
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 }
#FOSBundle
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: POKEtudiant\UserBundle\Entity\User
service:
mailer: fos_user.mailer.twig_swift
user_manager: pugx_user_manager
#registration:
#confirmation:
#enabled: true
#from_email:
#address: noreply@POKEtudiant.com
#sender_name: Elamrani Abou Elassad
#PUGXBundle
pugx_multi_user:
users:
etudiants:
entity:
class: POKEtudiant\UserBundle\Entity\Etudiant
# factory:
registration:
form:
type: POKEtudiant\UserBundle\Form\Type\RegistrationEtudiantFormType
name: fos_user_registration_form
validation_groups: [etudiant_grp, Default]
template: UserBundle:Registration:etudiants.form.html.twig
profile:
form:
type: POKEtudiant\UserBundle\Form\Type\ProfileEtudiantFormType
name: fos_user_profile_form
#validation_groups: [Profile, Default]
recruteurs:
entity:
class: POKEtudiant\UserBundle\Entity\Recruiter
registration:
form:
type: POKEtudiant\UserBundle\Form\Type\RegistrationRecruiterFormType
template: UserBundle:Registration:recruteurs.form.html.twig
profile:
form:
type: POKEtudiant\UserBundle\Form\Type\ProfileRecruiterFormType
#SonataBlock
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:
#SonataKnp
knp_menu:
twig: # use "twig: false" to disable the Twig extension and the TwigRenderer
template: knp_menu.html.twig
templating: false # if true, enables the helper for PHP templates
default_renderer: twig # The renderer to use, list is also available by default
#SonataAdmin
sonata_admin:
title: PokTv
#title_logo: /bundles/acmedemo/fancy_acme_logo.png
#security:
#handler: sonata.admin.security.handler.noop
#acl_user_manager: fos_user.user_manager
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
history: SonataAdminBundle:CRUD:history.html.twig
preview: SonataAdminBundle:CRUD:preview.html.twig
delete: SonataAdminBundle:CRUD:delete.html.twig
batch: SonataAdminBundle:CRUD:list__batch.html.twig
batch_confirmation: SonataAdminBundle:CRUD:batch_confirmation.html.twig
# list related templates
inner_list_row: SonataAdminBundle:CRUD:list_inner_row.html.twig
base_list_field: SonataAdminBundle:CRUD:base_list_field.html.twig
# default values of block templates, they should extend the base_block template
list_block: SonataAdminBundle:Block:block_admin_list.html.twig
dashboard:
blocks:
- { position: left, type: sonata.admin.block.admin_list }
# display two dashboard blocks
#-
#position: left
#type: sonata.admin.block.admin_list
#settings:
#groups: [Movies]
#-
#position: right
#type: sonata.admin.block.admin_list
#settings:
#groups: [Series]
groups:
Movies:
items:
- sonata.admin.movies
Series:
items:
- sonata.admin.series
Foot:
items:
- sonata.admin.foot
sonata_doctrine_orm_admin:
# default value is null, so doctrine uses the value defined in the configuration
entity_manager:
templates:
form:
- SonataDoctrineORMAdminBundle:Form:form_admin_fields.html.twig
filter:
- SonataDoctrineORMAdminBundle:Form:filter_admin_fields.html.twig
types:
list:
array: SonataAdminBundle:CRUD:list_array.html.twig
boolean: SonataAdminBundle:CRUD:list_boolean.html.twig
date: SonataAdminBundle:CRUD:list_date.html.twig
time: SonataAdminBundle:CRUD:list_time.html.twig
datetime: SonataAdminBundle:CRUD:list_datetime.html.twig
text: SonataAdminBundle:CRUD:base_list_field.html.twig
trans: SonataAdminBundle:CRUD:list_trans.html.twig
string: SonataAdminBundle:CRUD:base_list_field.html.twig
smallint: SonataAdminBundle:CRUD:base_list_field.html.twig
bigint: SonataAdminBundle:CRUD:base_list_field.html.twig
integer: SonataAdminBundle:CRUD:base_list_field.html.twig
decimal: SonataAdminBundle:CRUD:base_list_field.html.twig
identifier: SonataAdminBundle:CRUD:base_list_field.html.twig
show:
array: SonataAdminBundle:CRUD:show_array.html.twig
boolean: SonataAdminBundle:CRUD:show_boolean.html.twig
date: SonataAdminBundle:CRUD:show_date.html.twig
time: SonataAdminBundle:CRUD:show_time.html.twig
datetime: SonataAdminBundle:CRUD:show_datetime.html.twig
text: SonataAdminBundle:CRUD:base_show_field.html.twig
trans: SonataAdminBundle:CRUD:show_trans.html.twig
string: SonataAdminBundle:CRUD:base_show_field.html.twig
smallint: SonataAdminBundle:CRUD:base_show_field.html.twig
bigint: SonataAdminBundle:CRUD:base_show_field.html.twig
integer: SonataAdminBundle:CRUD:base_show_field.html.twig
decimal: SonataAdminBundle:CRUD:base_show_field.html.twig
admin.yml
services:
sonata.admin.movies:
class: POKEtudiant\PokTVBundle\Admin\MoviesAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "Movies", label: "Movies", show_in_dashboard: "true" }
arguments:
- ~
- POKEtudiant\PokTVBundle\Entity\Movies
- ~
sonata.admin.series:
class: POKEtudiant\PokTVBundle\Admin\SeriesAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "Series", label: "Series" }
arguments:
- ~
- POKEtudiant\PokTVBundle\Entity\Series
- ~
sonata.admin.foot:
class: POKEtudiant\PokTVBundle\Admin\FootAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "Foot", label: "Foot" }
arguments:
- ~
- POKEtudiant\PokTVBundle\Entity\Foot
- ~
应用/配置/ routing.yml中
#PokTV Bundle
pok_tv:
resource: "@PokTVBundle/Resources/config/routing.yml"
prefix: /PokTV
#User Bundle
user:
resource: "@UserBundle/Resources/config/routing.yml"
prefix: /
#Sonata Admin
admin:
resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
prefix: /admin
_sonata_admin:
resource: .
type: sonata_admin
prefix: /admin
appKernel(registerBundles)
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new FOS\UserBundle\FOSUserBundle(),
new PUGX\MultiUserBundle\PUGXMultiUserBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\jQueryBundle\SonatajQueryBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
new POKEtudiant\UserBundle\UserBundle(),
new POKEtudiant\PokTVBundle\PokTVBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
答案 0 :(得分:6)
看起来您没有为您的用户配置ROLE_SONATA_ADMIN; 或者只是将它映射到security.yml,就像这样
security:
role_hierarchy:
ROLE_ADMIN: [ROLE_USER, ROLE_SONATA_ADMIN]
用户具有此角色后,必须显示菜单;
答案 1 :(得分:2)
检查您的twig文件以查看仍在使用哪个块。 sonata blocks部分只有sonata.admin.block.admin_list,应加载默认值。
您可以通过启用过滤器获得错误反馈: [对不起,这是我的第一个共鸣。你如何让格式化工作?] sonata_block: default_contexts:[cms] 例外: 默认: filter:debug_only 渲染器:扔 过滤器: debug_only:sonata.block.exception.filter.debug_only ignore_block_exception:sonata.block.exception.filter.ignore_block_exception keep_all:sonata.block.exception.filter.keep_all keep_none:sonata.block.exception.filter.keep_none 渲染器: 内联:sonata.block.exception.renderer.inline inline_debug:sonata.block.exception.renderer.inline_debug throw:sonata.block.exception.renderer.throw
然后在admin块下直接添加此行: 块: sonata.admin.block.admin_list: 上下文:[admin] 例外:{filter:keep_all,renderer:inline}