Skip to content

Commit

Permalink
Merge pull request #32 from bluzphp/develop
Browse files Browse the repository at this point in the history
 Updated `Row` template
  • Loading branch information
Anton authored Oct 19, 2017
2 parents 2f27bdb + 46f5920 commit 7f89e76
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 33 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.DS_Store
.idea
!**.stub
vendor
composer.lock
composer.phar
vendor
build
10 changes: 6 additions & 4 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
MIT License

Copyright (c) 2012-2017 by Bluz PHP Team

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -7,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"require": {
"php": ">=7.0",
"codeception/codeception": "~2.3",
"composer/composer": "~1.4",
"robmorgan/phinx": "~0.8",
"composer/composer": "~1.5",
"robmorgan/phinx": "~0.9",
"symfony/console": "~3.0",
"symfony/event-dispatcher": "~3.0",
"symfony/filesystem": "~3.0",
Expand All @@ -24,11 +24,11 @@
"bluzphp/framework": "~7.7"
},
"require-dev": {
"phpunit/phpunit": "~6.2",
"mockery/mockery": "~0.9",
"nelmio/alice": "~2.2",
"fzaninotto/faker": "~1.6",
"squizlabs/php_codesniffer": "~3.0",
"phpunit/phpunit": "~6.4",
"mockery/mockery": "~1.0",
"nelmio/alice": "~3.0",
"fzaninotto/faker": "~1.7",
"squizlabs/php_codesniffer": "~3.1",
"satooshi/php-coveralls": "~1.0"
},
"bin": ["bin/bluzman"],
Expand Down
9 changes: 8 additions & 1 deletion src/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,14 @@ final public function initialize(InputInterface $input, OutputInterface $output)
$this->setInput($input);
$this->setOutput($output);

putenv('BLUZ_ENV=' . $input->getOption('env'));
putenv('BLUZ_ENV=' . ($input->getOption('env') ?: getenv('BLUZ_ENV')));

$config = new \Bluz\Config\Config();
$config->setPath(PATH_APPLICATION);
$config->setEnvironment($input->getOption('env'));
$config->init();

\Bluz\Proxy\Config::setInstance($config);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Command/Db/AbstractDbCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$phinxArguments['command'] = $commandName;
$phinxArguments['--configuration'] = PATH_APPLICATION .DS. 'configs' .DS. 'phinx.php';

if ($command->getDefinition()->hasOption('environment')) {
$phinxArguments['--environment'] = 'default';
}
$phinxArguments['--environment'] = 'default';

$phinxInput = new ArrayInput($phinxArguments);
$command->run($phinxInput, $output);
Expand Down
1 change: 0 additions & 1 deletion src/Command/Generate/ModelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ protected function generate(InputInterface $input, OutputInterface $output)
}
}
*/

// generate table
$tableFile = $this->getApplication()->getModelPath($modelName) . DS . 'Table.php';

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Server/StartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
// enable BLUZ_DEBUG
// use public/routing.php
$process = new Process(
"export BLUZ_ENV=$env && export BLUZ_DEBUG=1 && php -S $host:$port routing.php",
"export BLUZ_ENV=$env && export BLUZ_DEBUG=1 && export BLUZ_LOG=1 && php -S $host:$port routing.php",
$publicDir
);

Expand Down
4 changes: 2 additions & 2 deletions src/Generator/Template/RowTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function setTemplateData($templateData)
$columns = $templateData['columns'];
foreach ($columns as $column) {
// all properties will be `string` except `bigint`, `int`, etc. columns
$columnType = preg_match('/^int/', $column['type']) ? 'integer' : 'string';
$properties .= " * @property " . $columnType . " $" . $column['name'] . "\n";
$columnType = false !== strpos($column['type'], 'int') ? 'integer' : 'string';
$properties .= ' * @property ' . $columnType . ' $' . $column['name'] . "\n";
}
unset($templateData['columns']);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Generator/views/models/table.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Application\<?=$model?>;

use \Application\<?=$model?>\Row;

/**
* Class Table for `<?=$table?>`
*
Expand All @@ -20,7 +22,7 @@ class Table extends \Bluz\Db\Table
*/
protected $name = '<?=$table?>';

protected $rowClass = '\Application\<?=$model?>\Row';
protected $rowClass = Row::class;

/**
* Primary key(s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* @return array
*/
return [
"foo" => "bar"
'foo' => 'bar'
];
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* @return array
*/
return [
"bar" => "foo"
'bar' => 'foo'
];
9 changes: 4 additions & 5 deletions tests/BluzmanTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use Faker;
use Mockery;
use Nelmio\Alice\Fixtures\Loader;
use Nelmio\Alice\Loader\NativeLoader;
use Symfony\Component\Filesystem\Filesystem;

/**
Expand Down Expand Up @@ -99,10 +99,9 @@ public function setUp()
// generate unique working path for future use in commands
$this->setWorkingPath(PATH_TMP . DS . $this->getFaker()->uuid);

$loader = new Loader();
$fixture = $loader->load(__DIR__ . DS . 'Resources' . DS . 'fixtures' . DS . 'application.yml');

$this->setApplication(current($fixture));
$loader = new NativeLoader();
$fixture = $loader->loadfile(__DIR__ . DS . 'Resources' . DS . 'fixtures' . DS . 'application.yml');
$this->setApplication($fixture->getObjects()['app']);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion tests/Generator/samples/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
namespace Application\Users;

use \Application\Users\Row;

/**
* Class Table for `users`
*
Expand All @@ -19,7 +21,7 @@
*/
protected $name = 'users';

protected $rowClass = '\Application\Users\Row';
protected $rowClass = Row::class;

/**
* Primary key(s)
Expand Down
2 changes: 1 addition & 1 deletion tests/Resources/fixtures/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# fixture for Application
Bluzman\Application\Application:
-
app:
name: 'Bluzman Tests Application'
version: '1.0.0'
4 changes: 4 additions & 0 deletions tests/_bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
define('PATH_ROOT', $root);
define('PATH_VENDOR', PATH_ROOT . DS . 'vendor');
define('PATH_TMP', PATH_ROOT . DS . 'tests' . DS . 'Resources' . DS . 'tmp');
define(
'PATH_APPLICATION',
PATH_ROOT . DS . 'tests' . DS . 'Application' . DS . 'Resources' . DS . 'fixtures' . DS . 'app' . DS . 'application'
);
define('BLUZ_ENV', 'dev');

// register composer autoloader
Expand Down

0 comments on commit 7f89e76

Please sign in to comment.