Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ik_constant_contact
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
ik_constant_contact
Commits
ed18a41b
Commit
ed18a41b
authored
Mar 28, 2024
by
Rosemary Reilman
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3432136
by fractile81: Delay getConfig() Calls in ConstantContact.php
parent
94535f04
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Service/ConstantContact.php
+61
-45
61 additions, 45 deletions
src/Service/ConstantContact.php
with
61 additions
and
45 deletions
src/Service/ConstantContact.php
+
61
−
45
View file @
ed18a41b
...
...
@@ -340,8 +340,6 @@ class ConstantContact {
* @see https://v3.developer.constantcontact.com/api_reference/index.html#!/Contacts/createContact
*/
private
function
createContact
(
array
$data
,
$listIDs
)
{
$config
=
$this
->
getConfig
();
$body
=
(
object
)
[
'email_address'
=>
(
object
)
[
'address'
=>
NULL
,
...
...
@@ -364,6 +362,10 @@ class ConstantContact {
$this
->
moduleHandler
->
invokeAll
(
'ik_constant_contact_contact_data_alter'
,
[
$data
,
&
$body
]);
$this
->
moduleHandler
->
invokeAll
(
'ik_constant_contact_contact_create_data_alter'
,
[
$data
,
&
$body
]);
// Waiting to pull the configuration until now in case the refreshToken()
// call changes the active tokens.
$config
=
$this
->
getConfig
();
try
{
$response
=
$this
->
httpClient
->
request
(
'POST'
,
$config
[
'contact_url'
],
[
'headers'
=>
[
...
...
@@ -604,7 +606,6 @@ class ConstantContact {
*
*/
public
function
getContactLists
(
$cached
=
true
)
{
$config
=
$this
->
getConfig
();
$cid
=
'ik_constant_contact.lists'
;
$cache
=
(
$cached
===
true
?
$this
->
cache
->
get
(
$cid
)
:
null
);
...
...
@@ -615,6 +616,10 @@ class ConstantContact {
// Update access tokens.
$this
->
refreshToken
(
false
);
// Waiting to pull the configuration until now in case the refreshToken()
// call changes the active tokens.
$config
=
$this
->
getConfig
();
if
(
isset
(
$config
[
'access_token'
]))
{
try
{
$response
=
$this
->
httpClient
->
request
(
'GET'
,
$config
[
'contact_lists_url'
],
[
...
...
@@ -999,8 +1004,6 @@ class ConstantContact {
* an array here and an object in updateContact.
*/
private
function
putContact
(
array
$contact
,
array
$data
,
$listIDs
)
{
$config
=
$this
->
getConfig
();
$body
=
(
object
)
$contact
;
$body
=
$this
->
buildResponseBody
(
$data
,
$body
);
...
...
@@ -1014,6 +1017,10 @@ class ConstantContact {
$this
->
moduleHandler
->
invokeAll
(
'ik_constant_contact_contact_data_alter'
,
[
$data
,
&
$body
]);
$this
->
moduleHandler
->
invokeAll
(
'ik_constant_contact_contact_update_data_alter'
,
[
$data
,
&
$body
]);
// Waiting to pull the config until now so that any config changes can take
// immediate effect.
$config
=
$this
->
getConfig
();
try
{
$response
=
$this
->
httpClient
->
request
(
'PUT'
,
$config
[
'contact_url'
]
.
'/'
.
$contact
[
'contact_id'
],
[
'headers'
=>
[
...
...
@@ -1225,6 +1232,10 @@ class ConstantContact {
$this
->
moduleHandler
->
invokeAll
(
'ik_constant_contact_contact_data_alter'
,
[
$data
,
&
$body
]);
$this
->
moduleHandler
->
invokeAll
(
'ik_constant_contact_contact_form_submission_alter'
,
[
$data
,
&
$body
]);
// Pulling the config again so that any config changes can take immediate
// effect.
$config
=
$this
->
getConfig
();
try
{
$response
=
$this
->
httpClient
->
request
(
'POST'
,
$config
[
'contact_url'
]
.
'/sign_up_form'
,
[
'headers'
=>
[
...
...
@@ -1267,7 +1278,6 @@ class ConstantContact {
*
*/
public
function
unsubscribeContact
(
array
$data
)
{
$config
=
$this
->
getConfig
();
// Check if contact already exists.
$exists
=
(
array
)
$this
->
getContact
(
$data
);
$body
=
null
;
...
...
@@ -1291,6 +1301,10 @@ class ConstantContact {
$this
->
moduleHandler
->
invokeAll
(
'ik_constant_contact_contact_data_alter'
,
[
$data
,
&
$body
]);
$this
->
moduleHandler
->
invokeAll
(
'ik_constant_contact_contact_unsubscribe_data_alter'
,
[
$data
,
&
$body
]);
// Waiting to pull the config until now so that any config changes can take
// immediate effect.
$config
=
$this
->
getConfig
();
try
{
$response
=
$this
->
httpClient
->
request
(
'PUT'
,
$config
[
'contact_url'
]
.
'/'
.
$exists
->
contact_id
,
[
'headers'
=>
[
...
...
@@ -1335,8 +1349,6 @@ class ConstantContact {
* @see https://v3.developer.constantcontact.com/api_reference/index.html#!/Contacts/putContact
*/
private
function
updateContact
(
array
$data
,
$contact
,
$listIDs
)
{
$config
=
$this
->
getConfig
();
if
(
$contact
&&
property_exists
(
$contact
,
'contact_id'
))
{
$body
=
$contact
;
...
...
@@ -1351,6 +1363,10 @@ class ConstantContact {
$this
->
moduleHandler
->
invokeAll
(
'ik_constant_contact_contact_data_alter'
,
[
$data
,
&
$body
]);
$this
->
moduleHandler
->
invokeAll
(
'ik_constant_contact_contact_update_data_alter'
,
[
$data
,
&
$body
]);
// Waiting to pull the config until now so that any config changes can take
// immediate effect.
$config
=
$this
->
getConfig
();
try
{
$response
=
$this
->
httpClient
->
request
(
'PUT'
,
$config
[
'contact_url'
]
.
'/'
.
$contact
->
contact_id
,
[
'headers'
=>
[
...
...
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