Set associations for "self relation" type Modules.

@param string $module Module name
@param mixed[] $fields CSV Fields
@return void
10204
private function setByTypeSelfRelationField(string $module, array $fields) : void
    {
        $first = $fields[0];
        $second = $fields[1];

        $this->setAssociation(
            'belongsToMany',
            static::generateAssociationName($module, $first->getName()),
            [
                'joinTable' => Inflector::tableize($module),
                'className' => $first->getAssocCsvModule(),
                'foreignKey' => $second->getName(),
                'targetForeignKey' => $first->getName()
            ]
        );

        $this->setAssociation(
            'belongsToMany',
            static::generateAssociationName($module, $second->getName()),
            [
                'joinTable' => Inflector::tableize($module),
                'className' => $second->getAssocCsvModule(),
                'foreignKey' => $first->getName(),
                'targetForeignKey' => $second->getName()
            ]
        );
    }
1064864
public function setModule($module)
    {
        if (!is_string($module)) {
            throw new \InvalidArgumentException('The attribute module on the class Entity has to be string (' . gettype($module) . ('object' === gettype($module) ? ' ' . get_class($module) : '') . ' given).');
        }

        $this->module = $module;

        return $this;
    }
1275615
public function setFields(array $fields)
    {
        foreach ($fields as $key => $field) {
            $this->setField($key, $field);
        }

        return $this;
    }
63256
public function setFieldForRelation($fieldName, FormField $field)
    {
        if (self::isLocalizedRelation($fieldName)) {
            self::$localizedFields[$this->ownerBaseClass . '_has_one'][$fieldName]['FormField'] = $field;
        }
    }
386158
public function setSubfields (array $subfields) 
    {
        $this->_subfields = array();
        foreach ($subfields as $subfield) {
            $this->addSubfield($subfield);
        }
    }
175887
protected function setQueryFields(array $fields)
    {
        $this->queryFields = array();
        foreach ($fields as $field => $included) {
            if ($included) $this->queryFields[$field] = 1;
        }
    }
492835
protected function createRelationIndex(array $modules) : array
    {
        $index = [];

        foreach ($modules as $moduleName => $module) {
            if (! isset($module['relations'])) {
                $index[$moduleName] = [];
                continue;
            }

            if (! is_array($module['relations'])) {
                $index[$moduleName] = [];
                continue;
            }

            foreach ($module['relations'] as $relatedModule) {
                if (!empty($index[$relatedModule][$moduleName])) {
                    continue;
                }
                $index[$relatedModule][] = $moduleName;
            }
        }

        return $index;
    }
1058681
public function setFromArray(array $fields)
    {
        foreach($fields as $key => $value)
        {
                $this->fields[$key] = $value;
                unset($key);
                unset($value);
        }
    }
823083
public function addFields(array $fields)
    {
        array_walk(
            $fields,
            function ($field, $key) {
                $this->addField($key, $field);
            }
        );
    }
888516
public static function init(array $mcaName, array $modules): void
    {
        self::$mcaName = $mcaName;
        self::$modules = $modules;
    }
632798
public function setFields( $fields )
	{
		if( is_array( $fields ) && count( $fields ) )
			$this->fields = $fields;
		else
			trigger_error( 'Field Array of Table Definition must no be empty.', E_USER_ERROR );
	}
545334
public function reset($module)
    {
        if (is_string($module)) {
            $module = $this->module->findOrFail($module);
        }

        $migrator = new Migrator($module);

        $database = $this->option('database');

        if (!empty($database)) {
            $migrator->setDatabase($database);
        }

        $migrated = $migrator->reset();

        if (count($migrated)) {
            foreach ($migrated as $migration) {
                $this->line("Rollback: <info>{$migration}</info>");
            }

            return;
        }

        $this->comment('Nothing to rollback.');
    }
841492
public function dropSchema($module)
    {			
    		$res = $this->parseSchema($module);
    		if (is_array($res['tables'])) foreach ($res['tables'] as $table) {
            $this->dbConnection->executeQuery('DROP TABLE IF EXISTS `'.$table['name'].'`');
    		}
    		if (is_array($res['types'])) foreach ($res['types'] as $type) {
            try {
                ObjectDefinition::findByTable($type['name'])->delete();
            } catch (\Exception $e) {}
    		}        
    }
320446
public final function registerModule(Module $module)
    {
        $dependencies = $module->getModules();

        foreach($dependencies as $dependency){
            $this->registerModule($dependency);
        }

        $this->modules[$module->getModuleName()] = $module;
    }
1002812
public static function remove_module( $module ) {
		$key = array_search( $module, self::$modules, true );
		if ( false !== $key ) {
			unset( self::$modules[ $key ] );
		}
	}
992538
public function register_module( \Dekode\Hogan\Module $module ) {

		if ( did_action( 'hogan/modules_included' ) ) {
			_doing_it_wrong( __METHOD__, esc_html__( 'Hogan modules have already been registered. Please do module registration on action hogan/include_modules.', 'hogan-core' ), '1.0.0' );
		}

		$this->_modules[ $module->name ] = $module;
	}
1317147
protected function setFields($values)
    {
        foreach ($values[0]->fields as $name => $field) {
            $this->fields[$name] = $field;
        }
    }