Ejemplo n.º 1
0
 /**
  * 添加一张小图配置
  * @param $type
  * @param $image
  * @param null $config
  * @return bool
  */
 public function addSingleImageConfig($type, $image, $config = null)
 {
     $path = $this->root . '/' . C('IMERGE_IMAGE_DIR') . '/' . $type;
     $filename = file_uid($image);
     $oldFile = $path . '/' . $filename . '.php';
     $newFile = $path . '/_' . $filename . '.php';
     if (file_exists($oldFile) || file_exists($newFile)) {
         // 小图已存在
         return false;
     } else {
         if (is_null($config)) {
             $config = MergeConfigGenerator::getDefaultConfig();
         }
         contents_to_file($newFile, self::configStringify($config, $image));
         return true;
     }
 }