protected function mergeIndexes(&$resource, $input)
    {
        $existingNames = [];

        foreach ($resource->indexes as $index) {
            $existingNames[] = $index->getName();
        }
        $mergeIndexes = 0;
        foreach ($input->indexes as $index) {
            $newIndex = Index::fromString($index);
            if (!empty($newIndex->getName()) && in_array($newIndex->getName(), $existingNames)) {
                $this->warn('The index "' . $newIndex->getName() . '" already exists in the file.');
                continue;
            }

            $resource->indexes[] = $newIndex;
            $existingNames[] = $newIndex->getName();
            $mergeIndexes++;
        }

        return $mergeIndexes;
    }
protected function mergeIndexes(&$resource, $input)
    {
        $existingNames = [];

        foreach ($resource->indexes as $index) {
            $existingNames[] = $index->getName();
        }
        $mergeIndexes = 0;
        foreach ($input->indexes as $index) {
            $newIndex = Index::fromString($index);
            if (!empty($newIndex->getName()) && in_array($newIndex->getName(), $existingNames)) {
                $this->warn('The index "' . $newIndex->getName() . '" already exists in the file.');
                continue;
            }

            $resource->indexes[] = $newIndex;
            $existingNames[] = $newIndex->getName();
            $mergeIndexes++;
        }

        return $mergeIndexes;
    }
protected function mergeIndexes ( & $ resource , $ input ) { $ existingNames = [ ] ; foreach ( $ resource -> indexes as $ index ) { $ existingNames [ ] = $ index -> getName ( ) ; } $ mergeIndexes = 0 ; foreach ( $ input -> indexes as $ index ) { $ newIndex = Index :: fromString ( $ index ) ; if ( ! empty ( $ newIndex -> getName ( ) ) && in_array ( $ newIndex -> getName ( ) , $ existingNames ) ) { $ this -> warn ( 'The index "' . $ newIndex -> getName ( ) . '" already exists in the file.' ) ; continue ; } $ resource -> indexes [ ] = $ newIndex ; $ existingNames [ ] = $ newIndex -> getName ( ) ; $ mergeIndexes ++ ; } return $ mergeIndexes ; }
Merges the indexes to the existing resources.

@param CrestApps\CodeGenerator\Models\Resource &$resource
@param (object) $input

@return int
Merges the indexes to the existing resources .