src/Event/Model/ModelAfterSaveListener.php
protected function getReminderField(RepositoryInterface $table) : string
    {
        $config = (new ModuleConfig(ConfigType::MIGRATION(), $table->getRegistryAlias()))->parse();

        $fields = array_filter((array)$config, function ($field) {
            if ('reminder' === $field->type) {
                return $field;
            }
        });

        if (empty($fields)) {
            return '';
        }

        // FIXME: What should happen when there is more than 1 reminder field on the table?
        reset($fields);

        return current($fields)->name;
    }
protected function getReminderField(RepositoryInterface $table) : string
    {
        $config = (new ModuleConfig(ConfigType::MIGRATION(), $table->getRegistryAlias()))->parse();

        $fields = array_filter((array)$config, function ($field) {
            if ('reminder' === $field->type) {
                return $field;
            }
        });

        if (empty($fields)) {
            return '';
        }

        // FIXME: What should happen when there is more than 1 reminder field on the table?
        reset($fields);

        return current($fields)->name;
    }
protected function getReminderField ( RepositoryInterface $ table ) : string { $ config = ( new ModuleConfig ( ConfigType :: MIGRATION ( ) , $ table -> getRegistryAlias ( ) ) ) -> parse ( ) ; $ fields = array_filter ( ( array ) $ config , function ( $ field ) { if ( 'reminder' === $ field -> type ) { return $ field ; } } ) ; if ( empty ( $ fields ) ) { return '' ; } // FIXME: What should happen when there is more than 1 reminder field on the table? reset ( $ fields ) ; return current ( $ fields ) -> name ; }
Get the fist reminder field of the given table

NOTE: It is not very common to have more than one
reminder field per table, but it is not
impossible.  We need to figure out what
should happen.  Possible scenarios:

* Forbid more than one field with validation.
* Send reminder only to the first/non-empty.
* Send separate reminder for each.
* Have more flexible configuration rules.

@param \Cake\Datasource\RepositoryInterface $table Table to use
@return string First reminder field name
Get the fist reminder field of the given table