download report content

@param String $type
@param mixed $id
@param GeneratorListener $listener
765277
public function download($type, $id, GeneratorListener $listener)
    {
        $model = Report::where('id', $id)->first();
        if (is_null($model)) {
            return $listener->downloadFailed();
        }
        $filename = snake_case(str_replace(['-', ':', ' '], '_', $model->name));
        switch ($type) {
            case 'pdf':
                $snappy = app('snappy.pdf.wrapper');
                $appKey = config('app.key');
                $ch     = curl_init();
                curl_setopt($ch, CURLOPT_URL, handles('antares::logger/view/' . $id . '/html'));
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_HTTPHEADER, ["generator:  {$appKey}"]);
                $html   = curl_exec($ch);
                curl_close($ch);
                $snappy->loadHTML($html);
                $return = $snappy->download($filename . '.pdf');
                break;
            default:
                $return = Response::make($model->html, '200', array(
                            'Content-Type'        => 'application/octet-stream',
                            'Content-Disposition' => 'attachment; filename="' . $filename . '.html'
                ));
                break;
        }
        return $return;
    }
840676
public function group(TranslationListener $listener, $typeId, $group, $code = null)
    {
        try {
            Session::put('group', $group);
            return redirect(handles("antares::translations/index/{$typeId}/{$code}"));
        } catch (Exception $e) {
            Log::warning($e);
            return $listener->groupFailedFailed($e->getMessage());
        }
    }
327701
public function delete($id = null, ActivityListener $listener)
    {
        if (is_null($id) && !is_null($range = Input::get('daterange'))) {
            return $this->deleteByRange($listener, $range);
        }
        if (is_null($id) && !is_null($ids = input('attr'))) {
            return $this->deleteByIds($listener, $ids);
        }

        $model = Logs::withoutGlobalScopes()->whereHas('user', function($query) {
                    $query->whereIn('id', $this->users());
                })->find($id);
        if (is_null($model)) {
            return $listener->deleteFailed();
        }
        $model->delete();
        return $listener->deleteSuccess();
    }
185082
public function details($type, $id)
    {
      // Concat url
      $url = self::API_URL . '/' . $type . '/' . $id;

      // Create a REST request
      $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_GET);

      // Create a REST response
      $response = new \LibX\Net\Rest\Response();

      // Make the call
      $data = $this->call($request, $response);

      //return $data->_embedded;
      return $data;
    }
624358
public function update(BannedEmailUpdateListener $listener, $id, array $input)
    {
        if (empty(array_get($input, 'expired_at'))) {
            $input['expired_at'] = null;
        }

        $bannedEmail = $this->repository->findById($id);
        if (!$bannedEmail) {
            return $listener->notFound($id);
        }
        $bannedEmail->fill($input);
        $form = $this->presenter->form($bannedEmail);
        if (!$form->isValid()) {
            return $listener->updateBannedEmailFailedValidation($form->getMessageBag(), $id);
        }
        try {
            $this->repository->update($bannedEmail);
            $this->bannedEmailsService->saveToFile();
            return $listener->updateBannedEmailSuccess($bannedEmail);
        } catch (Exception $e) {
            Log::critical($e->getMessage());
            return $listener->updateBannedEmailFailed(['error' => $e->getMessage()]);
        }
    }
431966
public function render($type, $id, $level)
    {
        return $this->providers[$type]->getHtml($id, $level);
    }
308374
public function update(FieldUpdater $listener, $id, array $input)
    {
        $customfield = Foundation::make('antares.customfields.model')->findOrFail($id);
        $this->attachValidator();
        $on          = $customfield->imported ? 'imported' : 'update';
        $validation  = $this->validator->on($on)->with($input);

        if ($validation->fails()) {
            return $listener->updateFieldFailedValidation($validation->getMessageBag(), $id);
        }


        try {
            $this->saving($customfield, $input, 'update');
        } catch (Exception $e) {
            Log::emergency($e);
            return $listener->updateFieldFailed(['error' => $e->getMessage()]);
        }

        return $listener->fieldUpdated();
    }
1233259
public function update(Listener $listener, $id)
    {
        $model = LogsLoginDevices::query()->findOrFail($id);
        $form  = new DeviceForm($model);
        if (!$form->isValid()) {
            return $listener->deviceUpdateFailedValidation();
        }
        $model->name = Input::get('name');
        if (!$model->save()) {
            return $listener->deviceUpdateFailed();
        }
        return $listener->deviceUpdateSuccess();
    }
1220729
public function update($index, $type, $id, $document)
    {
        $request = $this->createRequestInstance(self::UPDATE_DOCUMENT, $index, $type);
        $request->setId($id);
        $request->setBody($document);

        return $this->client->send($request);
    }
119248
public function edit($listener, $id)
    {
        $eloquent = $this->model->findOrFail($id);
        $form = $this->presenter->form($eloquent);

        $this->fireEvent('form', [$eloquent, $form]);

        return $listener->editSucceed(compact('eloquent', 'form'));
    }
1036400
public function getEntityPath($type, $id)
    {
        // Allow other modules to interact
        $event = new EntityGetPathEvent($type, $id);
        $this->eventDispatcher->dispatch(EntityGetPathEvent::EVENT_GET_PATH, $event);
        if ($path = $event->getPath()) {
            return $path;
        }

        // In most cases, this will be used for nodes only, so just set the
        // node URL.
        // It will avoid nasty bugs, since the 'text' core module does sanitize
        // (and call check_markup()) during field load if there are any circular
        // links dependencies between two nodes, it triggers an finite loop.
        // This will also make the whole faster.
        // @todo If node does not exists, no error will be triggered.
        if ('node' === $type) {
            return 'node/' . $id;
        }

        $entity = $this->entityManager->getStorage($type)->load($id);
        if (!$entity) {
            throw new \InvalidArgumentException(sprintf("entity of type %s with identifier %s does not exist", $type, $id));
        }

        if (!$entity instanceof EntityInterface) {
            return $this->getDrupalEntityPath($type, $entity);
        } else {
            return $entity->url();
        }
    }
1279935
public function edit(Listener $listener, $id)
    {
        $eloquent = with(new Eloquent())->findOrNew($id);
        $name     = $eloquent->name;
        $raw      = app('antares.memory')->make('ui-components')->raw();
        $data     = isset($raw[$name]['data']) ? $raw[$name]['data'] : [];
        if (!empty($data)) {
            foreach ($data as $attribute => $value) {
                $eloquent->{$attribute} = $value;
            }
        }
        $form = $this->presenter->form($name, $eloquent, "antares::ui-components/updater");
        return $listener->showComponentUpdater($id, compact('form'));
    }
874779
function GetCache($type, $id) {
		if (!isset($this->cache[$type]) || !$this->cache[$type]) // Dont cache this type of call
			return FALSE;
		if (isset($this->_cache[$type][$id]))
			return $this->_cache[$type][$id];
		return FALSE;
	}
1021833
protected function patchExistingFile(TypeGenerator $generator, Type $type, SplFileInfo $fileInfo): bool
    {
        try {
            $this->filesystem->createBackup($fileInfo->getPathname());
            $file = FileGenerator::fromReflectedFileName($fileInfo->getPathname());
            $this->generateType($file, $generator, $type, $fileInfo);
        } catch (\Exception $e) {
            $this->output->writeln('<fg=red>'.$e->getMessage().'</fg=red>');
            $this->filesystem->removeBackup($fileInfo->getPathname());

            return false;
        }

        return true;
    }
1334334
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $contentType = $data->contentType;

        $urlTypeSuffix = $this->getUrlTypeSuffix($contentType->status);
        $mediaType = $data->fieldDefinitions !== null ? 'ContentType' : 'ContentTypeInfo';

        $generator->startObjectElement($mediaType);

        $visitor->setHeader('Content-Type', $generator->getMediaType($mediaType));

        if ($contentType->status === APIContentType::STATUS_DRAFT) {
            $visitor->setHeader('Accept-Patch', $generator->getMediaType('ContentTypeUpdate'));
        }

        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_loadContentType' . $urlTypeSuffix,
                array(
                    'contentTypeId' => $contentType->id,
                )
            )
        );
        $generator->endAttribute('href');

        $generator->startValueElement('id', $contentType->id);
        $generator->endValueElement('id');

        $generator->startValueElement('status', $this->serializeStatus($contentType->status));
        $generator->endValueElement('status');

        $generator->startValueElement('identifier', $contentType->identifier);
        $generator->endValueElement('identifier');

        $this->visitNamesList($generator, $contentType->getNames());

        $descriptions = $contentType->getDescriptions();
        if (is_array($descriptions)) {
            $this->visitDescriptionsList($generator, $descriptions);
        }

        $generator->startValueElement('creationDate', $contentType->creationDate->format('c'));
        $generator->endValueElement('creationDate');

        $generator->startValueElement('modificationDate', $contentType->modificationDate->format('c'));
        $generator->endValueElement('modificationDate');

        $generator->startObjectElement('Creator', 'User');
        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_loadUser',
                array('userId' => $contentType->creatorId)
            )
        );
        $generator->endAttribute('href');
        $generator->endObjectElement('Creator');

        $generator->startObjectElement('Modifier', 'User');
        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_loadUser',
                array('userId' => $contentType->modifierId)
            )
        );
        $generator->endAttribute('href');
        $generator->endObjectElement('Modifier');

        $generator->startObjectElement('Groups', 'ContentTypeGroupRefList');
        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_loadGroupsOfContentType',
                array('contentTypeId' => $contentType->id)
            )
        );
        $generator->endAttribute('href');
        $generator->endObjectElement('Groups');

        $generator->startObjectElement('Draft', 'ContentType');
        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_loadContentTypeDraft',
                array('contentTypeId' => $contentType->id)
            )
        );
        $generator->endAttribute('href');
        $generator->endObjectElement('Draft');

        $generator->startValueElement('remoteId', $contentType->remoteId);
        $generator->endValueElement('remoteId');

        $generator->startValueElement('urlAliasSchema', $contentType->urlAliasSchema);
        $generator->endValueElement('urlAliasSchema');

        $generator->startValueElement('nameSchema', $contentType->nameSchema);
        $generator->endValueElement('nameSchema');

        $generator->startValueElement(
            'isContainer',
            $this->serializeBool($generator, $contentType->isContainer)
        );
        $generator->endValueElement('isContainer');

        $generator->startValueElement('mainLanguageCode', $contentType->mainLanguageCode);
        $generator->endValueElement('mainLanguageCode');

        $generator->startValueElement(
            'defaultAlwaysAvailable',
            $this->serializeBool($generator, $contentType->defaultAlwaysAvailable)
        );
        $generator->endValueElement('defaultAlwaysAvailable');

        $generator->startValueElement('defaultSortField', $this->serializeSortField($contentType->defaultSortField));
        $generator->endValueElement('defaultSortField');

        $generator->startValueElement('defaultSortOrder', $this->serializeSortOrder($contentType->defaultSortOrder));
        $generator->endValueElement('defaultSortOrder');

        if ($data->fieldDefinitions !== null) {
            $visitor->visitValueObject(
                new Values\FieldDefinitionList(
                    $contentType,
                    $data->fieldDefinitions
                )
            );
        }

        $generator->endObjectElement($mediaType);
    }
400012
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $restContent = $data;
        $contentInfo = $restContent->contentInfo;
        $contentType = $restContent->contentType;
        $mainLocation = $restContent->mainLocation;
        $currentVersion = $restContent->currentVersion;

        $mediaType = ($restContent->currentVersion === null ? 'ContentInfo' : 'Content');

        $generator->startObjectElement('Content', $mediaType);

        $visitor->setHeader('Content-Type', $generator->getMediaType($mediaType));
        $visitor->setHeader('Accept-Patch', $generator->getMediaType('ContentUpdate'));

        $generator->startAttribute(
            'href',
            $data->path === null ?
                $this->router->generate('ezpublish_rest_loadContent', array('contentId' => $contentInfo->id)) :
                $data->path
        );
        $generator->endAttribute('href');

        $generator->startAttribute('remoteId', $contentInfo->remoteId);
        $generator->endAttribute('remoteId');
        $generator->startAttribute('id', $contentInfo->id);
        $generator->endAttribute('id');

        $generator->startObjectElement('ContentType');
        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_loadContentType',
                array('contentTypeId' => $contentInfo->contentTypeId)
            )
        );
        $generator->endAttribute('href');
        $generator->endObjectElement('ContentType');

        $generator->startValueElement('Name', $contentInfo->name);
        $generator->endValueElement('Name');

        $generator->startObjectElement('Versions', 'VersionList');
        $generator->startAttribute(
            'href',
            $this->router->generate('ezpublish_rest_loadContentVersions', array('contentId' => $contentInfo->id))
        );
        $generator->endAttribute('href');
        $generator->endObjectElement('Versions');

        $generator->startObjectElement('CurrentVersion', 'Version');
        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_redirectCurrentVersion',
                array('contentId' => $contentInfo->id)
            )
        );
        $generator->endAttribute('href');

        // Embed current version, if available
        if ($currentVersion !== null) {
            $visitor->visitValueObject(
                new VersionValue(
                    $currentVersion,
                    $contentType,
                    $restContent->relations
                )
            );
        }

        $generator->endObjectElement('CurrentVersion');

        $generator->startObjectElement('Section');
        $generator->startAttribute(
            'href',
            $this->router->generate('ezpublish_rest_loadSection', array('sectionId' => $contentInfo->sectionId))
        );
        $generator->endAttribute('href');
        $generator->endObjectElement('Section');

        // Main location will not exist if we're visiting the content draft
        if ($data->mainLocation !== null) {
            $generator->startObjectElement('MainLocation', 'Location');
            $generator->startAttribute(
                'href',
                $this->router->generate(
                    'ezpublish_rest_loadLocation',
                    array('locationPath' => trim($mainLocation->pathString, '/'))
                )
            );
            $generator->endAttribute('href');
            $generator->endObjectElement('MainLocation');
        }

        $generator->startObjectElement('Locations', 'LocationList');
        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_loadLocationsForContent',
                array('contentId' => $contentInfo->id)
            )
        );
        $generator->endAttribute('href');
        $generator->endObjectElement('Locations');

        $generator->startObjectElement('Owner', 'User');
        $generator->startAttribute(
            'href',
            $this->router->generate('ezpublish_rest_loadUser', array('userId' => $contentInfo->ownerId))
        );
        $generator->endAttribute('href');
        $generator->endObjectElement('Owner');

        // Modification date will not exist if we're visiting the content draft
        if ($contentInfo->modificationDate !== null) {
            $generator->startValueElement(
                'lastModificationDate',
                $contentInfo->modificationDate->format('c')
            );
            $generator->endValueElement('lastModificationDate');
        }

        // Published date will not exist if we're visiting the content draft
        if ($contentInfo->publishedDate !== null) {
            $generator->startValueElement(
                'publishedDate',
                ($contentInfo->publishedDate !== null
                    ? $contentInfo->publishedDate->format('c')
                    : null)
            );
            $generator->endValueElement('publishedDate');
        }

        $generator->startValueElement(
            'mainLanguageCode',
            $contentInfo->mainLanguageCode
        );
        $generator->endValueElement('mainLanguageCode');

        $generator->startValueElement(
            'currentVersionNo',
            $contentInfo->currentVersionNo
        );
        $generator->endValueElement('currentVersionNo');

        $generator->startValueElement(
            'alwaysAvailable',
            $this->serializeBool($generator, $contentInfo->alwaysAvailable)
        );
        $generator->endValueElement('alwaysAvailable');

        $generator->startValueElement(
            'status',
            $this->getStatusString($contentInfo->status)
        );
        $generator->endValueElement('status');

        $generator->startObjectElement('ObjectStates', 'ContentObjectStates');
        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_getObjectStatesForContent',
                array('contentId' => $contentInfo->id)
            )
        );
        $generator->endAttribute('href');
        $generator->endObjectElement('ObjectStates');

        $generator->endObjectElement('Content');
    }
708522
public function stepCreateRecord($type, $id) {
		$class = $this->convertTypeToClass($type);
		$fields = $this->prepareFixture($class, $id);
		$this->fixtureFactory->createObject($class, $id, $fields);
	}