public function bindAssociations()
    {
        $config = $this->getConfig();
        $tagsAlias = $config['tagsAlias'];
        $tagsAssoc = $config['tagsAssoc'];
        $taggedAlias = $config['taggedAlias'];
        $taggedAssoc = $config['taggedAssoc'];

        $table = $this->_table;
        $tableAlias = $this->_table->getAlias();

        $assocConditions = [$taggedAlias . '.' . $this->getConfig('fkTableField') => $table->getTable()];

        if (!$table->hasAssociation($taggedAlias)) {
            $table->hasMany($taggedAlias, $taggedAssoc + [
                'foreignKey' => $tagsAssoc['foreignKey'],
                'conditions' => $assocConditions,
            ]);
        }

        if (!$table->hasAssociation($tagsAlias)) {
            $table->belongsToMany($tagsAlias, $tagsAssoc + [
                'through' => $table->{$taggedAlias}->getTarget(),
                'conditions' => $assocConditions,
            ]);
        }

        if (!$table->{$tagsAlias}->hasAssociation($tableAlias)) {
            $table->{$tagsAlias}
                ->belongsToMany($tableAlias, [
                    'className' => $table->getTable(),
                ] + $tagsAssoc);
        }

        if (!$table->{$taggedAlias}->hasAssociation($tableAlias)) {
            $table->{$taggedAlias}
                ->belongsTo($tableAlias, [
                    'className' => $table->getTable(),
                    'foreignKey' => $tagsAssoc['foreignKey'],
                    'conditions' => $assocConditions,
                    'joinType' => 'INNER',
                ]);
        }

        if (!$table->{$taggedAlias}->hasAssociation($tableAlias . $tagsAlias)) {
            $table->{$taggedAlias}
                ->belongsTo($tableAlias . $tagsAlias, [
                    'className' => $tagsAssoc['className'],
                    'foreignKey' => $tagsAssoc['targetForeignKey'],
                    'conditions' => $assocConditions,
                    'joinType' => 'INNER',
                ]);
        }
    }