當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Server::getResourceTypeForNode方法代碼示例

本文整理匯總了PHP中Sabre\DAV\Server::getResourceTypeForNode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Server::getResourceTypeForNode方法的具體用法?PHP Server::getResourceTypeForNode怎麽用?PHP Server::getResourceTypeForNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sabre\DAV\Server的用法示例。


在下文中一共展示了Server::getResourceTypeForNode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: propFind

    /**
     * This method is called when properties are retrieved.
     *
     * Here we add all the default properties.
     *
     * @param PropFind $propFind
     * @param INode $node
     * @return void
     */
    function propFind(PropFind $propFind, INode $node) {

        $propFind->handle('{DAV:}getlastmodified', function() use ($node) {
            $lm = $node->getLastModified();
            if ($lm) {
                return new Xml\Property\GetLastModified($lm);
            }
        });

        if ($node instanceof IFile) {
            $propFind->handle('{DAV:}getcontentlength', [$node, 'getSize']);
            $propFind->handle('{DAV:}getetag', [$node, 'getETag']);
            $propFind->handle('{DAV:}getcontenttype', [$node, 'getContentType']);
        }

        if ($node instanceof IQuota) {
            $quotaInfo = null;
            $propFind->handle('{DAV:}quota-used-bytes', function() use (&$quotaInfo, $node) {
                $quotaInfo = $node->getQuotaInfo();
                return $quotaInfo[0];
            });
            $propFind->handle('{DAV:}quota-available-bytes', function() use (&$quotaInfo, $node) {
                if (!$quotaInfo) {
                    $quotaInfo = $node->getQuotaInfo();
                }
                return $quotaInfo[1];
            });
        }

        $propFind->handle('{DAV:}supported-report-set', function() use ($propFind) {
            $reports = [];
            foreach ($this->server->getPlugins() as $plugin) {
                $reports = array_merge($reports, $plugin->getSupportedReportSet($propFind->getPath()));
            }
            return new Xml\Property\SupportedReportSet($reports);
        });
        $propFind->handle('{DAV:}resourcetype', function() use ($node) {
            return new Xml\Property\ResourceType($this->server->getResourceTypeForNode($node));
        });
        $propFind->handle('{DAV:}supported-method-set', function() use ($propFind) {
            return new Xml\Property\SupportedMethodSet(
                $this->server->getAllowedMethods($propFind->getPath())
            );
        });

    }
開發者ID:nikosv,項目名稱:openeclass,代碼行數:55,代碼來源:CorePlugin.php


注:本文中的Sabre\DAV\Server::getResourceTypeForNode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。