/** * Gets list of message groups filtered by user input. * @return MessageGroup[] */ protected function getGroups() { $groups = MessageGroups::getGroupsByType('FileBasedMessageGroup'); // Include all if option not given $include = $this->getOption('group', '*'); $include = explode(',', $include); $include = array_map('trim', $include); $include = MessageGroups::expandWildcards($include); // Exclude nothing if option not given $exclude = $this->getOption('skipgroup', ''); $exclude = explode(',', $exclude); $exclude = array_map('trim', $exclude); $exclude = MessageGroups::expandWildcards($exclude); // Flip to allow isset $include = array_flip($include); $exclude = array_flip($exclude); $groups = array_filter($groups, function (MessageGroup $group) use($include, $exclude) { $id = $group->getId(); return isset($include[$id]) && !isset($exclude[$id]); }); return $groups; }