<commit_before><?php
namespace Concrete\Core\Attribute;

use Concrete\Core\Entity\Attribute\Key\Key;
use Concrete\Core\Entity\Package;
use Doctrine\ORM\EntityManager;
use Gettext\Translations;

/**
 * Factory class for creating and retrieving instances of the Attribute type entity.
 */
class SetFactory
{
    protected $entityManager;

    public function __construct(EntityManager $entityManager)
    {
        $this->entityManager = $entityManager;
    }

    public function getByHandle($atHandle)
    {
        $r = $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Set');

        return $r->findOneBy(array('asHandle' => $atHandle));
    }

    public function getListByPackage(Package $package)
    {
        $r = $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Set');

        return $r->findByPackage($package);
    }


    public function getByID($asID)
    {
        $r = $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Set');

        return $r->findOneBy(array('asID' => $asID));
    }

    /**
     * @param $key Key
     */
    public function getByAttributeKey($key)
    {
        $r = $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\SetKey');
        $query = $r->createQueryBuilder('sk')
            ->where('sk.attribute_key = :attribute_key');
        $query->setParameter('attribute_key', $key);
        $results = $query->getQuery()->getResult();
        $sets = array();
        foreach ($results as $result) {
            $sets[] = $result->getAttributeSet();
        }

        return array_unique($sets);
    }

    public function add($atHandle, $atName, $pkg = null)
    {
        $type = new AttributeType();
        $type->setAttributeTypeName($atName);
        $type->setAttributeTypeHandle($atHandle);
        if ($pkg) {
            $type->setPackage($pkg);
        }
        $this->entityManager->persist($type);
        $this->entityManager->flush();

        return $type;
    }

    /**
     * @deprecated
     */
    public function exportTranslations()
    {
        $translations = new Translations();
        $sets = $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Set')
            ->findAll();
        foreach($sets as $set) {
            $translations->insert('AttributeSet', $set->getAttributeSetName());
        }
        return $translations;
    }

}<commit_msg>Removing broken attribute set code<commit_after><?php
namespace Concrete\Core\Attribute;

use Concrete\Core\Entity\Attribute\Key\Key;
use Concrete\Core\Entity\Package;
use Doctrine\ORM\EntityManager;
use Gettext\Translations;

/**
 * Factory class for creating and retrieving instances of the Attribute type entity.
 */
class SetFactory
{
    protected $entityManager;

    public function __construct(EntityManager $entityManager)
    {
        $this->entityManager = $entityManager;
    }

    public function getByHandle($atHandle)
    {
        $r = $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Set');

        return $r->findOneBy(array('asHandle' => $atHandle));
    }

    public function getListByPackage(Package $package)
    {
        $r = $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Set');

        return $r->findByPackage($package);
    }


    public function getByID($asID)
    {
        $r = $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Set');

        return $r->findOneBy(array('asID' => $asID));
    }

    /**
     * @param $key Key
     */
    public function getByAttributeKey($key)
    {
        $r = $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\SetKey');
        $query = $r->createQueryBuilder('sk')
            ->where('sk.attribute_key = :attribute_key');
        $query->setParameter('attribute_key', $key);
        $results = $query->getQuery()->getResult();
        $sets = array();
        foreach ($results as $result) {
            $sets[] = $result->getAttributeSet();
        }

        return array_unique($sets);
    }
    
    /**
     * @deprecated
     */
    public function exportTranslations()
    {
        $translations = new Translations();
        $sets = $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Set')
            ->findAll();
        foreach($sets as $set) {
            $translations->insert('AttributeSet', $set->getAttributeSetName());
        }
        return $translations;
    }

}
{'fraction_non_alphanumeric': 0.1470391061452514, 'fraction_numerical': 0.0, 'mean_word_length': 2.7176079734219267, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 60, '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': '7375081', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1278, 'n_words': 222}