phpldapadmin/app/Classes/LDAP/Attribute/ObjectClass.php

50 lines
1.1 KiB
PHP
Raw Permalink Normal View History

<?php
namespace App\Classes\LDAP\Attribute;
use Illuminate\Contracts\View\View;
2023-04-11 22:17:57 +00:00
use Illuminate\Support\Collection;
2024-01-21 07:15:23 +00:00
use App\Classes\LDAP\{Attribute,Server};
/**
2023-03-02 07:21:53 +00:00
* Represents an ObjectClass Attribute
*/
final class ObjectClass extends Attribute
{
2023-04-11 22:17:57 +00:00
// Which of the values is the structural object class
protected Collection $structural;
public function __construct(string $name,array $values)
{
2023-04-11 22:17:57 +00:00
parent::__construct($name,$values);
$this->structural = collect();
// Determine which of the values is the structural objectclass
foreach ($values as $oc) {
2024-01-21 07:15:23 +00:00
if ((new Server)->schema('objectclasses',$oc)->isStructural())
2023-04-11 22:17:57 +00:00
$this->structural->push($oc);
}
}
2023-04-11 22:17:57 +00:00
/**
* Is a specific value the structural objectclass
*
* @param string $value
* @return bool
*/
public function isStructural(string $value): bool
{
return $this->structural->search($value) !== FALSE;
}
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
{
return view('components.attribute.objectclass')
->with('o',$this)
->with('edit',$edit)
->with('old',$old)
->with('new',$new);
}
}