Source
in package
Class Source
Provides functionality to manage sources, including querying, creating, and updating source records in the data store.
Table of Contents
Properties
Methods
- __construct() : mixed
- createByAdmin() : void
- Create a new source (admin).
- getAll() : array<int, array<string, mixed>>
- Get all sources filtered by status.
- getByCode() : array<string, mixed>
- Get a source by its code.
- updateByCode() : void
- Update a source by its code (admin).
Properties
$mySql
protected
MySql
$mySql
Methods
__construct()
public
__construct(MySql $mySql) : mixed
Parameters
- $mySql : MySql
createByAdmin()
Create a new source (admin).
public
createByAdmin(array<string, mixed> $data) : void
Expects in $data:
- source_code (string, required)
- source_name (string, required)
- source_display (string|null)
- source_link (string|null)
- source_addition (string|null)
- source_type_code (string, required)
- sort_order (int|null)
- status (int, required)
- createdby (string, required)
- modifiedby (string, required)
Parameters
- $data : array<string, mixed>
getAll()
Get all sources filtered by status.
public
getAll(array<string|int, int> $statuses) : array<int, array<string, mixed>>
Parameters
- $statuses : array<string|int, int>
Return values
array<int, array<string, mixed>>getByCode()
Get a source by its code.
public
getByCode(string $code) : array<string, mixed>
Parameters
- $code : string
Return values
array<string, mixed>updateByCode()
Update a source by its code (admin).
public
updateByCode(array<string, mixed> $data) : void
Behaviour for source_type:
- If source_type_code is not present in $data → keep existing.
- If present but empty string → set type_id and type_code to NULL.
- If present and non-empty → resolve id by code and update both.
Expects in $data:
- source_code (string, required)
- source_name (string|null)
- source_display (string|null)
- source_link (string|null)
- source_addition (string|null)
- source_type_code (string|null, presence matters)
- sort_order (int|null)
- status (int|null)
- modifiedby (string, required)
Parameters
- $data : array<string, mixed>