Skip to content

Commit 14d10cf

Browse files
committed
add description of the interfaces
1 parent d577e98 commit 14d10cf

14 files changed

+269
-0
lines changed

Diff for: index.md

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Too short? Confused? You should probably read the documentation. 😉
8080
- [Configure the SAP remote function call](saprfc-function)
8181
* [DateTime conversions for SAP](datetime)
8282
* [Docker images with SAP modules](docker)
83+
* [Implementing PHP/SAP using the interfaces](interfaces.md)
8384

8485
[koucky]: http://saprfc.sourceforge.net/ "SAPRFC extension module for PHP"
8586
[harding]: https://github.com/piersharding/php-sapnwrfc "SAP RFC Connector using the SAP NW RFC SDK for PHP"

Diff for: interfaces-api.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## API
2+
3+
* The `IApi` interfaces manages the elements of the remote function.
4+
* `IApiElement` defines an element of an API with attributes all elements have in common: name, type, direction, and optional-flag.
5+
* `IValue`, `IStruct`, and `ITable` all add a `cast()` method for typecasting.
6+
* `IStruct` and `ITable` contain a list of `IMember` members.
7+
* `IMember` is a member of `IStruct` or `ITable` and only has name and type attributes.
8+
9+
[![API interfaces](res/interfaces-api.svg)](res/interfaces-api.svg)
10+
11+
---
12+
13+
[Go back to the interfaces overview](interfaces)

Diff for: interfaces-config.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Configuration
2+
3+
* `IConfiguration` Defines methods for configuration management and (un)serialization. It configures connection parameters, that are common to both connection types (A, and B).
4+
* `IConfigA` Configure connection parameters for SAP remote function calls using a specific SAP application server (type A).
5+
* `IConfigB` Configure connection parameters for SAP remote function calls using load balancing (type B).
6+
7+
[![Configuration Interfaces](res/interfaces-config.svg)](res/interfaces-config.svg)
8+
9+
---
10+
11+
[Go back to the interfaces overview](interfaces)

Diff for: interfaces-exceptions.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Exceptions
2+
3+
* `ISapException` A generic parent exception in order to catch SAP remote function call exceptions in general.
4+
* `IArrayElementMissingException` In case the API description of the SAP remote function call defines a member element in an `IArray` that is not present in the given data.
5+
* `IConfigKeyNotFoundException` In case a requested configuration key is missing.
6+
* `IConnectionFailedException` The connection to the remote SAP system failed.
7+
* `IFunctionCallException` In case the SAP remote function call failed for some reason.
8+
* `IIncompleteConfigException` The connection configuration doesn't contain all the necessary parameters.
9+
* `IUnknownFunctionException` The SAP remote function cannot be found using the given connection parameters.
10+
11+
[![Exceptions](res/interfaces-exceptions.svg)](res/interfaces-exceptions.svg)
12+
13+
---
14+
15+
[Go back to the interfaces overview](interfaces)

Diff for: interfaces-function.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Function
2+
3+
There are three ways to create a function instance:
4+
5+
1. Factory method: `create()` which takes all necessary information via its parameters.
6+
2. Decoding a formerly JSON encoded function instance using `jsonDecode()`.
7+
3. The constructor accepts an associative array created from `json_decode()` of a formerly JSON encoded function instance.
8+
9+
* The `IFunction` interface defines how functions are handled:
10+
* `create()` is a factory method creating a function instance.
11+
* `extractApi()` queries the SAP remote function for its API circumventing the internal cache.
12+
* `getApi()` returns the API of the SAP remote function and caches the result.
13+
* `getConfiguration()` returns the configuration used to connect to the SAP system.
14+
* `getName()` the SAP remote function name.
15+
* `getParams()` returns an array of SAP remote function call parameters set by `setParams()`.
16+
* `invoke()` invokes the SAP remote function call and returns its result.
17+
* `resetParams()` removes any SAP remote function call parameters set by `setParams()`.
18+
* `setApi()` manually sets the API of the SAP remote function.
19+
* `setConfiguration()` sets the configuration used to connect to the SAP system.
20+
* `setParams()` sets an array of SAP remote function call parameters.
21+
22+
[![API function](res/interfaces-function.svg)](res/interfaces-function.svg)
23+
24+
---
25+
26+
[Go back to the interfaces overview](interfaces)

Diff for: interfaces.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Interfaces
2+
3+
The following PHP/SAP interfaces are available in namespace `phpsap\interfaces`. See the [php-sap/interfaces repository on github][interfaces].
4+
5+
### Configuration
6+
7+
The configuration interfaces are used to describe connection configuration parameters and their (un)serialization. They are separated into a generic configuration management interface, a common SAP configuration, that contains connection parameters that are common to both connection types (A and B), and connection type specific SAP configuration.
8+
9+
[Continue to the configuration interfaces...](interfaces-config)
10+
11+
### API
12+
13+
The API interfaces are used to describe the API of the SAP remote function. They are separated by their number of attributes. An element, has only type and name attributes, while a value adds a direction and an optional flag and an array adds Sub-members which can only be elements.
14+
15+
[Continue to the API interfaces...](interfaces-api)
16+
17+
### Exceptions
18+
19+
The exception interfaces are used to describe the result of methods in case of errors. They are all children to the overall `ISapException` which should make it easy to generally catch exceptions. Please keep in mind, to throw `InvalidArgumentException` or `LogicException` in case of programming errors as they have nothing to do with the SAP remote function call.
20+
21+
[Continue to the exception interfaces...](interfaces-exceptions)
22+
23+
### Function
24+
25+
The function interface is used to describe how a SAP remove function call is created and invoked.
26+
27+
[Continue to the function interface...](interfaces-function)
28+
29+
[interfaces]: https://github.com/php-sap/interfaces "Interfaces for implementing the PHP/SAP API."

Diff for: res/interfaces-api.svg

+1
Loading

Diff for: res/interfaces-api.txt

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@startuml
2+
3+
!theme plain
4+
top to bottom direction
5+
skinparam linetype ortho
6+
7+
class IApi {
8+
getInputElements():
9+
getOutputElements():
10+
add(element):
11+
getTables():
12+
getChangingElements():
13+
}
14+
class IApiElement {
15+
getDirection():
16+
isOptional():
17+
getType():
18+
getName():
19+
}
20+
class IJsonSerializable {
21+
__construct(array):
22+
jsonDecode(json):
23+
}
24+
class IMember {
25+
__construct(array):
26+
create(type, name):
27+
cast(value):
28+
getType():
29+
getName():
30+
}
31+
class IStruct {
32+
__construct(array):
33+
create(name, direction, isOptional, members):
34+
getMembers():
35+
cast(value):
36+
}
37+
class ITable {
38+
__construct(array):
39+
create(name, direction, isOptional, members):
40+
getMembers():
41+
cast(value):
42+
}
43+
class IValue {
44+
__construct(array):
45+
create(type, name, direction, isOptional):
46+
cast(value):
47+
}
48+
class JsonSerializable {
49+
jsonSerialize():
50+
}
51+
52+
IApi -[#008200,plain]-^ IJsonSerializable
53+
IApiElement -[#008200,plain]-^ IJsonSerializable
54+
IJsonSerializable -[#008200,plain]-^ JsonSerializable
55+
IMember -[#008200,plain]-^ IJsonSerializable
56+
IStruct -[#008200,plain]-^ IApiElement
57+
ITable -[#008200,plain]-^ IApiElement
58+
IValue -[#008200,plain]-^ IApiElement
59+
@enduml

0 commit comments

Comments
 (0)