repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
spicywebau/craft-embedded-assets
src/Service.php
Service._isImageLargeEnough
private function _isImageLargeEnough(array $image) { $pluginSettings = EmbeddedAssets::$plugin->getSettings(); $minImageSize = $pluginSettings->minImageSize; return $image['width'] >= $minImageSize && $image['height'] >= $minImageSize; }
php
private function _isImageLargeEnough(array $image) { $pluginSettings = EmbeddedAssets::$plugin->getSettings(); $minImageSize = $pluginSettings->minImageSize; return $image['width'] >= $minImageSize && $image['height'] >= $minImageSize; }
[ "private", "function", "_isImageLargeEnough", "(", "array", "$", "image", ")", "{", "$", "pluginSettings", "=", "EmbeddedAssets", "::", "$", "plugin", "->", "getSettings", "(", ")", ";", "$", "minImageSize", "=", "$", "pluginSettings", "->", "minImageSize", ";...
Helper method for filtering images to some minimum size. Used to filter out small images that likely are absolutely useless. @param array $image @return bool
[ "Helper", "method", "for", "filtering", "images", "to", "some", "minimum", "size", ".", "Used", "to", "filter", "out", "small", "images", "that", "likely", "are", "absolutely", "useless", "." ]
c751fbecb2357cb63994875600722ed18dac9b06
https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Service.php#L485-L491
train
spicywebau/craft-embedded-assets
src/Service.php
Service._convertFromAdapter
private function _convertFromAdapter(Adapter $adapter): array { return [ 'title' => $adapter->title, 'description' => $adapter->description, 'url' => $adapter->url, 'type' => $adapter->type, 'tags' => $adapter->tags, 'images' => array_filter($adapter->images, [$this, '_isImageLargeEnough']), 'image' => $adapter->image, 'imageWidth' => $adapter->imageWidth, 'imageHeight' => $adapter->imageHeight, 'code' => Template::raw($adapter->code ?: ''), 'width' => $adapter->width, 'height' => $adapter->height, 'aspectRatio' => $adapter->aspectRatio, 'authorName' => $adapter->authorName, 'authorUrl' => $adapter->authorUrl, 'providerName' => $adapter->providerName, 'providerUrl' => $adapter->providerUrl, 'providerIcons' => array_filter($adapter->providerIcons, [$this, '_isImageLargeEnough']), 'providerIcon' => $adapter->providerIcon, 'publishedTime' => $adapter->publishedTime, 'license' => $adapter->license, 'feeds' => $adapter->feeds, ]; }
php
private function _convertFromAdapter(Adapter $adapter): array { return [ 'title' => $adapter->title, 'description' => $adapter->description, 'url' => $adapter->url, 'type' => $adapter->type, 'tags' => $adapter->tags, 'images' => array_filter($adapter->images, [$this, '_isImageLargeEnough']), 'image' => $adapter->image, 'imageWidth' => $adapter->imageWidth, 'imageHeight' => $adapter->imageHeight, 'code' => Template::raw($adapter->code ?: ''), 'width' => $adapter->width, 'height' => $adapter->height, 'aspectRatio' => $adapter->aspectRatio, 'authorName' => $adapter->authorName, 'authorUrl' => $adapter->authorUrl, 'providerName' => $adapter->providerName, 'providerUrl' => $adapter->providerUrl, 'providerIcons' => array_filter($adapter->providerIcons, [$this, '_isImageLargeEnough']), 'providerIcon' => $adapter->providerIcon, 'publishedTime' => $adapter->publishedTime, 'license' => $adapter->license, 'feeds' => $adapter->feeds, ]; }
[ "private", "function", "_convertFromAdapter", "(", "Adapter", "$", "adapter", ")", ":", "array", "{", "return", "[", "'title'", "=>", "$", "adapter", "->", "title", ",", "'description'", "=>", "$", "adapter", "->", "description", ",", "'url'", "=>", "$", "...
Creates an "embedded asset ready" array from an adapter. @param Adapter $adapter @return array
[ "Creates", "an", "embedded", "asset", "ready", "array", "from", "an", "adapter", "." ]
c751fbecb2357cb63994875600722ed18dac9b06
https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Service.php#L499-L525
train
spicywebau/craft-embedded-assets
src/Service.php
Service._convertFromLegacy
private function _convertFromLegacy(array $legacy): array { $width = intval($legacy['width'] ?? 0); $height = intval($legacy['height'] ?? 0); $imageUrl = $legacy['thumbnailUrl'] ?? null; $imageWidth = intval($legacy['thumbnailWidth'] ?? 0); $imageHeight = intval($legacy['thumbnailHeight'] ?? 0); return [ 'title' => $legacy['title'] ?? null, 'description' => $legacy['description'] ?? null, 'url' => $legacy['url'] ?? null, 'type' => $legacy['type'] ?? null, 'images' => $imageUrl ? [[ 'url' => $imageUrl, 'width' => $imageWidth, 'height' => $imageHeight, 'size' => $imageWidth * $imageHeight, 'mime' => null, ]] : [], 'image' => $imageUrl, 'imageWidth' => $imageWidth, 'imageHeight' => $imageHeight, 'code' => Template::raw($legacy['html'] ?? $legacy['safeHtml'] ?? ''), 'width' => $width, 'height' => $height, 'aspectRatio' => $width > 0 ? $height / $width * 100 : 0, 'authorName' => $legacy['authorName'] ?? null, 'authorUrl' => $legacy['authorUrl'] ?? null, 'providerName' => $legacy['providerName'] ?? null, 'providerUrl' => $legacy['providerUrl'] ?? null, ]; }
php
private function _convertFromLegacy(array $legacy): array { $width = intval($legacy['width'] ?? 0); $height = intval($legacy['height'] ?? 0); $imageUrl = $legacy['thumbnailUrl'] ?? null; $imageWidth = intval($legacy['thumbnailWidth'] ?? 0); $imageHeight = intval($legacy['thumbnailHeight'] ?? 0); return [ 'title' => $legacy['title'] ?? null, 'description' => $legacy['description'] ?? null, 'url' => $legacy['url'] ?? null, 'type' => $legacy['type'] ?? null, 'images' => $imageUrl ? [[ 'url' => $imageUrl, 'width' => $imageWidth, 'height' => $imageHeight, 'size' => $imageWidth * $imageHeight, 'mime' => null, ]] : [], 'image' => $imageUrl, 'imageWidth' => $imageWidth, 'imageHeight' => $imageHeight, 'code' => Template::raw($legacy['html'] ?? $legacy['safeHtml'] ?? ''), 'width' => $width, 'height' => $height, 'aspectRatio' => $width > 0 ? $height / $width * 100 : 0, 'authorName' => $legacy['authorName'] ?? null, 'authorUrl' => $legacy['authorUrl'] ?? null, 'providerName' => $legacy['providerName'] ?? null, 'providerUrl' => $legacy['providerUrl'] ?? null, ]; }
[ "private", "function", "_convertFromLegacy", "(", "array", "$", "legacy", ")", ":", "array", "{", "$", "width", "=", "intval", "(", "$", "legacy", "[", "'width'", "]", "??", "0", ")", ";", "$", "height", "=", "intval", "(", "$", "legacy", "[", "'heig...
Creates an "embedded asset ready" array from an array matching the Craft 2 version of the plugin. @param array $legacy @return array
[ "Creates", "an", "embedded", "asset", "ready", "array", "from", "an", "array", "matching", "the", "Craft", "2", "version", "of", "the", "plugin", "." ]
c751fbecb2357cb63994875600722ed18dac9b06
https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Service.php#L533-L565
train
spicywebau/craft-embedded-assets
src/Controller.php
Controller.actionSave
public function actionSave(): Response { $this->requireAcceptsJson(); // The behaviour of certain controller actions depends on whether Craft 3.0 or 3.1 is being used // Figure out which Craft version is being used by checking whether the project config service class exists $isCraft30 = !class_exists('craft\\services\\ProjectConfig'); $response = null; $assetsService = Craft::$app->getAssets(); $elementsService = Craft::$app->getElements(); $requestService = Craft::$app->getRequest(); $url = $requestService->getRequiredParam('url'); $folderId = $requestService->getRequiredParam('folderId'); $embeddedAsset = EmbeddedAssets::$plugin->methods->requestUrl($url); // Craft 3.0 requires finding the folder by its ID, whereas Craft 3.1 requires finding it by its UID $folderIdProp = $isCraft30 ? 'id' : 'uid'; $folder = $assetsService->findFolder([$folderIdProp => $folderId]); if (!$folder) { throw new BadRequestHttpException('The target folder provided for uploading is not valid'); } $userTempFolder = !$folder->volumeId ? $assetsService->getCurrentUserTemporaryUploadFolder() : null; if (!$userTempFolder || $folder->id != $userTempFolder->id) { $volume = Craft::$app->getVolumes()->getVolumeById($folder->volumeId); $this->requirePermission('saveAssetInVolume:'. $volume->$folderIdProp); } $asset = EmbeddedAssets::$plugin->methods->createAsset($embeddedAsset, $folder); $result = $elementsService->saveElement($asset); if (!$result) { $errors = $asset->getFirstErrors(); $errorLabel = Craft::t('app', "Failed to save the Asset:"); $response = $this->asErrorJson($errorLabel . implode(";\n", $errors)); } else { $response = $this->asJson([ 'success' => true, 'payload' => [ 'assetId' => $asset->id, 'folderId' => $folderId, ], ]); } return $response; }
php
public function actionSave(): Response { $this->requireAcceptsJson(); // The behaviour of certain controller actions depends on whether Craft 3.0 or 3.1 is being used // Figure out which Craft version is being used by checking whether the project config service class exists $isCraft30 = !class_exists('craft\\services\\ProjectConfig'); $response = null; $assetsService = Craft::$app->getAssets(); $elementsService = Craft::$app->getElements(); $requestService = Craft::$app->getRequest(); $url = $requestService->getRequiredParam('url'); $folderId = $requestService->getRequiredParam('folderId'); $embeddedAsset = EmbeddedAssets::$plugin->methods->requestUrl($url); // Craft 3.0 requires finding the folder by its ID, whereas Craft 3.1 requires finding it by its UID $folderIdProp = $isCraft30 ? 'id' : 'uid'; $folder = $assetsService->findFolder([$folderIdProp => $folderId]); if (!$folder) { throw new BadRequestHttpException('The target folder provided for uploading is not valid'); } $userTempFolder = !$folder->volumeId ? $assetsService->getCurrentUserTemporaryUploadFolder() : null; if (!$userTempFolder || $folder->id != $userTempFolder->id) { $volume = Craft::$app->getVolumes()->getVolumeById($folder->volumeId); $this->requirePermission('saveAssetInVolume:'. $volume->$folderIdProp); } $asset = EmbeddedAssets::$plugin->methods->createAsset($embeddedAsset, $folder); $result = $elementsService->saveElement($asset); if (!$result) { $errors = $asset->getFirstErrors(); $errorLabel = Craft::t('app', "Failed to save the Asset:"); $response = $this->asErrorJson($errorLabel . implode(";\n", $errors)); } else { $response = $this->asJson([ 'success' => true, 'payload' => [ 'assetId' => $asset->id, 'folderId' => $folderId, ], ]); } return $response; }
[ "public", "function", "actionSave", "(", ")", ":", "Response", "{", "$", "this", "->", "requireAcceptsJson", "(", ")", ";", "// The behaviour of certain controller actions depends on whether Craft 3.0 or 3.1 is being used", "// Figure out which Craft version is being used by checking...
Saves an embedded asset as a Craft asset. @query string url The URL to create an embedded asset from (required). @query int folderId The volume folder ID to save the asset to (required). @response JSON @return Response @throws BadRequestHttpException @throws \Throwable @throws \craft\errors\ElementNotFoundException @throws \yii\base\Exception @throws \yii\web\ForbiddenHttpException
[ "Saves", "an", "embedded", "asset", "as", "a", "Craft", "asset", "." ]
c751fbecb2357cb63994875600722ed18dac9b06
https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Controller.php#L38-L94
train
spicywebau/craft-embedded-assets
src/Controller.php
Controller.actionPreview
public function actionPreview(): Response { $assetsService = Craft::$app->getAssets(); $requestService = Craft::$app->getRequest(); $viewService = Craft::$app->getView(); $viewService->registerAssetBundle(PreviewAsset::class); $url = $requestService->getParam('url'); $assetId = $requestService->getParam('assetId'); $callback = $requestService->getParam('callback'); $showContent = (bool)$requestService->getParam('showContent', true); if ($url) { $embeddedAsset = EmbeddedAssets::$plugin->methods->requestUrl($url); } else if ($assetId) { $asset = $assetsService->getAssetById($assetId); if (!$asset) { throw new BadRequestHttpException("Could not find asset with ID: $assetId"); } $embeddedAsset = EmbeddedAssets::$plugin->methods->getEmbeddedAsset($asset); if (!$embeddedAsset) { throw new BadRequestHttpException("Could not find embedded asset from asset $assetId ($asset->filename)"); } } else { throw new BadRequestHttpException("URL or asset ID are missing from the request"); } $template = $viewService->renderTemplate('embeddedassets/_preview', [ 'embeddedAsset' => $embeddedAsset, 'callback' => $callback, 'showContent' => $showContent, ]); $response = $this->asRaw($template); $headers = $response->getHeaders(); $headers->set('content-type', 'text/html; charset=utf-8'); return $response; }
php
public function actionPreview(): Response { $assetsService = Craft::$app->getAssets(); $requestService = Craft::$app->getRequest(); $viewService = Craft::$app->getView(); $viewService->registerAssetBundle(PreviewAsset::class); $url = $requestService->getParam('url'); $assetId = $requestService->getParam('assetId'); $callback = $requestService->getParam('callback'); $showContent = (bool)$requestService->getParam('showContent', true); if ($url) { $embeddedAsset = EmbeddedAssets::$plugin->methods->requestUrl($url); } else if ($assetId) { $asset = $assetsService->getAssetById($assetId); if (!$asset) { throw new BadRequestHttpException("Could not find asset with ID: $assetId"); } $embeddedAsset = EmbeddedAssets::$plugin->methods->getEmbeddedAsset($asset); if (!$embeddedAsset) { throw new BadRequestHttpException("Could not find embedded asset from asset $assetId ($asset->filename)"); } } else { throw new BadRequestHttpException("URL or asset ID are missing from the request"); } $template = $viewService->renderTemplate('embeddedassets/_preview', [ 'embeddedAsset' => $embeddedAsset, 'callback' => $callback, 'showContent' => $showContent, ]); $response = $this->asRaw($template); $headers = $response->getHeaders(); $headers->set('content-type', 'text/html; charset=utf-8'); return $response; }
[ "public", "function", "actionPreview", "(", ")", ":", "Response", "{", "$", "assetsService", "=", "Craft", "::", "$", "app", "->", "getAssets", "(", ")", ";", "$", "requestService", "=", "Craft", "::", "$", "app", "->", "getRequest", "(", ")", ";", "$"...
Renders a preview of the embedded asset. @query string url The URL to create an embedded asset from. @query string assetId The asset ID to load the embedded asset from. @query string callback The name of a global Javascript function to be called when the preview is loaded. @response HTML @return Response @throws BadRequestHttpException @throws \Twig_Error_Loader @throws \yii\base\Exception @throws \yii\base\InvalidConfigException
[ "Renders", "a", "preview", "of", "the", "embedded", "asset", "." ]
c751fbecb2357cb63994875600722ed18dac9b06
https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Controller.php#L110-L158
train
spicywebau/craft-embedded-assets
src/Plugin.php
Plugin.init
public function init() { parent::init(); self::$plugin = $this; $requestService = Craft::$app->getRequest(); $this->setComponents([ 'methods' => Service::class, ]); $this->_configureTemplateVariable(); if ($requestService->getIsCpRequest()) { $this->_configureCpResources(); $this->_configureAssetThumbnails(); $this->_configureAssetIndexAttributes(); } }
php
public function init() { parent::init(); self::$plugin = $this; $requestService = Craft::$app->getRequest(); $this->setComponents([ 'methods' => Service::class, ]); $this->_configureTemplateVariable(); if ($requestService->getIsCpRequest()) { $this->_configureCpResources(); $this->_configureAssetThumbnails(); $this->_configureAssetIndexAttributes(); } }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "self", "::", "$", "plugin", "=", "$", "this", ";", "$", "requestService", "=", "Craft", "::", "$", "app", "->", "getRequest", "(", ")", ";", "$", "this", "->", "...
Plugin initializer.
[ "Plugin", "initializer", "." ]
c751fbecb2357cb63994875600722ed18dac9b06
https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Plugin.php#L63-L83
train
spicywebau/craft-embedded-assets
src/Plugin.php
Plugin._configureTemplateVariable
private function _configureTemplateVariable() { Event::on( CraftVariable::class, CraftVariable::EVENT_INIT, function(Event $event) { $event->sender->set('embeddedAssets', Variable::class); } ); }
php
private function _configureTemplateVariable() { Event::on( CraftVariable::class, CraftVariable::EVENT_INIT, function(Event $event) { $event->sender->set('embeddedAssets', Variable::class); } ); }
[ "private", "function", "_configureTemplateVariable", "(", ")", "{", "Event", "::", "on", "(", "CraftVariable", "::", "class", ",", "CraftVariable", "::", "EVENT_INIT", ",", "function", "(", "Event", "$", "event", ")", "{", "$", "event", "->", "sender", "->",...
Assigns the template variable so it can be accessed in the templates at `craft.embeddedAssets`.
[ "Assigns", "the", "template", "variable", "so", "it", "can", "be", "accessed", "in", "the", "templates", "at", "craft", ".", "embeddedAssets", "." ]
c751fbecb2357cb63994875600722ed18dac9b06
https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Plugin.php#L126-L136
train
spicywebau/craft-embedded-assets
src/Plugin.php
Plugin._configureAssetThumbnails
private function _configureAssetThumbnails() { Event::on( Assets::class, Assets::EVENT_GET_ASSET_THUMB_URL, function(GetAssetThumbUrlEvent $event) { $embeddedAsset = $this->methods->getEmbeddedAsset($event->asset); $thumbSize = max($event->width, $event->height); $thumbnailUrl = $embeddedAsset ? $this->_getThumbnailUrl($embeddedAsset, $thumbSize) : null; if ($thumbnailUrl) { $event->url = $thumbnailUrl; } } ); }
php
private function _configureAssetThumbnails() { Event::on( Assets::class, Assets::EVENT_GET_ASSET_THUMB_URL, function(GetAssetThumbUrlEvent $event) { $embeddedAsset = $this->methods->getEmbeddedAsset($event->asset); $thumbSize = max($event->width, $event->height); $thumbnailUrl = $embeddedAsset ? $this->_getThumbnailUrl($embeddedAsset, $thumbSize) : null; if ($thumbnailUrl) { $event->url = $thumbnailUrl; } } ); }
[ "private", "function", "_configureAssetThumbnails", "(", ")", "{", "Event", "::", "on", "(", "Assets", "::", "class", ",", "Assets", "::", "EVENT_GET_ASSET_THUMB_URL", ",", "function", "(", "GetAssetThumbUrlEvent", "$", "event", ")", "{", "$", "embeddedAsset", "...
Sets the embedded asset thumbnails on asset elements in the control panel.
[ "Sets", "the", "embedded", "asset", "thumbnails", "on", "asset", "elements", "in", "the", "control", "panel", "." ]
c751fbecb2357cb63994875600722ed18dac9b06
https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Plugin.php#L141-L158
train
spicywebau/craft-embedded-assets
src/Plugin.php
Plugin._configureAssetIndexAttributes
private function _configureAssetIndexAttributes() { $newAttributes = [ 'provider' => "Provider", ]; Event::on( Asset::class, Asset::EVENT_REGISTER_HTML_ATTRIBUTES, function(RegisterElementHtmlAttributesEvent $event) { $embeddedAsset = $this->methods->getEmbeddedAsset($event->sender); if ($embeddedAsset && $embeddedAsset->code && $embeddedAsset->isSafe()) { // Setting `null` actually adds the attribute, but doesn't include a value $event->htmlAttributes['data-embedded-asset'] = $embeddedAsset->aspectRatio; } } ); Event::on( Asset::class, Asset::EVENT_REGISTER_TABLE_ATTRIBUTES, function(RegisterElementTableAttributesEvent $event) use($newAttributes) { foreach ($newAttributes as $attributeHandle => $attributeLabel) { $event->tableAttributes[$attributeHandle] = [ 'label' => Craft::t('embeddedassets', $attributeLabel), ]; } } ); Event::on( Asset::class, Asset::EVENT_SET_TABLE_ATTRIBUTE_HTML, function(SetElementTableAttributeHtmlEvent $event) use($newAttributes) { // Prevent new table attributes from causing server errors if (array_key_exists($event->attribute, $newAttributes)) { $event->html = ''; } $embeddedAsset = $this->methods->getEmbeddedAsset($event->sender); $html = $embeddedAsset ? $this->_getTableAttributeHtml($embeddedAsset, $event->attribute) : null; if ($html !== null) { $event->html = $html; } } ); }
php
private function _configureAssetIndexAttributes() { $newAttributes = [ 'provider' => "Provider", ]; Event::on( Asset::class, Asset::EVENT_REGISTER_HTML_ATTRIBUTES, function(RegisterElementHtmlAttributesEvent $event) { $embeddedAsset = $this->methods->getEmbeddedAsset($event->sender); if ($embeddedAsset && $embeddedAsset->code && $embeddedAsset->isSafe()) { // Setting `null` actually adds the attribute, but doesn't include a value $event->htmlAttributes['data-embedded-asset'] = $embeddedAsset->aspectRatio; } } ); Event::on( Asset::class, Asset::EVENT_REGISTER_TABLE_ATTRIBUTES, function(RegisterElementTableAttributesEvent $event) use($newAttributes) { foreach ($newAttributes as $attributeHandle => $attributeLabel) { $event->tableAttributes[$attributeHandle] = [ 'label' => Craft::t('embeddedassets', $attributeLabel), ]; } } ); Event::on( Asset::class, Asset::EVENT_SET_TABLE_ATTRIBUTE_HTML, function(SetElementTableAttributeHtmlEvent $event) use($newAttributes) { // Prevent new table attributes from causing server errors if (array_key_exists($event->attribute, $newAttributes)) { $event->html = ''; } $embeddedAsset = $this->methods->getEmbeddedAsset($event->sender); $html = $embeddedAsset ? $this->_getTableAttributeHtml($embeddedAsset, $event->attribute) : null; if ($html !== null) { $event->html = $html; } } ); }
[ "private", "function", "_configureAssetIndexAttributes", "(", ")", "{", "$", "newAttributes", "=", "[", "'provider'", "=>", "\"Provider\"", ",", "]", ";", "Event", "::", "on", "(", "Asset", "::", "class", ",", "Asset", "::", "EVENT_REGISTER_HTML_ATTRIBUTES", ","...
Adds new and modifies existing asset table attributes in the control panel.
[ "Adds", "new", "and", "modifies", "existing", "asset", "table", "attributes", "in", "the", "control", "panel", "." ]
c751fbecb2357cb63994875600722ed18dac9b06
https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Plugin.php#L163-L218
train
spicywebau/craft-embedded-assets
src/Plugin.php
Plugin._getThumbnailUrl
private function _getThumbnailUrl(EmbeddedAsset $embeddedAsset, int $size, int $maxSize = 200) { $assetManagerService = Craft::$app->getAssetManager(); $defaultThumb = $assetManagerService->getPublishedUrl('@spicyweb/embeddedassets/resources/default-thumb.svg', true); // If embedded asset thumbnails are disabled, just show Embedded Assets' default. if (!$this->getSettings()->showThumbnailsInCp) { return $defaultThumb; } $url = false; $image = $embeddedAsset->getImageToSize($size); if ($image && UrlHelper::isAbsoluteUrl($image['url'])) { $imageSize = max($image['width'], $image['height']); if ($size <= $maxSize || $imageSize > $maxSize) { $url = $image['url']; } } // Check to avoid showing the default thumbnail or provider icon in the asset editor HUD. else if ($size <= $maxSize) { $providerIcon = $embeddedAsset->getProviderIconToSize($size); if ($providerIcon && UrlHelper::isAbsoluteUrl($providerIcon['url'])) { $url = $providerIcon['url']; } else { $url = $defaultThumb; } } return $url; }
php
private function _getThumbnailUrl(EmbeddedAsset $embeddedAsset, int $size, int $maxSize = 200) { $assetManagerService = Craft::$app->getAssetManager(); $defaultThumb = $assetManagerService->getPublishedUrl('@spicyweb/embeddedassets/resources/default-thumb.svg', true); // If embedded asset thumbnails are disabled, just show Embedded Assets' default. if (!$this->getSettings()->showThumbnailsInCp) { return $defaultThumb; } $url = false; $image = $embeddedAsset->getImageToSize($size); if ($image && UrlHelper::isAbsoluteUrl($image['url'])) { $imageSize = max($image['width'], $image['height']); if ($size <= $maxSize || $imageSize > $maxSize) { $url = $image['url']; } } // Check to avoid showing the default thumbnail or provider icon in the asset editor HUD. else if ($size <= $maxSize) { $providerIcon = $embeddedAsset->getProviderIconToSize($size); if ($providerIcon && UrlHelper::isAbsoluteUrl($providerIcon['url'])) { $url = $providerIcon['url']; } else { $url = $defaultThumb; } } return $url; }
[ "private", "function", "_getThumbnailUrl", "(", "EmbeddedAsset", "$", "embeddedAsset", ",", "int", "$", "size", ",", "int", "$", "maxSize", "=", "200", ")", "{", "$", "assetManagerService", "=", "Craft", "::", "$", "app", "->", "getAssetManager", "(", ")", ...
Helper method for retrieving an appropriately sized thumbnail from an embedded asset. @param EmbeddedAsset $embeddedAsset @param int $size The preferred size of the thumbnail. @param int $maxSize The largest size to bother getting a thumbnail for. @return false|string The URL to the thumbnail.
[ "Helper", "method", "for", "retrieving", "an", "appropriately", "sized", "thumbnail", "from", "an", "embedded", "asset", "." ]
c751fbecb2357cb63994875600722ed18dac9b06
https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Plugin.php#L228-L267
train
spicywebau/craft-embedded-assets
src/Variable.php
Variable.isEmbedded
public function isEmbedded(Asset $asset): bool { Craft::$app->getDeprecator()->log('craft.embeddedAssets.isEmbedded', "The template method `craft.embeddedAssets.isEmbedded` is now deprecated. Use `craft.embeddedAssets.get` instead."); return (bool)EmbeddedAssets::$plugin->methods->getEmbeddedAsset($asset); }
php
public function isEmbedded(Asset $asset): bool { Craft::$app->getDeprecator()->log('craft.embeddedAssets.isEmbedded', "The template method `craft.embeddedAssets.isEmbedded` is now deprecated. Use `craft.embeddedAssets.get` instead."); return (bool)EmbeddedAssets::$plugin->methods->getEmbeddedAsset($asset); }
[ "public", "function", "isEmbedded", "(", "Asset", "$", "asset", ")", ":", "bool", "{", "Craft", "::", "$", "app", "->", "getDeprecator", "(", ")", "->", "log", "(", "'craft.embeddedAssets.isEmbedded'", ",", "\"The template method `craft.embeddedAssets.isEmbedded` is n...
Determines if an asset is an embedded asset or not. @deprecated Will be removed in next major version. Use the `get` method instead. @param Asset $asset @return bool
[ "Determines", "if", "an", "asset", "is", "an", "embedded", "asset", "or", "not", "." ]
c751fbecb2357cb63994875600722ed18dac9b06
https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Variable.php#L42-L47
train
spicywebau/craft-embedded-assets
src/Variable.php
Variable.fromAsset
public function fromAsset(Asset $asset) { Craft::$app->getDeprecator()->log('craft.embeddedAssets.fromAsset', "The template method `craft.embeddedAssets.fromAsset` is now deprecated. Use `craft.embeddedAssets.get` instead."); return EmbeddedAssets::$plugin->methods->getEmbeddedAsset($asset); }
php
public function fromAsset(Asset $asset) { Craft::$app->getDeprecator()->log('craft.embeddedAssets.fromAsset', "The template method `craft.embeddedAssets.fromAsset` is now deprecated. Use `craft.embeddedAssets.get` instead."); return EmbeddedAssets::$plugin->methods->getEmbeddedAsset($asset); }
[ "public", "function", "fromAsset", "(", "Asset", "$", "asset", ")", "{", "Craft", "::", "$", "app", "->", "getDeprecator", "(", ")", "->", "log", "(", "'craft.embeddedAssets.fromAsset'", ",", "\"The template method `craft.embeddedAssets.fromAsset` is now deprecated. Use `...
Retrieves the embedded asset model from an asset, if one exists. @deprecated Will be removed in next major version. Use the `get` method instead. @param Asset $asset @return mixed
[ "Retrieves", "the", "embedded", "asset", "model", "from", "an", "asset", "if", "one", "exists", "." ]
c751fbecb2357cb63994875600722ed18dac9b06
https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Variable.php#L57-L62
train
spicywebau/craft-embedded-assets
src/Variable.php
Variable.fromAssets
public function fromAssets($assets, $indexBy = null): array { Craft::$app->getDeprecator()->log('craft.embeddedAssets.fromAssets', "The template method `craft.embeddedAssets.fromAssets` is now deprecated. Use `craft.embeddedAssets.get` instead."); $embeddedAssets = []; if (is_iterable($assets)) { foreach ($assets as $asset) { $embeddedAsset = $asset instanceof Asset ? EmbeddedAssets::$plugin->methods->getEmbeddedAsset($asset) : null; if ($embeddedAsset) { if (is_string($indexBy) && $asset->hasProperty($indexBy)) { $embeddedAssets[$asset->$indexBy] = $embeddedAsset; } else { $embeddedAssets[] = $embeddedAsset; } } } } return $embeddedAssets; }
php
public function fromAssets($assets, $indexBy = null): array { Craft::$app->getDeprecator()->log('craft.embeddedAssets.fromAssets', "The template method `craft.embeddedAssets.fromAssets` is now deprecated. Use `craft.embeddedAssets.get` instead."); $embeddedAssets = []; if (is_iterable($assets)) { foreach ($assets as $asset) { $embeddedAsset = $asset instanceof Asset ? EmbeddedAssets::$plugin->methods->getEmbeddedAsset($asset) : null; if ($embeddedAsset) { if (is_string($indexBy) && $asset->hasProperty($indexBy)) { $embeddedAssets[$asset->$indexBy] = $embeddedAsset; } else { $embeddedAssets[] = $embeddedAsset; } } } } return $embeddedAssets; }
[ "public", "function", "fromAssets", "(", "$", "assets", ",", "$", "indexBy", "=", "null", ")", ":", "array", "{", "Craft", "::", "$", "app", "->", "getDeprecator", "(", ")", "->", "log", "(", "'craft.embeddedAssets.fromAssets'", ",", "\"The template method `cr...
Retrieves the embedded asset models from an array of assets. @deprecated Will be removed in next major version. Use the `get` method instead. @param mixed $assets An iterable object of asset models. @param null $indexBy Whether to index the resulting array by a property of the asset. @return array
[ "Retrieves", "the", "embedded", "asset", "models", "from", "an", "array", "of", "assets", "." ]
c751fbecb2357cb63994875600722ed18dac9b06
https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Variable.php#L73-L101
train
themosis/theme
resources/Providers/RouteServiceProvider.php
RouteServiceProvider.map
public function map() { $themeName = ltrim( str_replace(themes_path(), '', realpath(__DIR__.'/../../')), '\/' ); Route::middleware('web') ->namespace($this->namespace) ->group(themes_path($themeName.'/routes.php')); }
php
public function map() { $themeName = ltrim( str_replace(themes_path(), '', realpath(__DIR__.'/../../')), '\/' ); Route::middleware('web') ->namespace($this->namespace) ->group(themes_path($themeName.'/routes.php')); }
[ "public", "function", "map", "(", ")", "{", "$", "themeName", "=", "ltrim", "(", "str_replace", "(", "themes_path", "(", ")", ",", "''", ",", "realpath", "(", "__DIR__", ".", "'/../../'", ")", ")", ",", "'\\/'", ")", ";", "Route", "::", "middleware", ...
Load theme routes.
[ "Load", "theme", "routes", "." ]
184bb0bf791b418f1b1be404419baff81f69b24c
https://github.com/themosis/theme/blob/184bb0bf791b418f1b1be404419baff81f69b24c/resources/Providers/RouteServiceProvider.php#L25-L35
train
Asana/php-asana
src/Asana/Resources/Gen/CustomFieldsBase.php
CustomFieldsBase.delete
public function delete($customField, $params = array(), $options = array()) { $path = sprintf("/custom_fields/%s", $customField); return $this->client->delete($path, $params, $options); }
php
public function delete($customField, $params = array(), $options = array()) { $path = sprintf("/custom_fields/%s", $customField); return $this->client->delete($path, $params, $options); }
[ "public", "function", "delete", "(", "$", "customField", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/custom_fields/%s\"", ",", "$", "customField", ")", ";", ...
A specific, existing custom field can be deleted by making a DELETE request on the URL for that custom field. Returns an empty data record. @param custom_field Globally unique identifier for the custom field. @return response
[ "A", "specific", "existing", "custom", "field", "can", "be", "deleted", "by", "making", "a", "DELETE", "request", "on", "the", "URL", "for", "that", "custom", "field", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/CustomFieldsBase.php#L88-L92
train
Asana/php-asana
src/Asana/Resources/Gen/CustomFieldsBase.php
CustomFieldsBase.updateEnumOption
public function updateEnumOption($enumOption, $params = array(), $options = array()) { $path = sprintf("/enum_options/%s", $enumOption); return $this->client->put($path, $params, $options); }
php
public function updateEnumOption($enumOption, $params = array(), $options = array()) { $path = sprintf("/enum_options/%s", $enumOption); return $this->client->put($path, $params, $options); }
[ "public", "function", "updateEnumOption", "(", "$", "enumOption", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/enum_options/%s\"", ",", "$", "enumOption", ")", ...
Updates an existing enum option. Enum custom fields require at least one enabled enum option. Returns the full record of the updated enum option. @param enum_option Globally unique identifier for the enum option. @return response
[ "Updates", "an", "existing", "enum", "option", ".", "Enum", "custom", "fields", "require", "at", "least", "one", "enabled", "enum", "option", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/CustomFieldsBase.php#L116-L120
train
Asana/php-asana
src/Asana/Resources/Gen/StoriesBase.php
StoriesBase.delete
public function delete($story, $params = array(), $options = array()) { $path = sprintf("/stories/%s", $story); return $this->client->delete($path, $params, $options); }
php
public function delete($story, $params = array(), $options = array()) { $path = sprintf("/stories/%s", $story); return $this->client->delete($path, $params, $options); }
[ "public", "function", "delete", "(", "$", "story", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/stories/%s\"", ",", "$", "story", ")", ";", "return", "$", ...
Deletes a story. A user can only delete stories they have created. Returns an empty data record. @param story Globally unique identifier for the story. @return response
[ "Deletes", "a", "story", ".", "A", "user", "can", "only", "delete", "stories", "they", "have", "created", ".", "Returns", "an", "empty", "data", "record", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/StoriesBase.php#L84-L88
train
Asana/php-asana
src/Asana/Resources/Gen/ProjectStatusesBase.php
ProjectStatusesBase.delete
public function delete($projectStatus, $params = array(), $options = array()) { $path = sprintf("/project_statuses/%s", $projectStatus); return $this->client->delete($path, $params, $options); }
php
public function delete($projectStatus, $params = array(), $options = array()) { $path = sprintf("/project_statuses/%s", $projectStatus); return $this->client->delete($path, $params, $options); }
[ "public", "function", "delete", "(", "$", "projectStatus", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/project_statuses/%s\"", ",", "$", "projectStatus", ")", ...
Deletes a specific, existing project status update. Returns an empty data record. @param project-status The project status update to delete. @return response
[ "Deletes", "a", "specific", "existing", "project", "status", "update", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/ProjectStatusesBase.php#L69-L73
train
Asana/php-asana
src/Asana/Resources/Gen/TasksBase.php
TasksBase.delete
public function delete($task, $params = array(), $options = array()) { $path = sprintf("/tasks/%s", $task); return $this->client->delete($path, $params, $options); }
php
public function delete($task, $params = array(), $options = array()) { $path = sprintf("/tasks/%s", $task); return $this->client->delete($path, $params, $options); }
[ "public", "function", "delete", "(", "$", "task", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/tasks/%s\"", ",", "$", "task", ")", ";", "return", "$", "th...
A specific, existing task can be deleted by making a DELETE request on the URL for that task. Deleted tasks go into the "trash" of the user making the delete request. Tasks can be recovered from the trash within a period of 30 days; afterward they are completely removed from the system. Returns an empty data record. @param task The task to delete. @return response
[ "A", "specific", "existing", "task", "can", "be", "deleted", "by", "making", "a", "DELETE", "request", "on", "the", "URL", "for", "that", "task", ".", "Deleted", "tasks", "go", "into", "the", "trash", "of", "the", "user", "making", "the", "delete", "requ...
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/TasksBase.php#L101-L105
train
Asana/php-asana
src/Asana/Resources/Gen/TasksBase.php
TasksBase.findByProject
public function findByProject($projectId, $params = array(), $options = array()) { $path = sprintf("/projects/%s/tasks", $projectId); return $this->client->getCollection($path, $params, $options); }
php
public function findByProject($projectId, $params = array(), $options = array()) { $path = sprintf("/projects/%s/tasks", $projectId); return $this->client->getCollection($path, $params, $options); }
[ "public", "function", "findByProject", "(", "$", "projectId", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/projects/%s/tasks\"", ",", "$", "projectId", ")", ";"...
Returns the compact task records for all tasks within the given project, ordered by their priority within the project. @param projectId The project in which to search for tasks. @return response
[ "Returns", "the", "compact", "task", "records", "for", "all", "tasks", "within", "the", "given", "project", "ordered", "by", "their", "priority", "within", "the", "project", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/TasksBase.php#L114-L118
train
Asana/php-asana
src/Asana/Resources/Gen/TasksBase.php
TasksBase.findByTag
public function findByTag($tag, $params = array(), $options = array()) { $path = sprintf("/tags/%s/tasks", $tag); return $this->client->getCollection($path, $params, $options); }
php
public function findByTag($tag, $params = array(), $options = array()) { $path = sprintf("/tags/%s/tasks", $tag); return $this->client->getCollection($path, $params, $options); }
[ "public", "function", "findByTag", "(", "$", "tag", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/tags/%s/tasks\"", ",", "$", "tag", ")", ";", "return", "$",...
Returns the compact task records for all tasks with the given tag. @param tag The tag in which to search for tasks. @return response
[ "Returns", "the", "compact", "task", "records", "for", "all", "tasks", "with", "the", "given", "tag", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/TasksBase.php#L126-L130
train
Asana/php-asana
src/Asana/Resources/Gen/TasksBase.php
TasksBase.projects
public function projects($task, $params = array(), $options = array()) { $path = sprintf("/tasks/%s/projects", $task); return $this->client->getCollection($path, $params, $options); }
php
public function projects($task, $params = array(), $options = array()) { $path = sprintf("/tasks/%s/projects", $task); return $this->client->getCollection($path, $params, $options); }
[ "public", "function", "projects", "(", "$", "task", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/tasks/%s/projects\"", ",", "$", "task", ")", ";", "return", ...
Returns a compact representation of all of the projects the task is in. @param task The task to get projects on. @return response
[ "Returns", "a", "compact", "representation", "of", "all", "of", "the", "projects", "the", "task", "is", "in", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/TasksBase.php#L274-L278
train
Asana/php-asana
src/Asana/Resources/Gen/TeamsBase.php
TeamsBase.findByOrganization
public function findByOrganization($organization, $params = array(), $options = array()) { $path = sprintf("/organizations/%s/teams", $organization); return $this->client->getCollection($path, $params, $options); }
php
public function findByOrganization($organization, $params = array(), $options = array()) { $path = sprintf("/organizations/%s/teams", $organization); return $this->client->getCollection($path, $params, $options); }
[ "public", "function", "findByOrganization", "(", "$", "organization", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/organizations/%s/teams\"", ",", "$", "organizatio...
Returns the compact records for all teams in the organization visible to the authorized user. @param organization Globally unique identifier for the workspace or organization. @return response
[ "Returns", "the", "compact", "records", "for", "all", "teams", "in", "the", "organization", "visible", "to", "the", "authorized", "user", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/TeamsBase.php#L38-L42
train
Asana/php-asana
src/Asana/Resources/Gen/TeamsBase.php
TeamsBase.findByUser
public function findByUser($user, $params = array(), $options = array()) { $path = sprintf("/users/%s/teams", $user); return $this->client->getCollection($path, $params, $options); }
php
public function findByUser($user, $params = array(), $options = array()) { $path = sprintf("/users/%s/teams", $user); return $this->client->getCollection($path, $params, $options); }
[ "public", "function", "findByUser", "(", "$", "user", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/users/%s/teams\"", ",", "$", "user", ")", ";", "return", ...
Returns the compact records for all teams to which user is assigned. @param user An identifier for the user. Can be one of an email address, the globally unique identifier for the user, or the keyword `me` to indicate the current user making the request. @return response
[ "Returns", "the", "compact", "records", "for", "all", "teams", "to", "which", "user", "is", "assigned", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/TeamsBase.php#L52-L56
train
Asana/php-asana
src/Asana/Resources/Gen/TeamsBase.php
TeamsBase.users
public function users($team, $params = array(), $options = array()) { $path = sprintf("/teams/%s/users", $team); return $this->client->getCollection($path, $params, $options); }
php
public function users($team, $params = array(), $options = array()) { $path = sprintf("/teams/%s/users", $team); return $this->client->getCollection($path, $params, $options); }
[ "public", "function", "users", "(", "$", "team", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/teams/%s/users\"", ",", "$", "team", ")", ";", "return", "$", ...
Returns the compact records for all users that are members of the team. @param team Globally unique identifier for the team. @return response
[ "Returns", "the", "compact", "records", "for", "all", "users", "that", "are", "members", "of", "the", "team", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/TeamsBase.php#L64-L68
train
Asana/php-asana
src/Asana/Resources/Gen/WebhooksBase.php
WebhooksBase.getById
public function getById($webhook, $params = array(), $options = array()) { $path = sprintf("/webhooks/%s", $webhook); return $this->client->get($path, $params, $options); }
php
public function getById($webhook, $params = array(), $options = array()) { $path = sprintf("/webhooks/%s", $webhook); return $this->client->get($path, $params, $options); }
[ "public", "function", "getById", "(", "$", "webhook", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/webhooks/%s\"", ",", "$", "webhook", ")", ";", "return", ...
Returns the full record for the given webhook. @param webhook The webhook to get. @return response
[ "Returns", "the", "full", "record", "for", "the", "given", "webhook", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/WebhooksBase.php#L102-L106
train
Asana/php-asana
src/Asana/Resources/Gen/WebhooksBase.php
WebhooksBase.deleteById
public function deleteById($webhook, $params = array(), $options = array()) { $path = sprintf("/webhooks/%s", $webhook); return $this->client->delete($path, $params, $options); }
php
public function deleteById($webhook, $params = array(), $options = array()) { $path = sprintf("/webhooks/%s", $webhook); return $this->client->delete($path, $params, $options); }
[ "public", "function", "deleteById", "(", "$", "webhook", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/webhooks/%s\"", ",", "$", "webhook", ")", ";", "return",...
This method permanently removes a webhook. Note that it may be possible to receive a request that was already in flight after deleting the webhook, but no further requests will be issued. @param webhook The webhook to delete. @return response
[ "This", "method", "permanently", "removes", "a", "webhook", ".", "Note", "that", "it", "may", "be", "possible", "to", "receive", "a", "request", "that", "was", "already", "in", "flight", "after", "deleting", "the", "webhook", "but", "no", "further", "request...
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/WebhooksBase.php#L116-L120
train
Asana/php-asana
src/Asana/Resources/Gen/ProjectsBase.php
ProjectsBase.createInTeam
public function createInTeam($team, $params = array(), $options = array()) { $path = sprintf("/teams/%s/projects", $team); return $this->client->post($path, $params, $options); }
php
public function createInTeam($team, $params = array(), $options = array()) { $path = sprintf("/teams/%s/projects", $team); return $this->client->post($path, $params, $options); }
[ "public", "function", "createInTeam", "(", "$", "team", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/teams/%s/projects\"", ",", "$", "team", ")", ";", "return...
Creates a project shared with the given team. Returns the full record of the newly created project. @param team The team to create the project in. @return response
[ "Creates", "a", "project", "shared", "with", "the", "given", "team", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/ProjectsBase.php#L69-L73
train
Asana/php-asana
src/Asana/Resources/Gen/ProjectsBase.php
ProjectsBase.delete
public function delete($project, $params = array(), $options = array()) { $path = sprintf("/projects/%s", $project); return $this->client->delete($path, $params, $options); }
php
public function delete($project, $params = array(), $options = array()) { $path = sprintf("/projects/%s", $project); return $this->client->delete($path, $params, $options); }
[ "public", "function", "delete", "(", "$", "project", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/projects/%s\"", ",", "$", "project", ")", ";", "return", "...
A specific, existing project can be deleted by making a DELETE request on the URL for that project. Returns an empty data record. @param project The project to delete. @return response
[ "A", "specific", "existing", "project", "can", "be", "deleted", "by", "making", "a", "DELETE", "request", "on", "the", "URL", "for", "that", "project", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/ProjectsBase.php#L116-L120
train
Asana/php-asana
src/Asana/Resources/Gen/ProjectsBase.php
ProjectsBase.addFollowers
public function addFollowers($project, $params = array(), $options = array()) { $path = sprintf("/projects/%s/addFollowers", $project); return $this->client->post($path, $params, $options); }
php
public function addFollowers($project, $params = array(), $options = array()) { $path = sprintf("/projects/%s/addFollowers", $project); return $this->client->post($path, $params, $options); }
[ "public", "function", "addFollowers", "(", "$", "project", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/projects/%s/addFollowers\"", ",", "$", "project", ")", "...
Adds the specified list of users as followers to the project. Followers are a subset of members, therefore if the users are not already members of the project they will also become members as a result of this operation. Returns the updated project record. @param project The project to add followers to. @return response
[ "Adds", "the", "specified", "list", "of", "users", "as", "followers", "to", "the", "project", ".", "Followers", "are", "a", "subset", "of", "members", "therefore", "if", "the", "users", "are", "not", "already", "members", "of", "the", "project", "they", "w...
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/ProjectsBase.php#L178-L182
train
Asana/php-asana
src/Asana/Resources/Gen/SectionsBase.php
SectionsBase.delete
public function delete($section, $params = array(), $options = array()) { $path = sprintf("/sections/%s", $section); return $this->client->delete($path, $params, $options); }
php
public function delete($section, $params = array(), $options = array()) { $path = sprintf("/sections/%s", $section); return $this->client->delete($path, $params, $options); }
[ "public", "function", "delete", "(", "$", "section", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/sections/%s\"", ",", "$", "section", ")", ";", "return", "...
A specific, existing section can be deleted by making a DELETE request on the URL for that section. Note that sections must be empty to be deleted. The last remaining section in a board view cannot be deleted. Returns an empty data block. @param section The section to delete. @return response
[ "A", "specific", "existing", "section", "can", "be", "deleted", "by", "making", "a", "DELETE", "request", "on", "the", "URL", "for", "that", "section", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/SectionsBase.php#L92-L96
train
Asana/php-asana
src/Asana/Resources/Gen/TagsBase.php
TagsBase.createInWorkspace
public function createInWorkspace($workspace, $params = array(), $options = array()) { $path = sprintf("/workspaces/%s/tags", $workspace); return $this->client->post($path, $params, $options); }
php
public function createInWorkspace($workspace, $params = array(), $options = array()) { $path = sprintf("/workspaces/%s/tags", $workspace); return $this->client->post($path, $params, $options); }
[ "public", "function", "createInWorkspace", "(", "$", "workspace", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/workspaces/%s/tags\"", ",", "$", "workspace", ")", ...
Creates a new tag in a workspace or organization. Every tag is required to be created in a specific workspace or organization, and this cannot be changed once set. Note that you can use the `workspace` parameter regardless of whether or not it is an organization. Returns the full record of the newly created tag. @param workspace The workspace or organization to create the tag in. @return response
[ "Creates", "a", "new", "tag", "in", "a", "workspace", "or", "organization", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/TagsBase.php#L54-L58
train
Asana/php-asana
src/Asana/Resources/Gen/TagsBase.php
TagsBase.update
public function update($tag, $params = array(), $options = array()) { $path = sprintf("/tags/%s", $tag); return $this->client->put($path, $params, $options); }
php
public function update($tag, $params = array(), $options = array()) { $path = sprintf("/tags/%s", $tag); return $this->client->put($path, $params, $options); }
[ "public", "function", "update", "(", "$", "tag", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/tags/%s\"", ",", "$", "tag", ")", ";", "return", "$", "this"...
Updates the properties of a tag. Only the fields provided in the `data` block will be updated; any unspecified fields will remain unchanged. When using this method, it is best to specify only those fields you wish to change, or else you may overwrite changes made by another user since you last retrieved the task. Returns the complete updated tag record. @param tag The tag to update. @return response
[ "Updates", "the", "properties", "of", "a", "tag", ".", "Only", "the", "fields", "provided", "in", "the", "data", "block", "will", "be", "updated", ";", "any", "unspecified", "fields", "will", "remain", "unchanged", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/TagsBase.php#L85-L89
train
Asana/php-asana
src/Asana/Resources/Gen/TagsBase.php
TagsBase.delete
public function delete($tag, $params = array(), $options = array()) { $path = sprintf("/tags/%s", $tag); return $this->client->delete($path, $params, $options); }
php
public function delete($tag, $params = array(), $options = array()) { $path = sprintf("/tags/%s", $tag); return $this->client->delete($path, $params, $options); }
[ "public", "function", "delete", "(", "$", "tag", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "path", "=", "sprintf", "(", "\"/tags/%s\"", ",", "$", "tag", ")", ";", "return", "$", "this"...
A specific, existing tag can be deleted by making a DELETE request on the URL for that tag. Returns an empty data record. @param tag The tag to delete. @return response
[ "A", "specific", "existing", "tag", "can", "be", "deleted", "by", "making", "a", "DELETE", "request", "on", "the", "URL", "for", "that", "tag", "." ]
acee83043dbb1fb25c20c89abd44c8cb2911c021
https://github.com/Asana/php-asana/blob/acee83043dbb1fb25c20c89abd44c8cb2911c021/src/Asana/Resources/Gen/TagsBase.php#L100-L104
train
shivas/versioning-bundle
Formatter/GitDescribeFormatter.php
GitDescribeFormatter.format
public function format(Version $version) { if (preg_match('/^(\d+)-g([a-fA-F0-9]{7,40})(-dirty)?$/', $version->getPreRelease(), $matches)) { if ((int) $matches[1] != 0) { // we are not on TAG commit, add "dev" and git commit hash as pre release part $version = $version->withPreRelease(array('dev', $matches[2])); } else { $version = $version->withPreRelease(array()); } } if (preg_match('/^(.*)-(\d+)-g([a-fA-F0-9]{7,40})(-dirty)?$/', $version->getPreRelease(), $matches)) { if ((int) $matches[2] != 0) { // we are not on TAG commit, add "dev" and git commit hash as pre release part if (empty($matches[1])) { $version = $version->withPreRelease(array('dev', $matches[3])); } else { $version = $version->withPreRelease(array_merge(explode('.', trim($matches[1], '-')), array('dev', $matches[3]))); } } else { if (empty($matches[1])) { $version = $version->withPreRelease(array()); } else { $version = $version->withPreRelease(trim($matches[1], '-')); } } } return $version; }
php
public function format(Version $version) { if (preg_match('/^(\d+)-g([a-fA-F0-9]{7,40})(-dirty)?$/', $version->getPreRelease(), $matches)) { if ((int) $matches[1] != 0) { // we are not on TAG commit, add "dev" and git commit hash as pre release part $version = $version->withPreRelease(array('dev', $matches[2])); } else { $version = $version->withPreRelease(array()); } } if (preg_match('/^(.*)-(\d+)-g([a-fA-F0-9]{7,40})(-dirty)?$/', $version->getPreRelease(), $matches)) { if ((int) $matches[2] != 0) { // we are not on TAG commit, add "dev" and git commit hash as pre release part if (empty($matches[1])) { $version = $version->withPreRelease(array('dev', $matches[3])); } else { $version = $version->withPreRelease(array_merge(explode('.', trim($matches[1], '-')), array('dev', $matches[3]))); } } else { if (empty($matches[1])) { $version = $version->withPreRelease(array()); } else { $version = $version->withPreRelease(trim($matches[1], '-')); } } } return $version; }
[ "public", "function", "format", "(", "Version", "$", "version", ")", "{", "if", "(", "preg_match", "(", "'/^(\\d+)-g([a-fA-F0-9]{7,40})(-dirty)?$/'", ",", "$", "version", "->", "getPreRelease", "(", ")", ",", "$", "matches", ")", ")", "{", "if", "(", "(", ...
Remove hash on tag commit else put dev.hash in prerelease @param Version $version @return Version
[ "Remove", "hash", "on", "tag", "commit", "else", "put", "dev", ".", "hash", "in", "prerelease" ]
ff92fb096646a1330f1e72cdd8ed83a581079450
https://github.com/shivas/versioning-bundle/blob/ff92fb096646a1330f1e72cdd8ed83a581079450/Formatter/GitDescribeFormatter.php#L18-L47
train
shivas/versioning-bundle
Command/ListProvidersCommand.php
ListProvidersCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('Registered version providers'); $providers = $this->manager->getProviders(); $table = new Table($output); $table->setHeaders(array('Alias', 'Class', 'Priority', 'Supported')) ->setStyle('borderless'); foreach ($providers as $alias => $providerEntry) { /** @var $provider ProviderInterface */ $provider = $providerEntry['provider']; $supported = $provider->isSupported() ? 'Yes' : 'No'; $table->addRow(array($alias, get_class($provider), $providerEntry['priority'], $supported)); } $table->render(); }
php
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('Registered version providers'); $providers = $this->manager->getProviders(); $table = new Table($output); $table->setHeaders(array('Alias', 'Class', 'Priority', 'Supported')) ->setStyle('borderless'); foreach ($providers as $alias => $providerEntry) { /** @var $provider ProviderInterface */ $provider = $providerEntry['provider']; $supported = $provider->isSupported() ? 'Yes' : 'No'; $table->addRow(array($alias, get_class($provider), $providerEntry['priority'], $supported)); } $table->render(); }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "output", "->", "writeln", "(", "'Registered version providers'", ")", ";", "$", "providers", "=", "$", "this", "->", "manager", "->"...
List all registered version providers
[ "List", "all", "registered", "version", "providers" ]
ff92fb096646a1330f1e72cdd8ed83a581079450
https://github.com/shivas/versioning-bundle/blob/ff92fb096646a1330f1e72cdd8ed83a581079450/Command/ListProvidersCommand.php#L47-L64
train
shivas/versioning-bundle
Command/StatusCommand.php
StatusCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln(sprintf('Provider: <comment>%s</comment>', get_class($this->manager->getActiveProvider()))); $formatter = $this->manager->getFormatter(); if ($formatter instanceof FormatterInterface) { $output->writeln(sprintf('Formatter: <comment>%s</comment>', get_class($formatter))); } else { $output->writeln(sprintf('Formatter: <comment>%s</comment>', 'None')); } $version = $this->manager->getVersion(); $newVersion = $this->manager->getVersionFromProvider(); if ((string) $version == (string) $newVersion) { $output->writeln(sprintf('Current version: <info>%s</info>', $version)); } else { $output->writeln(sprintf('Current version: <error>%s</error>', $version)); $output->writeln(sprintf('New version: <info>%s</info>', $newVersion)); $output->writeln(sprintf('<comment>%s</comment>', 'Version outdated, please run the cache:clear command')); } }
php
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln(sprintf('Provider: <comment>%s</comment>', get_class($this->manager->getActiveProvider()))); $formatter = $this->manager->getFormatter(); if ($formatter instanceof FormatterInterface) { $output->writeln(sprintf('Formatter: <comment>%s</comment>', get_class($formatter))); } else { $output->writeln(sprintf('Formatter: <comment>%s</comment>', 'None')); } $version = $this->manager->getVersion(); $newVersion = $this->manager->getVersionFromProvider(); if ((string) $version == (string) $newVersion) { $output->writeln(sprintf('Current version: <info>%s</info>', $version)); } else { $output->writeln(sprintf('Current version: <error>%s</error>', $version)); $output->writeln(sprintf('New version: <info>%s</info>', $newVersion)); $output->writeln(sprintf('<comment>%s</comment>', 'Version outdated, please run the cache:clear command')); } }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "'Provider: <comment>%s</comment>'", ",", "get_class", "(", "$", "this", "->", "manager...
Show current application version status
[ "Show", "current", "application", "version", "status" ]
ff92fb096646a1330f1e72cdd8ed83a581079450
https://github.com/shivas/versioning-bundle/blob/ff92fb096646a1330f1e72cdd8ed83a581079450/Command/StatusCommand.php#L46-L66
train
shivas/versioning-bundle
Service/VersionManager.php
VersionManager.getActiveProvider
public function getActiveProvider() { if ($this->activeProvider instanceof ProviderInterface) { return $this->activeProvider; } if (empty($this->providers)) { throw new RuntimeException('No versioning provider found'); } foreach ($this->providers as $entry) { $provider = $entry['provider']; /** @var $provider ProviderInterface */ if ($provider->isSupported()) { $this->activeProvider = $provider; return $provider; } } throw new RuntimeException('No supported versioning providers found'); }
php
public function getActiveProvider() { if ($this->activeProvider instanceof ProviderInterface) { return $this->activeProvider; } if (empty($this->providers)) { throw new RuntimeException('No versioning provider found'); } foreach ($this->providers as $entry) { $provider = $entry['provider']; /** @var $provider ProviderInterface */ if ($provider->isSupported()) { $this->activeProvider = $provider; return $provider; } } throw new RuntimeException('No supported versioning providers found'); }
[ "public", "function", "getActiveProvider", "(", ")", "{", "if", "(", "$", "this", "->", "activeProvider", "instanceof", "ProviderInterface", ")", "{", "return", "$", "this", "->", "activeProvider", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "pro...
Returns the active provider @return ProviderInterface @throws RuntimeException
[ "Returns", "the", "active", "provider" ]
ff92fb096646a1330f1e72cdd8ed83a581079450
https://github.com/shivas/versioning-bundle/blob/ff92fb096646a1330f1e72cdd8ed83a581079450/Service/VersionManager.php#L101-L122
train
shivas/versioning-bundle
Service/VersionManager.php
VersionManager.writeVersion
public function writeVersion(Version $version) { $cacheItem = $this->cache->getItem('version'); $cacheItem->set($version); $this->cache->save($cacheItem); $this->writer->write($version); }
php
public function writeVersion(Version $version) { $cacheItem = $this->cache->getItem('version'); $cacheItem->set($version); $this->cache->save($cacheItem); $this->writer->write($version); }
[ "public", "function", "writeVersion", "(", "Version", "$", "version", ")", "{", "$", "cacheItem", "=", "$", "this", "->", "cache", "->", "getItem", "(", "'version'", ")", ";", "$", "cacheItem", "->", "set", "(", "$", "version", ")", ";", "$", "this", ...
Write a new version number to the cache and storage @param Version $version @throws InvalidArgumentException
[ "Write", "a", "new", "version", "number", "to", "the", "cache", "and", "storage" ]
ff92fb096646a1330f1e72cdd8ed83a581079450
https://github.com/shivas/versioning-bundle/blob/ff92fb096646a1330f1e72cdd8ed83a581079450/Service/VersionManager.php#L130-L137
train
shivas/versioning-bundle
Service/VersionManager.php
VersionManager.getVersion
public function getVersion() { $cacheItem = $this->cache->getItem('version'); if ($cacheItem->isHit()) { return $cacheItem->get(); } else { $version = $this->getVersionFromProvider(); $cacheItem->set($version); $this->cache->save($cacheItem); return $version; } }
php
public function getVersion() { $cacheItem = $this->cache->getItem('version'); if ($cacheItem->isHit()) { return $cacheItem->get(); } else { $version = $this->getVersionFromProvider(); $cacheItem->set($version); $this->cache->save($cacheItem); return $version; } }
[ "public", "function", "getVersion", "(", ")", "{", "$", "cacheItem", "=", "$", "this", "->", "cache", "->", "getItem", "(", "'version'", ")", ";", "if", "(", "$", "cacheItem", "->", "isHit", "(", ")", ")", "{", "return", "$", "cacheItem", "->", "get"...
Get the current application version @return Version @throws InvalidArgumentException
[ "Get", "the", "current", "application", "version" ]
ff92fb096646a1330f1e72cdd8ed83a581079450
https://github.com/shivas/versioning-bundle/blob/ff92fb096646a1330f1e72cdd8ed83a581079450/Service/VersionManager.php#L145-L157
train
shivas/versioning-bundle
Service/VersionManager.php
VersionManager.getVersionFromProvider
public function getVersionFromProvider() { $provider = $this->getActiveProvider(); try { $versionString = $provider->getVersion(); if (substr(strtolower($versionString), 0, 1) == 'v') { $versionString = substr($versionString, 1); } $version = Version::fromString($versionString); if ($this->formatter instanceof FormatterInterface) { $version = $this->formatter->format($version); } return $version; } catch (InvalidVersionStringException $e) { throw new RuntimeException(get_class($provider) . ' returned an invalid version'); } }
php
public function getVersionFromProvider() { $provider = $this->getActiveProvider(); try { $versionString = $provider->getVersion(); if (substr(strtolower($versionString), 0, 1) == 'v') { $versionString = substr($versionString, 1); } $version = Version::fromString($versionString); if ($this->formatter instanceof FormatterInterface) { $version = $this->formatter->format($version); } return $version; } catch (InvalidVersionStringException $e) { throw new RuntimeException(get_class($provider) . ' returned an invalid version'); } }
[ "public", "function", "getVersionFromProvider", "(", ")", "{", "$", "provider", "=", "$", "this", "->", "getActiveProvider", "(", ")", ";", "try", "{", "$", "versionString", "=", "$", "provider", "->", "getVersion", "(", ")", ";", "if", "(", "substr", "(...
Get the version from the active provider @return Version @throws RuntimeException
[ "Get", "the", "version", "from", "the", "active", "provider" ]
ff92fb096646a1330f1e72cdd8ed83a581079450
https://github.com/shivas/versioning-bundle/blob/ff92fb096646a1330f1e72cdd8ed83a581079450/Service/VersionManager.php#L165-L184
train
tengzhinei/rapphp
rpc/service/RpcHandlerAdapter.php
RpcHandlerAdapter._initialize
public function _initialize() { $config = Config::getFileConfig()[ 'rpc_service' ]; $this->config = array_merge($this->config, $config); }
php
public function _initialize() { $config = Config::getFileConfig()[ 'rpc_service' ]; $this->config = array_merge($this->config, $config); }
[ "public", "function", "_initialize", "(", ")", "{", "$", "config", "=", "Config", "::", "getFileConfig", "(", ")", "[", "'rpc_service'", "]", ";", "$", "this", "->", "config", "=", "array_merge", "(", "$", "this", "->", "config", ",", "$", "config", ")...
RpcInterceptor _initialize.
[ "RpcInterceptor", "_initialize", "." ]
491336cfcc09e051a42838df05f61ef1385b903b
https://github.com/tengzhinei/rapphp/blob/491336cfcc09e051a42838df05f61ef1385b903b/rpc/service/RpcHandlerAdapter.php#L28-L31
train
delight-im/PHP-Cookie
src/Session.php
Session.take
public static function take($key, $defaultValue = null) { if (isset($_SESSION[$key])) { $value = $_SESSION[$key]; unset($_SESSION[$key]); return $value; } else { return $defaultValue; } }
php
public static function take($key, $defaultValue = null) { if (isset($_SESSION[$key])) { $value = $_SESSION[$key]; unset($_SESSION[$key]); return $value; } else { return $defaultValue; } }
[ "public", "static", "function", "take", "(", "$", "key", ",", "$", "defaultValue", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "_SESSION", "[", "$", "key", "]", ")", ")", "{", "$", "value", "=", "$", "_SESSION", "[", "$", "key", "]", "...
Returns the requested value and removes it from the session This is identical to calling `get` first and then `remove` for the same key @param string $key the key to retrieve and remove the value for @param mixed $defaultValue the default value to return if the requested value cannot be found @return mixed the requested value or the default value
[ "Returns", "the", "requested", "value", "and", "removes", "it", "from", "the", "session" ]
b3ca3233dd1e1e91efb259b9b717a1c941d67ecc
https://github.com/delight-im/PHP-Cookie/blob/b3ca3233dd1e1e91efb259b9b717a1c941d67ecc/src/Session.php#L107-L118
train
delight-im/PHP-Cookie
src/Session.php
Session.rewriteCookieHeader
private static function rewriteCookieHeader($sameSiteRestriction = Cookie::SAME_SITE_RESTRICTION_LAX) { // get and remove the original cookie header set by PHP $originalCookieHeader = ResponseHeader::take('Set-Cookie', \session_name() . '='); // if a cookie header has been found if (isset($originalCookieHeader)) { // parse it into a cookie instance $parsedCookie = Cookie::parse($originalCookieHeader); // if the cookie has successfully been parsed if (isset($parsedCookie)) { // apply the supplied same-site restriction $parsedCookie->setSameSiteRestriction($sameSiteRestriction); // save the cookie $parsedCookie->save(); } } }
php
private static function rewriteCookieHeader($sameSiteRestriction = Cookie::SAME_SITE_RESTRICTION_LAX) { // get and remove the original cookie header set by PHP $originalCookieHeader = ResponseHeader::take('Set-Cookie', \session_name() . '='); // if a cookie header has been found if (isset($originalCookieHeader)) { // parse it into a cookie instance $parsedCookie = Cookie::parse($originalCookieHeader); // if the cookie has successfully been parsed if (isset($parsedCookie)) { // apply the supplied same-site restriction $parsedCookie->setSameSiteRestriction($sameSiteRestriction); // save the cookie $parsedCookie->save(); } } }
[ "private", "static", "function", "rewriteCookieHeader", "(", "$", "sameSiteRestriction", "=", "Cookie", "::", "SAME_SITE_RESTRICTION_LAX", ")", "{", "// get and remove the original cookie header set by PHP", "$", "originalCookieHeader", "=", "ResponseHeader", "::", "take", "(...
Intercepts and rewrites the session cookie header @param string|null $sameSiteRestriction indicates that the cookie should not be sent along with cross-site requests (either `null`, `Lax` or `Strict`)
[ "Intercepts", "and", "rewrites", "the", "session", "cookie", "header" ]
b3ca3233dd1e1e91efb259b9b717a1c941d67ecc
https://github.com/delight-im/PHP-Cookie/blob/b3ca3233dd1e1e91efb259b9b717a1c941d67ecc/src/Session.php#L146-L163
train
delight-im/PHP-Cookie
src/Cookie.php
Cookie.buildCookieHeader
public static function buildCookieHeader($name, $value = null, $expiryTime = 0, $path = null, $domain = null, $secureOnly = false, $httpOnly = false, $sameSiteRestriction = null) { if (self::isNameValid($name)) { $name = (string) $name; } else { return null; } if (self::isExpiryTimeValid($expiryTime)) { $expiryTime = (int) $expiryTime; } else { return null; } $forceShowExpiry = false; if (\is_null($value) || $value === false || $value === '') { $value = 'deleted'; $expiryTime = 0; $forceShowExpiry = true; } $maxAgeStr = self::formatMaxAge($expiryTime, $forceShowExpiry); $expiryTimeStr = self::formatExpiryTime($expiryTime, $forceShowExpiry); $headerStr = self::HEADER_PREFIX . $name . '=' . \urlencode($value); if (!\is_null($expiryTimeStr)) { $headerStr .= '; expires=' . $expiryTimeStr; } // The `Max-Age` property is supported on PHP 5.5+ only (https://bugs.php.net/bug.php?id=23955). if (\PHP_VERSION_ID >= 50500) { if (!\is_null($maxAgeStr)) { $headerStr .= '; Max-Age=' . $maxAgeStr; } } if (!empty($path) || $path === 0) { $headerStr .= '; path=' . $path; } if (!empty($domain) || $domain === 0) { $headerStr .= '; domain=' . $domain; } if ($secureOnly) { $headerStr .= '; secure'; } if ($httpOnly) { $headerStr .= '; httponly'; } if ($sameSiteRestriction === self::SAME_SITE_RESTRICTION_LAX) { $headerStr .= '; SameSite=Lax'; } elseif ($sameSiteRestriction === self::SAME_SITE_RESTRICTION_STRICT) { $headerStr .= '; SameSite=Strict'; } return $headerStr; }
php
public static function buildCookieHeader($name, $value = null, $expiryTime = 0, $path = null, $domain = null, $secureOnly = false, $httpOnly = false, $sameSiteRestriction = null) { if (self::isNameValid($name)) { $name = (string) $name; } else { return null; } if (self::isExpiryTimeValid($expiryTime)) { $expiryTime = (int) $expiryTime; } else { return null; } $forceShowExpiry = false; if (\is_null($value) || $value === false || $value === '') { $value = 'deleted'; $expiryTime = 0; $forceShowExpiry = true; } $maxAgeStr = self::formatMaxAge($expiryTime, $forceShowExpiry); $expiryTimeStr = self::formatExpiryTime($expiryTime, $forceShowExpiry); $headerStr = self::HEADER_PREFIX . $name . '=' . \urlencode($value); if (!\is_null($expiryTimeStr)) { $headerStr .= '; expires=' . $expiryTimeStr; } // The `Max-Age` property is supported on PHP 5.5+ only (https://bugs.php.net/bug.php?id=23955). if (\PHP_VERSION_ID >= 50500) { if (!\is_null($maxAgeStr)) { $headerStr .= '; Max-Age=' . $maxAgeStr; } } if (!empty($path) || $path === 0) { $headerStr .= '; path=' . $path; } if (!empty($domain) || $domain === 0) { $headerStr .= '; domain=' . $domain; } if ($secureOnly) { $headerStr .= '; secure'; } if ($httpOnly) { $headerStr .= '; httponly'; } if ($sameSiteRestriction === self::SAME_SITE_RESTRICTION_LAX) { $headerStr .= '; SameSite=Lax'; } elseif ($sameSiteRestriction === self::SAME_SITE_RESTRICTION_STRICT) { $headerStr .= '; SameSite=Strict'; } return $headerStr; }
[ "public", "static", "function", "buildCookieHeader", "(", "$", "name", ",", "$", "value", "=", "null", ",", "$", "expiryTime", "=", "0", ",", "$", "path", "=", "null", ",", "$", "domain", "=", "null", ",", "$", "secureOnly", "=", "false", ",", "$", ...
Builds the HTTP header that can be used to set a cookie with the specified options @param string $name the name of the cookie which is also the key for future accesses via `$_COOKIE[...]` @param mixed|null $value the value of the cookie that will be stored on the client's machine @param int $expiryTime the Unix timestamp indicating the time that the cookie will expire at, i.e. usually `time() + $seconds` @param string|null $path the path on the server that the cookie will be valid for (including all sub-directories), e.g. an empty string for the current directory or `/` for the root directory @param string|null $domain the domain that the cookie will be valid for (including subdomains) or `null` for the current host (excluding subdomains) @param bool $secureOnly indicates that the cookie should be sent back by the client over secure HTTPS connections only @param bool $httpOnly indicates that the cookie should be accessible through the HTTP protocol only and not through scripting languages @param string|null $sameSiteRestriction indicates that the cookie should not be sent along with cross-site requests (either `null`, `Lax` or `Strict`) @return string the HTTP header
[ "Builds", "the", "HTTP", "header", "that", "can", "be", "used", "to", "set", "a", "cookie", "with", "the", "specified", "options" ]
b3ca3233dd1e1e91efb259b9b717a1c941d67ecc
https://github.com/delight-im/PHP-Cookie/blob/b3ca3233dd1e1e91efb259b9b717a1c941d67ecc/src/Cookie.php#L304-L367
train
delight-im/PHP-Cookie
src/Cookie.php
Cookie.parse
public static function parse($cookieHeader) { if (empty($cookieHeader)) { return null; } if (\preg_match('/^' . self::HEADER_PREFIX . '(.*?)=(.*?)(?:; (.*?))?$/i', $cookieHeader, $matches)) { $cookie = new self($matches[1]); $cookie->setPath(null); $cookie->setHttpOnly(false); $cookie->setValue( \urldecode($matches[2]) ); $cookie->setSameSiteRestriction(null); if (\count($matches) >= 4) { $attributes = \explode('; ', $matches[3]); foreach ($attributes as $attribute) { if (\strcasecmp($attribute, 'HttpOnly') === 0) { $cookie->setHttpOnly(true); } elseif (\strcasecmp($attribute, 'Secure') === 0) { $cookie->setSecureOnly(true); } elseif (\stripos($attribute, 'Expires=') === 0) { $cookie->setExpiryTime((int) \strtotime(\substr($attribute, 8))); } elseif (\stripos($attribute, 'Domain=') === 0) { $cookie->setDomain(\substr($attribute, 7)); } elseif (\stripos($attribute, 'Path=') === 0) { $cookie->setPath(\substr($attribute, 5)); } elseif (\stripos($attribute, 'SameSite=') === 0) { $cookie->setSameSiteRestriction(\substr($attribute, 9)); } } } return $cookie; } else { return null; } }
php
public static function parse($cookieHeader) { if (empty($cookieHeader)) { return null; } if (\preg_match('/^' . self::HEADER_PREFIX . '(.*?)=(.*?)(?:; (.*?))?$/i', $cookieHeader, $matches)) { $cookie = new self($matches[1]); $cookie->setPath(null); $cookie->setHttpOnly(false); $cookie->setValue( \urldecode($matches[2]) ); $cookie->setSameSiteRestriction(null); if (\count($matches) >= 4) { $attributes = \explode('; ', $matches[3]); foreach ($attributes as $attribute) { if (\strcasecmp($attribute, 'HttpOnly') === 0) { $cookie->setHttpOnly(true); } elseif (\strcasecmp($attribute, 'Secure') === 0) { $cookie->setSecureOnly(true); } elseif (\stripos($attribute, 'Expires=') === 0) { $cookie->setExpiryTime((int) \strtotime(\substr($attribute, 8))); } elseif (\stripos($attribute, 'Domain=') === 0) { $cookie->setDomain(\substr($attribute, 7)); } elseif (\stripos($attribute, 'Path=') === 0) { $cookie->setPath(\substr($attribute, 5)); } elseif (\stripos($attribute, 'SameSite=') === 0) { $cookie->setSameSiteRestriction(\substr($attribute, 9)); } } } return $cookie; } else { return null; } }
[ "public", "static", "function", "parse", "(", "$", "cookieHeader", ")", "{", "if", "(", "empty", "(", "$", "cookieHeader", ")", ")", "{", "return", "null", ";", "}", "if", "(", "\\", "preg_match", "(", "'/^'", ".", "self", "::", "HEADER_PREFIX", ".", ...
Parses the given cookie header and returns an equivalent cookie instance @param string $cookieHeader the cookie header to parse @return \Delight\Cookie\Cookie|null the cookie instance or `null`
[ "Parses", "the", "given", "cookie", "header", "and", "returns", "an", "equivalent", "cookie", "instance" ]
b3ca3233dd1e1e91efb259b9b717a1c941d67ecc
https://github.com/delight-im/PHP-Cookie/blob/b3ca3233dd1e1e91efb259b9b717a1c941d67ecc/src/Cookie.php#L375-L419
train
delight-im/PHP-Cookie
src/Cookie.php
Cookie.get
public static function get($name, $defaultValue = null) { if (isset($_COOKIE[$name])) { return $_COOKIE[$name]; } else { return $defaultValue; } }
php
public static function get($name, $defaultValue = null) { if (isset($_COOKIE[$name])) { return $_COOKIE[$name]; } else { return $defaultValue; } }
[ "public", "static", "function", "get", "(", "$", "name", ",", "$", "defaultValue", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "_COOKIE", "[", "$", "name", "]", ")", ")", "{", "return", "$", "_COOKIE", "[", "$", "name", "]", ";", "}", ...
Returns the value from the requested cookie or, if not found, the specified default value @param string $name the name of the cookie to retrieve the value from @param mixed $defaultValue the default value to return if the requested cookie cannot be found @return mixed the value from the requested cookie or the default value
[ "Returns", "the", "value", "from", "the", "requested", "cookie", "or", "if", "not", "found", "the", "specified", "default", "value" ]
b3ca3233dd1e1e91efb259b9b717a1c941d67ecc
https://github.com/delight-im/PHP-Cookie/blob/b3ca3233dd1e1e91efb259b9b717a1c941d67ecc/src/Cookie.php#L438-L445
train
Azure/azure-sdk-for-php
src/MediaServices/Models/ContentKeyAuthorizationPolicyOption.php
ContentKeyAuthorizationPolicyOption.fromArray
public function fromArray($options) { if (isset($options['Id'])) { Validate::isString($options['Id'], 'options[Id]'); $this->_id = $options['Id']; } if (isset($options['Name'])) { Validate::isString($options['Name'], 'options[Name]'); $this->_name = $options['Name']; } if (isset($options['KeyDeliveryType'])) { Validate::isInteger($options['KeyDeliveryType'], 'options[KeyDeliveryType]'); $this->_keyDeliveryType = $options['KeyDeliveryType']; } if (isset($options['KeyDeliveryConfiguration'])) { Validate::isString($options['KeyDeliveryConfiguration'], 'options[KeyDeliveryConfiguration]'); $this->_keyDeliveryConfiguration = $options['KeyDeliveryConfiguration']; } if (!empty($options['Restrictions'])) { Validate::isArray($options['Restrictions'], 'options[Restrictions]'); foreach ($options['Restrictions'] as $restriction) { $this->_restrictions[] = ContentKeyAuthorizationPolicyRestriction::createFromOptions($restriction); } } }
php
public function fromArray($options) { if (isset($options['Id'])) { Validate::isString($options['Id'], 'options[Id]'); $this->_id = $options['Id']; } if (isset($options['Name'])) { Validate::isString($options['Name'], 'options[Name]'); $this->_name = $options['Name']; } if (isset($options['KeyDeliveryType'])) { Validate::isInteger($options['KeyDeliveryType'], 'options[KeyDeliveryType]'); $this->_keyDeliveryType = $options['KeyDeliveryType']; } if (isset($options['KeyDeliveryConfiguration'])) { Validate::isString($options['KeyDeliveryConfiguration'], 'options[KeyDeliveryConfiguration]'); $this->_keyDeliveryConfiguration = $options['KeyDeliveryConfiguration']; } if (!empty($options['Restrictions'])) { Validate::isArray($options['Restrictions'], 'options[Restrictions]'); foreach ($options['Restrictions'] as $restriction) { $this->_restrictions[] = ContentKeyAuthorizationPolicyRestriction::createFromOptions($restriction); } } }
[ "public", "function", "fromArray", "(", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'Id'", "]", ")", ")", "{", "Validate", "::", "isString", "(", "$", "options", "[", "'Id'", "]", ",", "'options[Id]'", ")", ";", "$", "t...
Fill ContentKeyAuthorizationPolicyOption from array. @param array $options Array containing values for object properties
[ "Fill", "ContentKeyAuthorizationPolicyOption", "from", "array", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Models/ContentKeyAuthorizationPolicyOption.php#L118-L146
train
Azure/azure-sdk-for-php
src/Common/Internal/ServiceBusSettings.php
ServiceBusSettings.createFromConnectionString
public static function createFromConnectionString($connectionString) { $tokenizedSettings = self::parseAndValidateKeys($connectionString); if (array_key_exists(Resources::SHARED_SHARED_ACCESS_KEY_NAME, $tokenizedSettings)) { return self::createServiceBusWithSasAuthentication($tokenizedSettings, $connectionString); } return self::createServiceBusWithWrapAuthentication($tokenizedSettings, $connectionString); }
php
public static function createFromConnectionString($connectionString) { $tokenizedSettings = self::parseAndValidateKeys($connectionString); if (array_key_exists(Resources::SHARED_SHARED_ACCESS_KEY_NAME, $tokenizedSettings)) { return self::createServiceBusWithSasAuthentication($tokenizedSettings, $connectionString); } return self::createServiceBusWithWrapAuthentication($tokenizedSettings, $connectionString); }
[ "public", "static", "function", "createFromConnectionString", "(", "$", "connectionString", ")", "{", "$", "tokenizedSettings", "=", "self", "::", "parseAndValidateKeys", "(", "$", "connectionString", ")", ";", "if", "(", "array_key_exists", "(", "Resources", "::", ...
Creates a ServiceBusSettings object from the given connection string. @param string $connectionString The storage settings connection string @return ServiceBusSettings|void
[ "Creates", "a", "ServiceBusSettings", "object", "from", "the", "given", "connection", "string", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/ServiceBusSettings.php#L290-L297
train
Azure/azure-sdk-for-php
src/Common/Internal/Http/Url.php
Url.appendUrlPath
public function appendUrlPath($urlPath) { Validate::isString($urlPath, 'urlPath'); $newUrlPath = parse_url($this->_url, PHP_URL_PATH).$urlPath; $this->_url->setPath($newUrlPath); }
php
public function appendUrlPath($urlPath) { Validate::isString($urlPath, 'urlPath'); $newUrlPath = parse_url($this->_url, PHP_URL_PATH).$urlPath; $this->_url->setPath($newUrlPath); }
[ "public", "function", "appendUrlPath", "(", "$", "urlPath", ")", "{", "Validate", "::", "isString", "(", "$", "urlPath", ",", "'urlPath'", ")", ";", "$", "newUrlPath", "=", "parse_url", "(", "$", "this", "->", "_url", ",", "PHP_URL_PATH", ")", ".", "$", ...
Appends url path. @param string $urlPath url path to append
[ "Appends", "url", "path", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/Http/Url.php#L149-L155
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.sendMessage
public function sendMessage($path, BrokeredMessage $brokeredMessage) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_POST); $httpCallContext->addStatusCode(Resources::STATUS_CREATED); $httpCallContext->setPath($path); $contentType = $brokeredMessage->getContentType(); if (!is_null($contentType)) { $httpCallContext->addHeader( Resources::CONTENT_TYPE, $contentType ); } $brokerProperties = $brokeredMessage->getBrokerProperties(); if (!is_null($brokerProperties)) { $httpCallContext->addHeader( Resources::BROKER_PROPERTIES, $brokerProperties->toString() ); } $customProperties = $brokeredMessage->getProperties(); if (!empty($customProperties)) { foreach ($customProperties as $key => $value) { $value = json_encode($value); $httpCallContext->addHeader($key, $value); } } $httpCallContext->setBody($brokeredMessage->getBody()); $this->sendHttpContext($httpCallContext); }
php
public function sendMessage($path, BrokeredMessage $brokeredMessage) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_POST); $httpCallContext->addStatusCode(Resources::STATUS_CREATED); $httpCallContext->setPath($path); $contentType = $brokeredMessage->getContentType(); if (!is_null($contentType)) { $httpCallContext->addHeader( Resources::CONTENT_TYPE, $contentType ); } $brokerProperties = $brokeredMessage->getBrokerProperties(); if (!is_null($brokerProperties)) { $httpCallContext->addHeader( Resources::BROKER_PROPERTIES, $brokerProperties->toString() ); } $customProperties = $brokeredMessage->getProperties(); if (!empty($customProperties)) { foreach ($customProperties as $key => $value) { $value = json_encode($value); $httpCallContext->addHeader($key, $value); } } $httpCallContext->setBody($brokeredMessage->getBody()); $this->sendHttpContext($httpCallContext); }
[ "public", "function", "sendMessage", "(", "$", "path", ",", "BrokeredMessage", "$", "brokeredMessage", ")", "{", "$", "httpCallContext", "=", "new", "HttpCallContext", "(", ")", ";", "$", "httpCallContext", "->", "setMethod", "(", "Resources", "::", "HTTP_POST",...
Sends a brokered message. Queues: @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780775 Topic Subscriptions: @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780786 @param string $path The path to send message @param BrokeredMessage $brokeredMessage The brokered message
[ "Sends", "a", "brokered", "message", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L103-L136
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.sendQueueMessage
public function sendQueueMessage($queueName, BrokeredMessage $brokeredMessage) { $path = sprintf(Resources::SEND_MESSAGE_PATH, $queueName); $this->sendMessage($path, $brokeredMessage); }
php
public function sendQueueMessage($queueName, BrokeredMessage $brokeredMessage) { $path = sprintf(Resources::SEND_MESSAGE_PATH, $queueName); $this->sendMessage($path, $brokeredMessage); }
[ "public", "function", "sendQueueMessage", "(", "$", "queueName", ",", "BrokeredMessage", "$", "brokeredMessage", ")", "{", "$", "path", "=", "sprintf", "(", "Resources", "::", "SEND_MESSAGE_PATH", ",", "$", "queueName", ")", ";", "$", "this", "->", "sendMessag...
Sends a queue message. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780775 @param string $queueName The name of the queue @param BrokeredMessage $brokeredMessage The brokered message
[ "Sends", "a", "queue", "message", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L146-L150
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.receiveQueueMessage
public function receiveQueueMessage( $queueName, ReceiveMessageOptions $receiveMessageOptions = null ) { $queueMessagePath = sprintf(Resources::RECEIVE_MESSAGE_PATH, $queueName); return $this->receiveMessage( $queueMessagePath, $receiveMessageOptions ); }
php
public function receiveQueueMessage( $queueName, ReceiveMessageOptions $receiveMessageOptions = null ) { $queueMessagePath = sprintf(Resources::RECEIVE_MESSAGE_PATH, $queueName); return $this->receiveMessage( $queueMessagePath, $receiveMessageOptions ); }
[ "public", "function", "receiveQueueMessage", "(", "$", "queueName", ",", "ReceiveMessageOptions", "$", "receiveMessageOptions", "=", "null", ")", "{", "$", "queueMessagePath", "=", "sprintf", "(", "Resources", "::", "RECEIVE_MESSAGE_PATH", ",", "$", "queueName", ")"...
Receives a queue message. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780735 @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780756 @param string $queueName The name of the queue @param ReceiveMessageOptions|null $receiveMessageOptions The options to receive the message @return BrokeredMessage
[ "Receives", "a", "queue", "message", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L165-L175
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.receiveMessage
public function receiveMessage($path, ReceiveMessageOptions $receiveMessageOptions = null) { if (is_null($receiveMessageOptions)) { $receiveMessageOptions = new ReceiveMessageOptions(); } $httpCallContext = new HttpCallContext(); $httpCallContext->setPath($path); $httpCallContext->addStatusCode(Resources::STATUS_CREATED); $httpCallContext->addStatusCode(Resources::STATUS_NO_CONTENT); $httpCallContext->addStatusCode(Resources::STATUS_OK); $timeout = $receiveMessageOptions->getTimeout(); if (!is_null($timeout)) { $httpCallContext->addQueryParameter('timeout', $timeout); } if ($receiveMessageOptions->getIsReceiveAndDelete()) { $httpCallContext->setMethod(Resources::HTTP_DELETE); } elseif ($receiveMessageOptions->getIsPeekLock()) { $httpCallContext->setMethod(Resources::HTTP_POST); } else { throw new \InvalidArgumentException( Resources::INVALID_RECEIVE_MODE_MSG ); } $response = $this->sendHttpContext($httpCallContext); if ($response->getStatusCode() === Resources::STATUS_NO_CONTENT) { $brokeredMessage = null; } else { $responseHeaders = HttpClient::getResponseHeaders($response); $brokerProperties = new BrokerProperties(); if (array_key_exists('brokerproperties', $responseHeaders)) { $brokerProperties = BrokerProperties::create($responseHeaders['brokerproperties']); } if (array_key_exists('location', $responseHeaders)) { $brokerProperties->setLockLocation($responseHeaders['location']); } $brokeredMessage = new BrokeredMessage(); $brokeredMessage->setBrokerProperties($brokerProperties); if (array_key_exists(Resources::CONTENT_TYPE, $responseHeaders)) { $brokeredMessage->setContentType($responseHeaders[Resources::CONTENT_TYPE]); } if (array_key_exists('date', $responseHeaders)) { $brokeredMessage->setDate($responseHeaders['date']); } $brokeredMessage->setBody($response->getBody()); foreach ($responseHeaders as $headerKey => $value) { $decodedValue = json_decode($value); if (is_scalar($decodedValue)) { $brokeredMessage->setProperty( $headerKey, $decodedValue ); } } } return $brokeredMessage; }
php
public function receiveMessage($path, ReceiveMessageOptions $receiveMessageOptions = null) { if (is_null($receiveMessageOptions)) { $receiveMessageOptions = new ReceiveMessageOptions(); } $httpCallContext = new HttpCallContext(); $httpCallContext->setPath($path); $httpCallContext->addStatusCode(Resources::STATUS_CREATED); $httpCallContext->addStatusCode(Resources::STATUS_NO_CONTENT); $httpCallContext->addStatusCode(Resources::STATUS_OK); $timeout = $receiveMessageOptions->getTimeout(); if (!is_null($timeout)) { $httpCallContext->addQueryParameter('timeout', $timeout); } if ($receiveMessageOptions->getIsReceiveAndDelete()) { $httpCallContext->setMethod(Resources::HTTP_DELETE); } elseif ($receiveMessageOptions->getIsPeekLock()) { $httpCallContext->setMethod(Resources::HTTP_POST); } else { throw new \InvalidArgumentException( Resources::INVALID_RECEIVE_MODE_MSG ); } $response = $this->sendHttpContext($httpCallContext); if ($response->getStatusCode() === Resources::STATUS_NO_CONTENT) { $brokeredMessage = null; } else { $responseHeaders = HttpClient::getResponseHeaders($response); $brokerProperties = new BrokerProperties(); if (array_key_exists('brokerproperties', $responseHeaders)) { $brokerProperties = BrokerProperties::create($responseHeaders['brokerproperties']); } if (array_key_exists('location', $responseHeaders)) { $brokerProperties->setLockLocation($responseHeaders['location']); } $brokeredMessage = new BrokeredMessage(); $brokeredMessage->setBrokerProperties($brokerProperties); if (array_key_exists(Resources::CONTENT_TYPE, $responseHeaders)) { $brokeredMessage->setContentType($responseHeaders[Resources::CONTENT_TYPE]); } if (array_key_exists('date', $responseHeaders)) { $brokeredMessage->setDate($responseHeaders['date']); } $brokeredMessage->setBody($response->getBody()); foreach ($responseHeaders as $headerKey => $value) { $decodedValue = json_decode($value); if (is_scalar($decodedValue)) { $brokeredMessage->setProperty( $headerKey, $decodedValue ); } } } return $brokeredMessage; }
[ "public", "function", "receiveMessage", "(", "$", "path", ",", "ReceiveMessageOptions", "$", "receiveMessageOptions", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "receiveMessageOptions", ")", ")", "{", "$", "receiveMessageOptions", "=", "new", "Receiv...
Receives a message. Queues: @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780735 @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780756 Topic Subscriptions: @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780722 @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780770 @param string $path The path of the message @param ReceiveMessageOptions $receiveMessageOptions The options to receive the message @return BrokeredMessage
[ "Receives", "a", "message", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L198-L265
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.sendTopicMessage
public function sendTopicMessage($topicName, BrokeredMessage $brokeredMessage) { $topicMessagePath = sprintf(Resources::SEND_MESSAGE_PATH, $topicName); $this->sendMessage($topicMessagePath, $brokeredMessage); }
php
public function sendTopicMessage($topicName, BrokeredMessage $brokeredMessage) { $topicMessagePath = sprintf(Resources::SEND_MESSAGE_PATH, $topicName); $this->sendMessage($topicMessagePath, $brokeredMessage); }
[ "public", "function", "sendTopicMessage", "(", "$", "topicName", ",", "BrokeredMessage", "$", "brokeredMessage", ")", "{", "$", "topicMessagePath", "=", "sprintf", "(", "Resources", "::", "SEND_MESSAGE_PATH", ",", "$", "topicName", ")", ";", "$", "this", "->", ...
Sends a brokered message to a specified topic. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780786 @param string $topicName The name of the topic @param BrokeredMessage $brokeredMessage The brokered message
[ "Sends", "a", "brokered", "message", "to", "a", "specified", "topic", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L277-L281
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.receiveSubscriptionMessage
public function receiveSubscriptionMessage( $topicName, $subscriptionName, ReceiveMessageOptions $receiveMessageOptions = null ) { $messagePath = sprintf( Resources::RECEIVE_SUBSCRIPTION_MESSAGE_PATH, $topicName, $subscriptionName ); $brokeredMessage = $this->receiveMessage( $messagePath, $receiveMessageOptions ); return $brokeredMessage; }
php
public function receiveSubscriptionMessage( $topicName, $subscriptionName, ReceiveMessageOptions $receiveMessageOptions = null ) { $messagePath = sprintf( Resources::RECEIVE_SUBSCRIPTION_MESSAGE_PATH, $topicName, $subscriptionName ); $brokeredMessage = $this->receiveMessage( $messagePath, $receiveMessageOptions ); return $brokeredMessage; }
[ "public", "function", "receiveSubscriptionMessage", "(", "$", "topicName", ",", "$", "subscriptionName", ",", "ReceiveMessageOptions", "$", "receiveMessageOptions", "=", "null", ")", "{", "$", "messagePath", "=", "sprintf", "(", "Resources", "::", "RECEIVE_SUBSCRIPTIO...
Receives a subscription message. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780722 @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780770 @param string $topicName The name of the topic @param string $subscriptionName The name of the subscription @param ReceiveMessageOptions|null $receiveMessageOptions The options to receive the subscription message @return BrokeredMessage
[ "Receives", "a", "subscription", "message", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L298-L315
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.unlockMessage
public function unlockMessage(BrokeredMessage $brokeredMessage) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_PUT); $lockLocation = $brokeredMessage->getLockLocation(); $lockLocationArray = parse_url($lockLocation); $lockLocationPath = Resources::EMPTY_STRING; if (array_key_exists(Resources::PHP_URL_PATH, $lockLocationArray)) { $lockLocationPath = $lockLocationArray[Resources::PHP_URL_PATH]; $lockLocationPath = preg_replace( '@^\/@', Resources::EMPTY_STRING, $lockLocationPath ); } $httpCallContext->setPath($lockLocationPath); $httpCallContext->addStatusCode(Resources::STATUS_OK); $this->sendHttpContext($httpCallContext); }
php
public function unlockMessage(BrokeredMessage $brokeredMessage) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_PUT); $lockLocation = $brokeredMessage->getLockLocation(); $lockLocationArray = parse_url($lockLocation); $lockLocationPath = Resources::EMPTY_STRING; if (array_key_exists(Resources::PHP_URL_PATH, $lockLocationArray)) { $lockLocationPath = $lockLocationArray[Resources::PHP_URL_PATH]; $lockLocationPath = preg_replace( '@^\/@', Resources::EMPTY_STRING, $lockLocationPath ); } $httpCallContext->setPath($lockLocationPath); $httpCallContext->addStatusCode(Resources::STATUS_OK); $this->sendHttpContext($httpCallContext); }
[ "public", "function", "unlockMessage", "(", "BrokeredMessage", "$", "brokeredMessage", ")", "{", "$", "httpCallContext", "=", "new", "HttpCallContext", "(", ")", ";", "$", "httpCallContext", "->", "setMethod", "(", "Resources", "::", "HTTP_PUT", ")", ";", "$", ...
Unlocks a brokered message. Queues: @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780723 Topic Subscriptions: @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780737 @param BrokeredMessage $brokeredMessage The brokered message
[ "Unlocks", "a", "brokered", "message", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L329-L349
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.deleteMessage
public function deleteMessage(BrokeredMessage $brokeredMessage) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_DELETE); $lockLocation = $brokeredMessage->getLockLocation(); $lockLocationArray = parse_url($lockLocation); $lockLocationPath = Resources::EMPTY_STRING; if (array_key_exists(Resources::PHP_URL_PATH, $lockLocationArray)) { $lockLocationPath = $lockLocationArray[Resources::PHP_URL_PATH]; $lockLocationPath = preg_replace( '@^\/@', Resources::EMPTY_STRING, $lockLocationPath ); } if (empty($lockLocationPath)) { throw new \InvalidArgumentException( Resources::MISSING_LOCK_LOCATION_MSG ); } $httpCallContext->setPath($lockLocationPath); $httpCallContext->addStatusCode(Resources::STATUS_OK); $this->sendHttpContext($httpCallContext); }
php
public function deleteMessage(BrokeredMessage $brokeredMessage) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_DELETE); $lockLocation = $brokeredMessage->getLockLocation(); $lockLocationArray = parse_url($lockLocation); $lockLocationPath = Resources::EMPTY_STRING; if (array_key_exists(Resources::PHP_URL_PATH, $lockLocationArray)) { $lockLocationPath = $lockLocationArray[Resources::PHP_URL_PATH]; $lockLocationPath = preg_replace( '@^\/@', Resources::EMPTY_STRING, $lockLocationPath ); } if (empty($lockLocationPath)) { throw new \InvalidArgumentException( Resources::MISSING_LOCK_LOCATION_MSG ); } $httpCallContext->setPath($lockLocationPath); $httpCallContext->addStatusCode(Resources::STATUS_OK); $this->sendHttpContext($httpCallContext); }
[ "public", "function", "deleteMessage", "(", "BrokeredMessage", "$", "brokeredMessage", ")", "{", "$", "httpCallContext", "=", "new", "HttpCallContext", "(", ")", ";", "$", "httpCallContext", "->", "setMethod", "(", "Resources", "::", "HTTP_DELETE", ")", ";", "$"...
Deletes a brokered message. Queues: @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780767 Topic Subscriptions: @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780768 @param BrokeredMessage $brokeredMessage The brokered message
[ "Deletes", "a", "brokered", "message", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L363-L388
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.createQueue
public function createQueue(QueueInfo $queueInfo) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_PUT); $httpCallContext->setPath($queueInfo->getTitle()); $httpCallContext->addHeader( Resources::CONTENT_TYPE, Resources::ATOM_ENTRY_CONTENT_TYPE ); $httpCallContext->addStatusCode(Resources::STATUS_CREATED); $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $queueInfo->writeXml($xmlWriter); $body = $xmlWriter->outputMemory(); $httpCallContext->setBody($body); $response = $this->sendHttpContext($httpCallContext); $queueInfo = new QueueInfo(); $queueInfo->parseXml($response->getBody()); return $queueInfo; }
php
public function createQueue(QueueInfo $queueInfo) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_PUT); $httpCallContext->setPath($queueInfo->getTitle()); $httpCallContext->addHeader( Resources::CONTENT_TYPE, Resources::ATOM_ENTRY_CONTENT_TYPE ); $httpCallContext->addStatusCode(Resources::STATUS_CREATED); $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $queueInfo->writeXml($xmlWriter); $body = $xmlWriter->outputMemory(); $httpCallContext->setBody($body); $response = $this->sendHttpContext($httpCallContext); $queueInfo = new QueueInfo(); $queueInfo->parseXml($response->getBody()); return $queueInfo; }
[ "public", "function", "createQueue", "(", "QueueInfo", "$", "queueInfo", ")", "{", "$", "httpCallContext", "=", "new", "HttpCallContext", "(", ")", ";", "$", "httpCallContext", "->", "setMethod", "(", "Resources", "::", "HTTP_PUT", ")", ";", "$", "httpCallCont...
Creates a queue with a specified queue information. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780716 @param QueueInfo $queueInfo The information of the queue @return QueueInfo
[ "Creates", "a", "queue", "with", "a", "specified", "queue", "information", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L399-L421
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.getQueue
public function getQueue($queuePath) { $httpCallContext = new HttpCallContext(); $httpCallContext->setPath($queuePath); $httpCallContext->setMethod(Resources::HTTP_GET); $httpCallContext->addStatusCode(Resources::STATUS_OK); $response = $this->sendHttpContext($httpCallContext); $queueInfo = new QueueInfo(); $queueInfo->parseXml($response->getBody()); return $queueInfo; }
php
public function getQueue($queuePath) { $httpCallContext = new HttpCallContext(); $httpCallContext->setPath($queuePath); $httpCallContext->setMethod(Resources::HTTP_GET); $httpCallContext->addStatusCode(Resources::STATUS_OK); $response = $this->sendHttpContext($httpCallContext); $queueInfo = new QueueInfo(); $queueInfo->parseXml($response->getBody()); return $queueInfo; }
[ "public", "function", "getQueue", "(", "$", "queuePath", ")", "{", "$", "httpCallContext", "=", "new", "HttpCallContext", "(", ")", ";", "$", "httpCallContext", "->", "setPath", "(", "$", "queuePath", ")", ";", "$", "httpCallContext", "->", "setMethod", "(",...
Gets a queue with specified path. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780764 @param string $queuePath The path of the queue @return QueueInfo
[ "Gets", "a", "queue", "with", "specified", "path", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L452-L463
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.listQueues
public function listQueues(ListQueuesOptions $listQueuesOptions = null) { $response = $this->_listOptions( $listQueuesOptions, Resources::LIST_QUEUES_PATH ); $listQueuesResult = new ListQueuesResult(); $listQueuesResult->parseXml($response->getBody()); return $listQueuesResult; }
php
public function listQueues(ListQueuesOptions $listQueuesOptions = null) { $response = $this->_listOptions( $listQueuesOptions, Resources::LIST_QUEUES_PATH ); $listQueuesResult = new ListQueuesResult(); $listQueuesResult->parseXml($response->getBody()); return $listQueuesResult; }
[ "public", "function", "listQueues", "(", "ListQueuesOptions", "$", "listQueuesOptions", "=", "null", ")", "{", "$", "response", "=", "$", "this", "->", "_listOptions", "(", "$", "listQueuesOptions", ",", "Resources", "::", "LIST_QUEUES_PATH", ")", ";", "$", "l...
Lists a queue. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780759 @param ListQueuesOptions|null $listQueuesOptions The options to list the queues @return ListQueuesResult
[ "Lists", "a", "queue", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L475-L486
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy._listOptions
private function _listOptions($listOptions, $path) { if (is_null($listOptions)) { $listOptions = new ListOptions(); } $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_GET); $httpCallContext->setPath($path); $httpCallContext->addStatusCode(Resources::STATUS_OK); $top = $listOptions->getTop(); $skip = $listOptions->getSkip(); if (!empty($top)) { $httpCallContext->addQueryParameter(Resources::QP_TOP, $top); } if (!empty($skip)) { $httpCallContext->addQueryParameter(Resources::QP_SKIP, $skip); } return $this->sendHttpContext($httpCallContext); }
php
private function _listOptions($listOptions, $path) { if (is_null($listOptions)) { $listOptions = new ListOptions(); } $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_GET); $httpCallContext->setPath($path); $httpCallContext->addStatusCode(Resources::STATUS_OK); $top = $listOptions->getTop(); $skip = $listOptions->getSkip(); if (!empty($top)) { $httpCallContext->addQueryParameter(Resources::QP_TOP, $top); } if (!empty($skip)) { $httpCallContext->addQueryParameter(Resources::QP_SKIP, $skip); } return $this->sendHttpContext($httpCallContext); }
[ "private", "function", "_listOptions", "(", "$", "listOptions", ",", "$", "path", ")", "{", "if", "(", "is_null", "(", "$", "listOptions", ")", ")", "{", "$", "listOptions", "=", "new", "ListOptions", "(", ")", ";", "}", "$", "httpCallContext", "=", "n...
The base method of all the list operations. @param ListOptions $listOptions The options for list operation @param string $path The path of the list operation @return ResponseInterface
[ "The", "base", "method", "of", "all", "the", "list", "operations", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L496-L518
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.createTopic
public function createTopic(TopicInfo $topicInfo) { Validate::notNullOrEmpty($topicInfo, 'topicInfo'); $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_PUT); $httpCallContext->setPath($topicInfo->getTitle()); $httpCallContext->addHeader( Resources::CONTENT_TYPE, Resources::ATOM_ENTRY_CONTENT_TYPE ); $httpCallContext->addStatusCode(Resources::STATUS_CREATED); $topicDescriptionXml = XmlSerializer::objectSerialize( $topicInfo->getTopicDescription(), 'TopicDescription' ); $entry = new Entry(); $content = new Content($topicDescriptionXml); $content->setType(Resources::XML_CONTENT_TYPE); $entry->setContent($content); $entry->setAttribute( Resources::XMLNS, Resources::SERVICE_BUS_NAMESPACE ); $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $entry->writeXml($xmlWriter); $httpCallContext->setBody($xmlWriter->outputMemory()); $response = $this->sendHttpContext($httpCallContext); $topicInfo = new TopicInfo(); $topicInfo->parseXml($response->getBody()); return $topicInfo; }
php
public function createTopic(TopicInfo $topicInfo) { Validate::notNullOrEmpty($topicInfo, 'topicInfo'); $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_PUT); $httpCallContext->setPath($topicInfo->getTitle()); $httpCallContext->addHeader( Resources::CONTENT_TYPE, Resources::ATOM_ENTRY_CONTENT_TYPE ); $httpCallContext->addStatusCode(Resources::STATUS_CREATED); $topicDescriptionXml = XmlSerializer::objectSerialize( $topicInfo->getTopicDescription(), 'TopicDescription' ); $entry = new Entry(); $content = new Content($topicDescriptionXml); $content->setType(Resources::XML_CONTENT_TYPE); $entry->setContent($content); $entry->setAttribute( Resources::XMLNS, Resources::SERVICE_BUS_NAMESPACE ); $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $entry->writeXml($xmlWriter); $httpCallContext->setBody($xmlWriter->outputMemory()); $response = $this->sendHttpContext($httpCallContext); $topicInfo = new TopicInfo(); $topicInfo->parseXml($response->getBody()); return $topicInfo; }
[ "public", "function", "createTopic", "(", "TopicInfo", "$", "topicInfo", ")", "{", "Validate", "::", "notNullOrEmpty", "(", "$", "topicInfo", ",", "'topicInfo'", ")", ";", "$", "httpCallContext", "=", "new", "HttpCallContext", "(", ")", ";", "$", "httpCallCont...
Creates a topic with specified topic info. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780728 @param TopicInfo $topicInfo The information of the topic @return TopicInfo
[ "Creates", "a", "topic", "with", "specified", "topic", "info", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L529-L566
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.deleteTopic
public function deleteTopic($topicPath) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_DELETE); $httpCallContext->setPath($topicPath); $httpCallContext->addStatusCode(Resources::STATUS_OK); $this->sendHttpContext($httpCallContext); }
php
public function deleteTopic($topicPath) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_DELETE); $httpCallContext->setPath($topicPath); $httpCallContext->addStatusCode(Resources::STATUS_OK); $this->sendHttpContext($httpCallContext); }
[ "public", "function", "deleteTopic", "(", "$", "topicPath", ")", "{", "$", "httpCallContext", "=", "new", "HttpCallContext", "(", ")", ";", "$", "httpCallContext", "->", "setMethod", "(", "Resources", "::", "HTTP_DELETE", ")", ";", "$", "httpCallContext", "->"...
Deletes a topic with specified topic path. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780721 @param string $topicPath The path of the topic
[ "Deletes", "a", "topic", "with", "specified", "topic", "path", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L575-L583
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.getTopic
public function getTopic($topicPath) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_GET); $httpCallContext->setPath($topicPath); $httpCallContext->addStatusCode(Resources::STATUS_OK); $response = $this->sendHttpContext($httpCallContext); $topicInfo = new TopicInfo(); $topicInfo->parseXml($response->getBody()); return $topicInfo; }
php
public function getTopic($topicPath) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_GET); $httpCallContext->setPath($topicPath); $httpCallContext->addStatusCode(Resources::STATUS_OK); $response = $this->sendHttpContext($httpCallContext); $topicInfo = new TopicInfo(); $topicInfo->parseXml($response->getBody()); return $topicInfo; }
[ "public", "function", "getTopic", "(", "$", "topicPath", ")", "{", "$", "httpCallContext", "=", "new", "HttpCallContext", "(", ")", ";", "$", "httpCallContext", "->", "setMethod", "(", "Resources", "::", "HTTP_GET", ")", ";", "$", "httpCallContext", "->", "s...
Gets a topic. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780769 @param string $topicPath The path of the topic @return TopicInfo
[ "Gets", "a", "topic", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L594-L605
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.listTopics
public function listTopics(ListTopicsOptions $listTopicsOptions = null) { $response = $this->_listOptions( $listTopicsOptions, Resources::LIST_TOPICS_PATH ); $listTopicsResult = new ListTopicsResult(); $listTopicsResult->parseXml($response->getBody()); return $listTopicsResult; }
php
public function listTopics(ListTopicsOptions $listTopicsOptions = null) { $response = $this->_listOptions( $listTopicsOptions, Resources::LIST_TOPICS_PATH ); $listTopicsResult = new ListTopicsResult(); $listTopicsResult->parseXml($response->getBody()); return $listTopicsResult; }
[ "public", "function", "listTopics", "(", "ListTopicsOptions", "$", "listTopicsOptions", "=", "null", ")", "{", "$", "response", "=", "$", "this", "->", "_listOptions", "(", "$", "listTopicsOptions", ",", "Resources", "::", "LIST_TOPICS_PATH", ")", ";", "$", "l...
Lists topics. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780744 @param ListTopicsOptions $listTopicsOptions The options to list the topics @return ListTopicsResult
[ "Lists", "topics", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L617-L628
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.createSubscription
public function createSubscription($topicPath, SubscriptionInfo $subscriptionInfo) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_PUT); $subscriptionPath = sprintf( Resources::SUBSCRIPTION_PATH, $topicPath, $subscriptionInfo->getTitle() ); $httpCallContext->setPath($subscriptionPath); $httpCallContext->addHeader( Resources::CONTENT_TYPE, Resources::ATOM_ENTRY_CONTENT_TYPE ); $httpCallContext->addStatusCode(Resources::STATUS_CREATED); $subscriptionDescriptionXml = XmlSerializer::objectSerialize( $subscriptionInfo->getSubscriptionDescription(), 'SubscriptionDescription' ); $entry = new Entry(); $content = new Content($subscriptionDescriptionXml); $content->setType(Resources::XML_CONTENT_TYPE); $entry->setContent($content); $entry->setAttribute( Resources::XMLNS, Resources::SERVICE_BUS_NAMESPACE ); $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $entry->writeXml($xmlWriter); $httpCallContext->setBody($xmlWriter->outputMemory()); $response = $this->sendHttpContext($httpCallContext); $subscriptionInfo = new SubscriptionInfo(); $subscriptionInfo->parseXml($response->getBody()); return $subscriptionInfo; }
php
public function createSubscription($topicPath, SubscriptionInfo $subscriptionInfo) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_PUT); $subscriptionPath = sprintf( Resources::SUBSCRIPTION_PATH, $topicPath, $subscriptionInfo->getTitle() ); $httpCallContext->setPath($subscriptionPath); $httpCallContext->addHeader( Resources::CONTENT_TYPE, Resources::ATOM_ENTRY_CONTENT_TYPE ); $httpCallContext->addStatusCode(Resources::STATUS_CREATED); $subscriptionDescriptionXml = XmlSerializer::objectSerialize( $subscriptionInfo->getSubscriptionDescription(), 'SubscriptionDescription' ); $entry = new Entry(); $content = new Content($subscriptionDescriptionXml); $content->setType(Resources::XML_CONTENT_TYPE); $entry->setContent($content); $entry->setAttribute( Resources::XMLNS, Resources::SERVICE_BUS_NAMESPACE ); $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $entry->writeXml($xmlWriter); $httpCallContext->setBody($xmlWriter->outputMemory()); $response = $this->sendHttpContext($httpCallContext); $subscriptionInfo = new SubscriptionInfo(); $subscriptionInfo->parseXml($response->getBody()); return $subscriptionInfo; }
[ "public", "function", "createSubscription", "(", "$", "topicPath", ",", "SubscriptionInfo", "$", "subscriptionInfo", ")", "{", "$", "httpCallContext", "=", "new", "HttpCallContext", "(", ")", ";", "$", "httpCallContext", "->", "setMethod", "(", "Resources", "::", ...
Creates a subscription with specified topic path and subscription info. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780748 @param string $topicPath The path of the topic @param SubscriptionInfo $subscriptionInfo The information of the subscription @return SubscriptionInfo
[ "Creates", "a", "subscription", "with", "specified", "topic", "path", "and", "subscription", "info", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L643-L684
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.getSubscription
public function getSubscription($topicPath, $subscriptionName) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_GET); $httpCallContext->addStatusCode(Resources::STATUS_OK); $subscriptionPath = sprintf( Resources::SUBSCRIPTION_PATH, $topicPath, $subscriptionName ); $httpCallContext->setPath($subscriptionPath); $response = $this->sendHttpContext($httpCallContext); $subscriptionInfo = new SubscriptionInfo(); $subscriptionInfo->parseXml($response->getBody()); return $subscriptionInfo; }
php
public function getSubscription($topicPath, $subscriptionName) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_GET); $httpCallContext->addStatusCode(Resources::STATUS_OK); $subscriptionPath = sprintf( Resources::SUBSCRIPTION_PATH, $topicPath, $subscriptionName ); $httpCallContext->setPath($subscriptionPath); $response = $this->sendHttpContext($httpCallContext); $subscriptionInfo = new SubscriptionInfo(); $subscriptionInfo->parseXml($response->getBody()); return $subscriptionInfo; }
[ "public", "function", "getSubscription", "(", "$", "topicPath", ",", "$", "subscriptionName", ")", "{", "$", "httpCallContext", "=", "new", "HttpCallContext", "(", ")", ";", "$", "httpCallContext", "->", "setMethod", "(", "Resources", "::", "HTTP_GET", ")", ";...
Gets a subscription. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780741 @param string $topicPath The path of the topic @param string $subscriptionName The name of the subscription @return SubscriptionInfo
[ "Gets", "a", "subscription", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L718-L734
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.listSubscriptions
public function listSubscriptions( $topicPath, ListSubscriptionsOptions $listSubscriptionsOptions = null ) { $listSubscriptionsPath = sprintf( Resources::LIST_SUBSCRIPTIONS_PATH, $topicPath ); $response = $this->_listOptions( $listSubscriptionsOptions, $listSubscriptionsPath ); $listSubscriptionsResult = new ListSubscriptionsResult(); $listSubscriptionsResult->parseXml($response->getBody()); return $listSubscriptionsResult; }
php
public function listSubscriptions( $topicPath, ListSubscriptionsOptions $listSubscriptionsOptions = null ) { $listSubscriptionsPath = sprintf( Resources::LIST_SUBSCRIPTIONS_PATH, $topicPath ); $response = $this->_listOptions( $listSubscriptionsOptions, $listSubscriptionsPath ); $listSubscriptionsResult = new ListSubscriptionsResult(); $listSubscriptionsResult->parseXml($response->getBody()); return $listSubscriptionsResult; }
[ "public", "function", "listSubscriptions", "(", "$", "topicPath", ",", "ListSubscriptionsOptions", "$", "listSubscriptionsOptions", "=", "null", ")", "{", "$", "listSubscriptionsPath", "=", "sprintf", "(", "Resources", "::", "LIST_SUBSCRIPTIONS_PATH", ",", "$", "topic...
Lists subscription. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780766 @param string $topicPath The path of the topic @param ListSubscriptionsOptions|null $listSubscriptionsOptions The options to list the subscription @return ListSubscriptionsResult
[ "Lists", "subscription", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L748-L764
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.getRule
public function getRule($topicPath, $subscriptionName, $ruleName) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_GET); $httpCallContext->addStatusCode(Resources::STATUS_OK); $rulePath = sprintf( Resources::RULE_PATH, $topicPath, $subscriptionName, $ruleName ); $httpCallContext->setPath($rulePath); $response = $this->sendHttpContext($httpCallContext); $ruleInfo = new RuleInfo(); $ruleInfo->parseXml($response->getBody()); return $ruleInfo; }
php
public function getRule($topicPath, $subscriptionName, $ruleName) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_GET); $httpCallContext->addStatusCode(Resources::STATUS_OK); $rulePath = sprintf( Resources::RULE_PATH, $topicPath, $subscriptionName, $ruleName ); $httpCallContext->setPath($rulePath); $response = $this->sendHttpContext($httpCallContext); $ruleInfo = new RuleInfo(); $ruleInfo->parseXml($response->getBody()); return $ruleInfo; }
[ "public", "function", "getRule", "(", "$", "topicPath", ",", "$", "subscriptionName", ",", "$", "ruleName", ")", "{", "$", "httpCallContext", "=", "new", "HttpCallContext", "(", ")", ";", "$", "httpCallContext", "->", "setMethod", "(", "Resources", "::", "HT...
Gets a rule. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780772 @param string $topicPath The path of the topic @param string $subscriptionName The name of the subscription @param string $ruleName The name of the rule @return RuleInfo
[ "Gets", "a", "rule", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L856-L873
train
Azure/azure-sdk-for-php
src/ServiceBus/ServiceBusRestProxy.php
ServiceBusRestProxy.listRules
public function listRules( $topicPath, $subscriptionName, ListRulesOptions $listRulesOptions = null ) { $listRulesPath = sprintf( Resources::LIST_RULES_PATH, $topicPath, $subscriptionName ); $response = $this->_listOptions( $listRulesOptions, $listRulesPath ); $listRulesResult = new ListRulesResult(); $listRulesResult->parseXml($response->getBody()); return $listRulesResult; }
php
public function listRules( $topicPath, $subscriptionName, ListRulesOptions $listRulesOptions = null ) { $listRulesPath = sprintf( Resources::LIST_RULES_PATH, $topicPath, $subscriptionName ); $response = $this->_listOptions( $listRulesOptions, $listRulesPath ); $listRulesResult = new ListRulesResult(); $listRulesResult->parseXml($response->getBody()); return $listRulesResult; }
[ "public", "function", "listRules", "(", "$", "topicPath", ",", "$", "subscriptionName", ",", "ListRulesOptions", "$", "listRulesOptions", "=", "null", ")", "{", "$", "listRulesPath", "=", "sprintf", "(", "Resources", "::", "LIST_RULES_PATH", ",", "$", "topicPath...
Lists rules. @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780732 @param string $topicPath The path of the topic @param string $subscriptionName The name of the subscription @param ListRulesOptions|null $listRulesOptions The options to list the rules @return ListRulesResult
[ "Lists", "rules", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/ServiceBusRestProxy.php#L886-L906
train
Azure/azure-sdk-for-php
src/MediaServices/Models/ContentKeyAuthorizationPolicy.php
ContentKeyAuthorizationPolicy.fromArray
public function fromArray($options) { if (isset($options['Id'])) { Validate::isString($options['Id'], 'options[Id]'); $this->_id = $options['Id']; } if (isset($options['Name'])) { Validate::isString($options['Name'], 'options[Name]'); $this->_name = $options['Name']; } }
php
public function fromArray($options) { if (isset($options['Id'])) { Validate::isString($options['Id'], 'options[Id]'); $this->_id = $options['Id']; } if (isset($options['Name'])) { Validate::isString($options['Name'], 'options[Name]'); $this->_name = $options['Name']; } }
[ "public", "function", "fromArray", "(", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'Id'", "]", ")", ")", "{", "Validate", "::", "isString", "(", "$", "options", "[", "'Id'", "]", ",", "'options[Id]'", ")", ";", "$", "t...
Fill ContentKeyAuthorizationPolicy from array. @param array $options Array containing values for object properties
[ "Fill", "ContentKeyAuthorizationPolicy", "from", "array", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Models/ContentKeyAuthorizationPolicy.php#L86-L97
train
Azure/azure-sdk-for-php
src/MediaServices/Templates/WidevineMessageSerializer.php
WidevineMessageSerializer.deserialize
public static function deserialize($json) { $data = json_decode($json); $template = new WidevineMessage(); foreach ($data as $key => $value) { if ($key == 'content_key_specs') { $specs = []; foreach ($value as $child) { $spec = new ContentKeySpecs(); foreach ($child as $cKey => $cValue) { if ($cKey == 'required_output_protection') { $rop = new RequiredOutputProtection(); if (isset($cValue->hdcp)) { $rop->hdcp = $cValue->hdcp; } $spec->{$cKey} = $rop; } else { $spec->{$cKey} = $cValue; } } $specs[] = $spec; } $template->content_key_specs = $specs; } else { $template->{$key} = $value; } } return $template; }
php
public static function deserialize($json) { $data = json_decode($json); $template = new WidevineMessage(); foreach ($data as $key => $value) { if ($key == 'content_key_specs') { $specs = []; foreach ($value as $child) { $spec = new ContentKeySpecs(); foreach ($child as $cKey => $cValue) { if ($cKey == 'required_output_protection') { $rop = new RequiredOutputProtection(); if (isset($cValue->hdcp)) { $rop->hdcp = $cValue->hdcp; } $spec->{$cKey} = $rop; } else { $spec->{$cKey} = $cValue; } } $specs[] = $spec; } $template->content_key_specs = $specs; } else { $template->{$key} = $value; } } return $template; }
[ "public", "static", "function", "deserialize", "(", "$", "json", ")", "{", "$", "data", "=", "json_decode", "(", "$", "json", ")", ";", "$", "template", "=", "new", "WidevineMessage", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>"...
Deserialize a JSON as a WidevineMessage. @param string $json @return WidevineMessage the message
[ "Deserialize", "a", "JSON", "as", "a", "WidevineMessage", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Templates/WidevineMessageSerializer.php#L62-L92
train
Azure/azure-sdk-for-php
src/Common/Internal/ServiceRestProxy.php
ServiceRestProxy.addMetadataHeaders
protected function addMetadataHeaders(array $headers, array $metadata) { $this->validateMetadata($metadata); $metadata = $this->generateMetadataHeaders($metadata); $headers = array_merge($headers, $metadata); return $headers; }
php
protected function addMetadataHeaders(array $headers, array $metadata) { $this->validateMetadata($metadata); $metadata = $this->generateMetadataHeaders($metadata); $headers = array_merge($headers, $metadata); return $headers; }
[ "protected", "function", "addMetadataHeaders", "(", "array", "$", "headers", ",", "array", "$", "metadata", ")", "{", "$", "this", "->", "validateMetadata", "(", "$", "metadata", ")", ";", "$", "metadata", "=", "$", "this", "->", "generateMetadataHeaders", "...
Adds metadata elements to headers array. @param array $headers HTTP request headers @param array $metadata user specified metadata @return array
[ "Adds", "metadata", "elements", "to", "headers", "array", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/ServiceRestProxy.php#L260-L268
train
Azure/azure-sdk-for-php
src/Common/Internal/ServiceRestProxy.php
ServiceRestProxy.generateMetadataHeaders
public function generateMetadataHeaders(array $metadata) { $metadataHeaders = []; if (is_array($metadata) && !is_null($metadata)) { foreach ($metadata as $key => $value) { $headerName = Resources::X_MS_META_HEADER_PREFIX; if (strpos($value, "\r") !== false || strpos($value, "\n") !== false ) { throw new \InvalidArgumentException(Resources::INVALID_META_MSG); } $headerName .= strtolower($key); $metadataHeaders[$headerName] = $value; } } return $metadataHeaders; }
php
public function generateMetadataHeaders(array $metadata) { $metadataHeaders = []; if (is_array($metadata) && !is_null($metadata)) { foreach ($metadata as $key => $value) { $headerName = Resources::X_MS_META_HEADER_PREFIX; if (strpos($value, "\r") !== false || strpos($value, "\n") !== false ) { throw new \InvalidArgumentException(Resources::INVALID_META_MSG); } $headerName .= strtolower($key); $metadataHeaders[$headerName] = $value; } } return $metadataHeaders; }
[ "public", "function", "generateMetadataHeaders", "(", "array", "$", "metadata", ")", "{", "$", "metadataHeaders", "=", "[", "]", ";", "if", "(", "is_array", "(", "$", "metadata", ")", "&&", "!", "is_null", "(", "$", "metadata", ")", ")", "{", "foreach", ...
Generates metadata headers by prefixing each element with 'x-ms-meta'. @param array $metadata user defined metadata @return array
[ "Generates", "metadata", "headers", "by", "prefixing", "each", "element", "with", "x", "-", "ms", "-", "meta", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/ServiceRestProxy.php#L277-L296
train
Azure/azure-sdk-for-php
src/Common/Internal/ServiceRestProxy.php
ServiceRestProxy.getMetadataArray
public function getMetadataArray(array $headers) { $metadata = []; foreach ($headers as $key => $value) { $isMetadataHeader = Utilities::startsWith( strtolower($key), Resources::X_MS_META_HEADER_PREFIX ); if ($isMetadataHeader) { $MetadataName = str_replace( Resources::X_MS_META_HEADER_PREFIX, Resources::EMPTY_STRING, strtolower($key) ); $metadata[$MetadataName] = $value; } } return $metadata; }
php
public function getMetadataArray(array $headers) { $metadata = []; foreach ($headers as $key => $value) { $isMetadataHeader = Utilities::startsWith( strtolower($key), Resources::X_MS_META_HEADER_PREFIX ); if ($isMetadataHeader) { $MetadataName = str_replace( Resources::X_MS_META_HEADER_PREFIX, Resources::EMPTY_STRING, strtolower($key) ); $metadata[$MetadataName] = $value; } } return $metadata; }
[ "public", "function", "getMetadataArray", "(", "array", "$", "headers", ")", "{", "$", "metadata", "=", "[", "]", ";", "foreach", "(", "$", "headers", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "isMetadataHeader", "=", "Utilities", "::", "sta...
Gets metadata array by parsing them from given headers. @param array $headers HTTP headers containing metadata elements @return array
[ "Gets", "metadata", "array", "by", "parsing", "them", "from", "given", "headers", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/ServiceRestProxy.php#L305-L326
train
Azure/azure-sdk-for-php
src/Common/Internal/ServiceRestProxy.php
ServiceRestProxy.validateMetadata
public function validateMetadata(array $metadata = null) { if (!is_null($metadata)) { Validate::isArray($metadata, 'metadata'); } else { $metadata = []; } foreach ($metadata as $key => $value) { Validate::isString($key, 'metadata key'); Validate::isString($value, 'metadata value'); } }
php
public function validateMetadata(array $metadata = null) { if (!is_null($metadata)) { Validate::isArray($metadata, 'metadata'); } else { $metadata = []; } foreach ($metadata as $key => $value) { Validate::isString($key, 'metadata key'); Validate::isString($value, 'metadata value'); } }
[ "public", "function", "validateMetadata", "(", "array", "$", "metadata", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "metadata", ")", ")", "{", "Validate", "::", "isArray", "(", "$", "metadata", ",", "'metadata'", ")", ";", "}", "else",...
Validates the provided metadata array. @param array|null $metadata The metadata array
[ "Validates", "the", "provided", "metadata", "array", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/ServiceRestProxy.php#L333-L345
train
Azure/azure-sdk-for-php
src/ServiceManagement/Models/GetAffinityGroupPropertiesResult.php
GetAffinityGroupPropertiesResult.create
public static function create($parsed) { $result = new self(); $hostedServices = Utilities::tryGetArray( Resources::XTAG_HOSTED_SERVICES, $parsed ); $storageServices = Utilities::tryGetArray( Resources::XTAG_STORAGE_SERVICES, $parsed ); $result->_affinityGroup = new AffinityGroup($parsed); foreach ($hostedServices as $value) { $service = new HostedService($value); $result->_hostedServices[] = $service; } foreach ($storageServices as $value) { $service = new StorageService($value); $result->_storageServices[] = $service; } return $result; }
php
public static function create($parsed) { $result = new self(); $hostedServices = Utilities::tryGetArray( Resources::XTAG_HOSTED_SERVICES, $parsed ); $storageServices = Utilities::tryGetArray( Resources::XTAG_STORAGE_SERVICES, $parsed ); $result->_affinityGroup = new AffinityGroup($parsed); foreach ($hostedServices as $value) { $service = new HostedService($value); $result->_hostedServices[] = $service; } foreach ($storageServices as $value) { $service = new StorageService($value); $result->_storageServices[] = $service; } return $result; }
[ "public", "static", "function", "create", "(", "$", "parsed", ")", "{", "$", "result", "=", "new", "self", "(", ")", ";", "$", "hostedServices", "=", "Utilities", "::", "tryGetArray", "(", "Resources", "::", "XTAG_HOSTED_SERVICES", ",", "$", "parsed", ")",...
Creates GetAffinityGroupPropertiesResult from parsed response into array. @param array $parsed The parsed HTTP response body @return GetAffinityGroupPropertiesResult
[ "Creates", "GetAffinityGroupPropertiesResult", "from", "parsed", "response", "into", "array", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceManagement/Models/GetAffinityGroupPropertiesResult.php#L68-L93
train
Azure/azure-sdk-for-php
src/ServiceManagement/Models/Mode.php
Mode.isValid
public static function isValid($mode) { switch (strtolower($mode)) { case self::AUTO: case self::MANUAL: return true; default: return false; } }
php
public static function isValid($mode) { switch (strtolower($mode)) { case self::AUTO: case self::MANUAL: return true; default: return false; } }
[ "public", "static", "function", "isValid", "(", "$", "mode", ")", "{", "switch", "(", "strtolower", "(", "$", "mode", ")", ")", "{", "case", "self", "::", "AUTO", ":", "case", "self", "::", "MANUAL", ":", "return", "true", ";", "default", ":", "retur...
Validates the provided mode. @param string $mode The deployment change mode @return bool
[ "Validates", "the", "provided", "mode", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceManagement/Models/Mode.php#L53-L63
train
Azure/azure-sdk-for-php
src/ServiceManagement/Models/RoleInstance.php
RoleInstance.create
public static function create($parsed) { $roleInstance = new self(); $roleName = Utilities::tryGetValue( $parsed, Resources::XTAG_ROLE_NAME ); $instanceName = Utilities::tryGetValue( $parsed, Resources::XTAG_INSTANCE_NAME ); $instanceStatus = Utilities::tryGetValue( $parsed, Resources::XTAG_INSTANCE_STATUS ); $instanceUpgradeDomain = Utilities::tryGetValue( $parsed, Resources::XTAG_INSTANCE_UPGRADE_DOMAIN ); $instanceFaultDomain = Utilities::tryGetValue( $parsed, Resources::XTAG_INSTANCE_FAULT_DOMAIN ); $instanceSize = Utilities::tryGetValue( $parsed, Resources::XTAG_INSTANCE_SIZE ); $instanceStateDetails = Utilities::tryGetValue( $parsed, Resources::XTAG_INSTANCE_STATE_DETAILS ); $instanceErrorCode = Utilities::tryGetValue( $parsed, Resources::XTAG_INSTANCE_ERROR_CODE ); $roleInstance->setInstanceErrorCode($instanceErrorCode); $roleInstance->setInstanceFaultDomain(intval($instanceFaultDomain)); $roleInstance->setInstanceName($instanceName); $roleInstance->setInstanceSize($instanceSize); $roleInstance->setInstanceStateDetails($instanceStateDetails); $roleInstance->setInstanceStatus($instanceStatus); $roleInstance->setInstanceUpgradeDomain(intval($instanceUpgradeDomain)); $roleInstance->setRoleName($roleName); return $roleInstance; }
php
public static function create($parsed) { $roleInstance = new self(); $roleName = Utilities::tryGetValue( $parsed, Resources::XTAG_ROLE_NAME ); $instanceName = Utilities::tryGetValue( $parsed, Resources::XTAG_INSTANCE_NAME ); $instanceStatus = Utilities::tryGetValue( $parsed, Resources::XTAG_INSTANCE_STATUS ); $instanceUpgradeDomain = Utilities::tryGetValue( $parsed, Resources::XTAG_INSTANCE_UPGRADE_DOMAIN ); $instanceFaultDomain = Utilities::tryGetValue( $parsed, Resources::XTAG_INSTANCE_FAULT_DOMAIN ); $instanceSize = Utilities::tryGetValue( $parsed, Resources::XTAG_INSTANCE_SIZE ); $instanceStateDetails = Utilities::tryGetValue( $parsed, Resources::XTAG_INSTANCE_STATE_DETAILS ); $instanceErrorCode = Utilities::tryGetValue( $parsed, Resources::XTAG_INSTANCE_ERROR_CODE ); $roleInstance->setInstanceErrorCode($instanceErrorCode); $roleInstance->setInstanceFaultDomain(intval($instanceFaultDomain)); $roleInstance->setInstanceName($instanceName); $roleInstance->setInstanceSize($instanceSize); $roleInstance->setInstanceStateDetails($instanceStateDetails); $roleInstance->setInstanceStatus($instanceStatus); $roleInstance->setInstanceUpgradeDomain(intval($instanceUpgradeDomain)); $roleInstance->setRoleName($roleName); return $roleInstance; }
[ "public", "static", "function", "create", "(", "$", "parsed", ")", "{", "$", "roleInstance", "=", "new", "self", "(", ")", ";", "$", "roleName", "=", "Utilities", "::", "tryGetValue", "(", "$", "parsed", ",", "Resources", "::", "XTAG_ROLE_NAME", ")", ";"...
Creates a new RoleInstance from parsed response body. @param array $parsed The parsed response body in array representation @return RoleInstance
[ "Creates", "a", "new", "RoleInstance", "from", "parsed", "response", "body", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceManagement/Models/RoleInstance.php#L93-L139
train
Azure/azure-sdk-for-php
src/MediaServices/Models/ChannelInputAccessControl.php
ChannelInputAccessControl.fromArray
public function fromArray($options) { if (isset($options['IP'])) { Validate::isArray($options['IP'], 'options[IP]'); $this->_ip = IPAccessControl::createFromOptions($options['IP']); } }
php
public function fromArray($options) { if (isset($options['IP'])) { Validate::isArray($options['IP'], 'options[IP]'); $this->_ip = IPAccessControl::createFromOptions($options['IP']); } }
[ "public", "function", "fromArray", "(", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'IP'", "]", ")", ")", "{", "Validate", "::", "isArray", "(", "$", "options", "[", "'IP'", "]", ",", "'options[IP]'", ")", ";", "$", "th...
Fill ChannelInputAccessControl from array. @param array $options Array containing values for object properties
[ "Fill", "ChannelInputAccessControl", "from", "array", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Models/ChannelInputAccessControl.php#L79-L85
train
Azure/azure-sdk-for-php
src/Common/Internal/Http/HttpClient.php
HttpClient.setPostParameters
public function setPostParameters(array $postParameters) { foreach ($postParameters as $k => $v) { $this->_postParams[$k] = $v; } }
php
public function setPostParameters(array $postParameters) { foreach ($postParameters as $k => $v) { $this->_postParams[$k] = $v; } }
[ "public", "function", "setPostParameters", "(", "array", "$", "postParameters", ")", "{", "foreach", "(", "$", "postParameters", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "this", "->", "_postParams", "[", "$", "k", "]", "=", "$", "v", ";", "}", ...
Sets HTTP POST parameters. @param array $postParameters The HTTP POST parameters
[ "Sets", "HTTP", "POST", "parameters", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/Http/HttpClient.php#L234-L239
train
Azure/azure-sdk-for-php
src/Common/Internal/Http/HttpClient.php
HttpClient.setExpectedStatusCode
public function setExpectedStatusCode($statusCodes) { if (!is_array($statusCodes)) { $this->_expectedStatusCodes[] = $statusCodes; } else { $this->_expectedStatusCodes = $statusCodes; } }
php
public function setExpectedStatusCode($statusCodes) { if (!is_array($statusCodes)) { $this->_expectedStatusCodes[] = $statusCodes; } else { $this->_expectedStatusCodes = $statusCodes; } }
[ "public", "function", "setExpectedStatusCode", "(", "$", "statusCodes", ")", "{", "if", "(", "!", "is_array", "(", "$", "statusCodes", ")", ")", "{", "$", "this", "->", "_expectedStatusCodes", "[", "]", "=", "$", "statusCodes", ";", "}", "else", "{", "$"...
Sets successful status code. @param array|string $statusCodes successful status code
[ "Sets", "successful", "status", "code", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/Http/HttpClient.php#L329-L336
train
Azure/azure-sdk-for-php
src/Common/Internal/Http/HttpClient.php
HttpClient.throwIfError
public static function throwIfError($actual, $reason, $message, array $expected) { if (!in_array($actual, $expected)) { throw new ServiceException($actual, $reason, $message); } }
php
public static function throwIfError($actual, $reason, $message, array $expected) { if (!in_array($actual, $expected)) { throw new ServiceException($actual, $reason, $message); } }
[ "public", "static", "function", "throwIfError", "(", "$", "actual", ",", "$", "reason", ",", "$", "message", ",", "array", "$", "expected", ")", "{", "if", "(", "!", "in_array", "(", "$", "actual", ",", "$", "expected", ")", ")", "{", "throw", "new",...
Throws ServiceException if the received status code is not expected. @param string $actual The received status code @param string $reason The reason phrase @param string $message The detailed message (if any) @param array $expected The expected status codes @throws ServiceException
[ "Throws", "ServiceException", "if", "the", "received", "status", "code", "is", "not", "expected", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/Http/HttpClient.php#L402-L407
train
Azure/azure-sdk-for-php
src/ServiceBus/Internal/WrapRestProxy.php
WrapRestProxy.wrapAccessToken
public function wrapAccessToken($uri, $name, $password, $scope) { $method = Resources::HTTP_POST; $headers = []; $queryParams = []; $postParameters = []; $statusCode = Resources::STATUS_OK; $postParameters = $this->addPostParameter( $postParameters, Resources::WRAP_NAME, $name ); $postParameters = $this->addPostParameter( $postParameters, Resources::WRAP_PASSWORD, $password ); $postParameters = $this->addPostParameter( $postParameters, Resources::WRAP_SCOPE, $scope ); $this->setUri($uri); $response = $this->sendHttp( $method, $headers, $queryParams, $postParameters, Resources::EMPTY_STRING, $statusCode ); return WrapAccessTokenResult::create($response->getBody()); }
php
public function wrapAccessToken($uri, $name, $password, $scope) { $method = Resources::HTTP_POST; $headers = []; $queryParams = []; $postParameters = []; $statusCode = Resources::STATUS_OK; $postParameters = $this->addPostParameter( $postParameters, Resources::WRAP_NAME, $name ); $postParameters = $this->addPostParameter( $postParameters, Resources::WRAP_PASSWORD, $password ); $postParameters = $this->addPostParameter( $postParameters, Resources::WRAP_SCOPE, $scope ); $this->setUri($uri); $response = $this->sendHttp( $method, $headers, $queryParams, $postParameters, Resources::EMPTY_STRING, $statusCode ); return WrapAccessTokenResult::create($response->getBody()); }
[ "public", "function", "wrapAccessToken", "(", "$", "uri", ",", "$", "name", ",", "$", "password", ",", "$", "scope", ")", "{", "$", "method", "=", "Resources", "::", "HTTP_POST", ";", "$", "headers", "=", "[", "]", ";", "$", "queryParams", "=", "[", ...
Gets a WRAP access token with specified parameters. @param string $uri The URI of the WRAP service @param string $name The user name of the WRAP service @param string $password The password of the WRAP service @param string $scope The scope of the WRAP service @return WrapAccessTokenResult
[ "Gets", "a", "WRAP", "access", "token", "with", "specified", "parameters", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/Internal/WrapRestProxy.php#L68-L106
train
Azure/azure-sdk-for-php
src/ServiceBus/Models/ListTopicsResult.php
ListTopicsResult.parseXml
public function parseXml($response) { parent::parseXml($response); $listTopicsResultXml = new \SimpleXMLElement($response); $this->_topicInfos = []; foreach ($listTopicsResultXml->entry as $entry) { $topicInfo = new TopicInfo(); $topicInfo->parseXml($entry->asXML()); $this->_topicInfos[] = $topicInfo; } }
php
public function parseXml($response) { parent::parseXml($response); $listTopicsResultXml = new \SimpleXMLElement($response); $this->_topicInfos = []; foreach ($listTopicsResultXml->entry as $entry) { $topicInfo = new TopicInfo(); $topicInfo->parseXml($entry->asXML()); $this->_topicInfos[] = $topicInfo; } }
[ "public", "function", "parseXml", "(", "$", "response", ")", "{", "parent", "::", "parseXml", "(", "$", "response", ")", ";", "$", "listTopicsResultXml", "=", "new", "\\", "SimpleXMLElement", "(", "$", "response", ")", ";", "$", "this", "->", "_topicInfos"...
Populates the properties with a the response from the list topics request. @param string $response The body of the response of the list topics request
[ "Populates", "the", "properties", "with", "a", "the", "response", "from", "the", "list", "topics", "request", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/Models/ListTopicsResult.php#L57-L67
train
Azure/azure-sdk-for-php
src/ServiceManagement/Models/AsynchronousOperationResult.php
AsynchronousOperationResult.create
public static function create($headers) { $result = new self(); $result->_requestId = Utilities::tryGetValue( $headers, Resources::X_MS_REQUEST_ID ); return $result; }
php
public static function create($headers) { $result = new self(); $result->_requestId = Utilities::tryGetValue( $headers, Resources::X_MS_REQUEST_ID ); return $result; }
[ "public", "static", "function", "create", "(", "$", "headers", ")", "{", "$", "result", "=", "new", "self", "(", ")", ";", "$", "result", "->", "_requestId", "=", "Utilities", "::", "tryGetValue", "(", "$", "headers", ",", "Resources", "::", "X_MS_REQUES...
Creates new AsynchronousOperationResult from response HTTP headers. @param array $headers The HTTP response headers array @return AsynchronousOperationResult
[ "Creates", "new", "AsynchronousOperationResult", "from", "response", "HTTP", "headers", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceManagement/Models/AsynchronousOperationResult.php#L58-L67
train
Azure/azure-sdk-for-php
src/Common/Internal/Atom/AtomBase.php
AtomBase.processEntryNode
protected function processEntryNode($xmlArray) { $entry = []; $entryItem = $xmlArray[Resources::ENTRY]; if (is_array($entryItem)) { foreach ($xmlArray[Resources::ENTRY] as $entryXmlInstance) { $entryInstance = new Entry(); $entryInstance->fromXml($entryXmlInstance); $entry[] = $entryInstance; } } else { $entryInstance = new Entry(); $entryInstance->fromXml($entryItem); $entry[] = $entryInstance; } return $entry; }
php
protected function processEntryNode($xmlArray) { $entry = []; $entryItem = $xmlArray[Resources::ENTRY]; if (is_array($entryItem)) { foreach ($xmlArray[Resources::ENTRY] as $entryXmlInstance) { $entryInstance = new Entry(); $entryInstance->fromXml($entryXmlInstance); $entry[] = $entryInstance; } } else { $entryInstance = new Entry(); $entryInstance->fromXml($entryItem); $entry[] = $entryInstance; } return $entry; }
[ "protected", "function", "processEntryNode", "(", "$", "xmlArray", ")", "{", "$", "entry", "=", "[", "]", ";", "$", "entryItem", "=", "$", "xmlArray", "[", "Resources", "::", "ENTRY", "]", ";", "if", "(", "is_array", "(", "$", "entryItem", ")", ")", ...
Processes entry node. @param array $xmlArray An array of simple xml elements @return array
[ "Processes", "entry", "node", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/Atom/AtomBase.php#L154-L172
train
Azure/azure-sdk-for-php
src/Common/Internal/Atom/AtomBase.php
AtomBase.processCategoryNode
protected function processCategoryNode(array $xmlArray) { $category = []; $categoryItem = $xmlArray[Resources::CATEGORY]; if (is_array($categoryItem)) { /** @var SimpleXMLElement $categoryXmlInstance */ foreach ($xmlArray[Resources::CATEGORY] as $categoryXmlInstance) { $categoryInstance = new Category(); $categoryInstance->parseXml($categoryXmlInstance->asXML()); $category[] = $categoryInstance; } } else { $categoryInstance = new Category(); $categoryInstance->parseXml($categoryItem->asXML()); $category[] = $categoryInstance; } return $category; }
php
protected function processCategoryNode(array $xmlArray) { $category = []; $categoryItem = $xmlArray[Resources::CATEGORY]; if (is_array($categoryItem)) { /** @var SimpleXMLElement $categoryXmlInstance */ foreach ($xmlArray[Resources::CATEGORY] as $categoryXmlInstance) { $categoryInstance = new Category(); $categoryInstance->parseXml($categoryXmlInstance->asXML()); $category[] = $categoryInstance; } } else { $categoryInstance = new Category(); $categoryInstance->parseXml($categoryItem->asXML()); $category[] = $categoryInstance; } return $category; }
[ "protected", "function", "processCategoryNode", "(", "array", "$", "xmlArray", ")", "{", "$", "category", "=", "[", "]", ";", "$", "categoryItem", "=", "$", "xmlArray", "[", "Resources", "::", "CATEGORY", "]", ";", "if", "(", "is_array", "(", "$", "categ...
Processes category node. @param SimpleXMLElement[] $xmlArray An array of simple xml elements @return Category[]
[ "Processes", "category", "node", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/Atom/AtomBase.php#L181-L200
train
Azure/azure-sdk-for-php
src/Common/Internal/Atom/AtomBase.php
AtomBase.processContributorNode
protected function processContributorNode($xmlArray) { $contributor = []; $contributorItem = $xmlArray[Resources::CONTRIBUTOR]; if (is_array($contributorItem)) { /** @var SimpleXMLElement $contributorXmlInstance */ foreach ($xmlArray[Resources::CONTRIBUTOR] as $contributorXmlInstance) { $contributorInstance = new Person(); $contributorInstance->parseXml($contributorXmlInstance->asXML()); $contributor[] = $contributorInstance; } } elseif (is_string($contributorItem)) { $contributorInstance = new Person(); $contributorInstance->setName((string) $contributorItem); $contributor[] = $contributorInstance; } else { $contributorInstance = new Person(); $contributorInstance->parseXml($contributorItem->asXML()); $contributor[] = $contributorInstance; } return $contributor; }
php
protected function processContributorNode($xmlArray) { $contributor = []; $contributorItem = $xmlArray[Resources::CONTRIBUTOR]; if (is_array($contributorItem)) { /** @var SimpleXMLElement $contributorXmlInstance */ foreach ($xmlArray[Resources::CONTRIBUTOR] as $contributorXmlInstance) { $contributorInstance = new Person(); $contributorInstance->parseXml($contributorXmlInstance->asXML()); $contributor[] = $contributorInstance; } } elseif (is_string($contributorItem)) { $contributorInstance = new Person(); $contributorInstance->setName((string) $contributorItem); $contributor[] = $contributorInstance; } else { $contributorInstance = new Person(); $contributorInstance->parseXml($contributorItem->asXML()); $contributor[] = $contributorInstance; } return $contributor; }
[ "protected", "function", "processContributorNode", "(", "$", "xmlArray", ")", "{", "$", "contributor", "=", "[", "]", ";", "$", "contributorItem", "=", "$", "xmlArray", "[", "Resources", "::", "CONTRIBUTOR", "]", ";", "if", "(", "is_array", "(", "$", "cont...
Processes contributor node. @param array $xmlArray An array of simple xml elements @return Person[]
[ "Processes", "contributor", "node", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/Atom/AtomBase.php#L209-L232
train
Azure/azure-sdk-for-php
src/Common/Internal/Atom/AtomBase.php
AtomBase.processLinkNode
protected function processLinkNode($xmlArray) { $link = []; $linkValue = $xmlArray[Resources::LINK]; if (is_array($linkValue)) { /** @var SimpleXMLElement $linkValueInstance */ foreach ($xmlArray[Resources::LINK] as $linkValueInstance) { $linkInstance = new AtomLink(); $linkInstance->parseXml($linkValueInstance->asXML()); $link[] = $linkInstance; } } else { $linkInstance = new AtomLink(); $linkInstance->parseXml($linkValue->asXML()); $link[] = $linkInstance; } return $link; }
php
protected function processLinkNode($xmlArray) { $link = []; $linkValue = $xmlArray[Resources::LINK]; if (is_array($linkValue)) { /** @var SimpleXMLElement $linkValueInstance */ foreach ($xmlArray[Resources::LINK] as $linkValueInstance) { $linkInstance = new AtomLink(); $linkInstance->parseXml($linkValueInstance->asXML()); $link[] = $linkInstance; } } else { $linkInstance = new AtomLink(); $linkInstance->parseXml($linkValue->asXML()); $link[] = $linkInstance; } return $link; }
[ "protected", "function", "processLinkNode", "(", "$", "xmlArray", ")", "{", "$", "link", "=", "[", "]", ";", "$", "linkValue", "=", "$", "xmlArray", "[", "Resources", "::", "LINK", "]", ";", "if", "(", "is_array", "(", "$", "linkValue", ")", ")", "{"...
Processes link node. @param array $xmlArray An array of simple xml elements @return array
[ "Processes", "link", "node", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/Atom/AtomBase.php#L241-L260
train
Azure/azure-sdk-for-php
src/Common/Internal/Atom/AtomBase.php
AtomBase.writeOptionalAttribute
protected function writeOptionalAttribute( \XMLWriter $xmlWriter, $attributeName, $attributeValue ) { Validate::notNull($xmlWriter, 'xmlWriter'); Validate::isString($attributeName, 'attributeName'); if (!empty($attributeValue)) { $xmlWriter->writeAttribute( $attributeName, $attributeValue ); } }
php
protected function writeOptionalAttribute( \XMLWriter $xmlWriter, $attributeName, $attributeValue ) { Validate::notNull($xmlWriter, 'xmlWriter'); Validate::isString($attributeName, 'attributeName'); if (!empty($attributeValue)) { $xmlWriter->writeAttribute( $attributeName, $attributeValue ); } }
[ "protected", "function", "writeOptionalAttribute", "(", "\\", "XMLWriter", "$", "xmlWriter", ",", "$", "attributeName", ",", "$", "attributeValue", ")", "{", "Validate", "::", "notNull", "(", "$", "xmlWriter", ",", "'xmlWriter'", ")", ";", "Validate", "::", "i...
Writes an optional attribute for ATOM. @param \XMLWriter $xmlWriter The XML writer @param string $attributeName The name of the attribute @param mixed $attributeValue The value of the attribute
[ "Writes", "an", "optional", "attribute", "for", "ATOM", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/Atom/AtomBase.php#L269-L283
train
Azure/azure-sdk-for-php
src/Common/Internal/Atom/AtomBase.php
AtomBase.writeOptionalElementNS
protected function writeOptionalElementNS( \XMLWriter $xmlWriter, $prefix, $elementName, $namespace, $elementValue ) { Validate::isString($elementName, 'elementName'); if (!empty($elementValue)) { $xmlWriter->writeElementNS( $prefix, $elementName, $namespace, $elementValue ); } }
php
protected function writeOptionalElementNS( \XMLWriter $xmlWriter, $prefix, $elementName, $namespace, $elementValue ) { Validate::isString($elementName, 'elementName'); if (!empty($elementValue)) { $xmlWriter->writeElementNS( $prefix, $elementName, $namespace, $elementValue ); } }
[ "protected", "function", "writeOptionalElementNS", "(", "\\", "XMLWriter", "$", "xmlWriter", ",", "$", "prefix", ",", "$", "elementName", ",", "$", "namespace", ",", "$", "elementValue", ")", "{", "Validate", "::", "isString", "(", "$", "elementName", ",", "...
Writes the optional elements namespaces. @param \XMLWriter $xmlWriter The XML writer @param string $prefix The prefix @param string $elementName The element name @param string $namespace The namespace name @param string $elementValue The element value
[ "Writes", "the", "optional", "elements", "namespaces", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/Atom/AtomBase.php#L294-L311
train
Azure/azure-sdk-for-php
src/ServiceRuntime/Internal/Protocol1RuntimeGoalStateClient.php
Protocol1RuntimeGoalStateClient.getRoleEnvironmentData
public function getRoleEnvironmentData() { $this->_ensureGoalStateRetrieved(); if (is_null($this->_currentEnvironmentData)) { $current = $this->_currentGoalState; if (is_null($current->getEnvironmentPath())) { throw new RoleEnvironmentNotAvailableException( 'No role environment data for the current goal state' ); } $environmentStream = $this->_inputChannel->getInputStream( $current->getEnvironmentPath() ); $this->_currentEnvironmentData = $this->_roleEnvironmentDeserializer ->deserialize($environmentStream); } return $this->_currentEnvironmentData; }
php
public function getRoleEnvironmentData() { $this->_ensureGoalStateRetrieved(); if (is_null($this->_currentEnvironmentData)) { $current = $this->_currentGoalState; if (is_null($current->getEnvironmentPath())) { throw new RoleEnvironmentNotAvailableException( 'No role environment data for the current goal state' ); } $environmentStream = $this->_inputChannel->getInputStream( $current->getEnvironmentPath() ); $this->_currentEnvironmentData = $this->_roleEnvironmentDeserializer ->deserialize($environmentStream); } return $this->_currentEnvironmentData; }
[ "public", "function", "getRoleEnvironmentData", "(", ")", "{", "$", "this", "->", "_ensureGoalStateRetrieved", "(", ")", ";", "if", "(", "is_null", "(", "$", "this", "->", "_currentEnvironmentData", ")", ")", "{", "$", "current", "=", "$", "this", "->", "_...
Gets the role environment data. @return RoleEnvironmentData @throws RoleEnvironmentNotAvailableException
[ "Gets", "the", "role", "environment", "data", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceRuntime/Internal/Protocol1RuntimeGoalStateClient.php#L130-L152
train
Azure/azure-sdk-for-php
src/ServiceRuntime/Internal/Protocol1RuntimeGoalStateClient.php
Protocol1RuntimeGoalStateClient._ensureGoalStateRetrieved
private function _ensureGoalStateRetrieved() { if (is_null($this->_currentGoalState) || !$this->_keepOpen) { $inputStream = $this->_inputChannel->getInputStream($this->_endpoint); $this->_goalStateDeserializer->initialize($inputStream); } $goalState = $this->_goalStateDeserializer->deserialize(); if (is_null($goalState)) { return; } $this->_currentGoalState = $goalState; if (!is_null($goalState->getEnvironmentPath())) { $this->_currentEnvironmentData = null; } $this->_currentStateClient->setEndpoint( $this->_currentGoalState->getCurrentStateEndpoint() ); if (!$this->_keepOpen) { $this->_inputChannel->closeInputStream(); } }
php
private function _ensureGoalStateRetrieved() { if (is_null($this->_currentGoalState) || !$this->_keepOpen) { $inputStream = $this->_inputChannel->getInputStream($this->_endpoint); $this->_goalStateDeserializer->initialize($inputStream); } $goalState = $this->_goalStateDeserializer->deserialize(); if (is_null($goalState)) { return; } $this->_currentGoalState = $goalState; if (!is_null($goalState->getEnvironmentPath())) { $this->_currentEnvironmentData = null; } $this->_currentStateClient->setEndpoint( $this->_currentGoalState->getCurrentStateEndpoint() ); if (!$this->_keepOpen) { $this->_inputChannel->closeInputStream(); } }
[ "private", "function", "_ensureGoalStateRetrieved", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "_currentGoalState", ")", "||", "!", "$", "this", "->", "_keepOpen", ")", "{", "$", "inputStream", "=", "$", "this", "->", "_inputChannel", "->...
Ensures that the goal state is retrieved.
[ "Ensures", "that", "the", "goal", "state", "is", "retrieved", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceRuntime/Internal/Protocol1RuntimeGoalStateClient.php#L197-L222
train
Azure/azure-sdk-for-php
src/ServiceManagement/Models/GetStorageServicePropertiesResult.php
GetStorageServicePropertiesResult.create
public static function create($parsed) { $result = new self(); $properties = Utilities::tryGetValue( $parsed, Resources::XTAG_STORAGE_SERVICE_PROPERTIES ); $result->_storageService = new StorageService($parsed, $properties); return $result; }
php
public static function create($parsed) { $result = new self(); $properties = Utilities::tryGetValue( $parsed, Resources::XTAG_STORAGE_SERVICE_PROPERTIES ); $result->_storageService = new StorageService($parsed, $properties); return $result; }
[ "public", "static", "function", "create", "(", "$", "parsed", ")", "{", "$", "result", "=", "new", "self", "(", ")", ";", "$", "properties", "=", "Utilities", "::", "tryGetValue", "(", "$", "parsed", ",", "Resources", "::", "XTAG_STORAGE_SERVICE_PROPERTIES",...
Creates GetStorageServicePropertiesResult from parsed response. @param array $parsed The parsed response in array representation @return GetStorageServicePropertiesResult
[ "Creates", "GetStorageServicePropertiesResult", "from", "parsed", "response", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceManagement/Models/GetStorageServicePropertiesResult.php#L58-L68
train
Azure/azure-sdk-for-php
src/MediaServices/Models/ChannelEndpoint.php
ChannelEndpoint.fromArray
public function fromArray($options) { if (isset($options['Protocol'])) { Validate::isString($options['Protocol'], 'options[Protocol]'); $this->_protocol = $options['Protocol']; } if (isset($options['Url'])) { Validate::isString($options['Url'], 'options[Url]'); $this->_url = $options['Url']; } }
php
public function fromArray($options) { if (isset($options['Protocol'])) { Validate::isString($options['Protocol'], 'options[Protocol]'); $this->_protocol = $options['Protocol']; } if (isset($options['Url'])) { Validate::isString($options['Url'], 'options[Url]'); $this->_url = $options['Url']; } }
[ "public", "function", "fromArray", "(", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'Protocol'", "]", ")", ")", "{", "Validate", "::", "isString", "(", "$", "options", "[", "'Protocol'", "]", ",", "'options[Protocol]'", ")", ...
Fill ChannelEndpoint from array. @param array $options Array containing values for object properties
[ "Fill", "ChannelEndpoint", "from", "array", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Models/ChannelEndpoint.php#L86-L96
train
Azure/azure-sdk-for-php
src/Common/Internal/Atom/Category.php
Category.parseXml
public function parseXml($xmlString) { Validate::notNull($xmlString, 'xmlString'); Validate::isString($xmlString, 'xmlString'); $categoryXml = simplexml_load_string($xmlString); $attributes = $categoryXml->attributes(); if (!empty($attributes['term'])) { $this->term = (string) $attributes['term']; } if (!empty($attributes['scheme'])) { $this->scheme = (string) $attributes['scheme']; } if (!empty($attributes['label'])) { $this->label = (string) $attributes['label']; } $this->undefinedContent = (string) $categoryXml; }
php
public function parseXml($xmlString) { Validate::notNull($xmlString, 'xmlString'); Validate::isString($xmlString, 'xmlString'); $categoryXml = simplexml_load_string($xmlString); $attributes = $categoryXml->attributes(); if (!empty($attributes['term'])) { $this->term = (string) $attributes['term']; } if (!empty($attributes['scheme'])) { $this->scheme = (string) $attributes['scheme']; } if (!empty($attributes['label'])) { $this->label = (string) $attributes['label']; } $this->undefinedContent = (string) $categoryXml; }
[ "public", "function", "parseXml", "(", "$", "xmlString", ")", "{", "Validate", "::", "notNull", "(", "$", "xmlString", ",", "'xmlString'", ")", ";", "Validate", "::", "isString", "(", "$", "xmlString", ",", "'xmlString'", ")", ";", "$", "categoryXml", "=",...
Creates an ATOM Category instance with specified xml string. @param string $xmlString an XML based string of ATOM CONTENT
[ "Creates", "an", "ATOM", "Category", "instance", "with", "specified", "xml", "string", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/Atom/Category.php#L89-L108
train
Azure/azure-sdk-for-php
src/Common/Internal/Atom/Category.php
Category.writeInnerXml
public function writeInnerXml(\XMLWriter $xmlWriter) { Validate::notNull($xmlWriter, 'xmlWriter'); $this->writeOptionalAttribute( $xmlWriter, 'term', $this->term ); $this->writeOptionalAttribute( $xmlWriter, 'scheme', $this->scheme ); $this->writeOptionalAttribute( $xmlWriter, 'label', $this->label ); if (!empty($this->undefinedContent)) { $xmlWriter->writeRaw($this->undefinedContent); } }
php
public function writeInnerXml(\XMLWriter $xmlWriter) { Validate::notNull($xmlWriter, 'xmlWriter'); $this->writeOptionalAttribute( $xmlWriter, 'term', $this->term ); $this->writeOptionalAttribute( $xmlWriter, 'scheme', $this->scheme ); $this->writeOptionalAttribute( $xmlWriter, 'label', $this->label ); if (!empty($this->undefinedContent)) { $xmlWriter->writeRaw($this->undefinedContent); } }
[ "public", "function", "writeInnerXml", "(", "\\", "XMLWriter", "$", "xmlWriter", ")", "{", "Validate", "::", "notNull", "(", "$", "xmlWriter", ",", "'xmlWriter'", ")", ";", "$", "this", "->", "writeOptionalAttribute", "(", "$", "xmlWriter", ",", "'term'", ",...
Writes an XML representing the category. @param \XMLWriter $xmlWriter The XML writer
[ "Writes", "an", "XML", "representing", "the", "category", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/Atom/Category.php#L212-L236
train
Azure/azure-sdk-for-php
src/Common/Internal/Atom/Feed.php
Feed.parseXml
public function parseXml($xmlString) { $feedXml = simplexml_load_string($xmlString); $attributes = $feedXml->attributes(); $feedArray = (array) $feedXml; if (!empty($attributes)) { $this->attributes = (array) $attributes; } if (array_key_exists('author', $feedArray)) { $this->author = $this->processAuthorNode($feedArray); } if (array_key_exists('entry', $feedArray)) { $this->entry = $this->processEntryNode($feedArray); } if (array_key_exists('category', $feedArray)) { $this->category = $this->processCategoryNode($feedArray); } if (array_key_exists('contributor', $feedArray)) { $this->contributor = $this->processContributorNode($feedArray); } if (array_key_exists('generator', $feedArray)) { $generator = new Generator(); $generatorValue = $feedArray['generator']; if (is_string($generatorValue)) { $generator->setText($generatorValue); } else { $generator->parseXml($generatorValue->asXML()); } $this->generator = $generator; } if (array_key_exists('icon', $feedArray)) { $this->icon = (string) $feedArray['icon']; } if (array_key_exists('id', $feedArray)) { $this->id = (string) $feedArray['id']; } if (array_key_exists('link', $feedArray)) { $this->link = $this->processLinkNode($feedArray); } if (array_key_exists('logo', $feedArray)) { $this->logo = (string) $feedArray['logo']; } if (array_key_exists('rights', $feedArray)) { $this->rights = (string) $feedArray['rights']; } if (array_key_exists('subtitle', $feedArray)) { $this->subtitle = (string) $feedArray['subtitle']; } if (array_key_exists('title', $feedArray)) { $this->title = (string) $feedArray['title']; } if (array_key_exists('updated', $feedArray)) { $this->updated = \DateTime::createFromFormat( \DateTime::ATOM, (string) $feedArray['updated'] ); } }
php
public function parseXml($xmlString) { $feedXml = simplexml_load_string($xmlString); $attributes = $feedXml->attributes(); $feedArray = (array) $feedXml; if (!empty($attributes)) { $this->attributes = (array) $attributes; } if (array_key_exists('author', $feedArray)) { $this->author = $this->processAuthorNode($feedArray); } if (array_key_exists('entry', $feedArray)) { $this->entry = $this->processEntryNode($feedArray); } if (array_key_exists('category', $feedArray)) { $this->category = $this->processCategoryNode($feedArray); } if (array_key_exists('contributor', $feedArray)) { $this->contributor = $this->processContributorNode($feedArray); } if (array_key_exists('generator', $feedArray)) { $generator = new Generator(); $generatorValue = $feedArray['generator']; if (is_string($generatorValue)) { $generator->setText($generatorValue); } else { $generator->parseXml($generatorValue->asXML()); } $this->generator = $generator; } if (array_key_exists('icon', $feedArray)) { $this->icon = (string) $feedArray['icon']; } if (array_key_exists('id', $feedArray)) { $this->id = (string) $feedArray['id']; } if (array_key_exists('link', $feedArray)) { $this->link = $this->processLinkNode($feedArray); } if (array_key_exists('logo', $feedArray)) { $this->logo = (string) $feedArray['logo']; } if (array_key_exists('rights', $feedArray)) { $this->rights = (string) $feedArray['rights']; } if (array_key_exists('subtitle', $feedArray)) { $this->subtitle = (string) $feedArray['subtitle']; } if (array_key_exists('title', $feedArray)) { $this->title = (string) $feedArray['title']; } if (array_key_exists('updated', $feedArray)) { $this->updated = \DateTime::createFromFormat( \DateTime::ATOM, (string) $feedArray['updated'] ); } }
[ "public", "function", "parseXml", "(", "$", "xmlString", ")", "{", "$", "feedXml", "=", "simplexml_load_string", "(", "$", "xmlString", ")", ";", "$", "attributes", "=", "$", "feedXml", "->", "attributes", "(", ")", ";", "$", "feedArray", "=", "(", "arra...
Creates a feed object with specified XML string. @param string $xmlString An XML string representing the feed object
[ "Creates", "a", "feed", "object", "with", "specified", "XML", "string", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/Internal/Atom/Feed.php#L159-L230
train