Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Open Y Socrates

143 sites No security coverage Drupal 10–11
View on drupal.org

This module implements a strategy pattern to manage pluggable data wrapper services with varying priorities. It allows you to define which service should be used to retrieve data based on the highest priority defined for a specific project. This can also be extended to manage cron services with specified periodicities.

πŸ‡ΊπŸ‡¦

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")-&gt;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-&gt;myMethod();

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

1 tracked project depends on this one

Activity

Tracked releases
2
Tracked since
May 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Dormant

Releases

Version Type Core Release date
1.1.0 Stable 10–11 Jun 30, 2025
1.0.4 Stable 9–11 May 2, 2025