繁体   English   中英

无法在树枝模板中呈现一些变量

[英]Can't render some variables in twig template

我已经使用ZF2编写了我的应用程序。 我有2个模块:邮件和文件。 来自邮件模块的所有变量都已呈现。 无法呈现目标文件。 当我做{{ dump(mail.file) }}它返回NULL 但是如果我做{{ dump() }} ,文件对象确实存在:

array (size=2)
  'mail' => 
    object(Mail\Entity\Incoming)[453]
      protected 'id' => int 8
      protected 'inNumber' => int 1
      protected 'inDate' => int 1320948000
      protected 'outNumber' => string '1' (length=1)
      protected 'outDate' => int 1320948000
      protected 'sheetsNumber' => int 1
      protected 'teaser' => string '' (length=0)
      protected 'file' => 
        object(File\Entity\File)[455]
          protected 'id' => int 5
          protected 'origName' => string 'eRa33cHgofw.jpg' (length=15)
          protected 'curName' => string 'eRa33cHgofw.jpg' (length=15)
          protected 'size' => int 284192
          protected 'type' => string 'image/jpeg' (length=10)
          protected 'uploaded' => int 1385736080
      protected 'sender' => 
        object(Mail\Entity\Sender)[457]
          protected 'id' => int 1
          protected 'name' => string 'ООО Ромашка' (length=21)
      protected 'type' => 
        object(Mail\Entity\Type)[459]
          protected 'id' => int 1
          protected 'name' => string 'Информация' (length=20)
      protected 'created' => int 1385736080
  'namespace' => string 'FileEntityFile' (length=14)

有人帮我吗?

Mail\\Entity\\Incoming类中的file属性protected因此只能从该类本身或Mail\\Entity\\Incoming类的任何子级中访问。 这就是为什么树枝无法访问该属性的原因。

Mail\\Entity\\Incoming类中将该属性设置为public或创建访问器函数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM