Updating object properties in twig

后端 未结 6 813
借酒劲吻你
借酒劲吻你 2020-12-29 18:30

Is there a way to update an object\'s property in twig?

An object like the following is passed to twig:

object
   property1
   property2
6条回答
  •  借酒劲吻你
    2020-12-29 19:07

    A possible way to set a property is to create a method in the object which actually creates new properties:

    class Get extends StdClass 
      {
    
        protected function setProperty($name,$value = null)
        {
        $this->$name = $value;
        }
    
      }
    

提交回复
热议问题