Documentation

CRM_Core_BAO_Block
in package

Add static functions to include some common functionality used across location sub object BAO classes.

Tags
copyright

CiviCRM LLC https://civicrm.org/licensing

Table of Contents

Properties

$requiredBlockFields  : array<string|int, mixed>
Fields that are required for a valid block.

Methods

blockDelete()  : mixed
Delete block.
blockExists()  : bool
Check if the current block exits.
create()  : array<string|int, mixed>|null
Takes an associative array and creates a block.
dataExists()  : bool
Check if the current block object has any valid data.
getBlockIds()  : array<string|int, mixed>
Get all block ids for a contact.
getValues()  : array<string|int, mixed>
Given the list of params in the params array, fetch the object and store the values in the values array
handleBilling()  : mixed
Handling for is_billing.
handlePrimary()  : mixed
Handling for is_primary.
primaryComparison()  : int
compare 2 locations to see which should go first based on is_primary (sort function for sortPrimaryFirst)
retrieveBlock()  : array<string|int, mixed>
Given the list of params in the params array, fetch the object and store the values in the values array
sortPrimaryFirst()  : mixed
Sort location array so primary element is first.

Properties

$requiredBlockFields

Fields that are required for a valid block.

public static array<string|int, mixed> $requiredBlockFields = ['email' => ['email'], 'phone' => ['phone'], 'im' => ['name'], 'openid' => ['openid']]

Methods

blockDelete()

Delete block.

public static blockDelete(string $blockName, int $params) : mixed
  • just call the BAO / api directly.
Parameters
$blockName : string

Block name.

$params : int

Associates array.

blockExists()

Check if the current block exits.

public static blockExists(string $blockName, array<string|int, mixed> $params) : bool
Parameters
$blockName : string

Block name.

$params : array<string|int, mixed>

Array of submitted fields.

Return values
bool

true if the block is in the params and is an array

create()

Takes an associative array and creates a block.

public static create(string $blockName, array<string|int, mixed> $params) : array<string|int, mixed>|null
Parameters
$blockName : string

Block name.

$params : array<string|int, mixed>

Array of name/value pairs.

Return values
array<string|int, mixed>|null

Array of created location entities or NULL if none to create.

dataExists()

Check if the current block object has any valid data.

public static dataExists(array<string|int, mixed> $blockFields, array<string|int, mixed> &$params) : bool
Parameters
$blockFields : array<string|int, mixed>

Array of fields that are of interest for this object.

$params : array<string|int, mixed>

Associated array of submitted fields.

Return values
bool

true if the block has data, otherwise false

getBlockIds()

Get all block ids for a contact.

public static getBlockIds(string $blockName[, int $contactId = NULL ][, null $entityElements = NULL ][, bool $updateBlankLocInfo = FALSE ]) : array<string|int, mixed>
Parameters
$blockName : string

Block name.

$contactId : int = NULL

Contact id.

$entityElements : null = NULL
$updateBlankLocInfo : bool = FALSE
Return values
array<string|int, mixed>

formatted array of block ids

getValues()

Given the list of params in the params array, fetch the object and store the values in the values array

public static & getValues(string $blockName, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$blockName : string

Name of the above object.

$params : array<string|int, mixed>

Input parameters to find object.

Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

Array of $block objects.

handleBilling()

Handling for is_billing.

public static handleBilling(array<string|int, mixed> &$params, mixed $class) : mixed

This process is a variation of handlePrimary above Find other entries with is_billing = 1 and reset them to 0

Parameters
$params : array<string|int, mixed>
$class : mixed
Tags
throws
CRM_Core_Exception

handlePrimary()

Handling for is_primary.

public static handlePrimary(array<string|int, mixed> &$params, mixed $class) : mixed

$params is_primary could be

1 - find other entries with is_primary = 1 & reset them to 0

0 - make sure at least one entry is set to 1

      - if no other entry is 1 change to 1
      - if one other entry exists change that to 1
      - if more than one other entry exists change first one to 1
Parameters
$params : array<string|int, mixed>
$class : mixed
Tags
fixme
  • perhaps should choose by location_type

empty - same as 0 as once we have checked first step

       we know if it should be 1 or 0

if $params['id'] is set $params['contact_id'] may need to be retrieved

throws
CRM_Core_Exception

primaryComparison()

compare 2 locations to see which should go first based on is_primary (sort function for sortPrimaryFirst)

public static primaryComparison(array<string|int, mixed> $location1, array<string|int, mixed> $location2) : int
Parameters
$location1 : array<string|int, mixed>
$location2 : array<string|int, mixed>
Return values
int

retrieveBlock()

Given the list of params in the params array, fetch the object and store the values in the values array

public static retrieveBlock(object $block) : array<string|int, mixed>
Parameters
$block : object

Typically a Phone|Email|IM|OpenID object.

Return values
array<string|int, mixed>

Array of $block objects.

sortPrimaryFirst()

Sort location array so primary element is first.

public static sortPrimaryFirst(array<string|int, mixed> &$locations) : mixed
Parameters
$locations : array<string|int, mixed>

        
On this page

Search results