Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // config/ProjectConfiguration.class.php
- class ProjectConfiguration extends sfProjectConfiguration
- {
- public function setup()
- {
- // ...
- $this->dispatcher->connect('request.filter_parameters', array($this, 'filterRequestParameters'));
- }
- public function filterRequestParameters(sfEvent $event, $parameters)
- {
- $request = $event->getSubject();
- if (preg_match('#Mobile/.+Safari#i', $request->getHttpHeader('User-Agent')))
- {
- $request->setRequestFormat('iphone');
- }
- return $parameters;
- }
- }
- <?php
- class iPhoneFilter extends sfFilter
- {
- public function execute ($filterChain)
- {
- // get the cool stuff
- $context = $this->getContext();
- $request = $context->getRequest();
- $response = $context->getResponse();
- if ($this->isFirstCall())
- {
- $cookies = $response->getCookies();
- if (preg_match('#Mobile/.+Safari#i', $request->getHttpHeader('User-Agent'))
- && ! isset($cookies['doaction']))
- {
- $request->setRequestFormat('iphone');
- }
- }
- // execute next filter
- $filterChain->execute();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement