Skip to content

Commit

Permalink
Merge pull request #7 from afosto/feature/generator
Browse files Browse the repository at this point in the history
fixed bug
  • Loading branch information
bakkerpeter authored Mar 10, 2017
2 parents a80df3f + 813850a commit 3e650de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Components/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function getNewModel() {
* @return integer
*/
public function getRelationType() {
if (in_array($this->_type, ['string', 'integer', 'float', 'boolean', '\DateTime'])) {
if (in_array($this->_type, ['string', 'integer', 'float', 'boolean', '\DateTime']) || (substr($this->_type, -2) == '[]' && strlen($this->_type) == 2)) {
return self::TYPE_VALUE;
} else if (substr($this->_type, -2) == '[]') {
return self::TYPE_MANY;
Expand Down
7 changes: 6 additions & 1 deletion src/Helpers/DocGen/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@

class Generator extends Command {

/**
* @var string
*/
public $root;

public function configure() {
$this->setName('docgen')->setDescription('Scraper for model data');
$this->addArgument('namespace', InputArgument::OPTIONAL, 'Directory of models (relative to root / src directory)?', 'Models');
}

public function execute(InputInterface $input, OutputInterface $output) {
$root = realpath(dirname(__FILE__) . '/../../') . DIRECTORY_SEPARATOR . 'Models' . DIRECTORY_SEPARATOR;
$root = $this->root . DIRECTORY_SEPARATOR . '/src/' . DIRECTORY_SEPARATOR . 'Models' . DIRECTORY_SEPARATOR;
$directory = new \RecursiveDirectoryIterator($root);
$iterator = new \RecursiveIteratorIterator($directory);
$regex = new \RegexIterator($iterator, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH);
Expand Down
7 changes: 5 additions & 2 deletions src/cli.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/usr/bin/env php
<?php

require_once '../vendor/autoload.php';
require_once 'vendor/autoload.php';

use Symfony\Component\Console\Application;
use Afosto\Bp\Helpers\DocGen\Generator;

$application = new Application();
$application->add(new Generator());

$generator = new Generator();
$generator->root = dirname(__FILE__);
$application->add($generator);
$application->run();

0 comments on commit 3e650de

Please sign in to comment.