Skip to content

Commit

Permalink
[WIP] Changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
DonCallisto committed May 28, 2020
1 parent 0826814 commit 4ccec5a
Show file tree
Hide file tree
Showing 3 changed files with 767 additions and 2,446 deletions.
96 changes: 9 additions & 87 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ class Configuration implements ConfigurationInterface
'logentries' => ['token', 'use_ssl', 'level', 'bubble', 'timeout', 'connection_timeout'],
'insightops' => ['token', 'region', 'use_ssl', 'level', 'bubble'],
'flowdock' => ['token', 'source', 'from_email', 'level', 'bubble'],
'rollbar' => ['id', 'token', 'config', 'level', 'bubble'],
'server_log' => ['host', 'level', 'bubble'],
];

Expand Down Expand Up @@ -1066,18 +1067,21 @@ public function getConfigTreeBuilder()
private function handlerTypeAcceptedOptionsValidation(array $v)
{
if (!array_key_exists('type', $v)) {
return $v;
throw new \InvalidArgumentException("An handler type must be provided.");
}

if (!array_key_exists(strtolower($v['type']), $this->acceptedParamsByHandlerType)) {
if (in_array($v['type'], ['config', 'id', 'service'])) {
return $v;
}

// @todo array_keys should be converted to lowercase?
if (!array_key_exists($v['type'], $this->acceptedParamsByHandlerType)) {
throw new \InvalidArgumentException(sprintf("Invalid handler type: %s", $v['type']));
}

$acceptableParamsForHandlers = array_intersect($this->provideAllConfigurationParams(), array_keys($v));
$unacceptableParamForHandler = array_diff(
$acceptableParamsForHandlers,
$this->acceptedParamsByHandlerType[strtolower($v['type'])]
$this->acceptedParamsByHandlerType[$v['type']]
);
if (!empty($unacceptableParamForHandler)) {
throw new InvalidConfigurationException(sprintf(
Expand All @@ -1093,88 +1097,6 @@ private function handlerTypeAcceptedOptionsValidation(array $v)

private function provideAllConfigurationParams()
{
return [
'accepted_levels',
'action_level',
'activation_strategy',
'api_version',
'app_name',
'auto_log_stacks',
'bubble',
'bot_name',
'buffer_size',
'channel',
'client_id',
'config',
'connection_string',
'connection_timeout',
'console_formater_options',
'content_type',
'date_format',
'deduplication_level',
'document_type',
'dsn',
'elasticsearch',
'email_prototype',
'environment',
'exchange',
'exchange_name',
'excluded_404s',
'excluded_http_codes',
'facility',
'filename_format',
'file_permission',
'flush_on_overflow',
'from_email',
'handler',
'headers',
'host',
'icon_emoji',
'id',
'ident',
'include_extra',
'index',
'lazy',
'level',
'logopts',
'mailer',
'max_files',
'max_level',
'message_format',
'message_type',
'min_level',
'members',
'mongo',
'nickname',
'notify',
'path',
'passthru_level',
'persistent',
'port',
'publisher',
'redis',
'release',
'region',
'room',
'source',
'stop_buffering',
'store',
'subject',
'tags',
'team',
'time',
'timeout',
'title',
'token',
'to_email',
'url',
'user',
'use_attachment',
'use_locking',
'use_short_attachment',
'use_ssl',
'verbosity_levels',
'webhook_url',
];
return array_unique(call_user_func_array('array_merge', $this->acceptedParamsByHandlerType));
}
}

0 comments on commit 4ccec5a

Please sign in to comment.