. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Module; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Menu; /** * Trait ModuleChartTrait - default implementation of ModuleChartInterface */ trait ModuleChartTrait { /** * @return string */ abstract function getName(): string; /** * A main menu item for this chart. * * @param Individual $individual * * @return Menu */ public function chartMenu(Individual $individual): Menu { return new Menu( $this->title(), $this->chartUrl($individual), $this->chartUrlClasss(), $this->chartUrlAttributes() ); } /** * A menu item for this chart for an individual box in a chart. * * @param Individual $individual * * @return Menu|null */ public function chartMenuIndividual(Individual $individual): ?Menu { return null; } /** * The title for a specific instance of this chart. * * @param Individual $individual * * @return string */ public function chartTitle(Individual $individual): string { return $this->title(); } /** * The URL for a page showing chart options. * * @param Individual $individual * @param string[] $parameters * * @return string */ public function chartUrl(Individual $individual, array $parameters = []): string { return route('module', [ 'module' => $this->getName(), 'action' => 'Chart', 'xref' => $individual->xref(), 'ged' => $individual->tree()->name(), ] + $parameters); } /** * Attributes for the URL. * * @return string[] */ public function chartUrlAttributes(): array { return ['rel' => 'nofollow']; } /** * CSS class for the URL. * * @return string */ public function chartUrlClasss(): string { return ''; } }