Skip to content

Commit

Permalink
Add new method in BlocKExtension to get block object (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBDev authored and benjamin-hubert committed Jul 11, 2017
1 parent 978dcc4 commit b414b9a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Twig/Extension/BlockExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function getFunctions()
'is_safe' => ['html'],
'needs_environment' => true,
]),
new \Twig_SimpleFunction('cms_block_object', [$this, 'getCMSBlockObject']),
];
}

Expand Down Expand Up @@ -77,4 +78,13 @@ public function displayBlock(\Twig_Environment $twig, $blockName)
]);
}
}

/**
* @param string $blockName
* @return \Alpixel\Bundle\CMSBundle\Entity\Block|null
*/
public function getCMSBlockObject($blockName)
{
return $this->blockHelper->loadBlock($blockName);
}
}

0 comments on commit b414b9a

Please sign in to comment.