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


PHP Read::isReadable方法代碼示例

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


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

示例1: launch

 /**
  * Run application
  *
  * @return \Magento\Framework\App\ResponseInterface
  * @throws \LogicException
  */
 public function launch()
 {
     if (!$this->_mediaDirectory) {
         $config = $this->_objectManager->create('Magento\\Core\\Model\\File\\Storage\\Config', ['cacheFile' => $this->_configCacheFile]);
         $config->save();
         $this->_mediaDirectory = str_replace($this->_workingDirectory, '', $config->getMediaDirectory());
         $allowedResources = $config->getAllowedResources();
         $this->_relativeFileName = str_replace($this->_mediaDirectory . '/', '', $this->_request->getPathInfo());
         $isAllowed = $this->_isAllowed;
         if (!$isAllowed($this->_relativeFileName, $allowedResources)) {
             throw new \LogicException('The specified path is not allowed.');
         }
     }
     if (0 !== stripos($this->_request->getPathInfo(), $this->_mediaDirectory . '/')) {
         throw new \LogicException('The specified path is not within media directory.');
     }
     $sync = $this->_objectManager->get('Magento\\Core\\Model\\File\\Storage\\Synchronization');
     $sync->synchronize($this->_relativeFileName, $this->_request->getFilePath());
     if ($this->directory->isReadable($this->directory->getRelativePath($this->_request->getFilePath()))) {
         $this->_response->setFilePath($this->_request->getFilePath());
     } else {
         $this->_response->setHttpResponseCode(404);
     }
     return $this->_response;
 }
開發者ID:,項目名稱:,代碼行數:31,代碼來源:

示例2: loadLocalPackage

 /**
  * Load local package data array
  *
  * @param string $packageName without extension
  * @return array|boolean
  */
 public function loadLocalPackage($packageName)
 {
     $xmlFile = sprintf('connect/%.xml', $packageName);
     $serFile = sprintf('connect/%.ser', $packageName);
     if ($this->readDirectory->isFile($xmlFile) && $this->readDirectory->isReadable($xmlFile)) {
         $xml = simplexml_load_string($this->readDirectory->readFile($xmlFile));
         $data = $this->_xmlConverter->xmlToAssoc($xml);
         if (!empty($data)) {
             return $data;
         }
     }
     if ($this->readDirectory->isFile($serFile) && $this->readDirectory->isReadable($xmlFile)) {
         $data = unserialize($this->readDirectory->readFile($serFile));
         if (!empty($data)) {
             return $data;
         }
     }
     return false;
 }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:25,代碼來源:Data.php

示例3: launch

 /**
  * Run application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     try {
         if (!$this->_applicationState->isInstalled()) {
             $this->_response->setHttpResponseCode(404);
             return $this->_response;
         }
         if (!$this->_mediaDirectory) {
             $config = $this->_objectManager->create('Magento\\Core\\Model\\File\\Storage\\Config', array('cacheFile' => $this->_configCacheFile));
             $config->save();
             $this->_mediaDirectory = str_replace($this->_workingDirectory, '', $config->getMediaDirectory());
             $allowedResources = $config->getAllowedResources();
             $this->_relativeFileName = str_replace($this->_mediaDirectory . '/', '', $this->_request->getPathInfo());
             $isAllowed = $this->_isAllowed;
             if (!$isAllowed($this->_relativeFileName, $allowedResources)) {
                 $this->_response->setHttpResponseCode(404);
                 return $this->_response;
             }
         }
         if (0 !== stripos($this->_request->getPathInfo(), $this->_mediaDirectory . '/')) {
             $this->_response->setHttpResponseCode(404);
             return $this->_response;
         }
         $sync = $this->_objectManager->get('Magento\\Core\\Model\\File\\Storage\\Synchronization');
         $sync->synchronize($this->_relativeFileName, $this->_request->getFilePath());
         if ($this->directory->isReadable($this->directory->getRelativePath($this->_request->getFilePath()))) {
             $this->_response->setFilePath($this->_request->getFilePath());
         } else {
             $this->_response->setHttpResponseCode(404);
         }
         return $this->_response;
     } catch (\Exception $e) {
         $this->_response->setHttpResponseCode(404);
         return $this->_response;
     }
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:41,代碼來源:Media.php


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