<commit_before><?php

/*
 * This file is part of the Indigo Base package.
 *
 * (c) Indigo Development Team
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Webshop;

use Indigo\Fuel\Dependency\Container as DiC;
use Twig_Extension;

class TwigWebshopExtension extends Twig_Extension
{

	/**
	 * Gets the name of the extension.
	 *
	 * @return  string
	 */
	public function getName()
	{
		return 'webshop';
	}

	/**
	 * {@inheritdocs}
	 */
	public function getFunctions()
	{
		return array(
			'cart' => new \Twig_Function_Method($this, 'cart'),
			'categories' => new \Twig_Function_Method($this, 'categories'),
			'active' => new \Twig_Function_Method($this, 'active'),
			'random_products' => new \Twig_Function_Method($this, 'random_products'),
		);
	}

	public function cart()
	{
		return DiC::resolve('cart');
	}

	public function categories()
	{
		$em = DiC::resolve('doctrine.manager')->getEntityManager();

		$categories = $em->createQueryBuilder()
			->select('t')
			->from('Taxonomy\\Entity\\Taxon', 't')
			->where('t.id = ?1')
			->setParameter(1, 1)
			->getQuery()
			->getResult();

		return reset($categories);
	}

	public function active()
	{
		return implode('/', \Request::active()->route->method_params);
	}

	public function random_products()
	{
		$em = DiC::resolve('doctrine.manager')->getEntityManager();

		$products = $em->createQueryBuilder()
			->select('p')
			->from('Erp\\Stock\\Entity\\Product', 'p')
			->setMaxResults(20)
			->getQuery()
			->getResult();

		return $products;
	}
}
<commit_msg>Random products<commit_after><?php

/*
 * This file is part of the Indigo Base package.
 *
 * (c) Indigo Development Team
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Webshop;

use Indigo\Fuel\Dependency\Container as DiC;
use Twig_Extension;

class TwigWebshopExtension extends Twig_Extension
{

	/**
	 * Gets the name of the extension.
	 *
	 * @return  string
	 */
	public function getName()
	{
		return 'webshop';
	}

	/**
	 * {@inheritdocs}
	 */
	public function getFunctions()
	{
		return array(
			'cart' => new \Twig_Function_Method($this, 'cart'),
			'categories' => new \Twig_Function_Method($this, 'categories'),
			'active' => new \Twig_Function_Method($this, 'active'),
			'random_products' => new \Twig_Function_Method($this, 'random_products'),
		);
	}

	public function cart()
	{
		return DiC::resolve('cart');
	}

	public function categories()
	{
		$em = DiC::resolve('doctrine.manager')->getEntityManager();

		$categories = $em->createQueryBuilder()
			->select('t')
			->from('Taxonomy\\Entity\\Taxon', 't')
			->where('t.id = ?1')
			->setParameter(1, 1)
			->getQuery()
			->getResult();

		return reset($categories);
	}

	public function active()
	{
		return implode('/', \Request::active()->route->method_params);
	}

	public function random_products()
	{
		$em = DiC::resolve('doctrine.manager')->getEntityManager();

		$products = $em->createQueryBuilder()
			->select('p')
			->from('Erp\\Stock\\Entity\\Product', 'p')
			->setMaxResults(20)
			->setFirstResult(rand(1, 950))
			->getQuery()
			->getResult();

		return $products;
	}
}

{'fraction_non_alphanumeric': 0.16768107121119902, 'fraction_numerical': 0.00426049908703591, 'mean_word_length': 3.876854599406528, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4716847', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1066, 'n_words': 251}