Skip to content

Commit

Permalink
Merge pull request #36 from alexplusde/update-class
Browse files Browse the repository at this point in the history
Aktualisierte Docs und Setter-Methoden für alle Dataset-Klassen
  • Loading branch information
alxndr-w authored Dec 16, 2023
2 parents 751f04f + b477d04 commit 805d742
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 62 deletions.
42 changes: 21 additions & 21 deletions lib/neues_author.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Klasse neues_author.
* Klasse neues_author
*
* Diese Klasse repräsentiert einen Autor in der News-Verwaltung.
* Sie erbt von der rex_yform_manager_dataset Klasse.
Expand Down Expand Up @@ -30,9 +30,9 @@ class neues_author extends \rex_yform_manager_dataset
*
* @api
*/
public function getName(): ?string
public function getName() : ?string
{
return $this->getValue('name');
return $this->getValue("name");
}

/**
Expand All @@ -47,9 +47,9 @@ public function getName(): ?string
*
* @api
*/
public function setName(string $value): self
public function setName(string $value) : self
{
$this->setValue('name', $value);
$this->setValue("name", $value);
return $this;
}

Expand All @@ -65,9 +65,9 @@ public function setName(string $value): self
*
* @api
*/
public function getNickname(): ?string
public function getNickname() : ?string
{
return $this->getValue('nickname');
return $this->getValue("nickname");
}

/**
Expand All @@ -82,9 +82,9 @@ public function getNickname(): ?string
*
* @api
*/
public function setNickname(string $value): self
public function setNickname(string $value) : self
{
$this->setValue('nickname', $value);
$this->setValue("nickname", $value);
return $this;
}

Expand All @@ -101,14 +101,14 @@ public function setNickname(string $value): self
*
* @api
*/
public function getText(bool $asPlaintext = false): ?string
public function getText(bool $asPlaintext = false) : ?string
{
if ($asPlaintext) {
return strip_tags($this->getValue('text'));
if($asPlaintext) {
return strip_tags($this->getValue("text"));
}
return $this->getValue('text');
return $this->getValue("text");
}

/**
* Setzt den Text des Autors.
* Sets the text of the author.
Expand All @@ -121,9 +121,9 @@ public function getText(bool $asPlaintext = false): ?string
*
* @api
*/
public function setText(string $value): self
public function setText(string $value) : self
{
$this->setValue('text', $value);
$this->setValue("text", $value);
return $this;
}

Expand All @@ -139,9 +139,9 @@ public function setText(string $value): self
*
* @api
*/
public function getBeUserId(): ?int
public function getBeUserId() : ?int
{
return $this->getValue('be_user_id');
return $this->getValue("be_user_id");
}

/**
Expand All @@ -156,9 +156,9 @@ public function getBeUserId(): ?int
*
* @api
*/
public function setBeUserId(int $value): self
public function setBeUserId(int $value) : self
{
$this->setValue('be_user_id', $value);
$this->setValue("be_user_id", $value);
return $this;
}

Expand All @@ -171,7 +171,7 @@ public function setBeUserId(int $value): self
* Beispiel / Example:
* $beUser = $author->getBeUser();
*/
public function getBeUser(): ?rex_user
public function getBeUser() : ?rex_user
{
return rex_user::get($this->getBeUserId());
}
Expand Down
74 changes: 67 additions & 7 deletions lib/neues_category.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,82 @@
<?php

/**
* Klasse neues_category
*
* Diese Klasse repräsentiert eine Kategorie in der News-Verwaltung.
* Sie erbt von der rex_yform_manager_dataset Klasse.
*
* Class neues_category
*
* This class represents a category in the news management.
* It inherits from the rex_yform_manager_dataset class.
*
* $category = neues_category::create();
* $category->setValue('name', 'Neue Kategorie');
* $category->save();
*/
class neues_category extends \rex_yform_manager_dataset
{
/** @api */
/**
* Gibt den Namen der Kategorie zurück.
* Returns the name of the category.
*
* @return string Der Name der Kategorie. / The name of the category.
*
* Beispiel / Example:
* $name = $category->getName();
*
* @api
*/
public function getName(): string
{
return $this->getValue('name');
}

public function setName(string $string): self
/**
* Setzt den Namen der Kategorie.
* Sets the name of the category.
*
* @param string $name Der neue Name der Kategorie. / The new name of the category.
*
* Beispiel / Example:
* $category->setName('Neuer Name');
*/
public function setName(string $name): self
{
$this->setValue('name', $string);
$this->setValue('name', $name);
return $this;
}

/** @api */
/**
* Gibt die Einträge der Kategorie zurück.
* Returns the entries of the category.
*
* @return rex_yform_manager_collection|null Die Einträge der Kategorie oder null, wenn keine Einträge vorhanden sind. / The entries of the category or null if no entries are present.
*
* Beispiel / Example:
* $entries = $category->getEntries();
*
* @api
*/
public function getEntries(): ?rex_yform_manager_collection
{
return $this->getRelatedDataset('entry_ids');
}
/**
* Gibt die URL der Kategorie zurück.
* Returns the URL of the category.
*
* @param string $profile Das Profil, das für die URL-Erstellung verwendet wird. Standardmäßig 'neues-category-id'. / The profile used for URL creation. Defaults to 'neues-category-id'.
* @return string Die URL der Kategorie oder ein leerer String, wenn keine URL gefunden wurde. / The URL of the category or an empty string if no URL was found.
*
* Beispiel / Example:
* $url = $category->getUrl();
*
* @api
*/
public function getUrl(string $profile = 'neues-category-id'): ?string
{
if ($url = rex_getUrl(null, null, [$profile => $this->getId()])) {
return $url;
}
return null;
}
}
86 changes: 52 additions & 34 deletions lib/neues_entry.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
<?php

/**
* Class neues_entry
*
* Diese Klasse repräsentiert einen neuen Eintrag.
* This class represents a new entry.
*
* Beispiel / Example:
* $entry = neues_entry::get($id);
*
* @package rex_yform_manager_dataset
*/
class neues_entry extends \rex_yform_manager_dataset
{
private $categories;

/** @api */
/**
* @api
* @return string
*
* Gibt den Namen des Eintrags zurück.
* Returns the name of the entry.
*
* Beispiel / Example:
* $name = $entry->getName();
*/
public function getName(): string
{
return $this->getValue('name');
Expand All @@ -15,8 +32,16 @@ public function setName(string $name): self
$this->setValue('name', $name);
return $this;
}

/** @api */
/**
* @api
* @return string
*
* Gibt den Autor des Eintrags zurück.
* Returns the author of the entry.
*
* Beispiel / Example:
* $author = $entry->getAuthor();
*/
public function getAuthor(): string
{
return $this->getValue('author');
Expand All @@ -27,8 +52,16 @@ public function setAuthor(string $author): self
$this->setValue('author', $author);
return $this;
}

/** @api */
/**
* @api
* @return string
*
* Gibt die Domain des Eintrags zurück.
* Returns the domain of the entry.
*
* Beispiel / Example:
* $domain = $entry->getDomain();
*/
public function getDomain(): string
{
return $this->getValue('domain');
Expand All @@ -46,19 +79,10 @@ public function getTeaser(): string
return $this->getValue('teaser');
}

public function setTeaser(string $teaser): self
{
$this->setValue('teaser', $teaser);
return $this;
}

/** @api */
public function getCategories(): ?rex_yform_manager_collection
{
if (!$this->categories) {
$this->categories = $this->getRelatedCollection('category_ids');
return $this->categories;
}
return $this->getRelatedCollection('category_ids');
}

/** @api */
Expand Down Expand Up @@ -93,6 +117,9 @@ public function setImages(?array $images): self
/** @api */
public function getMedia(): ?rex_media
{
if(rex_addon::get('media_manager_resposnive')->isAvailable()) {
return rex_media_plus::get($this->getImage());
}
return rex_media::get($this->getImage());
}

Expand All @@ -112,12 +139,6 @@ public function getDescriptionAsPlaintext(): string
return strip_tags($this->getValue('description'));
}

public function setDescriptionAsPlaintext(string $description): self
{
$this->setValue('description', $description);
return $this;
}

/** @api */
public function getDescription(): string
{
Expand Down Expand Up @@ -172,13 +193,13 @@ public function setPublishDate(string $publishdate): self
}

/** @api */
public function getFormattedPublishDate(string $format_date = IntlDateFormatter::FULL): string
public function getFormattedPublishDate($format_date = IntlDateFormatter::FULL): string
{
return $this->getFormattedPublishDateTime([$format_date, IntlDateFormatter::NONE]);
}

/** @api */
public function getFormattedPublishDateTime(string $format = [IntlDateFormatter::FULL, IntlDateFormatter::SHORT]): string
public function getFormattedPublishDateTime($format = [IntlDateFormatter::FULL, IntlDateFormatter::SHORT]): string
{
return rex_formatter::intlDateTime($this->getPublishDate(), $format);
}
Expand All @@ -195,12 +216,15 @@ public function setStatus(int $status): self
return $this;
}

public static function findOnline(): ?rex_yform_manager_collection
public static function findOnline(int $category_id = null): ?rex_yform_manager_collection
{
if($category_id) {
return self::findByCategory($category_id);
}
return self::query()->where('status', 1, '>=')->find();
}

public static function findByCategory(int $category_id, $status = 1): ?rex_yform_manager_collection
public static function findByCategory(int $category_id = null, int $status = 1): ?rex_yform_manager_collection
{
$query = self::query()->joinRelation('category_ids', 'c')->where('rex_neues_entry.status', $status, '>=')->where('c.id', $category_id);
return $query->find();
Expand All @@ -214,10 +238,4 @@ public function getUrl(string $profile = 'neues-entry-id'): string
}
return '';
}

public function setUrl(string $url): self
{
$this->setValue('url', $url);
return $this;
}
}

0 comments on commit 805d742

Please sign in to comment.