Created
October 23, 2012 15:57
-
-
Save harmstyler/3939637 to your computer and use it in GitHub Desktop.
How eZ Tags adds tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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