1: <?php
2:
3: /**
4: * This file contains the uri builder factory class.
5: *
6: * @package Core
7: * @subpackage Frontend_URI
8: * @author Rudi Bieller
9: * @copyright four for business AG <www.4fb.de>
10: * @license http://www.contenido.org/license/LIZENZ.txt
11: * @link http://www.4fb.de
12: * @link http://www.contenido.org
13: */
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: /**
18: * Factory for retrieving required cUriBuilder object.
19: *
20: * @package Core
21: * @subpackage Frontend_URI
22: */
23: class cUriBuilderFactory {
24:
25: /**
26: * Returns desired cUriBuilder object.
27: *
28: * @param string $sBuilder
29: * For now, those are valid: front_content, custom, custom_path
30: * or a Userdefined cUriBuilder name.
31: * The name must be a subpart of the cUriBuilder class,
32: * e.g. 'MyUriBuilder' for cUriBuilderMyUriBuilder.
33: * The classfile must be named like class.uribuilder.myuribuilder.php
34: * and it must be reside in /contenido/classes/uri/ folder.
35: * @return cUriBuilder
36: * @throws cInvalidArgumentException
37: * In case unknown type of builder is requested you'll get an Exception
38: */
39: public static function getUriBuilder($sBuilder) {
40: switch ($sBuilder) {
41: case 'front_content':
42: return cUriBuilderFrontcontent::getInstance();
43: break;
44: case 'custom':
45: return cUriBuilderCustom::getInstance();
46: break;
47: case 'custom_path':
48: return cUriBuilderCustomPath::getInstance();
49: break;
50: default:
51: if ((string) $sBuilder !== '') {
52: $sClassName = 'cUriBuilder' . $sBuilder;
53:
54: if (!class_exists($sClassName)) {
55: throw new cInvalidArgumentException('The classfile of cUriBuilder couldn\'t included by cUriBuilderFactory: ' . $sBuilder . '!');
56: }
57: return call_user_func(array($sClassName, 'getInstance'));
58: }
59:
60: throw new cInvalidArgumentException('Invalid/Empty cUriBuilder passed to cUriBuilderFactory: ' . $sBuilder . '!');
61: break;
62: }
63: }
64:
65: }
66: