Class Yiisoft\Yii\Debug\Collector\ServiceMethodProxy
| Inheritance | Yiisoft\Yii\Debug\Collector\ServiceMethodProxy » Yiisoft\Yii\Debug\Collector\ServiceProxy » Yiisoft\Proxy\ObjectProxy |
|---|---|
| Uses Traits | Yiisoft\Yii\Debug\Collector\ProxyLogTrait |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Yii\Debug\Collector\ServiceMethodProxy |
Protected Methods
Method Details
| public mixed __construct ( string $service, object $instance, array $methods, Yiisoft\Yii\Debug\Collector\ContainerProxyConfig $config ) | ||
| $service | string | |
| $instance | object | |
| $methods | array | |
| $config | Yiisoft\Yii\Debug\Collector\ContainerProxyConfig | |
public function __construct(
string $service,
object $instance,
/**
* @psalm-var array<string, callable>
*/
private readonly array $methods,
ContainerProxyConfig $config
) {
parent::__construct($service, $instance, $config);
}
| protected mixed afterCall ( string $methodName, array $arguments, mixed $result, float $timeStart ) | ||
| $methodName | string | |
| $arguments | array | |
| $result | mixed | |
| $timeStart | float | |
protected function afterCall(string $methodName, array $arguments, mixed $result, float $timeStart): mixed
{
try {
if (isset($this->methods[$methodName])) {
$callback = $this->methods[$methodName];
$result = $callback($result, ...$arguments);
}
} finally {
$this->logProxy($this->getService(), $this->getInstance(), $methodName, $arguments, $result, $timeStart);
}
return $result;
}
| protected Yiisoft\Yii\Debug\Collector\ContainerProxyConfig getConfig ( ) |
protected function getConfig(): ContainerProxyConfig
{
return $this->config;
}
| protected \Yiisoft\Proxy\ObjectProxy getNewStaticInstance ( object $instance ) | ||
| $instance | object | |
protected function getNewStaticInstance(object $instance): ObjectProxy
{
/**
* @psalm-suppress UnsafeInstantiation Constructor should be consistent to `getNewStaticInstance()`.
*/
return new static($this->getService(), $instance, $this->methods, $this->getConfig());
}
| protected string getService ( ) |
protected function getService(): string
{
return $this->service;
}
| protected void logProxy ( string $service, object $instance, string $method, array $arguments, mixed $result, float $timeStart ) | ||
| $service | string | |
| $instance | object | |
| $method | string | |
| $arguments | array | |
| $result | mixed | |
| $timeStart | float | |
protected function logProxy(
string $service,
object $instance,
string $method,
array $arguments,
mixed $result,
float $timeStart
): void {
$error = $this->getCurrentError();
$this->processLogData($arguments, $result, $error);
if ($this->config->getCollector() !== null) {
$this->logToCollector($service, $instance, $method, $arguments, $result, $error, $timeStart);
}
if ($this->config->getDispatcher() !== null) {
$this->logToEvent($service, $instance, $method, $arguments, $result, $error, $timeStart);
}
}
Signup or Login in order to comment.