Ejemplo n.º 1
0
 /**
  * Retrieves a user from crowd and prints their attributes
  * @param string $userName
  */
 public function showUserCommand($userName)
 {
     $validAttributes = $this->settings['additionalAttributes']['user'];
     $headerRow = ['Name', 'Fullname'];
     foreach ($validAttributes as $attribute) {
         $headerRow[] = $this->translator->translateById('attribute.' . $attribute, [], null, null, 'CrowdApi', 'Neos.NeosIo');
     }
     $user = $this->crowdApiConnector->fetchUser($userName, false);
     $attributes = [$user['name'], $user['display-name']];
     foreach ($validAttributes as $attribute) {
         $attributes[] = array_key_exists($attribute, $user) ? $user[$attribute] : '';
     }
     $this->output->outputTable([$attributes], $headerRow);
 }
Ejemplo n.º 2
0
 /**
  * @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);
 }