LdapTools\Resolver\BaseValueResolver::getInstance PHP Method

getInstance() public static method

Factory method for instantiation.
public static getInstance ( LdapObjectSchema $schema = null, BatchCollection | OperatorCollection | array $values, integer $type ) : AttributeValueResolver | BatchValueResolver
$schema LdapTools\Schema\LdapObjectSchema
$values LdapTools\BatchModify\BatchCollection | LdapTools\Query\OperatorCollection | array
$type integer
return AttributeValueResolver | BatchValueResolver
    public static function getInstance(LdapObjectSchema $schema = null, $values, $type)
    {
        $instance = AttributeValueResolver::class;
        if ($values instanceof BatchCollection) {
            $instance = BatchValueResolver::class;
        } elseif ($values instanceof OperatorCollection) {
            $instance = OperatorValueResolver::class;
        }
        return new $instance($schema, $values, $type);
    }

Usage Example

コード例 #1
0
ファイル: ArrayHydrator.php プロジェクト: ldaptools/ldaptools
 /**
  * Checks for attributes assigned an attribute converter. It will replace the value with the converted value then
  * send back all the attributes.
  *
  * @param array|BatchCollection|OperatorCollection $values
  * @param string|null $dn
  * @return array|BatchCollection|OperatorCollection
  */
 protected function convertValuesToLdap($values, $dn = null)
 {
     if (!$values instanceof OperatorCollection && !$this->schema) {
         return $values;
     }
     $valueResolver = BaseValueResolver::getInstance($this->schema, $values, $this->type);
     $this->configureValueResolver($valueResolver, $dn);
     return $valueResolver->toLdap();
 }