Overview

Namespaces

  • Budovy
  • Kdyby
    • BootstrapFormRenderer
      • DI
      • Latte
  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Diagnostics
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
      • Diagnostics
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • PhpGenerator
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
  • NetteModule
  • Nextras
    • Datagrid
  • None
  • PHP
  • Tester
    • CodeCoverage
    • Runner
      • Output
  • Vodacek
    • Forms
      • Controls
  • WebLoader
    • Filter
    • Nette

Classes

  • Compiler
  • DefaultOutputNamingConvention
  • FileCollection
  • LoaderFactory
  • Path

Interfaces

  • IFileCollection
  • IOutputNamingConvention

Exceptions

  • FileNotFoundException
  • InvalidArgumentException
  • WebLoaderException
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace WebLoader;
 4: 
 5: use Nette\DI\Container;
 6: use Nette\Http\Request;
 7: use WebLoader\Nette\CssLoader;
 8: use WebLoader\Nette\Extension;
 9: use WebLoader\Nette\JavaScriptLoader;
10: 
11: class LoaderFactory
12: {
13:     /** @var \Nette\Http\Request */
14:     private $httpRequest;
15: 
16:     /** @var \Nette\DI\Container */
17:     private $serviceLocator;
18: 
19:     /** @var array */
20:     private $tempPaths;
21: 
22:     /**
23:      * @param array $tempPaths
24:      * @param Request $httpRequest
25:      * @param \Nette\DI\Container $serviceLocator
26:      */
27:     public function __construct(array $tempPaths, Request $httpRequest, Container $serviceLocator)
28:     {
29:         $this->httpRequest = $httpRequest;
30:         $this->serviceLocator = $serviceLocator;
31:         $this->tempPaths = $tempPaths;
32:     }
33: 
34:     /**
35:      * @param string $name
36:      * @return \WebLoader\Nette\CssLoader
37:      */
38:     public function createCssLoader($name)
39:     {
40:         /** @var Compiler $compiler */
41:         $compiler = $this->serviceLocator->getService('webloader.css' . ucfirst($name) . 'Compiler');
42:         return new CssLoader($compiler, $this->formatTempPath($name));
43:     }
44: 
45:     /**
46:      * @param string $name
47:      * @return \WebLoader\Nette\JavaScriptLoader
48:      */
49:     public function createJavaScriptLoader($name)
50:     {
51:         /** @var Compiler $compiler */
52:         $compiler = $this->serviceLocator->getService('webloader.js' . ucfirst($name) . 'Compiler');
53:         return new JavaScriptLoader($compiler, $this->formatTempPath($name));
54:     }
55: 
56:     /**
57:      * @param string $name
58:      * @return string
59:      */
60:     private function formatTempPath($name)
61:     {
62:         $lName = strtolower($name);
63:         $tempPath = isset($this->tempPaths[$lName]) ? $this->tempPaths[$lName] : Extension::DEFAULT_TEMP_PATH;
64:         return rtrim($this->httpRequest->url->basePath, '/') . '/' . $tempPath;
65:     }
66: 
67: }
68: 
API documentation generated by ApiGen 2.8.0