99use Yiisoft \Factory \Exceptions \InvalidConfigException ;
1010use Yiisoft \Factory \Factory ;
1111
12- final class ActiveRecordFactory extends Factory
12+ final class ActiveRecordFactory
1313{
14+ /**
15+ * @var Factory
16+ */
17+ private Factory $ factory ;
18+
19+ public function __construct (Factory $ factory )
20+ {
21+ $ this ->factory = $ factory ;
22+ }
23+
1424 /**
1525 * Allows you to create an active record instance through the factory.
1626 *
@@ -22,7 +32,7 @@ final class ActiveRecordFactory extends Factory
2232 */
2333 public function createAR (string $ arClass ): ActiveRecordInterface
2434 {
25- return $ this ->create (
35+ return $ this ->factory -> create (
2636 [
2737 '__class ' => $ arClass ,
2838 ]
@@ -41,7 +51,7 @@ public function createAR(string $arClass): ActiveRecordInterface
4151 */
4252 public function createQueryTo (string $ arClass , string $ queryClass = null ): ActiveQueryInterface
4353 {
44- return $ this ->create (
54+ return $ this ->factory -> create (
4555 [
4656 '__class ' => $ queryClass ?? ActiveQuery::class,
4757 '__construct() ' => [
@@ -63,7 +73,7 @@ public function createQueryTo(string $arClass, string $queryClass = null): Activ
6373 */
6474 public function createRedisQueryTo (string $ arClass , string $ queryClass = null ): ActiveQueryInterface
6575 {
66- return $ this ->create (
76+ return $ this ->factory -> create (
6777 [
6878 '__class ' => $ queryClass ?? RedisActiveQuery::class,
6979 '__construct() ' => [
@@ -83,7 +93,7 @@ public function createRedisQueryTo(string $arClass, string $queryClass = null):
8393 */
8494 public function withConnection (ConnectionInterface $ connection ): void
8595 {
86- $ this ->set (ConnectionInterface::class, $ connection );
96+ $ this ->factory -> set (ConnectionInterface::class, $ connection );
8797 }
8898
8999 /**
@@ -95,6 +105,6 @@ public function withConnection(ConnectionInterface $connection): void
95105 */
96106 public function getConnection (): ConnectionInterface
97107 {
98- return $ this ->create (ConnectionInterface::class);
108+ return $ this ->factory -> create (ConnectionInterface::class);
99109 }
100110}
0 commit comments