0 follower

Class Yiisoft\Yii\Debug\Collector\ServiceMethodProxy

InheritanceYiisoft\Yii\Debug\Collector\ServiceMethodProxy » Yiisoft\Yii\Debug\Collector\ServiceProxy » Yiisoft\Proxy\ObjectProxy
Uses TraitsYiisoft\Yii\Debug\Collector\ProxyLogTrait

Method Details

Hide inherited methods

__construct() public method

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);
}

            
afterCall() protected method

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;
}

            
getConfig() protected method
protected Yiisoft\Yii\Debug\Collector\ContainerProxyConfig getConfig ( )

                protected function getConfig(): ContainerProxyConfig
{
    return $this->config;
}

            
getNewStaticInstance() protected method

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());
}

            
getService() protected method
protected string getService ( )

                protected function getService(): string
{
    return $this->service;
}

            
logProxy() protected method
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);
    }
}