| @@ 234-258 (lines=25) @@ | ||
| 231 | * @param string|null $toScenario |
|
| 232 | * @return Model|null |
|
| 233 | */ |
|
| 234 | public function findById(int $id, string $toScenario = null) |
|
| 235 | { |
|
| 236 | ||
| 237 | // Check cache |
|
| 238 | if (!$model = $this->findCacheById($id)) { |
|
| 239 | ||
| 240 | // Find record in db |
|
| 241 | if ($record = $this->findRecordById($id)) { |
|
| 242 | ||
| 243 | // Perhaps in cache |
|
| 244 | $model = $this->findByRecord($record, $toScenario); |
|
| 245 | ||
| 246 | } else { |
|
| 247 | ||
| 248 | $this->_cacheById[$id] = null; |
|
| 249 | ||
| 250 | return null; |
|
| 251 | ||
| 252 | } |
|
| 253 | ||
| 254 | } |
|
| 255 | ||
| 256 | return $model; |
|
| 257 | ||
| 258 | } |
|
| 259 | ||
| 260 | /** |
|
| 261 | * @param int $id |
|
| @@ 64-88 (lines=25) @@ | ||
| 61 | * @param string|null $toScenario |
|
| 62 | * @return ModelWithHandle|null |
|
| 63 | */ |
|
| 64 | public function findByHandle(string $handle, string $toScenario = null) |
|
| 65 | { |
|
| 66 | ||
| 67 | // Check cache |
|
| 68 | if (!$model = $this->findCacheByHandle($handle)) { |
|
| 69 | ||
| 70 | // Find record in db |
|
| 71 | if ($record = $this->findRecordByHandle($handle)) { |
|
| 72 | ||
| 73 | /** @var ModelWithHandle $model */ |
|
| 74 | $model = $this->findByRecord($record, $toScenario); |
|
| 75 | ||
| 76 | } else { |
|
| 77 | ||
| 78 | $this->_cacheByHandle[$handle] = null; |
|
| 79 | ||
| 80 | return null; |
|
| 81 | ||
| 82 | } |
|
| 83 | ||
| 84 | } |
|
| 85 | ||
| 86 | return $model; |
|
| 87 | ||
| 88 | } |
|
| 89 | ||
| 90 | /** |
|
| 91 | * @param string $handle |
|
| @@ 231-255 (lines=25) @@ | ||
| 228 | * @param string|null $toScenario |
|
| 229 | * @return Object|null |
|
| 230 | */ |
|
| 231 | public function findById(int $id, string $toScenario = null) |
|
| 232 | { |
|
| 233 | ||
| 234 | // Check cache |
|
| 235 | if (!$object = $this->findCacheById($id)) { |
|
| 236 | ||
| 237 | // Find record in db |
|
| 238 | if ($record = $this->findRecordById($id)) { |
|
| 239 | ||
| 240 | // Perhaps in cache |
|
| 241 | $object = $this->findByRecord($record, $toScenario); |
|
| 242 | ||
| 243 | } else { |
|
| 244 | ||
| 245 | $this->_cacheById[$id] = null; |
|
| 246 | ||
| 247 | return null; |
|
| 248 | ||
| 249 | } |
|
| 250 | ||
| 251 | } |
|
| 252 | ||
| 253 | return $object; |
|
| 254 | ||
| 255 | } |
|
| 256 | ||
| 257 | /** |
|
| 258 | * @param int $id |
|
| @@ 55-79 (lines=25) @@ | ||
| 52 | * @param string|null $toScenario |
|
| 53 | * @return ObjectWithHandle|null |
|
| 54 | */ |
|
| 55 | public function findByHandle(string $handle, string $toScenario = null) |
|
| 56 | { |
|
| 57 | ||
| 58 | // Check cache |
|
| 59 | if (!$object = $this->findCacheByHandle($handle)) { |
|
| 60 | ||
| 61 | // Find record in db |
|
| 62 | if ($record = $this->findRecordByHandle($handle)) { |
|
| 63 | ||
| 64 | /** @var ObjectWithHandle $object */ |
|
| 65 | $object = $this->findByRecord($record, $toScenario); |
|
| 66 | ||
| 67 | } else { |
|
| 68 | ||
| 69 | $this->_cacheByHandle[$handle] = null; |
|
| 70 | ||
| 71 | return null; |
|
| 72 | ||
| 73 | } |
|
| 74 | ||
| 75 | } |
|
| 76 | ||
| 77 | return $object; |
|
| 78 | ||
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @param string $handle |
|