Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | namespace LdapRecord\Models\OpenLDAP; |
| 4 | |
| 5 | use LdapRecord\Connection; |
| 6 | use LdapRecord\Models\Entry as BaseEntry; |
| 7 | use LdapRecord\Models\OpenLDAP\Scopes\AddEntryUuidToSelects; |
| 8 | use LdapRecord\Models\Types\OpenLDAP; |
| 9 | use LdapRecord\Query\Model\OpenLdapBuilder; |
| 10 | |
| 11 | /** @mixin OpenLdapBuilder */ |
| 12 | class Entry extends BaseEntry implements OpenLDAP |
| 13 | { |
| 14 | /** |
| 15 | * The attribute key that contains the models object GUID. |
| 16 | * |
| 17 | * @var string |
| 18 | */ |
| 19 | protected $guidKey = 'entryuuid'; |
| 20 | |
| 21 | /** |
| 22 | * @inheritdoc |
| 23 | */ |
| 24 | protected static function boot() |
| 25 | { |
| 26 | parent::boot(); |
| 27 | |
| 28 | // Here we'll add a global scope to all OpenLDAP models to ensure the |
| 29 | // Entry UUID is always selected on each query. This attribute is |
| 30 | // virtual, so it must be manually selected to be included. |
| 31 | static::addGlobalScope(new AddEntryUuidToSelects()); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Create a new query builder. |
| 36 | * |
| 37 | * @param Connection $connection |
| 38 | * |
| 39 | * @return OpenLdapBuilder |
| 40 | */ |
| 41 | public function newQueryBuilder(Connection $connection) |
| 42 | { |
| 43 | return new OpenLdapBuilder($connection); |
| 44 | } |
| 45 | } |