本文整理汇总了PHP中SplFileInfo::getPathname方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileInfo::getPathname方法的具体用法?PHP SplFileInfo::getPathname怎么用?PHP SplFileInfo::getPathname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplFileInfo
的用法示例。
在下文中一共展示了SplFileInfo::getPathname方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preUpload
/**
* @ORM\PreFlush()
*/
public function preUpload()
{
if ($this->file) {
if ($this->file instanceof FileUpload) {
$basename = $this->file->getSanitizedName();
$basename = $this->suggestName($this->getFilePath(), $basename);
$this->setName($basename);
} else {
$basename = trim(Strings::webalize($this->file->getBasename(), '.', FALSE), '.-');
$basename = $this->suggestName(dirname($this->file->getPathname()), $basename);
$this->setName($basename);
}
if ($this->_oldPath && $this->_oldPath !== $this->path) {
@unlink($this->getFilePathBy($this->_oldProtected, $this->_oldPath));
}
if ($this->file instanceof FileUpload) {
$this->file->move($this->getFilePath());
} else {
copy($this->file->getPathname(), $this->getFilePath());
}
return $this->file = NULL;
}
if (($this->_oldPath || $this->_oldProtected !== NULL) && ($this->_oldPath != $this->path || $this->_oldProtected != $this->protected)) {
$oldFilePath = $this->getFilePathBy($this->_oldProtected !== NULL ? $this->_oldProtected : $this->protected, $this->_oldPath ?: $this->path);
if (file_exists($oldFilePath)) {
rename($oldFilePath, $this->getFilePath());
}
}
}
示例2: __destruct
public function __destruct()
{
if ($this->unlinkOnDestroy) {
@unlink($this->file->getPathname());
@rmdir(dirname($this->file->getPathname()));
}
}
示例3: loadManifest
/**
* {@inheritdoc}
*/
public function loadManifest(\SplFileInfo $manifestFile, $build, $development = false)
{
$manifest = json_decode(file_get_contents($manifestFile->getPathname()), true);
$pathMapper = function ($path) use($build, $development) {
return $this->pathMapper->mapPath($path, $build, $development);
};
$mapArray = function (array $u) use($pathMapper) {
$u['path'] = $pathMapper($u['path']);
return $u;
};
$manifest['js'] = array_map($mapArray, $manifest['js']);
$manifest['css'] = array_map($mapArray, $manifest['css']);
if (isset($manifest['resources'])) {
$manifest['resources'] = array_map($pathMapper, $manifest['resources']);
}
if ($development && isset($manifest['paths'])) {
$manifest['paths'] = array_map($pathMapper, $manifest['paths']);
}
if ($development && isset($manifest['loadOrder'])) {
$manifest['loadOrder'] = array_map($mapArray, $manifest['loadOrder']);
}
foreach (clone $this->manifestMutators as $manifestMutator) {
$manifest = $manifestMutator($manifest, $build, $development);
}
return new Manifest($manifestFile->getPathname(), $manifest);
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$configHelper = $this->getHelper('configuration');
/* @var $configHelper GlobalConfigurationHelper */
$questionHelper = $this->getHelper('question');
/* @var $questionHelper QuestionHelper */
$sshConfig = new \SplFileInfo($configHelper->getConfiguration()->getSshDirectory() . '/config');
if (!$sshConfig->isFile()) {
throw new NotAFileException($sshConfig);
}
if (!$sshConfig->isReadable()) {
throw new UnreadableFileException($sshConfig);
}
if (!$sshConfig->isWritable()) {
throw new UnwritableFileException($sshConfig);
}
$sshConfigLines = file($sshConfig->getPathname());
$repoName = $input->getArgument('repository');
$repositoryConfig = $configHelper->getConfiguration()->getRepositoryConfiguration($repoName);
if (!$questionHelper->ask($input, $output, new ConfirmationQuestion(sprintf('Are you sure you want to remove the ssh key for "%s"? This action is irreversible.', $repoName)))) {
return 1;
}
$sshKeyFile = $repositoryConfig->getIdentityFile();
$this->unlinkFile($output, $sshKeyFile);
$this->unlinkFile($output, $sshKeyFile . '.pub');
if (Util::removeSshAliasLines($sshConfigLines, $repositoryConfig)) {
$output->writeln(sprintf('Removed section <info>Host %s</info> from <info>%s</info>', $repositoryConfig->getSshAlias(), $sshConfig->getPathname()), OutputInterface::VERBOSITY_VERBOSE);
}
$output->writeln(sprintf('Removed repository <info>%s</info>', $repoName));
$configHelper->getConfiguration()->removeRepositoryConfiguration($repoName);
FsUtil::file_put_contents($sshConfig->getPathname(), implode('', $sshConfigLines));
$configHelper->getConfiguration()->write();
return 0;
}
示例5: testInitializeFromEmptySchema
public function testInitializeFromEmptySchema()
{
$pdo = $this->aNewInitializedSchema();
$sqlDirectory = new \SplFileInfo(__DIR__ . "/../testsets/nummericsorting");
$files = call_user_func(new MigrateDryRun($pdo, $sqlDirectory));
$this->assertEquals([new SqlFile(new \SplFileInfo($sqlDirectory->getPathname() . "/v3_test.sql")), new SqlFile(new \SplFileInfo($sqlDirectory->getPathname() . "/v10_test.sql"))], $files);
}
示例6: generateSourceCode
protected function generateSourceCode(ParsedType $type, SourceBuffer $buffer, \SplFileInfo $file)
{
$extends = array_map(function ($t) {
return '\\' . ltrim($t, '\\');
}, $type->getExtends());
$extends = empty($extends) ? '' : implode(', ', $extends);
$implements = ['\\' . MergedSourceInterface::class];
// Double inclusion safeguard:
if ($type->isClass()) {
$safe1 = sprintf(' if(!class_exists(%s, false)) { ', var_export($type->getName(), true));
$safe2 = ' } ';
} elseif ($type->isInterface()) {
$safe1 = sprintf(' if(!interface_exists(%s, false)) { ', var_export($type->getName(), true));
$safe2 = ' } ';
} else {
$safe1 = sprintf(' if(!trait_exists(%s, false)) { ', var_export($type->getName(), true));
$safe2 = ' } ';
}
$generator = new SourceGenerator($buffer);
$generator->populateTypeMarker($type, ParsedType::MARKER_INTRODUCED_INTERFACES, implode(', ', $implements));
$generator->populateTypeMarker($type, ParsedType::MARKER_INTRODUCED_NAME, $type->getLocalName());
$generator->populateTypeMarker($type, ParsedType::MARKER_INTRODUCED_SUPERCLASS, $extends);
$generator->populateTypeMarker($type, ParsedType::MARKER_INTRODUCED_PREPENDED_CODE, $safe1);
$generator->populateTypeMarker($type, ParsedType::MARKER_INTRODUCED_EXTERNAL_CODE, $safe2);
$code = trim($generator->generateCode($file->getPathname(), dirname($file->getPathname())));
$code = preg_replace("'^<\\?(?:php)?'i", '', $code) . "\n";
return $code;
}
示例7: createImage
/**
* Creates a new image on the path which is set
*
* @return SplFileInfo
*/
public function createImage()
{
if (!$this->imageoutput($this->outputPath->getPathname(), strtolower($this->originalPath->getExtension()))) {
throw new ImageResourceException("Could not create image on " . $this->outputPath);
}
return new \SplFileInfo($this->outputPath);
}
示例8: register
public function register($fileinfo)
{
//parse module
if (!$fileinfo instanceof \SplFileInfo) {
$fileinfo = new \SplFileInfo($fileinfo);
}
echo sprintf("scan module %s in folder %s\n", $fileinfo->getFilename(), $fileinfo->getPathname());
$info_filename = $fileinfo->getPathname() . DIRECTORY_SEPARATOR . 'module.info';
$module_info = parse_ini_file($info_filename);
if (!isset($module_info['c_name'])) {
$module_info['c_name'] = $fileinfo->getFilename();
}
$dbal = DBAL::insert(\ORC\APP\Module::TABLENAME_MODULE);
$dbal->set('name', $module_info['name']);
$dbal->set('c_name', $module_info['c_name']);
$dbal->set('description', empty($module_info['description']) ? '' : $module_info['description']);
$dbal->set('dependence', empty($module_info['dependence']) ? '' : implode(',', $module_info['dependence']));
//$dbal->set('permissions', empty($module_info['permissions']) ? '' : implode(',', $module_info['permissions']));
$dbal->setDuplicate(array('name', 'description', 'dependence'));
$dbal->execute();
echo "\tdb done.\n";
if (!empty($module_info['permissions'])) {
$dbal = DBAL::insert(\ORC\APP\Module::TABLENAME_PERMS);
foreach ($module_info['permissions'] as $perm) {
$dbal->set('perm', $perm);
$dbal->setDuplicate('perm');
$dbal->execute();
}
echo "\tpermission done.\n";
}
//check actions
$folder = $fileinfo->getPathname() . DIRECTORY_SEPARATOR . 'actions';
$this->scanActions($module_info['c_name'], $folder);
}
示例9: scan_view
/**
* Scans an individual view file, adding it's version number (if found) to the
* $this->views array.
*
* @param SplFileInfo $file
*/
protected function scan_view(SplFileInfo $file)
{
if (!$file->isFile() || !$file->isReadable()) {
return;
}
$version = $this->get_template_version($file->getPathname());
$this->originals[$this->short_name($file->getPathname())] = $version;
}
示例10: upload
/**
* upload
*
* @param \JInput $input
*/
public static function upload(\JInput $input)
{
try {
$editorPlugin = \JPluginHelper::getPlugin('editors', 'akmarkdown');
if (!$editorPlugin) {
throw new \Exception('Editor Akmarkdown not exists');
}
$params = new Registry($editorPlugin->params);
$files = $input->files;
$field = $input->get('field', 'file');
$type = $input->get('type', 'post');
$allows = $params->get('Upload_AllowExtension', '');
$allows = array_map('strtolower', array_map('trim', explode(',', $allows)));
$file = $files->getVar($field);
$src = $file['tmp_name'];
$name = $file['name'];
$tmp = new \SplFileInfo(JPATH_ROOT . '/tmp/ak-upload/' . $name);
if (empty($file['tmp_name'])) {
throw new \Exception('File not upload');
}
$ext = pathinfo($name, PATHINFO_EXTENSION);
if (!in_array($ext, $allows)) {
throw new \Exception('File extension now allowed.');
}
// Move file to tmp
if (!is_dir($tmp->getPath())) {
\JFolder::create($tmp->getPath());
}
if (is_file($tmp->getPathname())) {
\JFile::delete($tmp->getPathname());
}
\JFile::upload($src, $tmp->getPathname());
$src = $tmp;
$dest = static::getDest($name, $params->get('Upload_S3_Subfolder', 'ak-upload'));
$s3 = new \S3($params->get('Upload_S3_Key'), $params->get('Upload_S3_SecretKey'));
$bucket = $params->get('Upload_S3_Bucket');
$result = $s3::putObject(\S3::inputFile($src->getPathname(), false), $bucket, $dest, \S3::ACL_PUBLIC_READ);
if (is_file($tmp->getPathname())) {
\JFile::delete($tmp->getPathname());
}
if (!$result) {
throw new \Exception('Upload fail.');
}
} catch (\Exception $e) {
$response = new Response();
$response->setBody(json_encode(['error' => $e->getMessage()]));
$response->setMimeType('text/json');
$response->respond();
exit;
}
$return = new \JRegistry();
$return['filename'] = 'https://' . $bucket . '.s3.amazonaws.com/' . $dest;
$return['file'] = 'https://' . $bucket . '.s3.amazonaws.com/' . $dest;
$response = new Response();
$response->setBody((string) $return);
$response->setMimeType('text/json');
$response->respond();
}
示例11: getFilePath
/**
* @param $path
*
* @return \SplFileInfo
*/
protected function getFilePath($path)
{
$contentdir = $this->contentDir->getPathname() . DIRECTORY_SEPARATOR;
$file = $contentdir . $path;
if (!is_file($file)) {
throw new FileNotFoundException($path);
}
return new \SplFileInfo($file);
}
示例12: listSqlFiles
/** @return SqlFile[] */
public function listSqlFiles()
{
$foundFiles = glob($this->scanDir->getPathname() . "/*.[sS][qQ][lL]");
natsort($foundFiles);
$foundFiles = array_values($foundFiles);
return array_map(function ($file) {
return new SqlFile(new \SplFileInfo($file));
}, $foundFiles);
}
示例13: deleteRawFile
/**
* @param \SplFileInfo $file
*
* @throws FileRemovalException
*/
protected function deleteRawFile(\SplFileInfo $file)
{
$fs = new Filesystem();
try {
$fs->remove($file->getPathname());
} catch (IOException $e) {
throw new FileRemovalException(sprintf('Unable to delete the file "%s".', $file->getPathname()), $e->getCode(), $e);
}
}
示例14: createThumb
/**
* createThumb
*
* @param string $src
*
* @return bool
*/
public static function createThumb($src, $width = 400, $height = 400)
{
$dest = new \SplFileInfo(WINDWALKER_CACHE . '/image/temp/' . md5($src));
Folder::create($dest->getPath());
$image = new Image();
$image->loadFile($src);
$image->cropResize($width, $height, false);
$image->toFile($dest->getPathname() . '.jpg');
return $dest->getPathname() . '.jpg';
}
示例15: getData
/**
* @param \SplFileInfo $package
* @return array
* @throws \movi\FileNotFoundException
*/
private function getData(\SplFileInfo $package)
{
$file = $package->getPathname() . '/' . self::PACKAGE_FILE;
if (!file_exists($file) || !is_readable($file)) {
throw new FileNotFoundException("JSON file for package '" . $package->getFilename() . "' was not found or is not readable.");
}
$data = Json::decode(file_get_contents($file), Json::FORCE_ARRAY);
$data['dir'] = $package->getPathname();
return Arrays::mergeTree($data, $this->defaults);
}