Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marcus Eibrink-Lunzenauer
Stud.IP
Commits
6bc8e7bb
Commit
6bc8e7bb
authored
10 months ago
by
Jan-Hendrik Willms
Browse files
Options
Downloads
Patches
Plain Diff
fixes #4138
Closes #4138 Merge request
studip/studip!2980
parent
f9cb99a8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/views/web_migrate/index.php
+1
-1
1 addition, 1 deletion
app/views/web_migrate/index.php
lib/migrations/Migration.php
+21
-3
21 additions, 3 deletions
lib/migrations/Migration.php
with
22 additions
and
4 deletions
app/views/web_migrate/index.php
+
1
−
1
View file @
6bc8e7bb
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
<?=
htmlReady
(
$number
)
?>
<?=
htmlReady
(
$number
)
?>
</td>
</td>
<td>
<td>
<?=
htmlReady
(
get_class
(
$migration
))
?>
<?=
htmlReady
(
$migration
->
getName
(
))
?>
</td>
</td>
<td>
<td>
<?
if
(
$migration
->
description
())
:
?>
<?
if
(
$migration
->
description
())
:
?>
...
...
This diff is collapsed.
Click to expand it.
lib/migrations/Migration.php
+
21
−
3
View file @
6bc8e7bb
...
@@ -48,6 +48,24 @@ abstract class Migration
...
@@ -48,6 +48,24 @@ abstract class Migration
return
''
;
return
''
;
}
}
/**
* Returns the name of the migration. If the migration is an anonymous
* class, the the name is created from the filename. Otherwise, it's the
* class name of the migration.
*
* @return string
*/
public
function
getName
():
string
{
$reflection
=
new
ReflectionClass
(
$this
);
if
(
$reflection
->
isAnonymous
())
{
$filename
=
basename
(
$reflection
->
getFileName
(),
'.php'
);
$name
=
implode
(
' '
,
array_slice
(
explode
(
'_'
,
$filename
),
1
));
return
ucfirst
(
$name
);
}
return
static
::
class
;
}
/**
/**
* Abstract method performing this migration step.
* Abstract method performing this migration step.
* This method should be implemented in a migration subclass.
* This method should be implemented in a migration subclass.
...
@@ -67,12 +85,12 @@ abstract class Migration
...
@@ -67,12 +85,12 @@ abstract class Migration
/**
/**
* Perform or revert this migration, depending on the indicated direction.
* Perform or revert this migration, depending on the indicated direction.
*
*
* @param string $direction migration direction (either 'up' or 'down')
* @param
?
string $direction migration direction (either 'up' or 'down')
*/
*/
public
function
migrate
(
$direction
)
public
function
migrate
(
$direction
)
{
{
if
(
!
in_array
(
$direction
,
[
'up'
,
'down'
]))
{
if
(
!
in_array
(
$direction
,
[
'up'
,
'down'
]))
{
return
;
return
null
;
}
}
$result
=
$this
->
$direction
();
$result
=
$this
->
$direction
();
...
@@ -107,7 +125,7 @@ abstract class Migration
...
@@ -107,7 +125,7 @@ abstract class Migration
$args
=
func_get_args
();
$args
=
func_get_args
();
$message
=
vsprintf
(
array_shift
(
$args
),
$args
);
$message
=
vsprintf
(
array_shift
(
$args
),
$args
);
return
$this
->
write
(
$this
->
mark
(
$message
));
$this
->
write
(
$this
->
mark
(
$message
));
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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