/** * Return the URL string to this object. * @return string */ public function url($relative = false) { if ($pattern = $this->getBlueprint('url')) { $path = stringf($pattern, $this->toArray()); return $relative ? "/{$path}" : url($path); } return $this->assembleSlugFrom($this->parents()->reverse(), $relative); }
/** * Use an action handle to quickly set up this button with common properties. * @param $name string action name * @return $this|null */ protected function setupAction($name) { if (!$name || !array_key_exists($name, $this->actions)) { return null; } list($label, $url, $icon) = $this->actions[$name]; $this->label = stringf($label, $this->parentAttributes); $this->attribute('href', cms_url(stringf($url, $this->parentAttributes))); $this->icon = stringf($icon, $this->parentAttributes); // Check if the specific action has a CSS class it normally uses. if (isset($this->actionClass[$name])) { $this->classes($this->actionClass[$name]); } // If the parent doesn't adhere to the contract, don't render it. if (isset($this->contracts[$name])) { $this->canRender = has_contract($this->parent, $this->contracts[$name]); } return $this; }