public class EntryManager

class.entrymanager.php #19

The EntryManager is responsible for all Entry objects in Symphony. Entries are stored in the database in a cluster of tables. There is a parent entry row stored in tbl_entries and then each field's data is stored in a separate table, tbl_entries_data_{field_id}. Where Field ID is generated when the Section is saved. This Manager provides basic add, edit, delete and fetching methods for Entries.

Properties

FieldManager $fieldManager

An instance of the FieldManager

TextFormatterManager $formatterManager

An instance of the TextFormatterManager

SectionManager $sectionManager

An instance of the SectionManager

Methods

array __buildEntries(array $rows, integer $section_id, array $element_names)

Given an array of Entry data from tbl_entries and a section ID, return an array of Entry objects. For performance reasons, it's possible to pass an array of field handles via $element_names, so that only a subset of the section schema will be queried. This function currently only supports Entry from one section at a time.

Parameters
  • $rows arrayAn array of Entry data from tbl_entries including the Entry ID, Entry section, the ID of the Author who created the Entry, and a Unix timestamp of creation

  • $section_id integerThe section ID of the entries in the $rows

  • $element_names arrayChoose whether to get data from a subset of fields or all fields in a section, by providing an array of field names. Defaults to null, which will load data from all fields in a section.

Returns

An array of Entry objects

void __construct(Administration $parent)

The constructor initialises the formatterManager, sectionManager and fieldManager variables and sets the $this->_Parent to the param provided.

Parameters
  • $parent AdministrationThe Administration object that this page has been created from passed by reference

boolean add(Entry $entry)

Given an Entry object, iterate over all of the fields in that object an insert them into their relevant entry tables.

Parameters
  • $entry EntryAn Entry object to insert into the database

Entry create()

Creates a new Entry object using this class as the parent.

boolean delete(array|integer $entries, integer $section_id)

Given an Entry ID, or an array of Entry ID's, delete all data associated with this Entry using a Field's entryDataCleanup() function, and then remove this Entry from tbl_entries. If the $entries all belong to the same section, passing $section_id will improve performance

Parameters
  • $entries array|integerAn entry_id, or an array of entry id's to delete

  • $section_id integer(optional) If possible, the $section_id of the the $entries. This parameter should be left as null if the $entries array contains entry_id's for multiple sections.

boolean edit(Entry $entry)

Update an existing Entry object given an Entry object

Parameters
  • $entry EntryAn Entry object

array fetch(integer|array $entry_id, integer $section_id, integer $limit, integer $start, string $where, string $joins, boolean $group, boolean $buildentries, array $element_names, boolean $enable_sort, boolean $records_only)

This function will return an array of Entry objects given an ID or an array of ID's. Do not provide $entry_id as an array if not specifying the $section_id. This function is commonly passed custom SQL statements through the $where and $join parameters that is generated by the fields of this section

Parameters
  • $entry_id integer|arrayAn array of Entry ID's or an Entry ID to return

  • $section_id integerThe ID of the Section that these entries are contained in

  • $limit integerThe limit of entries to return

  • $start integerThe starting offset of the entries to return

  • $where stringAny custom WHERE clauses

  • $joins stringAny custom JOIN's

  • $group booleanWhether the entries need to be grouped by Entry ID or not

  • $records_only booleanIf this is set to true, an array of Entry objects will be returned without any basic pagination information. Defaults to false

  • $buildentries booleanWhether to return an array of entry ID's or Entry objects. Defaults to true, which will return Entry objects

  • $element_names arrayChoose whether to get data from a subset of fields or all fields in a section, by providing an array of field names. Defaults to null, which will load data from all fields in a section.

  • $enable_sort booleanDefaults to true, if false this function will not apply any sorting

Returns

If $buildentries is true, this function will return an array of Entry objects, otherwise it will return an associative array of Entry data from tbl_entries

array fetchByPage(integer $page, integer $section_id, integer $entriesPerPage, string $where, string $joins, boolean $group, boolean $records_only, boolean $buildentries, array $element_names)

Returns an array of Entry objects, with some basic pagination given the number of Entry's to return and the current starting offset. This function in turn calls the fetch function that does alot of the heavy lifting. For instance, if there are 60 entries in a section and the pagination dictates that per page, 15 entries are to be returned, by passing 2 to the $page parameter you could return entries 15-30

Parameters
  • $page integerThe page to return, defaults to 1

  • $section_id integerThe ID of the Section that these entries are contained in

  • $entriesPerPage integerThe number of entries to return per page.

  • $where stringAny custom WHERE clauses

  • $joins stringAny custom JOIN's

  • $group booleanWhether the entries need to be grouped by Entry ID or not

  • $records_only booleanIf this is set to true, an array of Entry objects will be returned without any basic pagination information. Defaults to false

  • $buildentries booleanWhether to return an array of entry ID's or Entry objects. Defaults to true, which will return Entry objects

  • $element_names arrayChoose whether to get data from a subset of fields or all fields in a section, by providing an array of field names. Defaults to null, which will load data from all fields in a section.

Returns

Either an array of Entry objects, or an associative array containing the total entries, the start position, the entries per page and the Entry objects

integer fetchCount(integer $section_id, string $where, string $joins, boolean $group)

Return the count of the number of entries in a particular section.

Parameters
  • $section_id integerThe ID of the Section where the Entries are to be counted

  • $where stringAny custom WHERE clauses

  • $joins stringAny custom JOIN's

  • $group booleanWhether the entries need to be grouped by Entry ID or not

integer fetchEntrySectionID(integer $entry_id)

Given an Entry ID, return the Section ID that it belongs to

Parameters
  • $entry_id integerThe ID of the Entry to return it's section

Returns

The Section ID for this Entry's section

StdClass getFetchSorting()

Returns an object representation of the sorting for the EntryManager, with the field and direction provided

void setFetchSorting(integer $field_id, string $direction)

Convenience function that will set sorting field and direction by calling setFetchSortingField() & setFetchSortingDirection()

Parameters
  • $field_id integerThe ID of the Field that should be sorted on

  • $direction stringThe direction that entries should be sorted in, available options are RAND, ASC or DESC. Defaults to ASC

See Also
void setFetchSortingDirection(string $direction)

Setter function for the default sorting direction of the Fetch function. Available options are RAND, ASC or DESC.

Parameters
  • $direction stringThe direction that entries should be sorted in, available options are RAND, ASC or DESC.

void setFetchSortingField(integer $field_id)

Sets the field to applying the sorting direction on when fetching entries

Parameters
  • $field_id integerThe ID of the Field that should be sorted on

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details