Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
versionedfiles
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
silverstripe
versionedfiles
Commits
cad84217
Commit
cad84217
authored
15 years ago
by
Andrew Short
Browse files
Options
Downloads
Patches
Plain Diff
MINOR: Added a link from a file to its current version.
parent
39ac1229
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/VersionedFileExtension.php
+16
-1
16 additions, 1 deletion
code/VersionedFileExtension.php
with
16 additions
and
1 deletion
code/VersionedFileExtension.php
+
16
−
1
View file @
cad84217
...
...
@@ -10,7 +10,10 @@ class VersionedFileExtension extends DataObjectDecorator {
* @return array
*/
public
function
extraStatics
()
{
return
array
(
'has_many'
=>
array
(
'Versions'
=>
'FileVersion'
));
return
array
(
'has_one'
=>
array
(
'CurrentVersion'
=>
'FileVersion'
),
'has_many'
=>
array
(
'Versions'
=>
'FileVersion'
)
);
}
/**
...
...
@@ -25,6 +28,15 @@ class VersionedFileExtension extends DataObjectDecorator {
);
}
/**
* Get the current file version number, if one is available.
*
* @return int|null
*/
public
function
getVersionNumber
()
{
if
(
$this
->
owner
->
CurrentVersionID
)
return
$this
->
owner
->
CurrentVersion
()
->
VersionNumber
;
}
/**
* Called by the edit form upon save, and handles replacing the file if a replacement is specified.
*
...
...
@@ -55,6 +67,9 @@ class VersionedFileExtension extends DataObjectDecorator {
$version
=
new
FileVersion
();
$version
->
FileID
=
$this
->
owner
->
ID
;
$version
->
write
();
$this
->
owner
->
CurrentVersionID
=
$version
->
ID
;
$this
->
owner
->
write
();
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment