Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
project
drupal
Merge requests
!6552
Issue
#3327827
: Provide a block for running cron from a dashboard
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Issue
#3327827
: Provide a block for running cron from a dashboard
issue/drupal-3327827:3327827-provide-a-block
into
11.x
Overview
6
Commits
13
Pipelines
8
Changes
2
All threads resolved!
Hide all comments
Open
Pablo López
requested to merge
issue/drupal-3327827:3327827-provide-a-block
into
11.x
1 year ago
Overview
6
Commits
13
Pipelines
8
Changes
2
All threads resolved!
Hide all comments
Expand
Closes
#3327827
0
0
Merge request reports
Compare
11.x
version 6
599be7d0
1 year ago
version 5
4528cad4
1 year ago
version 4
c8fdb962
1 year ago
version 3
e92c1b56
1 year ago
version 2
24a1efdf
1 year ago
version 1
d7e1a8a4
1 year ago
11.x (HEAD)
and
latest version
latest version
03715c0d
13 commits,
1 year ago
version 6
599be7d0
12 commits,
1 year ago
version 5
4528cad4
11 commits,
1 year ago
version 4
c8fdb962
9 commits,
1 year ago
version 3
e92c1b56
7 commits,
1 year ago
version 2
24a1efdf
6 commits,
1 year ago
version 1
d7e1a8a4
5 commits,
1 year ago
2 files
+
175
−
0
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
core/modules/system/src/Plugin/Block/CronStatusBlock.php
0 → 100644
+
102
−
0
Options
<?php
declare
(
strict_types
=
1
);
namespace
Drupal\system\Plugin\Block
;
use
Drupal\Core\Access\AccessResult
;
use
Drupal\Core\Access\AccessResultInterface
;
use
Drupal\Core\Block\Attribute\Block
;
use
Drupal\Core\Block\BlockBase
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\Plugin\ContainerFactoryPluginInterface
;
use
Drupal\Core\Security\TrustedCallbackInterface
;
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\Core\StringTranslation\TranslatableMarkup
;
use
Drupal\system\Form\CronForm
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Provides a block to display Cron status.
*/
#
[
Block
(
id
:
"system_cron_status_block"
,
admin_label
:
new
TranslatableMarkup
(
"Cron status"
)
)]
class
CronStatusBlock
extends
BlockBase
implements
ContainerFactoryPluginInterface
,
TrustedCallbackInterface
{
/**
* Constructs a new CronStatusBlock instance.
*
* @param array $configuration
* An array of configuration settings.
* @param mixed $plugin_id
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* The configuration factory service.
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
protected
ConfigFactoryInterface
$configFactory
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
);
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
,
array
$configuration
,
$plugin_id
,
$plugin_definition
)
{
return
new
static
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$container
->
get
(
'config.factory'
),
);
}
/**
* {@inheritdoc}
*/
public
function
build
():
array
{
$build
=
[];
$build
[
'cron_status'
]
=
[
'#lazy_builder'
=>
[
self
::
class
.
'::lazyBuilder'
,
[]],
];
return
$build
;
}
/**
* {@inheritdoc}
*/
public
function
blockAccess
(
AccountInterface
$account
):
AccessResultInterface
{
return
AccessResult
::
allowedIfHasPermission
(
$account
,
'administer site configuration'
);
}
/**
* {@inheritdoc}
*/
public
static
function
trustedCallbacks
():
array
{
return
[
'lazyBuilder'
,
];
}
/**
* #lazy_builder callback; builds the cron form block.
*
* @return array
* A render array with the cron form.
*/
public
static
function
lazyBuilder
():
array
{
$build
=
\Drupal
::
service
(
'form_builder'
)
->
getForm
(
CronForm
::
class
);
// Hide parts of the form out of the block scope.
$build
[
'cron'
][
'#access'
]
=
FALSE
;
$build
[
'actions'
][
'#access'
]
=
FALSE
;
return
$build
;
}
}
Loading