Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Pimcore 11 compat #94

Merged
merged 11 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: make API compatible
  • Loading branch information
dkarlovi committed Sep 21, 2023
commit d47259ac982fe0ad1072b1d11747333bc5b9bb0c
6 changes: 3 additions & 3 deletions src/ProcessManagerBundle/Model/Process/Dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getById($id = null)
$this->model->setId($id);
}

$data = $this->db->fetchRow('SELECT * FROM '.$this->tableName.' WHERE id = ?', [$this->model->getId()]);
$data = $this->db->fetchAssociative('SELECT * FROM '.$this->tableName.' WHERE id = ?', [$this->model->getId()]);

if (!$data["id"]) {
throw new \Exception("Process with the ID " . $this->model->getId() . " doesn't exists");
Expand Down Expand Up @@ -100,10 +100,10 @@ public function delete()
/**
* @param array $data
*/
protected function assignVariablesToModel($data)
protected function assignVariablesToModel(array $data): void
{
foreach($data as $key => &$value) {
if ($key === "artifact") {
if ($key === "artifact" && $value !== null) {
$value = Asset::getById($value);
}
}
Expand Down
22 changes: 10 additions & 12 deletions src/ProcessManagerBundle/Model/Process/Listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Listing extends Model\Listing\AbstractListing implements PaginateListingIn
*
* @var array
*/
public $data = null;
public ?array $data = null;

/**
* @var string
Expand All @@ -53,7 +53,7 @@ class Listing extends Model\Listing\AbstractListing implements PaginateListingIn
*
* @return bool
*/
public function isValidOrderKey($key)
public function isValidOrderKey(string $key): bool
{
return in_array($key, $this->validOrderKeys);
}
Expand Down Expand Up @@ -83,7 +83,7 @@ public function setObjects($data)
*
* @return mixed
*/
public function count()
public function count(): int
{
return $this->getTotalCount();
}
Expand All @@ -96,7 +96,7 @@ public function count()
*
* @return mixed
*/
public function getItems($offset, $itemCountPerPage)
public function getItems(int $offset, int $itemCountPerPage): array
{
$this->setOffset($offset);
$this->setLimit($itemCountPerPage);
Expand Down Expand Up @@ -141,7 +141,7 @@ public function getLocale()
/**
* Rewind.
*/
public function rewind()
public function rewind(): void
{
$this->getData();
reset($this->data);
Expand All @@ -152,7 +152,7 @@ public function rewind()
*
* @return mixed
*/
public function current()
public function current(): mixed
{
$this->getData();
$var = current($this->data);
Expand All @@ -165,7 +165,7 @@ public function current()
*
* @return mixed
*/
public function key()
public function key(): string|int|null
{
$this->getData();
$var = key($this->data);
Expand All @@ -178,20 +178,18 @@ public function key()
*
* @return mixed
*/
public function next()
public function next(): void
{
$this->getData();
$var = next($this->data);

return $var;
next($this->data);
}

/**
* valid.
*
* @return bool
*/
public function valid()
public function valid(): bool
{
$this->getData();
$var = $this->current() !== false;
Expand Down
6 changes: 3 additions & 3 deletions src/ProcessManagerBundle/Model/Process/Listing/Dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getQueryBuilder($addListingParameters = true, ...$columns): Doct
*
* @return ProcessInterface[]
*/
public function load()
public function load(): array
{
// load id's
$list = $this->loadIdList();
Expand All @@ -82,7 +82,7 @@ public function load()
public function loadIdList()
{
$queryBuilder = $this->getQueryBuilder(true, [sprintf('%s as id', $this->getTableName() . '.id')]);
$objectIds = $this->db->fetchCol((string) $queryBuilder, $this->model->getConditionVariables(), $this->model->getConditionVariableTypes());
$objectIds = $this->db->fetchFirstColumn((string) $queryBuilder, $this->model->getConditionVariables(), $this->model->getConditionVariableTypes());

return array_map('intval', $objectIds);
}
Expand Down Expand Up @@ -112,7 +112,7 @@ public function getCount()
*
* @throws \Exception
*/
public function getTotalCount()
public function getTotalCount(): int
{
$queryBuilder = $this->getQueryBuilder(false, 'id');
return $queryBuilder->execute()->rowCount();
Expand Down