Skip to content

Commit c817f0c

Browse files
committed
Generic object support
1 parent a13769e commit c817f0c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/aleksip/DataTransformPlugin/Twig/PatternDataNodeTrait.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,20 @@ public function setData($data)
3737
$this->setData($v);
3838
}
3939
$this->data .= ')';
40-
} elseif ($data instanceof Attribute) {
41-
$this->data .= 'new \Drupal\Core\Template\Attribute(';
42-
$this->setData($data->toArray());
40+
} elseif (is_object($data)) {
41+
$this->data .= 'unserialize(';
42+
$this->data .= $this->string(serialize($data));
4343
$this->data .= ')';
4444
} else {
45-
$this->data .= sprintf('"%s"', addcslashes($data, "\0\t\"\$\\"));
45+
$this->data .= $this->string($data);
4646
}
4747
}
4848

49+
protected function string($value)
50+
{
51+
return sprintf('"%s"', addcslashes($value, "\0\t\"\$\\"));
52+
}
53+
4954
protected function addTemplateArguments(\Twig_Compiler $compiler)
5055
{
5156
$variables = $this->hasNode('variables')

0 commit comments

Comments
 (0)