Open
Description
Interception of methods in the internal PHP classes is the most complex one, however, it is required for special cases, for example, to intercept mysql->query()
invocation:
class MysqliQueryOperationCollectionAspect implements Aspect {
/**
* @param MethodInvocation $invocation Invocation
* @Around(execution(public mysqli->query(*))
* @return mixed
*/
public function aroundQueryMethod(MethodInvocation $invocation) {
$method = $invocation->getMethod();
$args = $invocation->getArguments();
$query = $args[1];
if ($this->logger->isTraceEnabled()) {
$this->logger->trace($method->getName().'('.$query.')');
}
try {
$result = $invocation->proceed();
return $result;
} catch(Exception $e) {
if ($this->logger->isTraceEnabled()) {
$this->logger->trace($method->getName().'('.$query.') '.get_class($e).':' .$e->getMessage());
}
throw $e;
}
}
}