当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Ldap::save方法代码示例

本文整理汇总了PHP中Zend_Ldap::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Ldap::save方法的具体用法?PHP Zend_Ldap::save怎么用?PHP Zend_Ldap::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Ldap的用法示例。


在下文中一共展示了Zend_Ldap::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * Save new set of data from a t41_Data_Object object
  *
  * @param t41_Data_Object $do
  * @return boolean
  * @throws t41_Backend_Exception
  */
 public function create(ObjectModel\DataObject $do)
 {
     $pkey = $this->_mapper ? $this->_mapper->getPrimaryKey($do->getClass()) : 'uid';
     $recordSet = $do->toArray($this->_uri->getAlias());
     // get a valid data array passing mapper if any
     if ($this->_mapper) {
         // get object class
         $objectClass = $this->_mapper->getDataclass($do->getClass());
         $subDn = $this->_mapper->getDatastore($do->getClass());
         $recordSet = $do->map($this->_mapper, $this->_uri->getAlias());
     } else {
         /*
          * If no mapper is available, LDAP objectClass is supposed to be the same as PHP object class
          * CN is a MD5 hash of recordSet 
          */
         $objectClass = $do->getClass();
         $subDn = null;
     }
     $recordSet['data']['objectClass'] = $objectClass;
     try {
         if (!$this->_ressource) {
             $this->_connect($subDn);
         }
         // Define unique part of the record DN
         // If no value is specified, get a unique identifier
         $dn = sprintf('%s=%s', $pkey, isset($recordSet['data'][$pkey]) ? $recordSet['data'][$pkey] : $this->_getIdentifier($this->_mapper->getDatastore($do->getClass())));
         // Datastore value may contain supplemental path like 'ou=...'
         if (($ou = $this->_mapper->getDatastore($do->getClass())) != null) {
             $dn = $dn . ',' . $ou;
         }
         $dn .= ',' . $this->_baseDN;
         $this->_ressource->save($dn, $recordSet['data']);
     } catch (Exception $e) {
         // @todo decide wether throw an exception or just save last message in a property
         die($e->getMessage());
         return false;
     }
     $uri = new ObjectModel\ObjectUri();
     $do->setUri($this->getAlias() . '/' . $dn);
     /* get collection handling properties (if any) and process them */
     foreach ($do->getProperties() as $property) {
         if (!$property instanceof Property\CollectionProperty) {
             continue;
         }
         $collection = $property->getValue();
         var_dump($collection->getMembers());
         /* @var $member t41_Object_Model */
         foreach ($collection->getMembers() as $member) {
             $member->setProperty($property->getParameter('keyprop'), $uri);
             $member->save();
         }
     }
     return true;
 }
开发者ID:crapougnax,项目名称:t41,代码行数:61,代码来源:LdapAdapter.php


注:本文中的Zend_Ldap::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。