Module Description
πΊπ¦ This module is maintained by Ukrainian developers. Please consider supporting Ukraine in a fight for their freedom and safety of Europe. Welcome to Socrates =====
Socrates is an OOP representation of https://en.wikipedia.org/wiki/Strategy_pattern for Open Y to cover needs of pluggable distributed Data Wrapper services by priority.
Basically, if you have a membership calculator which should be used for display same thing but for different Data Services, Socrates gives you a convenient opportunity to define which service should be used for obtaining data on specific project. The highest priority service will be chosen for retrieving data.
For connecting your service to Socrates you need to
- implement OpenyDataServiceInterface for the service's class - extend your_module.services.yml with tags
``` example_socrates_data_service: class: Drupal\openy_socrates\ExampleSocratesDataService tags: - { name: openy_data_service, priority: 1000 } ```
- replace the Data service with Socrates everywhere you need to have an ability to prioritize Data retrieving.
For connecting your service to Socrates Cron you need to:
- implement OpenyCronServiceInterface for the service's class - extend your_module.services.yml with a tags
``` example_socrates_cron_service: class: Drupal\openy_socrates\ExampleSocratesCronService tags: - name: openy_cron_service # In seconds from the last run. periodicity: 60 ```
Add the command to your crontab:
``` * * * * * drush ev '\Drupal::service("socrates")->cron();' ```
Your data class usage with Socrates is fairly simple:
``` /* @var \Drupal\my_module_data_service\dataService $dataService */ $myDataService = \Drupal::service('socrates'); $myDataService->myMethod(); ```
Socrates is an OOP representation of https://en.wikipedia.org/wiki/Strategy_pattern for Open Y to cover needs of pluggable distributed Data Wrapper services by priority.
Basically, if you have a membership calculator which should be used for display same thing but for different Data Services, Socrates gives you a convenient opportunity to define which service should be used for obtaining data on specific project. The highest priority service will be chosen for retrieving data.
For connecting your service to Socrates you need to
- implement OpenyDataServiceInterface for the service's class - extend your_module.services.yml with tags
``` example_socrates_data_service: class: Drupal\openy_socrates\ExampleSocratesDataService tags: - { name: openy_data_service, priority: 1000 } ```
- replace the Data service with Socrates everywhere you need to have an ability to prioritize Data retrieving.
For connecting your service to Socrates Cron you need to:
- implement OpenyCronServiceInterface for the service's class - extend your_module.services.yml with a tags
``` example_socrates_cron_service: class: Drupal\openy_socrates\ExampleSocratesCronService tags: - name: openy_cron_service # In seconds from the last run. periodicity: 60 ```
Add the command to your crontab:
``` * * * * * drush ev '\Drupal::service("socrates")->cron();' ```
Your data class usage with Socrates is fairly simple:
``` /* @var \Drupal\my_module_data_service\dataService $dataService */ $myDataService = \Drupal::service('socrates'); $myDataService->myMethod(); ```
Module Link
Project Usage
171
Security Covered
Not Covered By Security Advisory
Version Available
Production
Module Summary
Socrates solves the need for pluggable distributed Data Wrapper services by prioritizing different Data Services based on specific project requirements.
Data Name
openy_socrates