Display a DN entry with language tags - work for #16
This commit is contained in:
@@ -178,14 +178,7 @@ class Attribute implements \Countable, \ArrayAccess, \Iterator
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function addValue(string $tag,string $value): void
|
||||
{
|
||||
$this->_values->put(
|
||||
$tag,
|
||||
$this->_values
|
||||
->get($tag,collect())
|
||||
->push($value));
|
||||
}
|
||||
/* INTERFACE */
|
||||
|
||||
public function current(): mixed
|
||||
{
|
||||
@@ -237,6 +230,24 @@ class Attribute implements \Countable, \ArrayAccess, \Iterator
|
||||
// We cannot clear values using array syntax
|
||||
}
|
||||
|
||||
/* METHODS */
|
||||
|
||||
public function addValue(string $tag,array $values): void
|
||||
{
|
||||
$this->_values->put(
|
||||
$tag,
|
||||
array_unique(array_merge($this->_values
|
||||
->get($tag,[]),$values)));
|
||||
}
|
||||
|
||||
public function addValueOld(string $tag,array $values): void
|
||||
{
|
||||
$this->_values_old->put(
|
||||
$tag,
|
||||
array_unique(array_merge($this->_values_old
|
||||
->get($tag,[]),$values)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the hints about this attribute, ie: RDN, Required, etc
|
||||
*
|
||||
@@ -266,8 +277,10 @@ class Attribute implements \Countable, \ArrayAccess, \Iterator
|
||||
*/
|
||||
public function isDirty(): bool
|
||||
{
|
||||
return ($this->values_old->count() !== $this->values->count())
|
||||
|| ($this->values->diff($this->values_old)->count() !== 0);
|
||||
return (($a=$this->values_old->dot())->keys()->count() !== ($b=$this->values->dot())->keys()->count())
|
||||
|| ($a->values()->count() !== $b->values()->count())
|
||||
|| ($a->keys()->diff($b->keys())->count() !== 0)
|
||||
|| ($a->values()->diff($b->values())->count() !== 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,4 +342,18 @@ class Attribute implements \Countable, \ArrayAccess, \Iterator
|
||||
? $this->oc->intersect($this->required_by->keys())->sort()
|
||||
: collect();
|
||||
}
|
||||
|
||||
public function tagValues(string $tag=''): Collection
|
||||
{
|
||||
return $this->_values
|
||||
->filter(fn($item,$key)=>($key === $tag))
|
||||
->values();
|
||||
}
|
||||
|
||||
public function tagValuesOld(string $tag=''): Collection
|
||||
{
|
||||
return $this->_values_old
|
||||
->filter(fn($item,$key)=>($key === $tag))
|
||||
->values();
|
||||
}
|
||||
}
|
@@ -309,7 +309,9 @@ class Entry extends Model
|
||||
->map(fn($item)=>$item
|
||||
->values
|
||||
->keys()
|
||||
->filter(fn($item)=>preg_match(sprintf('/%s+;?/',self::TAG_CHARS_LANG),$item)))
|
||||
->filter(fn($item)=>preg_match(sprintf('/%s+;?/',self::TAG_CHARS_LANG),$item))
|
||||
->map(fn($item)=>preg_replace('/lang-/','',$item))
|
||||
)
|
||||
->filter(fn($item)=>$item->count());
|
||||
}
|
||||
|
||||
|
@@ -12,17 +12,19 @@ class Attribute extends Component
|
||||
public bool $edit;
|
||||
public bool $new;
|
||||
public bool $old;
|
||||
public ?string $na;
|
||||
public string $langtag;
|
||||
public ?string $na; // Text to render if the LDAPAttribute is null
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct(?LDAPAttribute $o,bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,?string $na=NULL)
|
||||
public function __construct(?LDAPAttribute $o,bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,string $langtag='',?string $na=NULL)
|
||||
{
|
||||
$this->o = $o;
|
||||
$this->edit = $edit;
|
||||
$this->old = $old;
|
||||
$this->new = $new;
|
||||
$this->langtag = $langtag;
|
||||
$this->na = $na;
|
||||
}
|
||||
|
||||
|
@@ -13,14 +13,16 @@ class AttributeType extends Component
|
||||
{
|
||||
private LDAPAttribute $o;
|
||||
private bool $new;
|
||||
private string $langtag;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct(LDAPAttribute $o,bool $new=FALSE)
|
||||
public function __construct(LDAPAttribute $o,bool $new=FALSE,string $langtag='')
|
||||
{
|
||||
$this->o = $o;
|
||||
$this->new = $new;
|
||||
$this->langtag = $langtag;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,6 +32,7 @@ class AttributeType extends Component
|
||||
{
|
||||
return view('components.attribute-type')
|
||||
->with('o',$this->o)
|
||||
->with('new',$this->new);
|
||||
->with('new',$this->new)
|
||||
->with('langtag',$this->langtag);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user