【问题标题】:Symfony2 and Propel bundle: add additional filter to the Propel param converterSymfony2 和 Propel 包:向 Propel 参数转换器添加额外的过滤器
【发布时间】:2014-03-22 15:56:27
【问题描述】:

我在我的一个控制器中使用 Propel 参数转换器:(Symfony 2.4.2 + Propel 1.7)

 * @ParamConverter("center", converter="propel", class="MyCompany\Bundle\CoreBundle\Model\Center")

效果很好,但我想添加额外的过滤器,通常是在isVisible 字段上添加(但过滤器可能更复杂),有可能吗?事实上,我想要的是使用我的模型的自定义查询函数,而不是基本的findPk() 函数。

【问题讨论】:

    标签: php symfony orm propel


    【解决方案1】:

    如果要指定用于查找实体的存储库方法,可以添加选项“repository_method”

     * @ParamConverter("center", converter="propel", class="MyCompany\Bundle\CoreBundle\Model\Center", options={"repository_method" = "findByCustomQuery"})
    

    【讨论】:

    • Juts 测试器,不幸的是,Propel 似乎不支持此选项,而只有 Doctrine 支持。
    • Oki,你的意思是推进 1.7 => 推进 1.1.7,因为版本 1.7 不存在
    • 我认为这不能在不修改代码的情况下完成。正在寻找 sn-p。
    • 没错,我刚刚提出了一个拉取请求github.com/arffak/PropelBundle/commit/…
    • 有了这个mofication你可以使用“query_method”选项==> @ParamConverter("center", converter="propel", class="MyCompany\Bundle\CoreBundle\Model\Center", options= {"query_method" = "findByCustomQuery"})
    猜你喜欢
    • 1970-01-01
    • 2023-03-25
    • 2014-11-27
    • 1970-01-01
    • 1970-01-01
    • 2013-01-24
    • 2014-08-30
    • 2012-09-17
    • 1970-01-01
    相关资源
    最近更新 更多