Internal attributes are now handled by the new backend setup for attribute tags
This commit is contained in:
parent
85c7132b30
commit
1470170928
@ -36,7 +36,7 @@ class Attribute implements \Countable, \ArrayAccess, \Iterator
|
||||
// The old values for this attribute - helps with isDirty() to determine if there is an update pending
|
||||
protected(set) Collection $values_old;
|
||||
// Current Values
|
||||
public Collection $values;
|
||||
protected Collection $values;
|
||||
// The objectclasses of the entry that has this attribute
|
||||
protected(set) Collection $oc;
|
||||
|
||||
@ -152,11 +152,26 @@ class Attribute implements \Countable, \ArrayAccess, \Iterator
|
||||
'required_by' => $this->schema?->required_by_object_classes ?: collect(),
|
||||
// Used in Object Classes
|
||||
'used_in' => $this->schema?->used_in_object_classes ?: collect(),
|
||||
// The current attribute values
|
||||
'values' => $this->values,
|
||||
|
||||
default => throw new \Exception('Unknown key:' . $key),
|
||||
};
|
||||
}
|
||||
|
||||
public function __set(string $key,mixed $values)
|
||||
{
|
||||
switch ($key) {
|
||||
case 'values':
|
||||
if (is_null($values)) throw new \Exception('values is null?');
|
||||
$this->values = $values;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Exception('Unknown key:'.$key);
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->name;
|
||||
|
@ -22,6 +22,7 @@ class Factory
|
||||
public const map = [
|
||||
'createtimestamp' => Internal\Timestamp::class,
|
||||
'creatorsname' => Internal\DN::class,
|
||||
'configcontext' => Schema\Generic::class,
|
||||
'contextcsn' => Internal\CSN::class,
|
||||
'entrycsn' => Internal\CSN::class,
|
||||
'entrydn' => Internal\DN::class,
|
||||
@ -34,6 +35,8 @@ class Factory
|
||||
'jpegphoto' => Binary\JpegPhoto::class,
|
||||
'modifytimestamp' => Internal\Timestamp::class,
|
||||
'modifiersname' => Internal\DN::class,
|
||||
'monitorcontext' => Schema\Generic::class,
|
||||
'namingcontexts' => Schema\Generic::class,
|
||||
'numsubordinates' => Internal\NumSubordinates::class,
|
||||
'objectclass' => ObjectClass::class,
|
||||
'pwdpolicysubentry' => Internal\PwdPolicySubentry::class,
|
||||
@ -42,6 +45,7 @@ class Factory
|
||||
'supportedcontrol' => Schema\OID::class,
|
||||
'supportedextension' => Schema\OID::class,
|
||||
'supportedfeatures' => Schema\OID::class,
|
||||
'supportedldapversion' => Schema\Generic::class,
|
||||
'supportedsaslmechanisms' => Schema\Mechanisms::class,
|
||||
'userpassword' => Password::class,
|
||||
];
|
||||
|
@ -13,6 +13,15 @@ abstract class Internal extends Attribute
|
||||
{
|
||||
protected(set) bool $is_internal = TRUE;
|
||||
|
||||
public function __get(string $key): mixed
|
||||
{
|
||||
return match ($key) {
|
||||
// Internal items shouldnt have language tags, so our values should only have 1 key
|
||||
'values'=>collect($this->values->first()),
|
||||
default => parent::__get($key),
|
||||
};
|
||||
}
|
||||
|
||||
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||
{
|
||||
// @note Internal attributes cannot be edited
|
||||
|
@ -30,7 +30,7 @@ abstract class Schema extends Attribute
|
||||
while (! feof($f)) {
|
||||
$line = trim(fgets($f));
|
||||
|
||||
if (! $line OR preg_match('/^#/',$line))
|
||||
if ((! $line) || preg_match('/^#/',$line))
|
||||
continue;
|
||||
|
||||
$fields = explode(':',$line);
|
||||
@ -41,12 +41,24 @@ abstract class Schema extends Attribute
|
||||
'desc'=>Arr::get($fields,3,__('No description available, can you help with one?')),
|
||||
]);
|
||||
}
|
||||
|
||||
fclose($f);
|
||||
|
||||
return $result;
|
||||
});
|
||||
|
||||
return Arr::get(($array ? $array->get($string) : []),$key);
|
||||
return Arr::get(($array ? $array->get($string) : []),
|
||||
$key,
|
||||
__('No description available, can you help with one?'));
|
||||
}
|
||||
|
||||
public function __get(string $key): mixed
|
||||
{
|
||||
return match ($key) {
|
||||
// Schema items shouldnt have language tags, so our values should only have 1 key
|
||||
'values'=>collect($this->values->first()),
|
||||
default => parent::__get($key),
|
||||
};
|
||||
}
|
||||
|
||||
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||
|
20
app/Classes/LDAP/Attribute/Schema/Generic.php
Normal file
20
app/Classes/LDAP/Attribute/Schema/Generic.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\LDAP\Attribute\Schema;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
use App\Classes\LDAP\Attribute\Schema;
|
||||
|
||||
/**
|
||||
* Represents a Generic Schema Attribute
|
||||
*/
|
||||
class Generic extends Schema
|
||||
{
|
||||
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||
{
|
||||
// @note Schema attributes cannot be edited
|
||||
return view('components.attribute.schema.generic')
|
||||
->with('o',$this);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
<!-- $o=Internal::class -->
|
||||
@foreach (old($o->name_lc,$o->values) as $value)
|
||||
@foreach(old($o->name_lc,$o->values) as $value)
|
||||
@if($loop->index)<br>@endif
|
||||
{{ $value }}
|
||||
@endforeach
|
@ -1,5 +1,5 @@
|
||||
<!-- $o=Internal\Timestamp::class -->
|
||||
@foreach (old($o->name_lc,$o->values) as $value)
|
||||
@foreach(old($o->name_lc,$o->values) as $value)
|
||||
@if($loop->index)<br>@endif
|
||||
{{ \Carbon\Carbon::createFromTimestamp(strtotime($value))->format(config('pla.datetime_format','Y-m-d H:i:s')) }}
|
||||
@endforeach
|
@ -0,0 +1 @@
|
||||
{!! $o->values->join('<br>') !!}
|
Loading…
x
Reference in New Issue
Block a user