diff --git a/composer.json b/composer.json index a9f48b1d5..3abfc4ca9 100644 --- a/composer.json +++ b/composer.json @@ -48,6 +48,7 @@ "yiisoft/yii-queue": "3.0.x-dev" }, "require-dev": { + "cycle/orm": "^2.2", "maglnet/composer-require-checker": "^4.2", "nyholm/psr7": "^1.3", "phpunit/phpunit": "^9.4", diff --git a/src/Collector/Database/CycleCollector.php b/src/Collector/Database/CycleCollector.php new file mode 100644 index 000000000..dae5a63bc --- /dev/null +++ b/src/Collector/Database/CycleCollector.php @@ -0,0 +1,50 @@ +queries; + } + + public function collect(...$args): void + { + $this->queries[] = $args; + } + + private function collectQuery(string $sql, array $params, string $line): void + { + $this->queries[] = [ + 'rawSql' => $sql, + 'params' => $params, + 'line' => $line, + 'time' => microtime(true), + ]; + } + + public function getIndexData(): array + { + return [ + 'cycle' => [ + 'total' => count($this->queries), + ], + ]; + } + + private function reset(): void + { + $this->queries = []; + } +} diff --git a/src/Collector/Database/CycleORMInterfaceProxy.php b/src/Collector/Database/CycleORMInterfaceProxy.php new file mode 100644 index 000000000..daad98b63 --- /dev/null +++ b/src/Collector/Database/CycleORMInterfaceProxy.php @@ -0,0 +1,114 @@ +collector->collect('get', $role, $scope, $load); + return $this->orm->get($role, $scope, $load); + } + + public function getIndexes(string $entity): array + { + $this->collector->collect('getIndexes', $entity); + return $this->orm->getIndexes($entity); + } + + public function resolveRole(object|string $entity): string + { + $this->collector->collect('resolveRole', $entity); + return $this->orm->resolveRole($entity); + } + + public function make(string $role, array $data = [], int $status = Node::NEW, bool $typecast = false): object + { + $this->collector->collect('make', $role, $data, $status, $typecast); + return $this->orm->make($role, $data, $status, $typecast); + } + + public function getFactory(): FactoryInterface + { + $this->collector->collect('getFactory'); + return $this->orm->getFactory(); + } + + public function getCommandGenerator(): CommandGeneratorInterface + { + $this->collector->collect('getCommandGenerator'); + return $this->orm->getCommandGenerator(); + } + + public function getService(string $class): object + { + $this->collector->collect('getService', $class); + return $this->orm->getService($class); + } + + public function getSchema(): \Cycle\ORM\SchemaInterface + { + $this->collector->collect('getSchema'); + return $this->orm->getSchema(); + } + + public function getHeap(): HeapInterface + { + $this->collector->collect('getHeap'); + return $this->orm->getHeap(); + } + + public function with( + ?\Cycle\ORM\SchemaInterface $schema = null, + ?FactoryInterface $factory = null, + ?HeapInterface $heap = null + ): ORMInterface { + $this->collector->collect('with', $schema, $factory, $heap); + return new self($this->orm->with($schema, $factory, $heap), $this->collector); + } + + public function getMapper(object|string $entity): MapperInterface + { + $this->collector->collect('getMapper', $entity); + return $this->orm->getMapper($entity); + } + + public function getRepository(object|string $entity): RepositoryInterface + { +// var_dump($this->orm); +// exit(); +// throw new \InvalidArgumentException(); + $this->collector->collect('getRepository', $entity); + return $this->orm->getRepository($entity); + } + + public function getRelationMap(string $entity): RelationMap + { + $this->collector->collect('getRelationMap', $entity); + return $this->orm->getRelationMap($entity); + } + + public function getSource(string $entity): SourceInterface + { + $this->collector->collect('getSource', $entity); + return $this->orm->getSource($entity); + } +} diff --git a/src/Collector/Web/AuthenticationMethodInterfaceProxy.php b/src/Collector/Web/AuthenticationMethodInterfaceProxy.php index 37ab0c348..a35fe358a 100644 --- a/src/Collector/Web/AuthenticationMethodInterfaceProxy.php +++ b/src/Collector/Web/AuthenticationMethodInterfaceProxy.php @@ -8,6 +8,7 @@ use Psr\Http\Message\ServerRequestInterface; use Yiisoft\Auth\AuthenticationMethodInterface; use Yiisoft\Auth\IdentityInterface; +use Yiisoft\Yii\Debug\Collector\IdentityCollector; final class AuthenticationMethodInterfaceProxy implements AuthenticationMethodInterface {