From: <bra...@kr...> - 2009-06-15 04:56:53
|
Revision: 6174 Author: bradoaks Date: 2009-06-15 00:56:50 -0400 (Mon, 15 Jun 2009) Log Message: ----------- Adding hook for an element class to modify the data during a clone(). We needed to get a new UUID for one of our elements and keep it from being a duplicate of the value from the original story. (I'm open to suggestions if you see something off about the way I've done this.) Modified Paths: -------------- trunk/krang/lib/Krang/Element.pm trunk/krang/lib/Krang/ElementClass.pm Modified: trunk/krang/lib/Krang/Element.pm =================================================================== --- trunk/krang/lib/Krang/Element.pm 2009-06-12 22:28:45 UTC (rev 6173) +++ trunk/krang/lib/Krang/Element.pm 2009-06-15 04:56:50 UTC (rev 6174) @@ -1033,6 +1033,11 @@ for (@{$clone->{children}}) { $_->parent($clone); } + + # allow element class to modify this element's data if needed during clone + my $class = $clone->class; + $class->clone_hook(data => $clone->data()); + return $clone; } Modified: trunk/krang/lib/Krang/ElementClass.pm =================================================================== --- trunk/krang/lib/Krang/ElementClass.pm 2009-06-12 22:28:45 UTC (rev 6173) +++ trunk/krang/lib/Krang/ElementClass.pm 2009-06-15 04:56:50 UTC (rev 6174) @@ -1366,6 +1366,15 @@ return $self; } +=item C<< $class->clone_hook(element => $element) >> + +Called after the story/category containing the element tree is cloned and just +before it is saved. The default implementation does nothing. + +=cut + +sub clone_hook { } + # # $url = _build_page_url(publisher => $pub, page => $page_num, protocol => 'https://'); # |