[李景山php]每天laravel-20160915|FileSystemManager-2

來源:互聯網
上載者:User

標籤:public   function   create   

    /**     * 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($s3Config[‘root‘]) ? $s3Config[‘root‘] : null;// get root name        return $this->adapt($this->createFlysystem(            new S3Adapter(new S3Client($s3Config), $s3Config[‘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     */    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     */    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}


本文出自 “專註php” 部落格,請務必保留此出處http://jingshanls.blog.51cto.com/3357095/1827284

[李景山php]每天laravel-20160915|FileSystemManager-2

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.