當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Flysystem\Util類代碼示例

本文整理匯總了PHP中League\Flysystem\Util的典型用法代碼示例。如果您正苦於以下問題:PHP Util類的具體用法?PHP Util怎麽用?PHP Util使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Util類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getConfirmEmail

 public function getConfirmEmail($token)
 {
     try {
         $email = Crypt::decrypt($token);
         $userQuery = DB::table('users')->where('email', $email);
         $user = $userQuery->first();
         if (isset($user)) {
             switch (\Config::get('app.registerMode')) {
                 case 'auto':
                     $userQuery->update(['active' => 1]);
                     Util::flash(trans('auth.confirmed'), '', Util::ALERT_SUCCESS);
                     // Foi enviado um email.
                     return view('auth/login');
                     break;
                 case 'confirm':
                     $userQuery->update(['pending' => 1]);
                     return view('info', ['title' => trans('auth.pending-approval_confirmation'), 'text' => trans('auth.pending-approval')]);
                     break;
             }
         } else {
             Util::flash(trans('auth.user'), '', Util::ALERT_ERROR);
         }
         // Não existe o email.
     } catch (Exception $e) {
         Util::flash(trans('auth.token'), '', Util::ALERT_ERROR);
         // Token inválido.
     }
     return Redirect::action(self::HOME_ACTION);
 }
開發者ID:hramose,項目名稱:laravel5-adminLTE-1,代碼行數:29,代碼來源:AuthController.php

示例2: stream

 /**
  * Stream fallback delegator.
  *
  * @param string   $path
  * @param resource $resource
  * @param Config   $config
  * @param string   $fallback
  *
  * @return mixed fallback result
  */
 protected function stream($path, $resource, Config $config, $fallback)
 {
     Util::rewindStream($resource);
     $contents = stream_get_contents($resource);
     $fallbackCall = [$this, $fallback];
     return call_user_func($fallbackCall, $path, $contents, $config);
 }
開發者ID:Ceciceciceci,項目名稱:MySJSU-Class-Registration,代碼行數:17,代碼來源:StreamedWritingTrait.php

示例3: getSize

 /**
  * @inheritdoc
  */
 public function getSize($path)
 {
     if (!($decrypted = $this->read($path))) {
         return false;
     }
     $size = Util::contentSize($decrypted['contents']);
     return compact('path', 'size');
 }
開發者ID:twistor,項目名稱:flysystem-encrypt,代碼行數:11,代碼來源:EncryptAdapter.php

示例4: update

 /**
  * {@inheritdoc}
  */
 public function update($path, $contents, Config $config)
 {
     $location = $this->applyPathPrefix($path);
     $mimetype = Util::guessMimeType($path, $contents);
     if (($size = file_put_contents($location, $contents)) === false) {
         return false;
     }
     return compact('path', 'size', 'contents', 'mimetype');
 }
開發者ID:njohns-pica9,項目名稱:flysystem-vfs,代碼行數:12,代碼來源:VfsAdapter.php

示例5: getFinder

 /**
  * @param string $path child path to find in
  *
  * @return Finder
  */
 public function getFinder($path = '')
 {
     $path = Util::normalizePath($path);
     $adapter = $this->getAdapter();
     if (!$adapter instanceof FindableAdapterInterface) {
         throw new NotSupportedException("Adapter doesn't support getFinder action. Adapter in use is: " . get_class($adapter));
     }
     return $adapter->getFinder($path);
 }
開發者ID:oasmobile,項目名稱:php-flysystem-wrappers,代碼行數:14,代碼來源:ExtendedFilesystem.php

示例6: handle

 /**
  * Emulates touch().
  *
  * @param string $path
  *
  * @return bool True on success, false on failure.
  */
 public function handle($path)
 {
     $path = Util::normalizePath($path);
     $adapter = $this->filesystem->getAdapter();
     if ($adapter->has($path)) {
         return true;
     }
     return (bool) $adapter->write($path, '', $this->defaultConfig());
 }
開發者ID:twistor,項目名稱:flysystem-stream-wrapper,代碼行數:16,代碼來源:Touch.php

示例7: write

 /**
  * Write a file
  *
  * @param $path
  * @param $contents
  * @param null $config
  * @return array|bool
  */
 public function write($path, $contents, $config = null)
 {
     $type = 'file';
     $config = Util::ensureConfig($config);
     $result = compact('contents', 'type', 'size', 'path');
     if ($visibility = $config->get('visibility')) {
         $result['visibility'] = $visibility;
     }
     return $result;
 }
開發者ID:limweb,項目名稱:webappservice,代碼行數:18,代碼來源:NullAdapter.php

示例8: rename

 public function rename($path, $newpath)
 {
     $location = $this->applyPathPrefix($path);
     $destination = $this->applyPathPrefix($newpath);
     $parentDirectory = $this->applyPathPrefix(Util::dirname($newpath));
     if (!$this->ensureDirectory($parentDirectory)) {
         return false;
     }
     return rename($location, $destination);
 }
開發者ID:aleksabp,項目名稱:bolt,代碼行數:10,代碼來源:Local.php

示例9: handle

 /**
  * Creates a directory.
  *
  * @param string $dirname
  * @param int    $mode
  * @param int    $options
  *
  * @return bool True on success, false on failure.
  */
 public function handle($dirname, $mode, $options)
 {
     $dirname = Util::normalizePath($dirname);
     $adapter = $this->filesystem->getAdapter();
     // If recursive, or a single level directory, just create it.
     if ($options & STREAM_MKDIR_RECURSIVE || strpos($dirname, '/') === false) {
         return (bool) $adapter->createDir($dirname, $this->defaultConfig());
     }
     if (!$adapter->has(dirname($dirname))) {
         throw new FileNotFoundException($dirname);
     }
     return (bool) $adapter->createDir($dirname, $this->defaultConfig());
 }
開發者ID:twistor,項目名稱:flysystem-stream-wrapper,代碼行數:22,代碼來源:Mkdir.php

示例10: isValidRename

 /**
  * Checks that a rename is valid.
  *
  * @param string $source
  * @param string $dest
  *
  * @return bool
  */
 protected function isValidRename($source, $dest)
 {
     $adapter = $this->filesystem->getAdapter();
     if (!$adapter->has($source)) {
         throw new FileNotFoundException($source);
     }
     $subdir = Util::dirname($dest);
     if (strlen($subdir) && !$adapter->has($subdir)) {
         throw new FileNotFoundException($source);
     }
     if (!$adapter->has($dest)) {
         return true;
     }
     return $this->compareTypes($source, $dest);
 }
開發者ID:twistor,項目名稱:flysystem-stream-wrapper,代碼行數:23,代碼來源:ForcedRename.php

示例11: storeContents

 /**
  * {@inheritdoc}
  */
 public function storeContents($directory, array $contents, $recursive)
 {
     if ($recursive) {
         return $contents;
     }
     foreach ($contents as $index => $object) {
         $pathinfo = Util::pathinfo($object['path']);
         $object = array_merge($pathinfo, $object);
         if (!$recursive && $object['dirname'] !== $directory) {
             unset($contents[$index]);
             continue;
         }
         $contents[$index] = $object;
     }
     return $contents;
 }
開發者ID:bogolubov,項目名稱:owncollab_talks-1,代碼行數:19,代碼來源:Noop.php

示例12: handle

 /**
  * Delete a directory.
  *
  * @param string $dirname path to directory
  * @param int    $options
  *
  * @return bool
  */
 public function handle($dirname, $options)
 {
     $dirname = Util::normalizePath($dirname);
     if ($dirname === '') {
         throw new RootViolationException('Root directories can not be deleted.');
     }
     $adapter = $this->filesystem->getAdapter();
     if ($options & STREAM_MKDIR_RECURSIVE) {
         // I don't know how this gets triggered.
         return (bool) $adapter->deleteDir($dirname);
     }
     $contents = $this->filesystem->listContents($dirname);
     if (!empty($contents)) {
         throw new DirectoryNotEmptyException();
     }
     return (bool) $adapter->deleteDir($dirname);
 }
開發者ID:twistor,項目名稱:flysystem-stream-wrapper,代碼行數:25,代碼來源:Rmdir.php

示例13: onGetClassGenerateFile

 /**
  * Use flysystem to save the file in the desired location.
  *
  * @param \Onema\ClassyFile\Event\GetClassEvent $event
  */
 public function onGetClassGenerateFile(GetClassEvent $event)
 {
     $statement = $event->getStatements();
     $fileLocation = $event->getFileLocation();
     $code = $event->getCode();
     $name = $statement->name;
     if (!$this->filesystem->has($fileLocation)) {
         // dir doesn't exist, make it
         $this->filesystem->createDir($fileLocation);
     }
     $location = sprintf('%s/%s.php', $fileLocation, $name);
     $this->filesystem->put($location, $code);
     $adapter = $this->filesystem->getAdapter();
     if ($adapter instanceof AbstractAdapter) {
         $prefix = $adapter->getPathPrefix();
         $location = Util::normalizePath($location);
         $event->setFileLocation(sprintf('%s%s', $prefix, $location));
     }
 }
開發者ID:onema,項目名稱:classyfile,代碼行數:24,代碼來源:GenerateClassFile.php

示例14: write

 /**
  * Write a new file.
  *
  * @param string $path
  * @param string $contents
  * @param Config $config Config object
  * @return array|false false on failure file meta data on success
  */
 public function write($path, $contents, Config $config = null)
 {
     $tmpFile = tempnam(sys_get_temp_dir(), 'arconnect-static');
     file_put_contents($tmpFile, $contents);
     $file = new \CURLFile($tmpFile, Util::guessMimeType($path, $tmpFile), basename($tmpFile));
     $data = ['slug' => $path, 'file' => $file];
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $this->apiUrl . '/' . $this->application);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_exec($ch);
     $fileInfo = curl_getinfo($ch);
     curl_close($ch);
     unlink($tmpFile);
     if ($fileInfo['http_code'] >= 200 && $fileInfo['http_code'] < 400) {
         $response = ['contents' => $contents, 'type' => $fileInfo['content_type'], 'size' => $fileInfo['size_download'], 'path' => $path];
         return $response;
     }
     return false;
 }
開發者ID:ArDeveloppement,項目名稱:flysystem-ardev-static,代碼行數:29,代碼來源:ArStatic.php

示例15: isSeekableStream

 /**
  * Determine if this stream is seekable
  *
  * @param resource $stream
  * @return bool True if this stream is seekable
  */
 protected function isSeekableStream($stream)
 {
     return Util::isSeekableStream($stream);
 }
開發者ID:jacobbuck,項目名稱:silverstripe-framework,代碼行數:10,代碼來源:FlysystemAssetStore.php


注:本文中的League\Flysystem\Util類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。