2023-03-02 09:54:30 +11:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Classes\LDAP\Attribute;
|
|
|
|
|
2023-04-02 22:07:15 +10:00
|
|
|
use Illuminate\Contracts\View\View;
|
2023-04-12 08:17:57 +10:00
|
|
|
use Illuminate\Support\Collection;
|
2023-04-02 22:07:15 +10:00
|
|
|
|
2025-01-19 22:01:20 +11:00
|
|
|
use App\Classes\LDAP\Attribute;
|
2023-03-02 09:54:30 +11:00
|
|
|
|
|
|
|
/**
|
2023-03-02 18:21:53 +11:00
|
|
|
* Represents an ObjectClass Attribute
|
2023-03-02 09:54:30 +11:00
|
|
|
*/
|
|
|
|
final class ObjectClass extends Attribute
|
|
|
|
{
|
2025-01-19 22:01:20 +11:00
|
|
|
// The schema ObjectClasses for this objectclass of a DN
|
|
|
|
protected Collection $oc_schema;
|
2023-04-12 08:17:57 +10:00
|
|
|
|
|
|
|
public function __construct(string $name,array $values)
|
2023-04-02 22:07:15 +10:00
|
|
|
{
|
2023-04-12 08:17:57 +10:00
|
|
|
parent::__construct($name,$values);
|
|
|
|
|
2025-01-19 22:01:20 +11:00
|
|
|
$this->oc_schema = config('server')
|
|
|
|
->schema('objectclasses')
|
|
|
|
->filter(fn($item)=>$this->values->contains($item->name));
|
|
|
|
}
|
2023-04-12 08:17:57 +10:00
|
|
|
|
2025-01-19 22:01:20 +11:00
|
|
|
public function __get(string $key): mixed
|
|
|
|
{
|
|
|
|
return match ($key) {
|
|
|
|
'structural' => $this->oc_schema->filter(fn($item) => $item->isStructural()),
|
|
|
|
default => parent::__get($key),
|
|
|
|
};
|
2023-04-02 22:07:15 +10:00
|
|
|
}
|
|
|
|
|
2023-04-12 08:17:57 +10:00
|
|
|
/**
|
|
|
|
* Is a specific value the structural objectclass
|
|
|
|
*
|
|
|
|
* @param string $value
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isStructural(string $value): bool
|
|
|
|
{
|
2025-01-19 22:01:20 +11:00
|
|
|
return $this->structural
|
|
|
|
->map(fn($item)=>$item->name)
|
|
|
|
->contains($value);
|
2023-04-12 08:17:57 +10:00
|
|
|
}
|
|
|
|
|
2024-01-20 10:36:30 +11:00
|
|
|
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
2023-03-02 09:54:30 +11:00
|
|
|
{
|
2023-04-02 22:07:15 +10:00
|
|
|
return view('components.attribute.objectclass')
|
2024-01-20 10:36:30 +11:00
|
|
|
->with('o',$this)
|
2023-04-02 22:07:15 +10:00
|
|
|
->with('edit',$edit)
|
2024-01-20 10:36:30 +11:00
|
|
|
->with('old',$old)
|
|
|
|
->with('new',$new);
|
2023-03-02 09:54:30 +11:00
|
|
|
}
|
|
|
|
}
|