本文整理汇总了PHP中Illuminate\Filesystem\Filesystem::isWritable方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::isWritable方法的具体用法?PHP Filesystem::isWritable怎么用?PHP Filesystem::isWritable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::isWritable方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setPath
/**
* Set the path for the JSON file.
*
* @param string $path
*
* @return self
*/
public function setPath($path)
{
if (!$this->files->exists($path) && $this->files->put($path, '{}') === false) {
throw new InvalidArgumentException("Could not write to {$path}.");
}
if (!$this->files->isWritable($path)) {
throw new InvalidArgumentException("{$path} is not writable.");
}
$this->path = $path;
return $this;
}
示例2: make
/**
* Compile routes template and generate
*
* @param string $path
* @param string $name
* @param array $options
* @return boolean
*/
public function make($path, $name, array $options = [])
{
$options += ['filter' => null, 'prefix' => null];
$this->parsedRoutes = $this->getParsedRoutes($options['filter'], $options['prefix']);
$template = $this->file->get(__DIR__ . '/templates/Router.js');
$template = str_replace("routes: null,", 'routes: ' . json_encode($this->parsedRoutes) . ',', $template);
$template = str_replace("'Router'", "'" . $options['object'] . "'", $template);
if ($this->file->isWritable($path)) {
$filename = $path . '/' . $name;
return $this->file->put($filename, $template) !== false;
}
return false;
}
示例3: setPath
/**
* Set the path for the JSON file.
*
* @param string $path
*/
public function setPath($path)
{
if (!$this->filesystem->exists($path)) {
$result = $this->filesystem->put($path, '{}');
if (!$result) {
throw new \InvalidArgumentException("Could not write to {$path}.");
}
}
if (!$this->filesystem->isWritable($path)) {
throw new \InvalidArgumentException("{$path} is not writable.");
}
$this->path = $path;
}
示例4: setPath
/**
* Set the path for the JSON file.
*
* @param string $path
* @throws NotWritableException
*/
public function setPath($path)
{
if (!$this->files->exists($path)) {
$result = $this->files->put($path, '{}');
if ($result === false) {
throw new NotWritableException("Could not write to {$path}.");
}
}
if (!$this->files->isWritable($path)) {
throw new NotWritableException("{$path} is not writable.");
}
$this->path = $path;
}
示例5: undo
/**
* Perform undo action
*
* @return void
*/
protected function undo()
{
// Delete status
$deleteCompleted = true;
// Get files from the json undo file
$files = json_decode($this->filesystem->get($this->undoFilePath), true);
// For each file
$this->info('Deleting files:');
foreach ($files as $file) {
// If this file can be deleted
if ($this->filesystem->isWritable($file)) {
// Delete it
$this->filesystem->delete($file);
$this->info(" Deleted: {$file}");
} else {
// Set status
$deleteCompleted = false;
// Show error
$this->error('Could not delete: ' . $file);
}
}
// if the delete prccess finished successfully
if ($deleteCompleted) {
// Delete undo file
$this->filesystem->delete($this->undoFilePath);
}
}
示例6: store
/**
* @param \Exolnet\Image\Imageable $image
* @param \Symfony\Component\HttpFoundation\File\File $file
* @return bool
* @throws \Exolnet\Core\Exceptions\ServiceValidationException
*/
public function store(Imageable $image, File $file)
{
if (!$image->getFilename()) {
throw new ServiceValidationException('Could not store image with an empty filename.');
}
$path = dirname($image->getImagePath());
$filename = basename($image->getImagePath());
if (!$this->filesystem->exists($path)) {
$this->filesystem->makeDirectory($path, 0755, true);
}
if (!$this->filesystem->isWritable($path)) {
throw new ServiceValidationException('The image base path "' . $path . '" is not writable.');
}
$file->move($path, $filename);
return true;
}
示例7: handle
/**
* Handle the command.
*
* @param Filesystem $files
* @param Application $application
*/
public function handle(Filesystem $files, Application $application)
{
$paths = ['storage', $application->getStoragePath(), 'public/assets', $application->getAssetsPath()];
foreach ($paths as $path) {
if ($files->exists(base_path($path)) && !$files->isWritable(base_path($path))) {
die('chmod -R 777 ' . base_path($path));
}
}
}
示例8: getStaticPathLocation
/**
* Where in the /public directory should the files
* be stored?
*
* @return string $path
*/
public function getStaticPathLocation()
{
$path = public_path() . $this->fileLocation;
if (!$this->fs->isWritable($path)) {
throw new PathNotWritableException();
}
if (!$this->fs->isDirectory($path)) {
$this->fs->makeDirectory($path);
}
return $path;
}
示例9: createFile
/**
* Erstellt die module.json Datei
*
* @param string $module
* @return void
*/
private function createFile($module)
{
$module = $this->modules[$module];
if($this->files->isWritable($module))
{
$this->files->copy(__DIR__.'/../templates/module.json', $module.'/module.json');
}
else
{
return App::abort('403', "Please set writable permissions to " . $module . "\n");
}
}
示例10: checkEnv
protected function checkEnv($path, $name, $namespace, $title)
{
// check directory exists
if ($this->files->exists($path)) {
$this->error($this->type . ' already exists!');
return false;
}
// check permission
$pluginsDir = app('xe.plugin')->getPluginsDir();
if (!$this->files->isWritable($pluginsDir)) {
$this->error("Permission denied. Can not create plugin directory({$path}).");
return false;
}
}
示例11: checkEnv
protected function checkEnv($path, $name, $namespace, $title)
{
// check directory exists
if ($this->files->exists($path)) {
$this->error('Plugin already exists!');
return false;
}
// check namespace
if (!str_contains($namespace, '\\')) {
$this->error('The namespace must have at least 1 delimiter(\\), use double backslash(\\\\) as delimiter');
return false;
}
// check permission
$pluginsDir = app('xe.plugin')->getPluginsDir();
if (!$this->files->isWritable($pluginsDir)) {
$this->error("Permission denied. Can not create plugin directory({$path}).");
return false;
}
}
示例12: isWritable
/**
* Determine if the given path is writable.
*
* @param string $path
* @return bool
* @static
*/
public static function isWritable($path)
{
return \Illuminate\Filesystem\Filesystem::isWritable($path);
}
示例13: ensureAttachmentFolder
/**
* Helper to ensure attachment folder
*/
protected function ensureAttachmentFolder()
{
$file = new Filesystem();
// Ensure base folder
if (!$file->isDirectory($this->directory)) {
$file->makeDirectory($this->directory, 0777, true);
}
// Ensure media folder
if (!$file->isDirectory($this->media_directory)) {
$file->makeDirectory($this->media_directory, 0777, true);
}
if (!$file->isWritable($this->directory) || !$file->isWritable($this->media_directory)) {
throw new RuntimeException('Invalid attachment directory');
}
}