Create a new (unsaved and unapproved) Locale instance given its locale ID.

@param string $id

@return static
763706
public static function create($id)
    {
        $language = GettextLanguage::getById($id);
        if ($language === null) {
            throw new UserMessageException(t('Unknown locale identifier: %s', $id));
        }
        $pluralForms = [];
        foreach ($language->categories as $category) {
            $pluralForms[] = $category->id . ':' . $category->examples;
        }
        $result = new static();
        $result->id = $language->id;
        $result
            ->setIsApproved(false)
            ->setIsSource(false)
            ->setName($language->name)
            ->setPluralForms($pluralForms)
            ->setPluralFormula($language->formula)
            ->setRequestedBy(null)
            ->setRequestedOn(null)
        ;

        return $result;
    }
1357871
public function initDefinition($id) {
		$reflection = $this->getReflectionById($id);
		$args       = $this->getArguments();
		
		$definition = new Definition\ClassDefinition($reflection, $args);
		
		if ($this->isFactory()) {
			$definition->setFactoryMode();
		}
		
		return $definition;
	}
733805
public static function firstOrNew($id)
    {
        if ($entity = self::getDataMapperInstance()->first($id)) {
            return $entity;
        }

        $entity = new static();
        $entity->_id = $id;

        return $entity;
    }
344910
public function setDatatableId($id)
    {
        if (!array_key_exists($id, self::$_instances))
        {
            self::$_instances[$id] = $this;
        }
        else
        {
            throw new \Exception('Identifer already exists');
        }
        return $this;
    }
222225
protected function __apiUpdate(string $id)
    {
        $record = HCCountries::findOrFail($id);
        $record->languages()->sync(array_get($this->getInputData(), 'languages'));

        return $this->apiShow($record->id);
    }
59128
public function getTranslationModel($id = null)
    {
        $translationModel = new TranslationModel();
        $translationModel->setKeyword($this->getKeyword());
        $translationModel->setDomain($this->getDomain());
        $translationModel->addText($this->getLocale(), $this->getText(), $id);

        return $translationModel;
    }
92135
public function edit($id = null)
    {
        $position = $this->BannersPositions->get($id);

        if ($this->request->is(['patch', 'post', 'put'])) {
            $position = $this->BannersPositions->patchEntity($position, $this->request->getData());

            if ($this->BannersPositions->save($position)) {
                $this->Flash->success(I18N_OPERATION_OK);

                return $this->redirect(['action' => 'index']);
            }

            $this->Flash->error(I18N_OPERATION_NOT_OK);
        }

        $this->set(compact('position'));
    }
849143
public function getTranslation($iso, $id)
    {

        $id_element = $this->model->hasBeenTranslated($this->model->getTable(), $id, $iso);
        if (!empty($id_element)) {
            return redirect()->to(action($this->getControllerNameForAction().'@getEdit', $id_element));
        }

        $model = (!empty($id) || $id === "0") ? $this->model->withoutTranslation()->findOrFail($id) : $this->model;
        $form  = FormBuilder::create(get_class($this->form), [
            'model' => $model
        ])
            ->remove('id')
            ->add('translation_iso', 'hidden', ['default_value' => $iso])
            ->add('translation_id_source', 'hidden', ['default_value' => $id])
            ->add('local_override', 'hidden', ['default_value' => $iso]);

        $form_content = view('form-builder::form.components.formgenerator.full', [
            'form' => $form
        ]);

        $this->layoutManager->add([
            'content' => view('expendable::admin.form.state.form', [
                'form' => $form_content
            ])
        ]);

        return $this->layoutManager->render();
    }
349067
public static function factory ($id)
    {
        // Which class to instantiate
        $entityClassName = get_called_class();

        // Get object cache registry
        $ObjectRegistry  = \Teon\ObjectRegistry\ObjectRegistry::getInstance();

        // If this object already in cache, use that
        if ($ObjectRegistry->exists($entityClassName, $id)) {
            return $ObjectRegistry->get($entityClassName, $id);
        }

        // If not, instantiate new, store in object registry and return it
        $Object = new $entityClassName($id);
        $ObjectRegistry->store($Object);
        return $Object;
    }
1287857
public function setId($id)
    {
        if (!is_null($id)) {
            $id = (string) $id;
        }

        $this->id = $id;
        return $this;
    }
1137522
public function setId($id = null)
    {
        if ($id == null) {
            $this->id = mt_rand(0, 255);
        } else {
            $this->id = (int)$id;
        }

        return $this;
    }
1295203
public static function cache( int $id )
	{
		if( ! self::cacheIs($id) && $id === 0 )
		{
			$module = new ModuleCore();
			self::setCache(0, $module->setLoadedFromCache());
		}

		return self::defaultCache($id);
	}
410057
protected function createNotFoundException(string $id): NotFoundExceptionInterface
    {
        return new ServiceNotFoundException($id, end($this->loading) ?: null, array_keys($this->factories));
    }
281911
public function get($id)
    {
        if ($this->has($id) === false)
        {
            $message = (string) 'Class (%s) does not exists';

            throw new NotFoundException(sprintf($message, $id));
        }

        $reflection = new \ReflectionClass($id);

        if ($constructor = $reflection->getConstructor())
        {
            $arguments = $this->arguments($constructor);

            return $reflection->newInstanceArgs($arguments);
        }

        return new $id;
    }
840663
public function deleteAction($id)
    {
        $this->checkCsrf();

        $transUnit = $this->get('lexik_translation.translation_storage')->getTransUnitById($id);

        if (!$transUnit) {
            throw $this->createNotFoundException(sprintf('No TransUnit found for id "%s".', $id));
        }

        $deleted = $this->get('lexik_translation.trans_unit.manager')->delete($transUnit);

        return new JsonResponse(array('deleted' => $deleted), $deleted ? 200 : 400);
    }
129691
public function edit($id)
    {
        $this->loadModel('Locale.Languages');
        $language = $this->Languages->get($id);
        $languages = LocaleToolbox::languagesList(true);
        $icons = LocaleToolbox::flagsList();

        if ($this->request->data()) {
            $language = $this->Languages->patchEntity($language, $this->request->data, [
                'fieldList' => [
                    'name',
                    'direction',
                    'icon',
                ]
            ]);

            if ($this->Languages->save($language)) {
                $this->Flash->success(__d('locale', 'Language was successfully saved!'));
                $this->redirect($this->referer());
            } else {
                $this->Flash->success(__d('locale', 'Language could not be saved, please check your information.'));
            }
        }

        $this->title(__d('locale', 'Editing Language'));
        $this->set(compact('language', 'languages', 'icons'));
        $this->Breadcrumb
            ->push('/admin/locale')
            ->push(__d('locale', 'Editing language'), '');
    }
1012925
protected function resolveData($id)
    {
        if (!is_null($id)) {
            return $this->getDoctrine()->getRepository($this->getEntityName())
                ->find($id);
        }

        return new Menu();
    }