Skip to content

Commit b62a35e

Browse files
authored
Merge pull request #1120 from phalcon/3.2.x
3.2.6
2 parents 3088ebf + a3c5a12 commit b62a35e

24 files changed

+1260
-123
lines changed

scripts/Phalcon/Builder/Scaffold.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ private function _captureFilterInput($var, $fields, $useGetSetters, $identityFie
280280

281281
$code .= '$' . Utils::lowerCamelizeWithDelimiter($var, '-', true) . '->';
282282
if ($useGetSetters) {
283-
$code .= 'set' . Text::camelize($field) . '(' . $fieldCode . ')';
283+
$code .= 'set' . Utils::lowerCamelizeWithDelimiter($field, '_', true) . '(' . $fieldCode . ')';
284284
} else {
285-
$code .= Text::camelize($field, '-') . ' = ' . $fieldCode;
285+
$code .= Utils::lowerCamelizeWithDelimiter($field, '-_', true) . ' = ' . $fieldCode;
286286
}
287287

288288
$code .= ';' . PHP_EOL . "\t\t";

scripts/Phalcon/Commands/Builtin/Migration.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
+------------------------------------------------------------------------+
55
| Phalcon Developer Tools |
66
+------------------------------------------------------------------------+
7-
| Copyright (c) 2011-2016 Phalcon Team (https://www.phalconphp.com) |
7+
| Copyright (c) 2011-2017 Phalcon Team (https://www.phalconphp.com) |
88
+------------------------------------------------------------------------+
99
| This source file is subject to the New BSD License that is bundled |
1010
| with this package in the file LICENSE.txt. |
@@ -47,13 +47,15 @@ public function getPossibleParams()
4747
'config=s' => 'Configuration file',
4848
'migrations=s' => 'Migrations directory',
4949
'directory=s' => 'Directory where the project was created',
50-
'table=s' => 'Table to migrate. Default: all',
50+
'table=s' => 'Table to migrate. Table name or table prefix with asterisk. Default: all',
5151
'version=s' => 'Version to migrate',
5252
'descr=s' => 'Migration description (used for timestamp based migration)',
5353
'data=s' => 'Export data [always|oncreate] (Import data when run migration)',
5454
'force' => 'Forces to overwrite existing migrations',
5555
'ts-based' => 'Timestamp based migration version',
5656
'log-in-db' => 'Keep migrations log in the database table rather than in file',
57+
'dry' => 'Attempt requested operation without making changes to system (Generating only)',
58+
'verbose' => 'Output of debugging information during operation (Running only)',
5759
'no-auto-increment' => 'Disable auto increment (Generating only)',
5860
'help' => 'Shows this help [optional]',
5961
];
@@ -111,23 +113,21 @@ public function run(array $parameters)
111113
}
112114

113115
$tableName = $this->isReceivedOption('table') ? $this->getOption('table') : '@';
114-
$descr = $this->getOption('descr');
115-
$exportData = $this->getOption('data');
116116
$action = $this->getOption(['action', 1]);
117-
$version = $this->getOption('version');
118117

119118
switch ($action) {
120119
case 'generate':
121120
Migrations::generate([
122121
'directory' => $path,
123122
'tableName' => $tableName,
124-
'exportData' => $exportData,
123+
'exportData' => $this->getOption('data'),
125124
'migrationsDir' => $migrationsDir,
126-
'version' => $version,
125+
'version' => $this->getOption('version'),
127126
'force' => $this->isReceivedOption('force'),
128127
'noAutoIncrement' => $this->isReceivedOption('no-auto-increment'),
129128
'config' => $config,
130-
'descr' => $descr,
129+
'descr' => $this->getOption('descr'),
130+
'verbose' => $this->isReceivedOption('dry'),
131131
]);
132132
break;
133133
case 'run':
@@ -138,8 +138,9 @@ public function run(array $parameters)
138138
'force' => $this->isReceivedOption('force'),
139139
'tsBased' => $migrationsTsBased,
140140
'config' => $config,
141-
'version' => $version,
141+
'version' => $this->getOption('version'),
142142
'migrationsInDb' => $migrationsInDb,
143+
'verbose' => $this->isReceivedOption('verbose'),
143144
]);
144145
break;
145146
case 'list':
@@ -150,7 +151,7 @@ public function run(array $parameters)
150151
'force' => $this->isReceivedOption('force'),
151152
'tsBased' => $migrationsTsBased,
152153
'config' => $config,
153-
'version' => $version,
154+
'version' => $this->getOption('version'),
154155
'migrationsInDb' => $migrationsInDb,
155156
]);
156157
break;

scripts/Phalcon/Commands/Command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
+------------------------------------------------------------------------+
55
| Phalcon Developer Tools |
66
+------------------------------------------------------------------------+
7-
| Copyright (c) 2011-2016 Phalcon Team (https://www.phalconphp.com) |
7+
| Copyright (c) 2011-2017 Phalcon Team (https://www.phalconphp.com) |
88
+------------------------------------------------------------------------+
99
| This source file is subject to the New BSD License that is bundled |
1010
| with this package in the file LICENSE.txt. |
@@ -135,7 +135,7 @@ protected function getConfig($path)
135135
{
136136
foreach (['app/config/', 'config/'] as $configPath) {
137137
foreach (['ini', 'php', 'json', 'yaml', 'yml'] as $extension) {
138-
if (file_exists($path . $configPath . "/config." . $extension)) {
138+
if (file_exists($path . $configPath . "config." . $extension)) {
139139
return $this->loadConfig($path . $configPath . "/config." . $extension);
140140
}
141141
}

scripts/Phalcon/Commands/CommandsListener.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function beforeCommand(Event $event, Command $command)
5454

5555
if ($command->canBeExternal() == false) {
5656
$path = $command->getOption('directory');
57+
if ($path) $path = realpath($path) . DIRECTORY_SEPARATOR;
5758
if (!file_exists($path.'.phalcon') || !is_dir($path.'.phalcon')) {
5859
throw new DotPhalconMissingException();
5960
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
/*
4+
+------------------------------------------------------------------------+
5+
| Phalcon Developer Tools |
6+
+------------------------------------------------------------------------+
7+
| Copyright (c) 2011-2017 Phalcon Team (https://www.phalconphp.com) |
8+
+------------------------------------------------------------------------+
9+
| This source file is subject to the New BSD License that is bundled |
10+
| with this package in the file LICENSE.txt. |
11+
| |
12+
| If you did not receive a copy of the license and are unable to |
13+
| obtain it through the world-wide-web, please send an email |
14+
| to [email protected] so we can send you a copy immediately. |
15+
+------------------------------------------------------------------------+
16+
| Authors: Sergii Svyrydenko <[email protected]> |
17+
+------------------------------------------------------------------------+
18+
*/
19+
20+
namespace Phalcon\Console;
21+
22+
/**
23+
* \Phalcon\Utils\OptionParserTrait
24+
*
25+
* Parsing CLI options
26+
*
27+
* @package Phalcon\Utils
28+
* @copyright Copyright (c) 2011-2017 Phalcon Team ([email protected])
29+
* @license New BSD License
30+
*/
31+
trait OptionParserTrait
32+
{
33+
/**
34+
* Get prefix from the option
35+
*
36+
* @param string $prefix
37+
* @param mixed $prefixEnd
38+
*
39+
* @return mixed
40+
*/
41+
public function getPrefixOption($prefix, $prefixEnd = '*')
42+
{
43+
if (substr($prefix, -1) != $prefixEnd) {
44+
return '';
45+
}
46+
47+
return substr($prefix, 0, -1);
48+
}
49+
}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
<?php
2+
3+
/*
4+
+------------------------------------------------------------------------+
5+
| Phalcon Developer Tools |
6+
+------------------------------------------------------------------------+
7+
| Copyright (c) 2011-2017 Phalcon Team (https://www.phalconphp.com) |
8+
+------------------------------------------------------------------------+
9+
| This source file is subject to the New BSD License that is bundled |
10+
| with this package in the file LICENSE.txt. |
11+
| |
12+
| If you did not receive a copy of the license and are unable to |
13+
| obtain it through the world-wide-web, please send an email |
14+
| to [email protected] so we can send you a copy immediately. |
15+
+------------------------------------------------------------------------+
16+
| Authors: Sergii Svyrydenko <[email protected]> |
17+
+------------------------------------------------------------------------+
18+
*/
19+
20+
namespace Phalcon\Console;
21+
22+
use Phalcon\Console\OptionParserTrait;
23+
24+
/**
25+
* Phalcon\Console\OptionStack
26+
*
27+
* CLI options
28+
*
29+
* @package Phalcon\Console;
30+
* @copyright Copyright (c) 2011-2017 Phalcon Team ([email protected])
31+
* @license New BSD License
32+
*/
33+
class OptionStack
34+
{
35+
use OptionParserTrait;
36+
37+
/**
38+
* Parameters received by the script.
39+
* @var array
40+
*/
41+
protected $options = [];
42+
43+
/**
44+
* Set recieved options
45+
*
46+
* @param array $options
47+
*/
48+
public function setOptions(array $options)
49+
{
50+
$this->options = array_merge($this->options, $options);
51+
}
52+
53+
/**
54+
* Add option to array
55+
*
56+
* @param mixed $key
57+
* @param mixed $option
58+
* @param mixed $defaultValue
59+
*/
60+
public function setOption($key, $option, $defaultValue = '')
61+
{
62+
if (!empty($option)) {
63+
$this->options[$key] = $option;
64+
65+
return;
66+
}
67+
68+
$this->options[$key] = $defaultValue;
69+
}
70+
71+
/**
72+
* Set option if value isn't exist
73+
*
74+
* @param string $key
75+
* @param mixed $defaultValue
76+
*/
77+
public function setDefaultOption($key, $defaultValue)
78+
{
79+
if (!isset($this->options[$key])) {
80+
$this->options[$key] = $defaultValue;
81+
}
82+
}
83+
84+
/**
85+
* Get recieved options
86+
*
87+
* @return mixed
88+
*/
89+
public function getOptions()
90+
{
91+
return $this->options;
92+
}
93+
94+
/**
95+
* Get option
96+
* @param string $key
97+
*
98+
* @return mixed
99+
*/
100+
public function getOption($key)
101+
{
102+
if (!isset($this->options[$key])) {
103+
return '';
104+
}
105+
106+
return $this->options[$key];
107+
}
108+
109+
/**
110+
* Get option if existence or get default option
111+
*
112+
* @param string $key
113+
* @param mixed $defaultOption
114+
*
115+
* @return mixed
116+
*/
117+
public function getValidOption($key, $defaultOption = '')
118+
{
119+
if (isset($this->options[$key])) {
120+
return $this->options[$key];
121+
}
122+
123+
return $defaultOption;
124+
}
125+
126+
/**
127+
* Count options
128+
*
129+
* @return integer
130+
*/
131+
public function countOptions()
132+
{
133+
return count($this->options);
134+
}
135+
136+
/**
137+
* Indicates whether the script was a particular option.
138+
*
139+
* @param string $key
140+
* @return boolean
141+
*/
142+
public function isReceivedOption($key)
143+
{
144+
return isset($this->options[$key]);
145+
}
146+
}

scripts/Phalcon/Devtools/Version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ class Version extends PhVersion
3939
*/
4040
protected static function _getVersion()
4141
{
42-
return [3, 2, 3, 4, 1];
42+
return [3, 2, 5, 4, 0];
4343
}
4444
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
/*
4+
+------------------------------------------------------------------------+
5+
| Phalcon Developer Tools |
6+
+------------------------------------------------------------------------+
7+
| Copyright (c) 2011-2017 Phalcon Team (https://www.phalconphp.com) |
8+
+------------------------------------------------------------------------+
9+
| This source file is subject to the New BSD License that is bundled |
10+
| with this package in the file LICENSE.txt. |
11+
| |
12+
| If you did not receive a copy of the license and are unable to |
13+
| obtain it through the world-wide-web, please send an email |
14+
| to [email protected] so we can send you a copy immediately. |
15+
+------------------------------------------------------------------------+
16+
| Authors: Sergii Svyrydenko <[email protected]> |
17+
+------------------------------------------------------------------------+
18+
*/
19+
20+
namespace Phalcon\Listeners;
21+
22+
use Phalcon\Mvc\Model\Migration\Profiler;
23+
use Phalcon\Events\Event;
24+
25+
/**
26+
* Phalcon\Listeners\DbProfilerListener
27+
*
28+
* Db event listener
29+
*
30+
* @package Phalcon\Listeners
31+
*/
32+
class DbProfilerListener
33+
{
34+
protected $_profiler;
35+
36+
public function __construct()
37+
{
38+
$this->_profiler = new Profiler();
39+
}
40+
41+
public function beforeQuery(Event $event, $connection)
42+
{
43+
$this->_profiler->startProfile(
44+
$connection->getSQLStatement()
45+
);
46+
}
47+
48+
public function afterQuery()
49+
{
50+
$this->_profiler->stopProfile();
51+
}
52+
}

0 commit comments

Comments
 (0)