Structure
in package
implements
IStructure
Uses
UtilsProvider
This class handles all hooks and functions for the structure.
If something will print out, this is a facade-wrapper function for the class View (stored in private $view).
Table of Contents
Interfaces
- IStructure
- Structure implementation for Real Media Library. It handles all SQL query which reads all folders from the database and "collects" it into one tree. You can modify the structure queries by RML/Tree* filters and extending the MatthiasWeb\RealMediaLibrary\attachment\Structure class (implements IStructure).
Properties
- $blogs : mixed
- The structure should be accessible within one or more blogs. For those purposes use the wp standard method switch_to_blog();
- $data : mixed
- Additional data passed to the structure.
- $hasInitialLoad : mixed
- Checks, if the folder tree is already loaded and do the initial load if needed by an function. So, RML can guarantee lazy loading.
- $parsed : mixed
- $root : mixed
- The root folder ID. Can only be set by the constructor!
- $rows : mixed
- Array of database read rows
- $tree : mixed
- $view : mixed
- The view handler for this structure
Methods
- __construct() : mixed
- Start reading a structure. If you pass a $root parameter the parameter is not automatically respected. You should then use your own implementation or filters to respect the root. Use this constructor to add your filters and respect your custom Structure class implementation.
- byAbsolutePath() : IFolder|null
- Get a folder by absolute path.
- byId() : IFolder|null
- Get a folder by id.
- getCntAttachments() : int
- Get the attachment count for this structure.
- getCntRoot() : int
- Get the attachment count for the "Unorganized" folder for this structure.
- getData() : array<string|int, mixed>
- Get the custom data.
- getFolderCounts() : array<string|int, int>
- Get all folder counts.
- getInstance() : Structure
- Get instance.
- getParsed() : array<string|int, IFolder>
- Get all SQL query results as IFolder objects.
- getPlainTree() : array<string|int, object>
- Get all SQL query results placed to a tree. It is fully resolved with all hierarchical plain objects of the folders expect the invisible nodes.
- getPluginConstantPrefix() : string
- Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
- getRows() : array<string|int, object>
- Get the SQL query result instead of IFolder objects.
- getTree() : array<string|int, IFolder>
- Get all SQL query results placed to a tree. That means it is a "hierarchical" result where you work with ->getChildren(). The first level contains the top folders.
- getView() : mixed
- Get the view class instance.
- initialLoad() : mixed
- Checks, if the SQL result is available and load it if not.
- resetData() : mixed
- Resets the data of the structure.
- setData() : mixed
- Set the custom data.
- fetch() : mixed
- Fetching all available folders into an array.
- parse() : mixed
- This functions parses the read rows into folder objects.
Properties
$blogs
The structure should be accessible within one or more blogs. For those purposes use the wp standard method switch_to_blog();
private
static mixed
$blogs
= []
This is an array of Structure objects.
$data
Additional data passed to the structure.
private
mixed
$data
$hasInitialLoad
Checks, if the folder tree is already loaded and do the initial load if needed by an function. So, RML can guarantee lazy loading.
private
mixed
$hasInitialLoad
= false
$parsed
private
mixed
$parsed
$root
The root folder ID. Can only be set by the constructor!
private
mixed
$root
$rows
Array of database read rows
private
mixed
$rows
$tree
private
mixed
$tree
$view
The view handler for this structure
private
mixed
$view
Methods
__construct()
Start reading a structure. If you pass a $root parameter the parameter is not automatically respected. You should then use your own implementation or filters to respect the root. Use this constructor to add your filters and respect your custom Structure class implementation.
public
__construct([mixed $root = null ][, mixed $data = null ]) : mixed
Parameters
- $root : mixed = null
-
The root folder defined for the structure
- $data : mixed = null
-
Custom data for the structure
byAbsolutePath()
Get a folder by absolute path.
public
byAbsolutePath(mixed $path) : IFolder|null
Parameters
- $path : mixed
-
The path
Return values
IFolder|nullbyId()
Get a folder by id.
public
byId(mixed $id[, mixed $nullForRoot = true ]) : IFolder|null
Parameters
- $id : mixed
-
The id of the folder
- $nullForRoot : mixed = true
-
If set to false and $id == -1 then the Root instance is returned
Return values
IFolder|nullgetCntAttachments()
Get the attachment count for this structure.
public
getCntAttachments() : int
Return values
int —Count
getCntRoot()
Get the attachment count for the "Unorganized" folder for this structure.
public
getCntRoot() : int
Return values
int —Count
getData()
Get the custom data.
public
getData() : array<string|int, mixed>
Return values
array<string|int, mixed> —Data
getFolderCounts()
Get all folder counts.
public
getFolderCounts() : array<string|int, int>
Return values
array<string|int, int>getInstance()
Get instance.
public
static getInstance() : Structure
Return values
StructuregetParsed()
Get all SQL query results as IFolder objects.
public
getParsed() : array<string|int, IFolder>
Return values
array<string|int, IFolder> —The folders
getPlainTree()
Get all SQL query results placed to a tree. It is fully resolved with all hierarchical plain objects of the folders expect the invisible nodes.
public
getPlainTree() : array<string|int, object>
Return values
array<string|int, object>getPluginConstantPrefix()
Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
public
getPluginConstantPrefix() : string
Tags
Return values
stringgetRows()
Get the SQL query result instead of IFolder objects.
public
getRows() : array<string|int, object>
Return values
array<string|int, object> —The SQL result
getTree()
Get all SQL query results placed to a tree. That means it is a "hierarchical" result where you work with ->getChildren(). The first level contains the top folders.
public
getTree() : array<string|int, IFolder>
Return values
array<string|int, IFolder> —The folders
getView()
Get the view class instance.
public
getView() : mixed
initialLoad()
Checks, if the SQL result is available and load it if not.
public
initialLoad() : mixed
resetData()
Resets the data of the structure.
public
resetData([mixed $root = null ][, mixed $fetchData = true ]) : mixed
Parameters
- $root : mixed = null
-
The root folder
- $fetchData : mixed = true
-
Determine, if the data should be re-fetched
setData()
Set the custom data.
public
setData(mixed $data) : mixed
Parameters
- $data : mixed
-
The custom data
fetch()
Fetching all available folders into an array.
private
fetch() : mixed
parse()
This functions parses the read rows into folder objects.
private
parse() : mixed
It also handles the cnt
cache for the attachments in this folder.