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


PHP PropPatch::getRemainingMutations方法代码示例

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


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

示例1: updateAddressBook

 /**
  * Updates an addressbook's properties
  *
  * See \Sabre\DAV\IProperties for a description of the mutations array, as
  * well as the return value.
  *
  * @param mixed $addressbookid
  * @see \Sabre\DAV\IProperties::updateProperties
  * @return bool|array
  */
 public function updateAddressBook($addressbookid, PropPatch $propPatch)
 {
     $changes = array();
     $mutations = $propPatch->getRemainingMutations();
     foreach ($mutations as $property => $newvalue) {
         switch ($property) {
             case '{DAV:}displayname':
                 $changes['displayname'] = $newvalue;
                 break;
             case '{' . \Sabre\CardDAV\Plugin::NS_CARDDAV . '}addressbook-description':
                 $changes['description'] = $newvalue;
                 break;
             default:
                 // If any unsupported values were being updated, we must
                 // let the entire request fail.
                 return false;
         }
     }
     list($id, $backend) = $this->getBackendForAddressBook($addressbookid);
     return $backend->updateAddressBook($id, $changes);
 }
开发者ID:s3menzer,项目名称:contacts,代码行数:31,代码来源:backend.php

示例2: updateCalendar

 /**
  * Updates a calendars properties
  *
  * The properties array uses the propertyName in clark-notation as key,
  * and the array value for the property value. In the case a property
  * should be deleted, the property value will be null.
  *
  * This method must be atomic. If one property cannot be changed, the
  * entire operation must fail.
  *
  * If the operation was successful, true can be returned.
  * If the operation failed, false can be returned.
  *
  * Deletion of a non-existant property is always succesful.
  *
  * Lastly, it is optional to return detailed information about any
  * failures. In this case an array should be returned with the following
  * structure:
  *
  * array(
  *   403 => array(
  *	  '{DAV:}displayname' => null,
  *   ),
  *   424 => array(
  *	  '{DAV:}owner' => null,
  *   )
  * )
  *
  * In this example it was forbidden to update {DAV:}displayname.
  * (403 Forbidden), which in turn also caused {DAV:}owner to fail
  * (424 Failed Dependency) because the request needs to be atomic.
  *
  * @param string $calendarId
  * @param PropPatch $propPatch
  * @return bool|array
  */
 public function updateCalendar($calendarId, PropPatch $propPatch)
 {
     $newValues = array();
     $result = array(200 => array(), 403 => array(), 424 => array());
     $hasError = false;
     $properties = $propPatch->getRemainingMutations();
     foreach ($properties as $propertyName => $propertyValue) {
         // We don't know about this property.
         if (!isset($this->propertyMap[$propertyName])) {
             $hasError = true;
             $result[403][$propertyName] = null;
             unset($properties[$propertyName]);
             continue;
         }
         $fieldName = $this->propertyMap[$propertyName];
         $newValues[$fieldName] = $propertyValue;
     }
     // If there were any errors we need to fail the request
     if ($hasError) {
         // Properties has the remaining properties
         foreach ($properties as $propertyName => $propertyValue) {
             $result[424][$propertyName] = null;
         }
         // Removing unused statuscodes for cleanliness
         foreach ($result as $status => $properties) {
             if (is_array($properties) && count($properties) === 0) {
                 unset($result[$status]);
             }
         }
         return $result;
     }
     // Success
     if (!isset($newValues['displayname'])) {
         $newValues['displayname'] = null;
     }
     if (!isset($newValues['timezone'])) {
         $newValues['timezone'] = null;
     }
     if (!isset($newValues['calendarorder'])) {
         $newValues['calendarorder'] = null;
     }
     if (!isset($newValues['calendarcolor'])) {
         $newValues['calendarcolor'] = null;
     }
     if (!is_null($newValues['calendarcolor']) && strlen($newValues['calendarcolor']) == 9) {
         $newValues['calendarcolor'] = substr($newValues['calendarcolor'], 0, 7);
     }
     OC_Calendar_Calendar::editCalendar($calendarId, $newValues['displayname'], null, $newValues['timezone'], $newValues['calendarorder'], $newValues['calendarcolor']);
     return true;
 }
开发者ID:AlfredoCubitos,项目名称:calendar,代码行数:86,代码来源:backend.php


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