파일 시스템에서 파일을 읽어야하는 Magento 2 확장 프로그램을 작업 중입니다.
ECGM2 표준을 사용하여 스니퍼는 PHP를 실행할 때, 내가 같은 기능을 사용하고 있다는 사실에 대해 불평 basename하거나 dirname.
dirname () 함수 사용은 금지되어 있습니다
또는
basename () 함수 사용은 금지되어 있습니다
동일한 효과를 얻으려면 래퍼 대신 어떤 래퍼를 사용해야합니까?
[편집]
여기 몇 가지 코드가 있지만 질문과 관련이 없습니다.
클래스를 확장하는 컬렉션 클래스가 있으며이 \Magento\Framework\Data\Collection\Filesystem컬렉션을 그리드 (ui 구성 요소)로 나열하고 그리드의 작업 중 하나는 다운로드 작업입니다.
이를 위해 파일의 실제 이름을 가져 와서 다운로드 작업으로 보낼 수 있습니다.
// here $file is dynamic and it can be
// folder/filename.xml or folder/subfolder/file.tar.gz
//so there is no strict number of folders and subfolders.
$file = $downloader->getRelativePath($packageName);
$relativeFile = UmcFilesystem::VAR_DIR_NAME . '/' .$file;
$absoluteFile = $rootDir->getAbsolutePath($relativeFile);
if ($rootDir->isFile($relativeFile) && $rootDir->isReadable($relativeFile)){
//I don't want to use `explode` just for the sake of avoiding basename
$fileName = basename($absoluteFile);
$this->fileFactory->create(
$fileName,
null,
DirectoryList::VAR_DIR,
'application/octet-stream',
$rootDir->stat($relativeFile)['size']
);
$resultRaw = $this->resultRawFactory->create();
$resultRaw->setContents($rootDir->readFile($relativeFile));
return $resultRaw;
} else {
...
}
basename. 질문을주의 깊게 읽으십시오.