本文整理汇总了PHP中Magento\Framework\App\Filesystem\DirectoryList::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP DirectoryList::getPath方法的具体用法?PHP DirectoryList::getPath怎么用?PHP DirectoryList::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Filesystem\DirectoryList
的用法示例。
在下文中一共展示了DirectoryList::getPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove
/**
* Run 'composer remove'
*
* @param array $packages
* @return void
*/
public function remove(array $packages)
{
$this->composerApp->resetComposer();
$this->composerApp->setAutoExit(false);
$vendor = (include $this->directoryList->getPath(DirectoryList::CONFIG) . '/vendor_path.php');
$this->composerApp->run(new ArrayInput(['command' => 'remove', 'packages' => $packages, '--working-dir' => $this->directoryList->getRoot() . '/' . $vendor . '/..']));
}
示例2: create
/**
* Create \Composer\Composer
*
* @return \Composer\Composer
* @throws \Exception
*/
public function create()
{
if (!getenv('COMPOSER_HOME')) {
putenv('COMPOSER_HOME=' . $this->directoryList->getPath(DirectoryList::COMPOSER_HOME));
}
return \Composer\Factory::create(new BufferIO(), $this->composerJsonFinder->findComposerJson());
}
示例3: load
/**
* Loads the configuration file
*
* @param string $fileKey
* @return array
* @throws \Exception
*/
public function load($fileKey = null)
{
$path = $this->dirList->getPath(DirectoryList::CONFIG);
if ($fileKey) {
$result = @(include $path . '/' . $this->configFilePool->getPath($fileKey));
} else {
$configFiles = $this->configFilePool->getPaths();
$result = [];
foreach (array_keys($configFiles) as $fileKey) {
$configFile = $path . '/' . $this->configFilePool->getPath($fileKey);
$fileData = @(include $configFile);
if (!empty($fileData)) {
$intersection = array_intersect_key($result, $fileData);
if (!empty($intersection)) {
$displayList = '';
foreach (array_keys($intersection) as $key) {
$displayList .= $key . PHP_EOL;
}
throw new \Exception("Key collision! The following keys occur in multiple config files:" . PHP_EOL . $displayList);
}
$result = array_merge($result, $fileData);
}
}
}
return $result ?: [];
}
示例4: load
/**
* Loads the configuration file
*
* @param string $fileKey
* @return array
* @throws \Exception
*/
public function load($fileKey = null)
{
$path = $this->dirList->getPath(DirectoryList::CONFIG);
$fileDriver = $this->driverPool->getDriver(DriverPool::FILE);
$result = [];
if ($fileKey) {
$filePath = $path . '/' . $this->configFilePool->getPath($fileKey);
if ($fileDriver->isExists($filePath)) {
$result = (include $filePath);
}
} else {
$configFiles = $this->configFilePool->getPaths();
$allFilesData = [];
$result = [];
foreach (array_keys($configFiles) as $fileKey) {
$configFile = $path . '/' . $this->configFilePool->getPath($fileKey);
if ($fileDriver->isExists($configFile)) {
$fileData = (include $configFile);
} else {
continue;
}
$allFilesData[$configFile] = $fileData;
if (!empty($fileData)) {
$intersection = array_intersect_key($result, $fileData);
if (!empty($intersection)) {
$displayMessage = $this->findFilesWithKeys(array_keys($intersection), $allFilesData);
throw new \Exception("Key collision! The following keys occur in multiple config files:" . PHP_EOL . $displayMessage);
}
$result = array_merge($result, $fileData);
}
}
}
return $result ?: [];
}
示例5: updateTranslationFileContent
/**
* @param string $content
* @return void
*/
public function updateTranslationFileContent($content)
{
$translationDir = $this->directoryList->getPath(DirectoryList::STATIC_VIEW) . \DIRECTORY_SEPARATOR . $this->assetRepo->getStaticViewFileContext()->getPath();
if (!$this->driverFile->isExists($this->getTranslationFileFullPath())) {
$this->driverFile->createDirectory($translationDir, \Magento\Framework\Filesystem\Driver\File::WRITEABLE_DIRECTORY_MODE);
}
$this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content);
}
示例6: updateTranslationFileContent
/**
* @param string $content
* @return void
*/
public function updateTranslationFileContent($content)
{
$translationDir = $this->directoryList->getPath(DirectoryList::STATIC_VIEW) . \DIRECTORY_SEPARATOR . $this->assetRepo->getStaticViewFileContext()->getPath();
if (!$this->driverFile->isExists($this->getTranslationFileFullPath())) {
$this->driverFile->createDirectory($translationDir);
}
$this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content);
}
示例7: findComposerJson
/**
* Find absolute path to root Composer json file
*
* @return string
* @throws \Exception
*/
public function findComposerJson()
{
$composerJson = $this->directoryList->getPath(DirectoryList::ROOT) . '/composer.json';
$composerJson = realpath($composerJson);
if ($composerJson === false) {
throw new \Exception('Composer file not found');
}
return $composerJson;
}
示例8: getApplicationNonWritableDirectories
/**
* Retrieve list of recommended non-writable directories for application
*
* @return array
*/
public function getApplicationNonWritableDirectories()
{
if (!$this->applicationNonWritableDirectories) {
$data = [DirectoryList::CONFIG];
foreach ($data as $code) {
$this->applicationNonWritableDirectories[$code] = $this->directoryList->getPath($code);
}
}
return array_values($this->applicationNonWritableDirectories);
}
示例9: testDirectoriesCustomization
public function testDirectoriesCustomization()
{
$config = [DirectoryList::APP => [DirectoryList::PATH => 'foo', DirectoryList::URL_PATH => 'bar']];
$object = new DirectoryList('/root/dir', $config);
$this->assertFileExists($object->getPath(DirectoryList::SYS_TMP));
$this->assertEquals('/root/dir/foo', $object->getPath(DirectoryList::APP));
$this->assertEquals('bar', $object->getUrlPath(DirectoryList::APP));
$this->setExpectedException('\\Magento\\Framework\\Filesystem\\FilesystemException', "Unknown directory type: 'unknown'");
$object->getPath('unknown');
}
示例10: load
/**
* Loads the configuration file
*
* @param string $configFile
* @return array
*/
public function load($configFile = null)
{
if ($configFile) {
$file = $this->dirList->getPath(DirectoryList::CONFIG) . '/' . $configFile;
} else {
$file = $this->dirList->getPath(DirectoryList::CONFIG) . '/' . $this->file;
}
$result = @(include $file);
return $result ?: [];
}
示例11: findComposerJson
/**
* Find absolute path to root Composer json file
*
* @return string
* @throws \Exception
*/
public function findComposerJson()
{
// composer.json is in same directory as vendor
$vendorPath = $this->directoryList->getPath(DirectoryList::CONFIG) . '/vendor_path.php';
$vendorDir = (require "{$vendorPath}");
$composerJson = $this->directoryList->getPath(DirectoryList::ROOT) . "/{$vendorDir}/../composer.json";
$composerJson = realpath($composerJson);
if ($composerJson === false) {
throw new \Exception('Composer file not found');
}
return $composerJson;
}
示例12: populateMappings
/**
* @param AutoloaderInterface $autoloader
* @param DirectoryList $dirList
* @return void
*/
public static function populateMappings(AutoloaderInterface $autoloader, DirectoryList $dirList)
{
$generationDir = $dirList->getPath(DirectoryList::GENERATION);
$frameworkDir = $dirList->getPath(DirectoryList::LIB_INTERNAL);
$autoloader->addPsr4('Magento\\', [$generationDir . '/Magento/'], true);
$autoloader->addPsr0('Cm_', $frameworkDir, true);
$autoloader->addPsr0('Credis_', $frameworkDir, true);
/** Required for Zend functionality */
FileResolver::addIncludePath($frameworkDir);
/** Required for code generation to occur */
FileResolver::addIncludePath($generationDir);
/** Required to autoload custom classes */
$autoloader->addPsr0('', [$generationDir]);
}
示例13: add
public function add($contentFile, $cssFile)
{
$styleContent = preg_replace('/^\\/\\*[\\s\\S]+\\*\\//', '', file_get_contents($contentFile));
if (empty($styleContent)) {
return;
}
$mediaDir = $this->directoryList->getPath(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
file_put_contents("{$mediaDir}/{$cssFile}", $styleContent, FILE_APPEND);
$linkText = sprintf('<link rel="stylesheet" type="text/css" media="all" href="{{MEDIA_URL}}%s" />', $cssFile);
$miscScriptsNode = 'design/head/includes';
$miscScripts = $this->scopeConfig->getValue($miscScriptsNode);
if (!$miscScripts || strpos($miscScripts, $linkText) === false) {
$this->configWriter->save($miscScriptsNode, $miscScripts . $linkText);
$this->configCacheType->clean();
}
}
示例14: __construct
public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Module\ModuleList $moduleList, \Magento\Framework\App\Config\MutableScopeConfigInterface $scopeConfig, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\Session\SessionManagerInterface $session, \Wyomind\Core\Helper\Data $coreHelper, \Magento\Framework\Filesystem\Directory\ReadFactory $directoryRead, \Magento\Framework\Filesystem\File\ReadFactory $fileRead, \Magento\Framework\App\Filesystem\DirectoryList $directoryList, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [])
{
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
$this->_magentoVersion = $coreHelper->getMagentoVersion();
$this->_moduleList = $moduleList;
$this->_scopeConfig = $scopeConfig;
$this->_urlBuilder = $urlBuilder;
$this->_cacheManager = $context->getCacheManager();
$this->_session = $session;
$this->_coreHelper = $coreHelper;
$root = $directoryList->getPath(\Magento\Framework\App\Filesystem\DirectoryList::ROOT);
if (file_exists($root . "/vendor/wyomind/")) {
$this->_directoryRead = $directoryRead->create($root . "/vendor/wyomind/");
} else {
$this->_directoryRead = $directoryRead->create($root . "/app/code/Wyomind/");
}
$this->_httpRead = $fileRead;
$this->_directoryList = $directoryList;
$this->_version = $this->_moduleList->getOne("Wyomind_Core")['setup_version'];
$this->_refreshCache = false;
$this->getValues();
foreach ($this->_values as $ext) {
$this->checkActivation($ext);
}
if ($this->_refreshCache) {
$this->_cacheManager->clean(['config']);
}
}
示例15: addHeadInclude
/**
* Add Link to Head
*
* @return void
*/
protected function addHeadInclude()
{
$styleContent = '';
foreach ($this->moduleList->getNames() as $moduleName) {
$fileName = substr($moduleName, strpos($moduleName, "_") + 1) . '/styles.css';
$fileName = $this->fixtureHelper->getPath($fileName);
if (!$fileName) {
continue;
}
$style = file_get_contents($fileName);
$styleContent .= preg_replace('/^\\/\\*[\\s\\S]+\\*\\//', '', $style);
}
if (empty($styleContent)) {
return;
}
$mediaDir = $this->directoryList->getPath(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
file_put_contents("{$mediaDir}/styles.css", $styleContent);
$linkTemplate = '<link rel="stylesheet" type="text/css" media="all" href="%sstyles.css" />';
$baseUrl = $this->baseUrl->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]);
$linkText = sprintf($linkTemplate, $baseUrl);
$miscScriptsNode = 'design/head/includes';
$miscScripts = $this->scopeConfig->getValue($miscScriptsNode);
if (!$miscScripts || strpos($miscScripts, $linkText) === false) {
$this->configWriter->save($miscScriptsNode, $miscScripts . $linkText);
$this->configCacheType->clean();
}
}