For a example, if we pass a table object to the twig view, how can we get the class name of that object like 'Table'.
class Table{
}
$table = new Table();
In Twig:
{{ table.className }}
---> this should display 'Table'
For a example, if we pass a table object to the twig view, how can we get the class name of that object like 'Table'.
class Table{
}
$table = new Table();
In Twig:
{{ table.className }}
---> this should display 'Table'
In \Twig_Extension you can add tests
And then use like
If you don't want to make this a method on the entity like so:
then you could create a Twig function or filter. Here's a function:
Use like so: