private function triggersFor($user = null, array $filter = []) {
        if (empty($user) || empty($filter)) {
            return true;
        }

        $filter = array_merge(['whitelist' => [], 'blacklist' => []],  $filter);

        $whitelist = array_flip($filter['whitelist']);
        $blacklist = array_flip($filter['blacklist']);

        if (
            // Both lists are empty
            empty($whitelist) && empty($blacklist) ||

            // Whitelist is empty, and the user is not blacklisted
            empty($whitelist) && !isset($blacklist[$user]) ||

            // Blacklist is empty, and the user is whitelisted
            empty($blacklist) && isset($whitelist[$user])
        ) {
            return true;
        }

        return false;
    }
private function triggersFor($user = null, array $filter = []) {
        if (empty($user) || empty($filter)) {
            return true;
        }

        $filter = array_merge(['whitelist' => [], 'blacklist' => []],  $filter);

        $whitelist = array_flip($filter['whitelist']);
        $blacklist = array_flip($filter['blacklist']);

        if (
            // Both lists are empty
            empty($whitelist) && empty($blacklist) ||

            // Whitelist is empty, and the user is not blacklisted
            empty($whitelist) && !isset($blacklist[$user]) ||

            // Blacklist is empty, and the user is whitelisted
            empty($blacklist) && isset($whitelist[$user])
        ) {
            return true;
        }

        return false;
    }
private function triggersFor ( $ user = null , array $ filter = [ ] ) { if ( empty ( $ user ) || empty ( $ filter ) ) { return true ; } $ filter = array_merge ( [ 'whitelist' => [ ] , 'blacklist' => [ ] ] , $ filter ) ; $ whitelist = array_flip ( $ filter [ 'whitelist' ] ) ; $ blacklist = array_flip ( $ filter [ 'blacklist' ] ) ; if ( // Both lists are empty empty ( $ whitelist ) && empty ( $ blacklist ) || // Whitelist is empty, and the user is not blacklisted empty ( $ whitelist ) && ! isset ( $ blacklist [ $ user ] ) || // Blacklist is empty, and the user is whitelisted empty ( $ blacklist ) && isset ( $ whitelist [ $ user ] ) ) { return true ; } return false ; }
Check if a listener will trigger for a given user

@param string $user The user to check for, can be null
@param array $filter The array from the listener with "whitelist" and "blacklist"
@return boolean
Check if a listener will trigger for a given user