blob: b7ad37a44a55c239ecf757f8523c7c6dd83472aa [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2
3namespace LdapRecord\Models\OpenLDAP;
4
5use LdapRecord\Connection;
6use LdapRecord\Models\Entry as BaseEntry;
7use LdapRecord\Models\OpenLDAP\Scopes\AddEntryUuidToSelects;
8use LdapRecord\Models\Types\OpenLDAP;
9use LdapRecord\Query\Model\OpenLdapBuilder;
10
11/** @mixin OpenLdapBuilder */
12class 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}