Skip to content

Instantly share code, notes, and snippets.

@chetzof
chetzof / timber-function-wrapper.php
Last active Aug 29, 2015
__toString exception workaround
View timber-function-wrapper.php
public function __toString() {
try {
return $this->call();
} catch(\Exception $e) {
// the __toString method isn't allowed to throw exceptions
// so we turn them into an error instead
trigger_error($e->getMessage() . "\n" . $e->getTraceAsString(), E_USER_ERROR);
return '';
}
}
@chetzof
chetzof / SluggableListener.php
Created Dec 9, 2012
Symfony2 russian transliterator for Sluggable
View SluggableListener.php
<?php
namespace Your\Bundle\Misc;
class SluggableListener extends \Gedmo\Sluggable\SluggableListener
{
public function __construct(){
$this->setTransliterator(array('\Your\Bundle\Misc\Transliterator', 'transliterate'));
}