Skip to content

Commit

Permalink
Merge pull request apex-enterprise-patterns#2 in OSD/force-di from op…
Browse files Browse the repository at this point in the history
…ensource_master to master

* commit 'fefc4f27b3abf695e7cc8911d9c9e8ca79d9e8cc':
  moving some files around
  moving some files around
  moving some files around to get the case correct
  moving some files around to get the "case" correct on the file name
  Fixes apex-enterprise-patterns#33
  Updated sourceApiVersion to v44.0 and made changes to flows to support new "version-less format"
  Added DF18 recording
  fixes apex-enterprise-patterns#31
  Update README.md
  fix typo
  • Loading branch information
Tory Netherton authored and Tory Netherton committed Feb 11, 2019
2 parents e213fc0 + fefc4f2 commit 672ec23
Show file tree
Hide file tree
Showing 23 changed files with 133 additions and 52 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Force DI

Generic [DI](https://en.wikipedia.org/wiki/Dependency_injection) library with support for injecting Apex, Visualforce and Lightning code at runtime.
Generic [dependency injection](https://en.wikipedia.org/wiki/Dependency_injection) (DI) library with support for injecting Apex, Visualforce, Lightning, and Flows at runtime.

Documentaiton
Documentation
-------------
- [General overview of the library features, configuration and use of Injectors](https://andyinthecloud.com/2018/07/15/managing-dependency-injection-within-salesforce/)
- [Using the library to aid with Test Driven Development in Apex](https://andyinthecloud.com/2018/07/29/test-driven-development-mocking-and-force-di/)
- [Dependency Injection, Flows, and Force DI](https://douglascayers.com/2018/08/05/dependency-injection-flows-and-force-di/)
- [Adopting Dependency Injection](https://douglascayers.com/2018/08/29/adopting-dependency-injection/)
- [General overview of the library features, configuration and use of Injectors](https://andyinthecloud.com/2018/07/15/managing-dependency-injection-within-salesforce/) (blog)
- [Using the library to aid with Test Driven Development in Apex](https://andyinthecloud.com/2018/07/29/test-driven-development-mocking-and-force-di/) (blog)
- [Dependency Injection, Flows, and Force DI](https://douglascayers.com/2018/08/05/dependency-injection-flows-and-force-di/) (blog)
- [Adopting Dependency Injection](https://douglascayers.com/2018/08/29/adopting-dependency-injection/) (webinar)
- [Understanding the Value of Dependency Injection in the Lightning Platform](https://www.youtube.com/watch?v=oce2QO-E_3k) (DF18 session)

Project Folders
---------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Runtime Binding Demo Org</label>
<protected>false</protected>
<values>
<field>BindingObjectAlternate__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>BindingObject__c</field>
<value xsi:nil="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Get String Flow</label>
<protected>false</protected>
<values>
<field>BindingObjectAlternate__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>BindingObject__c</field>
<value xsi:nil="true"/>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<label>Hello World</label>
<processType>AutoLaunchedFlow</processType>
<startElementReference>Hello_World</startElementReference>
<status>Active</status>
<variables>
<name>flowString</name>
<dataType>String</dataType>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Alert Customer for Account Trigger</label>
<protected>false</protected>
<values>
<field>BindingObjectAlternate__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>BindingObject__c</field>
<value xsi:type="xsd:string">Account</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Account Record Flow</label>
<protected>false</protected>
<values>
<field>BindingObjectAlternate__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>BindingObject__c</field>
<value xsi:nil="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Account Record Flow VF</label>
<protected>false</protected>
<values>
<field>BindingObjectAlternate__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>BindingObject__c</field>
<value xsi:nil="true"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Component A to B</label>
<protected>false</protected>
<values>
<field>BindingObjectAlternate__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>BindingObject__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>BindingSequence__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>To__c</field>
<value xsi:type="xsd:string">c:componentB</value>
</values>
<values>
<field>Type__c</field>
<value xsi:type="xsd:string">LightningComponent</value>
</values>
</CustomMetadata>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Widget Wizard</label>
<protected>false</protected>
<values>
<field>BindingObjectAlternate__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>BindingObject__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>BindingSequence__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>To__c</field>
<value xsi:type="xsd:string">c:widgetWizard</value>
</values>
<values>
<field>Type__c</field>
<value xsi:type="xsd:string">LightningComponent</value>
</values>
</CustomMetadata>

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ varDateTime: {!varDateTime}</fieldText>
<showHeader>true</showHeader>
</screens>
<startElementReference>Get_Account</startElementReference>
<status>Active</status>
<variables>
<name>recordId</name>
<dataType>String</dataType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ In the Outputs tab, select the expected data type in the &quot;Source&quot; fiel
<label>Account Record Flow VF</label>
<processType>Flow</processType>
<startElementReference>Get_Record_Id</startElementReference>
<status>Active</status>
<subflows>
<description>Passing flow variables to an existing flow for reuse and to separate concerns of needing to use Binding Param invocable apex action to retrieve flow parameters in Visualforce context.</description>
<name>Account_Record_Flow</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>force-app-3 Module</label>
<protected>false</protected>
<values>
<field>BindingObjectAlternate__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>BindingObject__c</field>
<value xsi:nil="true"/>
Expand Down
16 changes: 10 additions & 6 deletions force-di/main/classes/di_Injector.cls
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,22 @@ public class di_Injector {
**/
private class CustomMetadataModule extends di_Module {

private string bindingObjectApiName = null;

public override void configure() {
// TODO: Support Namespace
for(di_Binding__mdt bindingConfig :
[select QualifiedAPIName, DeveloperName, NamespacePrefix,
Type__c, To__c, BindingObject__c, BindingSequence__c
from di_Binding__mdt]) {
[select QualifiedAPIName, DeveloperName, NamespacePrefix
, Type__c, To__c, BindingObject__c, BindingObject__r.QualifiedApiName
, BindingObjectAlternate__c, BindingSequence__c
from di_Binding__mdt]) {
bind(bindingConfig.DeveloperName);
type(bindingConfig.Type__c);
if(String.isNotBlank(bindingConfig.BindingObject__c)) {
Schema.DescribeSobjectResult[] results = Schema.describeSObjects(new String[] { bindingConfig.BindingObject__c.toLowerCase().trim() });
if(String.isNotBlank(bindingConfig.BindingObject__c) || String.isNotBlank(bindingConfig.BindingObjectAlternate__c)) {
bindingObjectApiName = String.isNotBlank(bindingConfig.BindingObject__c) ? bindingConfig.BindingObject__r.QualifiedApiName.toLowerCase().trim() : bindingConfig.BindingObjectAlternate__c.toLowerCase().trim();
Schema.DescribeSobjectResult[] results = Schema.describeSObjects(new String[] { bindingObjectApiName });
if(results.size() != 1) {
throw new InjectorException('Failed to find SObject ' + bindingConfig.BindingObject__c + ' referened by binding ' + bindingConfig.DeveloperName );
throw new InjectorException('Failed to find SObject ' + bindingObjectApiName + ' referened by binding ' + bindingConfig.DeveloperName );
}
bind(results[0].getSObjectType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
<behavior>Edit</behavior>
<field>BindingObject__c</field>
</layoutItems>
<layoutItems>
<behavior>Edit</behavior>
<field>BindingObjectAlternate__c</field>
</layoutItems>
</layoutColumns>
<layoutColumns>
<layoutItems>
Expand Down Expand Up @@ -89,7 +93,7 @@
<showRunAssignmentRulesCheckbox>false</showRunAssignmentRulesCheckbox>
<showSubmitAndAttachButton>false</showSubmitAndAttachButton>
<summaryLayout>
<masterLabel>00hZ0000000qrei</masterLabel>
<masterLabel>00h0m000000cQew</masterLabel>
<sizeX>4</sizeX>
<sizeY>0</sizeY>
<summaryLayoutStyle>Default</summaryLayoutStyle>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>BindingObjectAlternate__c</fullName>
<description>Use this field to specify the SObject API name to bind to when the &quot;Binding Object&quot; field does not list that particular SObject. Only specify the &quot;Binding Object&quot; field or this one; not both.</description>
<externalId>false</externalId>
<fieldManageability>SubscriberControlled</fieldManageability>
<inlineHelpText>Use this field to specify the SObject API name to bind to when the &quot;Binding Object&quot; field does not list that particular SObject. Only specify the &quot;Binding Object&quot; field or this one; not both.</inlineHelpText>
<label>Binding Object Alternate</label>
<length>255</length>
<required>false</required>
<type>Text</type>
<unique>false</unique>
</CustomField>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<ListView xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>All</fullName>
<columns>MasterLabel</columns>
<columns>BindingObject__c</columns>
<columns>BindingObjectAlternate__c</columns>
<columns>BindingSequence__c</columns>
<columns>To__c</columns>
<columns>Type__c</columns>
<filterScope>Everything</filterScope>
<label>All</label>
</ListView>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<ValidationRule xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>BindObj_Or_BindObjAlt</fullName>
<active>true</active>
<description>This validation rule ensures that only the &quot;Binding Object&quot; or the &quot;Binding Object Alternate&quot; field is specified and not both.</description>
<errorConditionFormula>NOT( ISBLANK( BindingObject__c ) ) &amp;&amp; NOT( ISBLANK( BindingObjectAlternate__c ) )</errorConditionFormula>
<errorMessage>Only specify the &quot;Binding Object&quot; field or the &quot;Binding Object Alternate&quot; field; not both.</errorMessage>
</ValidationRule>
2 changes: 1 addition & 1 deletion sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "43.0",
"sourceApiVersion": "44.0",
"packageAliases": {
"force-di": "0Ho1N000000GmaTSAS",
"[email protected]": "04t1N000000Cr1fQAC",
Expand Down

0 comments on commit 672ec23

Please sign in to comment.