Logidav Docs

ExportClientsInformationsForGoogleAds extends ContainerAwareCommand
in package
uses LockableTrait

Table of Contents

Properties

$entityManager  : mixed
$exportDir  : mixed
$processedEmails  : mixed
$sftp  : SFTP

Methods

__construct()  : mixed
Class constructor.
configure()  : mixed
execute()  : int
exportDataInBatches()  : void
Export data in batches to a CSV file.
generateExportFilesByGroupName()  : void
Generate export files based on group name.
getCategoryGroupMapping()  : array<string|int, mixed>
Retrieves the category group mapping.
getCountOfSales()  : int
getDataFromDatabase()  : array<string|int, mixed>
Retrieves data from the database.
getSftpConnection()  : SFTP|false
Gets the SFTP connection.
sendExportFilesFtp()  : bool
Sends a file via FTP to a remote directory.
sortAndRewriteFile()  : void
Sorts and rewrites the contents of a file.
writeDataToCsv()  : void
Writes data to a CSV file.

Properties

Methods

__construct()

Class constructor.

public __construct(EntityManagerInterface $entityManager) : mixed
Parameters
$entityManager : EntityManagerInterface

The entity manager instance.

execute()

protected execute(InputInterface $input, OutputInterface $output) : int
Parameters
$input : InputInterface
$output : OutputInterface
Return values
int

exportDataInBatches()

Export data in batches to a CSV file.

private exportDataInBatches(resource $fp, int $batchSize, ProgressBar $progressBar, int $totalItems, callable $getPartOfTheData) : void
Parameters
$fp : resource

The file pointer to the CSV file.

$batchSize : int

The number of items to retrieve from the database in each batch.

$progressBar : ProgressBar

The progress bar to update after each batch.

$totalItems : int

The total number of items in the database. Set to null if unknown.

$getPartOfTheData : callable

A function that returns a part of the data to export. This function should accept two arguments: $batchSize and $offset. It should return an array of items to be exported.

generateExportFilesByGroupName()

Generate export files based on group name.

private generateExportFilesByGroupName(string $mainCsvFile) : void
Parameters
$mainCsvFile : string

The path to the main CSV file.

getCategoryGroupMapping()

Retrieves the category group mapping.

private getCategoryGroupMapping() : array<string|int, mixed>
Return values
array<string|int, mixed>

The category group mapping as an associative array.

getDataFromDatabase()

Retrieves data from the database.

private getDataFromDatabase(int $batchSize, int $offset, bool $getPartOfTheData) : array<string|int, mixed>
Parameters
$batchSize : int

The maximum number of records to retrieve.

$offset : int

The offset to start retrieving records from.

$getPartOfTheData : bool

Whether to retrieve only a part of the data based on a specific condition.

Return values
array<string|int, mixed>

The retrieved data as an array of associative arrays.

getSftpConnection()

Gets the SFTP connection.

private getSftpConnection() : SFTP|false

This method checks if the 'google_ads_sftp' parameter exists in the container. If it doesn't, it returns false.

Otherwise, it retrieves the parameters from the container and creates a new SFTP object using the 'host' and 'port' parameters. It then authenticates with the 'username' and 'password' parameters.

Return values
SFTP|false

The SFTP connection if the 'google_ads_sftp' parameter exists in the container, false otherwise.

sendExportFilesFtp()

Sends a file via FTP to a remote directory.

private sendExportFilesFtp(mixed $filePath) : bool
Parameters
$filePath : mixed
Return values
bool

Returns true if the file was successfully sent, or throws an exception on failure.

sortAndRewriteFile()

Sorts and rewrites the contents of a file.

private sortAndRewriteFile(string $filePath) : void
Parameters
$filePath : string

The path to the file.

writeDataToCsv()

Writes data to a CSV file.

private writeDataToCsv(resource $fp, array<string|int, mixed> $categoryGroupMapping, array<string|int, mixed> $data) : void
Parameters
$fp : resource

The file pointer resource.

$categoryGroupMapping : array<string|int, mixed>

The category group mapping as an associative array.

$data : array<string|int, mixed>

The data to be written to the CSV file.


        
On this page

Search results