Completed
Push — 4.0 ( 7e6da1...77faf8 )
by David
03:23
created
src/Mouf/Database/TDBM/MapIterator.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -9,86 +9,86 @@
 block discarded – undo
9 9
  */
10 10
 class MapIterator implements Iterator
11 11
 {
12
-    /**
13
-     * @var Iterator
14
-     */
15
-    protected $iterator;
12
+	/**
13
+	 * @var Iterator
14
+	 */
15
+	protected $iterator;
16 16
 
17
-    /**
18
-     * @var callable Modifies the current item in iterator
19
-     */
20
-    protected $callable;
17
+	/**
18
+	 * @var callable Modifies the current item in iterator
19
+	 */
20
+	protected $callable;
21 21
 
22
-    /**
23
-     * @param $iterator Iterator|array
24
-     * @param $callable callable This can have two parameters
25
-     *
26
-     * @throws TDBMException
27
-     */
28
-    public function __construct($iterator, callable $callable)
29
-    {
30
-        if (is_array($iterator)) {
31
-            $this->iterator = new \ArrayIterator($iterator);
32
-        } elseif (!($iterator instanceof Iterator)) {
33
-            throw new TDBMException('$iterator parameter must be an instance of Iterator');
34
-        } else {
35
-            $this->iterator = $iterator;
36
-        }
22
+	/**
23
+	 * @param $iterator Iterator|array
24
+	 * @param $callable callable This can have two parameters
25
+	 *
26
+	 * @throws TDBMException
27
+	 */
28
+	public function __construct($iterator, callable $callable)
29
+	{
30
+		if (is_array($iterator)) {
31
+			$this->iterator = new \ArrayIterator($iterator);
32
+		} elseif (!($iterator instanceof Iterator)) {
33
+			throw new TDBMException('$iterator parameter must be an instance of Iterator');
34
+		} else {
35
+			$this->iterator = $iterator;
36
+		}
37 37
 
38
-        if ($callable instanceof \Closure) {
39
-            // make sure there's one argument
40
-            $reflection = new \ReflectionObject($callable);
41
-            if ($reflection->hasMethod('__invoke')) {
42
-                $method = $reflection->getMethod('__invoke');
43
-                if ($method->getNumberOfParameters() !== 1) {
44
-                    throw new TDBMException('$callable must accept one and only one parameter.');
45
-                }
46
-            }
47
-        }
38
+		if ($callable instanceof \Closure) {
39
+			// make sure there's one argument
40
+			$reflection = new \ReflectionObject($callable);
41
+			if ($reflection->hasMethod('__invoke')) {
42
+				$method = $reflection->getMethod('__invoke');
43
+				if ($method->getNumberOfParameters() !== 1) {
44
+					throw new TDBMException('$callable must accept one and only one parameter.');
45
+				}
46
+			}
47
+		}
48 48
 
49
-        $this->callable = $callable;
50
-    }
49
+		$this->callable = $callable;
50
+	}
51 51
 
52
-    /**
53
-     * Alters the current item with $this->callable and returns a new item.
54
-     * Be careful with your types as we can't do static type checking here!
55
-     *
56
-     * @return mixed
57
-     */
58
-    public function current()
59
-    {
60
-        $callable = $this->callable;
52
+	/**
53
+	 * Alters the current item with $this->callable and returns a new item.
54
+	 * Be careful with your types as we can't do static type checking here!
55
+	 *
56
+	 * @return mixed
57
+	 */
58
+	public function current()
59
+	{
60
+		$callable = $this->callable;
61 61
 
62
-        return $callable($this->iterator->current());
63
-    }
62
+		return $callable($this->iterator->current());
63
+	}
64 64
 
65
-    public function next()
66
-    {
67
-        $this->iterator->next();
68
-    }
65
+	public function next()
66
+	{
67
+		$this->iterator->next();
68
+	}
69 69
 
70
-    public function key()
71
-    {
72
-        return $this->iterator->key();
73
-    }
70
+	public function key()
71
+	{
72
+		return $this->iterator->key();
73
+	}
74 74
 
75
-    public function valid()
76
-    {
77
-        return $this->iterator->valid();
78
-    }
75
+	public function valid()
76
+	{
77
+		return $this->iterator->valid();
78
+	}
79 79
 
80
-    public function rewind()
81
-    {
82
-        $this->iterator->rewind();
83
-    }
80
+	public function rewind()
81
+	{
82
+		$this->iterator->rewind();
83
+	}
84 84
 
85
-    /**
86
-     * Casts the iterator to a PHP array.
87
-     *
88
-     * @return array
89
-     */
90
-    public function toArray()
91
-    {
92
-        return iterator_to_array($this);
93
-    }
85
+	/**
86
+	 * Casts the iterator to a PHP array.
87
+	 *
88
+	 * @return array
89
+	 */
90
+	public function toArray()
91
+	{
92
+		return iterator_to_array($this);
93
+	}
94 94
 }
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Controllers/TdbmInstallController.php 1 patch
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -15,172 +15,172 @@
 block discarded – undo
15 15
  */
16 16
 class TdbmInstallController extends Controller
17 17
 {
18
-    /**
19
-     * @var HtmlBlock
20
-     */
21
-    public $content;
22
-
23
-    public $selfedit;
24
-
25
-    /**
26
-     * The active MoufManager to be edited/viewed.
27
-     *
28
-     * @var MoufManager
29
-     */
30
-    public $moufManager;
31
-
32
-    /**
33
-     * The template used by the main page for mouf.
34
-     *
35
-     * @Property
36
-     * @Compulsory
37
-     *
38
-     * @var TemplateInterface
39
-     */
40
-    public $template;
41
-
42
-    /**
43
-     * Displays the first install screen.
44
-     *
45
-     * @Action
46
-     * @Logged
47
-     *
48
-     * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)
49
-     */
50
-    public function defaultAction($selfedit = 'false')
51
-    {
52
-        $this->selfedit = $selfedit;
53
-
54
-        if ($selfedit == 'true') {
55
-            $this->moufManager = MoufManager::getMoufManager();
56
-        } else {
57
-            $this->moufManager = MoufManager::getMoufManagerHiddenInstance();
58
-        }
59
-
60
-        $this->content->addFile(dirname(__FILE__).'/../../../../views/installStep1.php', $this);
61
-        $this->template->toHtml();
62
-    }
63
-
64
-    /**
65
-     * Skips the install process.
66
-     *
67
-     * @Action
68
-     * @Logged
69
-     *
70
-     * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)
71
-     */
72
-    public function skip($selfedit = 'false')
73
-    {
74
-        InstallUtils::continueInstall($selfedit == 'true');
75
-    }
76
-
77
-    protected $daoNamespace;
78
-    protected $beanNamespace;
79
-    protected $autoloadDetected;
80
-    protected $storeInUtc;
81
-
82
-    /**
83
-     * Displays the second install screen.
84
-     *
85
-     * @Action
86
-     * @Logged
87
-     *
88
-     * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)
89
-     */
90
-    public function configure($selfedit = 'false')
91
-    {
92
-        $this->selfedit = $selfedit;
93
-
94
-        if ($selfedit == 'true') {
95
-            $this->moufManager = MoufManager::getMoufManager();
96
-        } else {
97
-            $this->moufManager = MoufManager::getMoufManagerHiddenInstance();
98
-        }
99
-
100
-        // Let's start by performing basic checks about the instances we assume to exist.
101
-        if (!$this->moufManager->instanceExists('dbalConnection')) {
102
-            $this->displayErrorMsg("The TDBM install process assumes your database connection instance is already created, and that the name of this instance is 'dbalConnection'. Could not find the 'dbalConnection' instance.");
103
-
104
-            return;
105
-        }
106
-
107
-        $this->daoNamespace = $this->moufManager->getVariable('tdbmDefaultDaoNamespace_tdbmService');
108
-        $this->beanNamespace = $this->moufManager->getVariable('tdbmDefaultBeanNamespace_tdbmService');
109
-
110
-        if ($this->daoNamespace == null && $this->beanNamespace == null) {
111
-            $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json');
112
-
113
-            $autoloadNamespaces = $classNameMapper->getManagedNamespaces();
114
-            if ($autoloadNamespaces) {
115
-                $this->autoloadDetected = true;
116
-                $rootNamespace = $autoloadNamespaces[0];
117
-                $this->daoNamespace = $rootNamespace.'Dao';
118
-                $this->beanNamespace = $rootNamespace.'Dao\\Bean';
119
-            } else {
120
-                $this->autoloadDetected = false;
121
-                $this->daoNamespace = 'YourApplication\\Dao';
122
-                $this->beanNamespace = 'YourApplication\\Dao\\Bean';
123
-            }
124
-        } else {
125
-            $this->autoloadDetected = true;
126
-        }
127
-        $this->defaultPath = true;
128
-        $this->storePath = '';
129
-
130
-        $this->castDatesToDateTime = true;
131
-
132
-        $this->content->addFile(dirname(__FILE__).'/../../../../views/installStep2.php', $this);
133
-        $this->template->toHtml();
134
-    }
135
-
136
-    /**
137
-     * This action generates the TDBM instance, then the DAOs and Beans.
138
-     *
139
-     * @Action
140
-     *
141
-     * @param string $daonamespace
142
-     * @param string $beannamespace
143
-     * @param int    $storeInUtc
144
-     * @param string $selfedit
145
-     *
146
-     * @throws \Mouf\MoufException
147
-     */
148
-    public function generate($daonamespace, $beannamespace, $storeInUtc = 0, $selfedit = 'false', $defaultPath = false, $storePath = '')
149
-    {
150
-        $this->selfedit = $selfedit;
151
-
152
-        if ($selfedit == 'true') {
153
-            $this->moufManager = MoufManager::getMoufManager();
154
-        } else {
155
-            $this->moufManager = MoufManager::getMoufManagerHiddenInstance();
156
-        }
157
-
158
-        if (!$this->moufManager->instanceExists('doctrineApcCache')) {
159
-            $doctrineApcCache = $this->moufManager->createInstance('Doctrine\\Common\\Cache\\ApcCache')->setName('doctrineApcCache');
160
-            // TODO: set namespace
161
-        } else {
162
-            $doctrineApcCache = $this->moufManager->getInstanceDescriptor('doctrineApcCache');
163
-        }
164
-
165
-        if (!$this->moufManager->instanceExists('tdbmService')) {
166
-            $tdbmService = $this->moufManager->createInstance('Mouf\\Database\\TDBM\\TDBMService')->setName('tdbmService');
167
-            $tdbmService->getConstructorArgumentProperty('connection')->setValue($this->moufManager->getInstanceDescriptor('dbalConnection'));
168
-            $tdbmService->getConstructorArgumentProperty('cache')->setValue($doctrineApcCache);
169
-        }
170
-
171
-        $this->moufManager->rewriteMouf();
172
-
173
-        TdbmController::generateDaos($this->moufManager, 'tdbmService', $daonamespace, $beannamespace, 'DaoFactory', 'daoFactory', $selfedit, $storeInUtc, $defaultPath, $storePath);
174
-
175
-        InstallUtils::continueInstall($selfedit == 'true');
176
-    }
177
-
178
-    protected $errorMsg;
179
-
180
-    private function displayErrorMsg($msg)
181
-    {
182
-        $this->errorMsg = $msg;
183
-        $this->content->addFile(dirname(__FILE__).'/../../../../views/installError.php', $this);
184
-        $this->template->toHtml();
185
-    }
18
+	/**
19
+	 * @var HtmlBlock
20
+	 */
21
+	public $content;
22
+
23
+	public $selfedit;
24
+
25
+	/**
26
+	 * The active MoufManager to be edited/viewed.
27
+	 *
28
+	 * @var MoufManager
29
+	 */
30
+	public $moufManager;
31
+
32
+	/**
33
+	 * The template used by the main page for mouf.
34
+	 *
35
+	 * @Property
36
+	 * @Compulsory
37
+	 *
38
+	 * @var TemplateInterface
39
+	 */
40
+	public $template;
41
+
42
+	/**
43
+	 * Displays the first install screen.
44
+	 *
45
+	 * @Action
46
+	 * @Logged
47
+	 *
48
+	 * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)
49
+	 */
50
+	public function defaultAction($selfedit = 'false')
51
+	{
52
+		$this->selfedit = $selfedit;
53
+
54
+		if ($selfedit == 'true') {
55
+			$this->moufManager = MoufManager::getMoufManager();
56
+		} else {
57
+			$this->moufManager = MoufManager::getMoufManagerHiddenInstance();
58
+		}
59
+
60
+		$this->content->addFile(dirname(__FILE__).'/../../../../views/installStep1.php', $this);
61
+		$this->template->toHtml();
62
+	}
63
+
64
+	/**
65
+	 * Skips the install process.
66
+	 *
67
+	 * @Action
68
+	 * @Logged
69
+	 *
70
+	 * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)
71
+	 */
72
+	public function skip($selfedit = 'false')
73
+	{
74
+		InstallUtils::continueInstall($selfedit == 'true');
75
+	}
76
+
77
+	protected $daoNamespace;
78
+	protected $beanNamespace;
79
+	protected $autoloadDetected;
80
+	protected $storeInUtc;
81
+
82
+	/**
83
+	 * Displays the second install screen.
84
+	 *
85
+	 * @Action
86
+	 * @Logged
87
+	 *
88
+	 * @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)
89
+	 */
90
+	public function configure($selfedit = 'false')
91
+	{
92
+		$this->selfedit = $selfedit;
93
+
94
+		if ($selfedit == 'true') {
95
+			$this->moufManager = MoufManager::getMoufManager();
96
+		} else {
97
+			$this->moufManager = MoufManager::getMoufManagerHiddenInstance();
98
+		}
99
+
100
+		// Let's start by performing basic checks about the instances we assume to exist.
101
+		if (!$this->moufManager->instanceExists('dbalConnection')) {
102
+			$this->displayErrorMsg("The TDBM install process assumes your database connection instance is already created, and that the name of this instance is 'dbalConnection'. Could not find the 'dbalConnection' instance.");
103
+
104
+			return;
105
+		}
106
+
107
+		$this->daoNamespace = $this->moufManager->getVariable('tdbmDefaultDaoNamespace_tdbmService');
108
+		$this->beanNamespace = $this->moufManager->getVariable('tdbmDefaultBeanNamespace_tdbmService');
109
+
110
+		if ($this->daoNamespace == null && $this->beanNamespace == null) {
111
+			$classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json');
112
+
113
+			$autoloadNamespaces = $classNameMapper->getManagedNamespaces();
114
+			if ($autoloadNamespaces) {
115
+				$this->autoloadDetected = true;
116
+				$rootNamespace = $autoloadNamespaces[0];
117
+				$this->daoNamespace = $rootNamespace.'Dao';
118
+				$this->beanNamespace = $rootNamespace.'Dao\\Bean';
119
+			} else {
120
+				$this->autoloadDetected = false;
121
+				$this->daoNamespace = 'YourApplication\\Dao';
122
+				$this->beanNamespace = 'YourApplication\\Dao\\Bean';
123
+			}
124
+		} else {
125
+			$this->autoloadDetected = true;
126
+		}
127
+		$this->defaultPath = true;
128
+		$this->storePath = '';
129
+
130
+		$this->castDatesToDateTime = true;
131
+
132
+		$this->content->addFile(dirname(__FILE__).'/../../../../views/installStep2.php', $this);
133
+		$this->template->toHtml();
134
+	}
135
+
136
+	/**
137
+	 * This action generates the TDBM instance, then the DAOs and Beans.
138
+	 *
139
+	 * @Action
140
+	 *
141
+	 * @param string $daonamespace
142
+	 * @param string $beannamespace
143
+	 * @param int    $storeInUtc
144
+	 * @param string $selfedit
145
+	 *
146
+	 * @throws \Mouf\MoufException
147
+	 */
148
+	public function generate($daonamespace, $beannamespace, $storeInUtc = 0, $selfedit = 'false', $defaultPath = false, $storePath = '')
149
+	{
150
+		$this->selfedit = $selfedit;
151
+
152
+		if ($selfedit == 'true') {
153
+			$this->moufManager = MoufManager::getMoufManager();
154
+		} else {
155
+			$this->moufManager = MoufManager::getMoufManagerHiddenInstance();
156
+		}
157
+
158
+		if (!$this->moufManager->instanceExists('doctrineApcCache')) {
159
+			$doctrineApcCache = $this->moufManager->createInstance('Doctrine\\Common\\Cache\\ApcCache')->setName('doctrineApcCache');
160
+			// TODO: set namespace
161
+		} else {
162
+			$doctrineApcCache = $this->moufManager->getInstanceDescriptor('doctrineApcCache');
163
+		}
164
+
165
+		if (!$this->moufManager->instanceExists('tdbmService')) {
166
+			$tdbmService = $this->moufManager->createInstance('Mouf\\Database\\TDBM\\TDBMService')->setName('tdbmService');
167
+			$tdbmService->getConstructorArgumentProperty('connection')->setValue($this->moufManager->getInstanceDescriptor('dbalConnection'));
168
+			$tdbmService->getConstructorArgumentProperty('cache')->setValue($doctrineApcCache);
169
+		}
170
+
171
+		$this->moufManager->rewriteMouf();
172
+
173
+		TdbmController::generateDaos($this->moufManager, 'tdbmService', $daonamespace, $beannamespace, 'DaoFactory', 'daoFactory', $selfedit, $storeInUtc, $defaultPath, $storePath);
174
+
175
+		InstallUtils::continueInstall($selfedit == 'true');
176
+	}
177
+
178
+	protected $errorMsg;
179
+
180
+	private function displayErrorMsg($msg)
181
+	{
182
+		$this->errorMsg = $msg;
183
+		$this->content->addFile(dirname(__FILE__).'/../../../../views/installError.php', $this);
184
+		$this->template->toHtml();
185
+	}
186 186
 }
Please login to merge, or discard this patch.