[Li Jingshan php] every day laravel-20160915| FileSystemManager-2

Source: Internet
Author: User

    /**     * create an instance of the  local driver.     *     *  @param    array   $config      *  @return  \illuminate\contracts\filesystem\ Filesystem     */    public function createlocaldriver ( array  $config)     {         $permissions   = isset ($config [' Permissions '])  ?  $config [' Permissions '] : [];// can use  as a permissions         $links  = arr::get ($ config,  ' links ')  ===  ' Skip '              ? localadapter::skip_links            :  localadapter::disallow_links;// set about link        return $ This->adapt ($this->createflysystem (New localadapter (              $config [' Root '], lock_ex,  $links,  $permissions          ),  $config));// return adapt function     }// create a local driver    /**     *  Create an instance of the ftp driver.     *      *  @param   array   $config      *  @return  \Illuminate\Contracts\Filesystem\Filesystem     */     public function createftpdriver (array  $config)     {          $ftpConfig  = arr::only ($config, [              ' host ',  ' username ',  ' password ',  ' port ',  ' root ',  ' passive ',  ' SSL ',   ' timeout ',         ]);// set ftp config         return  $this->adapt ($this->createflysystem (             new ftpadapter ($ftpConfig),  $config         );// new a ftp adapter     }// a ftp driver    /**     * create  an instance of the Amazon S3 driver.     *      *  @param   array   $config      *  @return  \illuminate\contracts\filesystem\cloud     */    public function  Creates3driver (array  $config)     {        $ s3config =  $this->formats3config ($config);// get the config          $root  = isset ($s 3config[' root ')  ?  $s 3config[' root '] :  null;// get root name        return  $this- >adapt ($this->createflysystem (             New s3adapter (New s3client ($s 3Config),  $s 3config[' bucket '],  $root),  $config          );// make it    }// create  a amazon s3 driver    /**     * format  The given s3 configuration with the default options.     *      *  @param   array   $config      *  @return  array      */    protected function formats3config (Array   $config)     {         $config  += [' Version '  =>  ' latest '];// config combine         if  ($config [' key '] &&  $config [' secret '])  {// if has key and  secret flag             $config [' Credentials '] = arr::only ($config,  [' key ',  ' secret ']);         }// get the credentials into the config array         return  $config;    }// format like array merge     /**     * Create an instance of the  rackspace driver.     *     *  @param    array   $config      *  @return  \illuminate\contracts\filesystem\ Cloud     */    public function createrackspacedriver ( array  $config)     {         $client  =  new rackspace ($config [' Endpoint '], [              ' username '  =>  $config [' username '],  ' apiKey '  =>  $config [' key '] ,         ]);// get client          $root  = isseT ($config [' Root '])  ?  $config [' Root '] : null;// get root         return  $this->adapt ($this->createflysystem (             new rackspaceadapter ($this->getrackspacecontainer ($client,   $config),  $root),  $config         ));// create  it    }// Create a special space driveer.     /**     * get the rackspace cloud files container .     *     *  @param   \opencloud\rackspace    $client      *  @param   array   $config       *  @return  \opencloud\objectstore\resource\container     * /   &nbSp;protected function getrackspacecontainer (rackspace  $client, array  $config)      {         $urlType  = arr::get ($config,   ' Url_type ');// first get type         $store   =  $client->objectstoreservice (' cloudfiles ',  $config [' Region '],  $urlType);//get store         return  $store->getcontainer ($config [' container ']);//     }// create and get rackspace cloud    /**      * create a flysystem instance with the given  adapter.     *     *  @param   \league\ flysystem\adapterinterface   $adapter      *  @param   array    $config      *  @return  \league\flysystem\flysysteminterface     */     protected function createflysystem (adapterinterface  $adapter,  array  $config)     {         $config  =  arr::only ($config,  [' visibility ');         return new  flysystem ($adapter,  count ($config)  > 0 ?  $config  : null);     }// create a file system by config    /**      * Adapt the filesystem implementation.      *     *  @param   \league\flysystem\filesysteminterface    $filesystem      *  @return  \illuminate\contracts\filesystem\ Filesystem    &nbsP;*/    protected function adapt (filesysteminterface  $filesystem)      {        return new filesystemadapter ($ FileSystem);    }// a wrap about this    /**      * Get the filesystem connection configuration.      *     *  @param   string   $name       *  @return  array     */    protected  function getconfig ($name)     {         return  $this->app[' config ' ["filesystems.disks.{ $name} "];    }// a super big config    /**      * get the default driver name.     *     *  @return  string      */    public function getdefaultdriver ()     {         return  $this->app[' config ' [' Filesystems.default '];     }// get Default Driver    /**      * Get the default cloud driver name.     *      *  @return  string     */     Public function getdefaultclouddriver ()     {         return  $this->app[' config ' [' Filesystems.cloud '];    }// get  the default cloud driver name.    /**      * register a  custom driver creator closure.     *     *   @param   string     $driver      *  @param    \Closure   $callback      *  @return   $this       */    public function extend ($driver, closure  $callback)     {         $this->customcreators[$driver]  =  $callback;        return  $this;     }// get extend    /**     * dynamically  call the default driver instance.     *      *  @param   string   $method      *  @param   array   $parameters      *  @return  mixed     */     public function __call ($method,  $parameters)     {         return call_user_func_array ([$this->disk (),  $method], $ parameters);     }// big call}


This article is from the "Focus on PHP" blog, please be sure to keep this source http://jingshanls.blog.51cto.com/3357095/1827284

[Li Jingshan php] every day laravel-20160915| FileSystemManager-2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.