<commit_before><?php namespace Gzero\Api\Controller;

use Gzero\Api\UrlParamsProcessor;
use Gzero\Core\BlockHandler;
use Gzero\Repository\BlockRepository;
use Gzero\Repository\LangRepository;


//use Illuminate\Support\Facades\Response;

/**
 * This file is part of the GZERO CMS package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * Class BlockController
 *
 * @package    Gzero\Admin\Controllers\Resource
 * @author     <NAME> <<EMAIL>>
 * @copyright  Copyright (c) 2014, <NAME>
 */
class BlockController extends ApiController {

    protected
        $processor,
        $blockRepo,
        $handler;

    public function __construct(
        BlockRepository $block,
        BlockHandler $blockHandler,
        UrlParamsProcessor $processor,
        LangRepository $lang
    ) {
        $this->blockRepo = $block;
        $this->processor = $processor;
        $this->langRepo  = $lang;
        $this->handler   = $blockHandler;
    }

    /**
     * Display a listing of the resource.
     *
     * @api        {get} /bocks Get blocks list
     * @apiVersion 0.1.0
     * @apiName    GetBlockList
     * @apiGroup   Block
     * @apiExample Example usage:
     * curl -i http://localhost/api/v1/blocks
     * @apiSuccess {Array} data List of blocks (Array of Objects)
     * @apiSuccess {Number} total Total count of all elements
     * @return Response
     */
    public function index()
    {
        $block = $this->blockRepo->getAllActive($this->processor->getPage(), $this->processor->getOrderByParams());
        if (!empty($block)) {
            return Response::json(['success' => TRUE, 'data' => $this->enSerializer->toArray($block)]);
        }
        return Response::json(['success' => TRUE, 'data' => NULL]);
    }<commit_msg>Blocks public API, index method<commit_after><?php namespace Gzero\Api\Controller;

use Gzero\Api\UrlParamsProcessor;
use Gzero\Core\BlockHandler;
use Gzero\Repository\BlockRepository;
use Gzero\Repository\LangRepository;


//use Illuminate\Support\Facades\Response;

/**
 * This file is part of the GZERO CMS package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * Class BlockController
 *
 * @package    Gzero\Admin\Controllers\Resource
 * @author     <NAME> <<EMAIL>>
 * @copyright  Copyright (c) 2014, <NAME>
 */
class BlockController extends ApiController {

    protected
        $processor,
        $blockRepo,
        $handler;

    public function __construct(
        BlockRepository $block,
        BlockHandler $blockHandler,
        UrlParamsProcessor $processor,
        LangRepository $lang
    ) {
        $this->blockRepo = $block;
        $this->processor = $processor;
        $this->langRepo  = $lang;
        $this->handler   = $blockHandler;
    }

    /**
     * Display a listing of the resource.
     *
     * @api        {get} /bocks Get blocks list
     * @apiVersion 0.1.0
     * @apiName    GetBlockList
     * @apiGroup   Block
     * @apiExample Example usage:
     * curl -i http://localhost/api/v1/blocks
     * @apiSuccess {Array} data List of blocks (Array of Objects)
     * @return Response
     */
    public function index()
    {
        $lang = $this->langRepo->getCurrent();
        if (!empty($lang)) {
            $regions = array();
            $blocks  = $this->blockRepo->getAllActive($lang);
            foreach ($blocks as $block) {
                $this->handler->build($block, $lang);

                foreach ($block->getRegions() as $region) {
                    $regions[$region][] = $block->view;
                }

            }
            return $this->respondWithSuccess(
                [
                    'data' => $regions,
                ]
            );
        }
        return $this->respondNotFound();
    }
{'fraction_non_alphanumeric': 0.11885245901639344, 'fraction_numerical': 0.004098360655737705, 'mean_word_length': 2.309322033898305, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 42, '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': '6637034', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1087, 'n_words': 289}