本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\ReadInterface::isExist方法的典型用法代码示例。如果您正苦于以下问题:PHP ReadInterface::isExist方法的具体用法?PHP ReadInterface::isExist怎么用?PHP ReadInterface::isExist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Filesystem\Directory\ReadInterface
的用法示例。
在下文中一共展示了ReadInterface::isExist方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* {@inheritdoc}
*/
public function get($filename, $scope)
{
switch ($scope) {
case 'global':
$iterator = $this->moduleReader->getConfigurationFiles($filename)->toArray();
$themeConfigFile = $this->currentTheme->getCustomization()->getCustomViewConfigPath();
if ($themeConfigFile && $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))) {
$iterator[$this->rootDirectory->getRelativePath($themeConfigFile)] = $this->rootDirectory->readFile($this->rootDirectory->getRelativePath($themeConfigFile));
} else {
$designPath = $this->resolver->resolve(RulePool::TYPE_FILE, 'etc/view.xml', $this->area, $this->currentTheme);
if (file_exists($designPath)) {
try {
$designDom = new \DOMDocument();
$designDom->load($designPath);
$iterator[$designPath] = $designDom->saveXML();
} catch (\Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Could not read config file'));
}
}
}
break;
default:
$iterator = $this->iteratorFactory->create([]);
break;
}
return $iterator;
}
示例2: read
/**
* Read Magento updater application jobs queue as a JSON string.
*
* @return string Queue file content (valid JSON string)
* @throws \RuntimeException
*/
public function read()
{
$queue = '';
if (!$this->reader->isExist($this->queueFileBasename)) {
return $queue;
}
$queueFileContent = $this->reader->readFile($this->queueFileBasename);
if ($queueFileContent) {
json_decode($queueFileContent);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \RuntimeException(sprintf('Content of "%s" must be a valid JSON.', $this->queueFileBasename));
}
$queue = $queueFileContent;
}
return $queue;
}
示例3: getViewConfig
/**
* Render view config object for current package and theme
*
* @param array $params
* @return \Magento\Framework\Config\View
*/
public function getViewConfig(array $params = [])
{
$this->assetRepo->updateDesignParams($params);
/** @var $currentTheme \Magento\Framework\View\Design\ThemeInterface */
$currentTheme = $params['themeModel'];
$key = $currentTheme->getCode();
if (isset($this->viewConfigs[$key])) {
return $this->viewConfigs[$key];
}
$configFiles = $this->moduleReader->getConfigurationFiles(basename($this->filename))->toArray();
$themeConfigFile = $currentTheme->getCustomization()->getCustomViewConfigPath();
if (empty($themeConfigFile)
|| !$this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))
) {
$themeConfigFile = $this->viewFileSystem->getFilename($this->filename, $params);
}
if ($themeConfigFile
&& $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))
) {
$configFiles[$this->rootDirectory->getRelativePath($themeConfigFile)] = $this->rootDirectory->readFile(
$this->rootDirectory->getRelativePath($themeConfigFile)
);
}
$config = $this->viewFactory->create($configFiles);
$this->viewConfigs[$key] = $config;
return $config;
}
示例4: getComposerInfo
/**
* Checks existence of composer.lock and returns its contents
*
* @return array
* @throws \Exception
*/
private function getComposerInfo()
{
if (!$this->rootDir->isExist('composer.lock')) {
throw new \Exception('Cannot read \'composer.lock\' file');
}
return json_decode($this->rootDir->readFile('composer.lock'), true);
}
示例5: getFiles
/**
* Get layout files from modules, theme with ancestors and library
*
* @param ThemeInterface $theme
* @param string $filePath
* @throws \InvalidArgumentException
* @return \Magento\Framework\View\File[]
*/
public function getFiles(ThemeInterface $theme, $filePath)
{
if (empty($filePath)) {
throw new \InvalidArgumentException('File path must be specified');
}
$files = [];
if ($this->libDirectory->isExist($filePath)) {
$filename = $this->libDirectory->getAbsolutePath($filePath);
$files[] = $this->fileFactory->create($filename);
}
$files = array_merge($files, $this->baseFiles->getFiles($theme, $filePath));
foreach ($theme->getInheritedThemes() as $currentTheme) {
$files = array_merge($files, $this->themeModularFiles->getFiles($currentTheme, $filePath));
$files = array_merge($files, $this->themeFiles->getFiles($currentTheme, $filePath));
}
return $files;
}
示例6: resolveFile
/**
* Get path of file after using fallback rules
*
* @param RuleInterface $fallbackRule
* @param string $file
* @param array $params
* @return string|bool
*/
protected function resolveFile(RuleInterface $fallbackRule, $file, array $params = [])
{
foreach ($fallbackRule->getPatternDirs($params) as $dir) {
$path = "{$dir}/{$file}";
if ($this->rootDirectory->isExist($this->rootDirectory->getRelativePath($path))) {
return $path;
}
}
return false;
}
示例7: _beforeSave
/**
* Process additional data before save config
*
* @return $this
* @throws \Magento\Framework\Model\Exception
*/
protected function _beforeSave()
{
$value = $this->getValue();
if (is_array($value) && !empty($value['delete'])) {
$this->setValue('');
$this->_certFactory->create()->loadByWebsite($this->getScopeId())->delete();
}
if (!isset($_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value'])) {
return $this;
}
$tmpPath = $this->_tmpDirectory->getRelativePath($_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value']);
if ($tmpPath && $this->_tmpDirectory->isExist($tmpPath)) {
if (!$this->_tmpDirectory->stat($tmpPath)['size']) {
throw new \Magento\Framework\Model\Exception(__('The PayPal certificate file is empty.'));
}
$this->setValue($_FILES['groups']['name'][$this->getGroupId()]['fields'][$this->getField()]['value']);
$content = $this->_encryptor->encrypt($this->_tmpDirectory->readFile($tmpPath));
$this->_certFactory->create()->loadByWebsite($this->getScopeId())->setContent($content)->save();
}
return $this;
}
示例8: getPaths
/**
* Get the list of files and directory paths from magento-base extra/map section.
*
* @return string []
* @throws \Magento\Setup\Exception
*/
public function getPaths()
{
// Locate composer.json for magento2-base module
$filesPathList = [];
$vendorDir = (require VENDOR_PATH);
$basePackageComposerFilePath = $vendorDir . '/' . self::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE;
if (!$this->reader->isExist($basePackageComposerFilePath)) {
throw new \Magento\Setup\Exception('Could not locate ' . self::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE . ' file.');
}
if (!$this->reader->isReadable($basePackageComposerFilePath)) {
throw new \Magento\Setup\Exception('Could not read ' . self::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE . ' file.');
}
// Fill array with list of files and directories from extra/map section
$composerJsonFileData = json_decode($this->reader->readFile($basePackageComposerFilePath), true);
if (!isset($composerJsonFileData[self::COMPOSER_KEY_EXTRA][self::COMPOSER_KEY_MAP])) {
return $filesPathList;
}
$extraMappings = $composerJsonFileData[self::COMPOSER_KEY_EXTRA][self::COMPOSER_KEY_MAP];
foreach ($extraMappings as $map) {
$filesPathList[] = $map[1];
}
return $filesPathList;
}
示例9: minify
/**
* Perform actual minification
*
* @return void
*/
protected function minify()
{
$isExists = $this->staticViewDir->isExist($this->path);
if (!$isExists) {
$shouldMinify = true;
} elseif ($this->strategy == self::FILE_EXISTS) {
$shouldMinify = false;
} else {
$origlFile = $this->rootDir->getRelativePath($this->originalAsset->getSourceFile());
$origMtime = $this->rootDir->stat($origlFile)['mtime'];
$minMtime = $this->staticViewDir->stat($this->path)['mtime'];
$shouldMinify = $origMtime != $minMtime;
}
if ($shouldMinify) {
$content = $this->adapter->minify($this->originalAsset->getContent());
$this->staticViewDir->writeFile($this->path, $content);
}
}
示例10: isDeployed
/**
* Check if Sample Data was deployed
*
* @return bool
*/
public function isDeployed()
{
return $this->rootDir->isExist(self::PATH);
}
示例11: isInstalled
/**
* Determines whether application is installed
*
* @return bool
*/
private function isInstalled()
{
$this->init();
return $this->configDir->isExist('local.xml');
}