数据校验规则.

@param array $fileds 字段.

@return array
179155
public final function getValidateRules(...$fileds) {
		if ($fileds) {
			$rules = [];
			foreach ($fileds as $f) {
				if (isset($this->rules[ $f ])) {
					$rules[ $f ] = $this->rules[ $f ];
				}
			}

			return $rules;
		}

		return $this->rules;
	}
1105759
private function getTableRows($files)
    {
        $rows = [];

        foreach ($files as $file => $keys) {
            $rows[] = [count($keys), $file];
        }

        return $rows;
    }
1260191
public function load($sessId)
    {
        $this->sessID = $sessId;
        $data = $this->cache->get(self::$cache_prefix . $sessId);
        //先读数据，如果没有，就初始化一个
        if (!empty($data))
        {
            return unserialize($data);
        }
        else
        {
            return array();
        }
    }
123525
public static function filter(array $fields)
    {
        if (array_values($fields) === $fields)
        {
            if (($key = array_search('id', $fields)) !== false)
            {
                unset($fields[$key]);
            }
        }
        else
        {
            unset($fields['id']);
        }
        return $fields;
    }
470347
public function bulkIndex(array $documents)
    {
        if (empty($documents)) {
            return;
        }

        $payload = '';
        foreach ($documents as $document) {
            $payload .= $this->serializer->getIndexMetadata($document) . "\n";
            $payload .= $this->serializer->getIndexDocument($document) . "\n";
        }

        $result = $this->client->request(
            'POST',
            "/{$this->indexName}/_bulk",
            new Message(
                array(
                    'Content-Type' => 'application/json',
                ),
                $payload
            )
        );

        if ($result->headers['status'] !== 201 && $result->headers['status'] !== 200) {
            throw new RuntimeException(
                'Wrong HTTP status received from Elasticsearch: ' . $result->headers['status']
            );
        }

        $this->flush();
    }
569870
public function createScenarios(array $modelScenarios)
    {
        switch ($this->owner->getScenario()) {
            case 'default':
                // 默认场景下，只有允许自定义的时间日期字段才会被添加进场景数据里
                foreach ([$this->createdAtAttribute, $this->updatedAtAttribute] as $attribute) {
                    if (
                        is_string($attribute)
                        && !in_array($attribute, $modelScenarios[$this->owner->getScenario()])
                        && (
                            ($attribute == $this->createdAtAttribute && $this->modifyCreatedAt)
                            || ($attribute == $this->updatedAtAttribute && $this->modifyUpdatedAt)
                        )
                    ) {
                        $modelScenarios['default'][] = $attribute;
                    }
                }
                break;
        }
        
        return $modelScenarios;
    }
1304504
public function findByKeys(array $keys)
    {
        $result = [];
        /** @var Cursor $list */
        $list = $this->collection->find(['_id' => ['$in' => $keys]]);

        foreach ($list as $document) {
            $result[] = $this->hydrateEntity($document);
        }

        return $result;
    }
146274
public function getMerchantFields(array $keys)
    {
        $fields = [];
        foreach ($keys as $key) {
            $fields[$key] = $this->data[$key];
        }

        return $fields;
    }
6487
public function getDocs($format = 'array')
    {
        if ($format == 'json') {
            $filler = [];
            foreach ($this->docs as $doc) {
                $filler[] = $doc->toArray();
            }

            return json_encode($filler, true);
        }

        return $this->docs;
    }
200920
public static function readWords(array $files)
    {
        $words = [];
        foreach ($files as $file) {
            $words = array_merge($words, file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
        }

        $types = [];

        for ($i = 0, $count = count($words); $i !== $count; ++$i) {
            $type = 1;
            $value = trim($words[$i]);

            // Reserved, data types, keys, functions, etc. keywords.
            foreach (static::$LABELS_FLAGS as $label => $flags) {
                if (strstr($value, $label) !== false) {
                    $type |= $flags;
                    $value = trim(str_replace($label, '', $value));
                }
            }

            // Composed keyword.
            if (strstr($value, ' ') !== false) {
                $type |= 2; // Reserved keyword.
                $type |= 4; // Composed keyword.
            }

            $len = strlen($words[$i]);
            if ($len === 0) {
                continue;
            }

            $value = strtoupper($value);
            if (! isset($types[$value])) {
                $types[$value] = $type;
            } else {
                $types[$value] |= $type;
            }
        }

        $ret = [];
        foreach ($types as $word => $type) {
            $len = strlen($word);
            if (! isset($ret[$type])) {
                $ret[$type] = [];
            }
            if (! isset($ret[$type][$len])) {
                $ret[$type][$len] = [];
            }
            $ret[$type][$len][] = $word;
        }

        return static::sortWords($ret);
    }
899229
public static function parseIds($ids)
    {
        if (empty($ids)) {
            return [];
        }
        
        // 转换数字ID和字符串形式ID串为数组
        if (is_numeric($ids)) {
            $ids = [$ids];
        } else if (is_string($ids)) {
            $ids = self::stringToArray($ids);
        }
        
        $id_array = array_unique(array_filter(array_map('intval', $ids)));
        
        return 0 == count($id_array) ? [] : $id_array;
    }
920288
public function resolveFiles()
    {
        // 获取文件列表
        $files = $this->fileSys->getFiles($this->source_dir);
      
        // 对文件按时间重新排序
        $this->resortByTime($files);
        
        // 文章归集
        // $lvl_index = [];        // 解析文章索引
        $new_files = [];        // 新的文件数组
        foreach ($files as $key => $file) {
            // 解析文件名
            $file_name = $file['file_name'];
            $file_type = substr(strrchr($file_name, '.'), 1);
            $file_name = basename($file_name, '.'.$file_type);

            // 解析时间并设置归档路径和链接地址
            $date = empty($file['date']) ? date('Y-m-d') : date('Y-m-d', strtotime($file['date']));
            $date_arr = explode('-', $date);
            $file['date'] = $date;
            $file['href'] = '/articles/'.$date_arr[0].'/'.$date_arr[1].'/'.$date_arr[2].'/'.$file_name;
            $file['public_dir'] = $this->public_dir . $file['href'] . '/index.html';   // 文件生成路径
            $file['web_title'] = $this->config['title'];            // 网站标题
            $file_path = str_replace('\\', '/', $file['file_path']);
            $file['page_uuid'] = md5($file_path);
            $file['page_uuid_type'] = getpy($file['type'][0]);
            $file['page_uuid_type_now'] = getpy($this->getLastItem($file['type']));

            // 处理文章分类
            if ( empty($file['type']) ) {
                $source_dir = str_replace('\\', '/', $this->source_di);
                $file_type = str_replace('\\', '/', $file['file_dire']);
                $file_type = str_replace($source_dir, '', $file_type);
                $file_type = explode('/', trim($file_type));
            }else{
                $file_type = explode(',', trim($file['type']));
            }
            // 去除空格
            foreach ($file_type as &$t) {
                $t = trim($t);
            }
            $file['type'] = array_values(array_filter($file_type));

            $new_files[$file['page_uuid']] = $file;
            // dd($this->single_pages);
        }
        unset($key, $file);
        $this->files = $new_files;

        // 单文件索引创建：包含标题索引
        $this->resolveFileMenu();

        // 类型归档索引创建
        $this->resolveTypeIndex();
    }
1237176
private static function parseUploadedFiles(array $uploadedFiles)
    {
        $parsed = [];
        foreach ($uploadedFiles as $field => $uploadedFile) {
            if (!isset($uploadedFile['error'])) {
                if (is_array($uploadedFile)) {
                    $parsed[$field] = static::parseUploadedFiles($uploadedFile);
                }
                continue;
            }

            $parsed[$field] = [];
            if (!is_array($uploadedFile['error'])) {
                $parsed[$field] = new static(
                    $uploadedFile['tmp_name'],
                    isset($uploadedFile['name']) ? $uploadedFile['name'] : null,
                    isset($uploadedFile['type']) ? $uploadedFile['type'] : null,
                    isset($uploadedFile['size']) ? $uploadedFile['size'] : null,
                    $uploadedFile['error'],
                    true
                );
            } else {
                $subArray = [];
                foreach ($uploadedFile['error'] as $fileIdx => $error) {
                    // normalise subarray and re-parse to move the input's keyname up a level
                    $subArray[$fileIdx]['name'] = $uploadedFile['name'][$fileIdx];
                    $subArray[$fileIdx]['type'] = $uploadedFile['type'][$fileIdx];
                    $subArray[$fileIdx]['tmp_name'] = $uploadedFile['tmp_name'][$fileIdx];
                    $subArray[$fileIdx]['error'] = $uploadedFile['error'][$fileIdx];
                    $subArray[$fileIdx]['size'] = $uploadedFile['size'][$fileIdx];

                    $parsed[$field] = static::parseUploadedFiles($subArray);
                }
            }
        }

        return $parsed;
    }
1310988
private function getFiles(array $uploadedFiles)
    {
        $files = [];

        foreach ($uploadedFiles as $key => $value) {
            if (null === $value) {
                $files[$key] = new DiactorosUploadedFile(null, 0, UPLOAD_ERR_NO_FILE, null, null);
                continue;
            }
            if ($value instanceof UploadedFile) {
                $files[$key] = $this->createUploadedFile($value);
            } else {
                $files[$key] = $this->getFiles($value);
            }
        }

        return $files;
    }
480534
public function getTree($items) {
		$tree     = array(); //格式化好的树
		$newItems = array();
		foreach ($items as $value) {
			$newItems[$value['id']] = $value;
		}
		foreach ($newItems as $key => $item) {
			if (isset($newItems[$item['pid']])) {
				$newItems[$item['pid']]['son'][] = &$newItems[$key];
			} else {
				$tree[] = &$newItems[$key];
			}
		}
		return $tree;
	}
1093123
protected function getIndexes($indexes)
    {
        $existingNames = [];
        $finalIndexes = [];
        foreach ($indexes as $index) {
            $newIndex = Index::fromString($index);
            if (!empty($newIndex->getName()) && in_array($newIndex->getName(), $existingNames)) {
                continue;
            }

            $finalIndexes[] = $newIndex;
            $existingNames[] = $newIndex->getName();
        }

        return $finalIndexes;
    }
238893
protected function getFormRules(array $fields)
    {
        $rules = [];

        foreach ($fields as $field) {
            /** @var FieldTypeInterface $field */
            $rules[$field->getName()] = $field->getOption('rules');
        }

        return $rules;
    }