namespace Sabberworm\CSS\RuleSet;
+use Sabberworm\CSS\Parsing\ParserState;
+use Sabberworm\CSS\Parsing\OutputException;
use Sabberworm\CSS\Property\Selector;
use Sabberworm\CSS\Rule\Rule;
use Sabberworm\CSS\Value\RuleValueList;
use Sabberworm\CSS\Value\Size;
use Sabberworm\CSS\Value\Color;
use Sabberworm\CSS\Value\URL;
-use Sabberworm\CSS\Parsing\OutputException;
/**
* Declaration blocks are the parts of a css file which denote the rules belonging to a selector.
$this->aSelectors = array();
}
+ public static function parse(ParserState $oParserState) {
+ $aComments = array();
+ $oResult = new DeclarationBlock($oParserState->currentLine());
+ $oResult->setSelector($oParserState->consumeUntil('{', false, true, $aComments));
+ $oResult->setComments($aComments);
+ RuleSet::parseRuleSet($oParserState, $oResult);
+ return $oResult;
+ }
+
+
public function setSelectors($mSelector) {
if (is_array($mSelector)) {
$this->aSelectors = $mSelector;
$this->setSelectors($mSelector);
}
+ /**
+ * Get selectors.
+ *
+ * @return Selector[] Selectors.
+ */
public function getSelectors() {
return $this->aSelectors;
}
// If all the selectors have been removed, this declaration block becomes invalid
throw new OutputException("Attempt to print declaration block with missing selector", $this->iLineNo);
}
- $sResult = $oOutputFormat->implode($oOutputFormat->spaceBeforeSelectorSeparator() . ',' . $oOutputFormat->spaceAfterSelectorSeparator(), $this->aSelectors) . $oOutputFormat->spaceBeforeOpeningBrace() . '{';
+ $sResult = $oOutputFormat->sBeforeDeclarationBlock;
+ $sResult .= $oOutputFormat->implode($oOutputFormat->spaceBeforeSelectorSeparator() . ',' . $oOutputFormat->spaceAfterSelectorSeparator(), $this->aSelectors);
+ $sResult .= $oOutputFormat->sAfterDeclarationBlockSelectors;
+ $sResult .= $oOutputFormat->spaceBeforeOpeningBrace() . '{';
$sResult .= parent::render($oOutputFormat);
$sResult .= '}';
+ $sResult .= $oOutputFormat->sAfterDeclarationBlock;
return $sResult;
}