@param \Kerox\Messenger\Model\Common\Button\AbstractButton[] $buttons

@throws \Kerox\Messenger\Exception\MessengerException

@return \Kerox\Messenger\Model\Message\Attachment\Template\Element\MediaElement
774206
public function setButtons(array $buttons): self
    {
        $this->isValidArray($buttons, 1);
        $this->isValidButtons($buttons, $this->getAllowedButtonsType());

        $this->buttons = $buttons;

        return $this;
    }
2953
public function buttons($buttons)
    {
        if ($buttons instanceof Closure) {
            $buttons = $buttons($this);
        }

        if (!is_array($buttons)) {
            exit('子菜单必须是数组或者匿名函数返回数组');
        }

        $this->with('sub_button', $buttons);

        return $this;
    }
313733
public static function button($params = array()) {

        if( !is_array($params) )
        {
            throw new \InvalidArgumentException("Arguments is not a Array". print_r($params, true));
        }

        $o = "<button type='submit'";
        $o .= (isset($params['id'])) ? " id='{$params['id']}'" : '';
        $o .= (isset($params['name'])) ? " name='{$params['name']}'" : '';
        $o .= (isset($params['class'])) ? " class='{$params['class']}'" : '';
        $o .= (isset($params['onclick'])) ? " onclick='{$params['onclick']}'" : '';
        $o .= (isset($params['disabled'])) ? " disabled='{$params['disabled']}'" : '';
        $o .= (isset($params['style'])) ? " style='{$params['style']}'" : '';
        $o .= ">";
        $o .= (isset($params['iclass'])) ? "<i class='fa {$params['iclass']}'></i> " : '';
        $o .= (isset($params['value'])) ? "{$params['value']}" : '';
        $o .= "</button>\n";
        return $o;
    }
802710
public function setButtonExport(string $url = null): ButtonInterface
    {
        $addUrl = 'export=1';
        if (!$url) {
            $url = url()->current();
        }
        if ($array = request()->except('export')) {
            $url .= '?' . http_build_query($array);
        }
        $addUrl = \Illuminate\Support\Str::is('*?*', $url) ? '&' . $addUrl : '?' . $addUrl;
        $text = GridView::trans('grid.export');

        return $this->setActionCustom($url . $addUrl, $text, 'btn btn-default btn-outline-primary', 'fa fa-download')
            ->setAction(self::TYPE_ACTION_EXPORT)
            ->setId('js_amiExportButton');
    }
1165589
public function createMenu(array $buttons)
    {
        $result = $this->httpRaw(self::WECHAT_MENU_CREATE_URL . 'access_token=' . $this->getAccessToken(), [
            'button' => $buttons
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok';
    }
1165893
public function resolveMediaFunction($media, $locale)
    {
        if (!$media) {
            return;
        }

        if (is_object($media)) {
            return $this->resolveMediaObject($media, $locale);
        }

        try {
            return $this->mediaManager->getById($media, $locale);
        } catch (MediaNotFoundException $e) {
            return;
        }
    }
663042
public function addButtonsToLine($line, $buttons)
    {
        if (func_num_args() > 2) {
            $buttons = func_get_args();
            array_shift($buttons);
        }
        if (!is_array($buttons)) {
            $buttons = [$buttons];
        }
        foreach ($buttons as $button) {
            $this->buttons[$line][] = $button;
        }
        return $this;
    }
119203
public function removeMedia(Media $media)
    {
        $this->medias->removeElement($media);
        $media->removeTweet($this);

        return $this;
    }
410644
protected function isValidButtons(array $buttons, array $allowedButtonsType): void
    {
        /** @var \Kerox\Messenger\Model\Common\Button\AbstractButton $button */
        foreach ($buttons as $button) {
            if (!$button instanceof AbstractButton) {
                throw new InvalidClassException(
                    sprintf('Array can only contain instance of %s.', AbstractButton::class)
                );
            }

            if (!\in_array($button->getType(), $allowedButtonsType, true)) {
                throw new InvalidClassException(sprintf(
                    'Buttons can only be an instance of %s.',
                    implode(', ', $allowedButtonsType)
                ));
            }
        }
    }
418387
protected function buttonMessageToArray()
    {
        $message = [];
        $message['recipient'] = $this->recipient;
        $message['notification_type'] = $this->notificationType;
        $message['message']['attachment']['type'] = 'template';
        $message['message']['attachment']['payload']['template_type'] = 'button';
        $message['message']['attachment']['payload']['text'] = $this->text;
        $message['message']['attachment']['payload']['buttons'] = $this->buttons;

        return $message;
    }
854783
protected function createModal($title, $content = null, array $buttons = [])
    {
        $modal = new Modal($title);

        $buttons = [];

        if (empty($buttons)) {
            $buttons['submit'] = [
                'id'       => 'submit',
                'label'    => 'ekyna_core.button.save',
                'icon'     => 'glyphicon glyphicon-ok',
                'cssClass' => 'btn-success',
                'autospin' => true,
            ];
        }
        if (!array_key_exists('close', $buttons)) {
            $buttons['close'] = [
                'id'       => 'close',
                'label'    => 'ekyna_core.button.cancel',
                'icon'     => 'glyphicon glyphicon-remove',
                'cssClass' => 'btn-default',
            ];
        }

        $modal->setButtons($buttons);

        if ($content) {
            $modal->setContent($content);
        }

        return $modal;
    }
105327
public function buttons($buttons)
    {
        if ($buttons instanceof Closure) {
            $buttons = $buttons($this);
        }

        if (!is_array($buttons)) {
            throw new Exception('子菜单必须是数组或者匿名函数返回数组', 1);
        }

        $this->with('sub_button', $buttons);

        return $this;
    }
754307
public function clickToolbarButton($button)
	{
		$input = strtolower($button);

		$screenSize = explode("x", $this->config['window_size']);

		if ($screenSize[0] <= 480)
		{
			$this->click('Toolbar');
		}

		switch ($input)
		{
			case "new":
				$this->click(array('xpath' => "//div[@id='toolbar-new']//button"));
				break;
			case "edit":
				$this->click(array('xpath' => "//div[@id='toolbar-edit']//button"));
				break;
			case "publish":
				$this->click(array('xpath' => "//div[@id='toolbar-publish']//button"));
				break;
			case "unpublish":
				$this->click(array('xpath' => "//div[@id='toolbar-unpublish']//button"));
				break;
			case "archive":
				$this->click(array('xpath' => "//div[@id='toolbar-archive']//button"));
				break;
			case "check-in":
				$this->click(array('xpath' => "//div[@id='toolbar-checkin']//button"));
				break;
			case "batch":
				$this->click(array('xpath' => "//div[@id='toolbar-batch']//button"));
				break;
			case "rebuild":
				$this->click(array('xpath' => "//div[@id='toolbar-refresh']//button"));
				break;
			case "trash":
				$this->click(array('xpath' => "//div[@id='toolbar-trash']//button"));
				break;
			case "save":
				$this->click(array('xpath' => "//div[@id='toolbar-apply']//button"));
				break;
			case "save & close":
				$this->click(array('xpath' => "//div[@id='toolbar-save']//button"));
				break;
			case "save & new":
				$this->click(array('xpath' => "//div[@id='toolbar-save-new']//button"));
				break;
			case "cancel":
				$this->click(array('xpath' => "//div[@id='toolbar-cancel']//button"));
				break;
			case "options":
				$this->click(array('xpath' => "//div[@id='toolbar-options']//button"));
				break;
			case "empty trash":
				$this->click(array('xpath' => "//div[@id='toolbar-delete']//button"));
				break;
		}
	}
1256404
public function prepareMedia(Media $media)
    {
        $handler = $this->getHandler($media);
        $handler->prepareMedia($media);

        return $this;
    }
1198871
protected function generateBinaryFromRequest(MediaInterface $media)
    {
        if (!$media->getContentType()) {
            throw new \RuntimeException(
                'You must provide the content type value for your media before setting the binary content'
            );
        }

        $request = $media->getBinaryContent();

        if (!$request instanceof Request) {
            throw new \RuntimeException('Expected Request in binary content');
        }

        $content = $request->getContent();

        // create unique id for media reference
        $guesser = ExtensionGuesser::getInstance();
        $extension = $guesser->guess($media->getContentType());

        if (!$extension) {
            throw new \RuntimeException(
                sprintf('Unable to guess extension for content type %s', $media->getContentType())
            );
        }

        $handle = tmpfile();
        fwrite($handle, $content);
        $file = new ApiMediaFile($handle);
        $file->setExtension($extension);
        $file->setMimetype($media->getContentType());

        $media->setBinaryContent($file);
    }
127166
protected function _getElementHtml(AbstractElement $element)
    {
        $element->addData([
            'wysiwyg' => true,
            'config'  => $this->wysiwygConfig->getConfig($element)
        ]);
        return parent::_getElementHtml($element);
    }
1296320
public function getNextSiblingOf( AbstractElement $element ) {
		$index = $this->indexOf($element);

		return $this->childAtIndex($index + 1);
	}