<commit_before><?php
/**
 * Created by PhpStorm.
 * User: emreyilmaz
 * Date: 27.02.15
 * Time: 15:47
 */

namespace Ojs\Common\Helper;


use APY\DataGridBundle\Grid\Action\RowAction;
use Symfony\Bundle\FrameworkBundle\Routing\Router;

class ActionHelper
{
    public static function deleteAction($route,$key)
    {
        global $kernel;
        $container = $kernel->getContainer();
        /** @var Router $router */
        $html = <<<HTML
             <i class="fa fa-trash-o"></i>
HTML;
        $rowAction = new RowAction("",$route);
        $rowAction->setTitle($html);
        $rowAction->setAttributes(['class'=>'btn btn-danger btn-xs  ']);
        $rowAction->setRouteParameters($key);
        $rowAction->setConfirm(true);
        $rowAction->setConfirmMessage("Do you want delete this row?");
        return $rowAction;
    }
} <commit_msg>ActionHelper for action buttons on grid bundle.<commit_after><?php
/**
 * Created by PhpStorm.
 * User: emreyilmaz
 * Date: 27.02.15
 * Time: 15:47
 */

namespace Ojs\Common\Helper;


use APY\DataGridBundle\Grid\Action\RowAction;
use APY\DataGridBundle\Grid\Row;
use Symfony\Bundle\FrameworkBundle\Routing\Router;

class ActionHelper
{
    public static function deleteAction($route,$key)
    {
        $rowAction = new RowAction("",$route);
        $rowAction->setTitle('<i class="fa fa-trash-o"></i>');
        $rowAction->setAttributes(['class'=>'btn btn-danger btn-xs  ']);
        $rowAction->setRouteParameters($key);
        $rowAction->setConfirm(true);
        $rowAction->setConfirmMessage("Do you want delete this row?");
        return $rowAction;
    }
    public static function userBanAction()
    {
        $rowAction = new RowAction("",'user_block');
        $rowAction->setTitle('<i class="fa fa-ban"></i>');
        $rowAction->setAttributes(['class'=>'btn btn-warning btn-xs  ']);
        $rowAction->setRouteParameters('id');
        $rowAction->setConfirm(true);
        $rowAction->setConfirmMessage("Do you want ban this user?");
        $rowAction->manipulateRender(function(RowAction $action, Row $row){
            if(!$row->getField('status')){
                $action->setRoute('user_unblock');
                $action->setTitle('<i class="fa fa-check"></i>');
                $action->setConfirmMessage("Do you want unban this user?");
            }
            return $action;
        });
        return $rowAction;
    }

    public static function switchUserAction($route, $key)
    {
        $rowAction = new RowAction("",$route);
        $rowAction->setTitle('<i class="fa fa-sign-in"></i>');
        $rowAction->setAttributes(['class'=>'btn btn-info btn-xs  ']);
        $rowAction->setRouteParameters($key);
        $rowAction->setRouteParametersMapping(['username'=>'_su']);
        $rowAction->setRole('ROLE_SUPER_ADMIN');
        return $rowAction;
    }

    public static function showAction($route, $key)
    {
        $rowAction = new RowAction("",$route);
        $rowAction->setTitle('<i class="fa fa-info-circle"></i>');
        $rowAction->setAttributes(['class'=>'btn btn-success btn-xs  ']);
        $rowAction->setRouteParameters($key);
        return $rowAction;
    }

    public static function editAction($route, $key)
    {
        $rowAction = new RowAction("",$route);
        $rowAction->setTitle('<i class="fa fa-pencil"></i>');
        $rowAction->setAttributes(['class'=>'btn btn-warning btn-xs  ']);
        $rowAction->setRouteParameters($key);
        return $rowAction;
    }
} 
{'fraction_non_alphanumeric': 0.16528452959679726, 'fraction_numerical': 0.005719187875321705, 'mean_word_length': 2.9436302142051862, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 56, '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': '352823', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1045, 'n_words': 194}