Ext: sg_consistence

License: GNU GPL, Version 2

Repository: https://gitlab.sgalinski.de/typo3/sg_consistence

TYPO3 version: >=10.4

Things you should take care of:

  • The services need to be in the following path: "Classes\Domain\Consistence\"
  • They need to have this suffix: "Consistence"
  • Each service needs to extend this class: "\SGalinski\SgConsistence\Domain\Consistence\AbstractConsistence"
  • If you adapt the values of a domain object, then you must write them directly into the database. @see: \SGalinski\SgConsistence\Domain\Consistence\AbstractConsistence::writeUpdatedFieldsIntoDatabase()
  • Your consistence service must take care of the incoming ID parameter. Cronjobs will pass 0 as a parameter, which means "run for all entries". For best performance - consider trying using raw SQL queries for the simple cases instead of iterating over all objects.
  • If you call a consistence class directly from an other consistence class, then you need to add the uid of the object to the "updatedUids" array of the called consistence class. See Example:
      // This check provides, that the appointment won't be consisted twice
      $appointmentUid = $appointment->getUid();
      if (in_array($appointmentUid, $this->appointmentConsistence->getUpdatedUids())) {
          return;
      }
      $this->appointmentConsistence->addUpdatedUid($appointmentUid);
      $this->appointmentConsistence->processUpdatedModifiedObject($appointment);
    

How to register a consistence service:

The preferred way is to use the function registerService in the ConsistenceRegistrationService.

The priority is an integer. The highest value will be executed at first. Use high values, so someone can register an another class between two.

Example:

ConsistenceRegistrationService::registerService('ScheduleEntry', 'SGalinski\RsEvents\Domain\\', 'tx_rsevents_domain_model_schedule_entry', 200);

Alternative way:

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['sg_consistence']['consistenceServices'][] = [
    'domainModel' => 'ScheduleEntry',
    'domainNamespace' => 'SGalinski\RsEvents\Domain\\',
    'consistenceClass' => 'SGalinski\RsEvents\Domain\Consistence\ScheduleEntryConsistence',
    'tableName' => 'tx_rsevents_domain_model_schedule_entry',
    'priority' => 200,
];

Important!!!

If you use the consistence API and modify record in the database you should ALWAYS use the TYPO3 Database API instead of Extbase Repository method. Otherwise you will end up in some troubles.