|
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 | use function array_filter, array_intersect_key, array_keys, array_map, array_merge, array_values, ceil, count, current, explode, func_num_args, hash, implode, is_array, is_int, iterator_to_array, key, next, reset, serialize, str_contains, substr_count; |
16 | 15 |
|
|
25 | 24 | class Selection implements \Iterator, \ArrayAccess, \Countable |
26 | 25 | { |
27 | 26 | protected readonly Explorer $explorer; |
28 | | - |
29 | | - /** back compatibility */ |
30 | | - protected Explorer $context; |
31 | | - protected readonly Conventions $conventions; |
32 | 27 | protected readonly ?Nette\Caching\Cache $cache; |
33 | 28 | protected SqlBuilder $sqlBuilder; |
34 | 29 |
|
@@ -73,18 +68,12 @@ class Selection implements \Iterator, \ArrayAccess, \Countable |
73 | 68 | */ |
74 | 69 | public function __construct( |
75 | 70 | Explorer $explorer, |
76 | | - Conventions $conventions, |
77 | 71 | string $tableName, |
78 | | - ?Nette\Caching\Storage $cacheStorage = null, |
79 | 72 | ) { |
80 | | - $this->explorer = $this->context = $explorer; |
81 | | - $this->conventions = $conventions; |
| 73 | + $this->explorer = $explorer; |
82 | 74 | $this->name = $tableName; |
83 | | - |
84 | | - $this->cache = $cacheStorage |
85 | | - ? new Nette\Caching\Cache($cacheStorage, 'Nette.Database.' . hash('xxh128', $explorer->getConnection()->getDsn())) |
86 | | - : null; |
87 | | - $this->primary = $conventions->getPrimary($tableName); |
| 75 | + $this->cache = $explorer->getCache(); |
| 76 | + $this->primary = $explorer->getConventions()->getPrimary($tableName); |
88 | 77 | $this->sqlBuilder = new SqlBuilder($tableName, $explorer); |
89 | 78 | $this->refCache = &$this->getRefTable($refPath)->globalRefCache[$refPath]; |
90 | 79 | } |
@@ -908,7 +897,7 @@ public function delete(): int |
908 | 897 | public function getReferencedTable(ActiveRow $row, ?string $table, ?string $column = null): ActiveRow|false|null |
909 | 898 | { |
910 | 899 | if (!$column) { |
911 | | - $belongsTo = $this->conventions->getBelongsToReference($this->name, $table); |
| 900 | + $belongsTo = $this->explorer->getConventions()->getBelongsToReference($this->name, $table); |
912 | 901 | if (!$belongsTo) { |
913 | 902 | return false; |
914 | 903 | } |
@@ -961,7 +950,7 @@ public function getReferencingTable( |
961 | 950 | if (str_contains($table, '.')) { |
962 | 951 | [$table, $column] = explode('.', $table); |
963 | 952 | } elseif (!$column) { |
964 | | - $hasMany = $this->conventions->getHasManyReference($this->name, $table); |
| 953 | + $hasMany = $this->explorer->getConventions()->getHasManyReference($this->name, $table); |
965 | 954 | if (!$hasMany) { |
966 | 955 | return null; |
967 | 956 | } |
|
0 commit comments