ItemType

class ItemType

Package: Record

An item type and its metadata.

property name
property description
property _elementsToSave
property _elementsToRemove
getElements()

Returns an array of element objects associated with this item type.

Returns:array The array of element objects associated with this item type.
getItems(int $count = 10, boolean $recent = 1)

Returns an array of item objects that have this item type.

Parameters:
  • $count (int) – The maximum number of items to return.
  • $recent (boolean) – Whether or not the items are recent.
Returns:

array The items associated with the item type.

_validate()

Current validation rules for Type

  1. ‘Name’ field can’t be blank2) ‘Name’ field must be unique
Returns:void
filterPostData($post)

Filter incoming POST data from ItemType form.

Parameters:
  • $post (unknown) –
Returns:

void

_delete()

Delete all the ItemTypesElements joins

Returns:void
afterSave($args)

Save Element records that are associated with this Item Type.

Parameters:
  • $args (unknown) –
Returns:

void

reorderElements(Array $elementOrderingArray)

This extracts the ordering for the elements from the form’s POST, then uses the given ordering to reorder each join record from item_types_elements into a new ordering, which is then saved.

Parameters:
  • $elementOrderingArray (Array) – An array of element_id => order pairs
Returns:

void

addElements(array $elements = Array)

Add a set of elements to the Item Type.

Parameters:
  • $elements (array) – Either an array of elements or an array of metadata, where each entry corresponds to a new element to add to the item type. If an element exists with the same id, it will replace the old element with the new element.
Returns:

void

addElementById($elementId)

Adds a new element to the item type by the id of the element

Parameters:
  • $elementId (unknown) –
Returns:

void

removeElements(Array $elements)

Removes an array of Elements from this item type The element will not be removed until the object is saved.

Parameters:
  • $elements (Array) – An array of Element objects or element id strings
Returns:

void

removeElement(Element|string $element)

Remove a single Element from this item type. The element will not be removed until the object is saved.

Parameters:
  • $element (Element|string) – The element object or the element id.
Returns:

void

_removeElement(Element|string $element)

Removes a single Element from this item type. It removes it immediately.

Parameters:
  • $element (Element|string) –
Returns:

void

hasElement(Element|string $element)

Determines whether a saved version of the item type has an element. It does not correctly determine the presence of elements that were added or removed without saving the item type object.

Parameters:
  • $element (Element|string) – The element object or the element id.
Returns:

boolean

totalItems()

Determines the total number of items that have this item type.

Returns:int The total number of items that have this item type.
getItemTypeElementSet()

Returns the ‘Item Type’ element set.

Returns:ElementSet