Skip to content

Instantly share code, notes, and snippets.

@garak
Forked from anonymous/gist:595592
Created Sep 24, 2010
Embed
What would you like to do?
<?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