Skip to content

Commit

Permalink
have a default hooks when customer did not provide hook
Browse files Browse the repository at this point in the history
  • Loading branch information
xinghengwang committed Mar 29, 2024
1 parent ca6585a commit 7acfb5a
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->defaultFalse()
->end()
->scalarNode('user_hooks_class')
->defaultValue(null)
->defaultValue('Moesif\MoesifBundle\Interfaces\MoesifDefaultHooks')
->end()
->arrayNode('options')
->addDefaultsIfNotSet()
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/MoesifExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function load(array $configs, ContainerBuilder $container)
$userMoesifConfigClass = $config['user_hooks_class'];
$definition = new Definition($userMoesifConfigClass);
$container->setDefinition('moesif.user_hooks', $definition);
}
}

if (isset($config['debug'])) {
$container->setParameter('moesif.debug', $config['debug']);
Expand Down
59 changes: 59 additions & 0 deletions src/Interfaces/MoesifDefaultHooks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace Moesif\MoesifBundle\Interfaces;

use Moesif\MoesifBundle\Interfaces\MoesifHooksInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;


class MoesifDefaultHooks implements MoesifHooksInterface {

public function __construct() {
}

public function identifyUserId(Request $request, Response $response): string|null
{
return null;
}

public function identifyCompanyId(Request $request, Response $response): string|null
{
return null;
}

public function identifySessionToken(Request $request, Response $response): string|null
{
return null;
}

public function getMetadata(Request $request, Response $response): ?array
{
return null;
}

public function skip(Request $request, Response $response): bool
{
return false;
}

public function maskRequestHeaders(array $headers): array
{
return $headers;
}

public function maskResponseHeaders(array $headers): array
{
return $headers;
}

public function maskRequestBody($body)
{
return $body;
}

public function maskResponseBody($body)
{
return $body;
}
}

0 comments on commit 7acfb5a

Please sign in to comment.