Skip to content

Instantly share code, notes, and snippets.

@garak
Forked from anonymous/gist:595592
Created September 24, 2010 16:14
Show Gist options
  • Save garak/595620 to your computer and use it in GitHub Desktop.
Save garak/595620 to your computer and use it in GitHub Desktop.
<?php
class frontendConfiguration extends sfApplicationConfiguration
{
protected $requestFormat = null;
public function configure()
{
$this->dispatcher->connect('request.filter_parameters', array($this, 'filterRequestParameters'));
$this->dispatcher->connect('view.configure_format', array($this, 'configureIPhoneFormat'));
}
public function filterRequestParameters(sfEvent $event, $parameters)
{
$request = $event->getSubject();
if (preg_match('#Mobile/.+Safari#i', $request->getHttpHeader('User-Agent')))
{
$this->requestFormat = 'iphone';
}
return $parameters;
}
public function configureIPhoneFormat(sfEvent $event)
{
if ($this->requestFormat == 'iphone')
{
//remove
$event['response']->removeStylesheet('a.css');
$event['response']->removeJavascript('a.js');
//add
$event['response']->addStylesheet('b.css');
$event['response']->addJavascript('b.js');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment