File: TestHelper.php

package info (click to toggle)
php-horde-routes 2.0.2-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 380 kB
  • ctags: 879
  • sloc: php: 3,649; xml: 313; sh: 3; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,166 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
 * Horde Routes package
 *
 * This package is heavily inspired by the Python "Routes" library
 * by Ben Bangert (http://routes.groovie.org).  Routes is based
 * largely on ideas from Ruby on Rails (http://www.rubyonrails.org).
 *
 * @author  Maintainable Software, LLC. (http://www.maintainable.com)
 * @author  Mike Naberezny <mike@maintainable.com>
 * @license http://www.horde.org/licenses/bsd BSD
 * @package Routes
 */

/**
 * @package Routes
 */
class Horde_Routes_TestHelper
{
    /**
     * Update a Mapper instance with a new $environ.  If PATH_INFO
     * is present, try to match it and update mapperDict.
     * 
     * @param  Horde_Routes_Mapper  $mapper   Mapper instance to update
     * @param  array                $environ  Environ to set in Mapper
     * @return void
     */
    public static function updateMapper($mapper, $environ)
    {
        $mapper->environ = $environ;
        $mapper->utils->mapperdict = null;
        
        if (isset($environ['PATH_INFO'])) {
            $result = $mapper->routeMatch($environ['PATH_INFO']);
            $mapper->utils->mapperDict = isset($result) ? $result[0] : null;
        }
    }

}