PHP Class Bolt\Stack

Each user (by design) has their own stack. No sharesies!
Author: Bob den Otter, [email protected]
显示文件 Open project: bolt/bolt Class Usage Examples

Public Methods

Method Description
__construct ( Matcher $matcher, Users $users, Symfony\Component\HttpFoundation\Session\SessionInterface $session, string[] $acceptedFileTypes ) Constructor.
add ( Bolt\Filesystem\Handler\FileInterface | string $filename, Bolt\Filesystem\Handler\FileInterface &$removed = null ) : Bolt\Filesystem\Handler\FileInterface Add a file to the stack.
contains ( Bolt\Filesystem\Handler\FileInterface | string $filename ) : boolean Check if a given file is present on the stack.
count ( )
delete ( Bolt\Filesystem\Handler\FileInterface | string $filename ) Delete a file from the stack.
getIterator ( )
getList ( array $types = [] ) : Bolt\Filesystem\Handler\FileInterface[] Returns the list of files in the stack, filtered by type (if given).
isStackable ( Bolt\Filesystem\Handler\FileInterface | string $filename ) : boolean Check if a given file can be added to the stack.

Private Methods

Method Description
hydrateList ( string[] $paths ) : Bolt\Filesystem\Handler\FileInterface[] Converts a list of paths to file objects.
initialize ( ) Initialize file list for current user, either from session or database.
persist ( ) Persist the contents of the current stack to the session, as well as the database.
persistableList ( ) : string[] Returns the list of files as full paths.

Method Details

__construct() public method

Constructor.
public __construct ( Matcher $matcher, Users $users, Symfony\Component\HttpFoundation\Session\SessionInterface $session, string[] $acceptedFileTypes )
$matcher Bolt\Filesystem\Matcher
$users Users
$session Symfony\Component\HttpFoundation\Session\SessionInterface
$acceptedFileTypes string[]

add() public method

Add a file to the stack.
public add ( Bolt\Filesystem\Handler\FileInterface | string $filename, Bolt\Filesystem\Handler\FileInterface &$removed = null ) : Bolt\Filesystem\Handler\FileInterface
$filename Bolt\Filesystem\Handler\FileInterface | string The file to add.
$removed Bolt\Filesystem\Handler\FileInterface Returns the removed file, if one was removed.
return Bolt\Filesystem\Handler\FileInterface If filename cannot be matched to filesystem.

contains() public method

Check if a given file is present on the stack.
public contains ( Bolt\Filesystem\Handler\FileInterface | string $filename ) : boolean
$filename Bolt\Filesystem\Handler\FileInterface | string
return boolean

count() public method

public count ( )

delete() public method

Delete a file from the stack.
public delete ( Bolt\Filesystem\Handler\FileInterface | string $filename )
$filename Bolt\Filesystem\Handler\FileInterface | string

getIterator() public method

public getIterator ( )

getList() public method

Returns the list of files in the stack, filtered by type (if given).
public getList ( array $types = [] ) : Bolt\Filesystem\Handler\FileInterface[]
$types array Filter files by type. Valid types: "image", "document", "other"
return Bolt\Filesystem\Handler\FileInterface[]

isStackable() public method

Requirements: - File's extension is accepted - File can be matched to filesystem - File is not currently on the stack
public isStackable ( Bolt\Filesystem\Handler\FileInterface | string $filename ) : boolean
$filename Bolt\Filesystem\Handler\FileInterface | string
return boolean