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


PHP Server::getPropertiesByNode方法代码示例

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


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

示例1: propFind

 /**
  * This method handler is invoked during fetching of properties.
  *
  * We use this event to add calendar-auto-schedule-specific properties.
  *
  * @param PropFind $propFind
  * @param INode $node
  * @return void
  */
 function propFind(PropFind $propFind, INode $node)
 {
     if ($node instanceof DAVACL\IPrincipal) {
         $caldavPlugin = $this->server->getPlugin('caldav');
         $principalUrl = $node->getPrincipalUrl();
         // schedule-outbox-URL property
         $propFind->handle('{' . self::NS_CALDAV . '}schedule-outbox-URL', function () use($principalUrl, $caldavPlugin) {
             $calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl);
             if (!$calendarHomePath) {
                 return null;
             }
             $outboxPath = $calendarHomePath . '/outbox/';
             return new Href($outboxPath);
         });
         // schedule-inbox-URL property
         $propFind->handle('{' . self::NS_CALDAV . '}schedule-inbox-URL', function () use($principalUrl, $caldavPlugin) {
             $calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl);
             if (!$calendarHomePath) {
                 return null;
             }
             $inboxPath = $calendarHomePath . '/inbox/';
             return new Href($inboxPath);
         });
         $propFind->handle('{' . self::NS_CALDAV . '}schedule-default-calendar-URL', function () use($principalUrl, $caldavPlugin) {
             // We don't support customizing this property yet, so in the
             // meantime we just grab the first calendar in the home-set.
             $calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl);
             if (!$calendarHomePath) {
                 return null;
             }
             $sccs = '{' . self::NS_CALDAV . '}supported-calendar-component-set';
             $result = $this->server->getPropertiesForPath($calendarHomePath, ['{DAV:}resourcetype', $sccs], 1);
             foreach ($result as $child) {
                 if (!isset($child[200]['{DAV:}resourcetype']) || !$child[200]['{DAV:}resourcetype']->is('{' . self::NS_CALDAV . '}calendar') || $child[200]['{DAV:}resourcetype']->is('{http://calendarserver.org/ns/}shared')) {
                     // Node is either not a calendar or a shared instance.
                     continue;
                 }
                 if (!isset($child[200][$sccs]) || in_array('VEVENT', $child[200][$sccs]->getValue())) {
                     // Either there is no supported-calendar-component-set
                     // (which is fine) or we found one that supports VEVENT.
                     return new Href($child['href']);
                 }
             }
         });
         // The server currently reports every principal to be of type
         // 'INDIVIDUAL'
         $propFind->handle('{' . self::NS_CALDAV . '}calendar-user-type', function () {
             return 'INDIVIDUAL';
         });
     }
     // Mapping the old property to the new property.
     $propFind->handle('{http://calendarserver.org/ns/}calendar-availability', function () use($propFind, $node) {
         // In case it wasn't clear, the only difference is that we map the
         // old property to a different namespace.
         $availProp = '{' . self::NS_CALDAV . '}calendar-availability';
         $subPropFind = new PropFind($propFind->getPath(), [$availProp]);
         $this->server->getPropertiesByNode($subPropFind, $node);
         $propFind->set('{http://calendarserver.org/ns/}calendar-availability', $subPropFind->get($availProp), $subPropFind->getStatus($availProp));
     });
 }
开发者ID:jakobsack,项目名称:sabre-dav,代码行数:69,代码来源:Plugin.php

示例2: prepareResponses

 /**
  * Prepare propfind response for the given nodes
  *
  * @param string[] $requestedProps requested properties
  * @param Node[] nodes nodes for which to fetch and prepare responses
  * @return Response[]
  */
 public function prepareResponses($requestedProps, $nodes)
 {
     $responses = [];
     foreach ($nodes as $node) {
         $propFind = new PropFind($node->getPath(), $requestedProps);
         $this->server->getPropertiesByNode($propFind, $node);
         // copied from Sabre Server's getPropertiesForPath
         $result = $propFind->getResultForMultiStatus();
         $result['href'] = $propFind->getPath();
         $resourceType = $this->server->getResourceTypeForNode($node);
         if (in_array('{DAV:}collection', $resourceType) || in_array('{DAV:}principal', $resourceType)) {
             $result['href'] .= '/';
         }
         $responses[] = new Response(rtrim($this->server->getBaseUri(), '/') . $node->getPath(), $result, 200);
     }
     return $responses;
 }
开发者ID:ZverAleksey,项目名称:core,代码行数:24,代码来源:filesreportplugin.php


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