Skip to content

Commit d13ff3f

Browse files
committed
Update README.md
1 parent 0c7fb91 commit d13ff3f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,24 @@ Filling in the Blanks
7272
Much of what's here currently is cursory. Something I threw together to get people started. Nodes will all work, but custom classes can and should be built for specific node types. Currently only ProjectIssues and Pages are supported. I extracted essentially a base class Node from their overlap, and tried to create traits that made sense accordingly. Adding new NodeInterface implementing classes to \EclipseGc\DrupalOrg\Api\Resources\Node that are Pascal cased of the node bundle's name. For example a project_distribution node type class would be ProjectDistribution. The existing NodeInterface::getClass() method will return the appropriate class once it is available.
7373

7474
Adding new entity type base classes should be fairly straight forward. The system leverages Reflection for class instantiation. This is because the data objects are treated very rudimentarily in order to keep them as simple as possible. Constructors with many parameters (one for each top level json key in the response) are the order of the day. This is a bit tiresome but results in clean class properties and getter methods that we can document properly. Comments, Taxonomy Terms and Field Collects will all certainly need doing. Other entity types may become obvious as we continue. Look at Node::getClass() if you need references to how to do bundle-specific classes for your return objects.
75+
76+
Writing a Caching Layer
77+
==================
78+
79+
Caching the results in something like Redis or similar should be fairly easy with a decorator pattern on the FactoryInterface. There's a static method on the DrupalClient class specific to this purpose which you can get, decorate and then manually inject into the DrupalClient during instantiation instead of relying on the DrupalClient::create() method.
80+
81+
This can be simply through:
82+
83+
```php
84+
<?php
85+
86+
use EclipseGc\DrupalOrg\Api\DrupalClient;
87+
88+
$factory = DrupalClient::createFactory();
89+
$decoratedFactory = new MyExampleCachedFactory($factory);
90+
$client = new DrupalClient($decoratedFactory);
91+
92+
?>
93+
```
94+
95+
With something this simple, we should be able to provide some measure of caching support to the use case with a simple pattern.

0 commit comments

Comments
 (0)