{% 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 %}
        {% if collector.applicationname %}
            <span class="sf-toolbar-label">{{ collector.applicationname }}</span>
            <span class="sf-toolbar-value">{{ collector.applicationversion }}</span>
        {% elseif collector.symfonyState is defined %}
            <span class="sf-toolbar-label">
                {{ include('@WebProfiler/Icon/symfony.svg') }}
            </span>
            <span class="sf-toolbar-value">{{ collector.symfonyversion }}</span>
        {% endif %}
    {% endset %}

    {% set text %}
        <div class="sf-toolbar-info-group">
            {% if collector.applicationname %}
                <div class="sf-toolbar-info-piece">
                    <b>{{ collector.applicationname }}</b>
                    <span>{{ collector.applicationversion }}</span>
                </div>
            {% endif %}

            <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.appname) %}
                <div class="sf-toolbar-info-piece">
                    <b>Kernel name</b>
                    <span>{{ collector.appname }}</span>
                </div>
            {% endif %}

            {% 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>
                    {{ 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' : 'red' }}">xdebug</span>
                <span class="sf-toolbar-status sf-toolbar-status-{{ collector.hasaccelerator ? 'green' : 'red' }}">accel</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>
                        {% if 'Silex' == collector.applicationname %}
                            <a href="http://silex.sensiolabs.org/documentation" rel="help">
                                Read Silex Docs
                            </a>
                        {% else %}
                            <a href="https://symfony.com/doc/{{ collector.symfonyversion }}/index.html" rel="help">
                                Read Symfony {{ collector.symfonyversion }} Docs
                            </a>
                        {% endif %}
                    </span>
                </div>
                <div class="sf-toolbar-info-piece">
                    <b>Help</b>
                    <span>
                        <a href="http://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' }) }}
{% 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 %}
    {% if collector.applicationname %}
        {# this application is not the Symfony framework #}
        <h2>Project Configuration</h2>

        <div class="metrics">
            <div class="metric">
                <span class="value">{{ collector.applicationname }}</span>
                <span class="label">Application name</span>
            </div>

            <div class="metric">
                <span class="value">{{ collector.applicationversion }}</span>
                <span class="label">Application version</span>
            </div>
        </div>

        <p>
            Based on <a class="text-bold" href="https://symfony.com">Symfony {{ collector.symfonyversion }}</a>
        </p>
    {% else %}
        <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.appname %}
                <div class="metric">
                    <span class="value">{{ collector.appname }}</span>
                    <span class="label">Application name</span>
                </div>
            {% endif %}

            {% 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>
    {% endif %}

    <h2>PHP Configuration</h2>

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

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

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

    <div class="metrics metrics-horizontal">
        <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.hasapc ? 'yes' : 'no') ~ '.svg') }}</span>
            <span class="label">APC</span>
        </div>

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

        <div class="metric">
            <span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.haseaccelerator ? 'yes' : 'no') ~ '.svg') }}</span>
            <span class="label">EAccelerator</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">{{ collector.bundles[name] }}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
{% endblock %}
