Skip to content

Commit baeddaf

Browse files
committed
rm metaprogramming
1 parent 65856e0 commit baeddaf

File tree

1 file changed

+10
-77
lines changed

1 file changed

+10
-77
lines changed

src/Qiniu/Processing/PersistentFop.php

Lines changed: 10 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,20 @@ public function __construct($auth, $bucket, $pipeline = null, $notify_url = null
4545
/**
4646
* 列取空间的文件列表
4747
*
48-
* @param $key 待处理的源文件
49-
* @param $fops 处理详细操作,规格详见 http://developer.qiniu.com/docs/v6/api/reference/fop/
48+
* @param $key 待处理的源文件
49+
* @param $fops string|array 待处理的pfop操作,多个操作已array的形式传入。
50+
* eg. avthumb/mp3/ab/192k, vframe/jpg/offset/7/w/480/h/360
5051
*
5152
* @return array[] 返回持久化处理的persistentId, 和返回的错误。
53+
*
54+
* @link http://developer.qiniu.com/docs/v6/api/reference/fop/
5255
*/
53-
public function execute($key, array $fops)
56+
public function execute($key, $fops)
5457
{
55-
$ops = implode(';', $fops);
58+
if (is_array($fops)) {
59+
$ops = implode(';', $fops);
60+
}
61+
5662
$params = array('bucket' => $this->bucket, 'key' => $key, 'fops' => $ops);
5763
if (!empty($this->pipeline)) {
5864
$params['pipeline'] = $this->pipeline;
@@ -85,77 +91,4 @@ public static function status($id)
8591
}
8692
return array($response->json(), null);
8793
}
88-
89-
private static $pfops = array(
90-
'avthumb',
91-
'vframe',
92-
'segtime',
93-
'vsample',
94-
'vwatermark',
95-
'avconcat',
96-
97-
'concat',
98-
);
99-
100-
public function __call($method, $args)
101-
{
102-
103-
if (!in_array($method, self::$pfops)) {
104-
throw new \InvalidArgumentException("pfop {$method} isn't supported");
105-
}
106-
$key = $args[0];
107-
$mod = null;
108-
if (count($args)>1) {
109-
$mod = $args[1];
110-
}
111-
112-
$options = array();
113-
if (count($args)>2) {
114-
$options = $args[2];
115-
}
116-
117-
$target_bucket = null;
118-
if (count($args)>3) {
119-
$target_bucket = $args[3];
120-
}
121-
122-
$target_key = null;
123-
if (count($args)>4) {
124-
$target_key = $args[4];
125-
}
126-
127-
$pfop = Operation::buildOp($method, $mod, $options);
128-
if ($target_bucket != null) {
129-
$pfop = Operation::saveas($pfop, $target_bucket, $target_key);
130-
}
131-
132-
$ops = array();
133-
array_push($ops, $pfop);
134-
return $this->execute($key, $ops);
135-
}
136-
137-
public function mkzip(
138-
$dummy_key,
139-
$urls_and_alias,
140-
$to_bucket = null,
141-
$to_key = null,
142-
$mode = 2
143-
) {
144-
$base = 'mkzip/' . $mode;
145-
$op = array($base);
146-
foreach ($urls_and_alias as $key => $value) {
147-
if (is_int($key)) {
148-
array_push($op, 'url/' . \Qiniu\base64_urlSafeEncode($value));
149-
} else {
150-
array_push($op, 'url/' . \Qiniu\base64_urlSafeEncode($key));
151-
array_push($op, 'alias/' . \Qiniu\base64_urlSafeEncode($key));
152-
}
153-
}
154-
$fop = implode('/', $op);
155-
if ($to_bucket != null) {
156-
$op = Operation::saveas($fop, $to_bucket, $to_key);
157-
}
158-
$ops =array($op);
159-
return $this->execute($dummy_key, $ops);
160-
}
16194
}

0 commit comments

Comments
 (0)