|
10 | 10 | namespace Nette\Database\Table; |
11 | 11 |
|
12 | 12 | use Nette; |
13 | | -use Nette\Database\Conventions; |
14 | 13 | use Nette\Database\Explorer; |
15 | 14 |
|
16 | 15 |
|
|
24 | 23 | class Selection implements \Iterator, \ArrayAccess, \Countable |
25 | 24 | { |
26 | 25 | protected readonly Explorer $explorer; |
27 | | - |
28 | | - /** back compatibility */ |
29 | | - protected Explorer $context; |
30 | | - protected readonly Conventions $conventions; |
31 | 26 | protected readonly ?Nette\Caching\Cache $cache; |
32 | 27 | protected SqlBuilder $sqlBuilder; |
33 | 28 |
|
@@ -72,18 +67,12 @@ class Selection implements \Iterator, \ArrayAccess, \Countable |
72 | 67 | */ |
73 | 68 | public function __construct( |
74 | 69 | Explorer $explorer, |
75 | | - Conventions $conventions, |
76 | 70 | string $tableName, |
77 | | - ?Nette\Caching\Storage $cacheStorage = null, |
78 | 71 | ) { |
79 | | - $this->explorer = $this->context = $explorer; |
80 | | - $this->conventions = $conventions; |
| 72 | + $this->explorer = $explorer; |
81 | 73 | $this->name = $tableName; |
82 | | - |
83 | | - $this->cache = $cacheStorage |
84 | | - ? new Nette\Caching\Cache($cacheStorage, 'Nette.Database.' . hash('xxh128', $explorer->getConnection()->getDsn())) |
85 | | - : null; |
86 | | - $this->primary = $conventions->getPrimary($tableName); |
| 74 | + $this->cache = $explorer->getCache(); |
| 75 | + $this->primary = $explorer->getConventions()->getPrimary($tableName); |
87 | 76 | $this->sqlBuilder = new SqlBuilder($tableName, $explorer); |
88 | 77 | $this->refCache = &$this->getRefTable($refPath)->globalRefCache[$refPath]; |
89 | 78 | } |
@@ -555,13 +544,13 @@ protected function createRow(array $row): ActiveRow |
555 | 544 |
|
556 | 545 | public function createSelectionInstance(?string $table = null): self |
557 | 546 | { |
558 | | - return new self($this->explorer, $this->conventions, $table ?: $this->name, $this->cache?->getStorage()); |
| 547 | + return new self($this->explorer, $table ?: $this->name); |
559 | 548 | } |
560 | 549 |
|
561 | 550 |
|
562 | 551 | protected function createGroupedSelectionInstance(string $table, string $column): GroupedSelection |
563 | 552 | { |
564 | | - return new GroupedSelection($this->explorer, $this->conventions, $table, $column, $this, $this->cache?->getStorage()); |
| 553 | + return new GroupedSelection($this->explorer, $table, $column, $this); |
565 | 554 | } |
566 | 555 |
|
567 | 556 |
|
@@ -886,7 +875,7 @@ public function delete(): int |
886 | 875 | public function getReferencedTable(ActiveRow $row, ?string $table, ?string $column = null): ActiveRow|false|null |
887 | 876 | { |
888 | 877 | if (!$column) { |
889 | | - $belongsTo = $this->conventions->getBelongsToReference($this->name, $table); |
| 878 | + $belongsTo = $this->explorer->getConventions()->getBelongsToReference($this->name, $table); |
890 | 879 | if (!$belongsTo) { |
891 | 880 | return false; |
892 | 881 | } |
@@ -939,7 +928,7 @@ public function getReferencingTable( |
939 | 928 | if (str_contains($table, '.')) { |
940 | 929 | [$table, $column] = explode('.', $table); |
941 | 930 | } elseif (!$column) { |
942 | | - $hasMany = $this->conventions->getHasManyReference($this->name, $table); |
| 931 | + $hasMany = $this->explorer->getConventions()->getHasManyReference($this->name, $table); |
943 | 932 | if (!$hasMany) { |
944 | 933 | return null; |
945 | 934 | } |
|
0 commit comments