getAliasAndAttribute() public static method

ie. list($alias, $attribute) = LdapUtilities::getAliasAndAttribute($attribute);
public static getAliasAndAttribute ( string $attribute ) : array
$attribute string
return array
 /**
  * @param array $attributes
  * @param null|string $alias
  * @return array
  */
 protected function getAttributesForAlias(array $attributes, $alias)
 {
     $toSelect = [];
     foreach ($attributes as $attribute) {
         list($attrAlias, $attrSelect) = LdapUtilities::getAliasAndAttribute($attribute);
         if (!$attrAlias || $attrAlias == $alias) {
             $toSelect[] = $attrSelect;
         }
     }
     return $toSelect;
 }
 /**
  * Determine how to get the value for the attribute from the LDAP entry being compared, and return that value.
  *
  * @param array|LdapObject $entry
  * @param string $attribute
  * @return mixed
  */
 protected function getComparisonValue($entry, $attribute)
 {
     $alias = null;
     if (!empty($this->aliases)) {
         list($alias, $attribute) = LdapUtilities::getAliasAndAttribute($attribute);
     }
     $value = '';
     if (is_array($entry) && isset($entry[$attribute])) {
         $value = $entry[$attribute];
         // Be forgiving if they are hydrating to an array and the case of the attribute was not correct.
     } elseif (is_array($entry) && array_key_exists(MBString::strtolower($attribute), MBString::array_change_key_case($entry))) {
         $value = MBString::array_change_key_case($entry)[MBString::strtolower($attribute)];
         // Only get the value if there is no alias requested, or if an alias was requested the object type must match the alias.
     } elseif ($entry instanceof LdapObject && (!$alias || $entry->isType($this->aliases[$alias]->getObjectType())) && $entry->has($attribute)) {
         $value = $entry->get($attribute);
     }
     // How to handle multi-valued attributes? This will at least prevent errors, but may not be accurate.
     $value = is_array($value) ? reset($value) : $value;
     return $this->convertValueToString($value);
 }
Beispiel #3
0
 /**
  * This formats the orderBy array to ignore case differences between the orderBy name and the actually selected name,
  * such as for sorting arrays.
  * 
  * @param $selected
  * @param $aliases
  * @return array
  */
 protected function getFormattedOrderBy($selected, $aliases)
 {
     if (!empty($aliases) && !$this->isWildCardSelection()) {
         $orderBy = [];
         foreach ($this->orderBy as $attribute => $direction) {
             list($alias, $attr) = LdapUtilities::getAliasAndAttribute($attribute);
             $orderAttr = MBString::array_search_get_value($attr, $selected);
             $orderAttr = $alias ? "{$alias}.{$orderAttr}" : $orderAttr;
             $orderBy[$orderAttr] = $direction;
         }
     } else {
         $orderBy = $this->orderBy;
     }
     return $orderBy;
 }