예제 #1
0
 /**
  * Create a new generator.
  * This method initializes the necessary objects to run the application.
  * 
  * @return void
  */
 public function __construct()
 {
     $schemaFormats = implode(", ", ezcDbSchemaHandlerManager::getSupportedFormats());
     $this->output = new ezcConsoleOutput();
     $this->output->options->autobreak = 80;
     $this->output->formats->info->color = 'blue';
     $this->output->formats->info->style = array('bold');
     $this->output->formats->help->color = 'blue';
     $this->output->formats->error->color = 'red';
     $this->output->formats->error->style = array('bold');
     $this->output->formats->success->color = 'green';
     $this->output->formats->success->style = array('bold');
     $this->input = new ezcConsoleInput();
     $this->input->registerOption(new ezcConsoleOption("s", "source", ezcConsoleInput::TYPE_STRING, null, false, "DatabaseSchema source to use.", "The DatabaseSchema to use for the generation of the PersistentObject definition. Or the DSN to the database to grab the schema from.", array(), array(), true, true));
     $this->input->registerOption(new ezcConsoleOption("f", "format", ezcConsoleInput::TYPE_STRING, null, false, "DatabaseSchema format of the input source.", "The format, the input DatabaseSchema is in. Valid formats are {$schemaFormats}.", array(), array(), true, true));
     $this->input->registerOption(new ezcConsoleOption("o", "overwrite", ezcConsoleInput::TYPE_NONE, null, false, "Overwrite existing files.", "If this option is set, files will be overwriten if they alreday exist."));
     $this->input->registerOption(new ezcConsoleOption("p", "prefix", ezcConsoleInput::TYPE_STRING, null, false, "Class prefix.", "Unique prefix that will be prepended to all class names.", array(), array(), true, false));
     $this->input->registerOption(new ezcConsoleOption("h", "help", ezcConsoleInput::TYPE_NONE, null, false, "Retrieve detailed help about this application.", "Print out this help information.", array(), array(), true, false, true));
     $this->input->argumentDefinition = new ezcConsoleArguments();
     $this->input->argumentDefinition[0] = new ezcConsoleArgument("def dir");
     $this->input->argumentDefinition[0]->shorthelp = "PersistentObject definition directory.";
     $this->input->argumentDefinition[0]->longhelp = "Directory where PersistentObject definitions will be stored.";
     $this->input->argumentDefinition[1] = new ezcConsoleArgument("class dir");
     $this->input->argumentDefinition[1]->mandatory = false;
     $this->input->argumentDefinition[1]->shorthelp = "Class directory.";
     $this->input->argumentDefinition[1]->longhelp = "Directory where PHP classes will be stored. Classes will not be generated if this argument is ommited.";
     $this->output->outputLine('eZ components PersistentObject definition generator', 'info');
     $this->output->outputLine();
 }
예제 #2
0
 /**
  * Create a new generator.
  * This method initializes the necessary objects to run the application.
  * 
  * @return void
  */
 public function __construct()
 {
     $schemaFormats = implode(", ", ezcDbSchemaHandlerManager::getSupportedFormats());
     $this->output = new ezcConsoleOutput();
     $this->output->options->autobreak = 80;
     $this->output->formats->info->color = 'blue';
     $this->output->formats->info->style = array('bold');
     $this->output->formats->help->color = 'blue';
     $this->output->formats->error->color = 'red';
     $this->output->formats->error->style = array('bold');
     $this->output->formats->success->color = 'green';
     $this->output->formats->success->style = array('bold');
     $this->input = new ezcConsoleInput();
     $this->input->registerOption(new ezcConsoleOption("s", "source", ezcConsoleInput::TYPE_STRING, null, false, "DatabaseSchema source to use.", "The DatabaseSchema to use for the generation of the PersistentObject definition. Or the DSN to the database to grab the schema from.", array(), array(), true, true));
     $this->input->registerOption(new ezcConsoleOption("f", "format", ezcConsoleInput::TYPE_STRING, null, false, "DatabaseSchema format of the input source.", "The format, the input DatabaseSchema is in. Valid formats are {$schemaFormats}.", array(), array(), true, true));
     $this->input->registerOption(new ezcConsoleOption("o", "overwrite", ezcConsoleInput::TYPE_NONE, null, false, "Overwrite existing files.", "If this option is set, files will be overwriten if they alreday exist."));
     $this->input->registerOption(new ezcConsoleOption("p", "prefix", ezcConsoleInput::TYPE_STRING, null, false, "Class prefix.", "Unique prefix that will be prepended to all class names.", array(), array(), true, false));
     $this->input->registerOption(new ezcConsoleOption("t", "template", ezcConsoleInput::TYPE_NONE, null, false, "Use template rendering.", "Switch on template rendering. Use --class-template, --definition-template, --template-path to customize.", array(), array(), true, false));
     $this->input->registerOption(new ezcConsoleOption("ct", "class-template", ezcConsoleInput::TYPE_STRING, 'class_template.ezt', false, "Class template.", "Template file to use for writing class stubs, defaults to eZ Components style classes. Look at default template to customize.", array(), array(), true, false));
     $this->input->registerOption(new ezcConsoleOption("dt", "definition-template", ezcConsoleInput::TYPE_STRING, 'definition_template.ezt', false, "Definition template.", "Template file to use for writing definition stubs, defaults configs fitting the default class template. Look at default template to customize.", array(), array(), true, false));
     $this->input->registerOption(new ezcConsoleOption("tp", "template-path", ezcConsoleInput::TYPE_STRING, dirname(__FILE__) . '/template_writer/templates', false, "Base template path.", "Path where templates are located. Will also by used as the path to compile templates to.", array(), array(), true, false));
     $this->input->registerOption(new ezcConsoleOption("h", "help", ezcConsoleInput::TYPE_NONE, null, false, "Retrieve detailed help about this application.", "Print out this help information.", array(), array(), true, false, true));
     $this->input->getOption('template-path')->addDependency(new ezcConsoleOptionRule($this->input->getOption('template')));
     $this->input->getOption('definition-template')->addDependency(new ezcConsoleOptionRule($this->input->getOption('template')));
     $this->input->getOption('class-template')->addDependency(new ezcConsoleOptionRule($this->input->getOption('template')));
     $this->input->argumentDefinition = new ezcConsoleArguments();
     $this->input->argumentDefinition[0] = new ezcConsoleArgument("def dir");
     $this->input->argumentDefinition[0]->shorthelp = "PersistentObject definition directory.";
     $this->input->argumentDefinition[0]->longhelp = "Directory where PersistentObject definitions will be stored.";
     $this->input->argumentDefinition[1] = new ezcConsoleArgument("class dir");
     $this->input->argumentDefinition[1]->mandatory = false;
     $this->input->argumentDefinition[1]->shorthelp = "Class directory.";
     $this->input->argumentDefinition[1]->longhelp = "Directory where PHP classes will be stored. Classes will not be generated if this argument is ommited.";
     $this->output->outputLine('eZ components PersistentObject definition generator', 'info');
     $this->output->outputLine();
 }
예제 #3
0
 public function testSupportedFormats4()
 {
     ezcDbSchemaHandlerManager::addReader('test1', 'TestSchemaReaderImplementation');
     ezcDbSchemaHandlerManager::addWriter('test1', 'TestSchemaWriterImplementation');
     $formats = ezcDbSchemaHandlerManager::getSupportedFormats();
     self::assertEquals(array('array', 'mysql', 'oracle', 'pgsql', 'sqlite', 'xml', 'test1', 'persistent'), $formats);
 }