private function installComplement($complement, $path, $slug, $root = true)
    {
        $path = ($root) ? $path : $path . key($complement) . '/';

        if (! $this->validateRoute($path)) {
            return false;
        }

        if (! File::createDir($path)) {
            $msg = "The directory exists or couldn't be created in: $path";
            self::$errors[] = ['message' => $msg];

            return false;
        }

        foreach ($complement as $folder => $file) {
            foreach ($file as $key => $val) {
                if (is_array($val)) {
                    $this->installComplement([$key => $val], $path, $slug, 0);
                    continue;
                }

                $filePath = $path . $val;

                $complementType = self::getType('strtoupper');
                $complementPath = App::$complementType() . $slug . '/';

                $url = Url::addBackSlash($this->complement['url-import']);
                $route = str_replace($complementPath, '', $filePath);
                $fileUrl = $url . '/' . $route;

                $this->saveRemoteFile($fileUrl, $filePath);
            }
        }

        return true;
    }
private function installComplement($complement, $path, $slug, $root = true)
    {
        $path = ($root) ? $path : $path . key($complement) . '/';

        if (! $this->validateRoute($path)) {
            return false;
        }

        if (! File::createDir($path)) {
            $msg = "The directory exists or couldn't be created in: $path";
            self::$errors[] = ['message' => $msg];

            return false;
        }

        foreach ($complement as $folder => $file) {
            foreach ($file as $key => $val) {
                if (is_array($val)) {
                    $this->installComplement([$key => $val], $path, $slug, 0);
                    continue;
                }

                $filePath = $path . $val;

                $complementType = self::getType('strtoupper');
                $complementPath = App::$complementType() . $slug . '/';

                $url = Url::addBackSlash($this->complement['url-import']);
                $route = str_replace($complementPath, '', $filePath);
                $fileUrl = $url . '/' . $route;

                $this->saveRemoteFile($fileUrl, $filePath);
            }
        }

        return true;
    }
private function installComplement ( $ complement , $ path , $ slug , $ root = true ) { $ path = ( $ root ) ? $ path : $ path . key ( $ complement ) . '/' ; if ( ! $ this -> validateRoute ( $ path ) ) { return false ; } if ( ! File :: createDir ( $ path ) ) { $ msg = "The directory exists or couldn't be created in: $path" ; self :: $ errors [ ] = [ 'message' => $ msg ] ; return false ; } foreach ( $ complement as $ folder => $ file ) { foreach ( $ file as $ key => $ val ) { if ( is_array ( $ val ) ) { $ this -> installComplement ( [ $ key => $ val ] , $ path , $ slug , 0 ) ; continue ; } $ filePath = $ path . $ val ; $ complementType = self :: getType ( 'strtoupper' ) ; $ complementPath = App :: $ complementType ( ) . $ slug . '/' ; $ url = Url :: addBackSlash ( $ this -> complement [ 'url-import' ] ) ; $ route = str_replace ( $ complementPath , '' , $ filePath ) ; $ fileUrl = $ url . '/' . $ route ; $ this -> saveRemoteFile ( $ fileUrl , $ filePath ) ; } } return true ; }
Install complement.

@param array  $complement → complement files
@param string $path       → complement path
@param string $slug       → complement slug
@param bool   $root       → root folder

@uses \Eliasis\Framework\App::COMPLEMENT_URL()
@uses \Eliasis\Complement\Traits\ComplementHandler::getType()
@uses \Josantonius\File\File::createDir()

@return bool
Install complement .