/** * Render the nav for the provided component. * * @param ComponentInterface $component * @return string */ public function direct(ComponentInterface $component, array $options = []) { if ($component instanceof CrudInterface) { $singularTitle = $component->getPrimaryModel()->getSingularTitle(); } else { $singularTitle = $component->getTitle(); } if ($component instanceof CrudInterface) { $pluralTitle = $component->getPrimaryModel()->getPluralTitle(); } else { $pluralTitle = $component->getTitle(); } if (!isset($options['createUrl'])) { $options['createUrl'] = null; } if (!isset($options['deletedRecordsModifier'])) { $options['deletedRecordsModifier'] = null; } return $this->partial('admin-component-nav.phtml', array('permissions' => $component->getPermissions(), 'singularTitle' => $singularTitle, 'pluralTitle' => $pluralTitle, 'createUrl' => $options['createUrl'], 'deletedRecordsModifier' => $options['deletedRecordsModifier'])); }
/** * Registering a component in WordPress means registering a handler * for a hook. Typically, add_object_page is used, but that implies * an entry in the top-level admin menu. Because we want to support * components that don't appear in the menu, we check the display-menu * permission here and then use add_submenu_page() with no slug to * get our callback over to WP without displaying anything in the * menu. * * @param ComponentInterface $component * @throws \Dewdrop\Exception */ protected function registerComponentHandlingCallback(ComponentInterface $component) { if ($component->getPermissions()->can('display-menu')) { $this->addObjectPage($component->getTitle(), $component->getTitle(), 'add_users', $component->getSlug(), function () use($component) { $this->renderOutputIntoShell($component); }, $component->getIcon(), $component->getMenuPosition()); } else { $this->addSubmenuPage(null, $component->getTitle(), $component->getTitle(), 'add_users', $component->getSlug(), function () use($component) { $this->renderOutputIntoShell($component); }); } }