PHP 클래스 JamesMoss\Flywheel\Repository

Analageous to a table in a traditional RDBMS, a repository is a siloed collection where documents live.
파일 보기 프로젝트 열기: jamesmoss/flywheel 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$documentClass
$formatter
$name
$path
$queryClass

공개 메소드들

메소드 설명
__construct ( string $name, Config $config ) Constructor
delete ( mixed $id ) : boolean Delete a document from the repository using its ID.
findAll ( ) : array Returns all the documents within this repo.
findById ( string $id ) : Document | boolean Returns a single document based on it's ID
getAllFiles ( ) : array Get an array containing the path of all files in this repository
getFilename ( string $id ) : string Gets just the filename for a document based on it's ID.
getName ( ) : string Returns the name of this repository
getPath ( ) : string Returns the filesystem path of this repository.
getPathForDocument ( string $id ) : string Get the filesystem path for a document based on it's ID.
query ( ) : Query A factory method that initialises and returns an instance of a Query object.
store ( JamesMoss\Flywheel\DocumentInterface $document ) : boolean Store a Document in the repository.
update ( JamesMoss\Flywheel\DocumentInterface $document ) : boolean Store a Document in the repository, but only if it already exists. The document must have an ID.

보호된 메소드들

메소드 설명
generateId ( ) : string Generates a random, unique ID for a document. The result is returned in base62. This keeps it shorted but still human readable if shared in URLs.
getIdFromPath ( string $path, string $ext ) : string Get a document's ID base on its filesystem path
validateId ( string $id ) : boolean Checks to see if a document ID is valid
validateName ( string $name ) : boolean Validates the name of the repo to ensure it can be stored in the filesystem.
write ( string $path, string $contents ) : boolean Writes data to the filesystem.

메소드 상세

__construct() 공개 메소드

Constructor
public __construct ( string $name, Config $config )
$name string The name of the repository. Must match /[A-Za-z0-9_-]{1,63}+/
$config Config The config to use for this repo

delete() 공개 메소드

Delete a document from the repository using its ID.
public delete ( mixed $id ) : boolean
$id mixed The ID of the document (or the document itself) to delete
리턴 boolean True if deleted, false if not.

findAll() 공개 메소드

Returns all the documents within this repo.
public findAll ( ) : array
리턴 array An array of Documents.

findById() 공개 메소드

Returns a single document based on it's ID
public findById ( string $id ) : Document | boolean
$id string The ID of the document to find
리턴 Document | boolean The document if it exists, false if not.

generateId() 보호된 메소드

Generates a random, unique ID for a document. The result is returned in base62. This keeps it shorted but still human readable if shared in URLs.
protected generateId ( ) : string
리턴 string The generated ID.

getAllFiles() 공개 메소드

Get an array containing the path of all files in this repository
public getAllFiles ( ) : array
리턴 array An array, item is a file

getFilename() 공개 메소드

Gets just the filename for a document based on it's ID.
public getFilename ( string $id ) : string
$id string The ID of the document.
리턴 string The filename of the document, including extension.

getIdFromPath() 보호된 메소드

Get a document's ID base on its filesystem path
protected getIdFromPath ( string $path, string $ext ) : string
$path string The full path to the file (including file extension)
$ext string The file extension (without the period)
리턴 string The ID of the document

getName() 공개 메소드

Returns the name of this repository
public getName ( ) : string
리턴 string The name of the repo

getPath() 공개 메소드

Returns the filesystem path of this repository.
public getPath ( ) : string
리턴 string The path where documents are stored.

getPathForDocument() 공개 메소드

Get the filesystem path for a document based on it's ID.
public getPathForDocument ( string $id ) : string
$id string The ID of the document.
리턴 string The full filesystem path of the document.

query() 공개 메소드

A factory method that initialises and returns an instance of a Query object.
public query ( ) : Query
리턴 Query A new Query class for this repo.

store() 공개 메소드

Store a Document in the repository.
public store ( JamesMoss\Flywheel\DocumentInterface $document ) : boolean
$document JamesMoss\Flywheel\DocumentInterface The document to store
리턴 boolean True if stored, otherwise false

update() 공개 메소드

Store a Document in the repository, but only if it already exists. The document must have an ID.
public update ( JamesMoss\Flywheel\DocumentInterface $document ) : boolean
$document JamesMoss\Flywheel\DocumentInterface The document to store
리턴 boolean True if stored, otherwise false

validateId() 보호된 메소드

Checks to see if a document ID is valid
protected validateId ( string $id ) : boolean
$id string The ID to check
리턴 boolean True if valid, otherwise false

validateName() 보호된 메소드

Validates the name of the repo to ensure it can be stored in the filesystem.
protected validateName ( string $name ) : boolean
$name string The name to validate against
리턴 boolean Returns true if valid. Throws an exception if not.

write() 보호된 메소드

Writes data to the filesystem.
protected write ( string $path, string $contents ) : boolean
$path string The absolute file path to write to
$contents string The contents of the file to write
리턴 boolean Returns true if write was successful, false if not.

프로퍼티 상세

$documentClass 보호되어 있는 프로퍼티

protected $documentClass

$formatter 보호되어 있는 프로퍼티

protected $formatter

$name 보호되어 있는 프로퍼티

protected $name

$path 보호되어 있는 프로퍼티

protected $path

$queryClass 보호되어 있는 프로퍼티

protected $queryClass