@@ 79-102 (lines=24) @@ | ||
76 | * @param int|null $siteId |
|
77 | * @return BaseElement|ElementInterface|null |
|
78 | */ |
|
79 | public function find($identifier, int $siteId = null) |
|
80 | { |
|
81 | ||
82 | if ($identifier instanceof ElementInterface) { |
|
83 | ||
84 | $this->addToCache($identifier); |
|
85 | ||
86 | return $identifier; |
|
87 | ||
88 | } elseif (is_numeric($identifier)) { |
|
89 | ||
90 | return $this->findById($identifier, $siteId); |
|
91 | ||
92 | } elseif (is_array($identifier)) { |
|
93 | ||
94 | return $this->getQuery($identifier) |
|
95 | ->siteId($siteId) |
|
96 | ->one(); |
|
97 | ||
98 | } |
|
99 | ||
100 | return null; |
|
101 | ||
102 | } |
|
103 | ||
104 | /** |
|
105 | * @param int $id |
@@ 179-200 (lines=22) @@ | ||
176 | * @param string $toScenario |
|
177 | * @return BaseObject|null |
|
178 | */ |
|
179 | public function find($identifier, string $toScenario = null) |
|
180 | { |
|
181 | ||
182 | if ($identifier instanceof BaseObject) { |
|
183 | ||
184 | $this->addToCache($identifier); |
|
185 | ||
186 | return $identifier; |
|
187 | ||
188 | } elseif ($identifier instanceof Record) { |
|
189 | ||
190 | return $this->findByRecord($identifier, $toScenario); |
|
191 | ||
192 | } elseif (is_numeric($identifier)) { |
|
193 | ||
194 | return $this->findById($identifier, $toScenario); |
|
195 | ||
196 | } |
|
197 | ||
198 | return null; |
|
199 | ||
200 | } |
|
201 | ||
202 | /** |
|
203 | * @param $identifier |