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


PHP Filesystem::getPath方法代码示例

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


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

示例1: aroundDispatch

 /**
  * Handle dispatch exceptions
  *
  * @param \Magento\Framework\App\FrontController $subject
  * @param callable $proceed
  * @param \Magento\Framework\App\RequestInterface $request
  *
  * @return mixed
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundDispatch(\Magento\Framework\App\FrontController $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
 {
     try {
         return $proceed($request);
     } catch (\Magento\Framework\Session\Exception $e) {
         header('Location: ' . $this->_storeManager->getStore()->getBaseUrl());
         exit;
     } catch (\Magento\Store\Model\Exception $e) {
         require $this->filesystem->getPath(Filesystem::PUB_DIR) . '/errors/404.php';
         exit;
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:22,代码来源:DispatchExceptionHandler.php

示例2: scheduledBackup

 /**
  * Create Backup
  *
  * @return $this
  */
 public function scheduledBackup()
 {
     if (!$this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_ENABLED, ScopeInterface::SCOPE_STORE)) {
         return $this;
     }
     if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) {
         $this->maintenanceMode->set(true);
     }
     $type = $this->_scopeConfig->getValue(self::XML_PATH_BACKUP_TYPE, ScopeInterface::SCOPE_STORE);
     $this->_errors = array();
     try {
         $backupManager = $this->_backupFactory->create($type)->setBackupExtension($this->_backupData->getExtensionByType($type))->setTime(time())->setBackupsDir($this->_backupData->getBackupsDir());
         $this->_coreRegistry->register('backup_manager', $backupManager);
         if ($type != \Magento\Framework\Backup\Factory::TYPE_DB) {
             $backupManager->setRootDir($this->_filesystem->getPath(\Magento\Framework\App\Filesystem::ROOT_DIR))->addIgnorePaths($this->_backupData->getBackupIgnorePaths());
         }
         $backupManager->create();
         $message = $this->_backupData->getCreateSuccessMessageByType($type);
         $this->_logger->log($message);
     } catch (\Exception $e) {
         $this->_errors[] = $e->getMessage();
         $this->_errors[] = $e->getTrace();
         $this->_logger->log($e->getMessage(), \Zend_Log::ERR);
         $this->_logger->logException($e);
     }
     if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) {
         $this->maintenanceMode->set(false);
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:35,代码来源:Observer.php

示例3: getMediaBaseDir

 /**
  * Return Media base dir
  *
  * @return string
  */
 public function getMediaBaseDir()
 {
     if (null === $this->_mediaBaseDirectory) {
         $mediaDir = $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::MEDIA_DIR);
         $this->_mediaBaseDirectory = rtrim($mediaDir, '\\/');
     }
     return $this->_mediaBaseDirectory;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:Database.php

示例4: getFonts

 /**
  * Get list of available fonts.
  *
  * Return format:
  * [['arial'] => ['label' => 'Arial', 'path' => '/www/magento/fonts/arial.ttf']]
  *
  * @return array
  */
 public function getFonts()
 {
     $fontsConfig = $this->_config->getValue(\Magento\Captcha\Helper\Data::XML_PATH_CAPTCHA_FONTS, 'default');
     $fonts = array();
     if ($fontsConfig) {
         $libDir = $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::LIB_INTERNAL);
         foreach ($fontsConfig as $fontName => $fontConfig) {
             $fonts[$fontName] = array('label' => $fontConfig['label'], 'path' => $libDir . '/' . $fontConfig['path']);
         }
     }
     return $fonts;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:20,代码来源:Data.php

示例5: getWritableFullPathsForCheck

 /**
  * Retrieve writable full paths for checking
  *
  * @return array
  */
 public function getWritableFullPathsForCheck()
 {
     $data = $this->_dataStorage->get();
     $paths = array();
     $items = isset($data['filesystem_prerequisites']) && isset($data['filesystem_prerequisites']['writables']) ? $data['filesystem_prerequisites']['writables'] : array();
     foreach ($items as $nodeKey => $item) {
         $value = $item;
         $value['path'] = $this->filesystem->getPath($nodeKey);
         $paths[$nodeKey] = $value;
     }
     return $paths;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:Config.php

示例6: handleGenericReport

 /**
  * Handle for any other errors
  *
  * @param Bootstrap $bootstrap
  * @param \Exception $exception
  * @return bool
  */
 private function handleGenericReport(Bootstrap $bootstrap, \Exception $exception)
 {
     $reportData = array($exception->getMessage(), $exception->getTraceAsString());
     $params = $bootstrap->getParams();
     if (isset($params['REQUEST_URI'])) {
         $reportData['url'] = $params['REQUEST_URI'];
     }
     if (isset($params['SCRIPT_NAME'])) {
         $reportData['script_name'] = $params['SCRIPT_NAME'];
     }
     require $this->_filesystem->getPath(Filesystem::PUB_DIR) . '/errors/report.php';
     return true;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:20,代码来源:Http.php

示例7: compactValue

 /**
  * {@inheritdoc}
  *
  * @return $this|string
  */
 public function compactValue($value)
 {
     if ($this->getIsAjaxRequest()) {
         return $this;
     }
     $attribute = $this->getAttribute();
     $original = $this->_value;
     $toDelete = false;
     if ($original) {
         if (!$attribute->isRequired() && !empty($value['delete'])) {
             $toDelete = true;
         }
         if (!empty($value['tmp_name'])) {
             $toDelete = true;
         }
     }
     $path = $this->_fileSystem->getPath(\Magento\Framework\App\Filesystem::MEDIA_DIR) . '/' . $this->_entityTypeCode;
     $result = $original;
     // unlink entity file
     if ($toDelete) {
         $result = '';
         $file = $path . $original;
         $ioFile = new \Magento\Framework\Io\File();
         if ($ioFile->fileExists($file)) {
             $ioFile->rm($file);
         }
     }
     if (!empty($value['tmp_name'])) {
         try {
             $uploader = new \Magento\Framework\File\Uploader($value);
             $uploader->setFilesDispersion(true);
             $uploader->setFilenamesCaseSensitivity(false);
             $uploader->setAllowRenameFiles(true);
             $uploader->save($path, $value['name']);
             $fileName = $uploader->getUploadedFileName();
             $result = $fileName;
         } catch (\Exception $e) {
             $this->_logger->logException($e);
         }
     }
     return $result;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:47,代码来源:File.php

示例8: install

 /**
  * Generate installation data and record them into local.xml using local.xml.template
  *
  * @return void
  */
 public function install()
 {
     $data = $this->getConfigData();
     $defaults = array('root_dir' => $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::ROOT_DIR), 'app_dir' => $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::APP_DIR), 'var_dir' => $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::VAR_DIR), 'base_url' => $this->_request->getDistroBaseUrl());
     foreach ($defaults as $index => $value) {
         if (!isset($data[$index])) {
             $data[$index] = $value;
         }
     }
     if (isset($data['unsecure_base_url'])) {
         $data['unsecure_base_url'] .= substr($data['unsecure_base_url'], -1) != '/' ? '/' : '';
         if (strpos($data['unsecure_base_url'], 'http') !== 0) {
             $data['unsecure_base_url'] = 'http://' . $data['unsecure_base_url'];
         }
         if (!$this->_getInstaller()->getDataModel()->getSkipBaseUrlValidation()) {
             $this->_checkUrl($data['unsecure_base_url']);
         }
     }
     if (isset($data['secure_base_url'])) {
         $data['secure_base_url'] .= substr($data['secure_base_url'], -1) != '/' ? '/' : '';
         if (strpos($data['secure_base_url'], 'http') !== 0) {
             $data['secure_base_url'] = 'https://' . $data['secure_base_url'];
         }
         if (!empty($data['use_secure']) && !$this->_getInstaller()->getDataModel()->getSkipUrlValidation()) {
             $this->_checkUrl($data['secure_base_url']);
         }
     }
     $data['date'] = self::TMP_INSTALL_DATE_VALUE;
     $data['key'] = self::TMP_ENCRYPT_KEY_VALUE;
     $data['var_dir'] = $data['root_dir'] . '/var';
     $data['use_script_name'] = isset($data['use_script_name']) ? 'true' : 'false';
     $this->_getInstaller()->getDataModel()->setConfigData($data);
     $contents = $this->_configDirectory->readFile('local.xml.template');
     foreach ($data as $index => $value) {
         $contents = str_replace('{{' . $index . '}}', '<![CDATA[' . $value . ']]>', $contents);
     }
     $this->_configDirectory->writeFile($this->_localConfigFile, $contents);
     $this->_configDirectory->changePermissions($this->_localConfigFile, 0777);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:44,代码来源:Config.php

示例9: getScriptConfig

 /**
  * Return current media directory, allowed resources for get.php script, etc.
  *
  * @return array
  */
 public function getScriptConfig()
 {
     $config = array();
     $config['media_directory'] = $this->filesystem->getPath(Filesystem::MEDIA_DIR);
     $allowedResources = $this->_coreConfig->getValue(self::XML_PATH_MEDIA_RESOURCE_WHITELIST, 'default');
     foreach ($allowedResources as $allowedResource) {
         $config['allowed_resources'][] = $allowedResource;
     }
     $config['update_time'] = $this->_scopeConfig->getValue(self::XML_PATH_MEDIA_UPDATE_TIME, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     return $config;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:Storage.php

示例10: __construct

 /**
  * @param \Magento\Framework\App\Filesystem $appFilesystem
  */
 public function __construct(Filesystem $appFilesystem)
 {
     $this->_schema = $appFilesystem->getPath(Filesystem::LIB_INTERNAL) . '/Magento/Framework/View/PageLayout/etc/layouts.xsd';
 }
开发者ID:aiesh,项目名称:magento2,代码行数:7,代码来源:SchemaLocator.php

示例11: _createDbBackupInstance

 /**
  * Create Db Instance
  *
  * @return \Magento\Framework\Backup\BackupInterface
  */
 protected function _createDbBackupInstance()
 {
     return $this->_backupFactory->create(\Magento\Framework\Backup\Factory::TYPE_DB)->setBackupExtension('gz')->setTime($this->getTime())->setBackupsDir($this->_filesystem->getPath(\Magento\Framework\App\Filesystem::VAR_DIR))->setResourceModel($this->getResourceModel());
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:9,代码来源:Snapshot.php

示例12: testGetPath

 /**
  * Test getPath returns right path
  */
 public function testGetPath()
 {
     $this->assertContains('design', $this->filesystem->getPath(\Magento\Framework\App\Filesystem::THEMES_DIR));
 }
开发者ID:aiesh,项目名称:magento2,代码行数:7,代码来源:FilesystemTest.php

示例13: getRollbackIgnorePaths

 /**
  * Get paths that should be ignored when rolling back system snapshots
  *
  * @return string[]
  */
 public function getRollbackIgnorePaths()
 {
     return array('.svn', '.git', $this->_filesystem->getPath(MaintenanceMode::FLAG_DIR) . '/' . MaintenanceMode::FLAG_FILENAME, $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::SESSION_DIR), $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::LOG_DIR), $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::VAR_DIR) . '/locks', $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::VAR_DIR) . '/report', $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::ROOT_DIR) . '/errors', $this->_filesystem->getPath(\Magento\Framework\App\Filesystem::ROOT_DIR) . '/index.php');
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:9,代码来源:Data.php

示例14: testGetUri

 /**
  * Test getUri returns right uri
  */
 public function testGetUri()
 {
     $this->assertContains('media', $this->filesystem->getPath(\Magento\Framework\App\Filesystem::MEDIA_DIR));
 }
开发者ID:aiesh,项目名称:magento2,代码行数:7,代码来源:FilesystemTest.php

示例15: __construct

 /**
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Framework\Stdlib\String $stringHelper
  * @param \Magento\Framework\App\RequestInterface $request
  * @param \Magento\Framework\App\State $appState
  * @param \Magento\Framework\App\Filesystem $filesystem
  * @param string $scopeType
  * @param string $saveMethod
  * @param null|string $savePath
  * @param null|string $cacheLimiter
  * @param string $lifetimePath
  */
 public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\String $stringHelper, \Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\State $appState, \Magento\Framework\App\Filesystem $filesystem, $scopeType, $saveMethod = \Magento\Framework\Session\SaveHandlerInterface::DEFAULT_HANDLER, $savePath = null, $cacheLimiter = null, $lifetimePath = self::XML_PATH_COOKIE_LIFETIME)
 {
     $this->_scopeConfig = $scopeConfig;
     $this->_stringHelper = $stringHelper;
     $this->_httpRequest = $request;
     $this->_appState = $appState;
     $this->_filesystem = $filesystem;
     $this->_scopeType = $scopeType;
     $this->setSaveHandler($saveMethod === 'db' ? 'user' : $saveMethod);
     if (!$this->_appState->isInstalled() || !$savePath) {
         $savePath = $this->_filesystem->getPath('session');
     }
     $this->setSavePath($savePath);
     if ($cacheLimiter) {
         $this->setOption('session.cache_limiter', $cacheLimiter);
     }
     $lifetime = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_LIFETIME, $this->_scopeType);
     $lifetime = is_numeric($lifetime) ? $lifetime : self::COOKIE_LIFETIME_DEFAULT;
     $this->setCookieLifetime($lifetime);
     $path = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_PATH, $this->_scopeType);
     if (empty($path)) {
         $path = $this->_httpRequest->getBasePath();
     }
     $this->setCookiePath($path);
     $domain = $this->_scopeConfig->getValue(self::XML_PATH_COOKIE_DOMAIN, $this->_scopeType);
     $domain = empty($domain) ? $this->_httpRequest->getHttpHost() : $domain;
     $this->setCookieDomain((string) $domain);
     $this->setCookieHttpOnly($this->_scopeConfig->getValue(self::XML_PATH_COOKIE_HTTPONLY, $this->_scopeType));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:41,代码来源:Config.php


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