src/LINEBot/MessageBuilder/TemplateBuilder/ButtonTemplateBuilder.php
public function buildTemplate()
    {
        if (!empty($this->template)) {
            return $this->template;
        }

        $actions = [];
        foreach ($this->actionBuilders as $actionBuilder) {
            $actions[] = $actionBuilder->buildTemplateAction();
        }

        $this->template = [
            'type' => TemplateType::BUTTONS,
            'text' => $this->text,
            'actions' => $actions,
        ];

        if ($this->title) {
            $this->template['title'] = $this->title;
        }

        if ($this->thumbnailImageUrl) {
            $this->template['thumbnailImageUrl'] = $this->thumbnailImageUrl;
        }

        if ($this->imageAspectRatio) {
            $this->template['imageAspectRatio'] = $this->imageAspectRatio;
        }

        if ($this->imageSize) {
            $this->template['imageSize'] = $this->imageSize;
        }

        if ($this->imageBackgroundColor) {
            $this->template['imageBackgroundColor'] = $this->imageBackgroundColor;
        }

        if ($this->defaultAction) {
            $this->template['defaultAction'] = $this->defaultAction->buildTemplateAction();
        }

        return $this->template;
    }
public function buildTemplate()
    {
        if (!empty($this->template)) {
            return $this->template;
        }

        $actions = [];
        foreach ($this->actionBuilders as $actionBuilder) {
            $actions[] = $actionBuilder->buildTemplateAction();
        }

        $this->template = [
            'type' => TemplateType::BUTTONS,
            'text' => $this->text,
            'actions' => $actions,
        ];

        if ($this->title) {
            $this->template['title'] = $this->title;
        }

        if ($this->thumbnailImageUrl) {
            $this->template['thumbnailImageUrl'] = $this->thumbnailImageUrl;
        }

        if ($this->imageAspectRatio) {
            $this->template['imageAspectRatio'] = $this->imageAspectRatio;
        }

        if ($this->imageSize) {
            $this->template['imageSize'] = $this->imageSize;
        }

        if ($this->imageBackgroundColor) {
            $this->template['imageBackgroundColor'] = $this->imageBackgroundColor;
        }

        if ($this->defaultAction) {
            $this->template['defaultAction'] = $this->defaultAction->buildTemplateAction();
        }

        return $this->template;
    }
public function buildTemplate ( ) { if ( ! empty ( $ this -> template ) ) { return $ this -> template ; } $ actions = [ ] ; foreach ( $ this -> actionBuilders as $ actionBuilder ) { $ actions [ ] = $ actionBuilder -> buildTemplateAction ( ) ; } $ this -> template = [ 'type' => TemplateType :: BUTTONS , 'text' => $ this -> text , 'actions' => $ actions , ] ; if ( $ this -> title ) { $ this -> template [ 'title' ] = $ this -> title ; } if ( $ this -> thumbnailImageUrl ) { $ this -> template [ 'thumbnailImageUrl' ] = $ this -> thumbnailImageUrl ; } if ( $ this -> imageAspectRatio ) { $ this -> template [ 'imageAspectRatio' ] = $ this -> imageAspectRatio ; } if ( $ this -> imageSize ) { $ this -> template [ 'imageSize' ] = $ this -> imageSize ; } if ( $ this -> imageBackgroundColor ) { $ this -> template [ 'imageBackgroundColor' ] = $ this -> imageBackgroundColor ; } if ( $ this -> defaultAction ) { $ this -> template [ 'defaultAction' ] = $ this -> defaultAction -> buildTemplateAction ( ) ; } return $ this -> template ; }
Builds button template message structure.

@return array
Builds button template message structure .