Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
private_message-3099166
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
private_message-3099166
Commits
f0d3676b
Commit
f0d3676b
authored
6 years ago
by
Jay Friendly
Browse files
Options
Downloads
Patches
Plain Diff
Fixing bug preventing new private messages from being able to be created
parent
3eb759d4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/private_message_nodejs/src/Form/PrivateMessageNodejsForm.php
+2
-2
2 additions, 2 deletions
...vate_message_nodejs/src/Form/PrivateMessageNodejsForm.php
src/Form/PrivateMessageForm.php
+16
-16
16 additions, 16 deletions
src/Form/PrivateMessageForm.php
with
18 additions
and
18 deletions
modules/private_message_nodejs/src/Form/PrivateMessageNodejsForm.php
+
2
−
2
View file @
f0d3676b
...
...
@@ -90,8 +90,8 @@ class PrivateMessageNodejsForm extends PrivateMessageForm {
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
FormStateInterface
$form
S
tate
,
PrivateMessageThreadInterface
$privateMessageThread
=
NULL
)
{
$form
=
parent
::
buildForm
(
$form
,
$form
S
tate
,
$privateMessageThread
);
public
function
buildForm
(
array
$form
,
FormStateInterface
$form
_s
tate
,
PrivateMessageThreadInterface
$privateMessageThread
=
NULL
)
{
$form
=
parent
::
buildForm
(
$form
,
$form
_s
tate
,
$privateMessageThread
);
$form
[
'#attached'
][
'library'
][]
=
'private_message_nodejs/form'
;
...
...
This diff is collapsed.
Click to expand it.
src/Form/PrivateMessageForm.php
+
16
−
16
View file @
f0d3676b
...
...
@@ -176,11 +176,11 @@ class PrivateMessageForm extends ContentEntityForm {
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
FormStateInterface
$form
_s
tate
,
PrivateMessageThreadInterface
$private_message_thread
=
NULL
)
{
$form
=
parent
::
buildForm
(
$form
,
$form
_s
tate
);
public
function
buildForm
(
array
$form
,
FormStateInterface
$form
S
tate
,
PrivateMessageThreadInterface
$private_message_thread
=
NULL
)
{
$form
=
parent
::
buildForm
(
$form
,
$form
S
tate
);
if
(
$private_message_thread
)
{
$form
_s
tate
->
set
(
'thread_members'
,
$private_message_thread
->
getMembers
());
$form
S
tate
->
set
(
'thread_members'
,
$private_message_thread
->
getMembers
());
$form
[
'actions'
][
'submit'
][
'#ajax'
]
=
[
'callback'
=>
'::ajaxCallback'
,
];
...
...
@@ -194,9 +194,9 @@ class PrivateMessageForm extends ContentEntityForm {
// members element from it.
$private_message_thread
=
PrivateMessageThread
::
create
();
$form_copy
=
$form
;
$form
_s
tate_copy
=
clone
(
$form
_s
tate
);
$form
S
tate_copy
=
clone
(
$form
S
tate
);
$form_display
=
EntityFormDisplay
::
collectRenderDisplay
(
$private_message_thread
,
'default'
);
$form_display
->
buildForm
(
$private_message_thread
,
$form_copy
,
$form
_s
tate_copy
);
$form_display
->
buildForm
(
$private_message_thread
,
$form_copy
,
$form
S
tate_copy
);
$form
[
'members'
]
=
$form_copy
[
'members'
];
$form
[
'#validate'
][]
=
'::validateMembers'
;
...
...
@@ -220,7 +220,7 @@ class PrivateMessageForm extends ContentEntityForm {
*
* @see \Drupal\private_message\Entity\PrivateMessageThead::baseFieldDefinitions
*/
public
function
validateMembers
(
array
&
$form
,
FormStateInterface
$form
_s
tate
)
{
public
function
validateMembers
(
array
&
$form
,
FormStateInterface
$form
S
tate
)
{
// The members form element was loaded from the PrivateMessageThread entity
// type. As it is not a part of the PrivateMessage entity, for which this
// form is built, the constraints that are a part of the field on the
...
...
@@ -236,7 +236,7 @@ class PrivateMessageForm extends ContentEntityForm {
// Retrieve any members submitted on the form.
$members
=
[];
foreach
(
$form
_s
tate
->
getValue
(
'members'
)
as
$info
)
{
foreach
(
$form
S
tate
->
getValue
(
'members'
)
as
$info
)
{
if
(
is_array
(
$info
)
&&
is_numeric
(
$info
[
'target_id'
]))
{
$user
=
$this
->
userManager
->
load
(
$info
[
'target_id'
]);
if
(
$user
)
{
...
...
@@ -255,7 +255,7 @@ class PrivateMessageForm extends ContentEntityForm {
if
(
$violations
->
count
()
>
0
)
{
// Output any errors for found constraint violations.
foreach
(
$violations
as
$violation
)
{
$form
_s
tate
->
setError
(
$form
[
'members'
],
$violation
->
getMessage
());
$form
S
tate
->
setError
(
$form
[
'members'
],
$violation
->
getMessage
());
}
}
}
...
...
@@ -263,7 +263,7 @@ class PrivateMessageForm extends ContentEntityForm {
/**
* Ajax callback for the PrivateMessageForm.
*/
public
function
ajaxCallback
(
array
$form
,
FormStateInterface
$form
_s
tate
)
{
public
function
ajaxCallback
(
array
$form
,
FormStateInterface
$form
S
tate
)
{
$response
=
new
AjaxResponse
();
$form
[
'message'
][
'widget'
][
0
][
'value'
][
'#value'
]
=
''
;
$response
->
addCommand
(
new
ReplaceCommand
(
NULL
,
$form
));
...
...
@@ -276,7 +276,7 @@ class PrivateMessageForm extends ContentEntityForm {
/**
* After build callback for the Private Message Form.
*/
public
function
afterBuild
(
array
$form
,
FormStateInterface
$form
_s
tate
)
{
public
function
afterBuild
(
array
$form
,
FormStateInterface
$form
S
tate
)
{
$form
[
'message'
][
'widget'
][
0
][
'format'
][
'#access'
]
=
FALSE
;
return
$form
;
}
...
...
@@ -284,16 +284,16 @@ class PrivateMessageForm extends ContentEntityForm {
/**
* {@inheritdoc}
*/
public
function
save
(
array
$form
,
FormStateInterface
$form
_s
tate
)
{
$status
=
parent
::
save
(
$form
,
$form
_s
tate
);
public
function
save
(
array
$form
,
FormStateInterface
$form
S
tate
)
{
$status
=
parent
::
save
(
$form
,
$form
S
tate
);
$members
=
$form
_s
tate
->
get
(
'thread_members'
);
$members
=
$form
S
tate
->
get
(
'thread_members'
);
if
(
!
$members
)
{
// Generate an array containing the members of the thread.
$current_user
=
$this
->
userManager
->
load
(
$this
->
currentUser
->
id
());
$members
=
[
$current_user
];
foreach
(
$form
_s
tate
->
getValue
(
'members'
)
as
$info
)
{
foreach
(
$form
S
tate
->
getValue
(
'members'
)
as
$info
)
{
$user
=
$this
->
userManager
->
load
(
$info
[
'target_id'
]);
if
(
$user
)
{
$members
[]
=
$user
;
...
...
@@ -308,11 +308,11 @@ class PrivateMessageForm extends ContentEntityForm {
$this
->
privateMessageThreadManager
->
saveThread
(
$this
->
entity
,
$members
,
[],
$private_message_thread
);
// Save the thread to the form state.
$form
_s
tate
->
set
(
'private_message_thread'
,
$private_message_thread
);
$form
S
tate
->
set
(
'private_message_thread'
,
$private_message_thread
);
// Send the user to the private message page. As this thread is the newest,
// it wll be at the top of the list.
$form
_s
tate
->
setRedirect
(
'entity.private_message_thread.canonical'
,
[
'private_message_thread'
=>
$private_message_thread
->
id
()]);
$form
S
tate
->
setRedirect
(
'entity.private_message_thread.canonical'
,
[
'private_message_thread'
=>
$private_message_thread
->
id
()]);
return
$status
;
}
...
...
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