Maslosoft Sprite API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
<?php
/**
* This software package is licensed under AGPL or Commercial license.
*
* @package maslosoft/sprite
* @licence AGPL or Commercial
* @copyright Copyright (c) Piotr Masełkowski <pmaselkowski@gmail.com>
* @copyright Copyright (c) Maslosoft
* @copyright Copyright (c) Others as mentioned in code
* @link http://maslosoft.com/sprite/
*/
namespace Maslosoft\Sprite\Models;
use Maslosoft\Sprite\Helpers\Normalizer;
use Maslosoft\Sprite\Interfaces\SpritePackageInterface;
/**
* Sprite package
*
* @author Piotr Maselkowski <pmaselkowski at gmail.com>
*/
class Package implements SpritePackageInterface
{
/**
* If set, it will **override** this class with same class name,
* but containing formatted constants with icon names.
*
* This parameter combined with `iconPrefix` can be used to select
* icons based on class constants, with IDE autocomplete support, and shorter names.
*
* Possible example usage, assume class name is `Icon` or some namespaced
* name, let's say `Maslosoft\Module\Icon` and is imported here:
* ```php
* Icon::Folder; // icon-folder
* ```
*
* With `iconPrefix` constant name will be the same, however CSS name will be prefixed:
* ```php
* Icon::Folder; // icon-module-folder
* ```
* @var string
*/
public $constantsClass = '';
/**
* Set this to create class if not yet exists
* @var string
*/
public $constantsClassPath = '';
/**
* Define any valid PHP callback to customize transformation constant names.
* By default they are camelized, ie:
* ```
* document-folder
* ```
* Will become:
* ```
* DocumentFolder
* ```
*
* Function accepts two parameter, package interface instance and sprite object.
*
* Example function:
* ```php
* $converter = function(SpritePackageInterface $package, SpriteImage $sprite)
* {
* // Basic camelize function
* return lcfirst(str_replace('-', '', ucwords($sprite->name, '-')));
* };
* ```
* @var callback
*/
public $constantsConverter = [Normalizer::class, 'camelize'];
/**
* Define any valid PHP callback to customize transformation of CSS class names.
* By default they are decamelized, ie:
* ```
* Document-Folder
* ```
* Will become:
* ```
* document-folder
* ```
*
* Function accepts two parameter, package interface instance and sprite object.
*
* Example function:
* ```php
* $converter = function(SpritePackageInterface $package, SpriteImage $sprite)
* {
* // Basic camelize function
* return lcfirst(str_replace('-', '', ucwords($sprite->name, '-')));
* };
* ```
* @var callback
*/
public $cssClassNameConverter = [Normalizer::class, 'decamelize'];
/**
* Icon prefix. It is used by CSS as selector.
* This can be usefull to create icon namespace for application module.
* Example icon CSS class name without prefix:
* ```
* icon-folder
* ```
* With prefix it will append this prefix after `icon` part
* @var string
*/
public $iconPrefix = '';
/**
* Absolute paths to scan for icons.
* It cat be paths to folder or to single icons:
* ```php
* $paths = [
* '/var/www/some/application/assets/',
* '/tmp/some-icon.png'
* ]
* ```
*
* If path have sub directories these will be added to icon name as prefix.
* For example, when configured path is
* ```php
* $paths = [
* '/var/www/some/application/assets/',
* ]
* ```
* And real paths are
* ```
* Paths:
* /var/www/some/application/assets/16/
* /var/www/some/application/assets/32/
* ```
* This will result in icons with two prefixes of `16` and `32`.
* This is useful for icon sizing. So when using icon, one would know
* it's size just by the icon name.
*
* @var string[]
*/
public $paths = [];
public function getConstantsClass()
{
return $this->constantsClass;
}
public function getConstantsClassPath()
{
return $this->constantsClassPath;
}
public function getConstantsConverter()
{
return $this->constantsConverter;
}
public function getCssClassNameConverter()
{
return $this->cssClassNameConverter;
}
public function getIconPrefix()
{
return $this->iconPrefix;
}
public function getPaths()
{
return $this->paths;
}
public function setConstantsClass($constantsClass)
{
$this->constantsClass = $constantsClass;
return $this;
}
public function setConstantsClassPath($constantsClassPath)
{
$this->constantsClassPath = $constantsClassPath;
return $this;
}
public function setConstantsConverter($constantsConverter)
{
$this->constantsConverter = $constantsConverter;
return $this;
}
public function setCssClassNameConverter($cssClassNameConverter)
{
$this->cssClassNameConverter = $cssClassNameConverter;
return $this;
}
public function setIconPrefix($iconPrefix)
{
$this->iconPrefix = $iconPrefix;
return $this;
}
public function setPaths($paths)
{
$this->paths = $paths;
return $this;
}
}
API documentation generated by ApiGen