private function assembleActions() { $actions = []; foreach ($this->actions->getAllActions() as $id => $action) { if ($id != WebApplication::INDEX_ACTION && $this->access->isPermitted($id)) { $actions[] = new ActionListItem($id, $action->caption(), $this->parser->shorten($action->description())); } } return $actions; }
private function printActions(Console $console) { $console->writeLine('Available Actions'); $console->writeLine('~~~~~~~~~~~~~~~~~'); foreach ($this->actions->getAllActions() as $id => $action) { $console->writeLine($id . ' - ' . $action->caption() . $this->shortDescription($action)); } }
function generateFromMethods() { eval('class ClassWithSomeMethods { /** * @param string $one * @param null|string $two */ function doThis($one, $two = "default") { return $one . ":" . $two; } function doThat() { return "foo"; } function _notMe() {} protected function notThis() {} static function neitherThis() {} }'); /** @noinspection PhpUndefinedClassInspection */ $object = new \ClassWithSomeMethods(); $actions = new ActionRegistry(); (new MethodActionGenerator($actions, new TypeFactory(), new CommentParser()))->fromObject($object)->configure($object, 'doThis', function (GenericMethodAction $action) { $action->generic()->setFill(function ($p) { $p['one'] = 'foo'; return $p; })->setDescription('My description')->setCaption('My caption')->mapParameter('one', function (Parameter $one) { return new Parameter('one', new ArrayType($one->getType())); }); })->configure($object, 'doThat', function (GenericMethodAction $action) { $action->generic()->setAfterExecute(function ($s) { return $s . '!'; })->setCaption('That'); }); $this->assert->size($actions->getAllActions(), 2); $doThis = $actions->getAction('ClassWithSomeMethods~doThis'); $this->assert($doThis->description(), 'My description'); $this->assert($doThis->caption(), 'My caption'); $this->assert($doThis->execute(['one' => 'foo', 'two' => 'bar']), 'foo:bar'); $this->assert($doThis->fill(['one' => 'bar']), ['one' => 'foo', 'two' => 'default']); $this->assert($doThis->parameters()[0], new Parameter('one', new ArrayType(new StringType()))); $doThat = $actions->getAction('ClassWithSomeMethods~doThat'); $this->assert($doThat->description(), ''); $this->assert($doThat->execute([]), 'foo!'); $this->assert($doThat->caption(), 'That'); }
private function whenIListTheActions() { $this->actions = $this->registry->getAllActions(); }