{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% block toolbar %}
    {% if 'unknown' == collector.symfonyState %}
        {% set block_status = '' %}
        {% set symfony_version_status = 'Unable to retrieve information about the Symfony version.' %}
    {% elseif 'eol' == collector.symfonyState %}
        {% set block_status = 'red' %}
        {% set symfony_version_status = 'This Symfony version will no longer receive security fixes.' %}
    {% elseif 'eom' == collector.symfonyState %}
        {% set block_status = 'yellow' %}
        {% set symfony_version_status = 'This Symfony version will only receive security fixes.' %}
    {% elseif 'dev' == collector.symfonyState %}
        {% set block_status = 'yellow' %}
        {% set symfony_version_status = 'This Symfony version is still in the development phase.' %}
    {% else %}
        {% set block_status = '' %}
        {% set symfony_version_status = '' %}
    {% endif %}

    {% set icon %}
        <span class="sf-toolbar-label">
            {{ include('@WebProfiler/Icon/symfony.svg') }}
        </span>
        <span class="sf-toolbar-value">{{ collector.symfonyState is defined ? collector.symfonyversion : 'n/a' }}</span>
    {% endset %}

    {% set text %}
        <div class="sf-toolbar-info-group">
            <div class="sf-toolbar-info-piece">
                <b>Profiler token</b>
                <span>
                    {% if profiler_url %}
                        <a href="{{ profiler_url }}">{{ collector.token }}</a>
                    {% else %}
                        {{ collector.token }}
                    {% endif %}
                </span>
            </div>

            {% if 'n/a' is not same as(collector.env) %}
                <div class="sf-toolbar-info-piece">
                    <b>Environment</b>
                    <span>{{ collector.env }}</span>
                </div>
            {% endif %}

            {% if 'n/a' is not same as(collector.debug) %}
                <div class="sf-toolbar-info-piece">
                    <b>Debug</b>
                    <span class="sf-toolbar-status sf-toolbar-status-{{ collector.debug ? 'green' : 'red' }}">{{ collector.debug ? 'enabled' : 'disabled' }}</span>
                </div>
            {% endif %}
        </div>

        <div class="sf-toolbar-info-group">
            <div class="sf-toolbar-info-piece sf-toolbar-info-php">
                <b>PHP version</b>
                <span{% if collector.phpversionextra %} title="{{ collector.phpversion ~ collector.phpversionextra }}"{% endif %}>
                    {{ collector.phpversion }}
                    &nbsp; <a href="{{ path('_profiler_phpinfo') }}">View phpinfo()</a>
                </span>
            </div>

            <div class="sf-toolbar-info-piece sf-toolbar-info-php-ext">
                <b>PHP Extensions</b>
                <span class="sf-toolbar-status sf-toolbar-status-{{ collector.hasxdebug ? 'green' : 'gray' }}">xdebug {{ collector.hasxdebug ? '✓' : '✗' }}</span>
                <span class="sf-toolbar-status sf-toolbar-status-{{ collector.hasapcu ? 'green' : 'gray' }}">APCu {{ collector.hasapcu ? '✓' : '✗' }}</span>
                <span class="sf-toolbar-status sf-toolbar-status-{{ collector.haszendopcache ? 'green' : 'red' }}">OPcache {{ collector.haszendopcache ? '✓' : '✗' }}</span>
            </div>

            <div class="sf-toolbar-info-piece">
                <b>PHP SAPI</b>
                <span>{{ collector.sapiName }}</span>
            </div>
        </div>

        <div class="sf-toolbar-info-group">
            {% if collector.symfonyversion is defined %}
                <div class="sf-toolbar-info-piece">
                    <b>Resources</b>
                    <span>
                        <a href="https://symfony.com/doc/{{ collector.symfonyversion }}/index.html" rel="help">
                            Read Symfony {{ collector.symfonyversion }} Docs
                        </a>
                    </span>
                </div>
                <div class="sf-toolbar-info-piece">
                    <b>Help</b>
                    <span>
                        <a href="https://symfony.com/support">
                            Symfony Support Channels
                        </a>
                    </span>
                </div>
            {% endif %}
        </div>
    {% endset %}

    {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: true, name: 'config', status: block_status, additional_classes: 'sf-toolbar-block-right', block_attrs: 'title="' ~ symfony_version_status ~ '"' }) }}
{% endblock %}

{% block menu %}
    <span class="label label-status-{{ collector.symfonyState == 'eol' ? 'red' : collector.symfonyState in ['eom', 'dev'] ? 'yellow' : '' }}">
        <span class="icon">{{ include('@WebProfiler/Icon/config.svg') }}</span>
        <strong>Configuration</strong>
    </span>
{% endblock %}

{% block panel %}
    <h2>Symfony Configuration</h2>

    <div class="metrics">
        <div class="metric">
            <span class="value">{{ collector.symfonyversion }}</span>
            <span class="label">Symfony version</span>
        </div>

        {% if 'n/a' != collector.env %}
            <div class="metric">
                <span class="value">{{ collector.env }}</span>
                <span class="label">Environment</span>
            </div>
        {% endif %}

        {% if 'n/a' != collector.debug %}
            <div class="metric">
                <span class="value">{{ collector.debug ? 'enabled' : 'disabled' }}</span>
                <span class="label">Debug</span>
            </div>
        {% endif %}
    </div>

    {% set symfony_status = { dev: 'Unstable Version', stable: 'Stable Version', eom: 'Maintenance Ended', eol: 'Version Expired' } %}
    {% set symfony_status_class = { dev: 'warning', stable: 'success', eom: 'warning', eol: 'error' } %}
    <table>
        <thead class="small">
            <tr>
                <th>Symfony Status</th>
                <th>Bugs {{ collector.symfonystate in ['eom', 'eol'] ? 'were' : 'are' }} fixed until</th>
                <th>Security issues {{ collector.symfonystate == 'eol' ? 'were' : 'are' }} fixed until</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td class="font-normal">
                    <span class="label status-{{ symfony_status_class[collector.symfonystate] }}">{{ symfony_status[collector.symfonystate]|upper }}</span>
                    {% if collector.symfonylts %}
                        &nbsp; <span class="label status-success">Long-Term Support</span>
                    {% endif %}
                </td>
                <td class="font-normal">{{ collector.symfonyeom }}</td>
                <td class="font-normal">{{ collector.symfonyeol }}</td>
                <td class="font-normal">
                    <a href="https://symfony.com/roadmap?version={{ collector.symfonyminorversion }}#checker">View roadmap</a>
                </td>
            </tr>
        </tbody>
    </table>

    <h2>PHP Configuration</h2>

    <div class="metrics">
        <div class="metric">
            <span class="value">{{ collector.phpversion }}{% if collector.phpversionextra %} <span class="unit">{{ collector.phpversionextra }}</span>{% endif %}</span>
            <span class="label">PHP version</span>
        </div>

        <div class="metric">
            <span class="value">{{ collector.phparchitecture }} <span class="unit">bits</span></span>
            <span class="label">Architecture</span>
        </div>

        <div class="metric">
            <span class="value">{{ collector.phpintllocale }}</span>
            <span class="label">Intl locale</span>
        </div>

        <div class="metric">
            <span class="value">{{ collector.phptimezone }}</span>
            <span class="label">Timezone</span>
        </div>
    </div>

    <div class="metrics">
        <div class="metric">
            <span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.haszendopcache ? 'yes' : 'no') ~ '.svg') }}</span>
            <span class="label">OPcache</span>
        </div>

        <div class="metric">
            <span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasapcu ? 'yes' : 'no-gray') ~ '.svg') }}</span>
            <span class="label">APCu</span>
        </div>

        <div class="metric">
            <span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasxdebug ? 'yes' : 'no-gray') ~ '.svg') }}</span>
            <span class="label">Xdebug</span>
        </div>
    </div>

    <p>
        <a href="{{ path('_profiler_phpinfo') }}">View full PHP configuration</a>
    </p>

    {% if collector.bundles %}
        <h2>Enabled Bundles <small>({{ collector.bundles|length }})</small></h2>
        <table>
            <thead>
                <tr>
                    <th class="key">Name</th>
                    <th>Path</th>
                </tr>
            </thead>
            <tbody>
                {% for name in collector.bundles|keys|sort %}
                <tr>
                    <th scope="row" class="font-normal">{{ name }}</th>
                    <td class="font-normal">{{ profiler_dump(collector.bundles[name]) }}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
{% endblock %}
