当前位置: 首页>>代码示例>>PHP>>正文


PHP File::name方法代码示例

本文整理汇总了PHP中Cake\Filesystem\File::name方法的典型用法代码示例。如果您正苦于以下问题:PHP File::name方法的具体用法?PHP File::name怎么用?PHP File::name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Filesystem\File的用法示例。


在下文中一共展示了File::name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _unzip

 /**
  * Extracts the current ZIP package.
  *
  * @param  string $file Full path to the ZIP package
  * @return bool True on success
  */
 protected function _unzip($file)
 {
     include_once Plugin::classPath('Installer') . 'Lib/pclzip.lib.php';
     $File = new File($file);
     $to = normalizePath($File->folder()->pwd() . '/' . $File->name() . '_unzip/');
     if (is_readable($to)) {
         $folder = new Folder($to);
         $folder->delete();
     } else {
         $folder = new Folder($to, true);
     }
     $PclZip = new \PclZip($file);
     $PclZip->delete(PCLZIP_OPT_BY_EREG, '/__MACOSX/');
     $PclZip->delete(PCLZIP_OPT_BY_EREG, '/\\.DS_Store$/');
     if ($PclZip->extract(PCLZIP_OPT_PATH, $to)) {
         list($directories, $files) = $folder->read(false, false, true);
         if (count($directories) === 1 && empty($files)) {
             $container = new Folder($directories[0]);
             $container->move(['to' => $to]);
         }
         $this->_workingDir = $to;
         return true;
     }
     $this->err(__d('installer', 'Unzip error: {0}', [$PclZip->errorInfo(true)]));
     return false;
 }
开发者ID:quickapps-plugins,项目名称:installer,代码行数:32,代码来源:PluginInstallTask.php

示例2: copy

 /**
  * Copy Objednavku
  * @param $id
  */
 public function copy($id)
 {
     $row = $this->Orders->findById($id)->contain(["Accessories", "Images", "Files", "Statuses", "Operations"])->first();
     if (!$row) {
         throw new InternalErrorException("Chyba pri nacitani objednavky", 500);
     }
     try {
         $data = $row->toArray();
         // Copy All Images
         if ($data['images']) {
             foreach ($data['images'] as $key => $image) {
                 $file_name = new File($image['name']);
                 $new_file = md5($file_name->name() . time()) . "." . $file_name->ext();
                 if (copy('img/images/' . $file_name->name, 'img/images/' . $new_file)) {
                     $data['images'][$key]['name'] = $new_file;
                 }
             }
         }
         // Copy all Files
         if ($data['files']) {
             foreach ($data['files'] as $key => $file) {
                 $file_name = new File($file['name']);
                 $origin_file = preg_replace("/-copy-\\d{2}\\.\\d{2}\\.\\d{2}.\\d{2}.\\d{2}/", "", $file_name->name());
                 $new_file = $origin_file . "-copy-" . date("d.m.y-H-i") . "." . $file_name->ext();
                 if (copy('files/' . $file_name->name, 'files/' . $new_file)) {
                     $data['files'][$key]['name'] = $new_file;
                 }
             }
         }
         $order = $this->Orders->newEntity($data);
         $order->user_id = $this->getUserId();
         if (!$this->Orders->save($order)) {
             $message = ['message' => "error saving data", "data" => $order->errors()];
             throw new InternalErrorException(json_encode($message));
         }
     } catch (Exception $e) {
         throw new InternalErrorException($e->getMessage());
     }
     $this->set('row', $order);
     $this->set('_serialize', ['row']);
 }
开发者ID:ranostaj,项目名称:autocar,代码行数:45,代码来源:OrdersController.php


注:本文中的Cake\Filesystem\File::name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。