Process an asset.
@param $id
@param string $language
@return mixed
439628
function process($id, $language = null)
    {
        if (!$language && defined('CONTENTFUL_DEFAULT_LANGUAGE')) {
            $language = CONTENTFUL_DEFAULT_LANGUAGE;
        } else {
            $language = 'en-US';
        }
        $this->requestDecorator->setId($id  . '/files/' . $language . '/process');
        $result = $this->client->put($this->requestDecorator->makeResource(), $this->requestDecorator->makePayload(), $this->requestDecorator->makeHeaders());
        $this->refresh();
        return $result;
    }
390480
public function delete($lang, $id)
    {
        if(!User::hasAccess('Language', 'delete')) {
            return $this->noPermission();
        }
        $language = Language::find($id);

        if($language) {
            if ($language->isDefault) {
                return $this->response("You can't delete the default language!", 403);
            }

            if($language->delete()) {
                // create virutal column for slug of every post type in the created language
                $allPostTypes = PostType::all();
                foreach ($allPostTypes as $postType){
                    AccioQuery::deleteColumn($postType->slug, "slug_".$language->slug);
                }

                $this->deleteDirectory($language->slug);
                return $this->response('The Language was deleted');
            }
        }

        return $this->response('The Language was not deleted. Please try again later', 500);
    }
1266925
public function getAsset($id)
    {
        $params = array( 'id' => $id );
        $params = $this->validator->validate($params);

        try {
            return $this->client->sendRequest('assets/{id}', $params, 'GET');
        } catch (\Exception $ex) {
            throw $ex;
        }
    }
1267472
public function delete($lang, $id)
    {
        if ($this->deleteUser($id)) {
            $result = $this->response('User is deleted');
        }else{
            $result = $this->response('Internal server error. Please try again later', 500);
        }
        return $result;
    }
263930
public function handle(Language $language): Response
    {
        // We need to unify response with repository format
        $this->load(ContentReadRepository::$loadRelations);
        return $this->getHandler()->handle($this, $language);
    }
283644
public function delete($lang, $postType, $id)
    {
        $deleteResult = $this->deletePost($id, $postType);
        if(gettype($deleteResult) == "boolean") {
            if($deleteResult) {
                return $this->response('Post is deleted successfully');
            }
            return $this->response('Post could not be deleted. Please try again later or contact administrator', 500);
        }
        return $deleteResult;
    }
274702
public function deleteTranslationAction($id, $locale)
    {
        $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')->deleteTranslation($transUnit, $locale);

        return new JsonResponse(array('deleted' => $deleted), $deleted ? 200 : 400);
    }
11098
public function deleteLanguage($id)
    {
        try {
            return $this->innerGateway->deleteLanguage($id);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
1352551
public function delete($lang, $id)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('PostType', 'delete')) {
            return $this->noPermission();
        }

        $res = $this->deletePostType($id);
        if($res && is_bool($res)) {
            return $this->response('Post Type is successfully deleted');
        }
        if($res && !is_bool($res)) {
            return $res;
        }
        return $this->response('Post Type could not be deleted. Please try again later or contact your Administrator!', 500);
    }
1206249
public function detailsJSON($lang, $id)
    {
        if(!User::hasAccess('Language', 'read')) {
            return $this->noPermission();
        }

        $language = Language::find($id);
        $final = array(
            'details' => $language
        );

        // Fire event
        $final['events'] = Event::fire('language:pre_update', [$final]);

        return $final;
    }
127186
def from_id(cls, _id, language=DEFAULT_LANG):
        
        db_file = DBVuln.get_file_for_id(_id, language=language)
        data = DBVuln.load_from_json(db_file, language=language)
        return cls(**data)
953121
public function update($id, $text)
    {
        $translation = $this->find($id);
        if (!$translation || $translation->isLocked()) {
            return false;
        }
        $translation->text = $text;
        $saved             = $translation->save();
        if ($saved && $translation->locale === $this->defaultLocale) {
            $this->flagAsUnstable($translation->namespace, $translation->group, $translation->item);
        }
        return $saved;
    }
907562
public function actionEditLanguage($id = null, $contextId = null)
    {
        if ($id === null) {
            $model = new Language();
        } else {
            $model = $this->findLanguageModel($id);
        }
        if ($contextId !== null) {
            $model->context_id = $contextId;
        }
        $hasAccess = ($model->isNewRecord && Yii::$app->user->can('multilingual-create-language'))
            || (!$model->isNewRecord && Yii::$app->user->can('multilingual-edit-language'));
        $isLoaded = $model->load(Yii::$app->request->post());
        if ($isLoaded && !$hasAccess) {
            throw new ForbiddenHttpException;
        }
        if ($isLoaded && $model->save()) {
            return $this->redirect(['edit-language', 'id' => $model->id]);
        } else {
            return $this->render(
                'edit-language',
                [
                    'hasAccess' => $hasAccess,
                    'model' => $model,
                ]
            );
        }
    }
351496
public function assetsDelete($id)
    {
        $resource = '/assets/' . $id . '.json';

        // Create request
        $data = $this->auth->request('DELETE', $resource);

        return $data;
    }
817440
protected function processLanguage(OutputInterface $output, $language)
    {
        $this->writeln($output, sprintf('processing language: <info>%s</info>...', $language));

        $destinationFiles = array();
        foreach ($this->baseFiles as $file) {
            $this->writelnVerbose($output, sprintf('processing file: <info>%s</info>...', $file));

            $srcFile = $this->getLanguageBasePath() . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . $file;

            // not a file from transifex received yet.
            if (!file_exists($srcFile)) {
                continue;
            }

            $src = new XliffFile($srcFile);

            $domain = $src->getOriginal();

            if ($domain != basename($file, '.xlf')) {
                throw new \InvalidArgumentException(
                    sprintf(
                        'Unexpected domain "%s" found in file "%s" instead of domain "%s"',
                        $domain,
                        $srcFile,
                        basename($file, '.xlf')
                    )
                );
            }

            $dstFile            = $domain . '.php';
            $destinationFiles[] = $dstFile;

            $dstDir = $this->getDestinationBasePath() . DIRECTORY_SEPARATOR . $language;
            if (!is_dir($dstDir)) {
                mkdir($dstDir, 0755, true);
            }

            $dest = new ContaoFile($dstDir . DIRECTORY_SEPARATOR . $dstFile);

            $changed = $this->convert($src, $dest);

            if ($changed) {
                $dest->setLanguage($language);
                $dest->setTransifexProject($this->project);
                $dest->setLastChange($src->getDate());

                if ($dest->getKeys()) {
                    $dest->save();
                } else {
                    unlink($dstDir . DIRECTORY_SEPARATOR . $dstFile);
                    // @codingStandardsIgnoreStart - Catch the error when directory is not empty.
                    @rmdir($dstDir);
                    // @codingStandardsIgnoreEnd
                }
            }
        }

        $this->cleanupObsoleteFiles($output, $language, $destinationFiles);
    }
865250
public function resolve($id)
    {
        foreach ($this->transformers as $contentType => $transformer) {
            if (stripos($id, $contentType) === 0) {
                return $transformer;
            }
        }
    }
993536
public function actionSave($id = null, $languageId)
    {
        if (!empty($languageId)) {
            if (!empty($id)) {

                $model = $this->findModel($id);
                if (empty($model)) {
                    throw new NotFoundHttpException;
                }
                $modelTranslation = $this->findModelTranslation($id, $languageId);
                if (empty($modelTranslation)) {
                    $modelTranslation = new ProductAvailabilityTranslation();
                }
            }
            else {
                $model = new ProductAvailability();
                $modelTranslation = new ProductAvailabilityTranslation();
            }
        }
        else throw new BadRequestHttpException();


        if ($modelTranslation->load(Yii::$app->request->post())) {

            $model->save(false);

            $modelTranslation->availability_id = $model->id;
            $modelTranslation->language_id = $languageId;
            if ($modelTranslation->validate()) {

                $modelTranslation->save();
                $this->trigger(self::EVENT_AFTER_CREATE_OR_UPDATE_PRODUCT_AVAILABILITY,
                    new ProductAvailabilityEvent(['availability' => $model]));

                return $this->redirect(['save', 'id' => $model->id, 'languageId' => $languageId]);
            }
        }
        return $this->render('save', [
            'model' => $model,
            'modelTranslation' => $modelTranslation,
            'languages' => Language::find()->all(),
            'selectedLanguage' => Language::findOne($languageId)
        ]);

    }