Skip to content

Commit

Permalink
Add filters to FilterCollection to be able to filter the filters on n…
Browse files Browse the repository at this point in the history
…ame and displayname.
  • Loading branch information
daedeloth committed Mar 18, 2022
1 parent cca6abc commit 76a0954
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/Collections/FilterCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use CatLab\Base\Collections\Collection;
use CatLab\Charon\Interfaces\ResourceDefinition;
use CatLab\Charon\Models\Filter;

/**
*
Expand All @@ -27,4 +28,34 @@ public function getResourceDefinition()
{
return $this->resourceDefinition;
}

/**
* @param string $name
* @return Filter|null
*/
public function getFromDisplayName(string $name)
{
foreach ($this as $v) {
/** @var Filter $v */
if ($v->getField()->getDisplayName() === $name) {
return $v;
}
}
return null;
}

/**
* @param string $name
* @return Filter|null
*/
public function getFromName(string $name)
{
foreach ($this as $v) {
/** @var Filter $v */
if ($v->getField()->getName() === $name) {
return $v;
}
}
return null;
}
}

0 comments on commit 76a0954

Please sign in to comment.