Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

openy_socrates

162 sites No security coverage
View on drupal.org

πŸ‡ΊπŸ‡¦

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();

Activity

Total releases
2
First release
May 2025
Latest release
9 months ago
Release cadence
59 days
Stability
100% stable

Releases

Version Type Release date
1.1.0 Stable Jun 30, 2025
1.0.4 Stable May 2, 2025