App\Traits\MenuHandlerTrait::getMenuItem PHP Метод

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

public getMenuItem ( $input ) : mixed
$input
Результат mixed
    public function getMenuItem($input)
    {
        // If we where given a MenuItem return it.
        if ($input instanceof Menu) {
            return $input;
        }
        // Fix #21: PostgreSQL throws an QueryException when we search a text value in a
        // field of numerical type.
        try {
            // Try to find the root object by it's ID
            $menuItem = $this->menuRepository->find($input);
            if ($menuItem instanceof Menu) {
                return $menuItem;
            }
        } catch (QueryException $ex) {
        }
        try {
            // Try to find the root object by it's name
            $menuItem = $this->menuRepository->findBy('name', $input);
            if ($menuItem instanceof Menu) {
                return $menuItem;
            }
        } catch (QueryException $ex) {
        }
        // Could not find the requested menu item, throwing an exception.
        throw new MenuBuilderMenuItemNotFoundException("Menu item [" . $input . "] not found.");
    }