include/DashletContainer/DCMetaDataParser.php

Show: inherited
Table of Contents

\DCMetaDataParser

Package: SugarCRM

DCMetaDataParser handles both the loading and saving of meta-data for Dashlet Containers.

It also provides the API for adding and removing Dashlets from a layout. Since all Dashlet Containers use the same Meta-Data it is in the interest of uniformity to keep this class separate. Think of this meta-data as the master list. This meta-data DOES NOT handle specifics on layout positioning of Dashlets. It just handles which Dashlets should be rendered. Layout Positioning is handled by each Dashlet Container Layout on an individual basis and is not common between Dashlet Container Layouts.

Api
 
Author
mitani  

Properties

Propertyprivatestring  $filePath= 'null'

file path to the original meta-data loaded

Default valuenullDetails
Type
string
Propertyprivatebool  $isDirty= 'false'

should the save occur

Default valuefalseDetails
Type
bool

Methods

methodpublic__construct( string $filePath ) : void

Constructor takes in a file path and loads the appropriate meta-data

Parameters
Name Type Description
$filePath string
Throws
Exception Description
\FileNotFound and InvalidMetaData errors
methodpublicaddDashlet( \$dashletID $dashletID, \$group $group, \$position $position ) : bool

This function will add a dashlet to the provided files meta-data based given a dashlet id specifiying the dashlet to add, the group id specifying the group to add it to, and the position within the group to place it in.

This function will be called in conjunction with addDashlet in the Dashlet Container Layout (DCL) with the DCL handling layout specific positioning of a dashlet.

Parameters
Name Type Description
$dashletID \$dashletID
  • id of the dashlet (not the instance id of the dashlet)
$group \$group
  • group it should be added to
$position \$position
  • position in the group
Returns
Type Description
bool - success or failure of add
methodpublicgetDashlets( ) : \unknown_type

Returns the metadata of the dashlets defined

Returns
Type Description
\unknown_type
methodpublicgetPages( ) : array

Returns the pages defined in the meta data

Returns
Type Description
array
methodpublicload( \$filePath $filePath ) : bool

This function will load the meta-data based on a given file path

Dashlet Meta Data Loading Process 1. Check if a user customized version exists in user preferences (convert the file path to a guid) and load that one if availble 2. Check if a system customized version exists in custom/$dashletMetaDataFile and load that one 3. Otherwise load the provided file path

If the file path is not found or if the meta-data is invalid it will throw an error and return false

Parameters
Name Type Description
$filePath \$filePath
  • path to the meta data
Returns
Type Description
bool - success or failure of load
Throws
Exception Description
\FileNotFound and InvalidMetaData errors
methodpublicmoveDashlet( \$id $id, \$group $group, \$position $position ) : bool

Allows for moving a dashlet to either a new position in the same group or a new group entirely

Parameters
Name Type Description
$id \$id
  • instance id of a dashlet
$group \$group
  • group it should be added to
$position \$position
  • position in the group
Returns
Type Description
bool - success or failure
methodpublicremoveDashlet( \$id $id ) : bool

Handles the removing of a dashlet from the meta-data based on an instance id of a dashlet

Parameters
Name Type Description
$id \$id
  • instance id of a dashlet
Returns
Type Description
bool - success or failure of remove
methodpublicsave( string $type = 'SYSTEM' ) : bool

Handles the saving of a Dashlet Containers Meta Data. This is useful when either an administrator or end user changes a given layout.Depending on the type it will save the meta-data accordingly.

if $type == 'SYSTEM' it will save to the custom directory if $type == 'USER' it will save to the user preferences of the current user

Parameters
Name Type Description
$type string
Returns
Type Description
bool - on success or failure of save
Documentation was generated by DocBlox 0.18.1.