/**
* Tags a bean or returns tags associated with a bean.
* If $tagList is NULL or omitted this method will return a
* comma separated list of tags associated with the bean provided.
* If $tagList is a comma separated list (string) of tags all tags will
* be associated with the bean.
* You may also pass an array instead of a string.
*
* Tag list can be either an array with tag names or a comma separated list
* of tag names.
*
* @param OODBBean $bean bean to be tagged
* @param array|string $tagList a list of tags
*
* @return array
*/
public function tag(OODBBean $bean, $tagList = NULL)
{
if (is_null($tagList)) {
$tags = $bean->sharedTag;
$foundTags = array();
foreach ($tags as $tag) {
$foundTags[] = $tag->title;
}
return $foundTags;
}
$this->associationManager->clearRelations($bean, 'tag');
$this->addTags($bean, $tagList);
return $tagList;
}