Example #1
0
 /**
  * Factory method to create a detached Zend_Ldap_Node from array data.
  *
  * @param  array   $data
  * @param  boolean $fromDataSource
  * @return Zend_Ldap_Node
  * @throws Zend_Ldap_Exception
  */
 public static function fromArray(array $data, $fromDataSource = false)
 {
     if (!array_key_exists('dn', $data)) {
         /**
          * @see Zend_Ldap_Exception
          */
         require_once PHP_LIBRARY_PATH . 'Zend/Ldap/Exception.php';
         throw new Zend_Ldap_Exception(null, '\'dn\' key is missing in array.');
     }
     if (is_string($data['dn']) || is_array($data['dn'])) {
         $dn = Zend_Ldap_Dn::factory($data['dn']);
     } else {
         if ($data['dn'] instanceof Zend_Ldap_Dn) {
             $dn = clone $data['dn'];
         } else {
             /**
              * @see Zend_Ldap_Exception
              */
             require_once PHP_LIBRARY_PATH . 'Zend/Ldap/Exception.php';
             throw new Zend_Ldap_Exception(null, '\'dn\' key is of a wrong data type.');
         }
     }
     $fromDataSource = $fromDataSource === true ? true : false;
     $new = new self($dn, $data, $fromDataSource, null);
     $new->_ensureRdnAttributeValues();
     return $new;
 }
Example #2
0
File: Node.php Project: narixx/zf2
 /**
  * Factory method to create a detached Zend_Ldap_Node from array data.
  *
  * @param  array   $data
  * @param  boolean $fromDataSource
  * @return \Zend\Ldap\Node
  * @throws \Zend\Ldap\Exception
  */
 public static function fromArray(array $data, $fromDataSource = false)
 {
     if (!array_key_exists('dn', $data)) {
         throw new Exception(null, '\'dn\' key is missing in array.');
     }
     if (is_string($data['dn']) || is_array($data['dn'])) {
         $dn = Dn::factory($data['dn']);
     } else {
         if ($data['dn'] instanceof Dn) {
             $dn = clone $data['dn'];
         } else {
             throw new Exception(null, '\'dn\' key is of a wrong data type.');
         }
     }
     $fromDataSource = $fromDataSource === true ? true : false;
     $new = new self($dn, $data, $fromDataSource, null);
     $new->_ensureRdnAttributeValues();
     return $new;
 }