Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
salesforce-3257058
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
salesforce-3257058
Commits
d6f08c1e
Commit
d6f08c1e
authored
8 years ago
by
Aaron Bauman
Browse files
Options
Downloads
Patches
Plain Diff
fix constructor per testability concerns
parent
5c9dbe50
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/salesforce_mapping/src/Entity/MappedObject.php
+14
-11
14 additions, 11 deletions
modules/salesforce_mapping/src/Entity/MappedObject.php
with
14 additions
and
11 deletions
modules/salesforce_mapping/src/Entity/MappedObject.php
+
14
−
11
View file @
d6f08c1e
...
...
@@ -56,9 +56,6 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject
protected
$sf_object
=
NULL
;
protected
$drupal_entity
=
NULL
;
// Drupal\salesforce\RestClient
protected
$client
;
/**
* Overrides ContentEntityBase::__construct().
*/
...
...
@@ -71,7 +68,6 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject
}
}
parent
::
__construct
(
$values
,
'salesforce_mapped_object'
);
$this
->
client
=
\Drupal
::
service
(
'salesforce.client'
);
}
/**
...
...
@@ -232,12 +228,19 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject
return
l
(
$this
->
sfid
(),
$this
->
getSalesforceUrl
(),
$options
);
}
/**
* Wrapper for salesforce.client Drupal\salesforce\Rest\RestClient service
*/
public
function
client
()
{
return
\Drupal
::
service
(
'salesforce.client'
);
}
/**
* @return string
*/
public
function
getSalesforceUrl
()
{
// @TODO dependency injection here:
return
$this
->
client
->
getInstanceUrl
()
.
'/'
.
$this
->
salesforce_id
->
value
;
return
$this
->
client
()
->
getInstanceUrl
()
.
'/'
.
$this
->
salesforce_id
->
value
;
}
/**
...
...
@@ -276,7 +279,7 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject
$action
=
''
;
if
(
$mapping
->
hasKey
())
{
$action
=
'upsert'
;
$result
=
$this
->
client
->
objectUpsert
(
$result
=
$this
->
client
()
->
objectUpsert
(
$mapping
->
getSalesforceObjectType
(),
$mapping
->
getKeyField
(),
$mapping
->
getKeyValue
(
$drupal_entity
),
...
...
@@ -285,7 +288,7 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject
}
elseif
(
$this
->
sfid
())
{
$action
=
'update'
;
$this
->
client
->
objectUpdate
(
$this
->
client
()
->
objectUpdate
(
$mapping
->
getSalesforceObjectType
(),
$this
->
sfid
(),
$params
->
getParams
()
...
...
@@ -293,7 +296,7 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject
}
else
{
$action
=
'create'
;
$result
=
$this
->
client
->
objectCreate
(
$result
=
$this
->
client
()
->
objectCreate
(
$mapping
->
getSalesforceObjectType
(),
$params
->
getParams
()
);
...
...
@@ -329,7 +332,7 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject
*/
public
function
pushDelete
()
{
$mapping
=
$this
->
salesforce_mapping
->
entity
;
$this
->
client
->
objectDelete
(
$mapping
->
getSalesforceObjectType
(),
$this
->
sfid
());
$this
->
client
()
->
objectDelete
(
$mapping
->
getSalesforceObjectType
(),
$this
->
sfid
());
$this
->
setNewRevision
(
TRUE
);
$this
->
set
(
'last_sync_action'
,
'push_delete'
)
...
...
@@ -365,13 +368,13 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject
// If the pull isn't coming from a cron job.
if
(
$this
->
sf_object
==
NULL
)
{
if
(
$this
->
sfid
())
{
$this
->
sf_object
=
$this
->
client
->
objectRead
(
$this
->
sf_object
=
$this
->
client
()
->
objectRead
(
$mapping
->
getSalesforceObjectType
(),
$this
->
sfid
()
);
}
elseif
(
$mapping
->
hasKey
())
{
$this
->
sf_object
=
$this
->
client
->
objectReadbyExternalId
(
$this
->
sf_object
=
$this
->
client
()
->
objectReadbyExternalId
(
$mapping
->
getSalesforceObjectType
(),
$mapping
->
getKeyField
(),
$mapping
->
getKeyValue
(
$this
->
drupal_entity
)
...
...
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