Use lots and lots of Moose modifiers in the Article.
This commit is contained in:
parent
8a3f36a449
commit
54f0148ec9
1 changed files with 21 additions and 21 deletions
|
|
@ -129,15 +129,15 @@ Override the default method in order to deal with attachments.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub addRevision {
|
override addRevision => sub {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $newSelf = $self->SUPER::addRevision(@_);
|
my $newSelf = super();
|
||||||
if ($newSelf->storageId && $newSelf->storageId eq $self->storageId) {
|
if ($newSelf->storageId && $newSelf->storageId eq $self->storageId) {
|
||||||
my $newStorage = WebGUI::Storage->get($self->session,$self->storageId)->copy;
|
my $newStorage = WebGUI::Storage->get($self->session,$self->storageId)->copy;
|
||||||
$newSelf->update({storageId => $newStorage->getId});
|
$newSelf->update({storageId => $newStorage->getId});
|
||||||
}
|
}
|
||||||
return $newSelf;
|
return $newSelf;
|
||||||
}
|
};
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -147,13 +147,13 @@ Extend the super class to duplicate the storage location.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub duplicate {
|
override duplicate => sub {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $newAsset = $self->SUPER::duplicate(@_);
|
my $newAsset = super();
|
||||||
my $newStorage = $self->getStorageLocation->copy;
|
my $newStorage = $self->getStorageLocation->copy;
|
||||||
$newAsset->update({storageId=>$newStorage->getId});
|
$newAsset->update({storageId=>$newStorage->getId});
|
||||||
return $newAsset;
|
return $newAsset;
|
||||||
}
|
};
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -248,16 +248,16 @@ any files stored in the storage location.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub processPropertiesFromFormPost {
|
override processPropertiesFromFormPost => sub {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->SUPER::processPropertiesFromFormPost(@_);
|
super();
|
||||||
my $size = 0;
|
my $size = 0;
|
||||||
my $storage = $self->getStorageLocation;
|
my $storage = $self->getStorageLocation;
|
||||||
foreach my $file (@{$storage->getFiles}) {
|
foreach my $file (@{$storage->getFiles}) {
|
||||||
$size += $storage->getFileSize($file);
|
$size += $storage->getFileSize($file);
|
||||||
}
|
}
|
||||||
$self->setSize($size);
|
$self->setSize($size);
|
||||||
}
|
};
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -267,7 +267,7 @@ Extend the super class to delete all storage locations.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub purge {
|
override purge => sub {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $sth = $self->session->db->read("select storageId from Article where assetId=?",[$self->getId]);
|
my $sth = $self->session->db->read("select storageId from Article where assetId=?",[$self->getId]);
|
||||||
while (my ($storageId) = $sth->array) {
|
while (my ($storageId) = $sth->array) {
|
||||||
|
|
@ -275,8 +275,8 @@ sub purge {
|
||||||
$storage->delete if defined $storage;
|
$storage->delete if defined $storage;
|
||||||
}
|
}
|
||||||
$sth->finish;
|
$sth->finish;
|
||||||
return $self->SUPER::purge;
|
return super();
|
||||||
}
|
};
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -286,11 +286,11 @@ See WebGUI::Asset::purgeCache() for details.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub purgeCache {
|
override purgeCache => sub {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
eval{$self->session->cache->delete("view_".$self->getId)};
|
eval{$self->session->cache->delete("view_".$self->getId)};
|
||||||
$self->SUPER::purgeCache;
|
super();
|
||||||
}
|
};
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -300,11 +300,11 @@ Extend the super class to delete the storage location for this revision.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub purgeRevision {
|
override purgeRevision => sub {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->getStorageLocation->delete;
|
$self->getStorageLocation->delete;
|
||||||
return $self->SUPER::purgeRevision;
|
return super();
|
||||||
}
|
};
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -429,11 +429,11 @@ See WebGUI::Asset::Wobject::www_view() for details.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_view {
|
override www_view => sub {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->session->http->setCacheControl($self->cacheTimeout);
|
$self->session->http->setCacheControl($self->cacheTimeout);
|
||||||
$self->SUPER::www_view(@_);
|
super();
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue