Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cloud-3284774
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
cloud-3284774
Commits
2775c437
Commit
2775c437
authored
5 years ago
by
xiaohua guan
Committed by
Yas Naoi
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3087534
by Xiaohua Guan, yas: Fix "Error: Call to a member function buildListHeader()"
parent
12053f39
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
cloud.services.yml
+1
-1
1 addition, 1 deletion
cloud.services.yml
src/Plugin/cloud/server_template/CloudServerTemplatePluginManager.php
+65
-1
65 additions, 1 deletion
...loud/server_template/CloudServerTemplatePluginManager.php
with
66 additions
and
2 deletions
cloud.services.yml
+
1
−
1
View file @
2775c437
...
...
@@ -15,4 +15,4 @@ services:
plugin.manager.cloud_server_template_plugin
:
class
:
Drupal\cloud\Plugin\cloud\server_template\CloudServerTemplatePluginManager
arguments
:
[
'
@module_handler'
,
'
@cache.discovery'
]
arguments
:
[
'
@module_handler'
,
'
@cache.discovery'
,
'
@string_translation'
,
'
@messenger'
]
This diff is collapsed.
Click to expand it.
src/Plugin/cloud/server_template/CloudServerTemplatePluginManager.php
+
65
−
1
View file @
2775c437
...
...
@@ -8,7 +8,10 @@ use Drupal\Core\Extension\ModuleHandlerInterface;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Plugin\DefaultPluginManager
;
use
Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator
;
use
Drupal\Core\StringTranslation\TranslationInterface
;
use
Drupal\Core\StringTranslation\StringTranslationTrait
;
use
Drupal\Core\Plugin\Discovery\YamlDiscovery
;
use
Drupal\Core\Messenger\MessengerInterface
;
use
Drupal\cloud\Entity\CloudServerTemplateInterface
;
/**
...
...
@@ -16,6 +19,15 @@ use Drupal\cloud\Entity\CloudServerTemplateInterface;
*/
class
CloudServerTemplatePluginManager
extends
DefaultPluginManager
implements
CloudServerTemplatePluginManagerInterface
{
use
StringTranslationTrait
;
/**
* The Messenger service.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
private
$messenger
;
/**
* Provides default values for all cloud_server_template_plugin plugins.
*
...
...
@@ -33,11 +45,25 @@ class CloudServerTemplatePluginManager extends DefaultPluginManager implements C
* The module handler.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation service.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger service.
*/
public
function
__construct
(
ModuleHandlerInterface
$module_handler
,
CacheBackendInterface
$cache_backend
)
{
public
function
__construct
(
ModuleHandlerInterface
$module_handler
,
CacheBackendInterface
$cache_backend
,
TranslationInterface
$string_translation
,
MessengerInterface
$messenger
)
{
// Add more services as required.
$this
->
moduleHandler
=
$module_handler
;
$this
->
setCacheBackend
(
$cache_backend
,
'cloud_server_template_plugin'
,
[
'cloud_server_template_plugin'
]);
// Setup the $this->t().
$this
->
stringTranslation
=
$string_translation
;
$this
->
messenger
=
$messenger
;
}
/**
...
...
@@ -82,6 +108,7 @@ class CloudServerTemplatePluginManager extends DefaultPluginManager implements C
break
;
}
}
return
$plugin
;
}
...
...
@@ -90,6 +117,23 @@ class CloudServerTemplatePluginManager extends DefaultPluginManager implements C
*/
public
function
launch
(
CloudServerTemplateInterface
$cloud_server_template
,
FormStateInterface
$form_state
=
NULL
)
{
$plugin
=
$this
->
loadPluginVariant
(
$cloud_server_template
->
getCloudContext
());
if
(
$plugin
===
FALSE
)
{
$message
=
$this
->
t
(
'Cannot load cloud server template plugin: %cloud_context'
,
[
'%cloud_context'
=>
$cloud_server_template
->
getCloudContext
(),
]
);
$this
->
messenger
->
addMessage
(
$message
);
return
[
'route_name'
=>
'entity.cloud_server_template.canonical'
,
'params'
=>
[
'cloud_server_template'
=>
$cloud_server_template
->
id
(),
'cloud_context'
=>
$cloud_server_template
->
getCloudContext
(),
],
];
}
return
$plugin
->
launch
(
$cloud_server_template
,
$form_state
);
}
...
...
@@ -98,6 +142,16 @@ class CloudServerTemplatePluginManager extends DefaultPluginManager implements C
*/
public
function
buildListHeader
(
$cloud_context
)
{
$plugin
=
$this
->
loadPluginVariant
(
$cloud_context
);
if
(
$plugin
===
FALSE
)
{
$message
=
$this
->
t
(
'Cannot load cloud server template plugin: %cloud_context'
,
[
'%cloud_context'
=>
$cloud_context
,
]
);
$this
->
messenger
->
addMessage
(
$message
);
return
[];
}
return
$plugin
->
buildListHeader
();
}
...
...
@@ -106,6 +160,16 @@ class CloudServerTemplatePluginManager extends DefaultPluginManager implements C
*/
public
function
buildListRow
(
CloudServerTemplateInterface
$entity
)
{
$plugin
=
$this
->
loadPluginVariant
(
$entity
->
getCloudContext
());
if
(
$plugin
===
FALSE
)
{
$message
=
$this
->
t
(
'Cannot load cloud server template plugin: %cloud_context'
,
[
'%cloud_context'
=>
$entity
->
getCloudContext
(),
]
);
$this
->
messenger
->
addMessage
(
$message
);
return
[];
}
return
$plugin
->
buildListRow
(
$entity
);
}
...
...
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