event派发
@param $type
@param $data
199877
public function my_dispatchEvent($type, $data)
    {
        foreach ($this->client as $client) {
            $client->dispatchEvent($type, $data);
        }
    }
927012
public function generateInput($type, array $data)
	{
		$class = $this->getElementInstance($type);

		if (array_key_exists('attributes', $data))
		{
			$class->setAttributes($data['attributes']);
		}

		if (array_key_exists('content', $data))
		{
			$class->setContents(
				  $this->generate($data['content'])
			);
		}

		if (array_key_exists('name', $data))
		{
			$class->setName($data['name']);
		}

		if (array_key_exists('value', $data))
		{
			$class->setValue($data['value']);
		}

		if (array_key_exists('label', $data))
		{
			$class->setLabel($data['label']);
		}

		return $class;
	}
1073189
protected function call($url, $data, $type = self::TYPE_POST)
    {
        try {
            $options = [
                'query' => [
                    'access_token' => $this->token,
                ],
            ];

            if ($this->secret) {
                $options['query']['appsecret_proof'] = $this->secret;
            }

            switch ($type) {
                case self::TYPE_DELETE:
                case self::TYPE_POST:
                    $options = array_merge($options, [
                        'headers' => [
                            'Content-Type' => 'application/json'
                        ],
                        'body' => json_encode($data),
                    ]);
                    break;
                case self::TYPE_GET:
                    $options['query'] = array_merge($options['query'], $data);
                    break;
            }
            
            $response = $this->client->request(
                $type,
                $url,
                $options
            );

            $this->debug($data, $response->getBody(), $response->getStatusCode());

            return json_decode($response->getBody(), true);
        } catch (ClientException $ex) {
            $this->debug($data, $ex->getResponse()->getBody(), $ex->getResponse()->getStatusCode());

            return json_decode($ex->getResponse()->getBody(), true);
        }
    }
919232
public function convert($type, $data)
    {
        foreach ($data as $k => $v) {
            if (is_array($v)) {
                $data[$k] = $this->convert($type, $v);
            }
        }

        switch (strtolower($type)) {
        case 'array':
            return (array) $data;
            break;
        case 'object':
            return (object) $data;
            break;
        default:
            throw new \Exception('Invalid conversion type given!');
        }
    }
350981
public function load($data, $dataType = 'json')
        {
            $this->_data = ($dataType != 'json') ? $this->dataToJson($data) : $data;
        }
505396
public static function set($key, $data, $type = 'ses')
    {
        $GLOBALS['TSFE']->fe_user->setKey(self::isType($type), $key, serialize($data));
        $GLOBALS['TSFE']->fe_user->storeSessionData();
    }
96259
public function setType($type)
    {
        if (!self::isValidType($type)) {
            throw new \InvalidArgumentException("$type is not a valid event type");
        }

        $this->type = $type;

        return $this;
    }
1303782
protected function response($data,$type='',$code=200) {
        $this->sendHttpStatus($code);
        exit($this->encodeData($data,strtolower($type)));
    }
1211771
public function delete_attribute( $type, $data ) {
		$type = $data['type'];
		unset( $data['type'] );
		return $this->post( 'attribute/' . $type, json_encode( $data ) );
	}
1087200
public function fire($eventType, $source, $data = null, $cancelable = true)
    {
        if (!$this->listeners) {
            return;
        }

        if (strpos($eventType, ':') === false) {
            throw new \Exception('事件类型字符串必须使用":"分隔');
        }

        list($type, $eventName) = explode(':', $eventType);

        if (!isset($this->listeners[$type]) && !isset($this->listeners[$eventType])) {
            return;
        }

        $event = new Event($eventName, $source, $data, $cancelable);

        // 总类型(如"db")对应的事件处理
        if (isset($this->listeners[$type])) {
            $this->performEventHandlers($this->listeners[$type], $event);
        }

        // 分类型(如"db:beforeQuery")对应的事件处理
        if (isset($this->listeners[$eventType])) {
            $this->performEventHandlers($this->listeners[$eventType], $event);
        }
    }
786162
protected function validateData($data): void
    {
        if ($data instanceof FormInterface) {
            $data = $data->getData();
        }

        if (!\is_object($data)) {
            throw new UnexpectedTypeException($data, 'object');
        }
    }
461463
protected function _create(array $data, $type, $id = null, array $parameters = []) {
        return $this->__create($data, $this->index(), $type, $id, $parameters);
    }
772650
public function report($type, $data)
    {
        $suite = $this->suite();
        if ($suite->root()->focused() && !$this->focused()) {
            return;
        }
        $suite->report($type, $data);
    }
1309509
public function onFrame($data, $type)
    {
        $ws = $this;
        $req = json_decode($data, true);
        if ($req['type'] === 'subscribe') {
            $eventName = $req['event'];
            $this->appInstance->pubsub->sub($req['event'], $this, function ($data) use ($ws, $eventName) {
                $ws->sendObject([
                    'type' => 'event',
                    'event' => $eventName,
                    'data' => $data,
                ]);
            });
        }
    }
548035
public function log($data, $level = self::LEVEL_INFO, $type = null)
    {
        if (!is_string($data)) {
            $data = print_r($data, true);
        }

        file_put_contents(
            $this->getLogDirectory() . '/' . $this->getLogFilename(),
            $this->getLogMessage($data, $level, $type),
            FILE_APPEND
        );
    }
1228680
private function doInsert($data, $type)
    {
        $eventResult = $this->fireEvents('before-insert');
        if (!is_null($eventResult)) {
            return $eventResult;
        }

        // If first value is not an array
        // Its not a batch insert
        if (!is_array(current($data))) {
            $queryObject = $this->getQuery($type, $data);

            list($result, $executionTime) = $this->statement($queryObject->getSql(), $queryObject->getBindings());

            $return = $result->rowCount() === 1 ? $this->pdo->lastInsertId() : null;
        } else {
            // Its a batch insert
            $return = array();
            $executionTime = 0;
            foreach ($data as $subData) {
                $queryObject = $this->getQuery($type, $subData);

                list($result, $time) = $this->statement($queryObject->getSql(), $queryObject->getBindings());
                $executionTime += $time;

                if ($result->rowCount() === 1) {
                    $return[] = $this->pdo->lastInsertId();
                }
            }
        }

        $this->fireEvents('after-insert', $return, $executionTime);

        return $return;
    }
398845
public function log($type = null, $data = [])
    {
        if (!func_num_args()) {
            return $this->_log;
        }
        $this->report($type, $this->log()->add($type, $data));
    }