1: <?php
2: /**
3: * Factory methods for basic objects required by the free/busy export.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_FreeBusy
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
11: * @link http://pear.horde.org/index.php?package=Kolab_FreeBusy
12: */
13:
14: /**
15: * Factory methods for basic objects required by the free/busy export.
16: *
17: * Copyright 2009-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you did not
20: * receive this file, see
21: * http://www.horde.org/licenses/lgpl21.
22: *
23: * @category Kolab
24: * @package Kolab_FreeBusy
25: * @author Gunnar Wrobel <wrobel@pardus.de>
26: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
27: * @link http://pear.horde.org/index.php?package=Kolab_FreeBusy
28: */
29: class Horde_Kolab_FreeBusy_Freebusy_Factory_Base
30: extends Horde_Kolab_FreeBusy_Factory_Base
31: {
32: /**
33: * Constructor.
34: *
35: * @param Horde_Injector $injector The injector providing required dependencies.
36: */
37: public function __construct(Horde_Injector $injector)
38: {
39: $injector->bindImplementation(
40: 'Horde_Kolab_FreeBusy_Params_Owner',
41: 'Horde_Kolab_FreeBusy_Freebusy_Params_Folder'
42: );
43: parent::__construct($injector);
44: }
45:
46: /**
47: * Create the mapper.
48: *
49: * @return Horde_Route_Mapper The mapper.
50: */
51: public function createMapper()
52: {
53: $mapper = parent::createMapper();
54:
55: $configuration = $this->_injector->getInstance('Horde_Kolab_FreeBusy_Configuration');
56: $params = isset($configuration['mapper']) ? $configuration['mapper'] : array();
57:
58: if (empty($params['controller'])) {
59: $params['controller'] = 'freebusy';
60: }
61:
62: // Check for route definitions.
63: if (!empty($configuration['config']['dir'])) {
64: $routeFile = $configuration['config']['dir'] . '/routes.php';
65: }
66: if (empty($params['config']['dir'])
67: || !file_exists($routeFile)) {
68: $mapper->connect(
69: ':(owner).:(type)',
70: array(
71: 'controller' => $params['controller'],
72: 'action' => 'fetch',
73: 'requirements' => array(
74: 'type' => '(i|x|v)fb',
75: 'owner' => '[^/]+'),
76: )
77: );
78: $mapper->connect(
79: 'trigger/*(folder).pfb',
80: array(
81: 'controller' => $params['controller'],
82: 'action' => 'trigger'
83: )
84: );
85:
86: $mapper->connect(
87: '*(folder).:(type)',
88: array(
89: 'controller' => $params['controller'],
90: 'action' => 'trigger',
91: 'requirements' => array('type' => '(p|px)fb'),
92: )
93: );
94: $mapper->connect(
95: 'delete/:(owner)',
96: array(
97: 'controller' => $params['controller'],
98: 'action' => 'delete',
99: 'requirements' => array('owner' => '[^/]+'),
100: )
101: );
102: $mapper->connect(
103: 'regenerate',
104: array(
105: 'controller' => $params['controller'],
106: 'action' => 'regenerate',
107: )
108: );
109: } else {
110: // Load application routes.
111: include $routeFile;
112: }
113: return $mapper;
114: }
115:
116: /**
117: * Return the class name prefix for controllers.
118: *
119: * @return string The prefix.
120: */
121: protected function getControllerPrefix()
122: {
123: return 'Horde_Kolab_FreeBusy_Freebusy_Controller_';
124: }
125: }
126: