Skip to content

Instantly share code, notes, and snippets.

@ornicar
Created May 10, 2010 10:13
Show Gist options
  • Save ornicar/395887 to your computer and use it in GitHub Desktop.
Save ornicar/395887 to your computer and use it in GitHub Desktop.
<?php
require_once(dm::getDir().'/dmFrontPlugin/lib/config/dmFrontApplicationConfiguration.php');
class frontConfiguration extends dmFrontApplicationConfiguration
{
protected $request;
public function configure()
{
$this->getEventDispatcher()->connect('request.filter_parameters', array($this, 'filterRequestParameters'));
$this->getEventDispatcher()->connect('dm.layout.filter_stylesheets', array($this, 'filterStylesheets'));
}
public function filterRequestParameters(sfEvent $event, $parameters)
{
$this->request = $event->getSubject();
if (preg_match('#Mobile/.+Safari#i', $this->request->getHttpHeader('User-Agent')))
{
$this->request->setRequestFormat('iphone');
}
return $parameters;
}
public function filterStylesheets(sfEvent $event, array $stylesheets)
{
if('iphone' == $this->request->getRequestFormat())
{
// Add, remove, change $stylesheets
}
return $stylesheets;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment