PHP Class Bolt\Legacy\Storage

Deprecation: Deprecated since 3.0, to be removed in 4.0.
Afficher le fichier Open project: bolt/bolt Class Usage Examples

Méthodes publiques

Свойство Type Description
$images array

Méthodes publiques

Méthode Description
__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.

Méthodes protégées

Méthode Description
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.

Private Methods

Méthode Description
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.

Method Details

__construct() public méthode

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

decodePageParameter() protected méthode

Decodes contextual page number from current request url if found.
Deprecation: 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
Résultat mixed Page number in context

deleteContent() public méthode

Delete a record.
public deleteContent ( string $contenttype, integer $id ) : integer
$contenttype string
$id integer
Résultat integer The number of affected rows.

depublishExpiredRecords() public méthode

See also: Bolt\Storage\EventProcessor\TimedRecord::holdExpiredRecords()
Deprecation: Deprecated since 3.0, to be removed in 4.0.

executeGetContentQueries() protected méthode

This is tightly coupled to $this->getContent()
protected executeGetContentQueries ( array $decoded ) : array
$decoded array
Résultat array

executeGetContentSearch() protected méthode

This is tightly coupled to $this->getContent()
protected executeGetContentSearch ( array $decoded, array $parameters ) : array
$decoded array
$parameters array
Résultat array

findContent() protected méthode

Find record from Content Type and Content Id.
protected findContent ( string $tablename, integer $contentId ) : array
$tablename string Table name
$contentId integer Content Id
Résultat array

getContent() public méthode

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
Résultat array

getContentByTaxonomy() public méthode

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
Résultat array

getContentObject() public méthode

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
Résultat Content

getContentType() public méthode

Get the contenttype as an array, based on the given $contenttypeslug.
public getContentType ( string $contenttypeslug ) : boolean | array
$contenttypeslug string
Résultat boolean | array

getContentTypeFieldType() public méthode

Get the fieldtype for a given contenttype and fieldname.
public getContentTypeFieldType ( string $contenttypeslug, string $fieldname ) : array
$contenttypeslug string
$fieldname string
Résultat array $fields

getContentTypeFields() public méthode

Get an array of the available fields for a given contenttype.
public getContentTypeFields ( string $contenttypeslug ) : array
$contenttypeslug string
Résultat array $fields

getContentTypeGrouping() public méthode

Check if a given contenttype has a grouping, and if it does, return it.
public getContentTypeGrouping ( string $contenttypeslug ) : mixed
$contenttypeslug string
Résultat mixed $grouping

getContentTypeTaxonomy() public méthode

Get an array of the available taxonomytypes for a given contenttype.
public getContentTypeTaxonomy ( string $contenttypeslug ) : array
$contenttypeslug string
Résultat array $taxonomy

getContentTypes() public méthode

Get an array of the available contenttypes.
public getContentTypes ( ) : array
Résultat array $contenttypes

getContenttypeTablename() public méthode

Get the tablename with prefix from a given Contenttype.
public getContenttypeTablename ( string | array $contenttype ) : string
$contenttype string | array
Résultat string

getEmptyContent() public méthode

public getEmptyContent ( $contenttypeslug )

getLatestId() public méthode

public getLatestId ( $contenttypeslug )

getOrderBys() protected méthode

Get the ORDER BY parameters for the query.
protected getOrderBys ( $order ) : array
$order
Résultat array

getPager() public méthode

Getter of a pager element. Pager can hold a paging snapshot map.
Deprecation: 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.
Résultat array

getRelation() protected méthode

Get the relations for one or more units of content, return the array with the taxonomy attached.
protected getRelation ( array $content ) : array
$content array
Résultat array $content

getRepeaters() public méthode

public getRepeaters ( $content )

getSortOrder() public méthode

Get sorting order of name, stripping possible " DESC" " ASC" etc., and also return the sorting order.
public getSortOrder ( string $name = '-datepublish' ) : string
$name string
Résultat string

getTablename() public méthode

Get the table name with prefix from a given $name.
public getTablename ( string $name ) : string
$name string
Résultat string

getTaxonomy() protected méthode

Get the taxonomy for one or more units of content, return the array with the taxonomy attached.
protected getTaxonomy ( Content[] $content ) : array
$content Content[]
Résultat array $content

getTaxonomyType() public méthode

Get the taxonomy as an array, based on the given $taxonomyslug.
public getTaxonomyType ( string $taxonomyslug ) : boolean | array
$taxonomyslug string
Résultat boolean | array

getUri() public méthode

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
Résultat string

hasRecords() protected méthode

protected hasRecords ( $tablename )

insertContent() protected méthode

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
Résultat boolean

isEmptyPager() public méthode

public isEmptyPager ( ) : boolean
Résultat boolean

isMultiOrderQuery() protected méthode

Check if this query has multiple ORDER BY parameters.
protected isMultiOrderQuery ( $order ) : boolean
$order
Résultat boolean

isNotLastItemInArray() protected méthode

Check if this is the last element in the array.
protected isNotLastItemInArray ( $totalOrderByElements, $index ) : boolean
$totalOrderByElements
$index
Résultat boolean

preFill() public méthode

Only fill the contenttypes passed as parameters If the parameters is empty, only fill empty tables
See also: preFillSingle
public preFill ( array $contenttypes = [] ) : string
$contenttypes array
Résultat string

publishTimedRecords() public méthode

See also: Bolt\Storage\EventProcessor\TimedRecord::publishTimedRecords()
Deprecation: Deprecated since 3.0, to be removed in 4.0.
public publishTimedRecords ( )

saveContent() public méthode

Save a record.
public saveContent ( Content $content, string $comment = null ) : integer
$content Content
$comment string
Résultat integer

searchAllContentTypes() public méthode

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

searchContent() public méthode

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
Résultat mixed false if query is invalid, an array with results if query was executed

searchContentType() public méthode

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

setPager() public méthode

Setter for pager storage element.
Deprecation: Just for keep BC
public setPager ( string $name, array | Bolt\Pager $pager ) : Storage
$name string
$pager array | Bolt\Pager
Résultat Storage

tableExists() protected méthode

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
Résultat boolean

updateRelation() protected méthode

$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() public méthode

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.
Résultat boolean Returns true when update is done or false if not.

updateTaxonomy() protected méthode

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

Property Details

$images public_oe property

public array $images
Résultat array