コード例 #1
0
ファイル: ImageStyleRoutes.php プロジェクト: aWEBoLabs/taxi
 /**
  * Returns an array of route objects.
  *
  * @return \Symfony\Component\Routing\Route[]
  *   An array of route objects.
  */
 public function routes()
 {
     $routes = array();
     // Generate image derivatives of publicly available files. If clean URLs are
     // disabled image derivatives will always be served through the menu system.
     // If clean URLs are enabled and the image derivative already exists, PHP
     // will be bypassed.
     $directory_path = $this->streamWrapperManager->getViaScheme('public')->getDirectoryPath();
     $routes['image.style_public'] = new Route('/' . $directory_path . '/styles/{image_style}/{scheme}', array('_controller' => 'Drupal\\image\\Controller\\ImageStyleDownloadController::deliver'), array('_access' => 'TRUE'));
     return $routes;
 }
コード例 #2
0
ファイル: StreamLocator.php プロジェクト: hugronaphor/cornel
 /**
  * Locates a library.
  *
  * @param \Drupal\libraries\ExternalLibrary\Local\LocalLibraryInterface $library
  *   The library to locate.
  *
  * @see \Drupal\libraries\ExternalLibrary\Local\LocatorInterface::locate()
  */
 public function locate(LocalLibraryInterface $library)
 {
     /** @var \Drupal\Core\StreamWrapper\LocalStream $stream_wrapper */
     $stream_wrapper = $this->streamWrapperManager->getViaScheme($this->scheme);
     assert('$stream_wrapper instanceof \\Drupal\\Core\\StreamWrapper\\LocalStream');
     // Calling LocalStream::getDirectoryPath() explicitly avoids the realpath()
     // usage in LocalStream::getLocalPath(), which breaks if Libraries API is
     // symbolically linked into the Drupal installation.
     $path = $stream_wrapper->getDirectoryPath() . '/' . $library->getId();
     if (is_dir($path) && is_readable($path)) {
         $library->setLocalPath($path);
     } else {
         $library->setUninstalled();
     }
 }
コード例 #3
0
ファイル: FileCopy.php プロジェクト: Greg-Boggs/electric-dev
 /**
  * Determines if the given URI or path is considered local.
  *
  * A URI or path is considered local if it either has no scheme component,
  * or the scheme is implemented by a stream wrapper which extends
  * \Drupal\Core\StreamWrapper\LocalStream.
  *
  * @param string $uri
  *   The URI or path to test.
  *
  * @return bool
  */
 protected function isLocalUri($uri)
 {
     $scheme = $this->fileSystem->uriScheme($uri);
     // The vfs scheme is vfsStream, which is used in testing. vfsStream is a
     // simulated file system that exists only in memory, but should be treated
     // as a local resource.
     if ($scheme == 'vfs') {
         $scheme = FALSE;
     }
     return $scheme === FALSE || $this->streamWrapperManager->getViaScheme($scheme) instanceof LocalStream;
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function processInbound($path, Request $request)
 {
     $directory_path = $this->streamWrapperManager->getViaScheme('public')->getDirectoryPath();
     if (strpos($path, '/' . $directory_path . '/styles/') === 0) {
         $path_prefix = '/' . $directory_path . '/styles/';
     } elseif (strpos($path, '/system/files/styles/') === 0) {
         $path_prefix = '/system/files/styles/';
     } else {
         return $path;
     }
     // Strip out path prefix.
     $rest = preg_replace('|^' . preg_quote($path_prefix, '|') . '|', '', $path);
     // Get the image style, scheme and path.
     if (substr_count($rest, '/') >= 2) {
         list($image_style, $scheme, $file) = explode('/', $rest, 3);
         // Set the file as query parameter.
         $request->query->set('file', $file);
         return $path_prefix . $image_style . '/' . $scheme;
     } else {
         return $path;
     }
 }
コード例 #5
0
ファイル: FileSystem.php プロジェクト: ddrozdik/dmaps
 /**
  * {@inheritdoc}
  */
 public function tempnam($directory, $prefix)
 {
     $scheme = $this->uriScheme($directory);
     if ($this->validScheme($scheme)) {
         $wrapper = $this->streamWrapperManager->getViaScheme($scheme);
         if ($filename = tempnam($wrapper->getDirectoryPath(), $prefix)) {
             return $scheme . '://' . static::basename($filename);
         } else {
             return FALSE;
         }
     } else {
         // Handle as a normal tempnam() call.
         return tempnam($directory, $prefix);
     }
 }
コード例 #6
0
ファイル: FileCopy.php プロジェクト: eigentor/tommiblog
 /**
  * Determines if the given URI or path is considered local.
  *
  * A URI or path is considered local if it either has no scheme component,
  * or the scheme is implemented by a stream wrapper which extends
  * \Drupal\Core\StreamWrapper\LocalStream.
  *
  * @param string $uri
  *   The URI or path to test.
  *
  * @return bool
  */
 protected function isLocalUri($uri)
 {
     $scheme = $this->fileSystem->uriScheme($uri);
     return $scheme === FALSE || $this->streamWrapperManager->getViaScheme($scheme) instanceof LocalStream;
 }