16 \array_shift($argv_copy);
18 foreach ($argv_copy as $arg) {
19 if (\substr($arg, 0, 2) ==
'--') {
20 \preg_match(
"/\=|\:|\ /", $arg, $matches, PREG_OFFSET_CAPTURE);
21 $eqPos = $matches[0][1];
22 if ($eqPos ===
false) {
23 $key = \substr($arg, 2);
24 $out[$key] = isset($out[$key]) ? $out[$key] :
true;
26 $key = \substr($arg, 2, $eqPos - 2);
27 $out[$key] = \substr($arg, $eqPos + 1);
29 }
else if (\substr($arg, 0, 1) ==
'-') {
30 if (\substr($arg, 2, 1) ==
'=' || \substr($arg, 2, 1) ==
':' || \substr($arg, 2, 1) ==
' ') {
31 $key = \substr($arg, 1, 1);
32 $out[$key] = \substr($arg, 3);
34 $chars = \str_split(\substr($arg, 1));
35 foreach ($chars as $char) {
37 $out[$key] = isset($out[$key]) ? $out[$key] :
true;
47 protected static function getOption($options, $option, $longOption, $default = NULL) {
48 if (\array_key_exists($option, $options)) {
49 $option = $options[$option];
50 }
else if (\array_key_exists($longOption, $options)) {
51 $option = $options[$longOption];
52 }
else if (isset($default) ===
true) {
59 protected static function getOptionArray($options, $option, $longOption, $default = NULL) {
61 if (\is_string($option)) {
62 return \explode(
',', $option);
67 protected static function getBooleanOption($options, $option, $longOption, $default = NULL) {
68 if (\array_key_exists($option, $options)) {
69 $option = $options[$option];
70 }
else if (\array_key_exists($longOption, $options)) {
71 $option = $options[$longOption];
72 }
else if (isset($default) ===
true) {
77 if (\filter_var($option, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) ===
false) {
85 protected static function hasOption($options, $option, $longOption): bool {
86 return isset($options[$option]) || isset($options[$longOption]);
93 if ($answer ==
null) {
102 protected static function answerModel($options, $option, $longOption, $part, $config) {
103 $resource = self::getOption($options, $option, $longOption,
null);
104 if ($resource ==
null) {
106 $models = CacheManager::getModels($config,
true);
107 $answer =
Console::question(
"Enter the " . $longOption .
" to add from the following:\n", $models);
108 if (array_search($answer, $models) !==
false) {
115 return self::getCompleteClassname($config, $resource);
119 $prefix = Startup::getNS($type);
120 $classname = \ltrim($classname,
"\\");
122 $classname = $prefix . $classname;
124 return \str_replace(
"\\\\",
"\\", $classname);
128 if ($models !=
null) {
130 $models = \explode(
",", $models);
131 foreach ($models as $model) {
132 $model = self::getCompleteClassname($config, $model);
133 if (\class_exists($model)) {
143 $domain = self::getOption($options,
'o',
'domain',
'');
146 if (\array_search($domain, $domains) !==
false) {
149 throw new \Ubiquity\exceptions\UbiquityException(
"Domain `$domain` doesn't exist!");
Manager for caches (Router, Rest, models).
Manager for a Domain Driven Design approach.
static setDomain(string $domain)
Sets the active domain.
static getDomains()
Returns an array of existing domains.
static startswith($hay, $needle)