/** * @param $prefix * @param $filename */ public function __construct(GinnyInput $input) { $this->input = $input; $this->prefix = $input->getOption('prefix'); $this->map = new BaseMap($input->getOption('prefix')); $this->map->namespace = $input->getOption('namespace'); }
private function getInput() { $yaml = new \Symfony\Component\Yaml\Parser(); $local_defaults = $yaml->parse(file_get_contents(__DIR__ . '/../configs/default.yml')); $local_defaults['root'] = __DIR__ . '/../../'; $input = new GinnyInput($local_defaults); $input->bind(new GinnyDefinition()); return $input; }
public function __construct(GinnyInput $input, OutputInterface $output) { $this->input = $input; $this->output = $output; $this->target = $input->getFullTargetPath(); $this->template = $input->getFullTemplatePath(); $this->schema = $input->getFullSchemaPath(); $this->map = $this->map(); //s($this->map->dump()); //exit; $this->loadTwig(); }
public static function convert(GinnyInput $input) { $path = $input->getOption('schema_path'); $parser = new \Symfony\Component\Yaml\Parser(); if (is_dir($path)) { $data['name'] = $input->getOption('bundle'); $data['namespace'] = $input->getOption('namespace'); $data['models'] = []; $data['associations'] = []; $data['manyToManys'] = []; $schema_filename = $input->getOption('schema_filename'); if (empty($schema_filename)) { $filenames = []; $finder = new \Symfony\Component\Finder\Finder(); $finder->files()->in($input->getFullSchemaPath()); foreach ($finder as $file) { if ($file->getFilename() != 'ginny.yml') { $filenames[] = $file->getFilename(); } } } else { $filenames = explode(',', $schema_filename); } foreach ($filenames as $filename) { $file = $parser->parse(file_get_contents($path . $filename)); if (!empty($file['model'])) { $defaults = ['name' => '', 'description' => '']; $model = array_merge($defaults, $file['model']); $defaults = ['name' => '', 'type' => '', 'size' => '', 'default' => false, 'required' => false, 'unique' => false, 'primary' => false, 'autoIncrement' => false]; foreach ($model['fields'] as $n => $field) { $model['fields'][$n] = array_merge($defaults, $field); } $data['models'][] = $model; } if (!empty($file['associations'])) { $data['associations'] = array_merge($data['associations'], $file['associations']); } if (!empty($file['manyToManys'])) { $data['manyToManys'] = array_merge($data['manyToManys'], $file['manyToManys']); } } return ['bundles' => [$data]]; } echo 'booger!'; exit; }
/** * @covers \Foote\Ginny\Command\GinnyInput::validate * * @expectedException \Foote\Ginny\Exception\GinnyInputException * @expectedExceptionCode 103 */ public function testInvalidGeneratorNamespaceException() { $yaml = new \Symfony\Component\Yaml\Parser(); $local_defaults = $yaml->parse(file_get_contents(__DIR__ . '/../configs/default.yml')); $local_defaults['root'] = __DIR__ . '/../../'; $input = new GinnyInput($local_defaults, ['-g' => 'InvalidGeneratorName']); $input->bind(new GinnyDefinition()); $input->validate(); }