本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\Write::getAbsolutePath方法的典型用法代码示例。如果您正苦于以下问题:PHP Write::getAbsolutePath方法的具体用法?PHP Write::getAbsolutePath怎么用?PHP Write::getAbsolutePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Filesystem\Directory\Write
的用法示例。
在下文中一共展示了Write::getAbsolutePath方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUpBeforeClass
public static function setUpBeforeClass()
{
/** @var \Magento\Framework\App\Filesystem $filesystem */
$filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\Filesystem');
self::$_varDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
self::$_tmpDir = self::$_varDirectory->getAbsolutePath('ConfigTest');
self::$_varDirectory->create(self::$_varDirectory->getRelativePath(self::$_tmpDir));
}
示例2: setUp
protected function setUp()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->varDirectory = $objectManager->get('Magento\\Framework\\Filesystem')->getDirectoryWrite(DirectoryList::VAR_DIR);
$generationDirectory = $this->varDirectory->getAbsolutePath('generation');
$this->_ioObject = new \Magento\Framework\Code\Generator\Io(new \Magento\Framework\Filesystem\Driver\File(), $generationDirectory);
$this->_generator = $objectManager->create('Magento\\Framework\\Code\\Generator', ['ioObject' => $this->_ioObject, 'generatedEntities' => [DIGenerator\Factory::ENTITY_TYPE => '\\Magento\\Framework\\ObjectManager\\Code\\Generator\\Factory', DIGenerator\Proxy::ENTITY_TYPE => '\\Magento\\Framework\\ObjectManager\\Code\\Generator\\Proxy', InterceptionGenerator\Interceptor::ENTITY_TYPE => '\\Magento\\Framework\\Interception\\Code\\Generator\\Interceptor']]);
$this->_generator->setObjectManager($objectManager);
}
示例3: setUp
protected function setUp()
{
$this->_includePath = get_include_path();
$this->varDirectory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\Filesystem')->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
$generationDirectory = $this->varDirectory->getAbsolutePath('generation');
(new \Magento\Framework\Autoload\IncludePath())->addIncludePath($generationDirectory);
$this->_ioObject = new \Magento\Framework\Code\Generator\Io(new \Magento\Framework\Filesystem\Driver\File(), new \Magento\Framework\Autoload\IncludePath(), $generationDirectory);
$this->_generator = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Code\\Generator', array('ioObject' => $this->_ioObject, 'generatedEntities' => array(DIGenerator\Factory::ENTITY_TYPE => '\\Magento\\Framework\\ObjectManager\\Code\\Generator\\Factory', DIGenerator\Proxy::ENTITY_TYPE => '\\Magento\\Framework\\ObjectManager\\Code\\Generator\\Proxy', InterceptionGenerator\Interceptor::ENTITY_TYPE => '\\Magento\\Framework\\Interception\\Code\\Generator\\Interceptor')));
}
示例4: getThumbnailUrl
/**
* Thumbnail URL getter
*
* @param string $filePath original file path
* @param bool $checkFile OPTIONAL is it necessary to check file availability
* @return string|false
*/
public function getThumbnailUrl($filePath, $checkFile = false)
{
$mediaRootDir = $this->_cmsWysiwygImages->getStorageRoot();
if (strpos($filePath, $mediaRootDir) === 0) {
$thumbSuffix = self::THUMBS_DIRECTORY_NAME . substr($filePath, strlen($mediaRootDir));
if (!$checkFile || $this->_directory->isExist($this->_directory->getRelativePath($mediaRootDir . '/' . $thumbSuffix))) {
$thumbSuffix = substr($mediaRootDir, strlen($this->_directory->getAbsolutePath())) . '/' . $thumbSuffix;
$randomIndex = '?rand=' . time();
return str_replace('\\', '/', $this->_cmsWysiwygImages->getBaseUrl() . $thumbSuffix) . $randomIndex;
}
}
return false;
}
示例5: collectFolders
/**
* Get all folders as options array
*
* @return array
*/
public function collectFolders()
{
$collectFiles = $this->_collectFiles;
$collectDirs = $this->_collectDirs;
$this->setCollectFiles(false)->setCollectDirs(true);
$this->_collectRecursive($this->connectDirectory->getAbsolutePath('connect'));
$result = array('/' => '/');
foreach ($this->_collectedDirs as $dir) {
$dir = substr($this->connectDirectory->getRelativePath($dir), strlen('connect/')) . '/';
$result[$dir] = $dir;
}
$this->setCollectFiles($collectFiles)->setCollectDirs($collectDirs);
return $result;
}
示例6: createPackageV1x
/**
* Create package file compatible with previous version of Magento Connect Manager
*
* @return boolean
*/
public function createPackageV1x()
{
try {
$this->writeDirectory->create('pear/');
} catch (\Magento\Framework\Filesystem\FilesystemException $e) {
$this->logger->addStreamLog(\Magento\Framework\Logger::LOGGER_EXCEPTION);
$this->logger->log($e->getMessage());
return false;
}
if (!$this->getPackageXml()) {
$this->generatePackageXml();
}
$this->getPackage()->saveV1x($this->writeDirectory->getAbsolutePath('pear/'));
return true;
}
示例7: compactValue
/**
* Export attribute value to entity model
*
* @param array|string $value
* @return $this
*/
public function compactValue($value)
{
if ($this->getIsAjaxRequest()) {
return $this;
}
$attribute = $this->getAttribute();
$original = $this->getEntity()->getData($attribute->getAttributeCode());
$toDelete = false;
if ($original) {
if (!$attribute->getIsRequired() && !empty($value['delete'])) {
$toDelete = true;
}
if (!empty($value['tmp_name'])) {
$toDelete = true;
}
}
$destinationFolder = $attribute->getEntity()->getEntityTypeCode();
// unlink entity file
if ($toDelete) {
$this->getEntity()->setData($attribute->getAttributeCode(), '');
$file = $destinationFolder . $original;
if ($this->_directory->isExist($file)) {
$this->_directory->delete($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($this->_directory->getAbsolutePath($destinationFolder), $value['name']);
$fileName = $uploader->getUploadedFileName();
$this->getEntity()->setData($attribute->getAttributeCode(), $fileName);
} catch (\Exception $e) {
$this->_logger->logException($e);
}
}
return $this;
}
示例8: _createThumbnail
/**
* Create thumbnail for image and save it to thumbnails directory
*
* @param string $source
* @return bool|string Resized filepath or false if errors were occurred
*/
public function _createThumbnail($source)
{
if (self::TYPE_IMAGE != $this->_helper->getStorageType() || !$this->mediaWriteDirectory->isFile($source) || !$this->mediaWriteDirectory->isReadable($source)) {
return false;
}
$thumbnailDir = $this->_helper->getThumbnailDirectory($source);
$thumbnailPath = $thumbnailDir . '/' . pathinfo($source, PATHINFO_BASENAME);
try {
$this->mediaWriteDirectory->isExist($thumbnailDir);
$image = $this->_imageFactory->create();
$image->open($this->mediaWriteDirectory->getAbsolutePath($source));
$image->keepAspectRatio(true);
$image->resize(self::THUMBNAIL_WIDTH, self::THUMBNAIL_HEIGHT);
$image->save($this->mediaWriteDirectory->getAbsolutePath($thumbnailPath));
} catch (\Magento\Framework\Exception\FileSystemException $e) {
$this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
return false;
}
if ($this->mediaWriteDirectory->isFile($thumbnailPath)) {
return $thumbnailPath;
}
return false;
}
示例9: getCurrentPath
/**
* Return path of the current selected directory or root directory for startup
* Try to create target directory if it doesn't exist
*
* @return string
* @throws \Magento\Framework\Model\Exception
*/
public function getCurrentPath()
{
if (!$this->_currentPath) {
$currentPath = $this->_directory->getAbsolutePath() . \Magento\Cms\Model\Wysiwyg\Config::IMAGE_DIRECTORY;
$path = $this->_getRequest()->getParam($this->getTreeNodeName());
if ($path) {
$path = $this->convertIdToPath($path);
if ($this->_directory->isDirectory($this->_directory->getRelativePath($path))) {
$currentPath = $path;
}
}
try {
$currentDir = $this->_directory->getRelativePath($currentPath);
if (!$this->_directory->isExist($currentDir)) {
$this->_directory->create($currentDir);
}
} catch (\Magento\Framework\Filesystem\FilesystemException $e) {
$message = __('The directory %1 is not writable by server.', $currentPath);
throw new \Magento\Framework\Model\Exception($message);
}
$this->_currentPath = $currentPath;
}
return $this->_currentPath;
}
示例10: _getBaseDir
/**
* Get base dir
*
* @return string
*/
protected function _getBaseDir()
{
return $this->_directory->getAbsolutePath();
}