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
Azure/azure-sdk-for-php
src/MediaServices/Models/ContentKeyAuthorizationPolicyRestriction.php
ContentKeyAuthorizationPolicyRestriction.fromArray
public function fromArray($options) { if (isset($options['Name'])) { Validate::isString($options['Name'], 'options[Name]'); $this->_name = $options['Name']; } if (isset($options['KeyRestrictionType'])) { Validate::isInteger($options['KeyRestrictionType'], 'options[KeyRestrictionType]'); $this->_keyRestrictionType = $options['KeyRestrictionType']; } if (isset($options['Requirements'])) { Validate::isString($options['Requirements'], 'options[Requirements]'); $this->_requirements = $options['Requirements']; } }
php
public function fromArray($options) { if (isset($options['Name'])) { Validate::isString($options['Name'], 'options[Name]'); $this->_name = $options['Name']; } if (isset($options['KeyRestrictionType'])) { Validate::isInteger($options['KeyRestrictionType'], 'options[KeyRestrictionType]'); $this->_keyRestrictionType = $options['KeyRestrictionType']; } if (isset($options['Requirements'])) { Validate::isString($options['Requirements'], 'options[Requirements]'); $this->_requirements = $options['Requirements']; } }
[ "public", "function", "fromArray", "(", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'Name'", "]", ")", ")", "{", "Validate", "::", "isString", "(", "$", "options", "[", "'Name'", "]", ",", "'options[Name]'", ")", ";", "$"...
Fill ContentKeyAuthorizationPolicyRestriction from array. @param array $options Array containing values for object properties
[ "Fill", "ContentKeyAuthorizationPolicyRestriction", "from", "array", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Models/ContentKeyAuthorizationPolicyRestriction.php#L103-L119
train
Azure/azure-sdk-for-php
src/Common/CloudConfigurationManager.php
CloudConfigurationManager.getConnectionString
public static function getConnectionString($key) { Validate::isString($key, 'key'); self::_init(); $value = null; foreach (self::$_sources as $source) { $value = call_user_func_array($source, [$key]); if (!empty($value)) { break; } } return $value; }
php
public static function getConnectionString($key) { Validate::isString($key, 'key'); self::_init(); $value = null; foreach (self::$_sources as $source) { $value = call_user_func_array($source, [$key]); if (!empty($value)) { break; } } return $value; }
[ "public", "static", "function", "getConnectionString", "(", "$", "key", ")", "{", "Validate", "::", "isString", "(", "$", "key", ",", "'key'", ")", ";", "self", "::", "_init", "(", ")", ";", "$", "value", "=", "null", ";", "foreach", "(", "self", "::...
Gets a connection string from all available sources. @param string $key The connection string key name @return string If the key does not exist return null
[ "Gets", "a", "connection", "string", "from", "all", "available", "sources", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/CloudConfigurationManager.php#L91-L107
train
Azure/azure-sdk-for-php
src/Common/CloudConfigurationManager.php
CloudConfigurationManager.registerSource
public static function registerSource($name, $provider = null, $prepend = false) { Validate::isString($name, 'name'); Validate::notNullOrEmpty($name, 'name'); self::_init(); $default = ConnectionStringSource::getDefaultSources(); // Try to get callback if the user is trying to register a default source. $provider = Utilities::tryGetValue($default, $name, $provider); Validate::notNullOrEmpty($provider, 'callback'); if ($prepend) { self::$_sources = array_merge( [$name => $provider], self::$_sources ); } else { self::$_sources[$name] = $provider; } }
php
public static function registerSource($name, $provider = null, $prepend = false) { Validate::isString($name, 'name'); Validate::notNullOrEmpty($name, 'name'); self::_init(); $default = ConnectionStringSource::getDefaultSources(); // Try to get callback if the user is trying to register a default source. $provider = Utilities::tryGetValue($default, $name, $provider); Validate::notNullOrEmpty($provider, 'callback'); if ($prepend) { self::$_sources = array_merge( [$name => $provider], self::$_sources ); } else { self::$_sources[$name] = $provider; } }
[ "public", "static", "function", "registerSource", "(", "$", "name", ",", "$", "provider", "=", "null", ",", "$", "prepend", "=", "false", ")", "{", "Validate", "::", "isString", "(", "$", "name", ",", "'name'", ")", ";", "Validate", "::", "notNullOrEmpty...
Registers a new connection string source provider. If the source to get registered is a default source, only the name of the source is required. @param string $name The source name @param callable $provider The source callback @param bool $prepend When true, the $provider is processed first when calling getConnectionString. When false (the default) the $provider is processed after the existing callbacks
[ "Registers", "a", "new", "connection", "string", "source", "provider", ".", "If", "the", "source", "to", "get", "registered", "is", "a", "default", "source", "only", "the", "name", "of", "the", "source", "is", "required", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/CloudConfigurationManager.php#L119-L140
train
Azure/azure-sdk-for-php
src/Common/CloudConfigurationManager.php
CloudConfigurationManager.unregisterSource
public static function unregisterSource($name) { Validate::isString($name, 'name'); Validate::notNullOrEmpty($name, 'name'); self::_init(); $sourceCallback = Utilities::tryGetValue(self::$_sources, $name); if (!is_null($sourceCallback)) { unset(self::$_sources[$name]); } return $sourceCallback; }
php
public static function unregisterSource($name) { Validate::isString($name, 'name'); Validate::notNullOrEmpty($name, 'name'); self::_init(); $sourceCallback = Utilities::tryGetValue(self::$_sources, $name); if (!is_null($sourceCallback)) { unset(self::$_sources[$name]); } return $sourceCallback; }
[ "public", "static", "function", "unregisterSource", "(", "$", "name", ")", "{", "Validate", "::", "isString", "(", "$", "name", ",", "'name'", ")", ";", "Validate", "::", "notNullOrEmpty", "(", "$", "name", ",", "'name'", ")", ";", "self", "::", "_init",...
Unregisters a connection string source. @param string $name The source name @return callable
[ "Unregisters", "a", "connection", "string", "source", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/Common/CloudConfigurationManager.php#L149-L163
train
Azure/azure-sdk-for-php
src/MediaServices/Models/AssetFile.php
AssetFile.createFromOptions
public static function createFromOptions(array $options) { Validate::notNull($options['Name'], 'options[Name]'); Validate::notNull($options['ParentAssetId'], 'options[ParentAssetId]'); $assetFile = new self($options['Name'], $options['ParentAssetId']); $assetFile->fromArray($options); return $assetFile; }
php
public static function createFromOptions(array $options) { Validate::notNull($options['Name'], 'options[Name]'); Validate::notNull($options['ParentAssetId'], 'options[ParentAssetId]'); $assetFile = new self($options['Name'], $options['ParentAssetId']); $assetFile->fromArray($options); return $assetFile; }
[ "public", "static", "function", "createFromOptions", "(", "array", "$", "options", ")", "{", "Validate", "::", "notNull", "(", "$", "options", "[", "'Name'", "]", ",", "'options[Name]'", ")", ";", "Validate", "::", "notNull", "(", "$", "options", "[", "'Pa...
Create asset file from array. @param array $options Array containing values for object properties @return AssetFile
[ "Create", "asset", "file", "from", "array", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Models/AssetFile.php#L150-L159
train
Azure/azure-sdk-for-php
src/ServiceBus/Internal/WrapTokenManager.php
WrapTokenManager.getAccessToken
public function getAccessToken($targetUri) { Validate::isString($targetUri, '$targetUri'); $this->_sweepExpiredTokens(); $scopeUri = $this->_createScopeUri($targetUri); if (array_key_exists($scopeUri, $this->_activeTokens)) { $activeToken = $this->_activeTokens[$scopeUri]; return $activeToken->getWrapAccessTokenResult()->getAccessToken(); } $wrapAccessTokenResult = $this->_wrapRestProxy->wrapAccessToken( $this->_wrapUri, $this->_wrapName, $this->_wrapPassword, $scopeUri ); $expirationDateTime = new \DateTime('now'); $expiresIn = intval($wrapAccessTokenResult->getExpiresIn() / 2); $expirationDateTime = $expirationDateTime->add( new \DateInterval('PT'.$expiresIn.'S') ); $acquiredActiveToken = new ActiveToken($wrapAccessTokenResult); $acquiredActiveToken->setExpirationDateTime($expirationDateTime); $this->_activeTokens[$scopeUri] = $acquiredActiveToken; return $wrapAccessTokenResult->getAccessToken(); }
php
public function getAccessToken($targetUri) { Validate::isString($targetUri, '$targetUri'); $this->_sweepExpiredTokens(); $scopeUri = $this->_createScopeUri($targetUri); if (array_key_exists($scopeUri, $this->_activeTokens)) { $activeToken = $this->_activeTokens[$scopeUri]; return $activeToken->getWrapAccessTokenResult()->getAccessToken(); } $wrapAccessTokenResult = $this->_wrapRestProxy->wrapAccessToken( $this->_wrapUri, $this->_wrapName, $this->_wrapPassword, $scopeUri ); $expirationDateTime = new \DateTime('now'); $expiresIn = intval($wrapAccessTokenResult->getExpiresIn() / 2); $expirationDateTime = $expirationDateTime->add( new \DateInterval('PT'.$expiresIn.'S') ); $acquiredActiveToken = new ActiveToken($wrapAccessTokenResult); $acquiredActiveToken->setExpirationDateTime($expirationDateTime); $this->_activeTokens[$scopeUri] = $acquiredActiveToken; return $wrapAccessTokenResult->getAccessToken(); }
[ "public", "function", "getAccessToken", "(", "$", "targetUri", ")", "{", "Validate", "::", "isString", "(", "$", "targetUri", ",", "'$targetUri'", ")", ";", "$", "this", "->", "_sweepExpiredTokens", "(", ")", ";", "$", "scopeUri", "=", "$", "this", "->", ...
Gets WRAP access token with specified target Uri. @param string $targetUri The target Uri of the WRAP access Token @return string
[ "Gets", "WRAP", "access", "token", "with", "specified", "target", "Uri", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/Internal/WrapTokenManager.php#L110-L141
train
Azure/azure-sdk-for-php
src/ServiceBus/Internal/WrapTokenManager.php
WrapTokenManager._sweepExpiredTokens
private function _sweepExpiredTokens() { foreach ($this->_activeTokens as $scopeUri => $activeToken) { $currentDateTime = new \DateTime('now'); if ($activeToken->getExpirationDateTime() < $currentDateTime) { unset($this->_activeTokens[$scopeUri]); } } }
php
private function _sweepExpiredTokens() { foreach ($this->_activeTokens as $scopeUri => $activeToken) { $currentDateTime = new \DateTime('now'); if ($activeToken->getExpirationDateTime() < $currentDateTime) { unset($this->_activeTokens[$scopeUri]); } } }
[ "private", "function", "_sweepExpiredTokens", "(", ")", "{", "foreach", "(", "$", "this", "->", "_activeTokens", "as", "$", "scopeUri", "=>", "$", "activeToken", ")", "{", "$", "currentDateTime", "=", "new", "\\", "DateTime", "(", "'now'", ")", ";", "if", ...
Removes the expired WRAP access tokens.
[ "Removes", "the", "expired", "WRAP", "access", "tokens", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/Internal/WrapTokenManager.php#L146-L154
train
Azure/azure-sdk-for-php
src/ServiceBus/Internal/WrapTokenManager.php
WrapTokenManager._createScopeUri
private function _createScopeUri($targetUri) { $targetUriComponents = parse_url($targetUri); $authority = Resources::EMPTY_STRING; if ($this->_containsValidAuthority($targetUriComponents)) { $authority = $this->_createAuthority($targetUriComponents); } $scopeUri = 'http://' .$authority .$targetUriComponents[Resources::PHP_URL_HOST]; if (array_key_exists(Resources::PHP_URL_PATH, $targetUriComponents)) { $scopeUri .= $targetUriComponents[Resources::PHP_URL_PATH]; } return $scopeUri; }
php
private function _createScopeUri($targetUri) { $targetUriComponents = parse_url($targetUri); $authority = Resources::EMPTY_STRING; if ($this->_containsValidAuthority($targetUriComponents)) { $authority = $this->_createAuthority($targetUriComponents); } $scopeUri = 'http://' .$authority .$targetUriComponents[Resources::PHP_URL_HOST]; if (array_key_exists(Resources::PHP_URL_PATH, $targetUriComponents)) { $scopeUri .= $targetUriComponents[Resources::PHP_URL_PATH]; } return $scopeUri; }
[ "private", "function", "_createScopeUri", "(", "$", "targetUri", ")", "{", "$", "targetUriComponents", "=", "parse_url", "(", "$", "targetUri", ")", ";", "$", "authority", "=", "Resources", "::", "EMPTY_STRING", ";", "if", "(", "$", "this", "->", "_containsV...
Creates a SCOPE URI with specified target URI. @param array $targetUri The target URI @return string
[ "Creates", "a", "SCOPE", "URI", "with", "specified", "target", "URI", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/Internal/WrapTokenManager.php#L163-L181
train
Azure/azure-sdk-for-php
src/ServiceBus/Internal/WrapTokenManager.php
WrapTokenManager._containsValidAuthority
private function _containsValidAuthority($uriComponents) { if (!array_key_exists(Resources::PHP_URL_USER, $uriComponents)) { return false; } if (empty($uriComponents[Resources::PHP_URL_USER])) { return false; } if (!array_key_exists(Resources::PHP_URL_PASS, $uriComponents)) { return false; } if (empty($uriComponents[Resources::PHP_URL_PASS])) { return false; } return true; }
php
private function _containsValidAuthority($uriComponents) { if (!array_key_exists(Resources::PHP_URL_USER, $uriComponents)) { return false; } if (empty($uriComponents[Resources::PHP_URL_USER])) { return false; } if (!array_key_exists(Resources::PHP_URL_PASS, $uriComponents)) { return false; } if (empty($uriComponents[Resources::PHP_URL_PASS])) { return false; } return true; }
[ "private", "function", "_containsValidAuthority", "(", "$", "uriComponents", ")", "{", "if", "(", "!", "array_key_exists", "(", "Resources", "::", "PHP_URL_USER", ",", "$", "uriComponents", ")", ")", "{", "return", "false", ";", "}", "if", "(", "empty", "(",...
Gets whether the authority related elements are valid. @param array $uriComponents The components of an URI @return bool
[ "Gets", "whether", "the", "authority", "related", "elements", "are", "valid", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/Internal/WrapTokenManager.php#L190-L209
train
Azure/azure-sdk-for-php
src/ServiceBus/Internal/WrapTokenManager.php
WrapTokenManager._createAuthority
private function _createAuthority($uriComponents) { $authority = sprintf( Resources::AUTHORITY_FORMAT, $uriComponents[Resources::PHP_URL_USER], $uriComponents[Resources::PHP_URL_PASS] ); return $authority; }
php
private function _createAuthority($uriComponents) { $authority = sprintf( Resources::AUTHORITY_FORMAT, $uriComponents[Resources::PHP_URL_USER], $uriComponents[Resources::PHP_URL_PASS] ); return $authority; }
[ "private", "function", "_createAuthority", "(", "$", "uriComponents", ")", "{", "$", "authority", "=", "sprintf", "(", "Resources", "::", "AUTHORITY_FORMAT", ",", "$", "uriComponents", "[", "Resources", "::", "PHP_URL_USER", "]", ",", "$", "uriComponents", "[", ...
Creates an authority string with specified Uri components. @param array $uriComponents The URI components @return string
[ "Creates", "an", "authority", "string", "with", "specified", "Uri", "components", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/Internal/WrapTokenManager.php#L218-L227
train
Azure/azure-sdk-for-php
src/MediaServices/Models/JobTemplate.php
JobTemplate.createFromOptions
public static function createFromOptions(array $options) { Validate::notNull($options['JobTemplateBody'], 'options[JobTemplateBody]'); $jobTemplate = new self( $options['JobTemplateBody'], $options['TemplateType'] ); $jobTemplate->fromArray($options); return $jobTemplate; }
php
public static function createFromOptions(array $options) { Validate::notNull($options['JobTemplateBody'], 'options[JobTemplateBody]'); $jobTemplate = new self( $options['JobTemplateBody'], $options['TemplateType'] ); $jobTemplate->fromArray($options); return $jobTemplate; }
[ "public", "static", "function", "createFromOptions", "(", "array", "$", "options", ")", "{", "Validate", "::", "notNull", "(", "$", "options", "[", "'JobTemplateBody'", "]", ",", "'options[JobTemplateBody]'", ")", ";", "$", "jobTemplate", "=", "new", "self", "...
Create asset from array. @param array $options Array containing values for object properties @return JobTemplate
[ "Create", "asset", "from", "array", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Models/JobTemplate.php#L115-L126
train
Azure/azure-sdk-for-php
src/MediaServices/Models/JobTemplate.php
JobTemplate.fromArray
public function fromArray(array $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['Created'])) { Validate::isDateString($options['Created'], 'options[Created]'); $this->_created = new \DateTime($options['Created']); } if (isset($options['LastModified'])) { Validate::isDateString( $options['LastModified'], 'options[LastModified]' ); $this->_lastModified = new \DateTime($options['LastModified']); } if (isset($options['JobTemplateBody'])) { Validate::isString( $options['JobTemplateBody'], 'options[JobTemplateBody]' ); $this->_jobTemplateBody = $options['JobTemplateBody']; } if (isset($options['NumberofInputAssets'])) { Validate::isInteger( $options['NumberofInputAssets'], 'options[NumberofInputAssets]' ); $this->_numberofInputAssets = $options['NumberofInputAssets']; } if (isset($options['TemplateType'])) { Validate::isInteger($options['TemplateType'], 'options[TemplateType]'); $this->_templateType = $options['TemplateType']; } }
php
public function fromArray(array $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['Created'])) { Validate::isDateString($options['Created'], 'options[Created]'); $this->_created = new \DateTime($options['Created']); } if (isset($options['LastModified'])) { Validate::isDateString( $options['LastModified'], 'options[LastModified]' ); $this->_lastModified = new \DateTime($options['LastModified']); } if (isset($options['JobTemplateBody'])) { Validate::isString( $options['JobTemplateBody'], 'options[JobTemplateBody]' ); $this->_jobTemplateBody = $options['JobTemplateBody']; } if (isset($options['NumberofInputAssets'])) { Validate::isInteger( $options['NumberofInputAssets'], 'options[NumberofInputAssets]' ); $this->_numberofInputAssets = $options['NumberofInputAssets']; } if (isset($options['TemplateType'])) { Validate::isInteger($options['TemplateType'], 'options[TemplateType]'); $this->_templateType = $options['TemplateType']; } }
[ "public", "function", "fromArray", "(", "array", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'Id'", "]", ")", ")", "{", "Validate", "::", "isString", "(", "$", "options", "[", "'Id'", "]", ",", "'options[Id]'", ")", ";", ...
Fill job template from array. @param array $options Array containing values for object properties
[ "Fill", "job", "template", "from", "array", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Models/JobTemplate.php#L147-L192
train
Azure/azure-sdk-for-php
src/ServiceManagement/Models/GetStorageServiceKeysResult.php
GetStorageServiceKeysResult.create
public static function create($parsed) { $result = new self(); $keys = Utilities::tryGetValue( $parsed, Resources::XTAG_STORAGE_SERVICE_KEYS ); $result->_url = Utilities::tryGetValue($parsed, Resources::XTAG_URL); $result->_primary = Utilities::tryGetValue( $keys, Resources::XTAG_PRIMARY ); $result->_secondary = Utilities::tryGetValue( $keys, Resources::XTAG_SECONDARY ); return $result; }
php
public static function create($parsed) { $result = new self(); $keys = Utilities::tryGetValue( $parsed, Resources::XTAG_STORAGE_SERVICE_KEYS ); $result->_url = Utilities::tryGetValue($parsed, Resources::XTAG_URL); $result->_primary = Utilities::tryGetValue( $keys, Resources::XTAG_PRIMARY ); $result->_secondary = Utilities::tryGetValue( $keys, Resources::XTAG_SECONDARY ); return $result; }
[ "public", "static", "function", "create", "(", "$", "parsed", ")", "{", "$", "result", "=", "new", "self", "(", ")", ";", "$", "keys", "=", "Utilities", "::", "tryGetValue", "(", "$", "parsed", ",", "Resources", "::", "XTAG_STORAGE_SERVICE_KEYS", ")", ";...
Creates new GetStorageServiceKeysResult object from parsed response. @param array $parsed The HTTP parsed response into array representation @return GetStorageServiceKeysResult
[ "Creates", "new", "GetStorageServiceKeysResult", "object", "from", "parsed", "response", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceManagement/Models/GetStorageServiceKeysResult.php#L68-L86
train
Azure/azure-sdk-for-php
src/ServiceManagement/Models/ListAffinityGroupsResult.php
ListAffinityGroupsResult.create
public static function create($parsed) { $result = new self(); $result->_affinityGroups = []; $entries = Utilities::tryGetArray( Resources::XTAG_AFFINITY_GROUP, $parsed ); foreach ($entries as $value) { $result->_affinityGroups[] = new AffinityGroup($value); } return $result; }
php
public static function create($parsed) { $result = new self(); $result->_affinityGroups = []; $entries = Utilities::tryGetArray( Resources::XTAG_AFFINITY_GROUP, $parsed ); foreach ($entries as $value) { $result->_affinityGroups[] = new AffinityGroup($value); } return $result; }
[ "public", "static", "function", "create", "(", "$", "parsed", ")", "{", "$", "result", "=", "new", "self", "(", ")", ";", "$", "result", "->", "_affinityGroups", "=", "[", "]", ";", "$", "entries", "=", "Utilities", "::", "tryGetArray", "(", "Resources...
Creates new ListAffinityGroupsResult from parsed response body. @param array $parsed The parsed response body @return ListAffinityGroupsResult
[ "Creates", "new", "ListAffinityGroupsResult", "from", "parsed", "response", "body", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceManagement/Models/ListAffinityGroupsResult.php#L58-L73
train
Azure/azure-sdk-for-php
src/MediaServices/Authentication/AzureAdClientAsymmetricKey.php
AzureAdClientAsymmetricKey.getCertificate
public function getCertificate($justbase64 = true) { if ($justbase64) { $str=str_replace("\n", "", $this->_certs['cert']); $str = str_replace("-----BEGIN CERTIFICATE-----","", $str); $str = str_replace("-----END CERTIFICATE-----","", $str); return $str; } return $this->_certs['cert']; }
php
public function getCertificate($justbase64 = true) { if ($justbase64) { $str=str_replace("\n", "", $this->_certs['cert']); $str = str_replace("-----BEGIN CERTIFICATE-----","", $str); $str = str_replace("-----END CERTIFICATE-----","", $str); return $str; } return $this->_certs['cert']; }
[ "public", "function", "getCertificate", "(", "$", "justbase64", "=", "true", ")", "{", "if", "(", "$", "justbase64", ")", "{", "$", "str", "=", "str_replace", "(", "\"\\n\"", ",", "\"\"", ",", "$", "this", "->", "_certs", "[", "'cert'", "]", ")", ";"...
Get the X.509 certificate @param boolean $justbase64 if true (the default), returns the certificate as plain base64 string (without headers nor formatting) @return string the certificate
[ "Get", "the", "X", ".", "509", "certificate" ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Authentication/AzureAdClientAsymmetricKey.php#L100-L110
train
Azure/azure-sdk-for-php
src/ServiceBus/Models/QueueInfo.php
QueueInfo.parseXml
public function parseXml($entryXml) { $this->_entry->parseXml($entryXml); $content = $this->_entry->getContent(); if (is_null($content)) { $this->_queueDescription = null; } else { $this->_queueDescription = QueueDescription::create($content->getText()); } }
php
public function parseXml($entryXml) { $this->_entry->parseXml($entryXml); $content = $this->_entry->getContent(); if (is_null($content)) { $this->_queueDescription = null; } else { $this->_queueDescription = QueueDescription::create($content->getText()); } }
[ "public", "function", "parseXml", "(", "$", "entryXml", ")", "{", "$", "this", "->", "_entry", "->", "parseXml", "(", "$", "entryXml", ")", ";", "$", "content", "=", "$", "this", "->", "_entry", "->", "getContent", "(", ")", ";", "if", "(", "is_null"...
Populates the properties of the queue info instance with a ATOM ENTRY XML string. @param string $entryXml An ATOM entry based XML string
[ "Populates", "the", "properties", "of", "the", "queue", "info", "instance", "with", "a", "ATOM", "ENTRY", "XML", "string", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceBus/Models/QueueInfo.php#L93-L102
train
Azure/azure-sdk-for-php
src/ServiceManagement/Models/GetDeploymentOptions.php
GetDeploymentOptions.setSlot
public function setSlot($slot) { Validate::isString($slot, 'slot'); Validate::notNullOrEmpty($slot, 'slot'); Validate::isTrue( DeploymentSlot::isValid($slot), sprintf(Resources::INVALID_SLOT, $slot) ); $this->_slot = $slot; }
php
public function setSlot($slot) { Validate::isString($slot, 'slot'); Validate::notNullOrEmpty($slot, 'slot'); Validate::isTrue( DeploymentSlot::isValid($slot), sprintf(Resources::INVALID_SLOT, $slot) ); $this->_slot = $slot; }
[ "public", "function", "setSlot", "(", "$", "slot", ")", "{", "Validate", "::", "isString", "(", "$", "slot", ",", "'slot'", ")", ";", "Validate", "::", "notNullOrEmpty", "(", "$", "slot", ",", "'slot'", ")", ";", "Validate", "::", "isTrue", "(", "Deplo...
Sets the deployment slot. @param string $slot The deployment slot name
[ "Sets", "the", "deployment", "slot", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceManagement/Models/GetDeploymentOptions.php#L71-L81
train
Azure/azure-sdk-for-php
src/ServiceManagement/Models/GetDeploymentOptions.php
GetDeploymentOptions.setDeploymentName
public function setDeploymentName($deploymentName) { Validate::isString($deploymentName, 'deploymentName'); Validate::notNullOrEmpty($deploymentName, 'deploymentName'); $this->_deploymentName = $deploymentName; }
php
public function setDeploymentName($deploymentName) { Validate::isString($deploymentName, 'deploymentName'); Validate::notNullOrEmpty($deploymentName, 'deploymentName'); $this->_deploymentName = $deploymentName; }
[ "public", "function", "setDeploymentName", "(", "$", "deploymentName", ")", "{", "Validate", "::", "isString", "(", "$", "deploymentName", ",", "'deploymentName'", ")", ";", "Validate", "::", "notNullOrEmpty", "(", "$", "deploymentName", ",", "'deploymentName'", "...
Sets the deployment name. @param string $deploymentName The deployment name
[ "Sets", "the", "deployment", "name", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceManagement/Models/GetDeploymentOptions.php#L98-L104
train
Azure/azure-sdk-for-php
src/ServiceManagement/Models/GetDeploymentResult.php
GetDeploymentResult.create
public static function create($parsed) { $result = new self(); $result->setDeployment(Deployment::create($parsed)); return $result; }
php
public static function create($parsed) { $result = new self(); $result->setDeployment(Deployment::create($parsed)); return $result; }
[ "public", "static", "function", "create", "(", "$", "parsed", ")", "{", "$", "result", "=", "new", "self", "(", ")", ";", "$", "result", "->", "setDeployment", "(", "Deployment", "::", "create", "(", "$", "parsed", ")", ")", ";", "return", "$", "resu...
Creates a new GetDeploymentResult from parsed response body. @param array $parsed The parsed response body in array representation @return GetDeploymentResult @static
[ "Creates", "a", "new", "GetDeploymentResult", "from", "parsed", "response", "body", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceManagement/Models/GetDeploymentResult.php#L57-L64
train
Azure/azure-sdk-for-php
src/ServiceRuntime/Internal/ChunkedGoalStateDeserializer.php
ChunkedGoalStateDeserializer.deserialize
public function deserialize() { do { $lengthString = stream_get_line($this->_inputStream, 100, "\n"); } while ( empty($lengthString) || $lengthString == "\n" || $lengthString == "\r" ); $intLengthString = hexdec(trim($lengthString)); $chunkData = stream_get_contents($this->_inputStream, $intLengthString); $goalState = $this->_deserializer->deserialize($chunkData); return $goalState; }
php
public function deserialize() { do { $lengthString = stream_get_line($this->_inputStream, 100, "\n"); } while ( empty($lengthString) || $lengthString == "\n" || $lengthString == "\r" ); $intLengthString = hexdec(trim($lengthString)); $chunkData = stream_get_contents($this->_inputStream, $intLengthString); $goalState = $this->_deserializer->deserialize($chunkData); return $goalState; }
[ "public", "function", "deserialize", "(", ")", "{", "do", "{", "$", "lengthString", "=", "stream_get_line", "(", "$", "this", "->", "_inputStream", ",", "100", ",", "\"\\n\"", ")", ";", "}", "while", "(", "empty", "(", "$", "lengthString", ")", "||", "...
Deserializes a goal state document. @return GoalState
[ "Deserializes", "a", "goal", "state", "document", "." ]
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/ServiceRuntime/Internal/ChunkedGoalStateDeserializer.php#L76-L90
train
Azure/azure-sdk-for-php
src/MediaServices/Templates/PlayReadyPlayRight.php
PlayReadyPlayRight.setUncompressedDigitalVideoOpl
public function setUncompressedDigitalVideoOpl($value) { if ($value != 100 && $value != 250 && $value != 270 && $value != 300) { throw new \InvalidArgumentException(ErrorMessages::UNCOMPRESSED_DIGITAL_VIDEO_OPL_VALUE_ERROR); } $this->_uncompressedDigitalVideoOpl = $value; }
php
public function setUncompressedDigitalVideoOpl($value) { if ($value != 100 && $value != 250 && $value != 270 && $value != 300) { throw new \InvalidArgumentException(ErrorMessages::UNCOMPRESSED_DIGITAL_VIDEO_OPL_VALUE_ERROR); } $this->_uncompressedDigitalVideoOpl = $value; }
[ "public", "function", "setUncompressedDigitalVideoOpl", "(", "$", "value", ")", "{", "if", "(", "$", "value", "!=", "100", "&&", "$", "value", "!=", "250", "&&", "$", "value", "!=", "270", "&&", "$", "value", "!=", "300", ")", "{", "throw", "new", "\...
Specifies the output protection level for uncompressed digital video. Valid values are null, 100, 250, 270, and 300. When the property is set to null, the output protection level is not set in the license. For further details on the meaning of the specific value see the PlayReady Compliance Rules. @param int $value UncompressedDigitalVideoOpl
[ "Specifies", "the", "output", "protection", "level", "for", "uncompressed", "digital", "video", ".", "Valid", "values", "are", "null", "100", "250", "270", "and", "300", ".", "When", "the", "property", "is", "set", "to", "null", "the", "output", "protection"...
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Templates/PlayReadyPlayRight.php#L340-L346
train
Azure/azure-sdk-for-php
src/MediaServices/Templates/PlayReadyPlayRight.php
PlayReadyPlayRight.setCompressedDigitalVideoOpl
public function setCompressedDigitalVideoOpl($value) { if ($value != 400 && $value != 500) { throw new \InvalidArgumentException(ErrorMessages::COMPRESSED_DIGITAL_VIDEO_OPL_VALUE_ERROR); } $this->_compressedDigitalVideoOpl = $value; }
php
public function setCompressedDigitalVideoOpl($value) { if ($value != 400 && $value != 500) { throw new \InvalidArgumentException(ErrorMessages::COMPRESSED_DIGITAL_VIDEO_OPL_VALUE_ERROR); } $this->_compressedDigitalVideoOpl = $value; }
[ "public", "function", "setCompressedDigitalVideoOpl", "(", "$", "value", ")", "{", "if", "(", "$", "value", "!=", "400", "&&", "$", "value", "!=", "500", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "ErrorMessages", "::", "COMPRESSED_DIGITA...
Specifies the output protection level for compressed digital video. Valid values are null, 400, and 500. When the property is set to null, the output protection level is not set in the license. For further details on the meaning of the specific value see the PlayReady Compliance Rules. @param int $value CompressedDigitalVideoOpl
[ "Specifies", "the", "output", "protection", "level", "for", "compressed", "digital", "video", ".", "Valid", "values", "are", "null", "400", "and", "500", ".", "When", "the", "property", "is", "set", "to", "null", "the", "output", "protection", "level", "is",...
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Templates/PlayReadyPlayRight.php#L367-L373
train
Azure/azure-sdk-for-php
src/MediaServices/Templates/PlayReadyPlayRight.php
PlayReadyPlayRight.setAnalogVideoOpl
public function setAnalogVideoOpl($value) { if ($value != 100 && $value != 150 && $value != 200) { throw new \InvalidArgumentException(ErrorMessages::ANALOG_VIDEO_OPL_VALUE_ERROR); } $this->_analogVideoOpl = $value; }
php
public function setAnalogVideoOpl($value) { if ($value != 100 && $value != 150 && $value != 200) { throw new \InvalidArgumentException(ErrorMessages::ANALOG_VIDEO_OPL_VALUE_ERROR); } $this->_analogVideoOpl = $value; }
[ "public", "function", "setAnalogVideoOpl", "(", "$", "value", ")", "{", "if", "(", "$", "value", "!=", "100", "&&", "$", "value", "!=", "150", "&&", "$", "value", "!=", "200", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "ErrorMessage...
Specifies the output protection level for analog video. Valid values are null, 100, 150, and 200. When the property is set to null, the output protection level is not set in the license. For further details on the meaning of the specific value see the PlayReady Compliance Rules. @param int $value AnalogVideoOpl
[ "Specifies", "the", "output", "protection", "level", "for", "analog", "video", ".", "Valid", "values", "are", "null", "100", "150", "and", "200", ".", "When", "the", "property", "is", "set", "to", "null", "the", "output", "protection", "level", "is", "not"...
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Templates/PlayReadyPlayRight.php#L394-L400
train
Azure/azure-sdk-for-php
src/MediaServices/Templates/PlayReadyPlayRight.php
PlayReadyPlayRight.setCompressedDigitalAudioOpl
public function setCompressedDigitalAudioOpl($value) { if ($value != 100 && $value != 150 && $value != 200 && $value != 250 && $value != 300) { throw new \InvalidArgumentException(ErrorMessages::COMPRESSED_DIGITAL_AUDIO_OPL_VALUE_ERROR); } $this->_compressedDigitalAudioOpl = $value; }
php
public function setCompressedDigitalAudioOpl($value) { if ($value != 100 && $value != 150 && $value != 200 && $value != 250 && $value != 300) { throw new \InvalidArgumentException(ErrorMessages::COMPRESSED_DIGITAL_AUDIO_OPL_VALUE_ERROR); } $this->_compressedDigitalAudioOpl = $value; }
[ "public", "function", "setCompressedDigitalAudioOpl", "(", "$", "value", ")", "{", "if", "(", "$", "value", "!=", "100", "&&", "$", "value", "!=", "150", "&&", "$", "value", "!=", "200", "&&", "$", "value", "!=", "250", "&&", "$", "value", "!=", "300...
Specifies the output protection level for compressed digital audio. Valid values are null, 100, 150, 200, 250, and 300. When the property is set to null, the output protection level is not set in the license. For further details on the meaning of the specific value see the PlayReady Compliance Rules. @param int $value CompressedDigitalAudioOpl
[ "Specifies", "the", "output", "protection", "level", "for", "compressed", "digital", "audio", ".", "Valid", "values", "are", "null", "100", "150", "200", "250", "and", "300", ".", "When", "the", "property", "is", "set", "to", "null", "the", "output", "prot...
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Templates/PlayReadyPlayRight.php#L421-L427
train
Azure/azure-sdk-for-php
src/MediaServices/Templates/PlayReadyPlayRight.php
PlayReadyPlayRight.setUncompressedDigitalAudioOpl
public function setUncompressedDigitalAudioOpl($value) { if ($value != 100 && $value != 150 && $value != 200 && $value != 250 && $value != 300) { throw new \InvalidArgumentException(ErrorMessages::UNCOMPRESSED_DIGITAL_AUDIO_OPL_VALUE_ERROR); } $this->_uncompressedDigitalAudioOpl = $value; }
php
public function setUncompressedDigitalAudioOpl($value) { if ($value != 100 && $value != 150 && $value != 200 && $value != 250 && $value != 300) { throw new \InvalidArgumentException(ErrorMessages::UNCOMPRESSED_DIGITAL_AUDIO_OPL_VALUE_ERROR); } $this->_uncompressedDigitalAudioOpl = $value; }
[ "public", "function", "setUncompressedDigitalAudioOpl", "(", "$", "value", ")", "{", "if", "(", "$", "value", "!=", "100", "&&", "$", "value", "!=", "150", "&&", "$", "value", "!=", "200", "&&", "$", "value", "!=", "250", "&&", "$", "value", "!=", "3...
Specifies the output protection level for uncompressed digital audio. Valid values are 100, 150, 200, 250, and 300. When the property is set to null, the output protection level is not set in the license. For further details on the meaning of the specific value see the PlayReady Compliance Rules. @param int $value UncompressedDigitalAudioOpl
[ "Specifies", "the", "output", "protection", "level", "for", "uncompressed", "digital", "audio", ".", "Valid", "values", "are", "100", "150", "200", "250", "and", "300", ".", "When", "the", "property", "is", "set", "to", "null", "the", "output", "protection",...
1e4eb9d083c73727561476ef3941c3b8b313cf04
https://github.com/Azure/azure-sdk-for-php/blob/1e4eb9d083c73727561476ef3941c3b8b313cf04/src/MediaServices/Templates/PlayReadyPlayRight.php#L448-L454
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/Tools/Migrations/AbstractMigration.php
AbstractMigration.execute
public function execute() { $response = $this->client->allDocs(100); $lastKey = null; do { if ($response->status !== 200) { throw new \RuntimeException('Error while migrating at offset '.$offset); } $bulkUpdater = $this->client->createBulkUpdater(); foreach ($response->body['rows'] as $row) { $doc = $this->migrate($row['doc']); if ($doc) { $bulkUpdater->updateDocument($doc); } $lastKey = $row['key']; } $bulkUpdater->execute(); $response = $this->client->allDocs(100, $lastKey); } while (count($response->body['rows']) > 1); }
php
public function execute() { $response = $this->client->allDocs(100); $lastKey = null; do { if ($response->status !== 200) { throw new \RuntimeException('Error while migrating at offset '.$offset); } $bulkUpdater = $this->client->createBulkUpdater(); foreach ($response->body['rows'] as $row) { $doc = $this->migrate($row['doc']); if ($doc) { $bulkUpdater->updateDocument($doc); } $lastKey = $row['key']; } $bulkUpdater->execute(); $response = $this->client->allDocs(100, $lastKey); } while (count($response->body['rows']) > 1); }
[ "public", "function", "execute", "(", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "allDocs", "(", "100", ")", ";", "$", "lastKey", "=", "null", ";", "do", "{", "if", "(", "$", "response", "->", "status", "!==", "200", ")", ...
Execute migration by iterating over all documents in batches of 100. @throws \RuntimeException @return void
[ "Execute", "migration", "by", "iterating", "over", "all", "documents", "in", "batches", "of", "100", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/Tools/Migrations/AbstractMigration.php#L25-L47
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/HTTP/StreamClient.php
StreamClient.getConnection
public function getConnection( $method, $path, $data = null, array $headers = [] ) { $fullPath = $path; if ($this->options['path']) { $fullPath = '/'.$this->options['path'].$path; } $this->checkConnection($method, $fullPath, $data, $headers); return $this->httpFilePointer; }
php
public function getConnection( $method, $path, $data = null, array $headers = [] ) { $fullPath = $path; if ($this->options['path']) { $fullPath = '/'.$this->options['path'].$path; } $this->checkConnection($method, $fullPath, $data, $headers); return $this->httpFilePointer; }
[ "public", "function", "getConnection", "(", "$", "method", ",", "$", "path", ",", "$", "data", "=", "null", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "$", "fullPath", "=", "$", "path", ";", "if", "(", "$", "this", "->", "options", "[...
Return the connection pointer after setting up the stream connection. The returned resource can later be used to read data in chunks. @param string $method @param string $path @param string $data @param array $headers @throws HTTPException @return resource
[ "Return", "the", "connection", "pointer", "after", "setting", "up", "the", "stream", "connection", ".", "The", "returned", "resource", "can", "later", "be", "used", "to", "read", "data", "in", "chunks", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/HTTP/StreamClient.php#L41-L55
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/HTTP/StreamClient.php
StreamClient.checkConnection
protected function checkConnection($method, $path, $data, $headers) { $basicAuth = ''; if ($this->options['username']) { $basicAuth .= "{$this->options['username']}:{$this->options['password']}@"; } if ($this->options['headers']) { $headers = array_merge($this->options['headers'], $headers); } if (!isset($headers['Content-Type'])) { $headers['Content-Type'] = 'application/json'; } $stringHeader = ''; if ($headers != null) { foreach ($headers as $key => $val) { $stringHeader .= $key.': '.$val."\r\n"; } } if ($this->httpFilePointer == null) { // TODO SSL support? $host = $this->options['host']; if ($this->options['port'] != 80) { $host .= ":{$this->options['port']}"; } $this->httpFilePointer = @fopen( 'http://'.$basicAuth.$host.$path, 'r', false, stream_context_create( [ 'http' => [ 'method' => $method, 'content' => $data, 'ignore_errors' => true, 'max_redirects' => 0, 'user_agent' => 'Doctrine CouchDB ODM $Revision$', 'timeout' => $this->options['timeout'], 'header' => $stringHeader, ], ] ) ); } // Check if connection has been established successfully. if ($this->httpFilePointer === false) { $error = error_get_last(); throw HTTPException::connectionFailure( $this->options['ip'], $this->options['port'], $error['message'], 0 ); } }
php
protected function checkConnection($method, $path, $data, $headers) { $basicAuth = ''; if ($this->options['username']) { $basicAuth .= "{$this->options['username']}:{$this->options['password']}@"; } if ($this->options['headers']) { $headers = array_merge($this->options['headers'], $headers); } if (!isset($headers['Content-Type'])) { $headers['Content-Type'] = 'application/json'; } $stringHeader = ''; if ($headers != null) { foreach ($headers as $key => $val) { $stringHeader .= $key.': '.$val."\r\n"; } } if ($this->httpFilePointer == null) { // TODO SSL support? $host = $this->options['host']; if ($this->options['port'] != 80) { $host .= ":{$this->options['port']}"; } $this->httpFilePointer = @fopen( 'http://'.$basicAuth.$host.$path, 'r', false, stream_context_create( [ 'http' => [ 'method' => $method, 'content' => $data, 'ignore_errors' => true, 'max_redirects' => 0, 'user_agent' => 'Doctrine CouchDB ODM $Revision$', 'timeout' => $this->options['timeout'], 'header' => $stringHeader, ], ] ) ); } // Check if connection has been established successfully. if ($this->httpFilePointer === false) { $error = error_get_last(); throw HTTPException::connectionFailure( $this->options['ip'], $this->options['port'], $error['message'], 0 ); } }
[ "protected", "function", "checkConnection", "(", "$", "method", ",", "$", "path", ",", "$", "data", ",", "$", "headers", ")", "{", "$", "basicAuth", "=", "''", ";", "if", "(", "$", "this", "->", "options", "[", "'username'", "]", ")", "{", "$", "ba...
Sets up the stream connection. @param $method @param $path @param $data @param $headers @throws HTTPException
[ "Sets", "up", "the", "stream", "connection", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/HTTP/StreamClient.php#L67-L121
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/HTTP/StreamClient.php
StreamClient.request
public function request($method, $path, $data = null, $raw = false, array $headers = []) { $fullPath = $path; if ($this->options['path']) { $fullPath = '/'.$this->options['path'].$path; } $this->checkConnection($method, $fullPath, $data, $headers); // Read request body. $body = ''; while (!feof($this->httpFilePointer)) { $body .= fgets($this->httpFilePointer); } $headers = $this->getStreamHeaders(); if (empty($headers['status'])) { throw HTTPException::readFailure( $this->options['ip'], $this->options['port'], 'Received an empty response or not status code', 0 ); } // Create response object from couch db response. if ($headers['status'] >= 400) { return new ErrorResponse($headers['status'], $headers, $body); } return new Response($headers['status'], $headers, $body, $raw); }
php
public function request($method, $path, $data = null, $raw = false, array $headers = []) { $fullPath = $path; if ($this->options['path']) { $fullPath = '/'.$this->options['path'].$path; } $this->checkConnection($method, $fullPath, $data, $headers); // Read request body. $body = ''; while (!feof($this->httpFilePointer)) { $body .= fgets($this->httpFilePointer); } $headers = $this->getStreamHeaders(); if (empty($headers['status'])) { throw HTTPException::readFailure( $this->options['ip'], $this->options['port'], 'Received an empty response or not status code', 0 ); } // Create response object from couch db response. if ($headers['status'] >= 400) { return new ErrorResponse($headers['status'], $headers, $body); } return new Response($headers['status'], $headers, $body, $raw); }
[ "public", "function", "request", "(", "$", "method", ",", "$", "path", ",", "$", "data", "=", "null", ",", "$", "raw", "=", "false", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "$", "fullPath", "=", "$", "path", ";", "if", "(", "$", ...
Perform a request to the server and return the result. Perform a request to the server and return the result converted into a Response object. If you do not expect a JSON structure, which could be converted in such a response object, set the forth parameter to true, and you get a response object returned, containing the raw body. @param string $method @param string $path @param string $data @param bool $raw @param array $headers @throws HTTPException @return Response
[ "Perform", "a", "request", "to", "the", "server", "and", "return", "the", "result", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/HTTP/StreamClient.php#L174-L206
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/HTTP/MultipartParserAndSender.php
MultipartParserAndSender.request
public function request( $sourceMethod, $sourcePath, $targetPath, $sourceData = null, array $sourceHeaders = [] ) { $this->sourceConnection = $this->sourceClient->getConnection( $sourceMethod, $sourcePath, $sourceData, $sourceHeaders ); $sourceResponseHeaders = $this->sourceClient->getStreamHeaders(); $body = ''; if (empty($sourceResponseHeaders['status'])) { try { // Close the connection resource. fclose($this->sourceConnection); } catch (\Exception $e) { } throw HTTPException::readFailure( $this->sourceClient->getOptions()['ip'], $this->sourceClient->getOptions()['port'], 'Received an empty response or not status code', 0 ); } elseif ($sourceResponseHeaders['status'] != 200) { while (!feof($this->sourceConnection)) { $body .= fgets($this->sourceConnection); } try { fclose($this->sourceConnection); } catch (\Exception $e) { } return new ErrorResponse( $sourceResponseHeaders['status'], $sourceResponseHeaders, $body ); } else { try { // Body is an array containing: // 1) Array of json string documents that don't have // attachments. These should be posted using the Bulk API. // 2) Responses of posting docs with attachments. $body = $this->parseAndSend($targetPath); try { fclose($this->sourceConnection); } catch (\Exception $e) { } return $body; } catch (\Exception $e) { throw $e; } } }
php
public function request( $sourceMethod, $sourcePath, $targetPath, $sourceData = null, array $sourceHeaders = [] ) { $this->sourceConnection = $this->sourceClient->getConnection( $sourceMethod, $sourcePath, $sourceData, $sourceHeaders ); $sourceResponseHeaders = $this->sourceClient->getStreamHeaders(); $body = ''; if (empty($sourceResponseHeaders['status'])) { try { // Close the connection resource. fclose($this->sourceConnection); } catch (\Exception $e) { } throw HTTPException::readFailure( $this->sourceClient->getOptions()['ip'], $this->sourceClient->getOptions()['port'], 'Received an empty response or not status code', 0 ); } elseif ($sourceResponseHeaders['status'] != 200) { while (!feof($this->sourceConnection)) { $body .= fgets($this->sourceConnection); } try { fclose($this->sourceConnection); } catch (\Exception $e) { } return new ErrorResponse( $sourceResponseHeaders['status'], $sourceResponseHeaders, $body ); } else { try { // Body is an array containing: // 1) Array of json string documents that don't have // attachments. These should be posted using the Bulk API. // 2) Responses of posting docs with attachments. $body = $this->parseAndSend($targetPath); try { fclose($this->sourceConnection); } catch (\Exception $e) { } return $body; } catch (\Exception $e) { throw $e; } } }
[ "public", "function", "request", "(", "$", "sourceMethod", ",", "$", "sourcePath", ",", "$", "targetPath", ",", "$", "sourceData", "=", "null", ",", "array", "$", "sourceHeaders", "=", "[", "]", ")", "{", "$", "this", "->", "sourceConnection", "=", "$", ...
Perform request to the source, parse the multipart response, stream the documents with attachments to the target and return the responses along with docs that did not have any attachments. @param string $sourceMethod @param string $sourcePath @param string $targetPath @param string $sourceData @param array $sourceHeaders @throws HTTPException @throws \Exception @return array|ErrorResponse|string
[ "Perform", "request", "to", "the", "source", "parse", "the", "multipart", "response", "stream", "the", "documents", "with", "attachments", "to", "the", "target", "and", "return", "the", "responses", "along", "with", "docs", "that", "did", "not", "have", "any",...
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/HTTP/MultipartParserAndSender.php#L84-L143
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/View/AbstractQuery.php
AbstractQuery.createDesignDocument
public function createDesignDocument() { if (!$this->doc) { throw new \Exception('No DesignDocument Class is connected to this view query, cannot create the design document with its corresponding view automatically!'); } $data = $this->doc->getData(); if ($data === null) { throw \Doctrine\CouchDB\JsonDecodeException::fromLastJsonError(); } $data['_id'] = '_design/'.$this->designDocumentName; $response = $this->client->request( 'PUT', sprintf( '/%s/_design/%s', $this->databaseName, $this->designDocumentName ), json_encode($data) ); }
php
public function createDesignDocument() { if (!$this->doc) { throw new \Exception('No DesignDocument Class is connected to this view query, cannot create the design document with its corresponding view automatically!'); } $data = $this->doc->getData(); if ($data === null) { throw \Doctrine\CouchDB\JsonDecodeException::fromLastJsonError(); } $data['_id'] = '_design/'.$this->designDocumentName; $response = $this->client->request( 'PUT', sprintf( '/%s/_design/%s', $this->databaseName, $this->designDocumentName ), json_encode($data) ); }
[ "public", "function", "createDesignDocument", "(", ")", "{", "if", "(", "!", "$", "this", "->", "doc", ")", "{", "throw", "new", "\\", "Exception", "(", "'No DesignDocument Class is connected to this view query, cannot create the design document with its corresponding view au...
Create non existing view. @throws \Doctrine\CouchDB\JsonDecodeException @throws \Exception @return void
[ "Create", "non", "existing", "view", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/View/AbstractQuery.php#L120-L141
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/MangoClient.php
MangoClient.createMangoIndex
public function createMangoIndex($fields, $ddoc = null, $name = null) { $documentPath = '/'.$this->databaseName.'/_index'; $params = ['index'=>['fields'=>$fields]]; if ($ddoc) { $params['ddoc'] = $ddoc; } if ($name) { $params['name'] = $name; } return $this->httpClient->request('POST', $documentPath, json_encode($params)); }
php
public function createMangoIndex($fields, $ddoc = null, $name = null) { $documentPath = '/'.$this->databaseName.'/_index'; $params = ['index'=>['fields'=>$fields]]; if ($ddoc) { $params['ddoc'] = $ddoc; } if ($name) { $params['name'] = $name; } return $this->httpClient->request('POST', $documentPath, json_encode($params)); }
[ "public", "function", "createMangoIndex", "(", "$", "fields", ",", "$", "ddoc", "=", "null", ",", "$", "name", "=", "null", ")", "{", "$", "documentPath", "=", "'/'", ".", "$", "this", "->", "databaseName", ".", "'/_index'", ";", "$", "params", "=", ...
Create a mango query index and return the HTTP response. @param array $fields - index fields @param string $ddoc - design document name @param string $name - view name
[ "Create", "a", "mango", "query", "index", "and", "return", "the", "HTTP", "response", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/MangoClient.php#L15-L29
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/MangoClient.php
MangoClient.deleteMangoIndex
public function deleteMangoIndex($ddoc, $name) { $documentPath = '/'.$this->databaseName.'/_index/_design/'.$ddoc.'/json/'.$name; $response = $this->httpClient->request('DELETE', $documentPath); return (isset($response->body['ok'])) ? true : false; }
php
public function deleteMangoIndex($ddoc, $name) { $documentPath = '/'.$this->databaseName.'/_index/_design/'.$ddoc.'/json/'.$name; $response = $this->httpClient->request('DELETE', $documentPath); return (isset($response->body['ok'])) ? true : false; }
[ "public", "function", "deleteMangoIndex", "(", "$", "ddoc", ",", "$", "name", ")", "{", "$", "documentPath", "=", "'/'", ".", "$", "this", "->", "databaseName", ".", "'/_index/_design/'", ".", "$", "ddoc", ".", "'/json/'", ".", "$", "name", ";", "$", "...
Delete a mango query index and return the HTTP response. @param string $ddoc - design document name @param string $name - view name
[ "Delete", "a", "mango", "query", "index", "and", "return", "the", "HTTP", "response", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/MangoClient.php#L37-L43
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/MangoClient.php
MangoClient.find
public function find(MangoQuery $query) { $documentPath = '/'.$this->databaseName.'/_find'; return $this->httpClient->request('POST', $documentPath, json_encode($query)); }
php
public function find(MangoQuery $query) { $documentPath = '/'.$this->databaseName.'/_find'; return $this->httpClient->request('POST', $documentPath, json_encode($query)); }
[ "public", "function", "find", "(", "MangoQuery", "$", "query", ")", "{", "$", "documentPath", "=", "'/'", ".", "$", "this", "->", "databaseName", ".", "'/_find'", ";", "return", "$", "this", "->", "httpClient", "->", "request", "(", "'POST'", ",", "$", ...
Find documents using Mango Query. @param MangoQuery $query @return HTTP\Response
[ "Find", "documents", "using", "Mango", "Query", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/MangoClient.php#L52-L56
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/CouchDBClient.php
CouchDBClient.create
public static function create(array $options) { if (isset($options['url'])) { $urlParts = parse_url($options['url']); foreach ($urlParts as $part => $value) { switch ($part) { case 'host': case 'user': case 'port': $options[$part] = $value; break; case 'path': $path = explode('/', $value); $options['dbname'] = array_pop($path); $options['path'] = trim(implode('/', $path), '/'); break; case 'pass': $options['password'] = $value; break; case 'scheme': $options['ssl'] = ($value === 'https'); break; default: break; } } } if (!isset($options['dbname'])) { throw new \InvalidArgumentException("'dbname' is a required option to create a CouchDBClient"); } $defaults = [ 'type' => 'socket', 'host' => 'localhost', 'port' => 5984, 'user' => null, 'password' => null, 'ip' => null, 'ssl' => false, 'path' => null, 'logging' => false, 'timeout' => 10, 'headers' => [], ]; $options = array_merge($defaults, $options); if (!isset(self::$clients[$options['type']])) { throw new \InvalidArgumentException(sprintf('There is no client implementation registered for %s, valid options are: %s', $options['type'], implode(', ', array_keys(self::$clients)) )); } $connectionClass = self::$clients[$options['type']]; $connection = new $connectionClass( $options['host'], $options['port'], $options['user'], $options['password'], $options['ip'], $options['ssl'], $options['path'], $options['timeout'], $options['headers'] ); if ($options['logging'] === true) { $connection = new HTTP\LoggingClient($connection); } return new static($connection, $options['dbname']); }
php
public static function create(array $options) { if (isset($options['url'])) { $urlParts = parse_url($options['url']); foreach ($urlParts as $part => $value) { switch ($part) { case 'host': case 'user': case 'port': $options[$part] = $value; break; case 'path': $path = explode('/', $value); $options['dbname'] = array_pop($path); $options['path'] = trim(implode('/', $path), '/'); break; case 'pass': $options['password'] = $value; break; case 'scheme': $options['ssl'] = ($value === 'https'); break; default: break; } } } if (!isset($options['dbname'])) { throw new \InvalidArgumentException("'dbname' is a required option to create a CouchDBClient"); } $defaults = [ 'type' => 'socket', 'host' => 'localhost', 'port' => 5984, 'user' => null, 'password' => null, 'ip' => null, 'ssl' => false, 'path' => null, 'logging' => false, 'timeout' => 10, 'headers' => [], ]; $options = array_merge($defaults, $options); if (!isset(self::$clients[$options['type']])) { throw new \InvalidArgumentException(sprintf('There is no client implementation registered for %s, valid options are: %s', $options['type'], implode(', ', array_keys(self::$clients)) )); } $connectionClass = self::$clients[$options['type']]; $connection = new $connectionClass( $options['host'], $options['port'], $options['user'], $options['password'], $options['ip'], $options['ssl'], $options['path'], $options['timeout'], $options['headers'] ); if ($options['logging'] === true) { $connection = new HTTP\LoggingClient($connection); } return new static($connection, $options['dbname']); }
[ "public", "static", "function", "create", "(", "array", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'url'", "]", ")", ")", "{", "$", "urlParts", "=", "parse_url", "(", "$", "options", "[", "'url'", "]", ")", ";", "forea...
Factory method for CouchDBClients. @param array $options @throws \InvalidArgumentException @return CouchDBClient
[ "Factory", "method", "for", "CouchDBClients", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/CouchDBClient.php#L64-L138
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/CouchDBClient.php
CouchDBClient.getUuids
public function getUuids($count = 1) { $count = (int) $count; $response = $this->httpClient->request('GET', '/_uuids?count='.$count); if ($response->status != 200) { throw new CouchDBException('Could not retrieve UUIDs from CouchDB.'); } return $response->body['uuids']; }
php
public function getUuids($count = 1) { $count = (int) $count; $response = $this->httpClient->request('GET', '/_uuids?count='.$count); if ($response->status != 200) { throw new CouchDBException('Could not retrieve UUIDs from CouchDB.'); } return $response->body['uuids']; }
[ "public", "function", "getUuids", "(", "$", "count", "=", "1", ")", "{", "$", "count", "=", "(", "int", ")", "$", "count", ";", "$", "response", "=", "$", "this", "->", "httpClient", "->", "request", "(", "'GET'", ",", "'/_uuids?count='", ".", "$", ...
Let CouchDB generate an array of UUIDs. @param int $count @throws CouchDBException @return array
[ "Let", "CouchDB", "generate", "an", "array", "of", "UUIDs", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/CouchDBClient.php#L177-L187
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/CouchDBClient.php
CouchDBClient.findDocument
public function findDocument($id) { $documentPath = '/'.$this->databaseName.'/'.urlencode($id); return $this->httpClient->request('GET', $documentPath); }
php
public function findDocument($id) { $documentPath = '/'.$this->databaseName.'/'.urlencode($id); return $this->httpClient->request('GET', $documentPath); }
[ "public", "function", "findDocument", "(", "$", "id", ")", "{", "$", "documentPath", "=", "'/'", ".", "$", "this", "->", "databaseName", ".", "'/'", ".", "urlencode", "(", "$", "id", ")", ";", "return", "$", "this", "->", "httpClient", "->", "request",...
Find a document by ID and return the HTTP response. @param string $id @return HTTP\Response
[ "Find", "a", "document", "by", "ID", "and", "return", "the", "HTTP", "response", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/CouchDBClient.php#L197-L202
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/CouchDBClient.php
CouchDBClient.findRevisions
public function findRevisions($docId, $revisions = null) { $path = '/'.$this->databaseName.'/'.urlencode($docId); if (is_array($revisions)) { // Fetch documents of only the specified leaf revisions. $path .= '?open_revs='.json_encode($revisions); } else { // Fetch documents of all leaf revisions. $path .= '?open_revs=all'; } // Set the Accept header to application/json to get a JSON array in the // response's body. Without this the response is multipart/mixed stream. return $this->httpClient->request( 'GET', $path, null, false, ['Accept' => 'application/json'] ); }
php
public function findRevisions($docId, $revisions = null) { $path = '/'.$this->databaseName.'/'.urlencode($docId); if (is_array($revisions)) { // Fetch documents of only the specified leaf revisions. $path .= '?open_revs='.json_encode($revisions); } else { // Fetch documents of all leaf revisions. $path .= '?open_revs=all'; } // Set the Accept header to application/json to get a JSON array in the // response's body. Without this the response is multipart/mixed stream. return $this->httpClient->request( 'GET', $path, null, false, ['Accept' => 'application/json'] ); }
[ "public", "function", "findRevisions", "(", "$", "docId", ",", "$", "revisions", "=", "null", ")", "{", "$", "path", "=", "'/'", ".", "$", "this", "->", "databaseName", ".", "'/'", ".", "urlencode", "(", "$", "docId", ")", ";", "if", "(", "is_array",...
Find documents of all or the specified revisions. If $revisions is an array containing the revisions to be fetched, only the documents of those revisions are fetched. Else document of all leaf revisions are fetched. @param string $docId @param mixed $revisions @return HTTP\Response
[ "Find", "documents", "of", "all", "or", "the", "specified", "revisions", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/CouchDBClient.php#L216-L235
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/CouchDBClient.php
CouchDBClient.findDocuments
public function findDocuments(array $ids, $limit = null, $offset = null) { $allDocsPath = '/'.$this->databaseName.'/_all_docs?include_docs=true'; if ($limit) { $allDocsPath .= '&limit='.(int) $limit; } if ($offset) { $allDocsPath .= '&skip='.(int) $offset; } return $this->httpClient->request('POST', $allDocsPath, json_encode( ['keys' => array_values($ids)]) ); }
php
public function findDocuments(array $ids, $limit = null, $offset = null) { $allDocsPath = '/'.$this->databaseName.'/_all_docs?include_docs=true'; if ($limit) { $allDocsPath .= '&limit='.(int) $limit; } if ($offset) { $allDocsPath .= '&skip='.(int) $offset; } return $this->httpClient->request('POST', $allDocsPath, json_encode( ['keys' => array_values($ids)]) ); }
[ "public", "function", "findDocuments", "(", "array", "$", "ids", ",", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "$", "allDocsPath", "=", "'/'", ".", "$", "this", "->", "databaseName", ".", "'/_all_docs?include_docs=true'", ";", ...
Find many documents by passing their ids and return the HTTP response. @param array $ids @param null $limit @param null $offset @return HTTP\Response
[ "Find", "many", "documents", "by", "passing", "their", "ids", "and", "return", "the", "HTTP", "response", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/CouchDBClient.php#L246-L259
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/CouchDBClient.php
CouchDBClient.allDocs
public function allDocs($limit = null, $startKey = null, $endKey = null, $skip = null, $descending = false) { $allDocsPath = '/'.$this->databaseName.'/_all_docs?include_docs=true'; if ($limit) { $allDocsPath .= '&limit='.(int) $limit; } if ($startKey) { $allDocsPath .= '&startkey="'.(string) $startKey.'"'; } if (!is_null($endKey)) { $allDocsPath .= '&endkey="'.(string) $endKey.'"'; } if (!is_null($skip) && (int) $skip > 0) { $allDocsPath .= '&skip='.(int) $skip; } if (!is_null($descending) && (bool) $descending === true) { $allDocsPath .= '&descending=true'; } return $this->httpClient->request('GET', $allDocsPath); }
php
public function allDocs($limit = null, $startKey = null, $endKey = null, $skip = null, $descending = false) { $allDocsPath = '/'.$this->databaseName.'/_all_docs?include_docs=true'; if ($limit) { $allDocsPath .= '&limit='.(int) $limit; } if ($startKey) { $allDocsPath .= '&startkey="'.(string) $startKey.'"'; } if (!is_null($endKey)) { $allDocsPath .= '&endkey="'.(string) $endKey.'"'; } if (!is_null($skip) && (int) $skip > 0) { $allDocsPath .= '&skip='.(int) $skip; } if (!is_null($descending) && (bool) $descending === true) { $allDocsPath .= '&descending=true'; } return $this->httpClient->request('GET', $allDocsPath); }
[ "public", "function", "allDocs", "(", "$", "limit", "=", "null", ",", "$", "startKey", "=", "null", ",", "$", "endKey", "=", "null", ",", "$", "skip", "=", "null", ",", "$", "descending", "=", "false", ")", "{", "$", "allDocsPath", "=", "'/'", ".",...
Get all documents. @param int|null $limit @param string|null $startKey @param string|null $endKey @param int|null $skip @param bool $descending @return HTTP\Response
[ "Get", "all", "documents", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/CouchDBClient.php#L272-L292
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/CouchDBClient.php
CouchDBClient.getVersion
public function getVersion() { if ($this->version === null) { $response = $this->httpClient->request('GET', '/'); if ($response->status != 200) { throw HTTPException::fromResponse('/', $response); } $this->version = $response->body['version']; } return $this->version; }
php
public function getVersion() { if ($this->version === null) { $response = $this->httpClient->request('GET', '/'); if ($response->status != 200) { throw HTTPException::fromResponse('/', $response); } $this->version = $response->body['version']; } return $this->version; }
[ "public", "function", "getVersion", "(", ")", "{", "if", "(", "$", "this", "->", "version", "===", "null", ")", "{", "$", "response", "=", "$", "this", "->", "httpClient", "->", "request", "(", "'GET'", ",", "'/'", ")", ";", "if", "(", "$", "respon...
Get the current version of CouchDB. @throws HTTPException @return string
[ "Get", "the", "current", "version", "of", "CouchDB", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/CouchDBClient.php#L301-L313
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/CouchDBClient.php
CouchDBClient.getDatabaseInfo
public function getDatabaseInfo($name = null) { $response = $this->httpClient->request('GET', '/'.($name ? urlencode($name) : $this->databaseName)); if ($response->status != 200) { throw HTTPException::fromResponse('/'.urlencode($name), $response); } return $response->body; }
php
public function getDatabaseInfo($name = null) { $response = $this->httpClient->request('GET', '/'.($name ? urlencode($name) : $this->databaseName)); if ($response->status != 200) { throw HTTPException::fromResponse('/'.urlencode($name), $response); } return $response->body; }
[ "public", "function", "getDatabaseInfo", "(", "$", "name", "=", "null", ")", "{", "$", "response", "=", "$", "this", "->", "httpClient", "->", "request", "(", "'GET'", ",", "'/'", ".", "(", "$", "name", "?", "urlencode", "(", "$", "name", ")", ":", ...
Get Information about a database. @param string $name @throws HTTPException @return array
[ "Get", "Information", "about", "a", "database", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/CouchDBClient.php#L377-L386
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/CouchDBClient.php
CouchDBClient.getChanges
public function getChanges(array $params = []) { $path = '/'.$this->databaseName.'/_changes'; $method = ((!isset($params['doc_ids']) || $params['doc_ids'] == null) ? 'GET' : 'POST'); $response = ''; if ($method == 'GET') { foreach ($params as $key => $value) { if (isset($params[$key]) === true && is_bool($value) === true) { $params[$key] = ($value) ? 'true' : 'false'; } } if (count($params) > 0) { $query = http_build_query($params); $path = $path.'?'.$query; } $response = $this->httpClient->request('GET', $path); } else { $path .= '?filter=_doc_ids'; $response = $this->httpClient->request('POST', $path, json_encode($params)); } if ($response->status != 200) { throw HTTPException::fromResponse($path, $response); } return $response->body; }
php
public function getChanges(array $params = []) { $path = '/'.$this->databaseName.'/_changes'; $method = ((!isset($params['doc_ids']) || $params['doc_ids'] == null) ? 'GET' : 'POST'); $response = ''; if ($method == 'GET') { foreach ($params as $key => $value) { if (isset($params[$key]) === true && is_bool($value) === true) { $params[$key] = ($value) ? 'true' : 'false'; } } if (count($params) > 0) { $query = http_build_query($params); $path = $path.'?'.$query; } $response = $this->httpClient->request('GET', $path); } else { $path .= '?filter=_doc_ids'; $response = $this->httpClient->request('POST', $path, json_encode($params)); } if ($response->status != 200) { throw HTTPException::fromResponse($path, $response); } return $response->body; }
[ "public", "function", "getChanges", "(", "array", "$", "params", "=", "[", "]", ")", "{", "$", "path", "=", "'/'", ".", "$", "this", "->", "databaseName", ".", "'/_changes'", ";", "$", "method", "=", "(", "(", "!", "isset", "(", "$", "params", "[",...
Get changes. @param array $params @throws HTTPException @return array
[ "Get", "changes", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/CouchDBClient.php#L397-L424
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/CouchDBClient.php
CouchDBClient.postDocument
public function postDocument(array $data) { $path = '/'.$this->databaseName; $response = $this->httpClient->request('POST', $path, json_encode($data)); if ($response->status != 201) { throw HTTPException::fromResponse($path, $response); } return [$response->body['id'], $response->body['rev']]; }
php
public function postDocument(array $data) { $path = '/'.$this->databaseName; $response = $this->httpClient->request('POST', $path, json_encode($data)); if ($response->status != 201) { throw HTTPException::fromResponse($path, $response); } return [$response->body['id'], $response->body['rev']]; }
[ "public", "function", "postDocument", "(", "array", "$", "data", ")", "{", "$", "path", "=", "'/'", ".", "$", "this", "->", "databaseName", ";", "$", "response", "=", "$", "this", "->", "httpClient", "->", "request", "(", "'POST'", ",", "$", "path", ...
Execute a POST request against CouchDB inserting a new document, leaving the server to generate a uuid. @param array $data @throws HTTPException @return array<id, rev>
[ "Execute", "a", "POST", "request", "against", "CouchDB", "inserting", "a", "new", "document", "leaving", "the", "server", "to", "generate", "a", "uuid", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/CouchDBClient.php#L445-L455
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/CouchDBClient.php
CouchDBClient.putDocument
public function putDocument($data, $id, $rev = null) { $data['_id'] = $id; if ($rev) { $data['_rev'] = $rev; } $path = '/'.$this->databaseName.'/'.urlencode($id); $response = $this->httpClient->request('PUT', $path, json_encode($data)); if ($response->status != 201) { throw HTTPException::fromResponse($path, $response); } return [$response->body['id'], $response->body['rev']]; }
php
public function putDocument($data, $id, $rev = null) { $data['_id'] = $id; if ($rev) { $data['_rev'] = $rev; } $path = '/'.$this->databaseName.'/'.urlencode($id); $response = $this->httpClient->request('PUT', $path, json_encode($data)); if ($response->status != 201) { throw HTTPException::fromResponse($path, $response); } return [$response->body['id'], $response->body['rev']]; }
[ "public", "function", "putDocument", "(", "$", "data", ",", "$", "id", ",", "$", "rev", "=", "null", ")", "{", "$", "data", "[", "'_id'", "]", "=", "$", "id", ";", "if", "(", "$", "rev", ")", "{", "$", "data", "[", "'_rev'", "]", "=", "$", ...
Execute a PUT request against CouchDB inserting or updating a document. @param array $data @param string $id @param string|null $rev @throws HTTPException @return array<id, rev>
[ "Execute", "a", "PUT", "request", "against", "CouchDB", "inserting", "or", "updating", "a", "document", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/CouchDBClient.php#L468-L483
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/CouchDBClient.php
CouchDBClient.createDesignDocument
public function createDesignDocument($designDocName, DesignDocument $designDoc) { $data = $designDoc->getData(); $data['_id'] = '_design/'.$designDocName; $documentPath = '/'.$this->databaseName.'/'.$data['_id']; $response = $this->httpClient->request('GET', $documentPath); if ($response->status == 200) { $docData = $response->body; $data['_rev'] = $docData['_rev']; } return $this->httpClient->request( 'PUT', sprintf('/%s/_design/%s', $this->databaseName, $designDocName), json_encode($data) ); }
php
public function createDesignDocument($designDocName, DesignDocument $designDoc) { $data = $designDoc->getData(); $data['_id'] = '_design/'.$designDocName; $documentPath = '/'.$this->databaseName.'/'.$data['_id']; $response = $this->httpClient->request('GET', $documentPath); if ($response->status == 200) { $docData = $response->body; $data['_rev'] = $docData['_rev']; } return $this->httpClient->request( 'PUT', sprintf('/%s/_design/%s', $this->databaseName, $designDocName), json_encode($data) ); }
[ "public", "function", "createDesignDocument", "(", "$", "designDocName", ",", "DesignDocument", "$", "designDoc", ")", "{", "$", "data", "=", "$", "designDoc", "->", "getData", "(", ")", ";", "$", "data", "[", "'_id'", "]", "=", "'_design/'", ".", "$", "...
Create or update a design document from the given in memory definition. @param string $designDocName @param DesignDocument $designDoc @return HTTP\Response
[ "Create", "or", "update", "a", "design", "document", "from", "the", "given", "in", "memory", "definition", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/CouchDBClient.php#L525-L543
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/CouchDBClient.php
CouchDBClient.getChangesAsStream
public function getChangesAsStream(array $params = []) { // Set feed to continuous. if (!isset($params['feed']) || $params['feed'] != 'continuous') { $params['feed'] = 'continuous'; } $path = '/'.$this->databaseName.'/_changes'; $connectionOptions = $this->getHttpClient()->getOptions(); $streamClient = new StreamClient( $connectionOptions['host'], $connectionOptions['port'], $connectionOptions['username'], $connectionOptions['password'], $connectionOptions['ip'], $connectionOptions['ssl'], $connectionOptions['path'] ); foreach ($params as $key => $value) { if (isset($params[$key]) === true && is_bool($value) === true) { $params[$key] = ($value) ? 'true' : 'false'; } } if (count($params) > 0) { $query = http_build_query($params); $path = $path.'?'.$query; } $stream = $streamClient->getConnection('GET', $path, null); $headers = $streamClient->getStreamHeaders($stream); if (empty($headers['status'])) { throw HTTPException::readFailure( $connectionOptions['ip'], $connectionOptions['port'], 'Received an empty response or not status code', 0 ); } elseif ($headers['status'] != 200) { $body = ''; while (!feof($stream)) { $body .= fgets($stream); } throw HTTPException::fromResponse($path, new Response($headers['status'], $headers, $body)); } // Everything seems okay. Return the connection resource. return $stream; }
php
public function getChangesAsStream(array $params = []) { // Set feed to continuous. if (!isset($params['feed']) || $params['feed'] != 'continuous') { $params['feed'] = 'continuous'; } $path = '/'.$this->databaseName.'/_changes'; $connectionOptions = $this->getHttpClient()->getOptions(); $streamClient = new StreamClient( $connectionOptions['host'], $connectionOptions['port'], $connectionOptions['username'], $connectionOptions['password'], $connectionOptions['ip'], $connectionOptions['ssl'], $connectionOptions['path'] ); foreach ($params as $key => $value) { if (isset($params[$key]) === true && is_bool($value) === true) { $params[$key] = ($value) ? 'true' : 'false'; } } if (count($params) > 0) { $query = http_build_query($params); $path = $path.'?'.$query; } $stream = $streamClient->getConnection('GET', $path, null); $headers = $streamClient->getStreamHeaders($stream); if (empty($headers['status'])) { throw HTTPException::readFailure( $connectionOptions['ip'], $connectionOptions['port'], 'Received an empty response or not status code', 0 ); } elseif ($headers['status'] != 200) { $body = ''; while (!feof($stream)) { $body .= fgets($stream); } throw HTTPException::fromResponse($path, new Response($headers['status'], $headers, $body)); } // Everything seems okay. Return the connection resource. return $stream; }
[ "public", "function", "getChangesAsStream", "(", "array", "$", "params", "=", "[", "]", ")", "{", "// Set feed to continuous.", "if", "(", "!", "isset", "(", "$", "params", "[", "'feed'", "]", ")", "||", "$", "params", "[", "'feed'", "]", "!=", "'continu...
Get changes as a stream. This method similar to the getChanges() method. But instead of returning the set of changes, it returns the connection stream from which the response can be read line by line. This is useful when you want to continuously get changes as they occur. Filtered changes feed is not supported by this method. @param array $params @param bool $raw @throws HTTPException @return resource
[ "Get", "changes", "as", "a", "stream", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/CouchDBClient.php#L747-L793
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/CouchDBClient.php
CouchDBClient.ensureFullCommit
public function ensureFullCommit() { $path = '/'.$this->databaseName.'/_ensure_full_commit'; $response = $this->httpClient->request('POST', $path); if ($response->status != 201) { throw HTTPException::fromResponse($path, $response); } return $response->body; }
php
public function ensureFullCommit() { $path = '/'.$this->databaseName.'/_ensure_full_commit'; $response = $this->httpClient->request('POST', $path); if ($response->status != 201) { throw HTTPException::fromResponse($path, $response); } return $response->body; }
[ "public", "function", "ensureFullCommit", "(", ")", "{", "$", "path", "=", "'/'", ".", "$", "this", "->", "databaseName", ".", "'/_ensure_full_commit'", ";", "$", "response", "=", "$", "this", "->", "httpClient", "->", "request", "(", "'POST'", ",", "$", ...
Commit any recent changes to the specified database to disk. @throws HTTPException @return array
[ "Commit", "any", "recent", "changes", "to", "the", "specified", "database", "to", "disk", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/CouchDBClient.php#L802-L811
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/Attachment.php
Attachment.getLength
public function getLength() { if (!$this->stub && !is_int($this->length)) { $this->length = strlen($this->data); } return $this->length; }
php
public function getLength() { if (!$this->stub && !is_int($this->length)) { $this->length = strlen($this->data); } return $this->length; }
[ "public", "function", "getLength", "(", ")", "{", "if", "(", "!", "$", "this", "->", "stub", "&&", "!", "is_int", "(", "$", "this", "->", "length", ")", ")", "{", "$", "this", "->", "length", "=", "strlen", "(", "$", "this", "->", "data", ")", ...
Get the length of the base64 encoded representation of this attachment. @return int
[ "Get", "the", "length", "of", "the", "base64", "encoded", "representation", "of", "this", "attachment", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/Attachment.php#L95-L102
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/Attachment.php
Attachment.lazyLoad
private function lazyLoad() { if ($this->stub) { $response = $this->httpClient->request('GET', $this->path, null, true); // raw request if ($response->status != 200) { throw HTTPException::fromResponse($this->path, $response); } $this->stub = false; $this->binaryData = $response->body; $this->data = \base64_encode($this->binaryData); } }
php
private function lazyLoad() { if ($this->stub) { $response = $this->httpClient->request('GET', $this->path, null, true); // raw request if ($response->status != 200) { throw HTTPException::fromResponse($this->path, $response); } $this->stub = false; $this->binaryData = $response->body; $this->data = \base64_encode($this->binaryData); } }
[ "private", "function", "lazyLoad", "(", ")", "{", "if", "(", "$", "this", "->", "stub", ")", "{", "$", "response", "=", "$", "this", "->", "httpClient", "->", "request", "(", "'GET'", ",", "$", "this", "->", "path", ",", "null", ",", "true", ")", ...
Lazy Load Data from CouchDB if necessary. @return void
[ "Lazy", "Load", "Data", "from", "CouchDB", "if", "necessary", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/Attachment.php#L131-L142
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/Attachment.php
Attachment.toArray
public function toArray() { if ($this->stub) { $json = ['stub' => true]; } else { $json = ['data' => $this->getBase64EncodedData()]; if ($this->contentType) { $json['content_type'] = $this->contentType; } } return $json; }
php
public function toArray() { if ($this->stub) { $json = ['stub' => true]; } else { $json = ['data' => $this->getBase64EncodedData()]; if ($this->contentType) { $json['content_type'] = $this->contentType; } } return $json; }
[ "public", "function", "toArray", "(", ")", "{", "if", "(", "$", "this", "->", "stub", ")", "{", "$", "json", "=", "[", "'stub'", "=>", "true", "]", ";", "}", "else", "{", "$", "json", "=", "[", "'data'", "=>", "$", "this", "->", "getBase64Encoded...
Attachments are special in how they need to be persisted depending on stub or not. TODO: Is this really necessary with all this special logic? Having attahments as special case without special code would be really awesome. @return string
[ "Attachments", "are", "special", "in", "how", "they", "need", "to", "be", "persisted", "depending", "on", "stub", "or", "not", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/Attachment.php#L167-L179
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/Attachment.php
Attachment.createFromBinaryData
public static function createFromBinaryData($data, $contentType = false) { if (\is_resource($data)) { $data = \stream_get_contents($data); } return new self($data, \base64_encode($data), $contentType); }
php
public static function createFromBinaryData($data, $contentType = false) { if (\is_resource($data)) { $data = \stream_get_contents($data); } return new self($data, \base64_encode($data), $contentType); }
[ "public", "static", "function", "createFromBinaryData", "(", "$", "data", ",", "$", "contentType", "=", "false", ")", "{", "if", "(", "\\", "is_resource", "(", "$", "data", ")", ")", "{", "$", "data", "=", "\\", "stream_get_contents", "(", "$", "data", ...
Create an Attachment from a string or resource of binary data. WARNING: Changes to the file handle after calling this method will *NOT* be recognized anymore. @param string|resource $data @param string $contentType @return Attachment
[ "Create", "an", "Attachment", "from", "a", "string", "or", "resource", "of", "binary", "data", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/Attachment.php#L216-L223
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/Attachment.php
Attachment.createFromBase64Data
public static function createFromBase64Data($data, $contentType = false, $revpos = false) { return new self(\base64_decode($data), $data, $contentType, false, $revpos); }
php
public static function createFromBase64Data($data, $contentType = false, $revpos = false) { return new self(\base64_decode($data), $data, $contentType, false, $revpos); }
[ "public", "static", "function", "createFromBase64Data", "(", "$", "data", ",", "$", "contentType", "=", "false", ",", "$", "revpos", "=", "false", ")", "{", "return", "new", "self", "(", "\\", "base64_decode", "(", "$", "data", ")", ",", "$", "data", "...
Create an attachment from base64 data. @param string $data @param string $contentType @param int $revpos @return Attachment
[ "Create", "an", "attachment", "from", "base64", "data", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/Attachment.php#L234-L237
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/Attachment.php
Attachment.createStub
public static function createStub($contentType, $length, $revPos, Client $httpClient, $path) { return new self(null, null, $contentType, $length, $revPos, $httpClient, $path); }
php
public static function createStub($contentType, $length, $revPos, Client $httpClient, $path) { return new self(null, null, $contentType, $length, $revPos, $httpClient, $path); }
[ "public", "static", "function", "createStub", "(", "$", "contentType", ",", "$", "length", ",", "$", "revPos", ",", "Client", "$", "httpClient", ",", "$", "path", ")", "{", "return", "new", "self", "(", "null", ",", "null", ",", "$", "contentType", ","...
Create a stub attachment that has lazy loading capabilities. @param string $contentType @param int $length @param int $revPos @param Client $httpClient @param string $path @return Attachment
[ "Create", "a", "stub", "attachment", "that", "has", "lazy", "loading", "capabilities", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/Attachment.php#L250-L253
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/View/Query.php
Query.getHttpQuery
protected function getHttpQuery() { $arguments = []; foreach ($this->params as $key => $value) { if (isset(self::$encodeParams[$key])) { $arguments[$key] = json_encode($value); } elseif (is_bool($value)) { $arguments[$key] = $value ? 'true' : 'false'; } else { $arguments[$key] = $value; } } return sprintf( '/%s/_design/%s/_view/%s?%s', $this->databaseName, $this->designDocumentName, $this->viewName, http_build_query($arguments) ); }
php
protected function getHttpQuery() { $arguments = []; foreach ($this->params as $key => $value) { if (isset(self::$encodeParams[$key])) { $arguments[$key] = json_encode($value); } elseif (is_bool($value)) { $arguments[$key] = $value ? 'true' : 'false'; } else { $arguments[$key] = $value; } } return sprintf( '/%s/_design/%s/_view/%s?%s', $this->databaseName, $this->designDocumentName, $this->viewName, http_build_query($arguments) ); }
[ "protected", "function", "getHttpQuery", "(", ")", "{", "$", "arguments", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "encodeParams", "...
Encode HTTP Query String for View correctly with the following rules in mind. 1. Params "key", "keys", "startkey" or "endkey" must be json encoded. 2. Booleans must be converted to "true" or "false" @return string
[ "Encode", "HTTP", "Query", "String", "for", "View", "correctly", "with", "the", "following", "rules", "in", "mind", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/View/Query.php#L37-L58
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/View/Query.php
Query.setStale
public function setStale($flag) { if (!is_bool($flag)) { $this->params['stale'] = $flag; } elseif ($flag === true) { $this->params['stale'] = 'ok'; } else { unset($this->params['stale']); } return $this; }
php
public function setStale($flag) { if (!is_bool($flag)) { $this->params['stale'] = $flag; } elseif ($flag === true) { $this->params['stale'] = 'ok'; } else { unset($this->params['stale']); } return $this; }
[ "public", "function", "setStale", "(", "$", "flag", ")", "{", "if", "(", "!", "is_bool", "(", "$", "flag", ")", ")", "{", "$", "this", "->", "params", "[", "'stale'", "]", "=", "$", "flag", ";", "}", "elseif", "(", "$", "flag", "===", "true", "...
If stale=ok is set CouchDB will not refresh the view even if it is stalled. @param bool $flag @return Query
[ "If", "stale", "=", "ok", "is", "set", "CouchDB", "will", "not", "refresh", "the", "view", "even", "if", "it", "is", "stalled", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/View/Query.php#L179-L190
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/HTTP/SocketClient.php
SocketClient.getConnection
public function getConnection( $method, $path, $data = null, array $headers = [] ) { $fullPath = $path; if ($this->options['path']) { $fullPath = '/'.$this->options['path'].$path; } $this->checkConnection(); $stringHeader = $this->buildRequest($method, $fullPath, $data, $headers); // Send the build request to the server if (fwrite($this->connection, $stringHeader) === false) { // Reestablish which seems to have been aborted // // The recursion in this method might be problematic if the // connection establishing mechanism does not correctly throw an // exception on failure. $this->connection = null; return $this->getConnection($method, $path, $data, $headers); } return $this->connection; }
php
public function getConnection( $method, $path, $data = null, array $headers = [] ) { $fullPath = $path; if ($this->options['path']) { $fullPath = '/'.$this->options['path'].$path; } $this->checkConnection(); $stringHeader = $this->buildRequest($method, $fullPath, $data, $headers); // Send the build request to the server if (fwrite($this->connection, $stringHeader) === false) { // Reestablish which seems to have been aborted // // The recursion in this method might be problematic if the // connection establishing mechanism does not correctly throw an // exception on failure. $this->connection = null; return $this->getConnection($method, $path, $data, $headers); } return $this->connection; }
[ "public", "function", "getConnection", "(", "$", "method", ",", "$", "path", ",", "$", "data", "=", "null", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "$", "fullPath", "=", "$", "path", ";", "if", "(", "$", "this", "->", "options", "[...
Return the socket after setting up the connection to server and writing the headers. The returned resource can later be used to read and write data in chunks. These should be done without much delay as the connection might get closed. @throws HTTPException @return resource
[ "Return", "the", "socket", "after", "setting", "up", "the", "connection", "to", "server", "and", "writing", "the", "headers", ".", "The", "returned", "resource", "can", "later", "be", "used", "to", "read", "and", "write", "data", "in", "chunks", ".", "Thes...
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/HTTP/SocketClient.php#L37-L63
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/HTTP/SocketClient.php
SocketClient.checkConnection
protected function checkConnection() { // Setting Connection scheme according ssl support if ($this->options['ssl']) { if (!extension_loaded('openssl')) { // no openssl extension loaded. // This is a bit hackisch... $this->connection = null; throw HTTPException::connectionFailure( $this->options['ip'], $this->options['port'], 'ssl activated without openssl extension loaded', 0 ); } $host = 'ssl://'.$this->options['host']; } else { $host = $this->options['ip']; } // If the connection could not be established, fsockopen sadly does not // only return false (as documented), but also always issues a warning. if (($this->connection === null) && (($this->connection = @fsockopen($host, $this->options['port'], $errno, $errstr, $this->options['timeout'])) === false)) { // This is a bit hackisch... $this->connection = null; throw HTTPException::connectionFailure( $this->options['ip'], $this->options['port'], $errstr, $errno ); } }
php
protected function checkConnection() { // Setting Connection scheme according ssl support if ($this->options['ssl']) { if (!extension_loaded('openssl')) { // no openssl extension loaded. // This is a bit hackisch... $this->connection = null; throw HTTPException::connectionFailure( $this->options['ip'], $this->options['port'], 'ssl activated without openssl extension loaded', 0 ); } $host = 'ssl://'.$this->options['host']; } else { $host = $this->options['ip']; } // If the connection could not be established, fsockopen sadly does not // only return false (as documented), but also always issues a warning. if (($this->connection === null) && (($this->connection = @fsockopen($host, $this->options['port'], $errno, $errstr, $this->options['timeout'])) === false)) { // This is a bit hackisch... $this->connection = null; throw HTTPException::connectionFailure( $this->options['ip'], $this->options['port'], $errstr, $errno ); } }
[ "protected", "function", "checkConnection", "(", ")", "{", "// Setting Connection scheme according ssl support", "if", "(", "$", "this", "->", "options", "[", "'ssl'", "]", ")", "{", "if", "(", "!", "extension_loaded", "(", "'openssl'", ")", ")", "{", "// no ope...
Check for server connection. Checks if the connection already has been established, or tries to establish the connection, if not done yet. @throws HTTPException @return void
[ "Check", "for", "server", "connection", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/HTTP/SocketClient.php#L75-L110
train
doctrine/couchdb-client
lib/Doctrine/CouchDB/HTTP/SocketClient.php
SocketClient.buildRequest
protected function buildRequest( $method, $path, $data = null, array $headers = [] ) { // Create basic request headers $host = "Host: {$this->options['host']}"; if ($this->options['port'] != 80) { $host .= ":{$this->options['port']}"; } $request = "$method $path HTTP/1.1\r\n$host\r\n"; // Add basic auth if set if ($this->options['username']) { $request .= sprintf("Authorization: Basic %s\r\n", base64_encode($this->options['username'].':'.$this->options['password']) ); } // Set keep-alive header, which helps to keep to connection // initialization costs low, especially when the database server is not // available in the locale net. $request .= 'Connection: '.($this->options['keep-alive'] ? 'Keep-Alive' : 'Close')."\r\n"; if ($this->options['headers']) { $headers = array_merge($this->options['headers'], $headers); } if (!isset($headers['Content-Type'])) { $headers['Content-Type'] = 'application/json'; } foreach ($headers as $key => $value) { if (is_bool($value) === true) { $value = ($value) ? 'true' : 'false'; } $request .= $key.': '.$value."\r\n"; } // Also add headers and request body if data should be sent to the // server. Otherwise just add the closing mark for the header section // of the request. if ($data !== null) { $request .= 'Content-Length: '.strlen($data)."\r\n\r\n"; $request .= $data; } else { $request .= "\r\n"; } return $request; }
php
protected function buildRequest( $method, $path, $data = null, array $headers = [] ) { // Create basic request headers $host = "Host: {$this->options['host']}"; if ($this->options['port'] != 80) { $host .= ":{$this->options['port']}"; } $request = "$method $path HTTP/1.1\r\n$host\r\n"; // Add basic auth if set if ($this->options['username']) { $request .= sprintf("Authorization: Basic %s\r\n", base64_encode($this->options['username'].':'.$this->options['password']) ); } // Set keep-alive header, which helps to keep to connection // initialization costs low, especially when the database server is not // available in the locale net. $request .= 'Connection: '.($this->options['keep-alive'] ? 'Keep-Alive' : 'Close')."\r\n"; if ($this->options['headers']) { $headers = array_merge($this->options['headers'], $headers); } if (!isset($headers['Content-Type'])) { $headers['Content-Type'] = 'application/json'; } foreach ($headers as $key => $value) { if (is_bool($value) === true) { $value = ($value) ? 'true' : 'false'; } $request .= $key.': '.$value."\r\n"; } // Also add headers and request body if data should be sent to the // server. Otherwise just add the closing mark for the header section // of the request. if ($data !== null) { $request .= 'Content-Length: '.strlen($data)."\r\n\r\n"; $request .= $data; } else { $request .= "\r\n"; } return $request; }
[ "protected", "function", "buildRequest", "(", "$", "method", ",", "$", "path", ",", "$", "data", "=", "null", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "// Create basic request headers", "$", "host", "=", "\"Host: {$this->options['host']}\"", ";",...
Build a HTTP 1.1 request. Build the HTTP 1.1 request headers from the given input. @param string $method @param string $path @param string $data @param array $headers @return string
[ "Build", "a", "HTTP", "1", ".", "1", "request", "." ]
2ca8e66343b6d00658a86ba9709fffcdb5965251
https://github.com/doctrine/couchdb-client/blob/2ca8e66343b6d00658a86ba9709fffcdb5965251/lib/Doctrine/CouchDB/HTTP/SocketClient.php#L124-L173
train
omise/omise-php
lib/omise/OmiseSearch.php
OmiseSearch.scope
public static function scope($scope, $publickey = null, $secretkey = null) { return new OmiseSearch($scope, $publickey, $secretkey); }
php
public static function scope($scope, $publickey = null, $secretkey = null) { return new OmiseSearch($scope, $publickey, $secretkey); }
[ "public", "static", "function", "scope", "(", "$", "scope", ",", "$", "publickey", "=", "null", ",", "$", "secretkey", "=", "null", ")", "{", "return", "new", "OmiseSearch", "(", "$", "scope", ",", "$", "publickey", ",", "$", "secretkey", ")", ";", "...
Create an instance of `OmiseSearch` with the given scope. @param string $scope See supported scope at [Search API](https://www.omise.co/search-api) page. @param string $publickey @param string $secretkey @return OmiseSearch The created instance.
[ "Create", "an", "instance", "of", "OmiseSearch", "with", "the", "given", "scope", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseSearch.php#L38-L41
train
omise/omise-php
lib/omise/OmiseSearch.php
OmiseSearch.filter
public function filter(array $filters = array()) { foreach ($filters as $k => $v) { if (is_bool($v)) { $filters[$k] = $v ? 'true' : 'false'; } } return $this->mergeAttributes('filters', $filters); }
php
public function filter(array $filters = array()) { foreach ($filters as $k => $v) { if (is_bool($v)) { $filters[$k] = $v ? 'true' : 'false'; } } return $this->mergeAttributes('filters', $filters); }
[ "public", "function", "filter", "(", "array", "$", "filters", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "filters", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_bool", "(", "$", "v", ")", ")", "{", "$", "filters", "[", ...
Update `filters` parameter. @param string $filters Searching text with specific key within the scope. @return OmiseSearch This instance.
[ "Update", "filters", "parameter", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseSearch.php#L77-L85
train
omise/omise-php
lib/omise/OmiseSearch.php
OmiseSearch.mergeAttributes
private function mergeAttributes($key, $value) { $this->dirty = true; $this->attributes[$key] = $value; return $this; }
php
private function mergeAttributes($key, $value) { $this->dirty = true; $this->attributes[$key] = $value; return $this; }
[ "private", "function", "mergeAttributes", "(", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "dirty", "=", "true", ";", "$", "this", "->", "attributes", "[", "$", "key", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Merge the given key and value to search attributes, and set instance state as dirty. @param string $key Search attribute key. @param mixed $value Search attribute value. @return OmiseSearch This instance.
[ "Merge", "the", "given", "key", "and", "value", "to", "search", "attributes", "and", "set", "instance", "state", "as", "dirty", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseSearch.php#L173-L179
train
omise/omise-php
lib/omise/OmiseCapabilities.php
OmiseCapabilities.retrieve
public static function retrieve($publickey = null, $secretkey = null) { return parent::g_retrieve(get_class(), self::getUrl(), $publickey, $secretkey); }
php
public static function retrieve($publickey = null, $secretkey = null) { return parent::g_retrieve(get_class(), self::getUrl(), $publickey, $secretkey); }
[ "public", "static", "function", "retrieve", "(", "$", "publickey", "=", "null", ",", "$", "secretkey", "=", "null", ")", "{", "return", "parent", "::", "g_retrieve", "(", "get_class", "(", ")", ",", "self", "::", "getUrl", "(", ")", ",", "$", "publicke...
Retrieves capabilities. @param string $publickey @param string $secretkey @return OmiseCapabilities
[ "Retrieves", "capabilities", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseCapabilities.php#L49-L52
train
omise/omise-php
lib/omise/OmiseCapabilities.php
OmiseCapabilities.makeBackendFilterCurrency
public function makeBackendFilterCurrency($currency) { return function ($backend) use ($currency) { return in_array(strtolower($currency), array_map('strtolower', $backend->currencies)); }; }
php
public function makeBackendFilterCurrency($currency) { return function ($backend) use ($currency) { return in_array(strtolower($currency), array_map('strtolower', $backend->currencies)); }; }
[ "public", "function", "makeBackendFilterCurrency", "(", "$", "currency", ")", "{", "return", "function", "(", "$", "backend", ")", "use", "(", "$", "currency", ")", "{", "return", "in_array", "(", "strtolower", "(", "$", "currency", ")", ",", "array_map", ...
Makes a filter function to check supported currency for backend. @param string $currency @return function
[ "Makes", "a", "filter", "function", "to", "check", "supported", "currency", "for", "backend", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseCapabilities.php#L92-L97
train
omise/omise-php
lib/omise/OmiseCapabilities.php
OmiseCapabilities.makeBackendFilterChargeAmount
public function makeBackendFilterChargeAmount($amount) { $defMin = $this['limits']['charge_amount']['min']; $defMax = $this['limits']['charge_amount']['max']; return function ($backend) use ($amount, $defMin, $defMax) { // temporary hack for now to correct min value for instalments to 500000 if ($backend->type == 'installment') { $min = 500000; } else { $min = empty($backend->amount['min']) ? $defMin : $backend->amount['min']; } $max = empty($backend->amount['max']) ? $defMax : $backend->amount['max']; return $amount >= $min && $amount <= $max; }; }
php
public function makeBackendFilterChargeAmount($amount) { $defMin = $this['limits']['charge_amount']['min']; $defMax = $this['limits']['charge_amount']['max']; return function ($backend) use ($amount, $defMin, $defMax) { // temporary hack for now to correct min value for instalments to 500000 if ($backend->type == 'installment') { $min = 500000; } else { $min = empty($backend->amount['min']) ? $defMin : $backend->amount['min']; } $max = empty($backend->amount['max']) ? $defMax : $backend->amount['max']; return $amount >= $min && $amount <= $max; }; }
[ "public", "function", "makeBackendFilterChargeAmount", "(", "$", "amount", ")", "{", "$", "defMin", "=", "$", "this", "[", "'limits'", "]", "[", "'charge_amount'", "]", "[", "'min'", "]", ";", "$", "defMax", "=", "$", "this", "[", "'limits'", "]", "[", ...
Makes a filter function to check if backends can handle given amount. @param int $amount @return function
[ "Makes", "a", "filter", "function", "to", "check", "if", "backends", "can", "handle", "given", "amount", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseCapabilities.php#L120-L134
train
omise/omise-php
lib/omise/OmiseCapabilities.php
OmiseCapabilities.combineFilters
private static function combineFilters($filters) { return function ($value) use ($filters) { foreach ($filters as $filter) { if (!$filter($value)) { return false; } } return true; }; }
php
private static function combineFilters($filters) { return function ($value) use ($filters) { foreach ($filters as $filter) { if (!$filter($value)) { return false; } } return true; }; }
[ "private", "static", "function", "combineFilters", "(", "$", "filters", ")", "{", "return", "function", "(", "$", "value", ")", "use", "(", "$", "filters", ")", "{", "foreach", "(", "$", "filters", "as", "$", "filter", ")", "{", "if", "(", "!", "$", ...
Combines boolean filters. @param [functions] $filters @return function
[ "Combines", "boolean", "filters", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseCapabilities.php#L143-L153
train
omise/omise-php
lib/omise/OmiseCardList.php
OmiseCardList.retrieve
public function retrieve($id) { $result = parent::execute($this->getUrl($id), parent::REQUEST_GET, self::getResourceKey()); return new OmiseCard($result, $this->_customerID, $this->_publickey, $this->_secretkey); }
php
public function retrieve($id) { $result = parent::execute($this->getUrl($id), parent::REQUEST_GET, self::getResourceKey()); return new OmiseCard($result, $this->_customerID, $this->_publickey, $this->_secretkey); }
[ "public", "function", "retrieve", "(", "$", "id", ")", "{", "$", "result", "=", "parent", "::", "execute", "(", "$", "this", "->", "getUrl", "(", "$", "id", ")", ",", "parent", "::", "REQUEST_GET", ",", "self", "::", "getResourceKey", "(", ")", ")", ...
retrieve a card @param string $id @return OmiseCard
[ "retrieve", "a", "card" ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseCardList.php#L29-L34
train
omise/omise-php
lib/omise/res/obj/OmiseObject.php
OmiseObject.refresh
public function refresh($values, $clear = false) { if ($clear) { $this->_values = array(); } $this->_values = array_merge($this->_values, $values); }
php
public function refresh($values, $clear = false) { if ($clear) { $this->_values = array(); } $this->_values = array_merge($this->_values, $values); }
[ "public", "function", "refresh", "(", "$", "values", ",", "$", "clear", "=", "false", ")", "{", "if", "(", "$", "clear", ")", "{", "$", "this", "->", "_values", "=", "array", "(", ")", ";", "}", "$", "this", "->", "_values", "=", "array_merge", "...
Reload the object. @param array $values @param boolean $clear
[ "Reload", "the", "object", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/res/obj/OmiseObject.php#L44-L51
train
omise/omise-php
lib/omise/OmiseCustomer.php
OmiseCustomer.create
public static function create($params, $publickey = null, $secretkey = null) { return parent::g_create(get_class(), self::getUrl(), $params, $publickey, $secretkey); }
php
public static function create($params, $publickey = null, $secretkey = null) { return parent::g_create(get_class(), self::getUrl(), $params, $publickey, $secretkey); }
[ "public", "static", "function", "create", "(", "$", "params", ",", "$", "publickey", "=", "null", ",", "$", "secretkey", "=", "null", ")", "{", "return", "parent", "::", "g_create", "(", "get_class", "(", ")", ",", "self", "::", "getUrl", "(", ")", "...
Creates a new customer. @param array $params @param string $publickey @param string $secretkey @return OmiseCustomer
[ "Creates", "a", "new", "customer", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseCustomer.php#L44-L47
train
omise/omise-php
lib/omise/OmiseCustomer.php
OmiseCustomer.cards
public function cards($options = array()) { if (is_array($options) && ! empty($options)) { $cards = parent::execute(self::getUrl($this['id']) . '/cards?' . http_build_query($options), parent::REQUEST_GET, parent::getResourceKey()); } else { $cards = $this['cards']; } return new OmiseCardList($cards, $this['id'], $this->_publickey, $this->_secretkey); }
php
public function cards($options = array()) { if (is_array($options) && ! empty($options)) { $cards = parent::execute(self::getUrl($this['id']) . '/cards?' . http_build_query($options), parent::REQUEST_GET, parent::getResourceKey()); } else { $cards = $this['cards']; } return new OmiseCardList($cards, $this['id'], $this->_publickey, $this->_secretkey); }
[ "public", "function", "cards", "(", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "is_array", "(", "$", "options", ")", "&&", "!", "empty", "(", "$", "options", ")", ")", "{", "$", "cards", "=", "parent", "::", "execute", "(", "sel...
Gets a list of all cards belongs to this customer. @param array $options @return OmiseCardList
[ "Gets", "a", "list", "of", "all", "cards", "belongs", "to", "this", "customer", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseCustomer.php#L100-L109
train
omise/omise-php
lib/omise/OmiseCustomer.php
OmiseCustomer.schedules
public function schedules($options = array()) { if ($this['object'] === 'customer') { if (is_array($options)) { $options = '?' . http_build_query($options); } return parent::g_retrieve('OmiseScheduleList', self::getUrl($this['id'] . '/schedules' . $options), $this->_publickey, $this->_secretkey); } }
php
public function schedules($options = array()) { if ($this['object'] === 'customer') { if (is_array($options)) { $options = '?' . http_build_query($options); } return parent::g_retrieve('OmiseScheduleList', self::getUrl($this['id'] . '/schedules' . $options), $this->_publickey, $this->_secretkey); } }
[ "public", "function", "schedules", "(", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "[", "'object'", "]", "===", "'customer'", ")", "{", "if", "(", "is_array", "(", "$", "options", ")", ")", "{", "$", "options", "=", ...
Gets a list of charge schedules that belongs to a given customer. @param array|string $options @return OmiseScheduleList
[ "Gets", "a", "list", "of", "charge", "schedules", "that", "belongs", "to", "a", "given", "customer", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseCustomer.php#L130-L139
train
omise/omise-php
lib/omise/OmiseTransfer.php
OmiseTransfer.schedule
public static function schedule($params, $publickey = null, $secretkey = null) { return new OmiseScheduler('transfer', $params, $publickey, $secretkey); }
php
public static function schedule($params, $publickey = null, $secretkey = null) { return new OmiseScheduler('transfer', $params, $publickey, $secretkey); }
[ "public", "static", "function", "schedule", "(", "$", "params", ",", "$", "publickey", "=", "null", ",", "$", "secretkey", "=", "null", ")", "{", "return", "new", "OmiseScheduler", "(", "'transfer'", ",", "$", "params", ",", "$", "publickey", ",", "$", ...
Schedule a transfer. @param string $params @param string $publickey @param string $secretkey @return OmiseScheduler
[ "Schedule", "a", "transfer", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseTransfer.php#L44-L47
train
omise/omise-php
lib/omise/OmiseTransfer.php
OmiseTransfer.schedules
public static function schedules($options = array(), $publickey = null, $secretkey = null) { if (is_array($options)) { $options = '?' . http_build_query($options); } return parent::g_retrieve('OmiseScheduleList', self::getUrl('schedules' . $options), $publickey, $secretkey); }
php
public static function schedules($options = array(), $publickey = null, $secretkey = null) { if (is_array($options)) { $options = '?' . http_build_query($options); } return parent::g_retrieve('OmiseScheduleList', self::getUrl('schedules' . $options), $publickey, $secretkey); }
[ "public", "static", "function", "schedules", "(", "$", "options", "=", "array", "(", ")", ",", "$", "publickey", "=", "null", ",", "$", "secretkey", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "options", ")", ")", "{", "$", "options", "...
Gets a list of transfer schedules. @param array|string $options @param string $publickey @param string $secretkey @return OmiseScheduleList
[ "Gets", "a", "list", "of", "transfer", "schedules", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseTransfer.php#L104-L111
train
omise/omise-php
lib/omise/exception/OmiseExceptions.php
OmiseException.getInstance
public static function getInstance($array) { switch ($array['code']) { case 'authentication_failure': return new OmiseAuthenticationFailureException($array['message'], $array); case 'bad_request': return new OmiseBadRequestException($array['message'], $array); case 'not_found': return new OmiseNotFoundException($array['message'], $array); case 'used_token': return new OmiseUsedTokenException($array['message'], $array); case 'invalid_card': return new OmiseInvalidCardException($array['message'], $array); case 'invalid_card_token': return new OmiseInvalidCardTokenException($array['message'], $array); case 'missing_card': return new OmiseMissingCardException($array['message'], $array); case 'invalid_charge': return new OmiseInvalidChargeException($array['message'], $array); case 'failed_capture': return new OmiseFailedCaptureException($array['message'], $array); case 'failed_fraud_check': return new OmiseFailedFraudCheckException($array['message'], $array); case 'failed_refund': return new OmiseFailedRefundException($array['message'], $array); case 'invalid_link': return new OmiseInvalidLinkException($array['message'], $array); case 'invalid_recipient': return new OmiseInvalidRecipientException($array['message'], $array); case 'invalid_bank_account': return new OmiseInvalidBankAccountException($array['message'], $array); default: return new OmiseUndefinedException($array['message'], $array); } }
php
public static function getInstance($array) { switch ($array['code']) { case 'authentication_failure': return new OmiseAuthenticationFailureException($array['message'], $array); case 'bad_request': return new OmiseBadRequestException($array['message'], $array); case 'not_found': return new OmiseNotFoundException($array['message'], $array); case 'used_token': return new OmiseUsedTokenException($array['message'], $array); case 'invalid_card': return new OmiseInvalidCardException($array['message'], $array); case 'invalid_card_token': return new OmiseInvalidCardTokenException($array['message'], $array); case 'missing_card': return new OmiseMissingCardException($array['message'], $array); case 'invalid_charge': return new OmiseInvalidChargeException($array['message'], $array); case 'failed_capture': return new OmiseFailedCaptureException($array['message'], $array); case 'failed_fraud_check': return new OmiseFailedFraudCheckException($array['message'], $array); case 'failed_refund': return new OmiseFailedRefundException($array['message'], $array); case 'invalid_link': return new OmiseInvalidLinkException($array['message'], $array); case 'invalid_recipient': return new OmiseInvalidRecipientException($array['message'], $array); case 'invalid_bank_account': return new OmiseInvalidBankAccountException($array['message'], $array); default: return new OmiseUndefinedException($array['message'], $array); } }
[ "public", "static", "function", "getInstance", "(", "$", "array", ")", "{", "switch", "(", "$", "array", "[", "'code'", "]", ")", "{", "case", "'authentication_failure'", ":", "return", "new", "OmiseAuthenticationFailureException", "(", "$", "array", "[", "'me...
Returns an instance of an exception class from the given error response. @param array $array @return OmiseAuthenticationFailureException|OmiseNotFoundException|OmiseUsedTokenException|OmiseInvalidCardException|OmiseInvalidCardTokenException|OmiseMissingCardException|OmiseInvalidChargeException|OmiseFailedCaptureException|OmiseFailedFraudCheckException|OmiseUndefinedException
[ "Returns", "an", "instance", "of", "an", "exception", "class", "from", "the", "given", "error", "response", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/exception/OmiseExceptions.php#L20-L68
train
omise/omise-php
lib/omise/res/OmiseApiResource.php
OmiseApiResource.g_retrieve
protected static function g_retrieve($clazz, $url, $publickey = null, $secretkey = null) { $resource = call_user_func(array($clazz, 'getInstance'), $clazz, $publickey, $secretkey); $result = $resource->execute($url, self::REQUEST_GET, $resource->getResourceKey()); $resource->refresh($result); return $resource; }
php
protected static function g_retrieve($clazz, $url, $publickey = null, $secretkey = null) { $resource = call_user_func(array($clazz, 'getInstance'), $clazz, $publickey, $secretkey); $result = $resource->execute($url, self::REQUEST_GET, $resource->getResourceKey()); $resource->refresh($result); return $resource; }
[ "protected", "static", "function", "g_retrieve", "(", "$", "clazz", ",", "$", "url", ",", "$", "publickey", "=", "null", ",", "$", "secretkey", "=", "null", ")", "{", "$", "resource", "=", "call_user_func", "(", "array", "(", "$", "clazz", ",", "'getIn...
Retrieves the resource. @param string $clazz @param string $publickey @param string $secretkey @throws Exception|OmiseException @return OmiseAccount|OmiseBalance|OmiseCharge|OmiseCustomer|OmiseToken|OmiseTransaction|OmiseTransfer
[ "Retrieves", "the", "resource", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/res/OmiseApiResource.php#L50-L57
train
omise/omise-php
lib/omise/res/OmiseApiResource.php
OmiseApiResource.g_create
protected static function g_create($clazz, $url, $params, $publickey = null, $secretkey = null) { $resource = call_user_func(array($clazz, 'getInstance'), $clazz, $publickey, $secretkey); $result = $resource->execute($url, self::REQUEST_POST, $resource->getResourceKey(), $params); $resource->refresh($result); return $resource; }
php
protected static function g_create($clazz, $url, $params, $publickey = null, $secretkey = null) { $resource = call_user_func(array($clazz, 'getInstance'), $clazz, $publickey, $secretkey); $result = $resource->execute($url, self::REQUEST_POST, $resource->getResourceKey(), $params); $resource->refresh($result); return $resource; }
[ "protected", "static", "function", "g_create", "(", "$", "clazz", ",", "$", "url", ",", "$", "params", ",", "$", "publickey", "=", "null", ",", "$", "secretkey", "=", "null", ")", "{", "$", "resource", "=", "call_user_func", "(", "array", "(", "$", "...
Creates the resource with given parameters.in an associative array. @param string $clazz @param string $url @param array $params @param string $publickey @param string $secretkey @throws Exception|OmiseException @return OmiseAccount|OmiseBalance|OmiseCharge|OmiseCustomer|OmiseToken|OmiseTransaction|OmiseTransfer
[ "Creates", "the", "resource", "with", "given", "parameters", ".", "in", "an", "associative", "array", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/res/OmiseApiResource.php#L72-L79
train
omise/omise-php
lib/omise/res/OmiseApiResource.php
OmiseApiResource.g_update
protected function g_update($url, $params) { $result = $this->execute($url, self::REQUEST_PATCH, $this->getResourceKey(), $params); $this->refresh($result); }
php
protected function g_update($url, $params) { $result = $this->execute($url, self::REQUEST_PATCH, $this->getResourceKey(), $params); $this->refresh($result); }
[ "protected", "function", "g_update", "(", "$", "url", ",", "$", "params", ")", "{", "$", "result", "=", "$", "this", "->", "execute", "(", "$", "url", ",", "self", "::", "REQUEST_PATCH", ",", "$", "this", "->", "getResourceKey", "(", ")", ",", "$", ...
Updates the resource with the given parameters in an associative array. @param string $url @param array $params @throws Exception|OmiseException
[ "Updates", "the", "resource", "with", "the", "given", "parameters", "in", "an", "associative", "array", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/res/OmiseApiResource.php#L89-L93
train
omise/omise-php
lib/omise/res/OmiseApiResource.php
OmiseApiResource.g_destroy
protected function g_destroy($url) { $result = $this->execute($url, self::REQUEST_DELETE, $this->getResourceKey()); $this->refresh($result, true); }
php
protected function g_destroy($url) { $result = $this->execute($url, self::REQUEST_DELETE, $this->getResourceKey()); $this->refresh($result, true); }
[ "protected", "function", "g_destroy", "(", "$", "url", ")", "{", "$", "result", "=", "$", "this", "->", "execute", "(", "$", "url", ",", "self", "::", "REQUEST_DELETE", ",", "$", "this", "->", "getResourceKey", "(", ")", ")", ";", "$", "this", "->", ...
Destroys the resource. @param string $url @throws Exception|OmiseException @return OmiseApiResource
[ "Destroys", "the", "resource", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/res/OmiseApiResource.php#L104-L108
train
omise/omise-php
lib/omise/res/OmiseApiResource.php
OmiseApiResource.g_reload
protected function g_reload($url) { $result = $this->execute($url, self::REQUEST_GET, $this->getResourceKey()); $this->refresh($result); }
php
protected function g_reload($url) { $result = $this->execute($url, self::REQUEST_GET, $this->getResourceKey()); $this->refresh($result); }
[ "protected", "function", "g_reload", "(", "$", "url", ")", "{", "$", "result", "=", "$", "this", "->", "execute", "(", "$", "url", ",", "self", "::", "REQUEST_GET", ",", "$", "this", "->", "getResourceKey", "(", ")", ")", ";", "$", "this", "->", "r...
Reloads the resource with latest data. @param string $url @throws Exception|OmiseException
[ "Reloads", "the", "resource", "with", "latest", "data", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/res/OmiseApiResource.php#L117-L121
train
omise/omise-php
lib/omise/res/OmiseApiResource.php
OmiseApiResource.execute
protected function execute($url, $requestMethod, $key, $params = null) { // If this class is execute by phpunit > get test mode. if (preg_match('/phpunit/', $_SERVER['SCRIPT_NAME'])) { $result = $this->_executeTest($url, $requestMethod, $key, $params); } else { $result = $this->_executeCurl($url, $requestMethod, $key, $params); } // Decode the JSON response as an associative array. $array = json_decode($result, true); // If response is invalid or not a JSON. if (!$this->isValidAPIResponse($array)) { throw new Exception('Unknown error. (Bad Response)'); } // If response is an error object. if (!empty($array['object']) && $array['object'] === 'error') { throw OmiseException::getInstance($array); } return $array; }
php
protected function execute($url, $requestMethod, $key, $params = null) { // If this class is execute by phpunit > get test mode. if (preg_match('/phpunit/', $_SERVER['SCRIPT_NAME'])) { $result = $this->_executeTest($url, $requestMethod, $key, $params); } else { $result = $this->_executeCurl($url, $requestMethod, $key, $params); } // Decode the JSON response as an associative array. $array = json_decode($result, true); // If response is invalid or not a JSON. if (!$this->isValidAPIResponse($array)) { throw new Exception('Unknown error. (Bad Response)'); } // If response is an error object. if (!empty($array['object']) && $array['object'] === 'error') { throw OmiseException::getInstance($array); } return $array; }
[ "protected", "function", "execute", "(", "$", "url", ",", "$", "requestMethod", ",", "$", "key", ",", "$", "params", "=", "null", ")", "{", "// If this class is execute by phpunit > get test mode.", "if", "(", "preg_match", "(", "'/phpunit/'", ",", "$", "_SERVER...
Makes a request and returns a decoded JSON data as an associative array. @param string $url @param string $requestMethod @param array $params @throws OmiseException @return array
[ "Makes", "a", "request", "and", "returns", "a", "decoded", "JSON", "data", "as", "an", "associative", "array", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/res/OmiseApiResource.php#L134-L157
train
omise/omise-php
lib/omise/res/OmiseApiResource.php
OmiseApiResource.genOptions
private function genOptions($requestMethod, $userpwd, $params) { $user_agent = "OmisePHP/".OMISE_PHP_LIB_VERSION." PHP/".phpversion(); $omise_api_version = defined('OMISE_API_VERSION') ? OMISE_API_VERSION : null; $options = array( // Set the HTTP version to 1.1. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, // Set the request method. CURLOPT_CUSTOMREQUEST => $requestMethod, // Make php-curl returns the data as string. CURLOPT_RETURNTRANSFER => true, // Do not include the header in the output. CURLOPT_HEADER => false, // Track the header request string and set the referer on redirect. CURLINFO_HEADER_OUT => true, CURLOPT_AUTOREFERER => true, // Make HTTP error code above 400 an error. // CURLOPT_FAILONERROR => true, // Time before the request is aborted. CURLOPT_TIMEOUT => $this->OMISE_TIMEOUT, // Time before the request is aborted when attempting to connect. CURLOPT_CONNECTTIMEOUT => $this->OMISE_CONNECTTIMEOUT, // Authentication. CURLOPT_USERPWD => $userpwd, // CA bundle. CURLOPT_CAINFO => dirname(__FILE__).'/../../../data/ca_certificates.pem' ); // Config Omise API Version if ($omise_api_version) { $options += array(CURLOPT_HTTPHEADER => array("Omise-Version: ".$omise_api_version)); $user_agent .= ' OmiseAPI/'.$omise_api_version; } // Config UserAgent if (defined('OMISE_USER_AGENT_SUFFIX')) { $options += array(CURLOPT_USERAGENT => $user_agent." ".OMISE_USER_AGENT_SUFFIX); } else { $options += array(CURLOPT_USERAGENT => $user_agent); } // Also merge POST parameters with the option. if (is_array($params) && count($params) > 0) { $http_query = http_build_query($params); $http_query = preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $http_query); $options += array(CURLOPT_POSTFIELDS => $http_query); } return $options; }
php
private function genOptions($requestMethod, $userpwd, $params) { $user_agent = "OmisePHP/".OMISE_PHP_LIB_VERSION." PHP/".phpversion(); $omise_api_version = defined('OMISE_API_VERSION') ? OMISE_API_VERSION : null; $options = array( // Set the HTTP version to 1.1. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, // Set the request method. CURLOPT_CUSTOMREQUEST => $requestMethod, // Make php-curl returns the data as string. CURLOPT_RETURNTRANSFER => true, // Do not include the header in the output. CURLOPT_HEADER => false, // Track the header request string and set the referer on redirect. CURLINFO_HEADER_OUT => true, CURLOPT_AUTOREFERER => true, // Make HTTP error code above 400 an error. // CURLOPT_FAILONERROR => true, // Time before the request is aborted. CURLOPT_TIMEOUT => $this->OMISE_TIMEOUT, // Time before the request is aborted when attempting to connect. CURLOPT_CONNECTTIMEOUT => $this->OMISE_CONNECTTIMEOUT, // Authentication. CURLOPT_USERPWD => $userpwd, // CA bundle. CURLOPT_CAINFO => dirname(__FILE__).'/../../../data/ca_certificates.pem' ); // Config Omise API Version if ($omise_api_version) { $options += array(CURLOPT_HTTPHEADER => array("Omise-Version: ".$omise_api_version)); $user_agent .= ' OmiseAPI/'.$omise_api_version; } // Config UserAgent if (defined('OMISE_USER_AGENT_SUFFIX')) { $options += array(CURLOPT_USERAGENT => $user_agent." ".OMISE_USER_AGENT_SUFFIX); } else { $options += array(CURLOPT_USERAGENT => $user_agent); } // Also merge POST parameters with the option. if (is_array($params) && count($params) > 0) { $http_query = http_build_query($params); $http_query = preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $http_query); $options += array(CURLOPT_POSTFIELDS => $http_query); } return $options; }
[ "private", "function", "genOptions", "(", "$", "requestMethod", ",", "$", "userpwd", ",", "$", "params", ")", "{", "$", "user_agent", "=", "\"OmisePHP/\"", ".", "OMISE_PHP_LIB_VERSION", ".", "\" PHP/\"", ".", "phpversion", "(", ")", ";", "$", "omise_api_versio...
Creates an option for php-curl from the given request method and parameters in an associative array. @param string $requestMethod @param array $params @return array
[ "Creates", "an", "option", "for", "php", "-", "curl", "from", "the", "given", "request", "method", "and", "parameters", "in", "an", "associative", "array", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/res/OmiseApiResource.php#L260-L312
train
omise/omise-php
lib/omise/OmiseCharge.php
OmiseCharge.search
public static function search($query = '', $publickey = null, $secretkey = null) { return OmiseSearch::scope('charge', $publickey, $secretkey)->query($query); }
php
public static function search($query = '', $publickey = null, $secretkey = null) { return OmiseSearch::scope('charge', $publickey, $secretkey)->query($query); }
[ "public", "static", "function", "search", "(", "$", "query", "=", "''", ",", "$", "publickey", "=", "null", ",", "$", "secretkey", "=", "null", ")", "{", "return", "OmiseSearch", "::", "scope", "(", "'charge'", ",", "$", "publickey", ",", "$", "secretk...
Search for charges. @param string $query @param string $publickey @param string $secretkey @return OmiseSearch
[ "Search", "for", "charges", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseCharge.php#L30-L33
train
omise/omise-php
lib/omise/OmiseCharge.php
OmiseCharge.capture
public function capture() { $result = parent::execute(self::getUrl($this['id']).'/capture', parent::REQUEST_POST, parent::getResourceKey()); $this->refresh($result); return $this; }
php
public function capture() { $result = parent::execute(self::getUrl($this['id']).'/capture', parent::REQUEST_POST, parent::getResourceKey()); $this->refresh($result); return $this; }
[ "public", "function", "capture", "(", ")", "{", "$", "result", "=", "parent", "::", "execute", "(", "self", "::", "getUrl", "(", "$", "this", "[", "'id'", "]", ")", ".", "'/capture'", ",", "parent", "::", "REQUEST_POST", ",", "parent", "::", "getResour...
Captures a charge. @return OmiseCharge
[ "Captures", "a", "charge", "." ]
b5fc79de2c493972d12eff7af53129f4e8ac0051
https://github.com/omise/omise-php/blob/b5fc79de2c493972d12eff7af53129f4e8ac0051/lib/omise/OmiseCharge.php#L92-L98
train
luyadev/luya-module-admin
src/base/ImageProperty.php
ImageProperty.getValue
public function getValue() { $value = parent::getValue(); if ($value) { $image = Yii::$app->storage->getImage($value); /* @var $image \luya\admin\image\Item */ if ($image) { if ($this->filterName()) { return $image->applyFilter($this->filterName())->sourceAbsolute; } return $image->source; } } return false; }
php
public function getValue() { $value = parent::getValue(); if ($value) { $image = Yii::$app->storage->getImage($value); /* @var $image \luya\admin\image\Item */ if ($image) { if ($this->filterName()) { return $image->applyFilter($this->filterName())->sourceAbsolute; } return $image->source; } } return false; }
[ "public", "function", "getValue", "(", ")", "{", "$", "value", "=", "parent", "::", "getValue", "(", ")", ";", "if", "(", "$", "value", ")", "{", "$", "image", "=", "Yii", "::", "$", "app", "->", "storage", "->", "getImage", "(", "$", "value", ")...
Get the absolute image source of the image, if not available the method returns false. @return string|boolean Returns the path to the file, otherwise false. @see \luya\admin\base\Property::getValue()
[ "Get", "the", "absolute", "image", "source", "of", "the", "image", "if", "not", "available", "the", "method", "returns", "false", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/base/ImageProperty.php#L71-L87
train
luyadev/luya-module-admin
src/base/ImageProperty.php
ImageProperty.getImage
public function getImage() { $value = parent::getValue(); if ($value) { return Yii::$app->storage->getImage($value); } return false; }
php
public function getImage() { $value = parent::getValue(); if ($value) { return Yii::$app->storage->getImage($value); } return false; }
[ "public", "function", "getImage", "(", ")", "{", "$", "value", "=", "parent", "::", "getValue", "(", ")", ";", "if", "(", "$", "value", ")", "{", "return", "Yii", "::", "$", "app", "->", "storage", "->", "getImage", "(", "$", "value", ")", ";", "...
Get the image property from the property value. @return \luya\admin\image\Item|boolean @since 1.0.2
[ "Get", "the", "image", "property", "from", "the", "property", "value", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/base/ImageProperty.php#L95-L104
train
luyadev/luya-module-admin
src/ngrest/aw/CallbackButtonFileDownloadWidget.php
CallbackButtonFileDownloadWidget.sendOutput
public static function sendOutput(ActiveWindow $context, $fileName, $content) { $mimeType = FileHelper::getMimeTypeByExtension($fileName); $url = $context->createDownloadableFileUrl($fileName, $mimeType, $content); return $context->sendSuccess(Module::t('callback_button_file_download_widget_success'), ['url' => $url]); }
php
public static function sendOutput(ActiveWindow $context, $fileName, $content) { $mimeType = FileHelper::getMimeTypeByExtension($fileName); $url = $context->createDownloadableFileUrl($fileName, $mimeType, $content); return $context->sendSuccess(Module::t('callback_button_file_download_widget_success'), ['url' => $url]); }
[ "public", "static", "function", "sendOutput", "(", "ActiveWindow", "$", "context", ",", "$", "fileName", ",", "$", "content", ")", "{", "$", "mimeType", "=", "FileHelper", "::", "getMimeTypeByExtension", "(", "$", "fileName", ")", ";", "$", "url", "=", "$"...
Generates and returns the content output. @param \luya\admin\ngrest\base\ActiveWindow $context The ActiveWindow context where the method is called in order to act as the callback could. @param string $fileName The filename which the the user would download. Make sure to use the correct extension as the mime type is read from the extension name. @param string $content The output content which will be written to a temporary file and the return to the user by your filename. @return array
[ "Generates", "and", "returns", "the", "content", "output", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/aw/CallbackButtonFileDownloadWidget.php#L73-L80
train
luyadev/luya-module-admin
src/models/TagRelation.php
TagRelation.getDataForRelation
public static function getDataForRelation($tableName, $pkId) { return self::find()->where(['table_name' => $tableName, 'pk_id' => $pkId])->asArray()->all(); }
php
public static function getDataForRelation($tableName, $pkId) { return self::find()->where(['table_name' => $tableName, 'pk_id' => $pkId])->asArray()->all(); }
[ "public", "static", "function", "getDataForRelation", "(", "$", "tableName", ",", "$", "pkId", ")", "{", "return", "self", "::", "find", "(", ")", "->", "where", "(", "[", "'table_name'", "=>", "$", "tableName", ",", "'pk_id'", "=>", "$", "pkId", "]", ...
Get an array with all entries for a table name associated with a primary key. This methods i mainly used internal to retrieve data for the Active Window. Use the {{luya\admin\traits\TagsTrait}} in your Model instead. @param string $tableName The table name @param integer $pkId The primary key combination. @return array|ActiveRecord[]
[ "Get", "an", "array", "with", "all", "entries", "for", "a", "table", "name", "associated", "with", "a", "primary", "key", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/TagRelation.php#L51-L54
train
luyadev/luya-module-admin
src/models/TagRelation.php
TagRelation.getDistinctDataForTable
public static function getDistinctDataForTable($tableName) { return self::find()->select('tag_id')->where(['table_name' => $tableName])->distinct()->asArray()->all(); }
php
public static function getDistinctDataForTable($tableName) { return self::find()->select('tag_id')->where(['table_name' => $tableName])->distinct()->asArray()->all(); }
[ "public", "static", "function", "getDistinctDataForTable", "(", "$", "tableName", ")", "{", "return", "self", "::", "find", "(", ")", "->", "select", "(", "'tag_id'", ")", "->", "where", "(", "[", "'table_name'", "=>", "$", "tableName", "]", ")", "->", "...
Get an array with all entries for a table name. This methods i mainly used internal to retrieve data for the Active Window. Use the {{luya\admin\traits\TagsTrait}} in your Model instead. @param string $tableName The table name. @return array|ActiveRecord[]
[ "Get", "an", "array", "with", "all", "entries", "for", "a", "table", "name", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/TagRelation.php#L64-L67
train
luyadev/luya-module-admin
src/commands/FilterController.php
FilterController.actionIndex
public function actionIndex() { if ($this->identifier === null) { $this->identifier = Inflector::variablize($this->prompt('Enter the filter identifier: (e.g. profilePicture)', ['required' => true, 'pattern' => '/^[a-zA-Z0-9]+$/i', 'error' => 'The filter identifer can only contain a-z,A-Z,0-9'])); } if ($this->chain === null) { $select = $this->select('Select the Effect', [Filter::EFFECT_THUMBNAIL => 'Thumbnail', Filter::EFFECT_CROP => 'Crop']); if ($select == Filter::EFFECT_THUMBNAIL) { $dimension = $this->prompt('Enter thumbnail dimensions (width x height):', ['required' => true, 'default' => '600xnull']); } else { $dimension = $this->prompt('Enter crop dimensions (width x height):', ['required' => true, 'default' => '600xnull']); } if ($select == Filter::EFFECT_THUMBNAIL) { $namedSelect = 'self::EFFECT_THUMBNAIL'; } else { $namedSelect = 'self::EFFECT_CROP'; } $xp = explode("x", $dimension); $this->chain[$namedSelect] = ['width' => $xp[0], 'height' => $xp[1]]; $tempName = $select == Filter::EFFECT_THUMBNAIL ? 'Thumbnail '. $dimension : 'Crop '.$dimension; $tempName.= ' ' . Inflector::camel2words($this->identifier); } if ($this->name === null) { if (!$tempName) { $tempName = Inflector::camel2words($this->identifier); } $this->name = ucfirst($this->prompt('Enter a self-explanatory Name:', ['required' => false, 'default' => $tempName])); } $folder = Yii::$app->basePath . DIRECTORY_SEPARATOR . 'filters'; $className = Inflector::camelize($this->identifier) . 'Filter'; $content = $this->generateClassView($this->identifier, $this->name, $this->chain, $className); $filePath = $folder . DIRECTORY_SEPARATOR . $className . '.php'; if (FileHelper::createDirectory($folder) && FileHelper::writeFile($filePath, $content)) { return $this->outputSuccess('Successfully generated ' . $filePath); } }
php
public function actionIndex() { if ($this->identifier === null) { $this->identifier = Inflector::variablize($this->prompt('Enter the filter identifier: (e.g. profilePicture)', ['required' => true, 'pattern' => '/^[a-zA-Z0-9]+$/i', 'error' => 'The filter identifer can only contain a-z,A-Z,0-9'])); } if ($this->chain === null) { $select = $this->select('Select the Effect', [Filter::EFFECT_THUMBNAIL => 'Thumbnail', Filter::EFFECT_CROP => 'Crop']); if ($select == Filter::EFFECT_THUMBNAIL) { $dimension = $this->prompt('Enter thumbnail dimensions (width x height):', ['required' => true, 'default' => '600xnull']); } else { $dimension = $this->prompt('Enter crop dimensions (width x height):', ['required' => true, 'default' => '600xnull']); } if ($select == Filter::EFFECT_THUMBNAIL) { $namedSelect = 'self::EFFECT_THUMBNAIL'; } else { $namedSelect = 'self::EFFECT_CROP'; } $xp = explode("x", $dimension); $this->chain[$namedSelect] = ['width' => $xp[0], 'height' => $xp[1]]; $tempName = $select == Filter::EFFECT_THUMBNAIL ? 'Thumbnail '. $dimension : 'Crop '.$dimension; $tempName.= ' ' . Inflector::camel2words($this->identifier); } if ($this->name === null) { if (!$tempName) { $tempName = Inflector::camel2words($this->identifier); } $this->name = ucfirst($this->prompt('Enter a self-explanatory Name:', ['required' => false, 'default' => $tempName])); } $folder = Yii::$app->basePath . DIRECTORY_SEPARATOR . 'filters'; $className = Inflector::camelize($this->identifier) . 'Filter'; $content = $this->generateClassView($this->identifier, $this->name, $this->chain, $className); $filePath = $folder . DIRECTORY_SEPARATOR . $className . '.php'; if (FileHelper::createDirectory($folder) && FileHelper::writeFile($filePath, $content)) { return $this->outputSuccess('Successfully generated ' . $filePath); } }
[ "public", "function", "actionIndex", "(", ")", "{", "if", "(", "$", "this", "->", "identifier", "===", "null", ")", "{", "$", "this", "->", "identifier", "=", "Inflector", "::", "variablize", "(", "$", "this", "->", "prompt", "(", "'Enter the filter identi...
Create a new image filter to apply on an Image Object. @return number
[ "Create", "a", "new", "image", "filter", "to", "apply", "on", "an", "Image", "Object", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/FilterController.php#L30-L75
train
luyadev/luya-module-admin
src/ngrest/base/ActiveButton.php
ActiveButton.sendError
public function sendError($message) { Yii::$app->response->setStatusCode(422, 'Data Validation Failed.'); return [ 'success' => false, 'message' => $message, 'events' => $this->_events, ]; }
php
public function sendError($message) { Yii::$app->response->setStatusCode(422, 'Data Validation Failed.'); return [ 'success' => false, 'message' => $message, 'events' => $this->_events, ]; }
[ "public", "function", "sendError", "(", "$", "message", ")", "{", "Yii", "::", "$", "app", "->", "response", "->", "setStatusCode", "(", "422", ",", "'Data Validation Failed.'", ")", ";", "return", "[", "'success'", "=>", "false", ",", "'message'", "=>", "...
Send an error message as response. Events are only triggered on success messages {{sendSuccess()}}. @param string $message The error message. @return array
[ "Send", "an", "error", "message", "as", "response", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/ActiveButton.php#L165-L174
train
luyadev/luya-module-admin
src/ngrest/render/RenderCrudView.php
RenderCrudView.getAngularControllerConfig
protected function getAngularControllerConfig() { return [ 'apiListQueryString' => $this->context->apiQueryString('list'), 'apiUpdateQueryString' => $this->context->apiQueryString('update'), 'apiServicesQueryString' => $this->context->apiQueryString('services'), 'apiExportQueryString' => $this->context->apiQueryString('export'), 'apiEndpoint' => $this->context->getApiEndpoint(), 'list' => $this->context->getFields('list'), 'create' => $this->context->getFields('create'), 'update' => $this->context->getFields('update'), 'ngrestConfigHash' => $this->context->getConfig()->getHash(), 'activeWindowCallbackUrl' => $this->context->getApiEndpoint('active-window-callback'), 'activeWindowRenderUrl' => $this->context->getApiEndpoint('active-window-render'), 'pk' => $this->context->getConfig()->getPrimaryKey(), 'inline' => $this->context->getIsInline(), 'modelSelection' => $this->context->getModelSelection(), 'orderBy' => $this->context->getOrderBy(), 'tableName' => $this->context->getConfig()->getTableName(), 'groupBy' => $this->context->getConfig()->getGroupByField() ? 1 : 0, 'groupByField' => $this->context->getConfig()->getGroupByField() ? $this->context->getConfig()->getGroupByField() : '0', 'groupByExpanded' => $this->context->getConfig()->getGroupByExpanded(), 'filter' => '0', 'fullSearchContainer' => false, 'minLengthWarning' => false, 'saveCallback' => $this->context->getConfig()->getOption('saveCallback') ? new JsExpression($this->context->getConfig()->getOption('saveCallback')) : false, 'relationCall' => $this->context->getRelationCall(), 'relations' => $this->context->getConfig()->getRelations(), 'pools' => $this->context->getActivePoolConfig(), 'tagFilter' => ObjectHelper::isTraitInstanceOf($this->context->getModel(), TaggableTrait::class), ]; }
php
protected function getAngularControllerConfig() { return [ 'apiListQueryString' => $this->context->apiQueryString('list'), 'apiUpdateQueryString' => $this->context->apiQueryString('update'), 'apiServicesQueryString' => $this->context->apiQueryString('services'), 'apiExportQueryString' => $this->context->apiQueryString('export'), 'apiEndpoint' => $this->context->getApiEndpoint(), 'list' => $this->context->getFields('list'), 'create' => $this->context->getFields('create'), 'update' => $this->context->getFields('update'), 'ngrestConfigHash' => $this->context->getConfig()->getHash(), 'activeWindowCallbackUrl' => $this->context->getApiEndpoint('active-window-callback'), 'activeWindowRenderUrl' => $this->context->getApiEndpoint('active-window-render'), 'pk' => $this->context->getConfig()->getPrimaryKey(), 'inline' => $this->context->getIsInline(), 'modelSelection' => $this->context->getModelSelection(), 'orderBy' => $this->context->getOrderBy(), 'tableName' => $this->context->getConfig()->getTableName(), 'groupBy' => $this->context->getConfig()->getGroupByField() ? 1 : 0, 'groupByField' => $this->context->getConfig()->getGroupByField() ? $this->context->getConfig()->getGroupByField() : '0', 'groupByExpanded' => $this->context->getConfig()->getGroupByExpanded(), 'filter' => '0', 'fullSearchContainer' => false, 'minLengthWarning' => false, 'saveCallback' => $this->context->getConfig()->getOption('saveCallback') ? new JsExpression($this->context->getConfig()->getOption('saveCallback')) : false, 'relationCall' => $this->context->getRelationCall(), 'relations' => $this->context->getConfig()->getRelations(), 'pools' => $this->context->getActivePoolConfig(), 'tagFilter' => ObjectHelper::isTraitInstanceOf($this->context->getModel(), TaggableTrait::class), ]; }
[ "protected", "function", "getAngularControllerConfig", "(", ")", "{", "return", "[", "'apiListQueryString'", "=>", "$", "this", "->", "context", "->", "apiQueryString", "(", "'list'", ")", ",", "'apiUpdateQueryString'", "=>", "$", "this", "->", "context", "->", ...
Returns the config array for Angular controller @return array @since 2.0.0
[ "Returns", "the", "config", "array", "for", "Angular", "controller" ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderCrudView.php#L39-L70
train
luyadev/luya-module-admin
src/Bootstrap.php
Bootstrap.runQueueJob
public function runQueueJob($event) { if (!$event->sender->request->isConsoleRequest && !$event->sender->request->isAdmin) { // use cache to ensure this will run only every 30min $this->getOrSetHasCache(['admin', 'bootstrap', 'queue'], function() { $timestamp = Config::get(Config::CONFIG_QUEUE_TIMESTAMP); // if last execution has NOT been done previously (maybe trough a cronjob) if ((time() - $timestamp) > (60*25)) { Yii::debug('"Fake-Cronjob" queue run execution.'); Yii::$app->adminqueue->run(false); Config::set(Config::CONFIG_QUEUE_TIMESTAMP, time()); } return $timestamp; }, 60*30); } }
php
public function runQueueJob($event) { if (!$event->sender->request->isConsoleRequest && !$event->sender->request->isAdmin) { // use cache to ensure this will run only every 30min $this->getOrSetHasCache(['admin', 'bootstrap', 'queue'], function() { $timestamp = Config::get(Config::CONFIG_QUEUE_TIMESTAMP); // if last execution has NOT been done previously (maybe trough a cronjob) if ((time() - $timestamp) > (60*25)) { Yii::debug('"Fake-Cronjob" queue run execution.'); Yii::$app->adminqueue->run(false); Config::set(Config::CONFIG_QUEUE_TIMESTAMP, time()); } return $timestamp; }, 60*30); } }
[ "public", "function", "runQueueJob", "(", "$", "event", ")", "{", "if", "(", "!", "$", "event", "->", "sender", "->", "request", "->", "isConsoleRequest", "&&", "!", "$", "event", "->", "sender", "->", "request", "->", "isAdmin", ")", "{", "// use cache ...
Evaluate whether the current queue job should be run or not. @param \yii\base\Event $event
[ "Evaluate", "whether", "the", "current", "queue", "job", "should", "be", "run", "or", "not", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/Bootstrap.php#L42-L58
train
luyadev/luya-module-admin
src/components/AdminLanguage.php
AdminLanguage.getLanguageByShortCode
public function getLanguageByShortCode($shortCode) { return isset($this->getLanguages()[$shortCode]) ? $this->getLanguages()[$shortCode] : false; }
php
public function getLanguageByShortCode($shortCode) { return isset($this->getLanguages()[$shortCode]) ? $this->getLanguages()[$shortCode] : false; }
[ "public", "function", "getLanguageByShortCode", "(", "$", "shortCode", ")", "{", "return", "isset", "(", "$", "this", "->", "getLanguages", "(", ")", "[", "$", "shortCode", "]", ")", "?", "$", "this", "->", "getLanguages", "(", ")", "[", "$", "shortCode"...
Get the language from a shortCode. @param string $shortCode @return boolean|mixed
[ "Get", "the", "language", "from", "a", "shortCode", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/components/AdminLanguage.php#L92-L95
train
luyadev/luya-module-admin
src/ngrest/plugins/SelectModel.php
SelectModel.getDataInstance
private static function getDataInstance(ActiveQuery $query) { $class = $query->modelClass; $keys = [$class]; if ($query->where) { foreach ($query->where as $v) { if (is_scalar($v)) { $keys[] = $v; } } } $instanceName = implode(",", $keys); if (!isset(static::$_dataInstance[$instanceName])) { $queryData = $query->all(); static::$_dataInstance[$instanceName] = $queryData; } return static::$_dataInstance[$instanceName]; }
php
private static function getDataInstance(ActiveQuery $query) { $class = $query->modelClass; $keys = [$class]; if ($query->where) { foreach ($query->where as $v) { if (is_scalar($v)) { $keys[] = $v; } } } $instanceName = implode(",", $keys); if (!isset(static::$_dataInstance[$instanceName])) { $queryData = $query->all(); static::$_dataInstance[$instanceName] = $queryData; } return static::$_dataInstance[$instanceName]; }
[ "private", "static", "function", "getDataInstance", "(", "ActiveQuery", "$", "query", ")", "{", "$", "class", "=", "$", "query", "->", "modelClass", ";", "$", "keys", "=", "[", "$", "class", "]", ";", "if", "(", "$", "query", "->", "where", ")", "{",...
Data DI Container for relation data. @param string $class @param string|array $where @return mixed
[ "Data", "DI", "Container", "for", "relation", "data", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/plugins/SelectModel.php#L109-L130
train
luyadev/luya-module-admin
src/ngrest/plugins/SelectModel.php
SelectModel.getValueField
public function getValueField() { if ($this->_valueField === null) { $class = $this->modelClass; $this->_valueField = implode("", $class::primaryKey()); } return $this->_valueField; }
php
public function getValueField() { if ($this->_valueField === null) { $class = $this->modelClass; $this->_valueField = implode("", $class::primaryKey()); } return $this->_valueField; }
[ "public", "function", "getValueField", "(", ")", "{", "if", "(", "$", "this", "->", "_valueField", "===", "null", ")", "{", "$", "class", "=", "$", "this", "->", "modelClass", ";", "$", "this", "->", "_valueField", "=", "implode", "(", "\"\"", ",", "...
Getter Method for valueField. If no value is provided it will auto matically return the primary key of the derived model class. @return string The primary key from `modelClass`.
[ "Getter", "Method", "for", "valueField", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/plugins/SelectModel.php#L184-L192
train
luyadev/luya-module-admin
src/models/StorageImage.php
StorageImage.getSource
public function getSource() { return Yii::$app->storage->fileAbsoluteHttpPath($this->filter_id . '_' . $this->file->name_new_compound); }
php
public function getSource() { return Yii::$app->storage->fileAbsoluteHttpPath($this->filter_id . '_' . $this->file->name_new_compound); }
[ "public", "function", "getSource", "(", ")", "{", "return", "Yii", "::", "$", "app", "->", "storage", "->", "fileAbsoluteHttpPath", "(", "$", "this", "->", "filter_id", ".", "'_'", ".", "$", "this", "->", "file", "->", "name_new_compound", ")", ";", "}" ...
Returns the current file source path for the current filter image. @return string
[ "Returns", "the", "current", "file", "source", "path", "for", "the", "current", "filter", "image", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/StorageImage.php#L78-L81
train
luyadev/luya-module-admin
src/models/StorageImage.php
StorageImage.getServerSource
public function getServerSource() { return Yii::$app->storage->fileServerPath($this->filter_id . '_' . $this->file->name_new_compound); }
php
public function getServerSource() { return Yii::$app->storage->fileServerPath($this->filter_id . '_' . $this->file->name_new_compound); }
[ "public", "function", "getServerSource", "(", ")", "{", "return", "Yii", "::", "$", "app", "->", "storage", "->", "fileServerPath", "(", "$", "this", "->", "filter_id", ".", "'_'", ".", "$", "this", "->", "file", "->", "name_new_compound", ")", ";", "}" ...
Get the path to the source files internal, on the servers path. This is used when you want to to grab the file on server side for example to read the file with `file_get_contents` and is the absolut path on the file system on the server. @return string The path to the file on the filesystem of the server. @since 1.2.2.1
[ "Get", "the", "path", "to", "the", "source", "files", "internal", "on", "the", "servers", "path", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/StorageImage.php#L92-L95
train
luyadev/luya-module-admin
src/models/StorageImage.php
StorageImage.getFileExists
public function getFileExists() { return Yii::$app->storage->fileSystemExists($this->filter_id . '_' . $this->file->name_new_compound); }
php
public function getFileExists() { return Yii::$app->storage->fileSystemExists($this->filter_id . '_' . $this->file->name_new_compound); }
[ "public", "function", "getFileExists", "(", ")", "{", "return", "Yii", "::", "$", "app", "->", "storage", "->", "fileSystemExists", "(", "$", "this", "->", "filter_id", ".", "'_'", ".", "$", "this", "->", "file", "->", "name_new_compound", ")", ";", "}" ...
Return boolean value whether the file server source exsits on the server or not. @return boolean Whether the file still exists in the storage folder or not. @since 1.2.2.1
[ "Return", "boolean", "value", "whether", "the", "file", "server", "source", "exsits", "on", "the", "server", "or", "not", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/StorageImage.php#L103-L106
train
luyadev/luya-module-admin
src/models/StorageImage.php
StorageImage.getFilterImage
public function getFilterImage($identifier) { $filterId = Yii::$app->storage->getFilterId($identifier); return $this->hasOne(self::class, ['file_id' => 'file_id'])->andWhere(['filter_id' => $filterId]); }
php
public function getFilterImage($identifier) { $filterId = Yii::$app->storage->getFilterId($identifier); return $this->hasOne(self::class, ['file_id' => 'file_id'])->andWhere(['filter_id' => $filterId]); }
[ "public", "function", "getFilterImage", "(", "$", "identifier", ")", "{", "$", "filterId", "=", "Yii", "::", "$", "app", "->", "storage", "->", "getFilterId", "(", "$", "identifier", ")", ";", "return", "$", "this", "->", "hasOne", "(", "self", "::", "...
The the relation for an storage image with the given filter identifier @param string $identifier The identifier of the filter to use. @return self @since 1.2.3
[ "The", "the", "relation", "for", "an", "storage", "image", "with", "the", "given", "filter", "identifier" ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/StorageImage.php#L145-L149
train
luyadev/luya-module-admin
src/models/StorageImage.php
StorageImage.imageFilter
public function imageFilter($filterId, $checkImagesRelation = true) { if ($checkImagesRelation) { foreach ($this->images as $image) { if ($image->filter_id == $filterId) { return $image; } } } return Yii::$app->storage->createImage($this->file_id, $filterId); }
php
public function imageFilter($filterId, $checkImagesRelation = true) { if ($checkImagesRelation) { foreach ($this->images as $image) { if ($image->filter_id == $filterId) { return $image; } } } return Yii::$app->storage->createImage($this->file_id, $filterId); }
[ "public", "function", "imageFilter", "(", "$", "filterId", ",", "$", "checkImagesRelation", "=", "true", ")", "{", "if", "(", "$", "checkImagesRelation", ")", "{", "foreach", "(", "$", "this", "->", "images", "as", "$", "image", ")", "{", "if", "(", "$...
Get an image for a given filter id of the current image. @param integer $filterId The filter id. @param boolean $checkImagesRelation If enabled the current relation `getImages()` will be used to check whether the file exists inside or not. This should only used when you preload this relation: ```php foreach (StorageImage::find()->where(['id', [1,3,4,5]])->with(['images'])->all() as $image) { var_dump($image->imageFilter(1)); } ``` @return StorageImage @since 2.0.0
[ "Get", "an", "image", "for", "a", "given", "filter", "id", "of", "the", "current", "image", "." ]
58ddcefc96df70af010076216e43a78dd2bc61db
https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/StorageImage.php#L165-L176
train