Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
feat(CategoryCollection): add getById to CategoryCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Schulze committed Nov 2, 2015
1 parent dd5fa7b commit 1a79cbc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Model/Category/CategoryCollection.php
Expand Up @@ -33,6 +33,7 @@ protected function indexRow($offset, $row)
$id = isset($row[static::ID]) ? $row[static::ID] : null;
$parentId = isset($row[static::PARENT][static::ID]) ? $row[static::PARENT][static::ID] : null;
}
$this->addToIndex(static::ID, $offset, $id);
foreach ($slugs as $locale => $slug) {
$locale = \Locale::canonicalize($locale);
$this->addToIndex(static::SLUG, $offset, $locale . '-' . $slug);
Expand All @@ -44,6 +45,18 @@ protected function indexRow($offset, $row)
}
}

/**
* @param $id
* @return Category|null
*/
public function getById($id)
{
return $this->getBy(static::ID, $id);
}

/**
* @return Category[]
*/
public function getRoots()
{
$elements = [];
Expand All @@ -53,6 +66,10 @@ public function getRoots()
return $elements;
}

/**
* @param $parentId
* @return Category[]
*/
public function getByParent($parentId)
{
$elements = [];
Expand Down

0 comments on commit 1a79cbc

Please sign in to comment.