Completed
Push — master ( dd800d...af5658 )
by Thomas
07:26
created

ActionUI::getLabel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace keeko\tools\ui;
3
4
use keeko\tools\ui\ModelSkeletonUI;
5
use Symfony\Component\Console\Question\Question;
6
use keeko\tools\helpers\ActionCommandHelperTrait;
7
8
class ActionUI extends ModelSkeletonUI {
9
10
	use ActionCommandHelperTrait;
11
	
12
	protected function getLabel() {
13
		return 'action';
14
	}
15
	
16
	protected function showSkeleton() {
17
		$input = $this->io->getInput();
18
		$name = $input->getArgument('name');
19
		
20
		if ($name === null) {
21
			$nameQuestion = new Question('What\'s the name for your action (must be a unique identifier)?', '');
22
			$name = $this->askQuestion($nameQuestion);
23
			$input->setArgument('name', $name);
24
		}
25
		$action = $this->getAction($name);
26
			
27
		// ask for title
28
		$pkgTitle = $action->getTitle();
29
		$title = $input->getOption('title');
30
		if ($title === null && !empty($pkgTitle)) {
31
			$title = $pkgTitle;
32
		}
33
		$titleQuestion = new Question('What\'s the title for your action?', $title);
34
		$title = $this->askQuestion($titleQuestion);
35
		$input->setOption('title', $title);
36
			
37
		// ask for classname
38
		$pkgClass = $action->getClass();
39
		$classname = $input->getOption('classname');
40
		if ($classname === null) {
41
			if (!empty($pkgClass)) {
42
				$classname = $pkgClass;
43
			} else {
44
				$classname = $this->guessClassname($name);
0 ignored issues
show
Bug introduced by
The method guessClassname() does not seem to exist on object<keeko\tools\ui\ActionUI>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
			}
46
		}
47
		$classname = $this->askQuestion(new Question('Classname', $classname));
48
		$input->setOption('classname', $classname);
49
			
50
		// ask for acl
51
		$acls = $this->getAcl($action);
52
		$aclQuestion = new Question('ACL (comma separated list, with these options: guest, user, admin)', implode(', ', $acls));
53
		$acls = $this->askQuestion($aclQuestion);
54
		$input->setOption('acl', $acls);
55
	}
56
}