Box\Spout\Writer\Common\Helper\AbstractStyleHelper::registerStyle PHP Method

registerStyle() public method

Duplicate styles won't be registered more than once.
public registerStyle ( Style $style ) : Style
$style Box\Spout\Writer\Style\Style The style to be registered
return Box\Spout\Writer\Style\Style The registered style, updated with an internal ID.
    public function registerStyle($style)
    {
        $serializedStyle = $style->serialize();
        if (!$this->hasStyleAlreadyBeenRegistered($style)) {
            $nextStyleId = count($this->serializedStyleToStyleIdMappingTable);
            $style->setId($nextStyleId);
            $this->serializedStyleToStyleIdMappingTable[$serializedStyle] = $nextStyleId;
            $this->styleIdToStyleMappingTable[$nextStyleId] = $style;
        }
        return $this->getStyleFromSerializedStyle($serializedStyle);
    }

Usage Example

Example #1
0
 /**
  * XLSX specific operations on the registered styles
  *
  * @param \Box\Spout\Writer\Style\Style $style
  * @return \Box\Spout\Writer\Style\Style
  */
 public function registerStyle($style)
 {
     $registeredStyle = parent::registerStyle($style);
     $this->registerFill($registeredStyle);
     $this->registerBorder($registeredStyle);
     return $registeredStyle;
 }
All Usage Examples Of Box\Spout\Writer\Common\Helper\AbstractStyleHelper::registerStyle