- Added a new ObjectType annotation.

- Computer entity added
- Fixed some problem related to filter and repository of LDAP specific methods.
This commit is contained in:
Dave M. 2021-03-29 20:02:17 +00:00
parent 1b11917bf5
commit a0363ebb71
5 changed files with 67 additions and 5 deletions

View File

@ -0,0 +1,15 @@
<?php
namespace Ulmus\Ldap\Annotation\Classes;
class ObjectType implements \Ulmus\Annotation\Annotation {
public string $type;
public function __construct($type = null)
{
if ( $type !== null ) {
$this->type = $type;
}
}
}

View File

@ -1,10 +1,53 @@
<?php <?php
namespace Ulmus\Ldap\Entity; namespace Ulmus\Ldap\Entity;
use Ulmus\Ldap\Entity\Field\{ Datetime };
/**
* @ObjectClass('computer')
*/
class Computer class Computer
{ {
use \Ulmus\Ldap\EntityTrait;
/**
* @Field
*/
public string $samaccountname;
/**
* @Field
*/
public string $name;
/**
* @Field
*/
public string $description;
/**
* @Field('DNSHostName')
*/
public string $hostname;
/**
* @Field
*/
public string $location;
/**
* @Field
*/
public string $operatingSystem;
/**
* @Field
*/
public string $operatingSystemServicePack;
/**
* @Field
*/
public string $operatingSystemVersion;
} }

View File

@ -4,7 +4,7 @@ namespace Ulmus\Ldap;
use Ulmus\{ Ulmus, EventTrait, Query, Common\EntityResolver, Common\EntityField }; use Ulmus\{ Ulmus, EventTrait, Query, Common\EntityResolver, Common\EntityField };
use Ulmus\Ldap\Annotation\Classes\{ ObjectClass, }; use Ulmus\Ldap\Annotation\Classes\{ ObjectClass, ObjectType, };
trait EntityTrait { trait EntityTrait {
use \Ulmus\EntityTrait; use \Ulmus\EntityTrait;

View File

@ -96,7 +96,7 @@ class Filter extends Fragment {
$return = $this->content ?: $this->content = implode("", array_filter([ $return = $this->content ?: $this->content = implode("", array_filter([
$this->field, $this->field,
$this->operator(), $this->operator(),
$this->operator === Filter::OPERATOR_LIKE ? "*{$this->value}*" : $value, $this->operator === Filter::OPERATOR_LIKE ? str_replace('%', '*', $this->value) : $value,
])); ]));
return $this->applyOperator($return, ""); return $this->applyOperator($return, "");

View File

@ -2,7 +2,7 @@
namespace Ulmus\Ldap; namespace Ulmus\Ldap;
use Ulmus\Ldap\Annotation\Classes\ObjectClass; use Ulmus\Ldap\Annotation\Classes\{ ObjectClass, ObjectType };
use Ulmus\{EntityCollection, Ulmus, SearchRequest, Query}; use Ulmus\{EntityCollection, Ulmus, SearchRequest, Query};
use Ulmus\Annotation\Property\{ Where, Having, Relation, Join, WithJoin, Relation\Ignore as RelationIgnore }; use Ulmus\Annotation\Property\{ Where, Having, Relation, Join, WithJoin, Relation\Ignore as RelationIgnore };
use Ulmus\Common\EntityResolver; use Ulmus\Common\EntityResolver;
@ -27,10 +27,14 @@ class Repository extends \Ulmus\Repository
$this->select(array_keys($this->entityResolver->fieldList(EntityResolver::KEY_COLUMN_NAME))); $this->select(array_keys($this->entityResolver->fieldList(EntityResolver::KEY_COLUMN_NAME)));
} }
if ( null !== $objectClass = $this->entityResolver->getAnnotationFromClassname( ObjectClass::class ) ) { if ( null !== $objectClass = $this->entityResolver->getAnnotationFromClassname( ObjectClass::class, false ) ) {
$this->where('objectclass', $objectClass->type); $this->where('objectclass', $objectClass->type);
} }
if ( null !== $objectClass = $this->entityResolver->getAnnotationFromClassname( ObjectType::class, false ) ) {
$this->where('objecttype', $objectClass->type);
}
return $this; return $this;
} }