Pipe\Environment::find PHP Method

find() public method

Example: find('application.js', ['bundled' => true]);
public find ( string $logicalPath, array $options = [] ) : Asset
$logicalPath string Path relative to the load path.
$options array
return Asset
    function find($logicalPath, $options = array())
    {
        $path = new FileUtils\PathInfo($logicalPath);
        if ($path->isAbsolute()) {
            $realPath = $logicalPath;
        } else {
            $realPath = $this->loadPaths->find($logicalPath);
        }
        if (!is_file($realPath)) {
            return;
        }
        if (null === $realPath) {
            return;
        }
        if (@$options["bundled"]) {
            $asset = new BundledAsset($this, $realPath, $logicalPath);
        } else {
            $asset = new ProcessedAsset($this, $realPath, $logicalPath);
        }
        return $asset;
    }

Usage Example

Example #1
0
File: Server.php Project: chh/pipe
 function handle(HttpFoundation\Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     $path = ltrim($request->getPathInfo(), '/');
     $asset = $this->environment->find($path, array("bundled" => true));
     $debug = $request->query->get("debug", false);
     $cache = !$request->query->get("nocache", false);
     if (!$asset or $path == '') {
         return $this->renderNotFound($request);
     }
     if ($debug) {
         $this->environment->bundleProcessors->clear();
     }
     $lastModified = new \DateTime();
     $lastModified->setTimestamp($asset->getLastModified());
     $response = new HttpFoundation\Response();
     $response->setPublic();
     $response->setLastModified($lastModified);
     if ($cache and $response->isNotModified($request)) {
         return $response;
     }
     $response->setContent($asset->getBody());
     $response->headers->set('Content-Type', $asset->getContentType());
     $response->prepare($request);
     return $response;
 }
All Usage Examples Of Pipe\Environment::find