src/Aggregator/AggregateResult.php
private static function findAssociation(AggregatorInterface $aggregator) : Association
    {
        $config = $aggregator->getConfig();
        $table = $config->getTable();
        $joinTable = $config->getJoinTable();

        foreach ($table->associations() as $association) {
            // skip unsupported associations
            if (! in_array($association->type(), ['manyToMany', 'manyToOne'])) {
                continue;
            }

            if ($association->className() !== $joinTable->getAlias()) {
                continue;
            }

            return $association;
        }

        throw new RuntimeException(sprintf(
            'Table "%s" has no association with "%s"',
            get_class($config->getTable()),
            $joinTable->getAlias()
        ));
    }
private static function findAssociation(AggregatorInterface $aggregator) : Association
    {
        $config = $aggregator->getConfig();
        $table = $config->getTable();
        $joinTable = $config->getJoinTable();

        foreach ($table->associations() as $association) {
            // skip unsupported associations
            if (! in_array($association->type(), ['manyToMany', 'manyToOne'])) {
                continue;
            }

            if ($association->className() !== $joinTable->getAlias()) {
                continue;
            }

            return $association;
        }

        throw new RuntimeException(sprintf(
            'Table "%s" has no association with "%s"',
            get_class($config->getTable()),
            $joinTable->getAlias()
        ));
    }
private static function findAssociation ( AggregatorInterface $ aggregator ) : Association { $ config = $ aggregator -> getConfig ( ) ; $ table = $ config -> getTable ( ) ; $ joinTable = $ config -> getJoinTable ( ) ; foreach ( $ table -> associations ( ) as $ association ) { // skip unsupported associations if ( ! in_array ( $ association -> type ( ) , [ 'manyToMany' , 'manyToOne' ] ) ) { continue ; } if ( $ association -> className ( ) !== $ joinTable -> getAlias ( ) ) { continue ; } return $ association ; } throw new RuntimeException ( sprintf ( 'Table "%s" has no association with "%s"' , get_class ( $ config -> getTable ( ) ) , $ joinTable -> getAlias ( ) ) ) ; }
Association instance finder.

This is from the target table's side, since the aggregation is applied on its column.

@param \CsvMigrations\Aggregator\AggregatorInterface $aggregator Aggregator instance
@return \Cake\ORM\Association
@throws \RuntimeException When association is not found between source and target tables.
Association instance finder .