Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
220
Merge Requests
220
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
8d989472
Commit
8d989472
authored
Apr 06, 2014
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1957152
by brantwynn: Replace calls to the flood service with Drupal::flood().
parent
c2423131
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
3 deletions
+50
-3
core/modules/contact/lib/Drupal/contact/MessageFormController.php
...ules/contact/lib/Drupal/contact/MessageFormController.php
+48
-1
core/modules/system/lib/Drupal/system/Tests/System/FloodTest.php
...dules/system/lib/Drupal/system/Tests/System/FloodTest.php
+1
-1
core/modules/system/system.module
core/modules/system/system.module
+1
-1
No files found.
core/modules/contact/lib/Drupal/contact/MessageFormController.php
View file @
8d989472
...
...
@@ -8,9 +8,13 @@
namespace
Drupal\contact
;
use
Drupal\Component\Utility\String
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\Entity\ContentEntityFormController
;
use
Drupal\Core\Entity\EntityManagerInterface
;
use
Drupal\Core\Flood\FloodInterface
;
use
Drupal\Core\Language\Language
;
use
Drupal\user\UserInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Form controller for contact message forms.
...
...
@@ -24,6 +28,48 @@ class MessageFormController extends ContentEntityFormController {
*/
protected
$entity
;
/**
* The config factory service.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected
$configFactory
;
/**
* The flood control mechanism.
*
* @var \Drupal\Core\Flood\FloodInterface
*/
protected
$flood
;
/**
* Constructs a MessageFormController object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Flood\FloodInterface $flood
* The flood control mechanism.
*/
public
function
__construct
(
ConfigFactoryInterface
$config_factory
,
EntityManagerInterface
$entity_manager
,
FloodInterface
$flood
)
{
parent
::
__construct
(
$entity_manager
);
$this
->
configFactory
=
$config_factory
;
$this
->
flood
=
$flood
;
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'config.factory'
),
$container
->
get
(
'entity.manager'
),
$container
->
get
(
'flood'
)
);
}
/**
* Overrides Drupal\Core\Entity\EntityFormController::form().
*/
...
...
@@ -195,7 +241,8 @@ public function save(array $form, array &$form_state) {
drupal_mail
(
'contact'
,
'page_autoreply'
,
$sender
->
getEmail
(),
$language_interface
->
id
,
$params
);
}
\
Drupal
::
service
(
'flood'
)
->
register
(
'contact'
,
\
Drupal
::
config
(
'contact.settings'
)
->
get
(
'flood.interval'
));
$config
=
$this
->
configFactory
->
get
(
'contact.settings'
);
$this
->
flood
->
register
(
'contact'
,
$config
->
get
(
'flood.interval'
));
if
(
!
$message
->
isPersonal
())
{
watchdog
(
'contact'
,
'%sender-name (@sender-from) sent an e-mail regarding %category.'
,
array
(
'%sender-name'
=>
$sender
->
name
,
...
...
core/modules/system/lib/Drupal/system/Tests/System/FloodTest.php
View file @
8d989472
...
...
@@ -48,7 +48,7 @@ function testCleanUp() {
$name
=
'flood_test_cleanup'
;
// Register expired event.
$flood
=
\
Drupal
::
service
(
'flood'
);
$flood
=
\
Drupal
::
flood
(
);
$flood
->
register
(
$name
,
$window_expired
);
// Verify event is not allowed.
$this
->
assertFalse
(
$flood
->
isAllowed
(
$name
,
$threshold
));
...
...
core/modules/system/system.module
View file @
8d989472
...
...
@@ -1558,7 +1558,7 @@ function system_get_module_admin_tasks($module, array $info) {
*/
function
system_cron
()
{
// Cleanup the flood.
\
Drupal
::
service
(
'flood'
)
->
garbageCollection
();
\
Drupal
::
flood
(
)
->
garbageCollection
();
foreach
(
Cache
::
getBins
()
as
$cache_backend
)
{
$cache_backend
->
garbageCollection
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment