/** * Returns all beans that have been tagged with one or more * of the specified tags. * * Tag list can be either an array with tag names or a comma separated list * of tag names. * * @param string $beanType type of bean you are looking for * @param array|string $tagList list of tags to match * * @return array */ public function tagged($beanType, $tagList) { $tags = $this->extractTagsIfNeeded($tagList); $collection = array(); $tags = $this->redbean->find('tag', array('title' => $tags)); if (is_array($tags) && count($tags) > 0) { $collectionKeys = $this->associationManager->related($tags, $beanType); if ($collectionKeys) { $collection = $this->redbean->batch($beanType, $collectionKeys); } } return $collection; }
/** * Part of RedBeanPHP Tagging API. * Returns all beans that have been tagged with one of the tags given. * * @param $beanType type of bean you are looking for * @param $tagList list of tags to match * * @return array */ public function tagged($beanType, $tagList) { if ($tagList !== false && !is_array($tagList)) { $tags = explode(",", (string) $tagList); } else { $tags = $tagList; } $collection = array(); $tags = $this->redbean->find('tag', array('title' => $tags)); if (count($tags) > 0) { $collectionKeys = $this->associationManager->related($tags, $beanType); if ($collectionKeys) { $collection = $this->redbean->batch($beanType, $collectionKeys); } } return $collection; }