Skip to content

Commit

Permalink
Merge pull request phalcon#1091 from phalcon/3.2.x
Browse files Browse the repository at this point in the history
3.2.3
  • Loading branch information
sergeyklay authored Aug 24, 2017
2 parents cd81da3 + afa7838 commit 6775406
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ $config = [

## Configuration file

By creating **phalcon.json** or any other configuration file called **phalcon** in root project you can set options for all possible commands, for example:
By creating **config.json** or any other configuration file called **config** in root project you can set options for all possible commands, for example:

```json
{
Expand Down
4 changes: 2 additions & 2 deletions scripts/Phalcon/Builder/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public function build()
foreach ($db->describeReferences($this->options->get('name'), $schema) as $reference) {
$entityNamespace = '';
if ($this->options->contains('namespace')) {
$entityNamespace = $this->options->get('namespace')."\\";
$entityNamespace = $this->options->get('namespace');
}

$refColumns = $reference->getReferencedColumns();
Expand Down Expand Up @@ -439,7 +439,7 @@ public function build()
$attributes[] = $this->snippet->getAttributes($type, $useSettersGetters ? 'protected' : 'public', $field, $this->options->has( 'annotate' ), $fieldName);

if ($useSettersGetters) {
$methodName = Utils::camelize($field->getName(). '_-');
$methodName = Utils::camelize($field->getName(), '_-');
$setters[] = $this->snippet->getSetter($fieldName, $type, $methodName);

if (isset($this->_typeMap[$type])) {
Expand Down
17 changes: 9 additions & 8 deletions scripts/Phalcon/Builder/Scaffold.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
namespace Phalcon\Builder;

use Phalcon\Text;
use Phalcon\Utils;
use Phalcon\Builder\Model as ModelBuilder;
use Phalcon\DI\FactoryDefault;
use Phalcon\Db\Column;
Expand Down Expand Up @@ -277,7 +278,7 @@ private function _captureFilterInput($var, $fields, $useGetSetters, $identityFie
}
}

$code .= '$' . Text::camelize($var, '-') . '->';
$code .= '$' . Utils::lowerCamelizeWithDelimiter($var, '-', true) . '->';
if ($useGetSetters) {
$code .= 'set' . Text::camelize($field) . '(' . $fieldCode . ')';
} else {
Expand Down Expand Up @@ -307,7 +308,7 @@ private function _assignTagDefaults($var, $fields, $useGetSetters)
$accessor = $field;
}

$code .= '$this->tag->setDefault("' . $field . '", $' . Text::camelize($var, '-') . '->' . $accessor . ');' . PHP_EOL . "\t\t\t";
$code .= '$this->tag->setDefault("' . $field . '", $' . Utils::lowerCamelizeWithDelimiter($var, '-', true) . '->' . $accessor . ');' . PHP_EOL . "\t\t\t";
}

return $code;
Expand Down Expand Up @@ -491,10 +492,10 @@ private function _makeController()

$code = str_replace('$fullyQualifiedModelName$', $this->options->get('modelClass'), $code);

$code = str_replace('$singularVar$', '$' . Text::camelize($this->options->get('singular'), '-'), $code);
$code = str_replace('$singularVar$', '$' . Utils::lowerCamelizeWithDelimiter($this->options->get('singular'), '-', true), $code);
$code = str_replace('$singular$', $this->options->get('singular'), $code);

$code = str_replace('$pluralVar$', '$' . Text::camelize($this->options->get('plural'), '-'), $code);
$code = str_replace('$pluralVar$', '$' . Utils::lowerCamelizeWithDelimiter($this->options->get('plural'), '-', true), $code);
$code = str_replace('$plural$', $this->options->get('plural'), $code);

$code = str_replace('$className$', $this->options->get('className'), $code);
Expand Down Expand Up @@ -726,7 +727,7 @@ private function _makeViewSearch()
$rowCode .= "\t\t\t" . '<td><?php echo ';
if (!isset($this->options->allReferences[$fieldName])) {
if ($this->options->genSettersGetters) {
$rowCode .= '$' . Text::camelize($this->options->singular, '-') . '->get' . Text::camelize($fieldName) . '()';
$rowCode .= '$' . Utils::lowerCamelizeWithDelimiter($this->options->singular, '-', true) . '->get' . Text::camelize($fieldName) . '()';
} else {
$rowCode .= '$' . $this->options->singular . '->' . $fieldName;
}
Expand All @@ -747,7 +748,7 @@ private function _makeViewSearch()
$code = str_replace('$plural$', $this->options->plural, $code);
$code = str_replace('$headerColumns$', $headerCode, $code);
$code = str_replace('$rowColumns$', $rowCode, $code);
$code = str_replace('$singularVar$', '$' . Text::camelize($this->options->singular, '-'), $code);
$code = str_replace('$singularVar$', '$' . Utils::lowerCamelizeWithDelimiter($this->options->singular, '-', true), $code);
$code = str_replace('$pk$', $idField, $code);

if ($this->isConsole()) {
Expand Down Expand Up @@ -791,7 +792,7 @@ private function _makeViewSearchVolt()
$rowCode .= "\t\t\t" . '<td>{{ ';
if (!isset($this->options->allReferences[$fieldName])) {
if ($this->options->contains('genSettersGetters')) {
$rowCode .= Text::camelize($this->options->singular, '-') . '.get' . Text::camelize($fieldName) . '()';
$rowCode .= Utils::lowerCamelizeWithDelimiter($this->options->singular, '-', true) . '.get' . Text::camelize($fieldName) . '()';
} else {
$rowCode .= $this->options->singular . '.' . $fieldName;
}
Expand All @@ -812,7 +813,7 @@ private function _makeViewSearchVolt()
$code = str_replace('$plural$', $this->options->plural, $code);
$code = str_replace('$headerColumns$', $headerCode, $code);
$code = str_replace('$rowColumns$', $rowCode, $code);
$code = str_replace('$singularVar$', Text::camelize($this->options->singular, '-'), $code);
$code = str_replace('$singularVar$', Utils::lowerCamelizeWithDelimiter($this->options->singular, '-', true), $code);
$code = str_replace('$pk$', $idField, $code);

if ($this->isConsole()) {
Expand Down
6 changes: 3 additions & 3 deletions scripts/Phalcon/Commands/Builtin/AllModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public function getPossibleParams()
{
return [
'config=s' => 'Configuration file [optional]',
'models=s' => 'Models directory [optional]',
'schema=s' => 'Name of the schema. [optional]',
'namespace=s' => "Model's namespace [optional]",
'extends=s' => 'Models extends [optional]',
Expand All @@ -56,6 +55,7 @@ public function getPossibleParams()
'relations' => 'Possible relations defined according to convention [optional]',
'fk' => 'Define any virtual foreign keys [optional]',
'directory=s' => 'Base path on which project will be created [optional]',
'output=s' => 'Folder where models are located [optional]',
'mapcolumn' => 'Get some code for map columns [optional]',
'abstract' => 'Abstract Model [optional]',
'help' => 'Shows this help [optional]',
Expand Down Expand Up @@ -100,13 +100,13 @@ public function run(array $parameters)
$config = $this->path->getConfig();
}

if (!$this->isReceivedOption('models')) {
if (!$this->isReceivedOption('output')) {
if (!isset($config->application->modelsDir)) {
throw new CommandsException("Builder doesn't know where is the models directory.");
}
$modelsDir = rtrim($config->application->modelsDir, '\\/') . DIRECTORY_SEPARATOR;
} else {
$modelsDir = $this->getOption('models');
$modelsDir = $this->getOption('output');
}

if (false == $this->path->isAbsolutePath($modelsDir)) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Commands/DotPhalconMissingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DotPhalconMissingException extends CommandsException implements iSelfHeali
const DEFAULT_MESSAGE = "This command must be run inside a Phalcon project with a .phalcon directory.";
const RESOLUTION_PROMPT = "Shall I create the .phalcon directory now? (y/n)";

public function __construct (string $message = self::DEFAULT_MESSAGE , int $code = 0)
public function __construct (string $message = self::DEFAULT_MESSAGE , $code = 0)
{
$this->message = $message;
$this->code = $code;
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Devtools/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ class Version extends PhVersion
*/
protected static function _getVersion()
{
return [3, 2, 0, 4, 1];
return [3, 2, 3, 4, 1];
}
}
3 changes: 2 additions & 1 deletion scripts/Phalcon/Migrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ private static function connectionSetup($options)
new Column(
'end_time',
[
'type' => 'TIMESTAMP NOT NULL DEFAULT NOW()',
'type' => Column::TYPE_TIMESTAMP,
'notNull' => true,
]
)
],
Expand Down

0 comments on commit 6775406

Please sign in to comment.