/** * Retrieves the list of groups from crowd and prints their attributes */ public function listGroupsCommand() { $validAttributes = $this->settings['additionalAttributes']['group']; $headerRow = ['Name', 'Description']; foreach ($validAttributes as $attribute) { $headerRow[] = $this->translator->translateById('attribute.' . $attribute, [], null, null, 'CrowdApi', 'Neos.NeosIo'); } $groups = $this->crowdApiConnector->fetchGroups(false); $tableRows = array_map(function ($item) use($validAttributes) { $attributes = [$item['name'], $item['description']]; foreach ($validAttributes as $attribute) { $attributes[] = array_key_exists($attribute, $item) ? $item[$attribute] : ''; } return $attributes; }, $groups); $this->output->outputTable($tableRows, $headerRow); }
/** * @param FlowQuery $flowQuery the FlowQuery object * @param array $arguments the arguments for this operation * @return void */ public function evaluate(FlowQuery $flowQuery, array $arguments) { $user = false; if (count($arguments) > 0 && is_string($arguments[0])) { $user = $this->apiConnector->fetchUser($arguments[0]); } if ($user) { $groups = $this->apiConnector->fetchGroups(); $user['memberships'] = array_filter($groups, function ($group) use($user) { return in_array($user['name'], $group['members']) && isset($group['neos_group_type']) && !empty($group['neos_group_type']); }); $user['additionalProperties'] = array_filter($user, function ($key) { return strpos($key, 'neos_') === 0; }, ARRAY_FILTER_USE_KEY); } $flowQuery->setContext($user); }
/** * @param FlowQuery $flowQuery the FlowQuery object * @param array $arguments the arguments for this operation * @return void */ public function evaluate(FlowQuery $flowQuery, array $arguments) { $groups = $this->apiConnector->fetchGroups(); $flowQuery->setContext($groups); }