Exemplo n.º 1
0
 /**
  * Creates a new instance of OPF.
  *
  * @param Opt_Class $opt Open Power Template instance.
  */
 public function __construct(Opt_Class $opt)
 {
     Opl_Registry::set('opf', $this);
     $opt->register(Opt_Class::OPT_NAMESPACE, 'opf');
     $opt->register(Opt_Class::OPT_INSTRUCTION, 'Form', 'Opf_View_Instruction_Form');
     $opt->register(Opt_Class::OPT_FORMAT, 'Form', 'Opf_View_Format_Form');
     $opt->register(Opt_Class::OPT_FORMAT, 'Design', 'Opf_View_Format_Design');
     $opt->register(Opt_Class::OPT_FORMAT, 'FormRepeater', 'Opf_View_Format_FormRepeater');
     $opt->register(Opt_Class::OPT_COMPONENT, 'opf:input', 'Opf_Widget_Input');
     $opt->register(Opt_Class::OPT_COMPONENT, 'opf:textarea', 'Opf_Widget_Textarea');
     $opt->register(Opt_Class::OPT_COMPONENT, 'opf:password', 'Opf_Widget_Password');
     $opt->register(Opt_Class::OPT_COMPONENT, 'opf:yesno', 'Opf_Widget_Yesno');
     $opt->register(Opt_Class::OPT_COMPONENT, 'opf:select', 'Opf_Widget_Select');
     $opt->register(Opt_Class::OPT_COMPONENT, 'opf:collection', 'Opf_Widget_Collection');
     Opt_View::setFormatGlobal('design', 'Design', false);
 }
Exemplo n.º 2
0
 /**
  * Starts the console application. The method checks the action to run,
  * parses the arguments and fires it.
  *
  * @throws Opl_Console_Exception
  * @param array $argv The argument list.
  */
 public function run(array $argv)
 {
     $action = isset($argv[1]) ? $argv[1] : $this->_default;
     if (!Opl_Registry::exists('stdout')) {
         Opl_Registry::set('stdout', new Opl_Stream_Console_Output());
     }
     if (!Opl_Registry::exists('stdin')) {
         Opl_Registry::set('stdin', new Opl_Stream_Console_Input());
     }
     if (isset($this->_actions[$action])) {
         unset($argv[0], $argv[1]);
         $getopt = new Opl_Getopt(Opl_Getopt::ALLOW_LONG_ARGS | Opl_Getopt::ALLOW_SHORT_ARGS | Opl_Getopt::AUTO_HELP);
         foreach ($this->_actions[$action]->getParams() as $option) {
             $getopt->addOption($option);
         }
         if (!$getopt->parse(array_values($argv))) {
             // TODO: Exception goes here!
             return;
         }
         $this->runAction($action, $getopt->getIterator()->getArrayCopy());
     } else {
         if ($this->_flags & self::AUTO_HELP) {
             $this->showHelp();
         } else {
             throw new Opl_Console_Exception('The specified action \'' . $action . '\' does not exist.');
         }
     }
 }
Exemplo n.º 3
0
 /**
  * @covers Opl_Registry::exists
  */
 public function testExistence()
 {
     Opl_Registry::set('foo', 'bar');
     $this->assertTrue(Opl_Registry::exists('foo'));
 }