Rework Components to use consistent variables and interface
This commit is contained in:
parent
cb06f3dcb6
commit
6991983743
@ -101,7 +101,7 @@ class Attribute implements \Countable, \ArrayAccess
|
|||||||
$this->values = collect($values);
|
$this->values = collect($values);
|
||||||
$this->lang_tags = collect();
|
$this->lang_tags = collect();
|
||||||
$this->required_by = collect();
|
$this->required_by = collect();
|
||||||
$this->oldValues = collect();
|
$this->oldValues = collect($values);
|
||||||
|
|
||||||
// No need to load our schema for internal attributes
|
// No need to load our schema for internal attributes
|
||||||
if (! $this->is_internal)
|
if (! $this->is_internal)
|
||||||
@ -143,6 +143,8 @@ class Attribute implements \Countable, \ArrayAccess
|
|||||||
'name' => $this->schema ? $this->schema->{$key} : $this->{$key},
|
'name' => $this->schema ? $this->schema->{$key} : $this->{$key},
|
||||||
// Attribute name in lower case
|
// Attribute name in lower case
|
||||||
'name_lc' => strtolower($this->name),
|
'name_lc' => strtolower($this->name),
|
||||||
|
// Old Values
|
||||||
|
'old_values' => $this->oldValues,
|
||||||
// Attribute values
|
// Attribute values
|
||||||
'values' => $this->values,
|
'values' => $this->values,
|
||||||
|
|
||||||
@ -150,9 +152,20 @@ class Attribute implements \Countable, \ArrayAccess
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __set(string $key,mixed $values): void
|
||||||
|
{
|
||||||
|
switch ($key) {
|
||||||
|
case 'value':
|
||||||
|
$this->values = collect($values);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
return $this->__get('name');
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function count(): int
|
public function count(): int
|
||||||
@ -230,15 +243,17 @@ class Attribute implements \Countable, \ArrayAccess
|
|||||||
* Display the attribute value
|
* Display the attribute value
|
||||||
*
|
*
|
||||||
* @param bool $edit
|
* @param bool $edit
|
||||||
* @param bool $blank
|
* @param bool $old
|
||||||
|
* @param bool $new
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function render(bool $edit=FALSE,bool $blank=FALSE): View
|
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||||
{
|
{
|
||||||
return view('components.attribute')
|
return view('components.attribute')
|
||||||
|
->with('o',$this)
|
||||||
->with('edit',$edit)
|
->with('edit',$edit)
|
||||||
->with('new',FALSE)
|
->with('old',$old)
|
||||||
->with('o',$this);
|
->with('new',$new);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,12 +21,13 @@ final class JpegPhoto extends Binary
|
|||||||
$this->internal = FALSE;
|
$this->internal = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render(bool $edit=FALSE,bool $blank=FALSE): View
|
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||||
{
|
{
|
||||||
return view('components.attribute.binary.jpegphoto')
|
return view('components.attribute.binary.jpegphoto')
|
||||||
->with('edit',$edit)
|
|
||||||
->with('blank',$blank)
|
|
||||||
->with('o',$this)
|
->with('o',$this)
|
||||||
|
->with('edit',$edit)
|
||||||
|
->with('old',$old)
|
||||||
|
->with('new',$new)
|
||||||
->with('f',new \finfo);
|
->with('f',new \finfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,7 +13,7 @@ abstract class Internal extends Attribute
|
|||||||
{
|
{
|
||||||
protected bool $is_internal = TRUE;
|
protected bool $is_internal = TRUE;
|
||||||
|
|
||||||
public function render(bool $edit=FALSE,bool $blank=FALSE): View
|
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||||
{
|
{
|
||||||
// @note Internal attributes cannot be edited
|
// @note Internal attributes cannot be edited
|
||||||
return view('components.attribute.internal')
|
return view('components.attribute.internal')
|
||||||
|
@ -11,7 +11,7 @@ use App\Classes\LDAP\Attribute\Internal;
|
|||||||
*/
|
*/
|
||||||
final class Timestamp extends Internal
|
final class Timestamp extends Internal
|
||||||
{
|
{
|
||||||
public function render(bool $edit=FALSE,bool $blank=FALSE): View
|
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||||
{
|
{
|
||||||
// @note Internal attributes cannot be edited
|
// @note Internal attributes cannot be edited
|
||||||
return view('components.attribute.internal.timestamp')
|
return view('components.attribute.internal.timestamp')
|
||||||
|
@ -39,10 +39,12 @@ final class ObjectClass extends Attribute
|
|||||||
return $this->structural->search($value) !== FALSE;
|
return $this->structural->search($value) !== FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render(bool $edit=FALSE,bool $blank=FALSE): View
|
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||||
{
|
{
|
||||||
return view('components.attribute.objectclass')
|
return view('components.attribute.objectclass')
|
||||||
|
->with('o',$this)
|
||||||
->with('edit',$edit)
|
->with('edit',$edit)
|
||||||
->with('o',$this);
|
->with('old',$old)
|
||||||
|
->with('new',$new);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,11 +14,12 @@ final class Password extends Attribute
|
|||||||
{
|
{
|
||||||
use MD5Updates;
|
use MD5Updates;
|
||||||
|
|
||||||
public function render(bool $edit=FALSE,bool $blank=FALSE): View
|
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||||
{
|
{
|
||||||
return view('components.attribute.password')
|
return view('components.attribute.password')
|
||||||
|
->with('o',$this)
|
||||||
->with('edit',$edit)
|
->with('edit',$edit)
|
||||||
->with('blank',$blank)
|
->with('old',$old)
|
||||||
->with('o',$this);
|
->with('new',$new);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -49,7 +49,7 @@ abstract class Schema extends Attribute
|
|||||||
return Arr::get(($array ? $array->get($string) : []),$key);
|
return Arr::get(($array ? $array->get($string) : []),$key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render(bool $edit=FALSE,bool $blank=FALSE): View
|
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||||
{
|
{
|
||||||
// @note Schema attributes cannot be edited
|
// @note Schema attributes cannot be edited
|
||||||
return view('components.attribute.internal')
|
return view('components.attribute.internal')
|
||||||
|
@ -33,7 +33,7 @@ final class Mechanisms extends Schema
|
|||||||
return parent::_get(config_path('ldap_supported_saslmechanisms.txt'),$string,$key);
|
return parent::_get(config_path('ldap_supported_saslmechanisms.txt'),$string,$key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render(bool $edit=FALSE,bool $blank=FALSE): View
|
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||||
{
|
{
|
||||||
// @note Schema attributes cannot be edited
|
// @note Schema attributes cannot be edited
|
||||||
return view('components.attribute.schema.mechanisms')
|
return view('components.attribute.schema.mechanisms')
|
||||||
|
@ -34,7 +34,7 @@ final class OID extends Schema
|
|||||||
return parent::_get(config_path('ldap_supported_oids.txt'),$string,$key);
|
return parent::_get(config_path('ldap_supported_oids.txt'),$string,$key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render(bool $edit=FALSE,bool $blank=FALSE): View
|
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
|
||||||
{
|
{
|
||||||
// @note Schema attributes cannot be edited
|
// @note Schema attributes cannot be edited
|
||||||
return view('components.attribute.schema.oid')
|
return view('components.attribute.schema.oid')
|
||||||
|
@ -11,16 +11,18 @@ class Attribute extends Component
|
|||||||
public LDAPAttribute $o;
|
public LDAPAttribute $o;
|
||||||
public bool $edit;
|
public bool $edit;
|
||||||
public bool $new;
|
public bool $new;
|
||||||
|
public bool $old;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new component instance.
|
* Create a new component instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(bool $edit,LDAPAttribute $o,bool $new=FALSE)
|
public function __construct(LDAPAttribute $o,bool $edit,bool $old=FALSE,bool $new=FALSE)
|
||||||
{
|
{
|
||||||
$this->edit = $edit;
|
|
||||||
$this->o = $o;
|
$this->o = $o;
|
||||||
|
$this->edit = $edit;
|
||||||
|
$this->old = $old;
|
||||||
$this->new = $new;
|
$this->new = $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +33,6 @@ class Attribute extends Component
|
|||||||
*/
|
*/
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return $this->o->render($this->edit,$this->new);
|
return $this->o->render($this->edit,$this->old,$this->new);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,6 +15,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<x-attribute :edit="true" :new="$new" :o="$o"/>
|
<x-attribute :o="$o" :edit="true" :new="$new"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
@ -1,8 +1,8 @@
|
|||||||
<!-- @todo We are not handling redirect backs with updated photos -->
|
<!-- @todo We are not handling redirect backs yet with updated photos -->
|
||||||
<!-- $o=Binary\JpegPhoto::class -->
|
<!-- $o=Binary\JpegPhoto::class -->
|
||||||
<x-attribute.layout :edit="$edit" :new="false" :o="$o">
|
<x-attribute.layout :edit="$edit" :new="false" :o="$o">
|
||||||
<table class="table table-borderless p-0 m-0">
|
<table class="table table-borderless p-0 m-0">
|
||||||
@foreach ($o->values as $value)
|
@foreach (($old ? $o->old_values : $o->values) as $value)
|
||||||
<tr>
|
<tr>
|
||||||
@switch ($x=$f->buffer($value,FILEINFO_MIME_TYPE))
|
@switch ($x=$f->buffer($value,FILEINFO_MIME_TYPE))
|
||||||
@case('image/jpeg')
|
@case('image/jpeg')
|
||||||
|
Loading…
Reference in New Issue
Block a user