- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我在这上面停留了几个小时。
我有管理类来列出所有类别,并且在一个表列中有相关产品(产品实体):Table example相关代码:
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('name')
->add('products') // Entity Product, @ORM\OneToMany
->add('ord')
;
}
我需要做的是根据“(boolean) product.active”隐藏不活动的产品,但我无法弄清楚。我知道“createQuery”方法,但它不起作用。当我生成 SQL 并直接运行查询时,它可以正常工作,但在这里看起来我只能使用 ProxyQuery 来过滤类别,然后在单独的查询中查询所有产品(我不确定如何更改这个单独的查询)。
public function createQuery($context = 'list')
{
$query = parent::createQuery($context);
$q = new ProxyQuery($query->join(sprintf('%s.products', $query->getRootAlias()), 'p')
->andWhere('p.active = :act')->setParameter('act', true));
return $q;
}
谢谢你的帮助
最佳答案
您可以将字段类型更改为空或实体并添加 query_builder option调整使用的查询:
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('name')
->add('products', null, array(
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('qb')
->leftjoin('qb.products', 'p')
->where('p.active = :act')
->setParameter('act', true)
}
));
}
我没有用 oneToMany 关系测试它。
这个topic里面有一些信息
关于php - configureListFields 中的 Sonata Admin 自定义查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33293419/
我使用 Sonata EasyExtends 包扩展了 Sonata 项目中的用户包。 默认放在 src/Application/Sonata/UserBundle 下 现在我想自定义扩展类并添加一些
我已经设置了一个奏鸣曲管理界面,它允许用户创建特定的内容,但是如何限制用户编辑其他用户创建的内容? 为了争论起见,用户登录并创建博客。 在博客 ListView 中,应该只显示用户创建的博客。 目前,
我正在使用奏鸣曲管理,并且我正在覆盖模板。 我在这个模板中创建了一个选择,当我显示页面时,我看不到我的选择,而是一个带有 UL 和 LI 的 html 代码。 Sonata 似乎通过他的代码覆盖了他模
我尝试在 Sonata Admin Bundle 的 sidebad 中配置自定义管理菜单,但我不明白该怎么做? 谢谢 卓 最佳答案 侧边栏导航没有特定的配置,它使用仪表板配置来生成。 要查看它,您必
我遵循了安装指南中的所有说明,但仍然在 Symfony 4 应用程序上安装 Sonata User Bundle 时出现此错误: Column name `id` referenced for rel
我在 Symfony 4 应用程序上安装 Sonata Media Bundle 时遇到一些错误,这些错误不适用于 Symfony 2.8。 第一个错误: sensio/generator-bund
我是 Sonata Admin 的新手。 我在里面有仪表盘模板,但是找不到仪表盘的 Controller ,我需要仪表盘文件中的动态数据。 谁能帮帮我? 谢谢。 最佳答案 /dashboard 默认由
我在 Symfony 4 应用程序上安装 Sonata Media Bundle 时遇到一些错误,这些错误不适用于 Symfony 2.8。 第一个错误: sensio/generator-bund
我知道这个主题已经开放,但几个月后他们根本没有答案,当我尝试回答以了解这位作者是否有任何解决方案时......我的评论被删除了。所以我要再次发布这个问题。 我正在使用 SonataAdminBunbd
我试图让奏鸣曲像这样工作: - 如果普通用户登录,他将被重定向到“/” - 如果管理员登录,他将被重定向到“/admin/dashboard” 我尝试使用 app/config/security.ym
我已按照本教程进行操作,并成功运行:http://sonata-project.org/bundles/admin/master/doc/reference/getting_started.html
我在 sonata admin 中更改文档的父级时遇到问题。 我的文档有这样的属性: /** * @PHPCRODM\Children(filter="teaserimage*", cascade
我在使用 Sonata Formatter Bundle 时遇到问题. 在我的 config.yml 中,我有以下内容(除其他外): imports: - { resource: sonata
我可以使用 Sonata User Bundle 将 FOS 包集成到 sonata Admin 包中。我的登录功能正常。现在我想添加 FOSUserBundle 中的更改密码等功能到 sonata
我正在尝试设置表单类型“sonata_type_immutable_array”,如下所示: ->add('metadatos', 'sonata_type_immutable_array', arr
我想将奏鸣曲媒体包用于我的包中的媒体。 我有一个实体应该有一个画廊。安装奏鸣曲媒体包并生成 easy:extends 后,有 3 个不同的实体: 媒体.php Gallery.php GalleryH
以前,我们可以执行以下操作: ->add('workDate', 'doctrine_orm_date_range', array(), null, array('format' => 'dd-MM
我安装了 Sonata Media Bundle,但我没有使用该 bundle 的图库部分。 如何禁用图库? 我使用的是 Symfony 2.3,并且根据文档安装了标准的 Media Bundle。
如何从奏鸣曲管理面板中删除奏鸣曲项目链接。 感谢您的帮助。谢谢 最佳答案 您需要覆盖 sonata-project/admin-bundle/Resources/views/standard_layo
我安装了来自同一供应商的 sonata 管理包和通知包。但是我不想在管理面板上显示通知包。 我知道,为了做到这一点,我可以使用: show_in_dashboard="false" 我已将它放在 ve
我是一名优秀的程序员,十分优秀!