Skip to content

Commit

Permalink
Update Sync.php
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndr-w authored Sep 13, 2024
1 parent 973d11e commit 3203c18
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/Cronjob/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ class Sync extends rex_cronjob

public function execute()
{
$url = rtrim($this->getParam('url'), '/') . self::ENDPOINT;
$url = rtrim($this->getParam('friendsofredaxo_neues_cronjob_sync_url'), '/') . self::ENDPOINT;
$data = [];

/* Query zusammenstellen */
$query = [];
if ((int) $this->getParam('x_per_page') > 0) {
$query[] = 'per_page=' . $this->getParam('x_per_page');
if ((int) $this->getParam('friendsofredaxo_neues_cronjob_sync_x_per_page') > 0) {
$query[] = 'per_page=' . $this->getParam('friendsofredaxo_neues_cronjob_sync_x_per_page');
}
$query[] = 'order[updatedate]=desc';
$socket_url = $url . '?' . implode('&', $query);
$token = $this->getParam('token');
$token = $this->getParam('friendsofredaxo_neues_cronjob_sync_token');

/* Socket erstellen und Daten abrufen */
$socket = rex_socket::factoryUrl($socket_url);
Expand Down Expand Up @@ -83,8 +83,8 @@ public function createEntry(array $current): void

/* Kategorien abrufen und speichern */
$target_category_ids = [];
if ($this->getParam('neues_category_id') > 0 && null !== Category::get($this->getParam('neues_category_id'))) {
$target_category_ids[] = $this->getParam('neues_category_id');
if ($this->getParam('friendsofredaxo_neues_cronjob_sync_neues_category_id') > 0 && null !== Category::get($this->getParam('friendsofredaxo_neues_cronjob_sync_neues_category_id'))) {
$target_category_ids[] = $this->getParam('friendsofredaxo_neues_cronjob_sync_neues_category_id');
} else {
$categories = $current['relationships']['category_ids']['data'];

Expand Down Expand Up @@ -194,7 +194,7 @@ public function createMedia(string $filename, ?string $prefix = null): bool
return true;
}

$socket = rex_socket::factoryUrl($this->getParam('url') . '/media/' . $filename);
$socket = rex_socket::factoryUrl($this->getParam('friendsofredaxo_neues_cronjob_sync_url') . '/media/' . $filename);
$response = $socket->doGet();

if ($response->isOk()) {
Expand All @@ -203,7 +203,7 @@ public function createMedia(string $filename, ?string $prefix = null): bool
/* Überprüfe, ob die Datei auf dem Dateisystem vorhanden ist */
try {
rex_media_service::addMedia([
'category_id' => $this->getParam('media_category_id'),
'category_id' => $this->getParam('friendsofredaxo_neues_cronjob_sync_media_category_id'),
'title' => $filename,
'createuser' => 'neues_sync_cronjob',
'file' => [
Expand Down

0 comments on commit 3203c18

Please sign in to comment.