PHP Класс Bolt\Legacy\Storage

Устаревший: Deprecated since 3.0, to be removed in 4.0.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$images array

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

Метод Описание
__construct ( Silex\Application $app )
deleteContent ( string $contenttype, integer $id ) : integer Delete a record.
depublishExpiredRecords ( )
getContent ( string $textquery, string $parameters = '', array &$pager = [], array $whereparameters = [] ) : array getContent based on a 'human readable query'.
getContentByTaxonomy ( string $taxonomyslug, string $name, string $parameters = [] ) : array Retrieve content from the database, filtered on taxonomy.
getContentObject ( array | string $contenttype, array $values = [] ) : Content Get an object for the content of a specific contenttype. This will be \Bolt\Legacy\Content, unless the contenttype defined another class to be used.
getContentType ( string $contenttypeslug ) : boolean | array Get the contenttype as an array, based on the given $contenttypeslug.
getContentTypeFieldType ( string $contenttypeslug, string $fieldname ) : array Get the fieldtype for a given contenttype and fieldname.
getContentTypeFields ( string $contenttypeslug ) : array Get an array of the available fields for a given contenttype.
getContentTypeGrouping ( string $contenttypeslug ) : mixed Check if a given contenttype has a grouping, and if it does, return it.
getContentTypeTaxonomy ( string $contenttypeslug ) : array Get an array of the available taxonomytypes for a given contenttype.
getContentTypes ( ) : array Get an array of the available contenttypes.
getContenttypeTablename ( string | array $contenttype ) : string Get the tablename with prefix from a given Contenttype.
getEmptyContent ( $contenttypeslug )
getLatestId ( $contenttypeslug )
getPager ( string $name = null ) : array Getter of a pager element. Pager can hold a paging snapshot map.
getRepeaters ( $content )
getSortOrder ( string $name = '-datepublish' ) : string Get sorting order of name, stripping possible " DESC" " ASC" etc., and also return the sorting order.
getTablename ( string $name ) : string Get the table name with prefix from a given $name.
getTaxonomyType ( string $taxonomyslug ) : boolean | array Get the taxonomy as an array, based on the given $taxonomyslug.
getUri ( string $title, integer $id, string $contenttypeslug = "", boolean $fulluri = true, boolean $allowempty = true, boolean $slugfield = 'slug' ) : string Get a unique URL for a record
isEmptyPager ( ) : boolean
preFill ( array $contenttypes = [] ) : string Add some records with dummy content.
publishTimedRecords ( )
saveContent ( Content $content, string $comment = null ) : integer Save a record.
searchAllContentTypes ( array $parameters = [], &$pager = [] )
searchContent ( string $q, array $contenttypes = null, array $filters = null, integer $limit = 9999, integer $offset ) : mixed Search through actual content.
searchContentType ( $contenttypename, array $parameters = [], &$pager = [] )
setPager ( string $name, array | Bolt\Pager $pager ) : Storage Setter for pager storage element.
updateSingleValue ( string $contenttype, integer $id, string $field, mixed $value ) : boolean Update a single value from content.

Защищенные методы

Метод Описание
decodePageParameter ( string $context = '', array $inParameters = null ) : mixed Decodes contextual page number from current request url if found.
executeGetContentQueries ( array $decoded ) : array Execute the content queries.
executeGetContentSearch ( array $decoded, array $parameters ) : array Execute the content queries.
findContent ( string $tablename, integer $contentId ) : array Find record from Content Type and Content Id.
getOrderBys ( $order ) : array Get the ORDER BY parameters for the query.
getRelation ( array $content ) : array Get the relations for one or more units of content, return the array with the taxonomy attached.
getTaxonomy ( Content[] $content ) : array Get the taxonomy for one or more units of content, return the array with the taxonomy attached.
hasRecords ( $tablename )
insertContent ( Content $content, string $comment = null ) : boolean Insert a new contenttype record in the database.
isMultiOrderQuery ( $order ) : boolean Check if this query has multiple ORDER BY parameters.
isNotLastItemInArray ( $totalOrderByElements, $index ) : boolean Check if this is the last element in the array.
tableExists ( $name ) : boolean Check if the table $name exists. We use our own queries here, because it's _much_ faster than Doctrine's getSchemaManager().
updateRelation ( string $contenttype, integer $contentId, array $relation ) Update / insert relation for a given content-unit.
updateTaxonomy ( string $contenttype, integer $contentId, array $taxonomy ) Update / insert taxonomy for a given content-unit.

Приватные методы

Метод Описание
compareSearchWeights ( Content $a, Content $b ) : integer Compare by search weights.
decodeContentQuery ( string $textquery, array $inParameters = null ) : array Decode a content textquery
decodeContentTypesFromText ( string $text ) : array Decode a contenttypes argument from text.
decodeQueryOrder ( array $contenttype, string $orderValue ) : string Get the parameter for the 'order by' part of a query.
decodeSearchQuery ( $q ) Decode search query into searchable parts.
getBlocksTitle ( ) : string Get the title for a 'Block' contenttype. Check if the desired ones aren't present in the database yet, and return them in order.
getEscapedSortorder ( string $name, string $prefix = 'r' ) : string Get an escaped sortorder for use in SQL, from a fieldname like 'title' or '-id'.
getFieldName ( string $name ) : string Get field name, stripping possible " DESC" " ASC" etc.
getSomeRandomTags ( integer $num = 5 ) : string[] Get an array of random tags
getValidSaveData ( array $fieldvalues, array $contenttype ) : array Get a valid array to commit.
groupingSort ( Content $a, Content $b ) : integer Helper function for sorting Records of content that have a Grouping.
hydrateRows ( array | string $contenttype, array $rows, boolean $getTaxoAndRel = true ) : array Hydrate database rows into objects.
isValidColumn ( string $name, array $contenttype, boolean $allowVariants = false ) : boolean Check if a given name is a valid column, and if it can be used in queries.
logDelete ( string $contenttype, integer $contentid, array $content, string $comment = null ) Writes a content-changelog entry for a deleted entry.
logInsert ( string $contenttype, integer $contentid, array $content, string $comment = null ) Writes a content-changelog entry for a newly-created entry.
logUpdate ( string $contenttype, integer $contentid, array $newContent, array $oldContent = null, string $comment = null ) Writes a content-changelog entry for an updated entry.
organizeQueryParameters ( array | string | null $inParameters = null ) : array Split into meta-parameters and contenttype parameters.
parseTextQuery ( $textquery, array &$decoded, array &$metaParameters, array &$ctypeParameters ) Parse textquery into useable arguments.
parseWhereParameter ( string $key, string $value, mixed $fieldtype = false ) : string Helper function to set the proper 'where' parameter, when getting values like '<2012' or '!bob'.
preFillSingle ( string $key, array $contenttype, array $images ) : string Add a record with dummy content.
prepareDecodedQueryForUse ( &$decoded, &$metaParameters, &$ctypeParameters ) Prepare decoded for actual use.
runContentTypeTableChecks ( array $contenttypes ) : boolean Check for the existence of ContentType tables.
searchSingleContentType ( $query, $contenttype, $fields, array $filter = null, boolean $implode = false ) : Content Search through a single contenttype.
updateContent ( Content $content, string $comment = null ) : boolean Update a Bolt contenttype record.

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

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

public __construct ( Silex\Application $app )
$app Silex\Application

decodePageParameter() защищенный Метод

Decodes contextual page number from current request url if found.
Устаревший: Not used in core anymore
protected decodePageParameter ( string $context = '', array $inParameters = null ) : mixed
$context string Pager id/name in url which value we find
$inParameters array
Результат mixed Page number in context

deleteContent() публичный Метод

Delete a record.
public deleteContent ( string $contenttype, integer $id ) : integer
$contenttype string
$id integer
Результат integer The number of affected rows.

depublishExpiredRecords() публичный Метод

См. также: Bolt\Storage\EventProcessor\TimedRecord::holdExpiredRecords()
Устаревший: Deprecated since 3.0, to be removed in 4.0.

executeGetContentQueries() защищенный Метод

This is tightly coupled to $this->getContent()
protected executeGetContentQueries ( array $decoded ) : array
$decoded array
Результат array

executeGetContentSearch() защищенный Метод

This is tightly coupled to $this->getContent()
protected executeGetContentSearch ( array $decoded, array $parameters ) : array
$decoded array
$parameters array
Результат array

findContent() защищенный Метод

Find record from Content Type and Content Id.
protected findContent ( string $tablename, integer $contentId ) : array
$tablename string Table name
$contentId integer Content Id
Результат array

getContent() публичный Метод

Used directly by {% setcontent %} but also in other parts. This code has been split into multiple methods in the spirit of separation of concerns, but the situation is still far from ideal. Where applicable each 'concern' notes the coupling in the local documentation.
public getContent ( string $textquery, string $parameters = '', array &$pager = [], array $whereparameters = [] ) : array
$textquery string
$parameters string
$pager array
$whereparameters array
Результат array

getContentByTaxonomy() публичный Метод

Note: we can NOT sort on anything meaningful. Records are fetched from multiple content-types, so we can not do joins. Neither can we sort after fetching, because it would mean fetching _all_ records and _then_ doing the sorting. Instead, we do not sort here. If you need ordering, use the '|order()' in your templates.
public getContentByTaxonomy ( string $taxonomyslug, string $name, string $parameters = [] ) : array
$taxonomyslug string
$name string
$parameters string
Результат array

getContentObject() публичный Метод

Get an object for the content of a specific contenttype. This will be \Bolt\Legacy\Content, unless the contenttype defined another class to be used.
public getContentObject ( array | string $contenttype, array $values = [] ) : Content
$contenttype array | string
$values array
Результат Content

getContentType() публичный Метод

Get the contenttype as an array, based on the given $contenttypeslug.
public getContentType ( string $contenttypeslug ) : boolean | array
$contenttypeslug string
Результат boolean | array

getContentTypeFieldType() публичный Метод

Get the fieldtype for a given contenttype and fieldname.
public getContentTypeFieldType ( string $contenttypeslug, string $fieldname ) : array
$contenttypeslug string
$fieldname string
Результат array $fields

getContentTypeFields() публичный Метод

Get an array of the available fields for a given contenttype.
public getContentTypeFields ( string $contenttypeslug ) : array
$contenttypeslug string
Результат array $fields

getContentTypeGrouping() публичный Метод

Check if a given contenttype has a grouping, and if it does, return it.
public getContentTypeGrouping ( string $contenttypeslug ) : mixed
$contenttypeslug string
Результат mixed $grouping

getContentTypeTaxonomy() публичный Метод

Get an array of the available taxonomytypes for a given contenttype.
public getContentTypeTaxonomy ( string $contenttypeslug ) : array
$contenttypeslug string
Результат array $taxonomy

getContentTypes() публичный Метод

Get an array of the available contenttypes.
public getContentTypes ( ) : array
Результат array $contenttypes

getContenttypeTablename() публичный Метод

Get the tablename with prefix from a given Contenttype.
public getContenttypeTablename ( string | array $contenttype ) : string
$contenttype string | array
Результат string

getEmptyContent() публичный Метод

public getEmptyContent ( $contenttypeslug )

getLatestId() публичный Метод

public getLatestId ( $contenttypeslug )

getOrderBys() защищенный Метод

Get the ORDER BY parameters for the query.
protected getOrderBys ( $order ) : array
$order
Результат array

getPager() публичный Метод

Getter of a pager element. Pager can hold a paging snapshot map.
Устаревший: Just for keep BC
public getPager ( string $name = null ) : array
$name string Optional name of a pager element. Whole pager map returns if no name given.
Результат array

getRelation() защищенный Метод

Get the relations for one or more units of content, return the array with the taxonomy attached.
protected getRelation ( array $content ) : array
$content array
Результат array $content

getRepeaters() публичный Метод

public getRepeaters ( $content )

getSortOrder() публичный Метод

Get sorting order of name, stripping possible " DESC" " ASC" etc., and also return the sorting order.
public getSortOrder ( string $name = '-datepublish' ) : string
$name string
Результат string

getTablename() публичный Метод

Get the table name with prefix from a given $name.
public getTablename ( string $name ) : string
$name string
Результат string

getTaxonomy() защищенный Метод

Get the taxonomy for one or more units of content, return the array with the taxonomy attached.
protected getTaxonomy ( Content[] $content ) : array
$content Content[]
Результат array $content

getTaxonomyType() публичный Метод

Get the taxonomy as an array, based on the given $taxonomyslug.
public getTaxonomyType ( string $taxonomyslug ) : boolean | array
$taxonomyslug string
Результат boolean | array

getUri() публичный Метод

Get a unique URL for a record
public getUri ( string $title, integer $id, string $contenttypeslug = "", boolean $fulluri = true, boolean $allowempty = true, boolean $slugfield = 'slug' ) : string
$title string
$id integer
$contenttypeslug string
$fulluri boolean
$allowempty boolean
$slugfield boolean
Результат string

hasRecords() защищенный Метод

protected hasRecords ( $tablename )

insertContent() защищенный Метод

Insert a new contenttype record in the database.
protected insertContent ( Content $content, string $comment = null ) : boolean
$content Content Record content to insert
$comment string Editor's comment
Результат boolean

isEmptyPager() публичный Метод

public isEmptyPager ( ) : boolean
Результат boolean

isMultiOrderQuery() защищенный Метод

Check if this query has multiple ORDER BY parameters.
protected isMultiOrderQuery ( $order ) : boolean
$order
Результат boolean

isNotLastItemInArray() защищенный Метод

Check if this is the last element in the array.
protected isNotLastItemInArray ( $totalOrderByElements, $index ) : boolean
$totalOrderByElements
$index
Результат boolean

preFill() публичный Метод

Only fill the contenttypes passed as parameters If the parameters is empty, only fill empty tables
См. также: preFillSingle
public preFill ( array $contenttypes = [] ) : string
$contenttypes array
Результат string

publishTimedRecords() публичный Метод

См. также: Bolt\Storage\EventProcessor\TimedRecord::publishTimedRecords()
Устаревший: Deprecated since 3.0, to be removed in 4.0.
public publishTimedRecords ( )

saveContent() публичный Метод

Save a record.
public saveContent ( Content $content, string $comment = null ) : integer
$content Content
$comment string
Результат integer

searchAllContentTypes() публичный Метод

public searchAllContentTypes ( array $parameters = [], &$pager = [] )
$parameters array

searchContent() публичный Метод

Unless the query is invalid it will always return a 'result array'. It may complain in the log but it won't abort.
public searchContent ( string $q, array $contenttypes = null, array $filters = null, integer $limit = 9999, integer $offset ) : mixed
$q string Search string
$contenttypes array Contenttype names to search for: - string: Specific contenttype - null: Every searchable contenttype
$filters array Additional filters for contenttypes - key is contenttype - value is filter
$limit integer limit the number of results
$offset integer skip this number of results
Результат mixed false if query is invalid, an array with results if query was executed

searchContentType() публичный Метод

public searchContentType ( $contenttypename, array $parameters = [], &$pager = [] )
$parameters array

setPager() публичный Метод

Setter for pager storage element.
Устаревший: Just for keep BC
public setPager ( string $name, array | Bolt\Pager $pager ) : Storage
$name string
$pager array | Bolt\Pager
Результат Storage

tableExists() защищенный Метод

Check if the table $name exists. We use our own queries here, because it's _much_ faster than Doctrine's getSchemaManager().
protected tableExists ( $name ) : boolean
$name
Результат boolean

updateRelation() защищенный Метод

$relation looks like: arr(2) [ "pages" => arr(1) [ 0 => str(2) "22" ] "showcases" => arr(3) [ 0 => str(2) "15" 1 => str(1) "9" 2 => str(2) "13" ] ] $currentvalues looks like arr(2) [ 0 => arr(3) [ "id" => str(1) "5" "to_contenttype" => str(12) "showcases" "to_id" => str(2) "15" ] 1 => arr(3) [ "id" => str(1) "6" "to_contenttype" => str(12) "showcases" "to_id" => str(1) "9" ] ]
protected updateRelation ( string $contenttype, integer $contentId, array $relation )
$contenttype string
$contentId integer
$relation array

updateSingleValue() публичный Метод

It is called in list of contents.
public updateSingleValue ( string $contenttype, integer $id, string $field, mixed $value ) : boolean
$contenttype string Content Type to be edited.
$id integer Id of content to be updated.
$field string Field name of content to be changed.
$value mixed New value to be defined on field.
Результат boolean Returns true when update is done or false if not.

updateTaxonomy() защищенный Метод

Update / insert taxonomy for a given content-unit.
protected updateTaxonomy ( string $contenttype, integer $contentId, array $taxonomy )
$contenttype string
$contentId integer
$taxonomy array

Описание свойств

$images публичное свойство

public array $images
Результат array