RoomRepository extends AbstractPostRepository
in package

Table of Contents

$items  : mixed
$persistence  : CPTPersistence
$type  : mixed
__construct()  : mixed
delete()  : int
findAll()  : mixed
findAllByRoomType()  : mixed
findById()  : Room
findByMeta()  : mixed
findOne()  : mixed
generateRooms()  : bool
getAvailableRooms()  : array<string|int, mixed>
getBookedDays()  : array<string|int, mixed>
getIdTitleList()  : mixed
getLockedRooms()  : array<string|int, int>
mapEntityToPostData()  : WPPostData
mapPostToEntity()  : mixed
persistence()  : CPTPersistence
save()  : int
mapPostsToEntity()  : mixed

Properties

$items

protected mixed $items = array()

$persistence

protected CPTPersistence $persistence

$type

protected mixed $type = 'room'

Methods

__construct()

public __construct(CPTPersistence $persistence) : mixed
Parameters
$persistence : CPTPersistence
Return values
mixed

delete()

public delete(type $entity) : int
Parameters
$entity : type
Return values
int

Id of deleted entity. 0 on failure.

findAll()

public findAll([mixed $atts = array() ]) : mixed
Parameters
$atts : mixed = array()
Return values
mixed

findAllByRoomType()

public findAllByRoomType(mixed $roomTypeId[, mixed $atts = array() ]) : mixed
Parameters
$roomTypeId : mixed
$atts : mixed = array()
Return values
mixed

findById()

public findById(int $id[, bool $force = false ]) : Room
Parameters
$id : int
$force : bool = false
Return values
Room

findByMeta()

public findByMeta(string $key, mixed $value) : mixed
Parameters
$key : string
$value : mixed
Return values
mixed

TODO Bug: will find the latest entity with the right meta_key and null meta_value; with a wrong meta_key will return null.

findOne()

public findOne([mixed $atts = array() ]) : mixed
Parameters
$atts : mixed = array()
Return values
mixed

generateRooms()

public generateRooms(RoomType $roomType[, int $count = 1 ][, string $customPrefix = '' ]) : bool
Parameters
$roomType : RoomType
$count : int = 1

Optional. Number of rooms to generate. Default 1.

$customPrefix : string = ''

Optional. Default ''

Return values
bool

getAvailableRooms()

public getAvailableRooms(DateTime $checkInDate, DateTime $checkOutDate, type $roomTypeId[, mixed $atts = array() ]) : array<string|int, mixed>
Parameters
$checkInDate : DateTime
$checkOutDate : DateTime
$roomTypeId : type

Optional. 0 by default.

$atts : mixed = array()
Tags
global

\wpdb $wpdb

since
3.8

added new argument $atts and parameter "exclude_bookings".

Return values
array<string|int, mixed>

[%Room type ID% => [%Rooms IDs%]] Will always return original IDs because of direct query to the DB.

getBookedDays()

public getBookedDays(int $roomTypeId) : array<string|int, mixed>
Parameters
$roomTypeId : int
Return values
array<string|int, mixed>

Keys are dates in format Y-m-d, values are room counts

getIdTitleList()

public getIdTitleList([mixed $atts = array() ]) : mixed
Parameters
$atts : mixed = array()
Tags
since
3.7.1
Return values
mixed

getLockedRooms()

public getLockedRooms(DateTime $checkInDate, DateTime $checkOutDate, int $roomTypeId[, array<string|int, mixed> $atts = array() ]) : array<string|int, int>
Parameters
$checkInDate : DateTime
$checkOutDate : DateTime
$roomTypeId : int
$atts : array<string|int, mixed> = array()

Optional. @param int|int[] $atts['exclude_bookings']

Tags
since
3.8

added new argument $atts and parameter "exclude_bookings".

Return values
array<string|int, int>

IDs of locked rooms. Will always return original IDs because of direct query to the DB.

mapEntityToPostData()

public mapEntityToPostData(Room $entity) : WPPostData
Parameters
$entity : Room
Return values
WPPostData

mapPostToEntity()

public mapPostToEntity(mixed $post) : mixed
Parameters
$post : mixed
Return values
mixed

persistence()

public persistence() : CPTPersistence
Tags
since
3.7.2
Return values
CPTPersistence

save()

public save(type &$entity) : int
Parameters
$entity : type
Return values
int

mapPostsToEntity()

protected mapPostsToEntity(mixed $posts) : mixed
Parameters
$posts : mixed
Return values
mixed

Search results