src/Generator/Writer/Model/Steps/StubReplaceRelationData.php
protected function getRelationsConfigReplace()
    {
        $relationships = $this->collectRelationshipDataForConfig();

        if ( ! count($relationships)) return '';


        $replace = $this->tab() . "protected \$relationsConfig = [\n";

        foreach ($relationships as $name => $relationship) {

            $replace .= $this->tab(2) . "'" . $name . "' => [\n";

            $rows = [];

            if (array_get($relationship, 'field')) {
                $rows['field'] = $relationship['field'];
            }

            if (array_get($relationship, 'special')) {
                $rows['type'] = $relationship['specialString'];
            } else {
                $rows['parent'] = ($relationship['reverse'] ? 'false' : 'true');
            }

            if (array_get($relationship, 'translated') === true) {
                $rows['translated'] = 'true';
            }

            $longestPropertyLength = $this->getLongestKey($rows);

            foreach ($rows as $property => $value) {

                $replace .= $this->tab(3) . "'"
                    . str_pad($property . "'", $longestPropertyLength + 1)
                    . " => {$value},\n";
            }


            $replace .= $this->tab(2) . "],\n";
        }

        $replace .= $this->tab() . "];\n\n";

        return $replace;
    }
protected function getRelationsConfigReplace()
    {
        $relationships = $this->collectRelationshipDataForConfig();

        if ( ! count($relationships)) return '';


        $replace = $this->tab() . "protected \$relationsConfig = [\n";

        foreach ($relationships as $name => $relationship) {

            $replace .= $this->tab(2) . "'" . $name . "' => [\n";

            $rows = [];

            if (array_get($relationship, 'field')) {
                $rows['field'] = $relationship['field'];
            }

            if (array_get($relationship, 'special')) {
                $rows['type'] = $relationship['specialString'];
            } else {
                $rows['parent'] = ($relationship['reverse'] ? 'false' : 'true');
            }

            if (array_get($relationship, 'translated') === true) {
                $rows['translated'] = 'true';
            }

            $longestPropertyLength = $this->getLongestKey($rows);

            foreach ($rows as $property => $value) {

                $replace .= $this->tab(3) . "'"
                    . str_pad($property . "'", $longestPropertyLength + 1)
                    . " => {$value},\n";
            }


            $replace .= $this->tab(2) . "],\n";
        }

        $replace .= $this->tab() . "];\n\n";

        return $replace;
    }
protected function getRelationsConfigReplace ( ) { $ relationships = $ this -> collectRelationshipDataForConfig ( ) ; if ( ! count ( $ relationships ) ) return '' ; $ replace = $ this -> tab ( ) . "protected \$relationsConfig = [\n" ; foreach ( $ relationships as $ name => $ relationship ) { $ replace .= $ this -> tab ( 2 ) . "'" . $ name . "' => [\n" ; $ rows = [ ] ; if ( array_get ( $ relationship , 'field' ) ) { $ rows [ 'field' ] = $ relationship [ 'field' ] ; } if ( array_get ( $ relationship , 'special' ) ) { $ rows [ 'type' ] = $ relationship [ 'specialString' ] ; } else { $ rows [ 'parent' ] = ( $ relationship [ 'reverse' ] ? 'false' : 'true' ) ; } if ( array_get ( $ relationship , 'translated' ) === true ) { $ rows [ 'translated' ] = 'true' ; } $ longestPropertyLength = $ this -> getLongestKey ( $ rows ) ; foreach ( $ rows as $ property => $ value ) { $ replace .= $ this -> tab ( 3 ) . "'" . str_pad ( $ property . "'" , $ longestPropertyLength + 1 ) . " => {$value},\n" ; } $ replace .= $ this -> tab ( 2 ) . "],\n" ; } $ replace .= $ this -> tab ( ) . "];\n\n" ; return $ replace ; }
Returns the replacement for the relations config placeholder

@return string
Returns the replacement for the relations config placeholder