This project is not covered by Drupal’s security advisory policy.
🇺🇦 |
This module is maintained by Ukrainian developers. Please consider supporting Ukraine in a fight for their freedom and safety of Europe. |
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
<span class="hljs-attribute">example_socrates_data_service</span>: <span class="hljs-attribute">class</span>: Drupal\openy_socrates\ExampleSocratesDataService <span class="hljs-attribute">tags</span>: - { <span class="hljs-attribute">name</span>: openy_data_service, <span class="hljs-attribute">priority</span>: <span class="hljs-number">1000</span> }
- 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
<span class="hljs-attr"> example_socrates_cron_service:</span> <span class="hljs-attr"> class:</span> Drupal\openy_socrates\ExampleSocratesCronService <span class="hljs-attr"> tags:</span> <span class="hljs-bullet"> -</span> <span class="hljs-attr"> name:</span> openy_cron_service <span class="hljs-comment"># In seconds from the last run.</span> <span class="hljs-attr"> periodicity:</span> <span class="hljs-number">60</span>
Add the command to your crontab:
<span class="hljs-bullet">* </span><span class="hljs-bullet">* *</span> <span class="hljs-bullet">* *</span> drush ev '\Drupal::service("socrates")->cron();'
Your data class usage with Socrates is fairly simple:
<span class="hljs-comment">/* <span class="hljs-doctag">@var</span> \Drupal\my_module_data_service\dataService $dataService */</span> $myDataService = \Drupal::service(<span class="hljs-string">'socrates'</span>); $myDataService->myMethod();
Project information
Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed.Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: Decoupled, Developer tools, Import and export
- Ecosystem: YMCA Website Services (former Open Y) Community Edition, Open Y Mappings
145 sites report using this module
- Created by podarok on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.




