<commit_before><?php
namespace AnhNhan\Converge\Modules\User\Controllers;

use AnhNhan\Converge;
use AnhNhan\Converge\Modules\User\Storage\Role;
use AnhNhan\Converge\Modules\User\Query\RoleQuery;
use AnhNhan\Converge\Views\Grid\Grid;
use AnhNhan\Converge\Views\Panel\Panel;

use AnhNhan\Converge\Web\Application\HtmlPayload;
use AnhNhan\Converge\Web\Application\JsonPayload;
use YamwLibs\Libs\Html\Markup\MarkupContainer;

/**
 * @author <NAME> <<EMAIL>>
 */
final class RoleListingController extends AbstractUserController
{
    public function handle()
    {
        $request = $this->request;

        $container = new MarkupContainer;

        // Currently not paged
        $roles = id(new RoleQuery($this->app))
            ->retrieveRoles()
        ;

        $container->push(Converge\ht("a", "Create new role", array(
            "href"  => "/role/create",
            "class" => "btn btn-primary pull-right",
        )));

        $container->push(Converge\ht("h1", "Roles / Permissions"));

        $grid = new Grid;
        $row = $grid->row();

        foreach ($roles as $role) {
            $headerGrid = new Grid;
            $headerRow  = $headerGrid->row();
            $headerRow
                ->column(10)
                ->push(Converge\ht("h3", $role->label)
                    ->append(Converge\ht("small", " " . $role->name))
                )
                ->parentRow()
                ->column(2)
                ->push(
                    Converge\ht("a", Converge\icon_ion("edit", "edit"))
                        ->addClass("btn btn-default btn-small pull-right")
                        ->addOption("href", "role/{$role->cleanId}/edit")
                )
            ;

            $row->column(4)->push(<commit_msg>Selectively displaying things in user roles listing depending on whether the user is authenticated or not<commit_after><?php
namespace AnhNhan\Converge\Modules\User\Controllers;

use AnhNhan\Converge;
use AnhNhan\Converge\Modules\User\Storage\Role;
use AnhNhan\Converge\Modules\User\Query\RoleQuery;
use AnhNhan\Converge\Views\Grid\Grid;
use AnhNhan\Converge\Views\Panel\Panel;

use AnhNhan\Converge\Web\Application\HtmlPayload;
use AnhNhan\Converge\Web\Application\JsonPayload;
use YamwLibs\Libs\Html\Markup\MarkupContainer;

/**
 * @author <NAME> <<EMAIL>>
 */
final class RoleListingController extends AbstractUserController
{
    public function handle()
    {
        $request = $this->request;
        $user_authenticated = $this->isGranted('ROLE_USER');

        $container = new MarkupContainer;

        // Currently not paged
        $roles = id(new RoleQuery($this->app))
            ->retrieveRoles()
        ;

        $user_authenticated and $container->push(Converge\ht("a", "Create new role", array(
            "href"  => "/role/create",
            "class" => "btn btn-primary pull-right",
        )));

        $container->push(Converge\ht("h1", "Roles / Permissions"));

        $grid = new Grid;
        $row = $grid->row();

        foreach ($roles as $role) {
            $headerGrid = new Grid;
            $headerRow  = $headerGrid->row();
            $headerRow
                ->column(10)
                ->push(Converge\ht("h3", $role->label)
                    ->append(Converge\ht("small", " " . $role->name))
                )
            ;
            $user_authenticated and $headerRow->column(2)->push(
                Converge\ht("a", Converge\icon_ion("edit", "edit"))
                    ->addClass("btn btn-default btn-small pull-right")
                    ->addOption("href", "role/{$role->cleanId}/edit")
            );

            $row->column(4)->push(
{'fraction_non_alphanumeric': 0.14626129827444537, 'fraction_numerical': 0.003286770747740345, 'mean_word_length': 2.1293916023993145, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 53, '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': '3634914', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1120, 'n_words': 196}