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
Jan-Hendrik Willms
Stud.IP
Commits
9faceafb
Commit
9faceafb
authored
5 months ago
by
Jan-Hendrik Willms
Browse files
Options
Downloads
Patches
Plain Diff
introduce PluginDispatcher, fixes #4913
Closes #4913 Merge request
studip/studip!3688
parent
e9727367
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/classes/PluginController.php
+10
-7
10 additions, 7 deletions
lib/classes/PluginController.php
lib/classes/PluginDispatcher.php
+25
-0
25 additions, 0 deletions
lib/classes/PluginDispatcher.php
lib/plugins/core/StudIPPlugin.php
+1
-6
1 addition, 6 deletions
lib/plugins/core/StudIPPlugin.php
with
36 additions
and
13 deletions
lib/classes/PluginController.php
+
10
−
7
View file @
9faceafb
...
...
@@ -6,20 +6,20 @@
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @property StudIPPlugin $plugin
* @property callable $_
* @property callable $_n
*/
class
PluginController
extends
StudipController
{
public
function
__construct
(
$dispatcher
)
public
function
__construct
(
PluginDispatcher
$dispatcher
)
{
parent
::
__construct
(
$dispatcher
);
if
(
!
isset
(
$dispatcher
->
current_plugin
))
{
throw
new
Exception
(
'Plugin missing for plugin controller!'
);
}
$this
->
plugin
=
$dispatcher
->
current_plugin
;
if
(
$this
->
plugin
&&
$this
->
plugin
->
hasTranslation
())
{
if
(
$this
->
plugin
->
hasTranslation
())
{
// Localization
$this
->
_
=
function
(
$string
)
{
return
call_user_func_array
(
...
...
@@ -64,7 +64,10 @@ class PluginController extends StudipController
*/
public
function
__call
(
$method
,
$arguments
)
{
if
(
isset
(
$this
->
_template_variables
[
$method
])
&&
is_callable
(
$this
->
_template_variables
[
$method
]))
{
if
(
isset
(
$this
->
_template_variables
[
$method
])
&&
is_callable
(
$this
->
_template_variables
[
$method
])
)
{
return
call_user_func_array
(
$this
->
_template_variables
[
$method
],
$arguments
);
}
return
parent
::
__call
(
$method
,
$arguments
);
...
...
This diff is collapsed.
Click to expand it.
lib/classes/PluginDispatcher.php
0 → 100644
+
25
−
0
View file @
9faceafb
<?php
/**
* This is a specialized dispatcher for plugins.
*
* @author Jan-Hendrik Willms <tleilax+studip@gmail.com>
* @license GPL2 or any later version
* @since Stud.IP 6.0
*/
class
PluginDispatcher
extends
StudipDispatcher
{
public
StudIPPlugin
$current_plugin
;
public
function
__construct
(
\Psr\Container\ContainerInterface
$container
,
StudIPPlugin
$plugin
)
{
parent
::
__construct
(
$container
);
$this
->
current_plugin
=
$plugin
;
$this
->
trails_root
=
$plugin
->
getPluginPath
();
$this
->
trails_uri
=
rtrim
(
PluginEngine
::
getLink
(
$this
->
current_plugin
,
[],
null
,
true
),
'/'
);
$this
->
default_controller
=
'index'
;
}
}
This diff is collapsed.
Click to expand it.
lib/plugins/core/StudIPPlugin.php
+
1
−
6
View file @
9faceafb
...
...
@@ -196,13 +196,8 @@ abstract class StudIPPlugin
$action
=
$args
[
0
]
!==
''
?
array_shift
(
$args
)
.
'_action'
:
'show_action'
;
if
(
!
method_exists
(
$this
,
$action
))
{
$dispatcher
=
app
(
\Trails\Dispatcher
::
class
);
$dispatcher
->
trails_root
=
$this
->
getPluginPath
();
$dispatcher
->
trails_uri
=
rtrim
(
PluginEngine
::
getLink
(
$this
,
[],
null
,
true
),
'/'
);
$dispatcher
->
default_controller
=
'index'
;
$dispatcher
->
current_plugin
=
$this
;
try
{
$dispatcher
->
dispatch
(
$unconsumed_path
);
app
(
PluginDispatcher
::
class
,
[
'plugin'
=>
$this
])
->
dispatch
(
$unconsumed_path
);
}
catch
(
Trails\Exceptions\UnknownAction
$exception
)
{
if
(
count
(
$args
)
>
0
)
{
throw
$exception
;
...
...
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