Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How eZ Tags adds tags
function add($parentTag, $newKeyword)
{
$db = eZDB::instance();
$db->begin();
$tag = new eZTagsObject( array( 'parent_id' => ( $parentTag instanceof eZTagsObject ) ? $parentTag->attribute( 'id' ) : 0,
'main_tag_id' => 0,
'keyword' => $newKeyword,
'depth' => ( $parentTag instanceof eZTagsObject ) ? (int) $parentTag->attribute( 'depth' ) + 1 : 1,
'path_string' => ( $parentTag instanceof eZTagsObject ) ? $parentTag->attribute( 'path_string' ) : '/' ) );
$tag->store();
$tag->setAttribute( 'path_string', $tag->attribute( 'path_string' ) . $tag->attribute( 'id' ) . '/' );
$tag->store();
$tag->updateModified();
/* Extended Hook */
if ( class_exists( 'ezpEvent', false ) )
ezpEvent::getInstance()->filter( 'tag/add', array( 'tag' => $tag, 'parentTag' => $parentTag ) );
$db->commit();
return $Module->redirectToView( 'id', array( $tag->attribute( 'id' ) ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment