数据库日志记录（仅供参考）
@access public
@param string $type 类型
@param mixed  $data 数据
@param array  $options 参数
@return void
439476
public function log($type, $data, $options = [])
    {
        if (!$this->config['debug']) {
            return;
        }

        if (is_array($data)) {
            array_walk_recursive($data, function (&$value) {
                if ($value instanceof ObjectID || $value instanceof \MongoDB\BSON\ObjectId) {
                    $value = $value->__toString();
                }
            });
        }

        switch (strtolower($type)) {
            case 'aggregate':
                $this->queryStr = 'runCommand(' . ($data ? json_encode($data) : '') . ');';
                break;
            case 'find':
                $this->queryStr = $type . '(' . ($data ? json_encode($data) : '') . ')';

                if (isset($options['sort'])) {
                    $this->queryStr .= '.sort(' . json_encode($options['sort']) . ')';
                }

                if (isset($options['limit'])) {
                    $this->queryStr .= '.limit(' . $options['limit'] . ')';
                }

                $this->queryStr .= ';';
                break;
            case 'insert':
            case 'remove':
                $this->queryStr = $type . '(' . ($data ? json_encode($data) : '') . ');';
                break;
            case 'update':
                $this->queryStr = $type . '(' . json_encode($options) . ',' . json_encode($data) . ');';
                break;
            case 'cmd':
                $this->queryStr = $data . '(' . json_encode($options) . ');';
                break;
        }

        $this->options = $options;
    }
644850
public function supportsConstraint($type, array $options = [])
    {
        if (in_array($type, $this->types)) {
            $this->type = $type;
            return true;
        }

        return false;
    }
149912
public function update($index, $type, $id, $data, $options = [])
    {
        $body = [
            'doc' => empty($data) ? new \stdClass() : $data,
        ];
        if (isset($options["detect_noop"])) {
            $body["detect_noop"] = $options["detect_noop"];
            unset($options["detect_noop"]);
        }

        return $this->db->post([$index, $type, $id, '_update'], $options, Json::encode($body));
    }
880674
public function update($data,$options) {
        $this->model  =   $options['model'];
        $this->parseBind(!empty($options['bind'])?$options['bind']:array());
        $sql   = 'UPDATE '
            .$this->parseTable($options['table'])
            .$this->parseSet($data)
            .$this->parseWhere(!empty($options['where'])?$options['where']:'')
            .$this->parseLock(isset($options['lock'])?$options['lock']:false)
            .$this->parseComment(!empty($options['comment'])?$options['comment']:'');
        return $this->execute($sql,!empty($options['fetch_sql']) ? true : false);
    }
1323283
private function validateOptions(array $options, $type)
    {
        if (!isset(self::$requiredOptions[$type])) {
            return;
        }
        foreach (self::$requiredOptions[$type] as $requiredOption) {
            if (!array_key_exists($requiredOption, $options)) {
                throw new ConfigurationException(
                    sprintf('Option "%s" must be provided for "%s" type parameters.', $requiredOption, $type)
                );
            }
        }
    }
906588
public function attachData($data, $options=[]) {
		$attachment = \Swift_Attachment::newInstance($data);
		if(isset($options['filename']))
			$attachment->setFilename($options['filename']);
		if(isset($options['mime']))
			$attachment->setContentType($options['mime']);
		return $this->attach($attachment);
	}
824799
public function setLogType($type)
    {
        if (empty($type)) {
            $type = 'log';
        }

        $this->log_type = $type;
        $this->function = 'console.' . $this->log_type;
    }
389540
public function find($type = 'all', $options = []) {
		if ($type === 'first') {
			return parent::find('all', $options)->first();
		}
		if ($type === 'count') {
			return parent::find('all', $options)->count();
		}
		return parent::find($type, $options);
	}
52440
public static function dump($data, $type = self::DUMP_VAR_DUMP){

            switch($type){

                case self::DUMP_JSON:
                    return json_encode($data);
                case self::DUMP_JSON_PRETTY:
                    return json_encode($data, JSON_PRETTY_PRINT);
                case self::DUMP_VAR_EXPORT:
                    return var_export($data);
                case self::DUMP_VAR_DUMP:
                    return var_dump($data);
                case self::DUMP_XML:
                    return self::arrayToXML($data);
                case self::DUMP_SERIALIZE:
                    return serialize($data);

            }

        }
740140
protected function parseData($data, $options)
    {
        if (empty($data)) {
            return [];
        }

        // 获取绑定信息
        $bind = $this->query->getFieldsBind($options['table']);
        if ('*' == $options['field']) {
            $fields = array_keys($bind);
        } else {
            $fields = $options['field'];
        }

        $result = [];
        foreach ($data as $key => $val) {
            $item = $this->parseKey($key, $options);
            if (is_object($val) && method_exists($val, '__toString')) {
                // 对象数据写入
                $val = $val->__toString();
            }
            if (false === strpos($key, '.') && !in_array($key, $fields, true)) {
                if ($options['strict']) {
                    throw new Exception('fields not exists:[' . $key . ']');
                }
            } elseif (is_null($val)) {
                $result[$item] = 'NULL';
            } elseif (isset($val[0]) && 'exp' == $val[0]) {
                $result[$item] = $val[1];
            } elseif (is_scalar($val)) {
                // 过滤非标量数据
                if (0 === strpos($val, ':') && $this->query->isBind(substr($val, 1))) {
                    $result[$item] = $val;
                } else {
                    $key = str_replace('.', '_', $key);
                    $this->query->bind('__data__' . $key, $val, isset($bind[$key]) ? $bind[$key] : PDO::PARAM_STR);
                    $result[$item] = ':__data__' . $key;
                }
            }
        }
        return $result;
    }
689505
public function write($messages, $options = 0)
    {
        $this->log($messages);
        $this->output->write($messages, false, $options);
    }
1289137
public function create($type = null, $data = null, array $options = [])
    {
        if ($type instanceof ResourceInterface) {
            $type = $this->parameterResolver->resolveForm($type);
        }

        $validationGroups = $this->parameterResolver->resolveValidationGroups();
        $translationDomain = $this->parameterResolver->resolveTranslationDomain();

        if (!empty($validationGroups)) {
            $options['validation_groups'] = $validationGroups;
        }

        if (!empty($translationDomain)) {
            $options['translation_domain'] = $translationDomain;
        }

        if ($this->parameterResolver->resolveApi()) {
            $options['csrf_protection'] = false;
        }

        return $this->factory->create($type, $data, $options);
    }
653253
public function write($data, array $options = [])
    {
        if (!$this->has_real_call) {
            $this->createRealCall($data);
            $this->has_real_call = true;
        }
        $this->real_call->write($data, $options);
    }
1091568
public function beforeMarshal(Event $event, \ArrayObject $data, \ArrayObject $options)
    {
        $this->_prepareParamsData($data);
    }
1265831
protected function createFormBuilder($type = FormType::class, $data = null, array $options = [])
    {
        return $this->app['form.factory']->createBuilder($type, $data, $options);
    }
28818
public function createForm($name, $type = "form", array $data = array(), array $options = array())
    {
        $options = array_merge(
            [
                "csrf_protection" => false,
            ],
            $options
        );

        return parent::createForm($name, $type, $data, $options);
    }
533631
public function publish($type, $data)
    {
        $context = $this->_context;

        $packet = $context->header;

        $packet['type'] = $type;
        $packet['data'] = $data;

        /** @noinspection PhpUndefinedMethodInspection */
        /** @var \Redis $redis */
        $redis = $this->redis->getConnection();
        $r = $redis->publish($context->channel, json_encode($packet, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
        if ($r <= 0) {
            $this->_enabled = false;
            $this->_last_checked = microtime(true);
        }

        return $r;
    }