Skip to content

Instantly share code, notes, and snippets.

@vladcosorg
vladcosorg / timber-function-wrapper.php
Last active August 29, 2015 14:13
__toString exception workaround
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 '';
}
}
@vladcosorg
vladcosorg / SluggableListener.php
Created December 9, 2012 13:48
Symfony2 russian transliterator for Sluggable
<?php
namespace Your\Bundle\Misc;
class SluggableListener extends \Gedmo\Sluggable\SluggableListener
{
public function __construct(){
$this->setTransliterator(array('\Your\Bundle\Misc\Transliterator', 'transliterate'));
}