快速推送一条消息
@param array|object $message
@param string|array|null $tag
@param array|null $attributes
@return bool
@throws \yii\base\InvalidConfigException
423408
public function PublishMessage($message, $tag = null, $attributes = null)
    {
        return $this->createMessage($message, $tag, $attributes)->send();
    }
514218
protected function writeTag($tagName, array $attributes, $content)
	{
		$xml = '<' . $tagName;
		foreach ($attributes as $attrName => $attrValue)
		{
			$xml .= ' ' . $attrName . '="' . htmlspecialchars($attrValue) . '"';
		}
		if ($content === '')
		{
			$xml .= '/>';
		}
		else
		{
			$xml .= '>' . $content . '</' . $tagName . '>';
		}

		return $xml;
	}
1243022
public function setHTMLMessage($message)
    {
        if ($message === '') {
            throw new \InvalidArgumentException('$message must not be empty.', 1331488845);
        }

        if ($this->hasCssFile()) {
            $this->loadEmogrifierClass();
            $emogrifier = new Emogrifier($message, $this->getCssFile());
            $messageToStore = $emogrifier->emogrify();
        } else {
            $messageToStore = $message;
        }

        $this->setAsString('html_message', $messageToStore);
    }
25905
public static function startTag($name, $attributes, $emptyTag = false)
    {
        $buffer = '<' . $name;
        $buffer .= static::attributes($attributes);
        $buffer .= $emptyTag ? '/>' : '>';

        return $buffer;
    }
950827
public static function assertXMLValid($XML, string $message = '')
    {
        AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertXMLValid', ['assertThat']);
        self::assertThat($XML, new XMLValidConstraint(), $message);
    }
377774
final public function tag(string $name, array $attributes = [])
    {
        if ('' === $name) {
            throw new InvalidArgumentException('The tag name in "_defaults" must be a non-empty string.');
        }

        foreach ($attributes as $attribute => $value) {
            if (null !== $value && !is_scalar($value)) {
                throw new InvalidArgumentException(sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type.', $name, $attribute));
            }
        }

        $this->definition->addTag($name, $attributes);

        return $this;
    }
981219
protected function checkAttributeNode(DOMAttr $attribute, Tag $tag)
	{
		// Parse the attribute value for XPath expressions and assess their safety
		foreach (AVTHelper::parse($attribute->value) as $token)
		{
			if ($token[0] === 'expression')
			{
				$this->checkExpression($attribute, $token[1], $tag);
			}
		}
	}
381350
private function validateUserInputs($attributes, $eventTags = null)
    {
        if (!is_null($attributes) && !Validator::areAttributesValid($attributes)) {
            $this->_logger->log(Logger::ERROR, 'Provided attributes are in an invalid format.');
            $this->_errorHandler->handleError(
                new InvalidAttributeException('Provided attributes are in an invalid format.')
            );
            return false;
        }

        if (!is_null($eventTags)) {
            if (!Validator::areEventTagsValid($eventTags)) {
                $this->_logger->log(Logger::ERROR, 'Provided event tags are in an invalid format.');
                $this->_errorHandler->handleError(
                    new InvalidEventTagException('Provided event tags are in an invalid format.')
                );
                return false;
            }
        }

        return true;
    }
265329
public static function tag($tag, $attr = [], $html = '')
    {
        // Build attributes
        $attributes = [];
        foreach ($attr as $name => $value) {
            $attributes[] = $name.'="'.$value.'"';
        }

        if (in_array($tag, self::$voidElements)) {
            return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>';
        } else {
            return '<'.$tag.(!empty($attributes) ? ' '.implode(' ', $attributes) : '').'>'.$html.'</'.$tag.'>';
        }
    }
598689
public function publish($message) {
		if ($this->name === null) {
			throw new InvalidConfigException(get_class($this)." requires a name!");
		}
		$this->_data[] = $message;
		return $this->getConnection()->getClient()->publish($this->name,$message);
	}
716502
public function run($id, $attribute)
    {
        $model = $this->findModel($this->modelClass, $id);

        if (!$model->hasAttribute($attribute)) {
            throw new InvalidConfigException("Attribute doesn't exist.");
        }

        if ($model->$attribute == $this->onValue) {
            $model->$attribute = $this->offValue;
        } else {
            $model->$attribute = $this->onValue;
        }

        if ($this->preProcess && is_callable($this->preProcess, true)) {
            call_user_func($this->preProcess, $model);
        }

        if ($model->save(true, [$attribute])) {
            if ($this->setFlash) {
                Yii::$app->session->setFlash('success', $this->flashSuccess);
            }
        } else {
            if ($this->setFlash) {
                Yii::$app->session->setFlash('error', $this->flashError);
            }
        }

        if (Yii::$app->request->getIsAjax()) {
            Yii::$app->end();
        }

        if (!empty($this->redirect)) {
            return $this->controller->redirect($this->redirect);
        }

        return $this->controller->redirect(Yii::$app->request->getReferrer());
    }
1253555
public function createElement($tag, $attributes = null)
    {
        $node = parent::createElement($tag);
        $text = false;
        if (is_string($attributes)) {
            $node->setAttribute('class', $attributes);
        } else {
            if (is_array($attributes)) {
                foreach ($attributes as $key => $value) {
                    if ($key == 'text') {
                        $node->appendChild($this->createTextNode($value));
                        $text = true;
                    } else {
                        if (!is_null($value)) {
                            $node->setAttribute($key, $value);
                        }
                    }
                }
            }
        }
        if (!$text && !in_array($tag, ['img', 'br', 'input'])) {
            $node->appendChild($this->createTextNode(''));
        }
        return $node;
    }
985278
public static function addDefaultAttributes(Tag &$Tag)
    {
        if (isset(TagInfo::$defaultAttributes[$Tag->name])) {
            $Tag->attributes = array_merge(
                TagInfo::$defaultAttributes[$Tag->name],
                $Tag->attributes
            );
        }
    }
533685
protected function tag_open($parser, $tag, $attributes) {
        switch ($tag) {
            case 'moodle_database' :
                if (empty($attributes['version']) || empty($attributes['timestamp'])) {
                    throw new dbtransfer_exception('malformedxmlexception');
                }
                $this->begin_database_import($attributes['version'], $attributes['timestamp']);
                break;
            case 'table' :
                if (isset($this->current_table)) {
                    throw new dbtransfer_exception('malformedxmlexception');
                }
                if (empty($attributes['name']) || empty($attributes['schemaHash'])) {
                    throw new dbtransfer_exception('malformedxmlexception');
                }
                $this->current_table = $attributes['name'];
                $this->begin_table_import($this->current_table, $attributes['schemaHash']);
                break;
            case 'record' :
                if (isset($this->current_row) || !isset($this->current_table)) {
                    throw new dbtransfer_exception('malformedxmlexception');
                }
                $this->current_row = new stdClass();
                break;
            case 'field' :
                if (isset($this->current_field) || !isset($this->current_row)) {
                    throw new dbtransfer_exception('malformedxmlexception');
                }
                $this->current_field = $attributes['name'];
                $this->current_data = '';
                if (isset($attributes['value']) and $attributes['value'] === 'null') {
                    $this->current_data_is_null = true;
                } else {
                    $this->current_data_is_null = false;
                }
                break;
            default :
                throw new dbtransfer_exception('malformedxmlexception');
        }
    }
1211571
public function html($tag, $value = null, array $attributes = array()) {
        // This happens when used from a Garp_Form context
        if (array_key_exists('id', $attributes) && !$attributes['id']) {
            unset($attributes['id']);
        }
        if (isset($attributes['tag'])) {
            $tag = $attributes['tag'];
            unset($attributes['tag']);
        }
        $escape = true;
        if (array_key_exists('escape', $attributes)) {
            $escape = $attributes['escape'];
            unset($attributes['escape']);
        }

        $html  = '<' . $tag;
        $html .= $this->_htmlAttribs($attributes) . '>';
        if ($value) {
            if ($escape) {
                $value = $this->view->escape($value);
            }
            $html .= $value;
        }
        $html .= '</' . $tag . '>';
        return $html;
    }
832601
public function addMeta($tag, $value, array $attributes = []){
		$value = $this->h($value);
		if( false !== strpos($tag, ':') ){
			$tags = explode(':', $tag);
			$node = $this->dom->metadata->addChild($tags[1], $value, Schemas::getUri($tags[0]));
		}else{
			$node = $this->dom->metadata->addChild($tag, $value);
		}
		foreach( $attributes as $key => $val ){
			$node[$key] = $this->h($val);
		}
	}
107695
function _tag_open( &$parser, $tag, $attributes ) {
		$this->currentElement = strtoupper( $tag );

		switch( $this->currentElement ) {
			case 'INDEX':
				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
					$index = $this->addIndex( $attributes );
					xml_set_object( $parser,  $index );
				}
				break;
			case 'DATA':
				if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
					$data = $this->addData( $attributes );
					xml_set_object( $parser, $data );
				}
				break;
			case 'DROP':
				$this->drop();
				break;
			case 'FIELD':
				// Add a field
				$fieldName = $attributes['NAME'];
				$fieldType = $attributes['TYPE'];
				$fieldSize = isset( $attributes['SIZE'] ) ? $attributes['SIZE'] : NULL;
				$fieldOpts = !empty( $attributes['OPTS'] ) ? $attributes['OPTS'] : NULL;

				$this->addField( $fieldName, $fieldType, $fieldSize, $fieldOpts );
				break;
			case 'KEY':
			case 'NOTNULL':
			case 'AUTOINCREMENT':
			case 'DEFDATE':
			case 'DEFTIMESTAMP':
			case 'UNSIGNED':
				// Add a field option
				$this->addFieldOpt( $this->current_field, $this->currentElement );
				break;
			case 'DEFAULT':
				// Add a field option to the table object

				// Work around ADOdb datadict issue that misinterprets empty strings.
				if( $attributes['VALUE'] == '' ) {
					$attributes['VALUE'] = " '' ";
				}

				$this->addFieldOpt( $this->current_field, $this->currentElement, $attributes['VALUE'] );
				break;
			case 'OPT':
			case 'CONSTRAINT':
				// Accept platform-specific options
				$this->currentPlatform = ( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) );
				break;
			default:
				// print_r( array( $tag, $attributes ) );
		}
	}