public static function tagged($beanType, $tagList) { if ($tagList !== false && !is_array($tagList)) { $tags = explode(",", (string) $tagList); } else { $tags = $tagList; } $collection = array(); foreach ($tags as $tag) { $retrieved = array(); $tag = RedBean_Facade::findOne('tag', ' title = ? ', array($tag)); if ($tag) { $retrieved = RedBean_Facade::related($tag, $beanType); } foreach ($retrieved as $key => $bean) { $collection[$key] = $bean; } } return $collection; }