Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
salesforce
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
salesforce
Commits
de95342e
Commit
de95342e
authored
6 years ago
by
Aaron Bauman
Browse files
Options
Downloads
Patches
Plain Diff
Remove deprecated method calls from salesforce.install update hooks
parent
5694c6f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
salesforce.install
+31
-11
31 additions, 11 deletions
salesforce.install
with
31 additions
and
11 deletions
salesforce.install
+
31
−
11
View file @
de95342e
...
@@ -9,6 +9,7 @@ use Drupal\Core\Url;
...
@@ -9,6 +9,7 @@ use Drupal\Core\Url;
use
Drupal\Component\Serialization\Json
;
use
Drupal\Component\Serialization\Json
;
use
Drupal\salesforce\Entity\SalesforceAuthConfig
;
use
Drupal\salesforce\Entity\SalesforceAuthConfig
;
use
Drupal\salesforce\SalesforceAuthProviderPluginManager
;
use
Drupal\salesforce\SalesforceAuthProviderPluginManager
;
use
Drupal\salesforce\Token\SalesforceToken
;
use
OAuth\Common\Storage\Exception\TokenNotFoundException
;
use
OAuth\Common\Storage\Exception\TokenNotFoundException
;
/**
/**
...
@@ -267,9 +268,6 @@ function salesforce_update_8004() {
...
@@ -267,9 +268,6 @@ function salesforce_update_8004() {
\Drupal
::
cache
()
->
delete
(
'salesforce:objects'
);
\Drupal
::
cache
()
->
delete
(
'salesforce:objects'
);
}
}
/**
* Convert legacy oauth credentials to new auth plugin config.
*/
/**
/**
* Convert legacy oauth credentials to new auth plugin config.
* Convert legacy oauth credentials to new auth plugin config.
*/
*/
...
@@ -290,7 +288,27 @@ function salesforce_update_8005() {
...
@@ -290,7 +288,27 @@ function salesforce_update_8005() {
$message
=
'Existing "oauth_default" provider config detected. Refused to set legacy credentials.'
;
$message
=
'Existing "oauth_default" provider config detected. Refused to set legacy credentials.'
;
}
}
else
{
else
{
SalesforceAuthProviderPluginManager
::
updateAuthConfig
();
/** @var \Drupal\salesforce\Entity\SalesforceAuthConfig $oauth */
$oauth
=
NULL
;
$config
=
\Drupal
::
configFactory
()
->
getEditable
(
'salesforce.settings'
);
// Config to new plugin config system.
$values
=
[
'id'
=>
'oauth_default'
,
'label'
=>
'OAuth Default'
,
'provider'
=>
'oauth'
,
];
$oauth
=
SalesforceAuthConfig
::
create
(
$values
);
$settings
=
[
'consumer_key'
=>
$config
->
get
(
'consumer_key'
),
'consumer_secret'
=>
$config
->
get
(
'consumer_secret'
),
'login_url'
=>
$config
->
get
(
'login_url'
),
];
$oauth
->
set
(
'provider_settings'
,
$settings
)
->
save
();
$config
->
set
(
'salesforce_auth_provider'
,
'oauth_default'
)
->
save
();
$message
=
'Default OAuth provider created from legacy credentials.'
;
$message
=
'Default OAuth provider created from legacy credentials.'
;
}
}
return
$message
;
return
$message
;
...
@@ -300,19 +318,21 @@ function salesforce_update_8005() {
...
@@ -300,19 +318,21 @@ function salesforce_update_8005() {
* Convert legacy token to new auth plugin config.
* Convert legacy token to new auth plugin config.
*/
*/
function
salesforce_update_8006
()
{
function
salesforce_update_8006
()
{
/** @var \Drupal\salesforce\Entity\SalesforceAuthConfig $oauth */
$oauth
=
SalesforceAuthConfig
::
load
(
'oauth_default'
);
$oauth
=
SalesforceAuthProviderPluginManager
::
getAuthConfig
();
if
(
!
$oauth
)
{
if
(
!
$oauth
)
{
return
"Auth config missing. Refused to update legacy token."
;
return
"Auth config missing. Refused to update legacy token."
;
}
}
try
{
try
{
if
(
\Drupal
::
service
(
'salesforce.auth_token_storage'
)
\Drupal
::
service
(
'salesforce.auth_token_storage'
)
->
retrieveAccessToken
(
$oauth
->
id
()))
{
->
retrieveAccessToken
(
$oauth
->
id
());
return
"Token exists. Refused to update."
;
return
"Token exists. Refused to update."
;
}
}
}
catch
(
TokenNotFoundException
$e
)
{
catch
(
TokenNotFoundException
$e
)
{
\Drupal
::
service
(
'salesforce.auth_token_storage'
)
->
updateToken
();
\Drupal
::
service
(
'salesforce.auth_token_storage'
)
->
storeAccessToken
(
'oauth_default'
,
new
SalesforceToken
(
\Drupal
::
state
()
->
get
(
'salesforce.access_token'
),
\Drupal
::
state
()
->
get
(
'salesforce.refresh_token'
)));
return
"Updated legacy token to new plugin config."
;
return
"Updated legacy token to new plugin config."
;
}
}
}
}
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