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: /**
  6:  * DefaultNamingConvention
  7:  *
  8:  * @author Jan Marek
  9:  */
 10: class DefaultOutputNamingConvention implements IOutputNamingConvention
 11: {
 12: 
 13:     /** @var string */
 14:     private $prefix = 'webloader-';
 15: 
 16:     /** @var string */
 17:     private $suffix = '';
 18: 
 19:     /**
 20:      * @return DefaultOutputNamingConvention
 21:      */
 22:     public static function createCssConvention()
 23:     {
 24:         $convention = new static();
 25:         $convention->setPrefix('cssloader-');
 26:         $convention->setSuffix('.css');
 27: 
 28:         return $convention;
 29:     }
 30: 
 31:     /**
 32:      * @return DefaultOutputNamingConvention
 33:      */
 34:     public static function createJsConvention()
 35:     {
 36:         $convention = new static();
 37:         $convention->setPrefix('jsloader-');
 38:         $convention->setSuffix('.js');
 39: 
 40:         return $convention;
 41:     }
 42: 
 43:     /**
 44:      * Get generated file name prefix
 45:      * @return string
 46:      */
 47:     public function getPrefix()
 48:     {
 49:         return $this->prefix;
 50:     }
 51: 
 52:     /**
 53:      * Set generated file name prefix
 54:      * @param string $prefix generated file name prefix
 55:      */
 56:     public function setPrefix($prefix)
 57:     {
 58:         $this->prefix = (string) $prefix;
 59:     }
 60: 
 61: 
 62:     /**
 63:      * Get generated file name suffix
 64:      * @return string
 65:      */
 66:     public function getSuffix()
 67:     {
 68:         return $this->suffix;
 69:     }
 70: 
 71: 
 72:     /**
 73:      * Set generated file name suffix
 74:      * @param string $suffix generated file name suffix
 75:      */
 76:     public function setSuffix($suffix)
 77:     {
 78:         $this->suffix = (string) $suffix;
 79:     }
 80: 
 81:     /**
 82:      * Filename of generated file
 83:      * @param array $files
 84:      * @param \WebLoader\Compiler $compiler
 85:      * @return string
 86:      */
 87:     public function getFilename(array $files, Compiler $compiler)
 88:     {
 89:         $name = $this->createHash($files, $compiler);
 90: 
 91:         if (count($files) === 1) {
 92:             $name .= "-" . pathinfo($files[0], PATHINFO_FILENAME);
 93:         }
 94: 
 95:         return $this->prefix . $name . $this->suffix;
 96:     }
 97: 
 98:     protected function createHash(array $files, Compiler $compiler)
 99:     {
100:         return substr(md5(implode("|", $files)), 0, 12);
101:     }
102: 
103: }
104: 
API documentation generated by ApiGen 2.8.0