Skip to content

Conversation

@Bilge
Copy link
Member

@Bilge Bilge commented Mar 30, 2018

Stop passing EncapsulatedOptions around in method calls, instead tying them to their Connector implementation. This makes sense because connectors have a 1:1 relationship with their options. That is, different options cannot be used with different connectors.

To make connectors and their options immutable during import, connectors are now cloned in Porter::fetch() and connectors exporting options must implement __clone() to deep clone their options. This addresses a dormant bug that failed to ensure connector options were immutable during import.

The new interface, ConnectorOptions must be implemented by connectors wishing to export options to ensure caching works correctly and to ensure Porter checks the connector implements the __clone method, which could not be specified in the interface due to a limitation in the mocking framework we're currently using (see mockery/mockery#669).

ProviderOptions has been completely removed because this made no sense. A providers only responsibility is to serve an appropriate connector for the specified resource, not to modify the connector or its configuration, which it couldn't even do without making assumptions about the connector's type, which it shouldn't do either. Implementations previously using this pattern should instead configure the connector properly before it's injected into the provider. Any methods for manipulating connector options implemented in the provider should be implemented in the connector instead.

@Bilge Bilge added this to the 4.0.0 milestone Mar 30, 2018
@Bilge Bilge force-pushed the no-option-passing branch from 68123ad to 98990d3 Compare March 30, 2018 18:55
Removed ProviderOptions.
Added ConnectorOptions interface and accompanying trait.
Forced ConnectorOptions to implement __clone in Porter.

These changes stop passing EncapsulatedOptions around in method calls,
instead tieing them to their Connector implementation. This makes sense
because connectors have a 1:1 relationship with their options. That is,
different options cannot be used with different connectors.

To make connectors and their options immutable during import, connectors
are now cloned in Porter::fetch() and connectors exporting options must
implement __clone() to deep clone their options.
@Bilge Bilge force-pushed the no-option-passing branch from 98990d3 to 0a80812 Compare March 30, 2018 19:00
@codecov-io
Copy link

codecov-io commented Mar 30, 2018

Codecov Report

Merging #48 into 4.0 will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@         Coverage Diff         @@
##            4.0    #48   +/-   ##
===================================
  Coverage   100%   100%           
===================================
  Files        29     29           
  Lines       371    327   -44     
===================================
- Hits        371    327   -44
Impacted Files Coverage Δ
src/Porter.php 100% <100%> (ø) ⬆️
src/Connector/NullConnector.php 100% <100%> (ø) ⬆️
src/Connector/ImportConnector.php 100% <100%> (ø) ⬆️
src/Connector/CachingConnector.php 100% <100%> (ø) ⬆️
src/Collection/RecordCollection.php 100% <100%> (ø) ⬆️
src/Type/ObjectType.php 100% <100%> (ø) ⬆️
src/Collection/FilteredRecords.php 100% <0%> (ø) ⬆️
src/Connector/ConnectionContextFactory.php 100% <0%> (ø) ⬆️
src/Provider/ProviderFactory.php 100% <0%> (ø) ⬆️
src/Collection/ProviderRecords.php 100% <0%> (ø) ⬆️
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 653774c...91ecee9. Read the comment docs.

@Bilge Bilge merged commit 91ecee9 into 4.0 Mar 31, 2018
@Bilge Bilge deleted the no-option-passing branch April 9, 2018 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants