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

use Concrete\Core\Entity\Attribute\Key\Key;
use Concrete\Core\Entity\Attribute\Value\Value\SelectValueOption;


/**
 * @deprecated
 */
class Option
{

    /**
     * @param Key $ak
     * @param $option
     * @param int $isEndUserAdded
     * @return Option
     */
    public static function add($ak, $value, $isEndUserAdded = 0)
    {
        /**
         * @var $type SelectSettings
         */
        $type = $ak->getAttributeKeySettings();
        $list = $type->getOptionList();

        $option = new SelectValueOption();
        $option->setSelectAttributeOptionValue($value);
        $option->setIsEndUserAdded($isEndUserAdded);
        $option->setOptionList($list);

        $em = \Database::connection()->getEntityManager();
        $em->persist($option);
        $em->flush();

        return $option;
    }

    public static function getByID($id)
    {
        $em = \Database::connection()->getEntityManager();
        return $em->find('\Concrete\Core\Entity\Attribute\Value\Value\SelectValueOption', $id);
    }


    public static function getByValue($value, $ak = false)
    {
        $em = \Database::connection()->getEntityManager();
        $controller = new \Concrete\Attribute\Select\Controller($em);
        return $controller->getOptionByValue($value, $ak);
    }


}<commit_msg>Fix #4575<commit_after><?php
namespace Concrete\Attribute\Select;

use Concrete\Core\Entity\Attribute\Key\Key;
use Concrete\Core\Entity\Attribute\Value\Value\SelectValueOption;
use Gettext\Translations;


/**
 * @deprecated
 */
class Option
{

    /**
     * @param Key $ak
     * @param $option
     * @param int $isEndUserAdded
     * @return Option
     */
    public static function add($ak, $value, $isEndUserAdded = 0)
    {
        /**
         * @var $type SelectSettings
         */
        $type = $ak->getAttributeKeySettings();
        $list = $type->getOptionList();

        $option = new SelectValueOption();
        $option->setSelectAttributeOptionValue($value);
        $option->setIsEndUserAdded($isEndUserAdded);
        $option->setOptionList($list);

        $em = \Database::connection()->getEntityManager();
        $em->persist($option);
        $em->flush();

        return $option;
    }

    public static function getByID($id)
    {
        $em = \Database::connection()->getEntityManager();
        return $em->find('\Concrete\Core\Entity\Attribute\Value\Value\SelectValueOption', $id);
    }


    public static function getByValue($value, $ak = false)
    {
        $em = \Database::connection()->getEntityManager();
        $controller = new \Concrete\Attribute\Select\Controller($em);
        return $controller->getOptionByValue($value, $ak);
    }

    public static function exportTranslations()
    {
        $translations = new Translations();
        $em = \Database::connection()->getEntityManager();
        $options = $em->getRepository(SelectValueOption::class)->findAll();
        /**
         * @var $option SelectValueOption
         */
        foreach($options as $option) {
            $translations->insert('SelectAttributeValue', $option->getSelectAttributeOptionValue());
        }
        return $translations;
    }


}
{'fraction_non_alphanumeric': 0.14814814814814814, 'fraction_numerical': 0.001851851851851852, 'mean_word_length': 2.6955530216647663, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, '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': '6185370', 'n_tokens_mistral': 932, 'n_tokens_neox': 914, 'n_words': 162}