<commit_before><?php namespace Anomaly\AddonsModule\Http\Controller\Admin;

use Anomaly\AddonsModule\Addon\Command\BuildDocumentationNavigation;
use Anomaly\Streams\Platform\Addon\Addon;
use Anomaly\Streams\Platform\Addon\AddonCollection;
use Anomaly\Streams\Platform\Http\Controller\AdminController;
use Anomaly\Streams\Platform\Ui\Breadcrumb\BreadcrumbCollection;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Http\Request;

/**
 * Class AddonsController
 *
 * @link          http://anomaly.is/streams-platform
 * @author        AnomalyLabs, Inc. <<EMAIL>>
 * @author        <NAME> <<EMAIL>>
 * @package       Anomaly\AddonsModule\Http\Controller\Admin
 */
class AddonsController extends AdminController
{

    /**
     * Show the details of an addon.
     *
     * @param BreadcrumbCollection $breadcrumbs
     * @param AddonCollection      $addons
     * @param                      $type
     * @param                      $addon
     * @return string
     */
    public function view(BreadcrumbCollection $breadcrumbs, Request $request, AddonCollection $addons, $type, $addon)
    {
        /* @var Addon $addon */
        $addon = $addons->merged()->get($addon);

        $breadcrumbs->put($addon->getTitle(), '#');

        $json = $addon->getComposerJson();

        if (file_exists($readme = $addon->getPath('README.md'))) {
            $readme = file_get_contents($readme);
        }

        if (file_exists($license = $addon->getPath('LICENSE.md'))) {
            $license = file_get_contents($license);
        }

        return view('module::admin/addon/index', compact('addon', 'json', 'readme', 'license', 'request'))->render();
    }

    /**
     * Display addon documentation.
     *
     * @param BreadcrumbCollection $breadcrumbs
     * @param Request              $request
     * @param AddonCollection      $addons
     * @param Filesystem           $files
     * @param                      $type
     * @param                      $addon
     * @param null                 $path
     * @return string
     * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
     */
    public function documentation(
        BreadcrumbCollection $breadcrumbs,
        Request $request,
        AddonCollection $addons,
        Filesystem $files,
        $type,
        $addon,
        $path = null
    ) {
        /* @var Addon $addon */
        $addon = $addons->merged()->get($addon);

        $breadcrumbs->put(
            $addon->getTitle(),
            str_replace(
                'documentation',
                'view',
                $request->route()->getCompiled()->getStaticPrefix()
            ) . '/' . $addon->getNamespace()<commit_msg>Fix breadcrumb<commit_after><?php namespace Anomaly\AddonsModule\Http\Controller\Admin;

use Anomaly\AddonsModule\Addon\Command\BuildDocumentationNavigation;
use Anomaly\Streams\Platform\Addon\Addon;
use Anomaly\Streams\Platform\Addon\AddonCollection;
use Anomaly\Streams\Platform\Http\Controller\AdminController;
use Anomaly\Streams\Platform\Ui\Breadcrumb\BreadcrumbCollection;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Http\Request;

/**
 * Class AddonsController
 *
 * @link          http://anomaly.is/streams-platform
 * @author        AnomalyLabs, Inc. <<EMAIL>>
 * @author        <NAME> <<EMAIL>>
 * @package       Anomaly\AddonsModule\Http\Controller\Admin
 */
class AddonsController extends AdminController
{

    /**
     * Show the details of an addon.
     *
     * @param BreadcrumbCollection $breadcrumbs
     * @param AddonCollection      $addons
     * @param                      $type
     * @param                      $addon
     * @return string
     */
    public function view(BreadcrumbCollection $breadcrumbs, Request $request, AddonCollection $addons, $type, $addon)
    {
        /* @var Addon $addon */
        $addon = $addons->merged()->get($addon);

        $breadcrumbs->put($addon->getTitle(), '#');

        $json = $addon->getComposerJson();

        if (file_exists($readme = $addon->getPath('README.md'))) {
            $readme = file_get_contents($readme);
        }

        if (file_exists($license = $addon->getPath('LICENSE.md'))) {
            $license = file_get_contents($license);
        }

        return view('module::admin/addon/index', compact('addon', 'json', 'readme', 'license', 'request'))->render();
    }

    /**
     * Display addon documentation.
     *
     * @param BreadcrumbCollection $breadcrumbs
     * @param Request              $request
     * @param AddonCollection      $addons
     * @param Filesystem           $files
     * @param                      $type
     * @param                      $addon
     * @param null                 $path
     * @return string
     * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
     */
    public function documentation(
        BreadcrumbCollection $breadcrumbs,
        Request $request,
        AddonCollection $addons,
        Filesystem $files,
        $type,
        $addon,
        $path = null
    ) {
        /* @var Addon $addon */
        $addon = $addons->merged()->get($addon);

        $breadcrumbs->put(
            $addon->getTitle(),
            str_replace(
                'documentation',
                'view',
                $request->route()->getCompiled()->getStaticPrefix()
            ) . '/' . str_plural($addon->getType()) . '/view/' . $addon->getNamespace()
{'fraction_non_alphanumeric': 0.13031423290203328, 'fraction_numerical': 0.0, 'mean_word_length': 2.1961015948021263, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1682829', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1575, 'n_words': 282}