PHP Класс Bkwld\Croppa\URL

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( array $config = [] ) Inject dependencies
buildFilters ( array $options ) : array | null Build filter class instancees
generate ( string $url, integer $width = null, integer $height = null, array $options = null ) : string Insert Croppa parameter suffixes into a URL. For use as a helper in views when rendering image src attributes.
options ( string $option_params ) : array Create options array where each key is an option name and the value if an array of the passed arguments
parse ( string $request ) : array | boolean Parse a request path into Croppa instructions
pathToUrl ( string $path ) : string Append host to the path if it was defined
phpThumbConfig ( array $options ) : array Take options in the URL and options from the config file and produce a config array in the format that PhpThumb expects
relativePath ( string $url ) : string Take a URL or path to an image and get the path relative to the src and crops dirs by using the path config regex
routePattern ( ) : string Make the regex for the route definition. This works by wrapping both the basic Croppa pattern and the path config in positive regex lookaheads so they working like an AND condition.
signingToken ( $url ) : string | void Generate the signing token from a URL or path. Or, if no key was defined, return nothing.
toPath ( string $url ) : string Extract the path from a URL and remove it's leading slash

Описание методов

__construct() публичный метод

Inject dependencies
public __construct ( array $config = [] )
$config array

buildFilters() публичный метод

Build filter class instancees
public buildFilters ( array $options ) : array | null
$options array
Результат array | null Array of filter instances

generate() публичный метод

Insert Croppa parameter suffixes into a URL. For use as a helper in views when rendering image src attributes.
public generate ( string $url, integer $width = null, integer $height = null, array $options = null ) : string
$url string URL of an image that should be cropped
$width integer Target width
$height integer Target height
$options array Addtional Croppa options, passed as key/value pairs. Like array('resize')
Результат string The new path to your thumbnail

options() публичный метод

Create options array where each key is an option name and the value if an array of the passed arguments
public options ( string $option_params ) : array
$option_params string Options string in the Croppa URL style
Результат array

parse() публичный метод

Parse a request path into Croppa instructions
public parse ( string $request ) : array | boolean
$request string
Результат array | boolean | boolean

pathToUrl() публичный метод

Append host to the path if it was defined
public pathToUrl ( string $path ) : string
$path string Request path (with leading slash)
Результат string

phpThumbConfig() публичный метод

Take options in the URL and options from the config file and produce a config array in the format that PhpThumb expects
public phpThumbConfig ( array $options ) : array
$options array The url options from `parseOptions()`
Результат array

relativePath() публичный метод

Take a URL or path to an image and get the path relative to the src and crops dirs by using the path config regex
public relativePath ( string $url ) : string
$url string url or path
Результат string

routePattern() публичный метод

https://regex101.com/r/kO6kL1/1 In the Laravel router, this gets wrapped with some extra regex before the matching happnens and for the pattern to match correctly, the final .* needs to exist. Otherwise, the lookaheads have no length and the regex fails https://regex101.com/r/xS3nQ2/1
public routePattern ( ) : string
Результат string

signingToken() публичный метод

Generate the signing token from a URL or path. Or, if no key was defined, return nothing.
public signingToken ( $url ) : string | void
Результат string | void

toPath() публичный метод

Extract the path from a URL and remove it's leading slash
public toPath ( string $url ) : string
$url string
Результат string path