@param bool $allowCreate

@return TranslationInterface
174716
public function getTranslation($allowCreate = false)
    {
        $locales = $this->getLocales();

        if (empty($locales)) {
            throw new LocaleNotFoundException();
        }

        $translation = null;

        foreach ($locales as $locale) {
            if (($translation = $this->translations->get($locale)) !== null) {
                break;
            }
        }

        if ($translation === null && $allowCreate) {
            $translation = $this->getTranslationFactory()->create(['locale' => reset($locales)]);
            $this->addTranslation($translation);
        }

        if ($translation === null && $this->hasFallbackLocale()) {
            $translation = $this->translations->get($this->getFallbackLocale());
        }

        if ($translation === null) {
            if ($this->hasFallbackLocale()) {
                $locales[] = $this->getFallbackLocale();
            }

            throw new TranslationNotFoundException();
        }

        return $translation;
    }
906477
public function create($checkExist = false)
    {
        $this->convertation();

        $model = new \CAgent;

        return $model->AddAgent(
            AgentHelper::createName($this->class, $this->constructorArgs, $this->callChain),
            $this->module,
            $this->periodically,
            $this->interval,
            null,
            $this->active,
            $this->executionTime,
            $this->sort,
            $this->userId,
            $checkExist
        );
    }
813298
private function resolveContentCreateForm(
        ContentCreateData $contentCreateData,
        string $languageCode
    ): FormInterface {
        return $this->formFactory->create(ContentEditType::class, $contentCreateData, [
            'languageCode' => $languageCode,
            'mainLanguageCode' => $languageCode,
            'drafts_enabled' => true,
        ]);
    }
792304
public function translations($active = true)
    {
        if ($active) {
            return $this->hasMany(BlockTranslation::class)->where('is_active', '=', true);
        }
        return $this->hasMany(BlockTranslation::class);
    }
306491
public function resizeToHeight($height, $allow_enlarge = false)
    {
        $ratio = $height / $this->getSourceHeight();
        $width = $this->getSourceWidth() * $ratio;

        $this->resize($width, $height, $allow_enlarge);

        return $this;
    }
490388
public function linkable($create = true, $edit = true)
    {
        $this->linkOnly = true;
        parent::writeable($create, $edit);
        return $this;
    }
723046
public function useLocaleParser($enable = true)
    {
        if ($enable === false) {
            $this->_useLocaleParser = $enable;

            return $this;
        }
        if (static::$numberClass === 'Cake\I18n\Number' ||
            is_subclass_of(static::$numberClass, 'Cake\I18n\Number')
        ) {
            $this->_useLocaleParser = $enable;

            return $this;
        }
        throw new RuntimeException(
            sprintf('Cannot use locale parsing with the %s class', static::$numberClass)
        );
    }
1298855
public function getTranslation($locale = 'en_US', ConnectionInterface $con = null)
    {
        if (!isset($this->currentTranslations[$locale])) {
            if (null !== $this->collPersonFunctionI18ns) {
                foreach ($this->collPersonFunctionI18ns as $translation) {
                    if ($translation->getLocale() == $locale) {
                        $this->currentTranslations[$locale] = $translation;

                        return $translation;
                    }
                }
            }
            if ($this->isNew()) {
                $translation = new ChildPersonFunctionI18n();
                $translation->setLocale($locale);
            } else {
                $translation = ChildPersonFunctionI18nQuery::create()
                    ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
                    ->findOneOrCreate($con);
                $this->currentTranslations[$locale] = $translation;
            }
            $this->addPersonFunctionI18n($translation);
        }

        return $this->currentTranslations[$locale];
    }
311064
public function buildArgsFormat(ArgsFormat $baseFormat = null)
    {
        $formatBuilder = ArgsFormat::build($baseFormat);

        if (!$this->anonymous) {
            $formatBuilder->addCommandName(new CommandName($this->name, $this->aliases));
        }

        $formatBuilder->addOptions($this->getOptions());
        $formatBuilder->addArguments($this->getArguments());

        return $formatBuilder->getFormat();
    }
141543
public function resizeToBestFit($max_width, $max_height, $allow_enlarge = false)
    {
        if ($this->getSourceWidth() <= $max_width && $this->getSourceHeight() <= $max_height && $allow_enlarge === false) {
            return $this;
        }

        $ratio  = $this->getSourceHeight() / $this->getSourceWidth();
        $width = $max_width;
        $height = $width * $ratio;

        if ($height > $max_height) {
            $height = $max_height;
            $width = $height / $ratio;
        }

        return $this->resize($width, $height, $allow_enlarge);
    }
1288785
public function create(CreateStruct $struct)
    {
        $language = $this->languageMapper->createLanguageFromCreateStruct(
            $struct
        );
        $language->id = $this->languageGateway->insertLanguage($language);

        return $language;
    }
869378
public function getBySource(tao_helpers_translation_TranslationUnit $translationUnit)
    {
        $returnValue = null;
        
        foreach ($this->getTranslationUnits() as $tu) {
            if ($tu->hasSameTranslationUnitSource($translationUnit)) {
                $returnValue = $tu;
                break;
            }
        }

        return $returnValue;
    }
420326
private function createLatteEngine()
	{
		$latte = new LatteEngine\Engine;
		$latte->setTempDirectory($this->temp);

		// Form macro.
		$latte->onCompile[] = function($latte) {
			Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
		};
		return $latte;
	}
244883
public function getTranslation($lang, $create = false)
    {
        foreach ($this->translations as $translation) {
            if ($lang == $translation->getLang()) {
                return $translation;
            }
        }

        if ($create) {
            $class = $this->getTranslationClass();

            /** @var TranslationInterface $translation */
            $translation = new $class();
            $translation->setLang($lang);
            $this->addTranslation($translation);

            return $translation;
        }

        return null;
    }
117272
private function insert($validate = true)
	{
		$this->verifyNotReadonly('insert');

		// Check if validation or beforeCreate returns false.
		if (($validate && !$this->_validate() || !$this->invokeCallback('beforeCreate',false))) {
			return false;
		}

		$table = static::table();

		// Get dirty attributes, or when nothing is dirty we just take all atrributes
		if (!($attributes = $this->dirtyAttributes())) { 
			$attributes = $this->_attributes;
		}

		$pk = $this->getPrimaryKey(true);
		$useSequence = false;

		if ($table->sequence && !isset($attributes[$pk]))
		{
			if (($conn = static::connection()) instanceof OciAdapter) {

				// terrible oracle makes us select the nextval first
				$attributes[$pk] = $conn->getNextSequenceValue($table->sequence);
				$table->insert($attributes);
				$this->_attributes[$pk] = $attributes[$pk];
				
			} else {
				// unset pk that was set to null
				if (array_key_exists($pk, $attributes)) {
					unset($attributes[$pk]);
				}

				$table->insert($attributes, $pk, $table->sequence);
				$useSequence = true;
			}
		} else {

			// Simple insert
			$table->insert($attributes);

		}
			

		// if we've got an autoincrementing/sequenced pk set it
		// don't need this check until the day comes that we decide to support composite pks
		// if (count($pk) == 1)
		{
			$column = $table->getColumnByInflectedName($pk);

			if ($column->autoIncrement || $useSequence) {
				$this->_attributes[$pk] = static::connection()->insertId($table->sequence);
			}
		}

		$this->_newRecord = false;
		$this->invokeCallback('afterCreate', false);
		return true;
	}
503898
protected function performAdditionalCreateAction($createEvent)
    {
        return $this->generateRedirectFromRoute(
            "admin.configuration.taxes-rules.update",
            $this->getViewArguments(),
            $this->getRouteArguments($createEvent->getTaxRule()->getId())
        );
    }
1231570
public function addTranslation(
        TranslationAddData $data = null,
        ?string $name = null
    ): FormInterface {
        $name = $name ?: sprintf('add-translation');

        return $this->formFactory->createNamed($name, TranslationAddType::class, $data ?? new TranslationAddData());
    }