MetaModels\Dca\MetaModelDcaBuilder::buildChildOperationButton PHP Метод

buildChildOperationButton() публичный Метод

This method exists only for being compatible when MetaModels are being used as child table from DC_Table context.
public buildChildOperationButton ( string $idParameter, array $arrRow, string $href, string $label, string $name, string $icon, string $attributes, string $table ) : string
$idParameter string The id parameter in use.
$arrRow array The current data row.
$href string The href to be appended.
$label string The operation label.
$name string The operation name.
$icon string The icon path.
$attributes string The button attributes.
$table string The table name.
Результат string
    public function buildChildOperationButton($idParameter, $arrRow, $href, $label, $name, $icon, $attributes, $table)
    {
        $dispatcher = $this->getDispatcher();
        $modelId = ModelId::fromValues($table, $arrRow['id']);
        $url = $href . '&' . $idParameter . '=' . $modelId->getSerialized();
        // If id parameter different, we have to override it in the URL.
        if ('id' !== $idParameter) {
            $url .= '&id=';
        }
        $urlEvent = new AddToUrlEvent($url);
        $dispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $urlEvent);
        $url = $urlEvent->getUrl();
        // If id parameter different, we have to clean out the id in the URL now.
        if ('id' !== $idParameter) {
            $url = preg_replace('#(&)id=(?:&)?#', '$1', $url);
        }
        $imageEvent = new GenerateHtmlEvent($icon, $label);
        $dispatcher->dispatch(ContaoEvents::IMAGE_GET_HTML, $imageEvent);
        $title = sprintf($label ?: $name, $arrRow['id']);
        return '<a href="' . $url . '" title="' . specialchars($title) . '"' . $attributes . '>' . $imageEvent->getHtml() . '</a> ';
    }