_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q243800 | MopDescription.loadPaymentSupplementaryData | validation | protected function loadPaymentSupplementaryData(MopInfo $options)
{
foreach ($options->paySupData as $paySupData) {
$this->paymentModule->paymentSupplementaryData[] = new PaymentSupplementaryData(
$paySupData->function,
$paySupData->data
);
}
} | php | {
"resource": ""
} |
q243801 | MopDescription.checkAndCreateMopDetailedData | validation | private function checkAndCreateMopDetailedData($fopType)
{
if (is_null($this->paymentModule->mopDetailedData)) {
$this->paymentModule->mopDetailedData = new MopDetailedData($fopType);
}
} | php | {
"resource": ""
} |
q243802 | OfficeIdentification.loadSpecificChanges | validation | public function loadSpecificChanges($changeTicketing, $changeQueueing, $changeOptQueueEl)
{
if ($changeTicketing) {
$this->specificChanges[] = new SpecificChanges(
SpecificChanges::ACTION_TICKETING_OFFICE
);
}
if ($changeQueueing) {
$this->specificChanges[] = new SpecificChanges(
SpecificChanges::ACTION_QUEUEING_OFFICE
);
}
if ($changeOptQueueEl) {
$this->specificChanges[] = new SpecificChanges(
SpecificChanges::ACTION_OPT_QUEUE_ELEMENT
);
}
} | php | {
"resource": ""
} |
q243803 | Search.loadGeoCode | validation | protected function loadGeoCode(PointOfRefSearchOptions $params)
{
if ($this->checkAllNotEmpty($params->latitude, $params->longitude)) {
$this->porFndQryParams->geoCode = new GeoCode(
$params->longitude,
$params->latitude
);
}
} | php | {
"resource": ""
} |
q243804 | Search.loadBusinessId | validation | protected function loadBusinessId(PointOfRefSearchOptions $params)
{
if ($this->checkAnyNotEmpty($params->businessCategory, $params->businessForeignKey)) {
$this->porFndQryParams->businessId = new BusinessId(
$params->businessCategory,
$params->businessForeignKey
);
}
} | php | {
"resource": ""
} |
q243805 | SomewhatRandomGenerator.generateSomewhatRandomString | validation | public static function generateSomewhatRandomString($length = 22)
{
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
srand((double) microtime() * 1000000);
$i = 0;
$somewhatRandom = '';
while ($i < $length) {
$num = rand() % 60;
$tmp = substr($chars, $num, 1);
$somewhatRandom = $somewhatRandom.$tmp;
$i++;
}
return $somewhatRandom;
} | php | {
"resource": ""
} |
q243806 | HandlerDisplayHistory.analyze | validation | public function analyze(SendResult $response)
{
$analyzeResponse = new Result($response);
$domXpath = $this->makeDomXpath($response->responseXml);
$queryAllErrorCodes = "//m:generalErrorGroup//m:errorNumber/m:errorDetails/m:errorCode";
$queryAllErrorMsg = "//m:generalErrorGroup/m:genrealErrorText/m:freeText";
$errorCodeNodeList = $domXpath->query($queryAllErrorCodes);
if ($errorCodeNodeList->length > 0) {
$analyzeResponse->status = Result::STATUS_ERROR;
$code = $errorCodeNodeList->item(0)->nodeValue;
$errorTextNodeList = $domXpath->query($queryAllErrorMsg);
$message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);
$analyzeResponse->messages[] = new Result\NotOk($code, trim($message));
}
return $analyzeResponse;
} | php | {
"resource": ""
} |
q243807 | WsMessageUtility.checkAnyNotEmpty | validation | protected function checkAnyNotEmpty()
{
$foundNotEmpty = false;
$args = func_get_args();
foreach ($args as $arg) {
if (!empty($arg)) {
$foundNotEmpty = true;
break;
}
}
return $foundNotEmpty;
} | php | {
"resource": ""
} |
q243808 | WsMessageUtility.checkAllNotEmpty | validation | protected function checkAllNotEmpty()
{
$foundEmpty = false;
$args = func_get_args();
foreach ($args as $arg) {
if (empty($arg)) {
$foundEmpty = true;
break;
}
}
return !$foundEmpty;
} | php | {
"resource": ""
} |
q243809 | WsMessageUtility.checkAllIntegers | validation | protected function checkAllIntegers()
{
$foundNonInt = false;
$args = func_get_args();
foreach ($args as $arg) {
if (!is_int($arg)) {
$foundNonInt = true;
break;
}
}
return !$foundNonInt;
} | php | {
"resource": ""
} |
q243810 | WsMessageUtility.checkAnyTrue | validation | protected function checkAnyTrue()
{
$foundTrue = false;
$args = func_get_args();
foreach ($args as $arg) {
if ($arg === true) {
$foundTrue = true;
break;
}
}
return $foundTrue;
} | php | {
"resource": ""
} |
q243811 | HandlerFactory.loadNonceBase | validation | protected static function loadNonceBase($handlerParams)
{
if (empty($handlerParams->authParams->nonceBase)) {
$handlerParams->authParams->nonceBase = SomewhatRandomGenerator::generateSomewhatRandomString();
}
return $handlerParams;
} | php | {
"resource": ""
} |
q243812 | Fop.isValidFopType | validation | public static function isValidFopType($fopType)
{
return ($fopType == self::IDENT_CASH
|| $fopType == self::IDENT_CHECK
|| $fopType == self::IDENT_CREDITCARD
|| $fopType == self::IDENT_MISC);
} | php | {
"resource": ""
} |
q243813 | Params.loadSessionHandler | validation | protected function loadSessionHandler($params)
{
if (isset($params['sessionHandler']) && $params['sessionHandler'] instanceof Session\Handler\HandlerInterface) {
$this->sessionHandler = $params['sessionHandler'];
}
} | php | {
"resource": ""
} |
q243814 | Params.loadAuthParams | validation | protected function loadAuthParams($params)
{
if (isset($params['authParams'])) {
if ($params['authParams'] instanceof AuthParams) {
$this->authParams = $params['authParams'];
} elseif (is_array($params['authParams'])) {
$this->authParams = new AuthParams($params['authParams']);
}
}
} | php | {
"resource": ""
} |
q243815 | Params.loadSessionHandlerParams | validation | protected function loadSessionHandlerParams($params)
{
if (isset($params['sessionHandlerParams'])) {
if ($params['sessionHandlerParams'] instanceof SessionHandlerParams) {
$this->sessionHandlerParams = $params['sessionHandlerParams'];
} elseif (is_array($params['sessionHandlerParams'])) {
$this->sessionHandlerParams = new SessionHandlerParams($params['sessionHandlerParams']);
}
}
} | php | {
"resource": ""
} |
q243816 | Params.loadRequestCreatorParams | validation | protected function loadRequestCreatorParams($params)
{
if (isset($params['requestCreatorParams'])) {
if ($params['requestCreatorParams'] instanceof RequestCreatorParams) {
$this->requestCreatorParams = $params['requestCreatorParams'];
} elseif (is_array($params['requestCreatorParams'])) {
$this->requestCreatorParams = new RequestCreatorParams($params['requestCreatorParams']);
}
}
} | php | {
"resource": ""
} |
q243817 | RepricePnrWithBookingClass.mergeOptions | validation | protected function mergeOptions($existingOptions, $newOptions)
{
if (!empty($newOptions)) {
$existingOptions = array_merge(
$existingOptions,
$newOptions
);
}
return $existingOptions;
} | php | {
"resource": ""
} |
q243818 | RepricePnrWithBookingClass.hasPricingOption | validation | protected function hasPricingOption($optionKey, $priceOptions)
{
$found = false;
foreach ($priceOptions as $pog) {
if ($pog->pricingOptionKey->pricingOptionKey === $optionKey) {
$found = true;
}
}
return $found;
} | php | {
"resource": ""
} |
q243819 | AirAuxItinerary.loadArnk | validation | protected function loadArnk(Segment\ArrivalUnknown $segment)
{
$this->travelProduct = new TravelProduct();
$this->travelProduct->productDetails = new ProductDetails($segment->identification);
$this->messageAction = new MessageAction(Business::FUNC_ARNK);
} | php | {
"resource": ""
} |
q243820 | MasterPricerTravelBoardSearch.loadCustomerRefs | validation | protected function loadCustomerRefs($dkNumber)
{
if (!is_null($dkNumber)) {
$this->customerRef = new MasterPricer\CustomerRef();
$this->customerRef->customerReferences[] = new MasterPricer\CustomerReferences(
$dkNumber,
MasterPricer\CustomerReferences::QUAL_AGENCY_GROUPING_ID
);
}
} | php | {
"resource": ""
} |
q243821 | SessionHandlerParams.loadWsdl | validation | protected function loadWsdl($params)
{
if (isset($params['wsdl'])) {
if (is_string($params['wsdl'])) {
$this->wsdl = [
$params['wsdl']
];
} elseif (is_array($params['wsdl'])) {
$this->wsdl = $params['wsdl'];
}
}
} | php | {
"resource": ""
} |
q243822 | SessionHandlerParams.loadOverrideSoapClient | validation | protected function loadOverrideSoapClient($params)
{
if (isset($params['overrideSoapClient']) && $params['overrideSoapClient'] instanceof \SoapClient) {
$this->overrideSoapClient = $params['overrideSoapClient'];
}
if (isset($params['overrideSoapClientWsdlName'])) {
$this->overrideSoapClientWsdlName = $params['overrideSoapClientWsdlName'];
}
} | php | {
"resource": ""
} |
q243823 | SessionHandlerParams.loadTransactionFlowLink | validation | protected function loadTransactionFlowLink($params)
{
if (isset($params['enableTransactionFlowLink']) && $params['enableTransactionFlowLink'] === true) {
$this->enableTransactionFlowLink = true;
$this->consumerId = (isset($params['consumerId'])) ? $params['consumerId'] : null;
}
} | php | {
"resource": ""
} |
q243824 | SoapHeader2.prepareForNextMessage | validation | protected function prepareForNextMessage($messageName, $messageOptions)
{
if (!$this->isAuthenticated && $messageName !== 'Security_Authenticate') {
throw new InvalidSessionException('No active session');
}
$this->getSoapClient($messageName)->__setSoapHeaders(null);
if ($this->isAuthenticated === true && is_int($this->sessionData['sequenceNumber'])) {
$this->sessionData['sequenceNumber']++;
$session = new Client\Struct\HeaderV2\Session(
$this->sessionData['sessionId'],
$this->sessionData['sequenceNumber'],
$this->sessionData['securityToken']
);
$this->getSoapClient($messageName)->__setSoapHeaders(
new \SoapHeader(self::CORE_WS_V2_SESSION_NS, self::NODENAME_SESSION, $session)
);
}
} | php | {
"resource": ""
} |
q243825 | HandlerNameChange.analyze | validation | public function analyze(SendResult $response)
{
$analyzeResponse = new Result($response);
$domXpath = $this->makeDomXpath($response->responseXml);
$qPassErrors = "//m:passengerErrorInEnhancedData//m:errorDetails/m:errorCode";
$qPassErrorCat = "//m:passengerErrorInEnhancedData//m:errorDetails/m:errorCategory";
$qPassErrorMsg = "//m:passengerErrorInEnhancedData//m:freeText";
$errorCodeNodeList = $domXpath->query($qPassErrors);
if ($errorCodeNodeList->length > 0) {
$analyzeResponse->status = Result::STATUS_ERROR;
$errorCatNode = $domXpath->query($qPassErrorCat)->item(0);
if ($errorCatNode instanceof \DOMNode) {
$analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue);
}
$code = $errorCodeNodeList->item(0)->nodeValue;
$errorTextNodeList = $domXpath->query($qPassErrorMsg);
$message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);
$analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'passenger');
}
if (empty($analyzeResponse->messages) && $analyzeResponse->status === Result::STATUS_OK) {
$analyzeResponse = $this->analyzeSimpleResponseErrorCodeAndMessage($response);
}
return $analyzeResponse;
} | php | {
"resource": ""
} |
q243826 | DisplayTST.loadReferences | validation | protected function loadReferences($params)
{
if ($this->checkAnyNotEmpty($params->passengers, $params->segments)) {
$this->psaInformation = new PsaInformation();
foreach ($params->passengers as $passenger) {
$this->psaInformation->refDetails[] = new RefDetails($passenger, RefDetails::QUAL_PASSENGER);
}
foreach ($params->segments as $segment) {
$this->psaInformation->refDetails[] = new RefDetails($segment, RefDetails::QUAL_SEGMENT_REFERENCE);
}
}
} | php | {
"resource": ""
} |
q243827 | AddMultiElements.loadBare | validation | protected function loadBare(PnrAddMultiElementsOptions $params)
{
$tattooCounter = 0;
if (!is_null($params->actionCode)) {
$this->pnrActions = new AddMultiElements\PnrActions(
$params->actionCode
);
}
if (!is_null($params->recordLocator)) {
$this->reservationInfo = new AddMultiElements\ReservationInfo($params->recordLocator);
}
if ($params->travellerGroup !== null) {
$this->addTravellerGroup($params->travellerGroup);
} else {
$this->addTravellers($params->travellers);
}
$this->addItineraries($params->itineraries, $params->tripSegments, $tattooCounter);
if (!empty($params->elements)) {
$this->addElements(
$params->elements,
$tattooCounter,
$params->autoAddReceivedFrom,
$params->defaultReceivedFrom,
$params->receivedFrom
);
} else {
$this->addReceivedFrom(
$params->receivedFrom,
$params->autoAddReceivedFrom,
$params->defaultReceivedFrom,
$tattooCounter
);
}
} | php | {
"resource": ""
} |
q243828 | AddMultiElements.loadCreatePnr | validation | protected function loadCreatePnr(PnrCreatePnrOptions $params)
{
$this->pnrActions = new AddMultiElements\PnrActions(
$params->actionCode
);
$tattooCounter = 0;
if ($params->travellerGroup !== null) {
$this->addTravellerGroup($params->travellerGroup);
} else {
$this->addTravellers($params->travellers);
}
$this->addItineraries($params->itineraries, $params->tripSegments, $tattooCounter);
$this->addElements(
$params->elements,
$tattooCounter,
$params->autoAddReceivedFrom,
$params->defaultReceivedFrom,
$params->receivedFrom
);
} | php | {
"resource": ""
} |
q243829 | AddMultiElements.addItineraries | validation | protected function addItineraries($itineraries, $legacySegments, &$tattooCounter)
{
if (!empty($legacySegments)) {
$this->addSegments($legacySegments, $tattooCounter);
}
foreach ($itineraries as $itinerary) {
$this->addSegments(
$itinerary->segments,
$tattooCounter,
$itinerary->origin,
$itinerary->destination
);
}
} | php | {
"resource": ""
} |
q243830 | AddMultiElements.addReceivedFrom | validation | protected function addReceivedFrom($explicitRf, $doAutoAdd, $defaultRf, &$tattooCounter)
{
if ($this->dataElementsMaster === null) {
$this->dataElementsMaster = new DataElementsMaster();
}
if (!empty($explicitRf) || ($doAutoAdd && !empty($defaultRf))) {
//Set a received from if explicitly provided or if auto received from is enabled
$tattooCounter++;
$rfToAdd = (!empty($explicitRf)) ? $explicitRf : $defaultRf;
$this->dataElementsMaster->dataElementsIndiv[] = $this->createElement(
new ReceivedFrom(['receivedFrom' => $rfToAdd]),
$tattooCounter
);
}
} | php | {
"resource": ""
} |
q243831 | FlightDate.setArrivalDate | validation | public function setArrivalDate(\DateTime $arrivalDate)
{
$this->arrivalDate = ($arrivalDate->format('dmy') !== '000000') ? $arrivalDate->format('dmy') : null;
$time = $arrivalDate->format('Hi');
if ($time !== '0000') {
$this->arrivalTime = $time;
}
} | php | {
"resource": ""
} |
q243832 | PaymentModule.loadPaymentData | validation | public function loadPaymentData(MopInfo $options)
{
if ($this->checkAnyNotEmpty(
$options->payMerchant,
$options->transactionDate,
$options->payments,
$options->installmentsInfo,
$options->fraudScreening,
$options->payIds
)) {
$this->paymentData = new PaymentData(
$options->payMerchant,
$options->transactionDate,
$options->payments,
$options->installmentsInfo,
$options->fraudScreening,
$options->payIds
);
}
} | php | {
"resource": ""
} |
q243833 | Factory.createRequestCreator | validation | public static function createRequestCreator($params, $libIdentifier)
{
$params->receivedFrom = self::makeReceivedFrom(
$params->receivedFrom,
$libIdentifier
);
$theRequestCreator = new Base($params);
return $theRequestCreator;
} | php | {
"resource": ""
} |
q243834 | FareOptions.loadFeeIds | validation | protected function loadFeeIds($feeIds)
{
if (is_null($this->feeIdDescription)) {
$this->feeIdDescription = new FeeIdDescription();
}
foreach ($feeIds as $feeId) {
$this->feeIdDescription->feeId[] = new FeeId($feeId->type, $feeId->number);
}
} | php | {
"resource": ""
} |
q243835 | FareOptions.loadCurrencyOverride | validation | protected function loadCurrencyOverride($currency)
{
if (is_string($currency) && strlen($currency) === 3) {
$this->addPriceType(PricingTicketing::PRICETYPE_OVERRIDE_CURRENCY_CONVERSION);
$this->conversionRate = new ConversionRate($currency);
}
} | php | {
"resource": ""
} |
q243836 | HandlerRetrieveSeatMap.findMessage | validation | public static function findMessage($code)
{
$message = null;
if (array_key_exists($code, self::$errorList)) {
$message = self::$errorList[$code];
}
return $message;
} | php | {
"resource": ""
} |
q243837 | HandlerRetrieveSeatMap.decodeProcessingLevel | validation | public static function decodeProcessingLevel($level)
{
$decoded = null;
$map = [
0 => 'system',
1 => 'application'
];
if (array_key_exists($level, $map)) {
$decoded = $map[$level];
}
return $decoded;
} | php | {
"resource": ""
} |
q243838 | AbstractLexer.isNextTokenAny | validation | public function isNextTokenAny(array $tokens)
{
return null !== $this->lookahead && in_array($this->lookahead['type'], $tokens, true);
} | php | {
"resource": ""
} |
q243839 | AbstractLexer.moveNext | validation | public function moveNext()
{
$this->peek = 0;
$this->token = $this->lookahead;
$this->lookahead = (isset($this->tokens[$this->position]))
? $this->tokens[$this->position++] : null;
return $this->lookahead !== null;
} | php | {
"resource": ""
} |
q243840 | AbstractLexer.skipUntil | validation | public function skipUntil($type)
{
while ($this->lookahead !== null && $this->lookahead['type'] !== $type) {
$this->moveNext();
}
} | php | {
"resource": ""
} |
q243841 | AbstractLexer.peek | validation | public function peek()
{
if (isset($this->tokens[$this->position + $this->peek])) {
return $this->tokens[$this->position + $this->peek++];
} else {
return null;
}
} | php | {
"resource": ""
} |
q243842 | AbstractLexer.getLiteral | validation | public function getLiteral($token)
{
$className = get_class($this);
$reflClass = new \ReflectionClass($className);
$constants = $reflClass->getConstants();
foreach ($constants as $name => $value) {
if ($value === $token) {
return $className . '::' . $name;
}
}
return $token;
} | php | {
"resource": ""
} |
q243843 | CheckAuthDictionary.execute | validation | public function execute()
{
$result = $this->resultJsonFactory->create();
try {
$activeVersion = $this->getRequest()->getParam('active_version');
$dictionaryName = Config::AUTH_DICTIONARY_NAME;
$dictionary = $this->api->getSingleDictionary($activeVersion, $dictionaryName);
if ((is_array($dictionary) && empty($dictionary)) || $dictionary == false) {
return $result->setData(['status' => false]);
} else {
return $result->setData(['status' => true]);
}
} catch (\Exception $e) {
return $result->setData([
'status' => false,
'msg' => $e->getMessage()
]);
}
} | php | {
"resource": ""
} |
q243844 | CheckSuSetting.execute | validation | public function execute()
{
$result = $this->resultJsonFactory->create();
try {
$service = $this->api->checkServiceDetails();
$currActiveVersion = $this->vcl->getCurrentVersion($service->versions);
$dictionaryName = Config::CONFIG_DICTIONARY_NAME;
$dictionary = $this->api->getSingleDictionary($currActiveVersion, $dictionaryName);
if (!$dictionary) {
return $result->setData([
'status' => false
]);
}
$dictionaryItems = $this->api->dictionaryItemsList($dictionary->id);
foreach ($dictionaryItems as $item) {
if ($item->item_key == Config::CONFIG_DICTIONARY_KEY && $item->item_value == 1) {
return $result->setData([
'status' => true
]);
}
}
return $result->setData([
'status' => false
]);
} catch (\Exception $e) {
return $result->setData([
'status' => false,
'msg' => $e->getMessage()
]);
}
} | php | {
"resource": ""
} |
q243845 | WafAllowlist.execute | validation | public function execute()
{
$result = $this->resultJson->create();
try {
$activeVersion = $this->getRequest()->getParam('active_version');
$activateVcl = $this->getRequest()->getParam('activate_flag');
$service = $this->api->checkServiceDetails();
$this->vcl->checkCurrentVersionActive($service->versions, $activeVersion);
$currActiveVersion = $this->vcl->getCurrentVersion($service->versions);
$clone = $this->api->cloneVersion($currActiveVersion);
$checkIfSettingExists = $this->api->hasSnippet($activeVersion, Config::WAF_SETTING_NAME);
$snippet = $this->config->getVclSnippets(
Config::VCL_WAF_PATH,
Config::VCL_WAF_ALLOWLIST_SNIPPET
);
$acls = $this->prepareAcls($this->config->getWafAllowByAcl());
$allowedItems = $acls;
$strippedAllowedItems = substr($allowedItems, 0, strrpos($allowedItems, '||', -1));
if (!$checkIfSettingExists) {
// Add WAF allowlist snippet
foreach ($snippet as $key => $value) {
if ($strippedAllowedItems === '') {
$value = '';
} else {
$value = str_replace('####WAF_ALLOWLIST####', $strippedAllowedItems, $value);
}
$snippetData = [
'name' => Config::FASTLY_MAGENTO_MODULE . '_waf_' . $key,
'type' => $key,
'dynamic' => 1,
'priority' => 10,
'content' => $value
];
$this->api->uploadSnippet($clone->number, $snippetData);
}
} else {
// Remove WAF allowlist snippet
foreach ($snippet as $key => $value) {
$name = Config::FASTLY_MAGENTO_MODULE . '_waf_' . $key;
if ($this->api->hasSnippet($clone->number, $name) == true) {
$this->api->removeSnippet($clone->number, $name);
}
}
}
$this->api->validateServiceVersion($clone->number);
if ($activateVcl === 'true') {
$this->api->activateVersion($clone->number);
}
$this->sendWebhook($checkIfSettingExists, $clone);
$comment = ['comment' => 'Magento Module turned ON WAF ACL Bypass'];
if ($checkIfSettingExists) {
$comment = ['comment' => 'Magento Module turned OFF WAF ACL Bypass'];
}
$this->api->addComment($clone->number, $comment);
return $result->setData([
'status' => true
]);
} catch (\Exception $e) {
return $result->setData([
'status' => false,
'msg' => $e->getMessage()
]);
}
} | php | {
"resource": ""
} |
q243846 | ResponsePlugin.aroundSetHeader | validation | public function aroundSetHeader(Http $subject, callable $proceed, ...$args) // @codingStandardsIgnoreLine - unused parameter
{
// Is Fastly cache enabled?
if ($this->config->getType() !== Config::FASTLY) {
return $proceed(...$args);
}
// Is current header X-Magento-Tags
if (isset($args[0]) == true && $args[0] !== 'X-Magento-Tags') {
return $proceed(...$args);
}
// Make the necessary adjustment
$args[1] = $this->cacheTags->convertCacheTags(str_replace(',', ' ', $args[1]));
$tagsSize = $this->config->getXMagentoTagsSize();
if (strlen($args[1]) > $tagsSize) {
$trimmedArgs = substr($args[1], 0, $tagsSize);
$args[1] = substr($trimmedArgs, 0, strrpos($trimmedArgs, ' ', -1));
}
// Proceed
return $proceed(...$args);
} | php | {
"resource": ""
} |
q243847 | Delete.execute | validation | public function execute()
{
$result = $this->resultJson->create();
try {
$aclId = $this->getRequest()->getParam('acl_id');
$aclItemId = $this->getRequest()->getParam('acl_item_id');
$deleteItem = $this->api->deleteAclItem($aclId, $aclItemId);
if (!$deleteItem) {
return $result->setData(['status' => false]);
}
return $result->setData(['status' => true]);
} catch (\Exception $e) {
return $result->setData([
'status' => false,
'msg' => $e->getMessage()
]);
}
} | php | {
"resource": ""
} |
q243848 | ListAll.execute | validation | public function execute()
{
$result = $this->resultJson->create();
try {
$activeVersion = $this->getRequest()->getParam('active_version');
$ioOptions = $this->api->getImageOptimizationDefaultConfigOptions($activeVersion)->data->attributes;
if (!$ioOptions) {
return $result->setData([
'status' => false,
'msg' => 'Failed to fetch image optimization default config options.'
]);
}
return $result->setData([
'status' => true,
'io_options' => $ioOptions
]);
} catch (\Exception $e) {
return $result->setData([
'status' => false,
'msg' => $e->getMessage()
]);
}
} | php | {
"resource": ""
} |
q243849 | Vcl.getCurrentVersion | validation | public function getCurrentVersion(array $versions)
{
if (!empty($versions)) {
foreach ($versions as $version) {
if ($version->active) {
return $activeVersion = $version->number;
}
}
}
throw new LocalizedException(__('Error fetching current version.'));
} | php | {
"resource": ""
} |
q243850 | Vcl.getNextVersion | validation | public function getNextVersion(array $versions)
{
if (isset(end($versions)->number)) {
return (int) end($versions)->number + 1;
}
throw new LocalizedException(__('Error fetching next version.'));
} | php | {
"resource": ""
} |
q243851 | Vcl.determineVersions | validation | public function determineVersions(array $versions)
{
$activeVersion = null;
$nextVersion = null;
if (!empty($versions)) {
foreach ($versions as $version) {
if ($version->active) {
$activeVersion = $version->number;
}
}
$nextVersion = (int) end($versions)->number + 1;
}
return [
'active_version' => $activeVersion,
'next_version' => $nextVersion
];
} | php | {
"resource": ""
} |
q243852 | Vcl.getActiveVersion | validation | public function getActiveVersion($service, $activeVersion)
{
$currActiveVersion = $this->determineVersions($service->versions);
if ($currActiveVersion['active_version'] != $activeVersion) {
throw new LocalizedException(__('Active versions mismatch.'));
}
return $currActiveVersion;
} | php | {
"resource": ""
} |
q243853 | Create.execute | validation | public function execute()
{
$result = $this->resultJson->create();
try {
$activeVersion = $this->getRequest()->getParam('active_version');
$dictionary = $this->api->getAuthDictionary($activeVersion);
if ((is_array($dictionary) && empty($dictionary)) || !isset($dictionary->id)) {
return $result->setData([
'status' => 'empty',
'msg' => 'Authentication dictionary does not exist.'
]);
}
$user = $this->getRequest()->getParam('auth_user');
$pass = $this->getRequest()->getParam('auth_pass');
$key = base64_encode($user . ':' . $pass);
$this->api->upsertDictionaryItem($dictionary->id, $key, true);
return $result->setData(['status' => true]);
} catch (\Exception $e) {
return $result->setData([
'status' => false,
'msg' => $e->getMessage()
]);
}
} | php | {
"resource": ""
} |
q243854 | Statistic.prepareGAReqData | validation | private function prepareGAReqData()
{
if (!empty($this->GAReqData)) {
return $this->GAReqData;
}
$mandatoryReqData = [];
$mandatoryReqData['v'] = 1;
// Tracking ID
$mandatoryReqData['tid'] = $this->getGATrackingId();
$cid = $this->config->getCID();
$mandatoryReqData['cid'] = $cid;
$mandatoryReqData['uid'] = $cid;
// Magento version
$mandatoryReqData['ua'] = $this->metaData->getVersion();
// Get Default Country
$mandatoryReqData['geoid'] = $this->getCountry();
// Data Source parameter is used to filter spam hits
$mandatoryReqData['ds'] = 'Fastly';
$customVars = $this->prepareCustomVariables();
$this->GAReqData = array_merge($mandatoryReqData, $customVars);
return $this->GAReqData;
} | php | {
"resource": ""
} |
q243855 | Statistic.getWebsiteName | validation | public function getWebsiteName()
{
$websites = $this->storeManager->getWebsites();
$websiteName = 'Not set.';
foreach ($websites as $website) {
if ($website->getIsDefault()) {
$websiteName = $website->getName();
}
}
return $websiteName;
} | php | {
"resource": ""
} |
q243856 | Statistic.isApiKeyValid | validation | public function isApiKeyValid()
{
try {
$apiKey = $this->scopeConfig->getValue(Config::XML_FASTLY_API_KEY);
$serviceId = $this->scopeConfig->getValue(Config::XML_FASTLY_SERVICE_ID);
$isApiKeyValid = $this->api->checkServiceDetails(true, $serviceId, $apiKey);
} catch (\Exception $e) {
return false;
}
return (bool)$isApiKeyValid;
} | php | {
"resource": ""
} |
q243857 | Statistic.prepareCustomVariables | validation | private function prepareCustomVariables()
{
if ($this->validationServiceId != null) {
$serviceId = $this->validationServiceId;
} else {
$serviceId = $this->scopeConfig->getValue(Config::XML_FASTLY_SERVICE_ID);
}
$customVars = [
// Service ID
'cd1' => $serviceId,
// isAPIKeyValid
'cd2' => ($this->isApiKeyValid()) ? 'yes' : 'no',
// Website name
'cd3' => $this->getWebsiteName(),
// Site domain
'cd4' => $this->request->getServer('HTTP_HOST'),
// Site location
'cd5' => $this->getSiteLocation(),
// Fastly module version
'cd6' => $this->helper->getModuleVersion(),
// Fastly CID
'cd7' => $this->config->getCID(),
// Anti spam protection
'cd8' => 'fastlyext'
];
return $customVars;
} | php | {
"resource": ""
} |
q243858 | Statistic.getCountry | validation | public function getCountry()
{
$countryCode = $this->scopeConfig->getValue('general/country/default');
if (!$countryCode) {
return null;
}
$country = $this->countryFactory->create()->loadByCode($countryCode);
return $country->getName();
} | php | {
"resource": ""
} |
q243859 | Statistic.getSiteLocation | validation | public function getSiteLocation()
{
$countryId = $this->scopeConfig->getValue('general/store_information/country_id');
if ($countryId) {
$country = $this->countryFactory->create()->loadByCode($countryId);
$countryName = $country->getName();
} else {
$countryName = 'Unknown country';
}
$regionId = $this->scopeConfig->getValue('general/store_information/region_id');
$regionName = 'Unknown region';
if ($regionId) {
$region = $this->regionFactory->create();
$region = $region->load($regionId);
if ($region->getId()) {
$regionName = $region->getName();
}
}
$postCode = $this->scopeConfig->getValue('general/store_information/postcode');
if (!$postCode) {
$postCode = 'Unknown zip code';
}
return $countryName .' | '.$regionName.' | '.$postCode;
} | php | {
"resource": ""
} |
q243860 | Statistic.generateCid | validation | public function generateCid()
{
return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
/* 32 bits for time_low */
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
/* 16 bits for time_mid */
mt_rand(0, 0xffff),
/* 16 bits for time_hi_and_version,
four most significant bits holds version number 4 */
mt_rand(0, 0x0fff) | 0x4000,
/* 16 bits, 8 bits for clk_seq_hi_res,
8 bits for clk_seq_low,
two most significant bits holds zero and one for variant DCE1.1 */
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for node
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff)
);
} | php | {
"resource": ""
} |
q243861 | Statistic.sendInstalledReq | validation | public function sendInstalledReq()
{
$pageViewParams = [
'dl' => self::GA_PAGEVIEW_URL . self::FASTLY_INSTALLED_FLAG,
'dh' => preg_replace('#^https?://#', '', rtrim(self::GA_PAGEVIEW_URL, '/')),
'dp' => '/'.self::FASTLY_INSTALLED_FLAG,
'dt' => ucfirst(self::FASTLY_INSTALLED_FLAG),
't' => self::GA_HITTYPE_PAGEVIEW,
];
$this->sendReqToGA($pageViewParams, self::GA_HITTYPE_PAGEVIEW);
$eventParams = [
'ec' => self::GA_FASTLY_SETUP,
'ea' => 'Fastly '.self::FASTLY_INSTALLED_FLAG,
'el' => $this->getWebsiteName(),
'ev' => 0,
't' => self::GA_HITTYPE_EVENT
];
$result = $this->sendReqToGA(array_merge($pageViewParams, $eventParams));
return $result;
} | php | {
"resource": ""
} |
q243862 | Statistic.sendValidationRequest | validation | public function sendValidationRequest($validatedFlag, $serviceId = null)
{
if ($serviceId != null) {
$this->validationServiceId = $serviceId;
}
if ($validatedFlag) {
$validationState = self::FASTLY_VALIDATED_FLAG;
} else {
$validationState = self::FASTLY_NON_VALIDATED_FLAG;
}
$pageViewParams = [
'dl' => self::GA_PAGEVIEW_URL . $validationState,
'dh' => preg_replace('#^https?://#', '', rtrim(self::GA_PAGEVIEW_URL, '/')),
'dp' => '/'.$validationState,
'dt' => ucfirst($validationState),
't' => self::GA_HITTYPE_PAGEVIEW,
];
$this->sendReqToGA($pageViewParams);
$eventParams = [
'ec' => self::GA_FASTLY_SETUP,
'ea' => 'Fastly '.$validationState,
'el' => $this->getWebsiteName(),
'ev' => $this->daysFromInstallation(),
't' => self::GA_HITTYPE_EVENT
];
$result = $this->sendReqToGA(array_merge($pageViewParams, $eventParams));
return $result;
} | php | {
"resource": ""
} |
q243863 | Statistic.sendConfigurationRequest | validation | public function sendConfigurationRequest($configuredFlag)
{
if ($configuredFlag) {
$configuredState = self::FASTLY_CONFIGURED_FLAG;
} else {
$configuredState = self::FASTLY_NOT_CONFIGURED_FLAG;
}
$pageViewParams = [
'dl' => self::GA_PAGEVIEW_URL . $configuredState,
'dh' => preg_replace('#^https?://#', '', rtrim(self::GA_PAGEVIEW_URL, '/')),
'dp' => '/'.$configuredState,
'dt' => ucfirst($configuredState),
't' => self::GA_HITTYPE_PAGEVIEW,
];
$this->sendReqToGA($pageViewParams);
$eventParams = [
'ec' => self::GA_FASTLY_SETUP,
'ea' => 'Fastly '.$configuredState,
'el' => $this->getWebsiteName(),
'ev' => $this->daysFromInstallation(),
't' => self::GA_HITTYPE_EVENT
];
$result = $this->sendReqToGA(array_merge($pageViewParams, $eventParams));
return $result;
} | php | {
"resource": ""
} |
q243864 | Statistic.daysFromInstallation | validation | public function daysFromInstallation()
{
$stat = $this->statisticRepository->getStatByAction(self::FASTLY_INSTALLED_FLAG);
if (!$stat->getCreatedAt()) {
return null;
}
$installDate = date_create($stat->getCreatedAt());
$currentDate = date_create($this->dateTime->gmtDate());
$dateDiff = date_diff($installDate, $currentDate);
return $dateDiff->days;
} | php | {
"resource": ""
} |
q243865 | Statistic.sendReqToGA | validation | private function sendReqToGA($body = '', $method = \Zend_Http_Client::POST, $uri = self::GA_API_ENDPOINT)
{
$reqGAData = (array)$this->getGAReqData();
if ($body != '' && is_array($body) && !empty($body)) {
$body = array_merge($reqGAData, $body);
}
try {
$client = $this->curlFactory->create();
$client->addOption(CURLOPT_TIMEOUT, 10);
$client->write($method, $uri, '1.1', null, http_build_query($body));
$response = $client->read();
$responseCode = \Zend_Http_Response::extractCode($response);
$client->close();
if ($responseCode != '200') {
throw new LocalizedException(__('Return status ' . $responseCode));
}
return true;
} catch (\Exception $e) {
return false;
}
} | php | {
"resource": ""
} |
q243866 | GetAction._toHtml | validation | protected function _toHtml() // @codingStandardsIgnoreLine - required by parent class
{
if ($this->config->isGeoIpEnabled() == false || $this->config->isFastlyEnabled() == false) {
return parent::_toHtml();
}
/** @var string $actionUrl */
$actionUrl = $this->getUrl('fastlyCdn/geoip/getaction');
// This page has an esi tag, set x-esi header if it is not already set
$header = $this->response->getHeader('x-esi');
if (empty($header)) {
$this->response->setHeader("x-esi", "1");
}
// HTTPS ESIs are not supported so we need to turn them into HTTP
return sprintf(
'<esi:include src=\'%s\' />',
preg_replace("/^https/", "http", $actionUrl)
);
} | php | {
"resource": ""
} |
q243867 | Acl._construct | validation | protected function _construct() // @codingStandardsIgnoreLine - required by parent class
{
$this->addColumn('backend_name', ['label' => __('Name')]);
$this->_addAfter = false;
$this->_template = 'Fastly_Cdn::system/config/form/field/acl.phtml';
parent::_construct();
} | php | {
"resource": ""
} |
q243868 | Acl.renderCellTemplate | validation | public function renderCellTemplate($columnName)
{
if ($columnName == 'store_id' && isset($this->_columns[$columnName])) {
$options = $this->getOptions(__('-- Select Store --'));
$element = $this->elementFactory->create('select');
$element->setForm(
$this->getForm()
)->setName(
$this->_getCellInputElementName($columnName)
)->setHtmlId(
$this->_getCellInputElementId('<%- _id %>', $columnName)
)->setValues(
$options
);
return str_replace("\n", '', $element->getElementHtml());
}
return parent::renderCellTemplate($columnName);
} | php | {
"resource": ""
} |
q243869 | Acl.getOptions | validation | protected function getOptions($label = false) // @codingStandardsIgnoreLine - required by parent class
{
$options = [];
foreach ($this->_storeManager->getStores() as $store) {
$options[] = [
'value' => $store->getId(),
'label' => $store->getName()
];
}
if ($label) {
array_unshift($options, [
'value' => '',
'label' => $label
]);
}
return $options;
} | php | {
"resource": ""
} |
q243870 | Delete.execute | validation | public function execute()
{
$result = $this->resultJson->create();
try {
$dictionaryId = $this->getRequest()->getParam('dictionary_id');
$key = $this->getRequest()->getParam('item_key');
if ($key == '') {
return $result->setData(['status' => true]);
}
$deleteItem = $this->api->deleteDictionaryItem($dictionaryId, $key);
if (!$deleteItem) {
return $result->setData(['status' => false]);
}
return $result->setData(['status' => true]);
} catch (\Exception $e) {
return $result->setData([
'status' => false,
'msg' => $e->getMessage()
]);
}
} | php | {
"resource": ""
} |
q243871 | Create.execute | validation | public function execute()
{
$result = $this->resultJson->create();
try {
$aclId = $this->getRequest()->getParam('acl_id');
$value = $this->getRequest()->getParam('item_value');
$comment = $this->getRequest()->getParam('comment_value');
$negated = 0;
if ($value[0] == '!') {
$negated = 1;
$value = ltrim($value, '!');
}
// Handle subnet
$ipParts = explode('/', $value);
$subnet = false;
if (!empty($ipParts[1])) {
if (is_numeric($ipParts[1]) && (int)$ipParts[1] < 129) {
$subnet = $ipParts[1];
} else {
return $result->setData([
'status' => false,
'msg' => 'Invalid IP subnet format.'
]);
}
}
if (!filter_var($ipParts[0], FILTER_VALIDATE_IP)) {
return $result->setData([
'status' => false,
'msg' => 'Invalid IP address format.'
]);
}
$createAclItem = $this->api->upsertAclItem($aclId, $ipParts[0], $negated, $comment, $subnet);
if (!$createAclItem) {
return $result->setData([
'status' => false,
'msg' => 'Failed to create Acl entry.'
]);
}
return $result->setData([
'status' => true,
'id' => $createAclItem->id,
'comment' => $createAclItem->comment,
'created_at' => $createAclItem->created_at
]);
} catch (\Exception $e) {
return $result->setData([
'status' => false,
'msg' => $e->getMessage()
]);
}
} | php | {
"resource": ""
} |
q243872 | GetCustomSnippets.execute | validation | public function execute()
{
$result = $this->resultJson->create();
try {
$read = $this->filesystem->getDirectoryRead(DirectoryList::VAR_DIR);
$snippetPath = $read->getRelativePath('vcl_snippets_custom');
$customSnippets = $read->read($snippetPath);
if (!$customSnippets) {
return $result->setData([
'status' => false,
'msg' => 'No snippets found.'
]);
}
$snippets = [];
foreach ($customSnippets as $snippet) {
$snippets[] = explode('/', $snippet)[1];
}
return $result->setData([
'status' => true,
'snippets' => $snippets
]);
} catch (\Exception $e) {
return $result->setData([
'status' => false,
'msg' => $e->getMessage()
]);
}
} | php | {
"resource": ""
} |
q243873 | PurgeCache.sendPurgeRequest | validation | public function sendPurgeRequest($pattern = '')
{
if (empty($pattern)) {
if ($this->config->canPreserveStatic()) {
$result = $this->api->cleanBySurrogateKey(['text']);
} else {
$result = $this->api->cleanAll();
}
} elseif (!is_array($pattern) && strpos($pattern, 'http') === 0) {
$result = $this->api->cleanUrl($pattern);
} elseif (is_array($pattern)) {
$result = $this->api->cleanBySurrogateKey($pattern);
} else {
return false;
}
return $result;
} | php | {
"resource": ""
} |
q243874 | Historic.execute | validation | public function execute()
{
$output = $this->layoutFactory->create()
->createBlock('Fastly\Cdn\Block\Dashboard\Tab\Stats\Historic')
->toHtml();
$resultRaw = $this->resultRawFactory->create();
return $resultRaw->setContents($output);
} | php | {
"resource": ""
} |
q243875 | DeleteCustomSnippet.execute | validation | public function execute()
{
$result = $this->resultJson->create();
try {
$activeVersion = $this->getRequest()->getParam('active_version');
$snippet = $this->getRequest()->getParam('snippet_id');
$activateVcl = $this->getRequest()->getParam('activate_flag');
$service = $this->api->checkServiceDetails();
$this->vcl->checkCurrentVersionActive($service->versions, $activeVersion);
$currActiveVersion = $this->vcl->getCurrentVersion($service->versions);
$write = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
$snippetPath = $write->getRelativePath(Config::CUSTOM_SNIPPET_PATH . $snippet);
$snippetName = explode('_', $snippet);
$snippetName = explode('.', $snippetName[2]);
$reqName = Config::FASTLY_MAGENTO_MODULE . '_' . $snippetName[0];
$checkIfSnippetExist = $this->api->hasSnippet($activeVersion, $reqName);
if ($checkIfSnippetExist) {
$clone = $this->api->cloneVersion($currActiveVersion);
$this->api->removeSnippet($clone->number, $reqName);
$this->api->validateServiceVersion($clone->number);
if ($activateVcl === 'true') {
$this->api->activateVersion($clone->number);
}
$comment = ['comment' => 'Magento Module deleted the ' . $reqName . ' custom snippet.'];
$this->api->addComment($clone->number, $comment);
}
if ($write->isExist($snippetPath)) {
$write->delete($snippetPath);
}
return $result->setData([
'status' => true
]);
} catch (\Exception $e) {
return $result->setData([
'status' => false,
'msg' => $e->getMessage()
]);
}
} | php | {
"resource": ""
} |
q243876 | Notification.checkUpdate | validation | public function checkUpdate($currentVersion = null)
{
$lastVersion = $this->getLastVersion();
if (!$lastVersion || version_compare($lastVersion, $currentVersion, '<=')) {
return;
}
$versionPath = Config::XML_FASTLY_LAST_CHECKED_ISSUED_VERSION;
$oldValue = $this->scopeConfig->getValue($versionPath);
if (version_compare($oldValue, $lastVersion, '<')) {
$this->configWriter->save($versionPath, $lastVersion);
// save last version in db, and notify only if newly fetched last version is greater than stored version
$inboxFactory = $this->_inboxFactory;
$inbox = $inboxFactory->create();
$inbox->addNotice(
'Fastly CDN',
"Version $lastVersion is available. You are currently running $currentVersion."
. ' Please consider upgrading at your earliest convenience.'
);
$this->cacheManager->clean([\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER]);
}
} | php | {
"resource": ""
} |
q243877 | Notification.getLastVersion | validation | public function getLastVersion()
{
try {
$url = self::CHECK_VERSION_URL;
$client = $this->curlFactory->create();
$client->write(\Zend_Http_Client::GET, $url, '1.1');
$responseBody = $client->read();
$client->close();
$responseCode = \Zend_Http_Response::extractCode($responseBody);
if ($responseCode !== 200) {
return false;
}
$body = \Zend_Http_Response::extractBody($responseBody);
$json = json_decode($body);
$version = !empty($json->version) ? $json->version : false;
return $version;
} catch (\Exception $e) {
$this->_logger->log(100, $e->getMessage().$url);
return false;
}
} | php | {
"resource": ""
} |
q243878 | Create.execute | validation | public function execute()
{
$result = $this->resultJson->create();
try {
$dictionaryId = $this->getRequest()->getParam('dictionary_id');
$value = $this->getRequest()->getParam('item_value');
$key = $this->getRequest()->getParam('item_key');
$this->api->upsertDictionaryItem($dictionaryId, $key, $value);
return $result->setData(['status' => true]);
} catch (\Exception $e) {
return $result->setData([
'status' => false,
'msg' => $e->getMessage()
]);
}
} | php | {
"resource": ""
} |
q243879 | ListAll.execute | validation | public function execute()
{
$result = $this->resultJson->create();
try {
$aclId = $this->getRequest()->getParam('acl_id');
$aclItems = $this->api->aclItemsList($aclId);
if (is_array($aclItems) && empty($aclItems)) {
return $result->setData([
'status' => 'empty',
'aclItems' => []
]);
}
if (!$aclItems) {
return $result->setData([
'status' => false,
'msg' => 'Failed to fetch acl items.'
]);
}
return $result->setData([
'status' => true,
'aclItems' => $aclItems
]);
} catch (\Exception $e) {
return $result->setData([
'status' => false,
'msg' => $e->getMessage()
]);
}
} | php | {
"resource": ""
} |
q243880 | StructurePlugin.aroundGetElementByPathParts | validation | public function aroundGetElementByPathParts(\Closure $proceed, array $pathParts)
{
/** @var Section $result */
$result = $proceed($pathParts);
if ($this->isLoaded == true || false) {
return $result;
}
if (($result instanceof Section) == false) {
return $result;
}
if (isset($pathParts[0]) == false || $pathParts[0] != 'system') {
return $result;
}
$this->isLoaded = true;
$data = $result->getData();
if (isset($data['children']['full_page_cache']['children']['fastly_edge_modules']['children']) == false) {
return $result;
}
$original = $data['children']['full_page_cache']['children']['fastly_edge_modules']['children'];
$data['children']['full_page_cache']['children']['fastly_edge_modules']['children'] = array_merge(
$original,
$this->loadModlyData()
);
$result->setData(
$data,
$this->scopeDefiner->getScope()
);
return $result;
} | php | {
"resource": ""
} |
q243881 | Api.cleanUrl | validation | public function cleanUrl($url)
{
$result = $this->_purge($url, 'PURGE', 'PURGE');
if ($result['status']) {
$this->logger->execute($url);
}
if ($this->config->areWebHooksEnabled() && $this->config->canPublishKeyUrlChanges()) {
$this->sendWebHook('*clean by URL for* ' . $url);
}
return $result;
} | php | {
"resource": ""
} |
q243882 | Api.cleanBySurrogateKey | validation | public function cleanBySurrogateKey($keys)
{
$type = 'clean by key on ';
$uri = $this->_getApiServiceUri() . 'purge';
$num = count($keys);
$result = false;
if ($num >= self::FASTLY_MAX_HEADER_KEY_SIZE) {
$parts = $num / self::FASTLY_MAX_HEADER_KEY_SIZE;
$additional = ($parts > (int)$parts) ? 1 : 0;
$parts = (int)$parts + (int)$additional;
$chunks = ceil($num/$parts);
$collection = array_chunk($keys, $chunks);
} else {
$collection = [$keys];
}
foreach ($collection as $keys) {
$payload = json_encode(['surrogate_keys' => $keys]);
$result = $this->_purge($uri, null, \Zend_Http_Client::POST, $payload);
if ($result['status']) {
foreach ($keys as $key) {
$this->logger->execute('surrogate key: ' . $key);
}
}
$canPublishKeyUrlChanges = $this->config->canPublishKeyUrlChanges();
$canPublishPurgeChanges = $this->config->canPublishPurgeChanges();
if ($this->config->areWebHooksEnabled() && ($canPublishKeyUrlChanges || $canPublishPurgeChanges)) {
$status = $result['status'] ? '' : 'FAILED ';
$this->sendWebHook($status . '*clean by key on ' . join(" ", $keys) . '*');
$canPublishPurgeByKeyDebugBacktrace = $this->config->canPublishPurgeByKeyDebugBacktrace();
$canPublishPurgeDebugBacktrace = $this->config->canPublishPurgeDebugBacktrace();
if ($canPublishPurgeByKeyDebugBacktrace == false && $canPublishPurgeDebugBacktrace == false) {
return $result['status'];
}
$this->stackTrace($type . join(" ", $keys));
}
}
return $result['status'];
} | php | {
"resource": ""
} |
q243883 | Api.cleanAll | validation | public function cleanAll()
{
// Check if purge has been requested on this request
if ($this->purged == true) {
return true;
}
$this->purged = true;
$type = 'clean/purge all';
$uri = $this->_getApiServiceUri() . 'purge_all';
$result = $this->_purge($uri, null);
if ($result['status']) {
$this->logger->execute('clean all items');
}
$canPublishPurgeAllChanges = $this->config->canPublishPurgeAllChanges();
$canPublishPurgeChanges = $this->config->canPublishPurgeChanges();
if ($this->config->areWebHooksEnabled() && ($canPublishPurgeAllChanges || $canPublishPurgeChanges)) {
$this->sendWebHook('*initiated clean/purge all*');
$canPublishPurgeAllDebugBacktrace = $this->config->canPublishPurgeAllDebugBacktrace();
$canPublishPurgeDebugBacktrace = $this->config->canPublishPurgeDebugBacktrace();
if ($canPublishPurgeAllDebugBacktrace == false && $canPublishPurgeDebugBacktrace == false) {
return $result['status'];
}
$this->stackTrace($type);
}
return $result['status'];
} | php | {
"resource": ""
} |
q243884 | Api._purge | validation | private function _purge($uri, $type, $method = \Zend_Http_Client::POST, $payload = null)
{
if ($method == 'PURGE') {
// create purge token
$expiration = time() + self::PURGE_TOKEN_LIFETIME;
$zendUri = \Zend_Uri::factory($uri);
$path = $zendUri->getPath();
$stringToSign = $path . $expiration;
$signature = hash_hmac('sha1', $stringToSign, $this->config->getServiceId());
$token = $expiration . '_' . urlencode($signature);
$headers = [
self::FASTLY_HEADER_TOKEN . ': ' . $token
];
} else {
// set headers
$headers = [
self::FASTLY_HEADER_AUTH . ': ' . $this->config->getApiKey()
];
}
// soft purge if needed
if ($this->config->canUseSoftPurge()) {
array_push(
$headers,
self::FASTLY_HEADER_SOFT_PURGE . ': 1'
);
}
$result['status'] = true;
try {
$client = $this->curlFactory->create();
$client->setConfig(['timeout' => self::PURGE_TIMEOUT]);
if ($method == 'PURGE') {
$client->addOption(CURLOPT_CUSTOMREQUEST, 'PURGE');
}
$client->write($method, $uri, '1.1', $headers, $payload);
$responseBody = $client->read();
$responseCode = \Zend_Http_Response::extractCode($responseBody);
$responseMessage = \Zend_Http_Response::extractMessage($responseBody);
$client->close();
// check response
if ($responseCode == '429') {
throw new LocalizedException(__($responseMessage));
} elseif ($responseCode != '200') {
throw new LocalizedException(__($responseCode . ': ' . $responseMessage));
}
} catch (\Exception $e) {
$this->logger->critical($e->getMessage(), $uri);
$result['status'] = false;
$result['msg'] = $e->getMessage();
}
if (empty($type)) {
return $result;
}
if ($this->config->areWebHooksEnabled() && $this->config->canPublishPurgeChanges()) {
$this->sendWebHook('*initiated ' . $type .'*');
if ($this->config->canPublishPurgeDebugBacktrace() == false) {
return $result;
}
$this->stackTrace($type);
}
return $result;
} | php | {
"resource": ""
} |
q243885 | Api.getCustomerInfo | validation | public function getCustomerInfo()
{
$uri = $this->config->getApiEndpoint() . 'current_customer';
$result = $this->_fetch($uri);
return $result;
} | php | {
"resource": ""
} |
q243886 | Api.checkServiceDetails | validation | public function checkServiceDetails($test = false, $serviceId = null, $apiKey = null)
{
if (!$test) {
$uri = rtrim($this->_getApiServiceUri(), '/');
$result = $this->_fetch($uri);
} else {
$uri = $this->config->getApiEndpoint() . 'service/' . $serviceId;
$result = $this->_fetch($uri, \Zend_Http_Client::GET, null, true, $apiKey);
}
if (!$result) {
throw new LocalizedException(__('Failed to check Service details.'));
}
return $result;
} | php | {
"resource": ""
} |
q243887 | Api.cloneVersion | validation | public function cloneVersion($curVersion)
{
$url = $this->_getApiServiceUri() . 'version/'.$curVersion.'/clone';
$result = $this->_fetch($url, \Zend_Http_Client::PUT);
if (!$result) {
throw new LocalizedException(__('Failed to clone active version.'));
}
return $result;
} | php | {
"resource": ""
} |
q243888 | Api.addComment | validation | public function addComment($version, $comment)
{
$url = $this->_getApiServiceUri() . 'version/' . $version;
$result = $this->_fetch($url, \Zend_Http_Client::PUT, $comment);
return $result;
} | php | {
"resource": ""
} |
q243889 | Api.uploadVcl | validation | public function uploadVcl($version, $vcl)
{
$url = $this->_getApiServiceUri() . 'version/' .$version. '/vcl';
$result = $this->_fetch($url, 'POST', $vcl);
return $result;
} | php | {
"resource": ""
} |
q243890 | Api.setVclAsMain | validation | public function setVclAsMain($version, $name)
{
$url = $this->_getApiServiceUri() . 'version/' .$version. '/vcl/' .$name. '/main';
$result = $this->_fetch($url, 'PUT');
return $result;
} | php | {
"resource": ""
} |
q243891 | Api.validateServiceVersion | validation | public function validateServiceVersion($version)
{
$url = $this->_getApiServiceUri() . 'version/' .$version. '/validate';
$result = $this->_fetch($url, 'GET');
if ($result->status == 'error') {
throw new LocalizedException(__('Failed to validate service version: ' . $result->msg));
}
} | php | {
"resource": ""
} |
q243892 | Api.activateVersion | validation | public function activateVersion($version)
{
$url = $this->_getApiServiceUri() . 'version/' .$version. '/activate';
$result = $this->_fetch($url, 'PUT');
return $result;
} | php | {
"resource": ""
} |
q243893 | Api.uploadSnippet | validation | public function uploadSnippet($version, array $snippet)
{
// Perform replacements vcl template replacements
if (isset($snippet['content'])) {
$adminUrl = $this->vcl->getAdminFrontName();
$adminPathTimeout = $this->config->getAdminPathTimeout();
$ignoredUrlParameters = $this->config->getIgnoredUrlParameters();
$ignoredUrlParameterPieces = explode(",", $ignoredUrlParameters);
$filterIgnoredUrlParameterPieces = array_filter(array_map('trim', $ignoredUrlParameterPieces));
$queryParameters = implode('|', $filterIgnoredUrlParameterPieces);
$snippet['content'] = str_replace('####ADMIN_PATH####', $adminUrl, $snippet['content']);
$snippet['content'] = str_replace('####ADMIN_PATH_TIMEOUT####', $adminPathTimeout, $snippet['content']);
$snippet['content'] = str_replace('####QUERY_PARAMETERS####', $queryParameters, $snippet['content']);
}
$checkIfExists = $this->hasSnippet($version, $snippet['name']);
$url = $this->_getApiServiceUri(). 'version/' .$version. '/snippet';
if (!$checkIfExists) {
$verb = \Zend_Http_Client::POST;
} else {
$verb = \Zend_Http_Client::PUT;
$url .= '/'.$snippet['name'];
unset($snippet['name'], $snippet['type'], $snippet['dynamic'], $snippet['priority']);
}
$result = $this->_fetch($url, $verb, $snippet);
if (!$result) {
throw new LocalizedException(__('Failed to upload the Snippet file.'));
}
} | php | {
"resource": ""
} |
q243894 | Api.updateSnippet | validation | public function updateSnippet(array $snippet)
{
$url = $this->_getApiServiceUri(). 'snippet' . '/'.$snippet['name'];
$result = $this->_fetch($url, \Zend_Http_Client::PUT, $snippet);
return $result;
} | php | {
"resource": ""
} |
q243895 | Api.hasSnippet | validation | public function hasSnippet($version, $name)
{
$url = $this->_getApiServiceUri() . 'version/' . $version . '/snippet/' . $name;
$result = $this->_fetch($url, \Zend_Http_Client::GET, '', false, null, false);
if ($result == false) {
return false;
}
return true;
} | php | {
"resource": ""
} |
q243896 | Api.createCondition | validation | public function createCondition($version, array $condition)
{
$checkIfExists = $this->getCondition($version, $condition['name']);
$url = $this->_getApiServiceUri(). 'version/' .$version. '/condition';
if (!$checkIfExists) {
$verb = \Zend_Http_Client::POST;
} else {
$verb = \Zend_Http_Client::PUT;
$url .= '/'.$condition['name'];
}
$result = $this->_fetch($url, $verb, $condition);
if (!$result) {
throw new LocalizedException(__('Failed to create a REQUEST condition.'));
}
return $result;
} | php | {
"resource": ""
} |
q243897 | Api.createHeader | validation | public function createHeader($version, array $condition)
{
$checkIfExists = $this->getHeader($version, $condition['name']);
$url = $this->_getApiServiceUri(). 'version/' .$version. '/header';
if ($checkIfExists === false) {
$verb = \Zend_Http_Client::POST;
} else {
$verb = \Zend_Http_Client::PUT;
$url .= '/'.$condition['name'];
}
$result = $this->_fetch($url, $verb, $condition);
return $result;
} | php | {
"resource": ""
} |
q243898 | Api.createResponse | validation | public function createResponse($version, array $response)
{
$checkIfExists = $this->getResponse($version, $response['name']);
$url = $this->_getApiServiceUri(). 'version/' .$version. '/response_object';
if (!$checkIfExists) {
$verb = \Zend_Http_Client::POST;
} else {
$verb = \Zend_Http_Client::PUT;
$url .= '/'.$response['name'];
}
$result = $this->_fetch($url, $verb, $response);
return $result;
} | php | {
"resource": ""
} |
q243899 | Api.getResponse | validation | public function getResponse($version, $name)
{
$url = $this->_getApiServiceUri(). 'version/'. $version. '/response_object/' . $name;
$result = $this->_fetch($url, \Zend_Http_Client::GET);
return $result;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.