Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | namespace LdapRecord\Query; |
| 4 | |
| 5 | use LdapRecord\LdapRecordException; |
| 6 | |
| 7 | class ObjectNotFoundException extends LdapRecordException |
| 8 | { |
| 9 | /** |
| 10 | * The query filter that was used. |
| 11 | * |
| 12 | * @var string |
| 13 | */ |
| 14 | protected $query; |
| 15 | |
| 16 | /** |
| 17 | * The base DN of the query that was used. |
| 18 | * |
| 19 | * @var string |
| 20 | */ |
| 21 | protected $baseDn; |
| 22 | |
| 23 | /** |
| 24 | * Create a new exception for the executed filter. |
| 25 | * |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame^] | 26 | * @param string $query |
| 27 | * @param ?string $baseDn |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 28 | * |
| 29 | * @return static |
| 30 | */ |
| 31 | public static function forQuery($query, $baseDn = null) |
| 32 | { |
| 33 | return (new static())->setQuery($query, $baseDn); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Set the query that was used. |
| 38 | * |
| 39 | * @param string $query |
| 40 | * @param string|null $baseDn |
| 41 | * |
| 42 | * @return $this |
| 43 | */ |
| 44 | public function setQuery($query, $baseDn = null) |
| 45 | { |
| 46 | $this->query = $query; |
| 47 | $this->baseDn = $baseDn; |
| 48 | $this->message = "No LDAP query results for filter: [$query] in: [$baseDn]"; |
| 49 | |
| 50 | return $this; |
| 51 | } |
| 52 | } |