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
Vectorface/whip
src/IpRange/IpWhitelist.php
IpWhitelist.isIpWhitelisted
public function isIpWhitelisted($ipAddress) { // determine whether this IP is IPv4 or IPv6 $isIpv4Address = filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); return $this->isIpInWhitelist( ($isIpv4Address) ? $this->ipv4Whitelist : $this->ipv6Whitelist, $ipAddress ); }
php
public function isIpWhitelisted($ipAddress) { // determine whether this IP is IPv4 or IPv6 $isIpv4Address = filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); return $this->isIpInWhitelist( ($isIpv4Address) ? $this->ipv4Whitelist : $this->ipv6Whitelist, $ipAddress ); }
[ "public", "function", "isIpWhitelisted", "(", "$", "ipAddress", ")", "{", "// determine whether this IP is IPv4 or IPv6", "$", "isIpv4Address", "=", "filter_var", "(", "$", "ipAddress", ",", "FILTER_VALIDATE_IP", ",", "FILTER_FLAG_IPV4", ")", ";", "return", "$", "this...
Returns whether or not the given IP address is within the whitelist. @param string $ipAddress A valid IPv4 or IPv6 address. @return boolean Returns true if the IP address matches one of the whitelisted IP ranges and false otherwise.
[ "Returns", "whether", "or", "not", "the", "given", "IP", "address", "is", "within", "the", "whitelist", "." ]
67820616de482b3bb2a750337353e6243971c1eb
https://github.com/Vectorface/whip/blob/67820616de482b3bb2a750337353e6243971c1eb/src/IpRange/IpWhitelist.php#L73-L81
train
Vectorface/whip
src/IpRange/IpWhitelist.php
IpWhitelist.constructWhiteListForKey
private function constructWhiteListForKey(array $whitelist, $key, $class) { if (isset($whitelist[$key]) && is_array($whitelist[$key])) { return array_map(function ($range) use ($class) { return new $class($range); }, array_values($whitelist[$key])); } else { return array(); } }
php
private function constructWhiteListForKey(array $whitelist, $key, $class) { if (isset($whitelist[$key]) && is_array($whitelist[$key])) { return array_map(function ($range) use ($class) { return new $class($range); }, array_values($whitelist[$key])); } else { return array(); } }
[ "private", "function", "constructWhiteListForKey", "(", "array", "$", "whitelist", ",", "$", "key", ",", "$", "class", ")", "{", "if", "(", "isset", "(", "$", "whitelist", "[", "$", "key", "]", ")", "&&", "is_array", "(", "$", "whitelist", "[", "$", ...
Constructs the whitelist for the given key. Each element in the whitelist gets mapped from a string to an instance of an Ipv4Range or Ipv6Range. @param array $whitelist The input whitelist of ranges. @param string $key The key to use from the input whitelist ('ipv4' or 'ipv6'). @param string $class Each range string gets mapped to an instance of the specified $class. @return array Returns an array of Ipv4Range or Ipv6Range elements.
[ "Constructs", "the", "whitelist", "for", "the", "given", "key", ".", "Each", "element", "in", "the", "whitelist", "gets", "mapped", "from", "a", "string", "to", "an", "instance", "of", "an", "Ipv4Range", "or", "Ipv6Range", "." ]
67820616de482b3bb2a750337353e6243971c1eb
https://github.com/Vectorface/whip/blob/67820616de482b3bb2a750337353e6243971c1eb/src/IpRange/IpWhitelist.php#L94-L103
train
Vectorface/whip
src/IpRange/IpWhitelist.php
IpWhitelist.isIpInWhitelist
private function isIpInWhitelist(array $whitelist, $ipAddress) { foreach ($whitelist as $ipRange) { if ($ipRange->containsIp($ipAddress)) { return true; } } return false; }
php
private function isIpInWhitelist(array $whitelist, $ipAddress) { foreach ($whitelist as $ipRange) { if ($ipRange->containsIp($ipAddress)) { return true; } } return false; }
[ "private", "function", "isIpInWhitelist", "(", "array", "$", "whitelist", ",", "$", "ipAddress", ")", "{", "foreach", "(", "$", "whitelist", "as", "$", "ipRange", ")", "{", "if", "(", "$", "ipRange", "->", "containsIp", "(", "$", "ipAddress", ")", ")", ...
Returns whether or not the given IP address is in the given whitelist. @param array $whitelist The given whitelist. @param string $ipAddress The given IP address. @return boolean Returns true if the IP address is in the whitelist and false otherwise.
[ "Returns", "whether", "or", "not", "the", "given", "IP", "address", "is", "in", "the", "given", "whitelist", "." ]
67820616de482b3bb2a750337353e6243971c1eb
https://github.com/Vectorface/whip/blob/67820616de482b3bb2a750337353e6243971c1eb/src/IpRange/IpWhitelist.php#L112-L120
train
Vectorface/whip
src/Whip.php
Whip.addCustomHeader
public function addCustomHeader($header) { self::$headers[self::CUSTOM_HEADERS][] = $this->normalizeHeaderName($header); return $this; }
php
public function addCustomHeader($header) { self::$headers[self::CUSTOM_HEADERS][] = $this->normalizeHeaderName($header); return $this; }
[ "public", "function", "addCustomHeader", "(", "$", "header", ")", "{", "self", "::", "$", "headers", "[", "self", "::", "CUSTOM_HEADERS", "]", "[", "]", "=", "$", "this", "->", "normalizeHeaderName", "(", "$", "header", ")", ";", "return", "$", "this", ...
Adds a custom header to the list. @param string $header The custom header to add. @return Whip Returns $this.
[ "Adds", "a", "custom", "header", "to", "the", "list", "." ]
67820616de482b3bb2a750337353e6243971c1eb
https://github.com/Vectorface/whip/blob/67820616de482b3bb2a750337353e6243971c1eb/src/Whip.php#L122-L126
train
Vectorface/whip
src/Whip.php
Whip.getIpAddress
public function getIpAddress($source = null) { $source = $this->getRequestAdapter($this->coalesceSources($source)); $remoteAddr = $source->getRemoteAddr(); $requestHeaders = $source->getHeaders(); foreach (self::$headers as $key => $headers) { if (!$this->isMethodUsable($key, $remoteAddr)) { continue; } if ($ipAddress = $this->extractAddressFromHeaders($requestHeaders, $headers)) { return $ipAddress; } } if ($remoteAddr && ($this->enabled & self::REMOTE_ADDR)) { return $remoteAddr; } return false; }
php
public function getIpAddress($source = null) { $source = $this->getRequestAdapter($this->coalesceSources($source)); $remoteAddr = $source->getRemoteAddr(); $requestHeaders = $source->getHeaders(); foreach (self::$headers as $key => $headers) { if (!$this->isMethodUsable($key, $remoteAddr)) { continue; } if ($ipAddress = $this->extractAddressFromHeaders($requestHeaders, $headers)) { return $ipAddress; } } if ($remoteAddr && ($this->enabled & self::REMOTE_ADDR)) { return $remoteAddr; } return false; }
[ "public", "function", "getIpAddress", "(", "$", "source", "=", "null", ")", "{", "$", "source", "=", "$", "this", "->", "getRequestAdapter", "(", "$", "this", "->", "coalesceSources", "(", "$", "source", ")", ")", ";", "$", "remoteAddr", "=", "$", "sou...
Returns the IP address of the client using the given methods. @param mixed $source (optional) The source data. If omitted, the class will use the value passed to Whip::setSource or fallback to $_SERVER. @return string Returns the IP address as a string or false if no IP address could be found.
[ "Returns", "the", "IP", "address", "of", "the", "client", "using", "the", "given", "methods", "." ]
67820616de482b3bb2a750337353e6243971c1eb
https://github.com/Vectorface/whip/blob/67820616de482b3bb2a750337353e6243971c1eb/src/Whip.php#L149-L170
train
Vectorface/whip
src/Whip.php
Whip.getValidIpAddress
public function getValidIpAddress($source = null) { $ipAddress = $this->getIpAddress($source); if (false === $ipAddress || false === @inet_pton($ipAddress)) { return false; } return $ipAddress; }
php
public function getValidIpAddress($source = null) { $ipAddress = $this->getIpAddress($source); if (false === $ipAddress || false === @inet_pton($ipAddress)) { return false; } return $ipAddress; }
[ "public", "function", "getValidIpAddress", "(", "$", "source", "=", "null", ")", "{", "$", "ipAddress", "=", "$", "this", "->", "getIpAddress", "(", "$", "source", ")", ";", "if", "(", "false", "===", "$", "ipAddress", "||", "false", "===", "@", "inet_...
Returns the valid IP address or false if no valid IP address was found. @param mixed $source (optional) The source data. If omitted, the class will use the value passed to Whip::setSource or fallback to $_SERVER. @return string|false Returns the IP address (as a string) of the client or false if no valid IP address was found.
[ "Returns", "the", "valid", "IP", "address", "or", "false", "if", "no", "valid", "IP", "address", "was", "found", "." ]
67820616de482b3bb2a750337353e6243971c1eb
https://github.com/Vectorface/whip/blob/67820616de482b3bb2a750337353e6243971c1eb/src/Whip.php#L180-L187
train
Vectorface/whip
src/Whip.php
Whip.normalizeHeaderName
private function normalizeHeaderName($header) { if (strpos($header, 'HTTP_') === 0) { $header = str_replace('_', '-', substr($header, 5)); } return strtolower($header); }
php
private function normalizeHeaderName($header) { if (strpos($header, 'HTTP_') === 0) { $header = str_replace('_', '-', substr($header, 5)); } return strtolower($header); }
[ "private", "function", "normalizeHeaderName", "(", "$", "header", ")", "{", "if", "(", "strpos", "(", "$", "header", ",", "'HTTP_'", ")", "===", "0", ")", "{", "$", "header", "=", "str_replace", "(", "'_'", ",", "'-'", ",", "substr", "(", "$", "heade...
Normalizes HTTP header name representations. HTTP_MY_HEADER and My-Header would be transformed to my-header. @param string $header The original header name. @return string The normalized header name.
[ "Normalizes", "HTTP", "header", "name", "representations", "." ]
67820616de482b3bb2a750337353e6243971c1eb
https://github.com/Vectorface/whip/blob/67820616de482b3bb2a750337353e6243971c1eb/src/Whip.php#L197-L203
train
Vectorface/whip
src/Whip.php
Whip.isMethodUsable
private function isMethodUsable($key, $ipAddress) { if (!($key & $this->enabled)) { return false; } if (!isset($this->whitelist[$key])) { return true; } return $this->whitelist[$key]->isIpWhitelisted($ipAddress); }
php
private function isMethodUsable($key, $ipAddress) { if (!($key & $this->enabled)) { return false; } if (!isset($this->whitelist[$key])) { return true; } return $this->whitelist[$key]->isIpWhitelisted($ipAddress); }
[ "private", "function", "isMethodUsable", "(", "$", "key", ",", "$", "ipAddress", ")", "{", "if", "(", "!", "(", "$", "key", "&", "$", "this", "->", "enabled", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "isset", "(", "$", "this", ...
Returns whether or not the given method is enabled and usable. This method checks if the method is enabled and whether the method's data is usable given it's IP whitelist. @param string $key The source key. @param string $ipAddress The IP address. @return boolean Returns true if the IP address is whitelisted and false otherwise. Returns true if the source does not have a whitelist specified.
[ "Returns", "whether", "or", "not", "the", "given", "method", "is", "enabled", "and", "usable", "." ]
67820616de482b3bb2a750337353e6243971c1eb
https://github.com/Vectorface/whip/blob/67820616de482b3bb2a750337353e6243971c1eb/src/Whip.php#L239-L248
train
Vectorface/whip
src/Whip.php
Whip.coalesceSources
private function coalesceSources($source = null) { if (isset($source)) { return $source; } elseif (isset($this->source)) { return $this->source; } return $_SERVER; }
php
private function coalesceSources($source = null) { if (isset($source)) { return $source; } elseif (isset($this->source)) { return $this->source; } return $_SERVER; }
[ "private", "function", "coalesceSources", "(", "$", "source", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "source", ")", ")", "{", "return", "$", "source", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "source", ")", ")", "{", ...
Given available sources, get the first available source of IP data. @param mixed $source A source data argument, if available. @return mixed The best available source, after fallbacks.
[ "Given", "available", "sources", "get", "the", "first", "available", "source", "of", "IP", "data", "." ]
67820616de482b3bb2a750337353e6243971c1eb
https://github.com/Vectorface/whip/blob/67820616de482b3bb2a750337353e6243971c1eb/src/Whip.php#L275-L284
train
Vectorface/whip
src/IpRange/Ipv6Range.php
Ipv6Range.extractNetworkAndMaskFromRange
private function extractNetworkAndMaskFromRange($range) { if (false !== strpos($range, '/')) { // handle the CIDR notation list($network, $this->mask) = explode('/', $range); // store a substring of the binary representation of the range // minus the masked part $this->rangeSubstring = substr( $this->convertToBinaryString($network), 0, $this->mask ); } else { // handle a single IP address $this->rangeSubstring = $this->convertToBinaryString($range); $this->mask = false; } }
php
private function extractNetworkAndMaskFromRange($range) { if (false !== strpos($range, '/')) { // handle the CIDR notation list($network, $this->mask) = explode('/', $range); // store a substring of the binary representation of the range // minus the masked part $this->rangeSubstring = substr( $this->convertToBinaryString($network), 0, $this->mask ); } else { // handle a single IP address $this->rangeSubstring = $this->convertToBinaryString($range); $this->mask = false; } }
[ "private", "function", "extractNetworkAndMaskFromRange", "(", "$", "range", ")", "{", "if", "(", "false", "!==", "strpos", "(", "$", "range", ",", "'/'", ")", ")", "{", "// handle the CIDR notation", "list", "(", "$", "network", ",", "$", "this", "->", "ma...
Extracts the mask and binary string substring of the range to compare against incoming IP addresses. @param string $range The IPv6 range as a string.
[ "Extracts", "the", "mask", "and", "binary", "string", "substring", "of", "the", "range", "to", "compare", "against", "incoming", "IP", "addresses", "." ]
67820616de482b3bb2a750337353e6243971c1eb
https://github.com/Vectorface/whip/blob/67820616de482b3bb2a750337353e6243971c1eb/src/IpRange/Ipv6Range.php#L82-L99
train
Vectorface/whip
src/IpRange/Ipv4Range.php
Ipv4Range.computeLowerAndUpperBounds
private function computeLowerAndUpperBounds($range) { if (strpos($range, '/') !== false) { // support CIDR notation list($this->lowerInt, $this->upperInt) = $this->parseCidrRange($range); } elseif (strpos($range, '-') !== false) { // support for IP ranges like '10.0.0.0-10.0.0.255' list($this->lowerInt, $this->upperInt) = $this->parseHyphenRange($range); } elseif (($pos = strpos($range, '*')) !== false) { // support for IP ranges like '10.0.*' list($this->lowerInt, $this->upperInt) = $this->parseWildcardRange($range, $pos); } else { // assume we have a single address $this->lowerInt = ip2long($range); $this->upperInt = $this->lowerInt; } }
php
private function computeLowerAndUpperBounds($range) { if (strpos($range, '/') !== false) { // support CIDR notation list($this->lowerInt, $this->upperInt) = $this->parseCidrRange($range); } elseif (strpos($range, '-') !== false) { // support for IP ranges like '10.0.0.0-10.0.0.255' list($this->lowerInt, $this->upperInt) = $this->parseHyphenRange($range); } elseif (($pos = strpos($range, '*')) !== false) { // support for IP ranges like '10.0.*' list($this->lowerInt, $this->upperInt) = $this->parseWildcardRange($range, $pos); } else { // assume we have a single address $this->lowerInt = ip2long($range); $this->upperInt = $this->lowerInt; } }
[ "private", "function", "computeLowerAndUpperBounds", "(", "$", "range", ")", "{", "if", "(", "strpos", "(", "$", "range", ",", "'/'", ")", "!==", "false", ")", "{", "// support CIDR notation", "list", "(", "$", "this", "->", "lowerInt", ",", "$", "this", ...
Computes the lower and upper bounds of the IPv4 range by parsing the range string. @param string $range The IPv4 range as a string.
[ "Computes", "the", "lower", "and", "upper", "bounds", "of", "the", "IPv4", "range", "by", "parsing", "the", "range", "string", "." ]
67820616de482b3bb2a750337353e6243971c1eb
https://github.com/Vectorface/whip/blob/67820616de482b3bb2a750337353e6243971c1eb/src/IpRange/Ipv4Range.php#L90-L106
train
Vectorface/whip
src/IpRange/Ipv4Range.php
Ipv4Range.parseCidrRange
private function parseCidrRange($range) { list($address, $mask) = explode('/', $range); $longAddress = ip2long($address); return array( $longAddress & (((1 << $mask) - 1) << (32 - $mask)), $longAddress | ((1 << (32 - $mask)) - 1) ); }
php
private function parseCidrRange($range) { list($address, $mask) = explode('/', $range); $longAddress = ip2long($address); return array( $longAddress & (((1 << $mask) - 1) << (32 - $mask)), $longAddress | ((1 << (32 - $mask)) - 1) ); }
[ "private", "function", "parseCidrRange", "(", "$", "range", ")", "{", "list", "(", "$", "address", ",", "$", "mask", ")", "=", "explode", "(", "'/'", ",", "$", "range", ")", ";", "$", "longAddress", "=", "ip2long", "(", "$", "address", ")", ";", "r...
Parses a CIDR notation range. @param string $range The CIDR range. @return array Returns an array with the first element being the lower bound of the range and second element being the upper bound.
[ "Parses", "a", "CIDR", "notation", "range", "." ]
67820616de482b3bb2a750337353e6243971c1eb
https://github.com/Vectorface/whip/blob/67820616de482b3bb2a750337353e6243971c1eb/src/IpRange/Ipv4Range.php#L114-L122
train
Vectorface/whip
src/IpRange/Ipv4Range.php
Ipv4Range.parseWildcardRange
private function parseWildcardRange($range, $pos) { $prefix = substr($range, 0, $pos - 1); $parts = explode('.', $prefix); $partsCount = 4 - count($parts); return array( ip2long(implode('.', array_merge($parts, array_fill(0, $partsCount, 0)))), ip2long(implode('.', array_merge($parts, array_fill(0, $partsCount, 255)))) ); }
php
private function parseWildcardRange($range, $pos) { $prefix = substr($range, 0, $pos - 1); $parts = explode('.', $prefix); $partsCount = 4 - count($parts); return array( ip2long(implode('.', array_merge($parts, array_fill(0, $partsCount, 0)))), ip2long(implode('.', array_merge($parts, array_fill(0, $partsCount, 255)))) ); }
[ "private", "function", "parseWildcardRange", "(", "$", "range", ",", "$", "pos", ")", "{", "$", "prefix", "=", "substr", "(", "$", "range", ",", "0", ",", "$", "pos", "-", "1", ")", ";", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "prefix...
Parses a wildcard notation range. @param string $range The wildcard notation range. @param int $pos The integer position of the wildcard within the range string. @return array Returns an array with the first element being the lower bound of the range and second element being the upper bound.
[ "Parses", "a", "wildcard", "notation", "range", "." ]
67820616de482b3bb2a750337353e6243971c1eb
https://github.com/Vectorface/whip/blob/67820616de482b3bb2a750337353e6243971c1eb/src/IpRange/Ipv4Range.php#L142-L151
train
lajax/yii2-translate-manager
services/scanners/ScannerJavaScriptFunction.php
ScannerJavaScriptFunction.run
public function run($route, $params = []) { $this->scanner->stdout('Detect JavaScriptFunction - BEGIN', Console::FG_YELLOW); foreach (self::$files[static::EXTENSION] as $file) { if ($this->containsTranslator($this->module->jsTranslators, $file)) { $this->extractMessages($file, [ 'translator' => (array) $this->module->jsTranslators, 'begin' => '(', 'end' => ')', ]); } } $this->scanner->stdout('Detect JavaScriptFunction - END', Console::FG_YELLOW); }
php
public function run($route, $params = []) { $this->scanner->stdout('Detect JavaScriptFunction - BEGIN', Console::FG_YELLOW); foreach (self::$files[static::EXTENSION] as $file) { if ($this->containsTranslator($this->module->jsTranslators, $file)) { $this->extractMessages($file, [ 'translator' => (array) $this->module->jsTranslators, 'begin' => '(', 'end' => ')', ]); } } $this->scanner->stdout('Detect JavaScriptFunction - END', Console::FG_YELLOW); }
[ "public", "function", "run", "(", "$", "route", ",", "$", "params", "=", "[", "]", ")", "{", "$", "this", "->", "scanner", "->", "stdout", "(", "'Detect JavaScriptFunction - BEGIN'", ",", "Console", "::", "FG_YELLOW", ")", ";", "foreach", "(", "self", ":...
Start scanning JavaScript files. @param string $route @param array $params @inheritdoc
[ "Start", "scanning", "JavaScript", "files", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/services/scanners/ScannerJavaScriptFunction.php#L38-L52
train
lajax/yii2-translate-manager
behaviors/TranslateBehavior.php
TranslateBehavior.translateAttributes
public function translateAttributes($event) { foreach ($this->translateAttributes as $attribute) { $this->owner->{$attribute} = Yii::t($this->category, $this->owner->attributes[$attribute]); } }
php
public function translateAttributes($event) { foreach ($this->translateAttributes as $attribute) { $this->owner->{$attribute} = Yii::t($this->category, $this->owner->attributes[$attribute]); } }
[ "public", "function", "translateAttributes", "(", "$", "event", ")", "{", "foreach", "(", "$", "this", "->", "translateAttributes", "as", "$", "attribute", ")", "{", "$", "this", "->", "owner", "->", "{", "$", "attribute", "}", "=", "Yii", "::", "t", "...
Translates the attributes to the current language. @param \yii\base\Event $event
[ "Translates", "the", "attributes", "to", "the", "current", "language", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/behaviors/TranslateBehavior.php#L94-L99
train
lajax/yii2-translate-manager
behaviors/TranslateBehavior.php
TranslateBehavior.saveAttributes
public function saveAttributes($event) { $isAppInSourceLanguage = Yii::$app->sourceLanguage === Yii::$app->language; foreach ($this->translateAttributes as $attribute) { if (!$this->owner->isAttributeChanged($attribute)) { continue; } if ($isAppInSourceLanguage || !$this->saveAttributeValueAsTranslation($attribute)) { Language::saveMessage($this->owner->attributes[$attribute], $this->category); } } }
php
public function saveAttributes($event) { $isAppInSourceLanguage = Yii::$app->sourceLanguage === Yii::$app->language; foreach ($this->translateAttributes as $attribute) { if (!$this->owner->isAttributeChanged($attribute)) { continue; } if ($isAppInSourceLanguage || !$this->saveAttributeValueAsTranslation($attribute)) { Language::saveMessage($this->owner->attributes[$attribute], $this->category); } } }
[ "public", "function", "saveAttributes", "(", "$", "event", ")", "{", "$", "isAppInSourceLanguage", "=", "Yii", "::", "$", "app", "->", "sourceLanguage", "===", "Yii", "::", "$", "app", "->", "language", ";", "foreach", "(", "$", "this", "->", "translateAtt...
Saves new language element by category. @param \yii\base\Event $event
[ "Saves", "new", "language", "element", "by", "category", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/behaviors/TranslateBehavior.php#L106-L119
train
lajax/yii2-translate-manager
behaviors/TranslateBehavior.php
TranslateBehavior.findSourceMessage
private function findSourceMessage($message) { $sourceMessages = LanguageSource::findAll(['message' => $message, 'category' => $this->category]); foreach ($sourceMessages as $source) { if ($source->message === $message) { return $source; } } }
php
private function findSourceMessage($message) { $sourceMessages = LanguageSource::findAll(['message' => $message, 'category' => $this->category]); foreach ($sourceMessages as $source) { if ($source->message === $message) { return $source; } } }
[ "private", "function", "findSourceMessage", "(", "$", "message", ")", "{", "$", "sourceMessages", "=", "LanguageSource", "::", "findAll", "(", "[", "'message'", "=>", "$", "message", ",", "'category'", "=>", "$", "this", "->", "category", "]", ")", ";", "f...
Finds the source record with case sensitive match. @param string $message @return LanguageSource|null Null if the source is not found.
[ "Finds", "the", "source", "record", "with", "case", "sensitive", "match", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/behaviors/TranslateBehavior.php#L165-L174
train
lajax/yii2-translate-manager
controllers/actions/DeleteSourceAction.php
DeleteSourceAction.run
public function run() { Yii::$app->response->format = Response::FORMAT_JSON; $ids = Yii::$app->request->post('ids'); LanguageSource::deleteAll(['id' => (array) $ids]); return []; }
php
public function run() { Yii::$app->response->format = Response::FORMAT_JSON; $ids = Yii::$app->request->post('ids'); LanguageSource::deleteAll(['id' => (array) $ids]); return []; }
[ "public", "function", "run", "(", ")", "{", "Yii", "::", "$", "app", "->", "response", "->", "format", "=", "Response", "::", "FORMAT_JSON", ";", "$", "ids", "=", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", "'ids'", ")", ";", "Lang...
Deletes an existing LanguageSource model. If deletion is successful, the browser will be redirected to the 'list' page. @return array
[ "Deletes", "an", "existing", "LanguageSource", "model", ".", "If", "deletion", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "list", "page", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/controllers/actions/DeleteSourceAction.php#L24-L33
train
lajax/yii2-translate-manager
controllers/actions/SaveAction.php
SaveAction.run
public function run() { Yii::$app->response->format = Response::FORMAT_JSON; $id = Yii::$app->request->post('id', 0); $languageId = Yii::$app->request->post('language_id', Yii::$app->language); $languageTranslate = LanguageTranslate::findOne(['id' => $id, 'language' => $languageId]) ?: new LanguageTranslate(['id' => $id, 'language' => $languageId]); $languageTranslate->translation = Yii::$app->request->post('translation', ''); if ($languageTranslate->validate() && $languageTranslate->save()) { $generator = new Generator($this->controller->module, $languageId); $generator->run(); } return $languageTranslate->getErrors(); }
php
public function run() { Yii::$app->response->format = Response::FORMAT_JSON; $id = Yii::$app->request->post('id', 0); $languageId = Yii::$app->request->post('language_id', Yii::$app->language); $languageTranslate = LanguageTranslate::findOne(['id' => $id, 'language' => $languageId]) ?: new LanguageTranslate(['id' => $id, 'language' => $languageId]); $languageTranslate->translation = Yii::$app->request->post('translation', ''); if ($languageTranslate->validate() && $languageTranslate->save()) { $generator = new Generator($this->controller->module, $languageId); $generator->run(); } return $languageTranslate->getErrors(); }
[ "public", "function", "run", "(", ")", "{", "Yii", "::", "$", "app", "->", "response", "->", "format", "=", "Response", "::", "FORMAT_JSON", ";", "$", "id", "=", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", "'id'", ",", "0", ")", ...
Saving translated language elements. @return array
[ "Saving", "translated", "language", "elements", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/controllers/actions/SaveAction.php#L24-L42
train
lajax/yii2-translate-manager
controllers/actions/DialogAction.php
DialogAction.run
public function run() { $languageSource = LanguageSource::find()->where([ 'category' => Yii::$app->request->post('category', ''), 'MD5(message)' => Yii::$app->request->post('hash', ''), ])->one(); if (!$languageSource) { return '<div id="translate-manager-error">' . Yii::t('language', 'Text not found in database! Please run project scan before translating!') . '</div>'; } return $this->controller->renderPartial('dialog', [ 'languageSource' => $languageSource, 'languageTranslate' => $this->_getTranslation($languageSource), ]); }
php
public function run() { $languageSource = LanguageSource::find()->where([ 'category' => Yii::$app->request->post('category', ''), 'MD5(message)' => Yii::$app->request->post('hash', ''), ])->one(); if (!$languageSource) { return '<div id="translate-manager-error">' . Yii::t('language', 'Text not found in database! Please run project scan before translating!') . '</div>'; } return $this->controller->renderPartial('dialog', [ 'languageSource' => $languageSource, 'languageTranslate' => $this->_getTranslation($languageSource), ]); }
[ "public", "function", "run", "(", ")", "{", "$", "languageSource", "=", "LanguageSource", "::", "find", "(", ")", "->", "where", "(", "[", "'category'", "=>", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", "'category'", ",", "''", ")", ...
Creating dialogue box. @return string
[ "Creating", "dialogue", "box", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/controllers/actions/DialogAction.php#L23-L38
train
lajax/yii2-translate-manager
services/Optimizer.php
Optimizer.run
public function run() { $this->_scanner = new Scanner(); $this->_scanner->run(); $this->_scanner->stdout('Deleted language elements - BEGIN', Console::FG_RED); $languageSourceIds = $this->_scanner->getRemovableLanguageSourceIds(); $this->_initLanguageElements($languageSourceIds); LanguageSource::deleteAll(['id' => $languageSourceIds]); $this->_scanner->stdout('Deleted language elements - END', Console::FG_RED); return count($languageSourceIds); }
php
public function run() { $this->_scanner = new Scanner(); $this->_scanner->run(); $this->_scanner->stdout('Deleted language elements - BEGIN', Console::FG_RED); $languageSourceIds = $this->_scanner->getRemovableLanguageSourceIds(); $this->_initLanguageElements($languageSourceIds); LanguageSource::deleteAll(['id' => $languageSourceIds]); $this->_scanner->stdout('Deleted language elements - END', Console::FG_RED); return count($languageSourceIds); }
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "_scanner", "=", "new", "Scanner", "(", ")", ";", "$", "this", "->", "_scanner", "->", "run", "(", ")", ";", "$", "this", "->", "_scanner", "->", "stdout", "(", "'Deleted language elements ...
Removing unused language elements from database. @return int The number of removed language elements.
[ "Removing", "unused", "language", "elements", "from", "database", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/services/Optimizer.php#L44-L59
train
lajax/yii2-translate-manager
models/LanguageSource.php
LanguageSource.insertLanguageItems
public function insertLanguageItems($languageItems) { $data = []; foreach ($languageItems as $category => $messages) { foreach (array_keys($messages) as $message) { $data[] = [ $category, $message, ]; } } $count = count($data); for ($i = 0; $i < $count; $i += self::INSERT_LANGUAGE_ITEMS_LIMIT) { static::getDb() ->createCommand() ->batchInsert(static::tableName(), ['category', 'message'], array_slice($data, $i, self::INSERT_LANGUAGE_ITEMS_LIMIT)) ->execute(); } return $count; }
php
public function insertLanguageItems($languageItems) { $data = []; foreach ($languageItems as $category => $messages) { foreach (array_keys($messages) as $message) { $data[] = [ $category, $message, ]; } } $count = count($data); for ($i = 0; $i < $count; $i += self::INSERT_LANGUAGE_ITEMS_LIMIT) { static::getDb() ->createCommand() ->batchInsert(static::tableName(), ['category', 'message'], array_slice($data, $i, self::INSERT_LANGUAGE_ITEMS_LIMIT)) ->execute(); } return $count; }
[ "public", "function", "insertLanguageItems", "(", "$", "languageItems", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "languageItems", "as", "$", "category", "=>", "$", "messages", ")", "{", "foreach", "(", "array_keys", "(", "$", "mess...
Inserting new language elements into the language_source table. @param array $languageItems @return int The number of new language elements.
[ "Inserting", "new", "language", "elements", "into", "the", "language_source", "table", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/models/LanguageSource.php#L79-L100
train
lajax/yii2-translate-manager
controllers/actions/DeleteAction.php
DeleteAction.run
public function run($id) { $this->controller->findModel($id)->delete(); return $this->controller->redirect(['list']); }
php
public function run($id) { $this->controller->findModel($id)->delete(); return $this->controller->redirect(['list']); }
[ "public", "function", "run", "(", "$", "id", ")", "{", "$", "this", "->", "controller", "->", "findModel", "(", "$", "id", ")", "->", "delete", "(", ")", ";", "return", "$", "this", "->", "controller", "->", "redirect", "(", "[", "'list'", "]", ")"...
Deletes an existing Language model. If deletion is successful, the browser will be redirected to the 'list' page. @param string $id @return mixed
[ "Deletes", "an", "existing", "Language", "model", ".", "If", "deletion", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "list", "page", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/controllers/actions/DeleteAction.php#L22-L27
train
lajax/yii2-translate-manager
services/Generator.php
Generator._generateJSFile
private function _generateJSFile() { $this->_loadLanguageItems(); $data = []; foreach ($this->_languageItems as $language_item) { $data[md5($language_item->message)] = $language_item->languageTranslate->translation; } $filename = $this->_basePath . '/' . $this->_languageId . '.js'; file_put_contents($filename, str_replace('{language_items}', Json::encode($data), $this->_template)); }
php
private function _generateJSFile() { $this->_loadLanguageItems(); $data = []; foreach ($this->_languageItems as $language_item) { $data[md5($language_item->message)] = $language_item->languageTranslate->translation; } $filename = $this->_basePath . '/' . $this->_languageId . '.js'; file_put_contents($filename, str_replace('{language_items}', Json::encode($data), $this->_template)); }
[ "private", "function", "_generateJSFile", "(", ")", "{", "$", "this", "->", "_loadLanguageItems", "(", ")", ";", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "_languageItems", "as", "$", "language_item", ")", "{", "$", "data", "[...
Creating JavaScript language file in current language.
[ "Creating", "JavaScript", "language", "file", "in", "current", "language", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/services/Generator.php#L90-L102
train
lajax/yii2-translate-manager
services/Generator.php
Generator._loadLanguageItems
private function _loadLanguageItems() { $this->_languageItems = LanguageSource::find() ->joinWith(['languageTranslate' => function ($query) { $query->where(['language' => $this->_languageId]); }, ]) ->where(['category' => Scanner::CATEGORY_JAVASCRIPT]) ->all(); }
php
private function _loadLanguageItems() { $this->_languageItems = LanguageSource::find() ->joinWith(['languageTranslate' => function ($query) { $query->where(['language' => $this->_languageId]); }, ]) ->where(['category' => Scanner::CATEGORY_JAVASCRIPT]) ->all(); }
[ "private", "function", "_loadLanguageItems", "(", ")", "{", "$", "this", "->", "_languageItems", "=", "LanguageSource", "::", "find", "(", ")", "->", "joinWith", "(", "[", "'languageTranslate'", "=>", "function", "(", "$", "query", ")", "{", "$", "query", ...
Loads language elements in JavaScript category.
[ "Loads", "language", "elements", "in", "JavaScript", "category", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/services/Generator.php#L107-L116
train
lajax/yii2-translate-manager
Component.php
Component._initTranslation
private function _initTranslation() { $module = Yii::$app->getModule('translatemanager'); if ($module->checkAccess() && $this->_checkRoles($module->roles)) { Yii::$app->session->set(Module::SESSION_KEY_ENABLE_TRANSLATE, true); } }
php
private function _initTranslation() { $module = Yii::$app->getModule('translatemanager'); if ($module->checkAccess() && $this->_checkRoles($module->roles)) { Yii::$app->session->set(Module::SESSION_KEY_ENABLE_TRANSLATE, true); } }
[ "private", "function", "_initTranslation", "(", ")", "{", "$", "module", "=", "Yii", "::", "$", "app", "->", "getModule", "(", "'translatemanager'", ")", ";", "if", "(", "$", "module", "->", "checkAccess", "(", ")", "&&", "$", "this", "->", "_checkRoles"...
Initialising front end translator.
[ "Initialising", "front", "end", "translator", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/Component.php#L41-L48
train
lajax/yii2-translate-manager
Component.php
Component._checkRoles
private function _checkRoles($roles) { if (!$roles) { return true; } foreach ($roles as $role) { if (Yii::$app->user->can($role)) { return true; } } return false; }
php
private function _checkRoles($roles) { if (!$roles) { return true; } foreach ($roles as $role) { if (Yii::$app->user->can($role)) { return true; } } return false; }
[ "private", "function", "_checkRoles", "(", "$", "roles", ")", "{", "if", "(", "!", "$", "roles", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "roles", "as", "$", "role", ")", "{", "if", "(", "Yii", "::", "$", "app", "->", "user", ...
Determines if the current user has the necessary privileges for online translation. @param array $roles The necessary roles for accessing the module. @return bool
[ "Determines", "if", "the", "current", "user", "has", "the", "necessary", "privileges", "for", "online", "translation", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/Component.php#L57-L70
train
lajax/yii2-translate-manager
widgets/ToggleTranslate.php
ToggleTranslate._registerAssets
private function _registerAssets() { if ($this->frontendTranslationAsset) { Yii::$app->view->registerAssetBundle($this->frontendTranslationAsset); } if ($this->frontendTranslationPluginAsset) { Yii::$app->view->registerAssetBundle($this->frontendTranslationPluginAsset); } }
php
private function _registerAssets() { if ($this->frontendTranslationAsset) { Yii::$app->view->registerAssetBundle($this->frontendTranslationAsset); } if ($this->frontendTranslationPluginAsset) { Yii::$app->view->registerAssetBundle($this->frontendTranslationPluginAsset); } }
[ "private", "function", "_registerAssets", "(", ")", "{", "if", "(", "$", "this", "->", "frontendTranslationAsset", ")", "{", "Yii", "::", "$", "app", "->", "view", "->", "registerAssetBundle", "(", "$", "this", "->", "frontendTranslationAsset", ")", ";", "}"...
Registering asset files
[ "Registering", "asset", "files" ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/widgets/ToggleTranslate.php#L121-L130
train
lajax/yii2-translate-manager
models/Language.php
Language.getLanguageNames
public static function getLanguageNames($active = false) { $languageNames = []; foreach (self::getLanguages($active, true) as $language) { $languageNames[$language['language_id']] = $language['name']; } return $languageNames; }
php
public static function getLanguageNames($active = false) { $languageNames = []; foreach (self::getLanguages($active, true) as $language) { $languageNames[$language['language_id']] = $language['name']; } return $languageNames; }
[ "public", "static", "function", "getLanguageNames", "(", "$", "active", "=", "false", ")", "{", "$", "languageNames", "=", "[", "]", ";", "foreach", "(", "self", "::", "getLanguages", "(", "$", "active", ",", "true", ")", "as", "$", "language", ")", "{...
Returns the list of languages stored in the database in an array. @param bool $active True/False according to the status of the language. @return array @deprecated since version 1.5.2
[ "Returns", "the", "list", "of", "languages", "stored", "in", "the", "database", "in", "an", "array", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/models/Language.php#L113-L121
train
lajax/yii2-translate-manager
models/Language.php
Language.getLanguages
public static function getLanguages($active = true, $asArray = false) { if ($active) { return self::find()->where(['status' => static::STATUS_ACTIVE])->asArray($asArray)->all(); } else { return self::find()->asArray($asArray)->all(); } }
php
public static function getLanguages($active = true, $asArray = false) { if ($active) { return self::find()->where(['status' => static::STATUS_ACTIVE])->asArray($asArray)->all(); } else { return self::find()->asArray($asArray)->all(); } }
[ "public", "static", "function", "getLanguages", "(", "$", "active", "=", "true", ",", "$", "asArray", "=", "false", ")", "{", "if", "(", "$", "active", ")", "{", "return", "self", "::", "find", "(", ")", "->", "where", "(", "[", "'status'", "=>", "...
Returns language objects. @param bool $active True/False according to the status of the language. @param bool $asArray Return the languages as language object or as 'flat' array @return Language|array @deprecated since version 1.5.2
[ "Returns", "language", "objects", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/models/Language.php#L133-L140
train
lajax/yii2-translate-manager
controllers/actions/TranslateAction.php
TranslateAction.run
public function run() { $searchModel = new LanguageSourceSearch([ 'searchEmptyCommand' => $this->controller->module->searchEmptyCommand, ]); $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); return $this->controller->render('translate', [ 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'searchEmptyCommand' => $this->controller->module->searchEmptyCommand, 'language_id' => Yii::$app->request->get('language_id', ''), ]); }
php
public function run() { $searchModel = new LanguageSourceSearch([ 'searchEmptyCommand' => $this->controller->module->searchEmptyCommand, ]); $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); return $this->controller->render('translate', [ 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'searchEmptyCommand' => $this->controller->module->searchEmptyCommand, 'language_id' => Yii::$app->request->get('language_id', ''), ]); }
[ "public", "function", "run", "(", ")", "{", "$", "searchModel", "=", "new", "LanguageSourceSearch", "(", "[", "'searchEmptyCommand'", "=>", "$", "this", "->", "controller", "->", "module", "->", "searchEmptyCommand", ",", "]", ")", ";", "$", "dataProvider", ...
List of language elements. @return string
[ "List", "of", "language", "elements", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/controllers/actions/TranslateAction.php#L34-L47
train
lajax/yii2-translate-manager
services/scanners/ScannerPhpArray.php
ScannerPhpArray._getTranslators
private function _getTranslators($file) { $subject = file_get_contents($file); preg_match_all($this->module->patternArrayTranslator, $subject, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); $translators = []; foreach ($matches as $data) { if (isset($data['translator'][0])) { $translators[$data['translator'][0]] = true; } } return array_keys($translators); }
php
private function _getTranslators($file) { $subject = file_get_contents($file); preg_match_all($this->module->patternArrayTranslator, $subject, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); $translators = []; foreach ($matches as $data) { if (isset($data['translator'][0])) { $translators[$data['translator'][0]] = true; } } return array_keys($translators); }
[ "private", "function", "_getTranslators", "(", "$", "file", ")", "{", "$", "subject", "=", "file_get_contents", "(", "$", "file", ")", ";", "preg_match_all", "(", "$", "this", "->", "module", "->", "patternArrayTranslator", ",", "$", "subject", ",", "$", "...
Returns the names of the arrays storing the language elements to be translated. @param string $file Path to the file to scan. @return array List of arrays storing the language elements to be translated.
[ "Returns", "the", "names", "of", "the", "arrays", "storing", "the", "language", "elements", "to", "be", "translated", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/services/scanners/ScannerPhpArray.php#L81-L93
train
lajax/yii2-translate-manager
models/ImportForm.php
ImportForm.throwInvalidModelException
protected function throwInvalidModelException($model) { $errorMessage = Yii::t('language', 'Invalid model "{model}":', ['model' => $model->className()]); foreach ($model->getErrors() as $attribute => $errors) { $errorMessage .= "\n $attribute: " . join(', ', $errors); } throw new Exception($errorMessage); }
php
protected function throwInvalidModelException($model) { $errorMessage = Yii::t('language', 'Invalid model "{model}":', ['model' => $model->className()]); foreach ($model->getErrors() as $attribute => $errors) { $errorMessage .= "\n $attribute: " . join(', ', $errors); } throw new Exception($errorMessage); }
[ "protected", "function", "throwInvalidModelException", "(", "$", "model", ")", "{", "$", "errorMessage", "=", "Yii", "::", "t", "(", "'language'", ",", "'Invalid model \"{model}\":'", ",", "[", "'model'", "=>", "$", "model", "->", "className", "(", ")", "]", ...
Converts the model validation errors to a readable format an throws it as an exception @param ActiveRecord $model @throws Exception
[ "Converts", "the", "model", "validation", "errors", "to", "a", "readable", "format", "an", "throws", "it", "as", "an", "exception" ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/models/ImportForm.php#L228-L235
train
lajax/yii2-translate-manager
models/searches/LanguageSourceSearch.php
LanguageSourceSearch._getSourceLanguage
private function _getSourceLanguage() { $languageSourceSearch = Yii::$app->request->get('LanguageSourceSearch', []); return isset($languageSourceSearch['source']) ? $languageSourceSearch['source'] : Yii::$app->sourceLanguage; }
php
private function _getSourceLanguage() { $languageSourceSearch = Yii::$app->request->get('LanguageSourceSearch', []); return isset($languageSourceSearch['source']) ? $languageSourceSearch['source'] : Yii::$app->sourceLanguage; }
[ "private", "function", "_getSourceLanguage", "(", ")", "{", "$", "languageSourceSearch", "=", "Yii", "::", "$", "app", "->", "request", "->", "get", "(", "'LanguageSourceSearch'", ",", "[", "]", ")", ";", "return", "isset", "(", "$", "languageSourceSearch", ...
Returns the language of message source. @return string
[ "Returns", "the", "language", "of", "message", "source", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/models/searches/LanguageSourceSearch.php#L130-L135
train
lajax/yii2-translate-manager
controllers/actions/ListAction.php
ListAction.run
public function run() { $searchModel = new LanguageSearch(); $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); $dataProvider->sort = ['defaultOrder' => ['status' => SORT_DESC]]; return $this->controller->render('list', [ 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); }
php
public function run() { $searchModel = new LanguageSearch(); $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); $dataProvider->sort = ['defaultOrder' => ['status' => SORT_DESC]]; return $this->controller->render('list', [ 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); }
[ "public", "function", "run", "(", ")", "{", "$", "searchModel", "=", "new", "LanguageSearch", "(", ")", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "Yii", "::", "$", "app", "->", "request", "->", "getQueryParams", "(", ")", ...
List of languages @return string
[ "List", "of", "languages" ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/controllers/actions/ListAction.php#L34-L44
train
lajax/yii2-translate-manager
controllers/actions/MessageAction.php
MessageAction.run
public function run() { $languageTranslate = LanguageTranslate::findOne([ 'id' => Yii::$app->request->get('id', 0), 'language' => Yii::$app->request->get('language_id', ''), ]); if ($languageTranslate) { $translation = $languageTranslate->translation; } else { $languageSource = LanguageSource::findOne([ 'id' => Yii::$app->request->get('id', 0), ]); $translation = $languageSource ? $languageSource->message : ''; } return $translation; }
php
public function run() { $languageTranslate = LanguageTranslate::findOne([ 'id' => Yii::$app->request->get('id', 0), 'language' => Yii::$app->request->get('language_id', ''), ]); if ($languageTranslate) { $translation = $languageTranslate->translation; } else { $languageSource = LanguageSource::findOne([ 'id' => Yii::$app->request->get('id', 0), ]); $translation = $languageSource ? $languageSource->message : ''; } return $translation; }
[ "public", "function", "run", "(", ")", "{", "$", "languageTranslate", "=", "LanguageTranslate", "::", "findOne", "(", "[", "'id'", "=>", "Yii", "::", "$", "app", "->", "request", "->", "get", "(", "'id'", ",", "0", ")", ",", "'language'", "=>", "Yii", ...
Returning messages in the given language @return string
[ "Returning", "messages", "in", "the", "given", "language" ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/controllers/actions/MessageAction.php#L23-L41
train
lajax/yii2-translate-manager
controllers/actions/ImportAction.php
ImportAction.run
public function run() { $model = new ImportForm(); if (Yii::$app->request->isPost) { $model->importFile = UploadedFile::getInstance($model, 'importFile'); if ($model->validate()) { try { $result = $model->import(); $message = Yii::t('language', 'Successfully imported {fileName}', ['fileName' => $model->importFile->name]); $message .= "<br/>\n"; foreach ($result as $type => $typeResult) { $message .= "<br/>\n" . Yii::t('language', '{type}: {new} new, {updated} updated', [ 'type' => $type, 'new' => $typeResult['new'], 'updated' => $typeResult['updated'], ]); } $languageIds = Language::find() ->select('language_id') ->where(['status' => Language::STATUS_ACTIVE]) ->column(); foreach ($languageIds as $languageId) { $generator = new Generator($this->controller->module, $languageId); $generator->run(); } Yii::$app->getSession()->setFlash('success', $message); } catch (\Exception $e) { if (YII_DEBUG) { throw $e; } else { Yii::$app->getSession()->setFlash('danger', str_replace("\n", "<br/>\n", $e->getMessage())); } } } } return $this->controller->render('import', [ 'model' => $model, ]); }
php
public function run() { $model = new ImportForm(); if (Yii::$app->request->isPost) { $model->importFile = UploadedFile::getInstance($model, 'importFile'); if ($model->validate()) { try { $result = $model->import(); $message = Yii::t('language', 'Successfully imported {fileName}', ['fileName' => $model->importFile->name]); $message .= "<br/>\n"; foreach ($result as $type => $typeResult) { $message .= "<br/>\n" . Yii::t('language', '{type}: {new} new, {updated} updated', [ 'type' => $type, 'new' => $typeResult['new'], 'updated' => $typeResult['updated'], ]); } $languageIds = Language::find() ->select('language_id') ->where(['status' => Language::STATUS_ACTIVE]) ->column(); foreach ($languageIds as $languageId) { $generator = new Generator($this->controller->module, $languageId); $generator->run(); } Yii::$app->getSession()->setFlash('success', $message); } catch (\Exception $e) { if (YII_DEBUG) { throw $e; } else { Yii::$app->getSession()->setFlash('danger', str_replace("\n", "<br/>\n", $e->getMessage())); } } } } return $this->controller->render('import', [ 'model' => $model, ]); }
[ "public", "function", "run", "(", ")", "{", "$", "model", "=", "new", "ImportForm", "(", ")", ";", "if", "(", "Yii", "::", "$", "app", "->", "request", "->", "isPost", ")", "{", "$", "model", "->", "importFile", "=", "UploadedFile", "::", "getInstanc...
Show import form and import the uploaded file if posted @return string @throws \Exception
[ "Show", "import", "form", "and", "import", "the", "uploaded", "file", "if", "posted" ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/controllers/actions/ImportAction.php#L23-L68
train
lajax/yii2-translate-manager
models/searches/SearchTrait.php
SearchTrait.createLikeExpression
protected function createLikeExpression($operand1, $operand2) { /* @var $db \yii\db\Connection */ $db = static::getDb(); // In PGSQL we use case insensitive matching also. $like_function = $db->getDriverName() == 'pgsql' ? 'ILIKE' : 'LIKE'; return [$like_function, $operand1, $operand2]; }
php
protected function createLikeExpression($operand1, $operand2) { /* @var $db \yii\db\Connection */ $db = static::getDb(); // In PGSQL we use case insensitive matching also. $like_function = $db->getDriverName() == 'pgsql' ? 'ILIKE' : 'LIKE'; return [$like_function, $operand1, $operand2]; }
[ "protected", "function", "createLikeExpression", "(", "$", "operand1", ",", "$", "operand2", ")", "{", "/* @var $db \\yii\\db\\Connection */", "$", "db", "=", "static", "::", "getDb", "(", ")", ";", "// In PGSQL we use case insensitive matching also.", "$", "like_functi...
Creates a `LIKE` expression, which can be used in the Query builder. @param mixed $operand1 Should be a column or DB expression. @param mixed $operand2 Should be a string or an array representing the values that the column or DB expression should be like. @return array @see http://www.yiiframework.com/doc-2.0/yii-db-query.html#where%28%29-detail
[ "Creates", "a", "LIKE", "expression", "which", "can", "be", "used", "in", "the", "Query", "builder", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/models/searches/SearchTrait.php#L25-L34
train
lajax/yii2-translate-manager
controllers/actions/ExportAction.php
ExportAction.run
public function run() { /** @var Module $module */ $module = $this->controller->module; $model = new ExportForm([ 'format' => $module->defaultExportFormat, ]); if ($model->load(Yii::$app->request->post())) { $fileName = Yii::t('language', 'translations') . '.' . $model->format; Yii::$app->response->format = $model->format; Yii::$app->response->formatters = [ Response::FORMAT_XML => [ 'class' => XmlResponseFormatter::className(), 'rootTag' => 'translations', ], Response::FORMAT_JSON => [ 'class' => JsonResponseFormatter::className(), ], ]; Yii::$app->response->setDownloadHeaders($fileName); return $model->getExportData(); } else { if (empty($model->languages)) { $model->exportLanguages = $model->getDefaultExportLanguages($module->defaultExportStatus); } return $this->controller->render('export', [ 'model' => $model, ]); } }
php
public function run() { /** @var Module $module */ $module = $this->controller->module; $model = new ExportForm([ 'format' => $module->defaultExportFormat, ]); if ($model->load(Yii::$app->request->post())) { $fileName = Yii::t('language', 'translations') . '.' . $model->format; Yii::$app->response->format = $model->format; Yii::$app->response->formatters = [ Response::FORMAT_XML => [ 'class' => XmlResponseFormatter::className(), 'rootTag' => 'translations', ], Response::FORMAT_JSON => [ 'class' => JsonResponseFormatter::className(), ], ]; Yii::$app->response->setDownloadHeaders($fileName); return $model->getExportData(); } else { if (empty($model->languages)) { $model->exportLanguages = $model->getDefaultExportLanguages($module->defaultExportStatus); } return $this->controller->render('export', [ 'model' => $model, ]); } }
[ "public", "function", "run", "(", ")", "{", "/** @var Module $module */", "$", "module", "=", "$", "this", "->", "controller", "->", "module", ";", "$", "model", "=", "new", "ExportForm", "(", "[", "'format'", "=>", "$", "module", "->", "defaultExportFormat"...
Show export form or generate export file on post @return string
[ "Show", "export", "form", "or", "generate", "export", "file", "on", "post" ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/controllers/actions/ExportAction.php#L22-L58
train
lajax/yii2-translate-manager
controllers/actions/ChangeStatusAction.php
ChangeStatusAction.run
public function run() { Yii::$app->response->format = Response::FORMAT_JSON; $language = Language::findOne(Yii::$app->request->post('language_id', '')); if ($language !== null) { $language->status = Yii::$app->request->post('status', Language::STATUS_BETA); if ($language->validate()) { $language->save(); } } return $language->getErrors(); }
php
public function run() { Yii::$app->response->format = Response::FORMAT_JSON; $language = Language::findOne(Yii::$app->request->post('language_id', '')); if ($language !== null) { $language->status = Yii::$app->request->post('status', Language::STATUS_BETA); if ($language->validate()) { $language->save(); } } return $language->getErrors(); }
[ "public", "function", "run", "(", ")", "{", "Yii", "::", "$", "app", "->", "response", "->", "format", "=", "Response", "::", "FORMAT_JSON", ";", "$", "language", "=", "Language", "::", "findOne", "(", "Yii", "::", "$", "app", "->", "request", "->", ...
Modifying the state of language. @return array
[ "Modifying", "the", "state", "of", "language", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/controllers/actions/ChangeStatusAction.php#L23-L36
train
lajax/yii2-translate-manager
helpers/Language.php
Language.saveMessage
public static function saveMessage($message, $category = 'database') { $languageSources = \lajax\translatemanager\models\LanguageSource::find()->where(['category' => $category])->all(); $messages = []; foreach ($languageSources as $languageSource) { $messages[$languageSource->message] = $languageSource->id; } if (empty($messages[$message])) { $languageSource = new \lajax\translatemanager\models\LanguageSource(); $languageSource->category = $category; $languageSource->message = $message; $languageSource->save(); } }
php
public static function saveMessage($message, $category = 'database') { $languageSources = \lajax\translatemanager\models\LanguageSource::find()->where(['category' => $category])->all(); $messages = []; foreach ($languageSources as $languageSource) { $messages[$languageSource->message] = $languageSource->id; } if (empty($messages[$message])) { $languageSource = new \lajax\translatemanager\models\LanguageSource(); $languageSource->category = $category; $languageSource->message = $message; $languageSource->save(); } }
[ "public", "static", "function", "saveMessage", "(", "$", "message", ",", "$", "category", "=", "'database'", ")", "{", "$", "languageSources", "=", "\\", "lajax", "\\", "translatemanager", "\\", "models", "\\", "LanguageSource", "::", "find", "(", ")", "->",...
Saveing new language element by category. @param string $message Language element save in database. @param string $category the message category.
[ "Saveing", "new", "language", "element", "by", "category", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/helpers/Language.php#L216-L231
train
lajax/yii2-translate-manager
helpers/Language.php
Language.getCategories
public static function getCategories() { $languageSources = \lajax\translatemanager\models\LanguageSource::find()->select('category')->distinct()->all(); $categories = []; foreach ($languageSources as $languageSource) { $categories[$languageSource->category] = $languageSource->category; } return $categories; }
php
public static function getCategories() { $languageSources = \lajax\translatemanager\models\LanguageSource::find()->select('category')->distinct()->all(); $categories = []; foreach ($languageSources as $languageSource) { $categories[$languageSource->category] = $languageSource->category; } return $categories; }
[ "public", "static", "function", "getCategories", "(", ")", "{", "$", "languageSources", "=", "\\", "lajax", "\\", "translatemanager", "\\", "models", "\\", "LanguageSource", "::", "find", "(", ")", "->", "select", "(", "'category'", ")", "->", "distinct", "(...
Returns the category of LanguageSource in an associative array. @return array
[ "Returns", "the", "category", "of", "LanguageSource", "in", "an", "associative", "array", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/helpers/Language.php#L238-L248
train
lajax/yii2-translate-manager
services/scanners/ScannerFile.php
ScannerFile._getRoots
private function _getRoots() { $directories = []; if (is_string($this->module->root)) { $root = Yii::getAlias($this->module->root); if ($this->module->scanRootParentDirectory) { $root = dirname($root); } $directories[] = $root; } elseif (is_array($this->module->root)) { foreach ($this->module->root as $root) { $directories[] = Yii::getAlias($root); } } else { throw new InvalidConfigException('Invalid `root` option value!'); } return $directories; }
php
private function _getRoots() { $directories = []; if (is_string($this->module->root)) { $root = Yii::getAlias($this->module->root); if ($this->module->scanRootParentDirectory) { $root = dirname($root); } $directories[] = $root; } elseif (is_array($this->module->root)) { foreach ($this->module->root as $root) { $directories[] = Yii::getAlias($root); } } else { throw new InvalidConfigException('Invalid `root` option value!'); } return $directories; }
[ "private", "function", "_getRoots", "(", ")", "{", "$", "directories", "=", "[", "]", ";", "if", "(", "is_string", "(", "$", "this", "->", "module", "->", "root", ")", ")", "{", "$", "root", "=", "Yii", "::", "getAlias", "(", "$", "this", "->", "...
Returns the root directories to scan. @return array
[ "Returns", "the", "root", "directories", "to", "scan", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/services/scanners/ScannerFile.php#L241-L261
train
lajax/yii2-translate-manager
services/scanners/ScannerDatabase.php
ScannerDatabase.run
public function run() { $this->_scanner->stdout('Detect DatabaseTable - BEGIN', Console::FG_GREY); if (is_array($this->_tables)) { foreach ($this->_tables as $tables) { $this->_scanningTable($tables); } } $this->_scanner->stdout('Detect DatabaseTable - END', Console::FG_GREY); }
php
public function run() { $this->_scanner->stdout('Detect DatabaseTable - BEGIN', Console::FG_GREY); if (is_array($this->_tables)) { foreach ($this->_tables as $tables) { $this->_scanningTable($tables); } } $this->_scanner->stdout('Detect DatabaseTable - END', Console::FG_GREY); }
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "_scanner", "->", "stdout", "(", "'Detect DatabaseTable - BEGIN'", ",", "Console", "::", "FG_GREY", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "_tables", ")", ")", "{", "foreach...
Scanning database tables defined in configuration file. Searching for language elements yet to be translated.
[ "Scanning", "database", "tables", "defined", "in", "configuration", "file", ".", "Searching", "for", "language", "elements", "yet", "to", "be", "translated", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/services/scanners/ScannerDatabase.php#L72-L82
train
lajax/yii2-translate-manager
services/scanners/ScannerDatabase.php
ScannerDatabase._scanningTable
private function _scanningTable($tables) { $this->_scanner->stdout('Extracting mesages from ' . $tables['table'] . '.' . implode(',', $tables['columns']), Console::FG_GREEN); $query = new \yii\db\Query(); $data = $query->select($tables['columns']) ->from($tables['table']) ->createCommand(Yii::$app->{$tables['connection']}) ->queryAll(); $category = $this->_getCategory($tables); foreach ($data as $columns) { $columns = array_map('trim', $columns); foreach ($columns as $column) { $this->_scanner->addLanguageItem($category, $column); } } }
php
private function _scanningTable($tables) { $this->_scanner->stdout('Extracting mesages from ' . $tables['table'] . '.' . implode(',', $tables['columns']), Console::FG_GREEN); $query = new \yii\db\Query(); $data = $query->select($tables['columns']) ->from($tables['table']) ->createCommand(Yii::$app->{$tables['connection']}) ->queryAll(); $category = $this->_getCategory($tables); foreach ($data as $columns) { $columns = array_map('trim', $columns); foreach ($columns as $column) { $this->_scanner->addLanguageItem($category, $column); } } }
[ "private", "function", "_scanningTable", "(", "$", "tables", ")", "{", "$", "this", "->", "_scanner", "->", "stdout", "(", "'Extracting mesages from '", ".", "$", "tables", "[", "'table'", "]", ".", "'.'", ".", "implode", "(", "','", ",", "$", "tables", ...
Scanning database table @param array $tables
[ "Scanning", "database", "table" ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/services/scanners/ScannerDatabase.php#L89-L104
train
lajax/yii2-translate-manager
services/scanners/ScannerDatabase.php
ScannerDatabase._getCategory
private function _getCategory($tables) { if (isset($tables['category']) && $tables['category'] == 'database-table-name') { $category = $this->_normalizeTablename($tables['table']); } else { $category = Scanner::CATEGORY_DATABASE; } return $category; }
php
private function _getCategory($tables) { if (isset($tables['category']) && $tables['category'] == 'database-table-name') { $category = $this->_normalizeTablename($tables['table']); } else { $category = Scanner::CATEGORY_DATABASE; } return $category; }
[ "private", "function", "_getCategory", "(", "$", "tables", ")", "{", "if", "(", "isset", "(", "$", "tables", "[", "'category'", "]", ")", "&&", "$", "tables", "[", "'category'", "]", "==", "'database-table-name'", ")", "{", "$", "category", "=", "$", "...
Returns the language category. @param array $tables @return string
[ "Returns", "the", "language", "category", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/services/scanners/ScannerDatabase.php#L113-L122
train
lajax/yii2-translate-manager
services/Scanner.php
Scanner.run
public function run() { $scanTimeLimit = Yii::$app->getModule('translatemanager')->scanTimeLimit; if (!is_null($scanTimeLimit)) { set_time_limit($scanTimeLimit); } $scanners = Yii::$app->getModule('translatemanager')->scanners; if (!empty($scanners)) { $this->scanners = $scanners; // override scanners from module configuration (custom scanners) } $this->_initLanguageArrays(); $languageSource = new LanguageSource(); return $languageSource->insertLanguageItems($this->_languageElements); }
php
public function run() { $scanTimeLimit = Yii::$app->getModule('translatemanager')->scanTimeLimit; if (!is_null($scanTimeLimit)) { set_time_limit($scanTimeLimit); } $scanners = Yii::$app->getModule('translatemanager')->scanners; if (!empty($scanners)) { $this->scanners = $scanners; // override scanners from module configuration (custom scanners) } $this->_initLanguageArrays(); $languageSource = new LanguageSource(); return $languageSource->insertLanguageItems($this->_languageElements); }
[ "public", "function", "run", "(", ")", "{", "$", "scanTimeLimit", "=", "Yii", "::", "$", "app", "->", "getModule", "(", "'translatemanager'", ")", "->", "scanTimeLimit", ";", "if", "(", "!", "is_null", "(", "$", "scanTimeLimit", ")", ")", "{", "set_time_...
Scanning project for text not stored in database. @return int The number of new language elements.
[ "Scanning", "project", "for", "text", "not", "stored", "in", "database", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/services/Scanner.php#L70-L88
train
lajax/yii2-translate-manager
services/Scanner.php
Scanner._scanningProject
private function _scanningProject() { foreach ($this->scanners as $scanner) { $object = new $scanner($this); $object->run(''); } }
php
private function _scanningProject() { foreach ($this->scanners as $scanner) { $object = new $scanner($this); $object->run(''); } }
[ "private", "function", "_scanningProject", "(", ")", "{", "foreach", "(", "$", "this", "->", "scanners", "as", "$", "scanner", ")", "{", "$", "object", "=", "new", "$", "scanner", "(", "$", "this", ")", ";", "$", "object", "->", "run", "(", "''", "...
Scan project for new language elements.
[ "Scan", "project", "for", "new", "language", "elements", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/services/Scanner.php#L145-L151
train
lajax/yii2-translate-manager
services/Scanner.php
Scanner.addLanguageItem
public function addLanguageItem($category, $message) { $this->_languageElements[$category][$message] = true; $coloredCategory = Console::ansiFormat($category, [Console::FG_YELLOW]); $coloredMessage = Console::ansiFormat($message, [Console::FG_YELLOW]); $this->stdout('Detected language element: [ ' . $coloredCategory . ' ] ' . $coloredMessage); }
php
public function addLanguageItem($category, $message) { $this->_languageElements[$category][$message] = true; $coloredCategory = Console::ansiFormat($category, [Console::FG_YELLOW]); $coloredMessage = Console::ansiFormat($message, [Console::FG_YELLOW]); $this->stdout('Detected language element: [ ' . $coloredCategory . ' ] ' . $coloredMessage); }
[ "public", "function", "addLanguageItem", "(", "$", "category", ",", "$", "message", ")", "{", "$", "this", "->", "_languageElements", "[", "$", "category", "]", "[", "$", "message", "]", "=", "true", ";", "$", "coloredCategory", "=", "Console", "::", "an...
Adding language elements to the array. @param string $category @param string $message
[ "Adding", "language", "elements", "to", "the", "array", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/services/Scanner.php#L159-L167
train
lajax/yii2-translate-manager
services/scanners/ScannerPhpFunction.php
ScannerPhpFunction.concatMessage
protected function concatMessage($buffer) { $messages = []; $buffer = array_slice($buffer, 2); $message = stripcslashes($buffer[0][1]); $messages[] = mb_substr($message, 1, mb_strlen($message) - 2); if (isset($buffer[1], $buffer[2][0]) && $buffer[1] === '.' && $buffer[2][0] == T_CONSTANT_ENCAPSED_STRING) { $messages = array_merge_recursive($messages, $this->concatMessage($buffer)); } return $messages; }
php
protected function concatMessage($buffer) { $messages = []; $buffer = array_slice($buffer, 2); $message = stripcslashes($buffer[0][1]); $messages[] = mb_substr($message, 1, mb_strlen($message) - 2); if (isset($buffer[1], $buffer[2][0]) && $buffer[1] === '.' && $buffer[2][0] == T_CONSTANT_ENCAPSED_STRING) { $messages = array_merge_recursive($messages, $this->concatMessage($buffer)); } return $messages; }
[ "protected", "function", "concatMessage", "(", "$", "buffer", ")", "{", "$", "messages", "=", "[", "]", ";", "$", "buffer", "=", "array_slice", "(", "$", "buffer", ",", "2", ")", ";", "$", "message", "=", "stripcslashes", "(", "$", "buffer", "[", "0"...
Recursice concatenation of multiple-piece language elements. @param array $buffer Array to store language element pieces. @return array Sorted list of language element pieces.
[ "Recursice", "concatenation", "of", "multiple", "-", "piece", "language", "elements", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/services/scanners/ScannerPhpFunction.php#L87-L98
train
lajax/yii2-translate-manager
models/LanguageTranslate.php
LanguageTranslate.getLanguageTranslateByIdAndLanguageId
public static function getLanguageTranslateByIdAndLanguageId($id, $languageId) { $languageTranslate = self::findOne(['id' => $id, 'language' => $languageId]); if (!$languageTranslate) { $languageTranslate = new self([ 'id' => $id, 'language' => $languageId, ]); } return $languageTranslate; }
php
public static function getLanguageTranslateByIdAndLanguageId($id, $languageId) { $languageTranslate = self::findOne(['id' => $id, 'language' => $languageId]); if (!$languageTranslate) { $languageTranslate = new self([ 'id' => $id, 'language' => $languageId, ]); } return $languageTranslate; }
[ "public", "static", "function", "getLanguageTranslateByIdAndLanguageId", "(", "$", "id", ",", "$", "languageId", ")", "{", "$", "languageTranslate", "=", "self", "::", "findOne", "(", "[", "'id'", "=>", "$", "id", ",", "'language'", "=>", "$", "languageId", ...
Returnes language object by id and language_id. If not found, creates a new one. @param int $id LanguageSource id @param string $languageId Language language_id @return LanguageTranslate @deprecated since version 1.2.7
[ "Returnes", "language", "object", "by", "id", "and", "language_id", ".", "If", "not", "found", "creates", "a", "new", "one", "." ]
a30dd362108cd6f336268e5d72eee6c4e7f65849
https://github.com/lajax/yii2-translate-manager/blob/a30dd362108cd6f336268e5d72eee6c4e7f65849/models/LanguageTranslate.php#L86-L97
train
skeeks-cms/cms
src/relatedProperties/PropertyType.php
PropertyType.renderForActiveForm
public function renderForActiveForm() { $field = $this->activeForm->field($this->property->relatedPropertiesModel, $this->property->code); if (!$field) { return ''; } return $field; }
php
public function renderForActiveForm() { $field = $this->activeForm->field($this->property->relatedPropertiesModel, $this->property->code); if (!$field) { return ''; } return $field; }
[ "public", "function", "renderForActiveForm", "(", ")", "{", "$", "field", "=", "$", "this", "->", "activeForm", "->", "field", "(", "$", "this", "->", "property", "->", "relatedPropertiesModel", ",", "$", "this", "->", "property", "->", "code", ")", ";", ...
Drawing form element @return \yii\widgets\ActiveField
[ "Drawing", "form", "element" ]
e46cbc9cd370402423eced525caf76031a21f70b
https://github.com/skeeks-cms/cms/blob/e46cbc9cd370402423eced525caf76031a21f70b/src/relatedProperties/PropertyType.php#L81-L90
train
skeeks-cms/cms
src/console/controllers/CacheController.php
CacheController.actionFlushAssets
public function actionFlushAssets() { $paths = ArrayHelper::getValue(\Yii::$app->cms->tmpFolderScheme, 'assets'); $this->stdout("Clear assets directories\n", Console::FG_YELLOW); if ($paths) { foreach ($paths as $path) { $realPath = \Yii::getAlias($path); $this->stdout("\tClear asset directory: {$realPath}\n"); FileHelper::removeDirectory(\Yii::getAlias($path)); FileHelper::createDirectory(\Yii::getAlias($path)); } } }
php
public function actionFlushAssets() { $paths = ArrayHelper::getValue(\Yii::$app->cms->tmpFolderScheme, 'assets'); $this->stdout("Clear assets directories\n", Console::FG_YELLOW); if ($paths) { foreach ($paths as $path) { $realPath = \Yii::getAlias($path); $this->stdout("\tClear asset directory: {$realPath}\n"); FileHelper::removeDirectory(\Yii::getAlias($path)); FileHelper::createDirectory(\Yii::getAlias($path)); } } }
[ "public", "function", "actionFlushAssets", "(", ")", "{", "$", "paths", "=", "ArrayHelper", "::", "getValue", "(", "\\", "Yii", "::", "$", "app", "->", "cms", "->", "tmpFolderScheme", ",", "'assets'", ")", ";", "$", "this", "->", "stdout", "(", "\"Clear ...
Clear asstes directories
[ "Clear", "asstes", "directories" ]
e46cbc9cd370402423eced525caf76031a21f70b
https://github.com/skeeks-cms/cms/blob/e46cbc9cd370402423eced525caf76031a21f70b/src/console/controllers/CacheController.php#L68-L81
train
skeeks-cms/cms
src/console/controllers/UpdateController.php
UpdateController.actionUserNameToFirstName
public function actionUserNameToFirstName() { if (!CmsUser::find()->count()) { $this->stdout("Content not found!\n", Console::BOLD); return; } $this->stdout("1. Cms user name normalize!\n", Console::FG_YELLOW); /** * @var CmsUser $cmsUser */ foreach (CmsUser::find()->orderBy(['id' => SORT_ASC])->each(10) as $cmsUser) { $this->stdout("\t User: {$cmsUser->id}\n", Console::FG_YELLOW); if (!$cmsUser->_to_del_name) { $this->stdout("\t NOT found property: _to_del_name\n", Console::FG_YELLOW); continue; } $name = $cmsUser->_to_del_name; $nameData = explode(" ", $name); if (isset($nameData[0])) { $cmsUser->first_name = trim($nameData[0]); } if (isset($nameData[1])) { $cmsUser->last_name = trim($nameData[1]); } if (isset($nameData[2])) { $cmsUser->patronymic = trim($nameData[2]); } if ($cmsUser->save()) { $this->stdout("\t Updated name: {$cmsUser->name}\n", Console::FG_GREEN); } else { $this->stdout("\t NOT updated name: {$cmsUser->id}\n", Console::FG_RED); } } }
php
public function actionUserNameToFirstName() { if (!CmsUser::find()->count()) { $this->stdout("Content not found!\n", Console::BOLD); return; } $this->stdout("1. Cms user name normalize!\n", Console::FG_YELLOW); /** * @var CmsUser $cmsUser */ foreach (CmsUser::find()->orderBy(['id' => SORT_ASC])->each(10) as $cmsUser) { $this->stdout("\t User: {$cmsUser->id}\n", Console::FG_YELLOW); if (!$cmsUser->_to_del_name) { $this->stdout("\t NOT found property: _to_del_name\n", Console::FG_YELLOW); continue; } $name = $cmsUser->_to_del_name; $nameData = explode(" ", $name); if (isset($nameData[0])) { $cmsUser->first_name = trim($nameData[0]); } if (isset($nameData[1])) { $cmsUser->last_name = trim($nameData[1]); } if (isset($nameData[2])) { $cmsUser->patronymic = trim($nameData[2]); } if ($cmsUser->save()) { $this->stdout("\t Updated name: {$cmsUser->name}\n", Console::FG_GREEN); } else { $this->stdout("\t NOT updated name: {$cmsUser->id}\n", Console::FG_RED); } } }
[ "public", "function", "actionUserNameToFirstName", "(", ")", "{", "if", "(", "!", "CmsUser", "::", "find", "(", ")", "->", "count", "(", ")", ")", "{", "$", "this", "->", "stdout", "(", "\"Content not found!\\n\"", ",", "Console", "::", "BOLD", ")", ";",...
Update user name to first and last name
[ "Update", "user", "name", "to", "first", "and", "last", "name" ]
e46cbc9cd370402423eced525caf76031a21f70b
https://github.com/skeeks-cms/cms/blob/e46cbc9cd370402423eced525caf76031a21f70b/src/console/controllers/UpdateController.php#L40-L82
train
skeeks-cms/cms
src/base/Component.php
Component.getSettingsId
public function getSettingsId($autoGenerate = true) { if ($autoGenerate && $this->_settingsId === null) { $this->_settingsId = static::$autoSettingsIdPrefix.static::$counterSettings++; } return $this->_settingsId; }
php
public function getSettingsId($autoGenerate = true) { if ($autoGenerate && $this->_settingsId === null) { $this->_settingsId = static::$autoSettingsIdPrefix.static::$counterSettings++; } return $this->_settingsId; }
[ "public", "function", "getSettingsId", "(", "$", "autoGenerate", "=", "true", ")", "{", "if", "(", "$", "autoGenerate", "&&", "$", "this", "->", "_settingsId", "===", "null", ")", "{", "$", "this", "->", "_settingsId", "=", "static", "::", "$", "autoSett...
Returns the ID of the widget. @param boolean $autoGenerate whether to generate an ID if it is not set previously @return string ID of the widget.
[ "Returns", "the", "ID", "of", "the", "widget", "." ]
e46cbc9cd370402423eced525caf76031a21f70b
https://github.com/skeeks-cms/cms/blob/e46cbc9cd370402423eced525caf76031a21f70b/src/base/Component.php#L722-L729
train
skeeks-cms/cms
src/base/Component.php
Component.setOldAttribute
public function setOldAttribute($name, $value) { if (isset($this->_oldAttributes[$name]) || $this->hasAttribute($name)) { $this->_oldAttributes[$name] = $value; } else { throw new InvalidParamException(get_class($this).' has no attribute named "'.$name.'".'); } }
php
public function setOldAttribute($name, $value) { if (isset($this->_oldAttributes[$name]) || $this->hasAttribute($name)) { $this->_oldAttributes[$name] = $value; } else { throw new InvalidParamException(get_class($this).' has no attribute named "'.$name.'".'); } }
[ "public", "function", "setOldAttribute", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_oldAttributes", "[", "$", "name", "]", ")", "||", "$", "this", "->", "hasAttribute", "(", "$", "name", ")", ")", "...
Sets the old value of the named attribute. @param string $name the attribute name @param mixed $value the old attribute value. @throws InvalidParamException if the named attribute does not exist. @see hasAttribute()
[ "Sets", "the", "old", "value", "of", "the", "named", "attribute", "." ]
e46cbc9cd370402423eced525caf76031a21f70b
https://github.com/skeeks-cms/cms/blob/e46cbc9cd370402423eced525caf76031a21f70b/src/base/Component.php#L854-L861
train
skeeks-cms/cms
src/base/Component.php
Component.getAttributeLabel
public function getAttributeLabel($attribute) { $labels = $this->attributeLabels(); if (isset($labels[$attribute])) { return $labels[$attribute]; } return $this->generateAttributeLabel($attribute); }
php
public function getAttributeLabel($attribute) { $labels = $this->attributeLabels(); if (isset($labels[$attribute])) { return $labels[$attribute]; } return $this->generateAttributeLabel($attribute); }
[ "public", "function", "getAttributeLabel", "(", "$", "attribute", ")", "{", "$", "labels", "=", "$", "this", "->", "attributeLabels", "(", ")", ";", "if", "(", "isset", "(", "$", "labels", "[", "$", "attribute", "]", ")", ")", "{", "return", "$", "la...
Returns the text label for the specified attribute. If the attribute looks like `relatedModel.attribute`, then the attribute will be received from the related model. @param string $attribute the attribute name @return string the attribute label @see generateAttributeLabel() @see attributeLabels()
[ "Returns", "the", "text", "label", "for", "the", "specified", "attribute", ".", "If", "the", "attribute", "looks", "like", "relatedModel", ".", "attribute", "then", "the", "attribute", "will", "be", "received", "from", "the", "related", "model", "." ]
e46cbc9cd370402423eced525caf76031a21f70b
https://github.com/skeeks-cms/cms/blob/e46cbc9cd370402423eced525caf76031a21f70b/src/base/Component.php#L1051-L1059
train
skeeks-cms/cms
src/console/controllers/UtilsController.php
UtilsController.actionRemoveContentElements
public function actionRemoveContentElements($contentId = null) { $query = CmsContentElement::find(); if ($contentId) { $query->andWhere(['content_id' => $contentId]); } if (!$count = $query->count()) { $this->stdout("Content elements not found!\n", Console::BOLD); return; } $this->stdout("1. Found elements: {$count}!\n", Console::BOLD); foreach ($query->orderBy([ 'content_id' => SORT_ASC, 'id' => SORT_ASC ])->each(10) as $cmsContentElement) { $this->stdout("\t{$cmsContentElement->id}: {$cmsContentElement->name}"); if ($cmsContentElement->delete()) { $this->stdout(" - deleted\n", Console::FG_GREEN); } else { $this->stdout(" - NOT deleted\n", Console::FG_RED); } } }
php
public function actionRemoveContentElements($contentId = null) { $query = CmsContentElement::find(); if ($contentId) { $query->andWhere(['content_id' => $contentId]); } if (!$count = $query->count()) { $this->stdout("Content elements not found!\n", Console::BOLD); return; } $this->stdout("1. Found elements: {$count}!\n", Console::BOLD); foreach ($query->orderBy([ 'content_id' => SORT_ASC, 'id' => SORT_ASC ])->each(10) as $cmsContentElement) { $this->stdout("\t{$cmsContentElement->id}: {$cmsContentElement->name}"); if ($cmsContentElement->delete()) { $this->stdout(" - deleted\n", Console::FG_GREEN); } else { $this->stdout(" - NOT deleted\n", Console::FG_RED); } } }
[ "public", "function", "actionRemoveContentElements", "(", "$", "contentId", "=", "null", ")", "{", "$", "query", "=", "CmsContentElement", "::", "find", "(", ")", ";", "if", "(", "$", "contentId", ")", "{", "$", "query", "->", "andWhere", "(", "[", "'con...
Deleting content items @param null $contentId content id
[ "Deleting", "content", "items" ]
e46cbc9cd370402423eced525caf76031a21f70b
https://github.com/skeeks-cms/cms/blob/e46cbc9cd370402423eced525caf76031a21f70b/src/console/controllers/UtilsController.php#L185-L211
train
skeeks-cms/cms
src/traits/TWidget.php
TWidget.beforeRun
public function beforeRun() { $event = new WidgetEvent(); $this->trigger(Widget::EVENT_BEFORE_RUN, $event); return $event->isValid; }
php
public function beforeRun() { $event = new WidgetEvent(); $this->trigger(Widget::EVENT_BEFORE_RUN, $event); return $event->isValid; }
[ "public", "function", "beforeRun", "(", ")", "{", "$", "event", "=", "new", "WidgetEvent", "(", ")", ";", "$", "this", "->", "trigger", "(", "Widget", "::", "EVENT_BEFORE_RUN", ",", "$", "event", ")", ";", "return", "$", "event", "->", "isValid", ";", ...
This method is invoked right before the widget is executed. The method will trigger the [[EVENT_BEFORE_RUN]] event. The return value of the method will determine whether the widget should continue to run. When overriding this method, make sure you call the parent implementation like the following: ```php public function beforeRun() { if (!parent::beforeRun()) { return false; } // your custom code here return true; // or false to not run the widget } ``` @return bool whether the widget should continue to be executed. @since 2.0.11
[ "This", "method", "is", "invoked", "right", "before", "the", "widget", "is", "executed", "." ]
e46cbc9cd370402423eced525caf76031a21f70b
https://github.com/skeeks-cms/cms/blob/e46cbc9cd370402423eced525caf76031a21f70b/src/traits/TWidget.php#L256-L261
train
skeeks-cms/cms
src/traits/TWidget.php
TWidget.afterRun
public function afterRun($result) { $event = new WidgetEvent(); $event->result = $result; $this->trigger(Widget::EVENT_AFTER_RUN, $event); return $event->result; }
php
public function afterRun($result) { $event = new WidgetEvent(); $event->result = $result; $this->trigger(Widget::EVENT_AFTER_RUN, $event); return $event->result; }
[ "public", "function", "afterRun", "(", "$", "result", ")", "{", "$", "event", "=", "new", "WidgetEvent", "(", ")", ";", "$", "event", "->", "result", "=", "$", "result", ";", "$", "this", "->", "trigger", "(", "Widget", "::", "EVENT_AFTER_RUN", ",", ...
This method is invoked right after a widget is executed. The method will trigger the [[EVENT_AFTER_RUN]] event. The return value of the method will be used as the widget return value. If you override this method, your code should look like the following: ```php public function afterRun($result) { $result = parent::afterRun($result); // your custom code here return $result; } ``` @param mixed $result the widget return result. @return mixed the processed widget result. @since 2.0.11
[ "This", "method", "is", "invoked", "right", "after", "a", "widget", "is", "executed", "." ]
e46cbc9cd370402423eced525caf76031a21f70b
https://github.com/skeeks-cms/cms/blob/e46cbc9cd370402423eced525caf76031a21f70b/src/traits/TWidget.php#L284-L290
train
skeeks-cms/cms
src/relatedProperties/models/RelatedPropertiesModel.php
RelatedPropertiesModel.hasAttribute
public function hasAttribute($name) { if (in_array($name, $this->attributes())) { return true; } $repClass = $this->relatedElementModel->relatedElementPropertyClassName; $rpClass = $this->relatedElementModel->relatedPropertyClassName; //TODO: Подумать, возможно getTableCacheTag нужно делать у какого то другого метода. Например у элементов контент это cmsContent как только изменились данные в таблице cmsContent тогда обновляется кэш. $dependency = new TagDependency([ 'tags' => [ $this->relatedElementModel->getTableCacheTag(), (new $rpClass())->getTableCacheTag(), (new $repClass())->getTableCacheTag(), ], ]); $property = $this->relatedElementModel::getDb()->cache(function ($db) use ($name) { return $this->relatedElementModel->getRelatedProperties()->andWhere(['code' => $name])->one(); }, 3600*24, $dependency); if ($property) { $this->_defineByProperty($property); $pv = $this->relatedElementModel::getDb()->cache(function ($db) use ($property) { return $this->relatedElementModel->getRelatedElementProperties()->where(['property_id' => $property->id])->all(); }, 3600*24, $dependency); //$pv = $this->relatedElementModel->getRelatedElementProperties()->where(['property_id' => $property->id])->all(); $this->_initPropertyValue($property, (array)$pv); } if (in_array($name, $this->attributes())) { return true; } return false; }
php
public function hasAttribute($name) { if (in_array($name, $this->attributes())) { return true; } $repClass = $this->relatedElementModel->relatedElementPropertyClassName; $rpClass = $this->relatedElementModel->relatedPropertyClassName; //TODO: Подумать, возможно getTableCacheTag нужно делать у какого то другого метода. Например у элементов контент это cmsContent как только изменились данные в таблице cmsContent тогда обновляется кэш. $dependency = new TagDependency([ 'tags' => [ $this->relatedElementModel->getTableCacheTag(), (new $rpClass())->getTableCacheTag(), (new $repClass())->getTableCacheTag(), ], ]); $property = $this->relatedElementModel::getDb()->cache(function ($db) use ($name) { return $this->relatedElementModel->getRelatedProperties()->andWhere(['code' => $name])->one(); }, 3600*24, $dependency); if ($property) { $this->_defineByProperty($property); $pv = $this->relatedElementModel::getDb()->cache(function ($db) use ($property) { return $this->relatedElementModel->getRelatedElementProperties()->where(['property_id' => $property->id])->all(); }, 3600*24, $dependency); //$pv = $this->relatedElementModel->getRelatedElementProperties()->where(['property_id' => $property->id])->all(); $this->_initPropertyValue($property, (array)$pv); } if (in_array($name, $this->attributes())) { return true; } return false; }
[ "public", "function", "hasAttribute", "(", "$", "name", ")", "{", "if", "(", "in_array", "(", "$", "name", ",", "$", "this", "->", "attributes", "(", ")", ")", ")", "{", "return", "true", ";", "}", "$", "repClass", "=", "$", "this", "->", "relatedE...
Returns a value indicating whether the model has an attribute with the specified name. @param string $name the name of the attribute @return boolean whether the model has an attribute with the specified name.
[ "Returns", "a", "value", "indicating", "whether", "the", "model", "has", "an", "attribute", "with", "the", "specified", "name", "." ]
e46cbc9cd370402423eced525caf76031a21f70b
https://github.com/skeeks-cms/cms/blob/e46cbc9cd370402423eced525caf76031a21f70b/src/relatedProperties/models/RelatedPropertiesModel.php#L552-L589
train
skeeks-cms/cms
src/relatedProperties/models/RelatedPropertiesModel.php
RelatedPropertiesModel.isAttributeChanged
public function isAttributeChanged($name, $identical = true) { if ($this->hasAttribute($name) && isset($this->_oldAttributes[$name])) { if ($identical) { return $this->getAttribute($name) !== $this->_oldAttributes[$name]; } return $this->getAttribute($name) != $this->_oldAttributes[$name]; } return $this->hasAttribute($name) || isset($this->_oldAttributes[$name]); }
php
public function isAttributeChanged($name, $identical = true) { if ($this->hasAttribute($name) && isset($this->_oldAttributes[$name])) { if ($identical) { return $this->getAttribute($name) !== $this->_oldAttributes[$name]; } return $this->getAttribute($name) != $this->_oldAttributes[$name]; } return $this->hasAttribute($name) || isset($this->_oldAttributes[$name]); }
[ "public", "function", "isAttributeChanged", "(", "$", "name", ",", "$", "identical", "=", "true", ")", "{", "if", "(", "$", "this", "->", "hasAttribute", "(", "$", "name", ")", "&&", "isset", "(", "$", "this", "->", "_oldAttributes", "[", "$", "name", ...
Returns a value indicating whether the named attribute has been changed. @param string $name the name of the attribute. @param bool $identical whether the comparison of new and old value is made for identical values using `===`, defaults to `true`. Otherwise `==` is used for comparison. This parameter is available since version 2.0.4. @return bool whether the attribute has been changed
[ "Returns", "a", "value", "indicating", "whether", "the", "named", "attribute", "has", "been", "changed", "." ]
e46cbc9cd370402423eced525caf76031a21f70b
https://github.com/skeeks-cms/cms/blob/e46cbc9cd370402423eced525caf76031a21f70b/src/relatedProperties/models/RelatedPropertiesModel.php#L695-L706
train
wp-cli/import-command
src/Import_Command.php
Import_Command.import_wxr
private function import_wxr( $file, $args ) { $wp_import = new WP_Import(); $wp_import->processed_posts = $this->processed_posts; $import_data = $wp_import->parse( $file ); if ( is_wp_error( $import_data ) ) { return $import_data; } // Prepare the data to be used in process_author_mapping(); $wp_import->get_authors_from_import( $import_data ); // We no longer need the original data, so unset to avoid using excess // memory. unset( $import_data ); $author_data = array(); foreach ( $wp_import->authors as $wxr_author ) { $author = new \stdClass(); // Always in the WXR $author->user_login = $wxr_author['author_login']; // Should be in the WXR; no guarantees if ( isset( $wxr_author['author_email'] ) ) { $author->user_email = $wxr_author['author_email']; } if ( isset( $wxr_author['author_display_name'] ) ) { $author->display_name = $wxr_author['author_display_name']; } if ( isset( $wxr_author['author_first_name'] ) ) { $author->first_name = $wxr_author['author_first_name']; } if ( isset( $wxr_author['author_last_name'] ) ) { $author->last_name = $wxr_author['author_last_name']; } $author_data[] = $author; } // Build the author mapping $author_mapping = $this->process_author_mapping( $args['authors'], $author_data ); if ( is_wp_error( $author_mapping ) ) { return $author_mapping; } $author_in = wp_list_pluck( $author_mapping, 'old_user_login' ); $author_out = wp_list_pluck( $author_mapping, 'new_user_login' ); unset( $author_mapping, $author_data ); // $user_select needs to be an array of user IDs $user_select = array(); $invalid_user_select = array(); foreach ( $author_out as $author_login ) { $user = get_user_by( 'login', $author_login ); if ( $user ) { $user_select[] = $user->ID; } else { $invalid_user_select[] = $author_login; } } if ( ! empty( $invalid_user_select ) ) { return new WP_Error( 'invalid-author-mapping', sprintf( 'These user_logins are invalid: %s', implode( ',', $invalid_user_select ) ) ); } unset( $author_out ); // Drive the import $wp_import->fetch_attachments = ! in_array( 'attachment', $args['skip'], true ); $_GET = array( 'import' => 'wordpress', 'step' => 2, ); $_POST = array( 'imported_authors' => $author_in, 'user_map' => $user_select, 'fetch_attachments' => $wp_import->fetch_attachments, ); if ( in_array( 'image_resize', $args['skip'], true ) ) { add_filter( 'intermediate_image_sizes_advanced', array( $this, 'filter_set_image_sizes' ) ); } $GLOBALS['wpcli_import_current_file'] = basename( $file ); $wp_import->import( $file ); $this->processed_posts += $wp_import->processed_posts; return true; }
php
private function import_wxr( $file, $args ) { $wp_import = new WP_Import(); $wp_import->processed_posts = $this->processed_posts; $import_data = $wp_import->parse( $file ); if ( is_wp_error( $import_data ) ) { return $import_data; } // Prepare the data to be used in process_author_mapping(); $wp_import->get_authors_from_import( $import_data ); // We no longer need the original data, so unset to avoid using excess // memory. unset( $import_data ); $author_data = array(); foreach ( $wp_import->authors as $wxr_author ) { $author = new \stdClass(); // Always in the WXR $author->user_login = $wxr_author['author_login']; // Should be in the WXR; no guarantees if ( isset( $wxr_author['author_email'] ) ) { $author->user_email = $wxr_author['author_email']; } if ( isset( $wxr_author['author_display_name'] ) ) { $author->display_name = $wxr_author['author_display_name']; } if ( isset( $wxr_author['author_first_name'] ) ) { $author->first_name = $wxr_author['author_first_name']; } if ( isset( $wxr_author['author_last_name'] ) ) { $author->last_name = $wxr_author['author_last_name']; } $author_data[] = $author; } // Build the author mapping $author_mapping = $this->process_author_mapping( $args['authors'], $author_data ); if ( is_wp_error( $author_mapping ) ) { return $author_mapping; } $author_in = wp_list_pluck( $author_mapping, 'old_user_login' ); $author_out = wp_list_pluck( $author_mapping, 'new_user_login' ); unset( $author_mapping, $author_data ); // $user_select needs to be an array of user IDs $user_select = array(); $invalid_user_select = array(); foreach ( $author_out as $author_login ) { $user = get_user_by( 'login', $author_login ); if ( $user ) { $user_select[] = $user->ID; } else { $invalid_user_select[] = $author_login; } } if ( ! empty( $invalid_user_select ) ) { return new WP_Error( 'invalid-author-mapping', sprintf( 'These user_logins are invalid: %s', implode( ',', $invalid_user_select ) ) ); } unset( $author_out ); // Drive the import $wp_import->fetch_attachments = ! in_array( 'attachment', $args['skip'], true ); $_GET = array( 'import' => 'wordpress', 'step' => 2, ); $_POST = array( 'imported_authors' => $author_in, 'user_map' => $user_select, 'fetch_attachments' => $wp_import->fetch_attachments, ); if ( in_array( 'image_resize', $args['skip'], true ) ) { add_filter( 'intermediate_image_sizes_advanced', array( $this, 'filter_set_image_sizes' ) ); } $GLOBALS['wpcli_import_current_file'] = basename( $file ); $wp_import->import( $file ); $this->processed_posts += $wp_import->processed_posts; return true; }
[ "private", "function", "import_wxr", "(", "$", "file", ",", "$", "args", ")", "{", "$", "wp_import", "=", "new", "WP_Import", "(", ")", ";", "$", "wp_import", "->", "processed_posts", "=", "$", "this", "->", "processed_posts", ";", "$", "import_data", "=...
Imports a WXR file.
[ "Imports", "a", "WXR", "file", "." ]
e28a7f55138ceb53f2ff5926874d8e5582c87db8
https://github.com/wp-cli/import-command/blob/e28a7f55138ceb53f2ff5926874d8e5582c87db8/src/Import_Command.php#L95-L183
train
wp-cli/import-command
src/Import_Command.php
Import_Command.is_importer_available
private function is_importer_available() { require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( class_exists( 'WP_Import' ) ) { return true; } $plugins = get_plugins(); $wordpress_importer = 'wordpress-importer/wordpress-importer.php'; if ( array_key_exists( $wordpress_importer, $plugins ) ) { $error_msg = "WordPress Importer needs to be activated. Try 'wp plugin activate wordpress-importer'."; } else { $error_msg = "WordPress Importer needs to be installed. Try 'wp plugin install wordpress-importer --activate'."; } return new WP_Error( 'importer-missing', $error_msg ); }
php
private function is_importer_available() { require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( class_exists( 'WP_Import' ) ) { return true; } $plugins = get_plugins(); $wordpress_importer = 'wordpress-importer/wordpress-importer.php'; if ( array_key_exists( $wordpress_importer, $plugins ) ) { $error_msg = "WordPress Importer needs to be activated. Try 'wp plugin activate wordpress-importer'."; } else { $error_msg = "WordPress Importer needs to be installed. Try 'wp plugin install wordpress-importer --activate'."; } return new WP_Error( 'importer-missing', $error_msg ); }
[ "private", "function", "is_importer_available", "(", ")", "{", "require_once", "ABSPATH", ".", "'wp-admin/includes/plugin.php'", ";", "if", "(", "class_exists", "(", "'WP_Import'", ")", ")", "{", "return", "true", ";", "}", "$", "plugins", "=", "get_plugins", "(...
Determines whether the requested importer is available.
[ "Determines", "whether", "the", "requested", "importer", "is", "available", "." ]
e28a7f55138ceb53f2ff5926874d8e5582c87db8
https://github.com/wp-cli/import-command/blob/e28a7f55138ceb53f2ff5926874d8e5582c87db8/src/Import_Command.php#L297-L313
train
wp-cli/import-command
src/Import_Command.php
Import_Command.process_author_mapping
private function process_author_mapping( $authors_arg, $author_data ) { // Provided an author mapping file (method checks validity) if ( file_exists( $authors_arg ) ) { return $this->read_author_mapping_file( $authors_arg ); } // Provided a file reference, but the file doesn't yet exist if ( false !== stripos( $authors_arg, '.csv' ) ) { return $this->create_author_mapping_file( $authors_arg, $author_data ); } switch ( $authors_arg ) { // Create authors if they don't yet exist; maybe match on email or user_login case 'create': return $this->create_authors_for_mapping( $author_data ); // Skip any sort of author mapping case 'skip': return array(); default: return new WP_Error( 'invalid-argument', "'authors' argument is invalid." ); } }
php
private function process_author_mapping( $authors_arg, $author_data ) { // Provided an author mapping file (method checks validity) if ( file_exists( $authors_arg ) ) { return $this->read_author_mapping_file( $authors_arg ); } // Provided a file reference, but the file doesn't yet exist if ( false !== stripos( $authors_arg, '.csv' ) ) { return $this->create_author_mapping_file( $authors_arg, $author_data ); } switch ( $authors_arg ) { // Create authors if they don't yet exist; maybe match on email or user_login case 'create': return $this->create_authors_for_mapping( $author_data ); // Skip any sort of author mapping case 'skip': return array(); default: return new WP_Error( 'invalid-argument', "'authors' argument is invalid." ); } }
[ "private", "function", "process_author_mapping", "(", "$", "authors_arg", ",", "$", "author_data", ")", "{", "// Provided an author mapping file (method checks validity)", "if", "(", "file_exists", "(", "$", "authors_arg", ")", ")", "{", "return", "$", "this", "->", ...
Processes how the authors should be mapped @param string $authors_arg The `--author` argument originally passed to command @param array $author_data An array of WP_User-esque author objects @return array|WP_Error $author_mapping Author mapping array if successful, WP_Error if something bad happened
[ "Processes", "how", "the", "authors", "should", "be", "mapped" ]
e28a7f55138ceb53f2ff5926874d8e5582c87db8
https://github.com/wp-cli/import-command/blob/e28a7f55138ceb53f2ff5926874d8e5582c87db8/src/Import_Command.php#L322-L346
train
wp-cli/import-command
src/Import_Command.php
Import_Command.read_author_mapping_file
private function read_author_mapping_file( $file ) { $author_mapping = array(); foreach ( new \WP_CLI\Iterators\CSV( $file ) as $i => $author ) { if ( ! array_key_exists( 'old_user_login', $author ) || ! array_key_exists( 'new_user_login', $author ) ) { return new WP_Error( 'invalid-author-mapping', "Author mapping file isn't properly formatted." ); } $author_mapping[] = $author; } return $author_mapping; }
php
private function read_author_mapping_file( $file ) { $author_mapping = array(); foreach ( new \WP_CLI\Iterators\CSV( $file ) as $i => $author ) { if ( ! array_key_exists( 'old_user_login', $author ) || ! array_key_exists( 'new_user_login', $author ) ) { return new WP_Error( 'invalid-author-mapping', "Author mapping file isn't properly formatted." ); } $author_mapping[] = $author; } return $author_mapping; }
[ "private", "function", "read_author_mapping_file", "(", "$", "file", ")", "{", "$", "author_mapping", "=", "array", "(", ")", ";", "foreach", "(", "new", "\\", "WP_CLI", "\\", "Iterators", "\\", "CSV", "(", "$", "file", ")", "as", "$", "i", "=>", "$", ...
Reads an author mapping file.
[ "Reads", "an", "author", "mapping", "file", "." ]
e28a7f55138ceb53f2ff5926874d8e5582c87db8
https://github.com/wp-cli/import-command/blob/e28a7f55138ceb53f2ff5926874d8e5582c87db8/src/Import_Command.php#L351-L363
train
wp-cli/import-command
src/Import_Command.php
Import_Command.create_author_mapping_file
private function create_author_mapping_file( $file, $author_data ) { if ( touch( $file ) ) { $author_mapping = array(); foreach ( $author_data as $author ) { $author_mapping[] = array( 'old_user_login' => $author->user_login, 'new_user_login' => $this->suggest_user( $author->user_login, $author->user_email ), ); } $file_resource = fopen( $file, 'w' ); \WP_CLI\utils\write_csv( $file_resource, $author_mapping, array( 'old_user_login', 'new_user_login' ) ); return new WP_Error( 'author-mapping-error', sprintf( 'Please update author mapping file before continuing: %s', $file ) ); } else { return new WP_Error( 'author-mapping-error', "Couldn't create author mapping file." ); } }
php
private function create_author_mapping_file( $file, $author_data ) { if ( touch( $file ) ) { $author_mapping = array(); foreach ( $author_data as $author ) { $author_mapping[] = array( 'old_user_login' => $author->user_login, 'new_user_login' => $this->suggest_user( $author->user_login, $author->user_email ), ); } $file_resource = fopen( $file, 'w' ); \WP_CLI\utils\write_csv( $file_resource, $author_mapping, array( 'old_user_login', 'new_user_login' ) ); return new WP_Error( 'author-mapping-error', sprintf( 'Please update author mapping file before continuing: %s', $file ) ); } else { return new WP_Error( 'author-mapping-error', "Couldn't create author mapping file." ); } }
[ "private", "function", "create_author_mapping_file", "(", "$", "file", ",", "$", "author_data", ")", "{", "if", "(", "touch", "(", "$", "file", ")", ")", "{", "$", "author_mapping", "=", "array", "(", ")", ";", "foreach", "(", "$", "author_data", "as", ...
Creates an author mapping file, based on provided author data. @return WP_Error The file was just now created, so some action needs to be taken
[ "Creates", "an", "author", "mapping", "file", "based", "on", "provided", "author", "data", "." ]
e28a7f55138ceb53f2ff5926874d8e5582c87db8
https://github.com/wp-cli/import-command/blob/e28a7f55138ceb53f2ff5926874d8e5582c87db8/src/Import_Command.php#L370-L386
train
wp-cli/import-command
src/Import_Command.php
Import_Command.create_authors_for_mapping
private function create_authors_for_mapping( $author_data ) { $author_mapping = array(); foreach ( $author_data as $author ) { if ( isset( $author->user_email ) ) { $user = get_user_by( 'email', $author->user_email ); if ( $user instanceof WP_User ) { $author_mapping[] = array( 'old_user_login' => $author->user_login, 'new_user_login' => $user->user_login, ); continue; } } $user = get_user_by( 'login', $author->user_login ); if ( $user instanceof WP_User ) { $author_mapping[] = array( 'old_user_login' => $author->user_login, 'new_user_login' => $user->user_login, ); continue; } $user = array( 'user_login' => '', 'user_email' => '', 'user_pass' => wp_generate_password(), ); $user = array_merge( $user, (array) $author ); $user_id = wp_insert_user( $user ); if ( is_wp_error( $user_id ) ) { return $user_id; } $user = get_user_by( 'id', $user_id ); $author_mapping[] = array( 'old_user_login' => $author->user_login, 'new_user_login' => $user->user_login, ); } return $author_mapping; }
php
private function create_authors_for_mapping( $author_data ) { $author_mapping = array(); foreach ( $author_data as $author ) { if ( isset( $author->user_email ) ) { $user = get_user_by( 'email', $author->user_email ); if ( $user instanceof WP_User ) { $author_mapping[] = array( 'old_user_login' => $author->user_login, 'new_user_login' => $user->user_login, ); continue; } } $user = get_user_by( 'login', $author->user_login ); if ( $user instanceof WP_User ) { $author_mapping[] = array( 'old_user_login' => $author->user_login, 'new_user_login' => $user->user_login, ); continue; } $user = array( 'user_login' => '', 'user_email' => '', 'user_pass' => wp_generate_password(), ); $user = array_merge( $user, (array) $author ); $user_id = wp_insert_user( $user ); if ( is_wp_error( $user_id ) ) { return $user_id; } $user = get_user_by( 'id', $user_id ); $author_mapping[] = array( 'old_user_login' => $author->user_login, 'new_user_login' => $user->user_login, ); } return $author_mapping; }
[ "private", "function", "create_authors_for_mapping", "(", "$", "author_data", ")", "{", "$", "author_mapping", "=", "array", "(", ")", ";", "foreach", "(", "$", "author_data", "as", "$", "author", ")", "{", "if", "(", "isset", "(", "$", "author", "->", "...
Creates users if they don't exist, and build an author mapping file.
[ "Creates", "users", "if", "they", "don", "t", "exist", "and", "build", "an", "author", "mapping", "file", "." ]
e28a7f55138ceb53f2ff5926874d8e5582c87db8
https://github.com/wp-cli/import-command/blob/e28a7f55138ceb53f2ff5926874d8e5582c87db8/src/Import_Command.php#L391-L436
train
wp-cli/import-command
src/Import_Command.php
Import_Command.suggest_user
private function suggest_user( $author_user_login, $author_user_email = '' ) { if ( ! isset( $this->blog_users ) ) { $this->blog_users = get_users(); } $shortest = -1; $shortestavg = array(); $threshold = floor( ( strlen( $author_user_login ) / 100 ) * 10 ); // 10 % of the strlen are valid $closest = ''; foreach ( $this->blog_users as $user ) { // Before we resort to an algorithm, let's try for an exact match if ( $author_user_email && $user->user_email === $author_user_email ) { return $user->user_login; } $levs = array(); $levs[] = levenshtein( $author_user_login, $user->display_name ); $levs[] = levenshtein( $author_user_login, $user->user_login ); $levs[] = levenshtein( $author_user_login, $user->user_email ); $email_parts = explode( '@', $user->user_email ); $email_login = array_shift( $email_parts ); $levs[] = levenshtein( $author_user_login, $email_login ); rsort( $levs ); $lev = array_pop( $levs ); if ( 0 === $lev ) { $closest = $user->user_login; $shortest = 0; break; } if ( ( $lev <= $shortest || $shortest < 0 ) && $lev <= $threshold ) { $closest = $user->user_login; $shortest = $lev; } $shortestavg[] = $lev; } // in case all usernames have a common pattern if ( $shortest > ( array_sum( $shortestavg ) / count( $shortestavg ) ) ) { return ''; } return $closest; }
php
private function suggest_user( $author_user_login, $author_user_email = '' ) { if ( ! isset( $this->blog_users ) ) { $this->blog_users = get_users(); } $shortest = -1; $shortestavg = array(); $threshold = floor( ( strlen( $author_user_login ) / 100 ) * 10 ); // 10 % of the strlen are valid $closest = ''; foreach ( $this->blog_users as $user ) { // Before we resort to an algorithm, let's try for an exact match if ( $author_user_email && $user->user_email === $author_user_email ) { return $user->user_login; } $levs = array(); $levs[] = levenshtein( $author_user_login, $user->display_name ); $levs[] = levenshtein( $author_user_login, $user->user_login ); $levs[] = levenshtein( $author_user_login, $user->user_email ); $email_parts = explode( '@', $user->user_email ); $email_login = array_shift( $email_parts ); $levs[] = levenshtein( $author_user_login, $email_login ); rsort( $levs ); $lev = array_pop( $levs ); if ( 0 === $lev ) { $closest = $user->user_login; $shortest = 0; break; } if ( ( $lev <= $shortest || $shortest < 0 ) && $lev <= $threshold ) { $closest = $user->user_login; $shortest = $lev; } $shortestavg[] = $lev; } // in case all usernames have a common pattern if ( $shortest > ( array_sum( $shortestavg ) / count( $shortestavg ) ) ) { return ''; } return $closest; }
[ "private", "function", "suggest_user", "(", "$", "author_user_login", ",", "$", "author_user_email", "=", "''", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "blog_users", ")", ")", "{", "$", "this", "->", "blog_users", "=", "get_users", "("...
Suggests a blog user based on the levenshtein distance.
[ "Suggests", "a", "blog", "user", "based", "on", "the", "levenshtein", "distance", "." ]
e28a7f55138ceb53f2ff5926874d8e5582c87db8
https://github.com/wp-cli/import-command/blob/e28a7f55138ceb53f2ff5926874d8e5582c87db8/src/Import_Command.php#L441-L485
train
ptondereau/Laravel-UPS-Api
src/UpsApiServiceProvider.php
UpsApiServiceProvider.registerAddressValidation
protected function registerAddressValidation() { $this->app->singleton('ups.address-validation', function (Container $app) { $config = $app->config->get('ups'); return new AddressValidation( $config['access_key'], $config['user_id'], $config['password'], $config['sandbox'], null, $app->make('log') ); }); }
php
protected function registerAddressValidation() { $this->app->singleton('ups.address-validation', function (Container $app) { $config = $app->config->get('ups'); return new AddressValidation( $config['access_key'], $config['user_id'], $config['password'], $config['sandbox'], null, $app->make('log') ); }); }
[ "protected", "function", "registerAddressValidation", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'ups.address-validation'", ",", "function", "(", "Container", "$", "app", ")", "{", "$", "config", "=", "$", "app", "->", "config", "->", ...
Register the AddressValidation class. @return void
[ "Register", "the", "AddressValidation", "class", "." ]
fb794c49fca498e6421f9bf8b4773c2954229e55
https://github.com/ptondereau/Laravel-UPS-Api/blob/fb794c49fca498e6421f9bf8b4773c2954229e55/src/UpsApiServiceProvider.php#L75-L89
train
ptondereau/Laravel-UPS-Api
src/UpsApiServiceProvider.php
UpsApiServiceProvider.registerSimpleAddressValidation
protected function registerSimpleAddressValidation() { $this->app->singleton('ups.simple-address-validation', function (Container $app) { $config = $app->config->get('ups'); return new SimpleAddressValidation( $config['access_key'], $config['user_id'], $config['password'], $config['sandbox'], null, $app->make('log') ); }); }
php
protected function registerSimpleAddressValidation() { $this->app->singleton('ups.simple-address-validation', function (Container $app) { $config = $app->config->get('ups'); return new SimpleAddressValidation( $config['access_key'], $config['user_id'], $config['password'], $config['sandbox'], null, $app->make('log') ); }); }
[ "protected", "function", "registerSimpleAddressValidation", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'ups.simple-address-validation'", ",", "function", "(", "Container", "$", "app", ")", "{", "$", "config", "=", "$", "app", "->", "conf...
Register the SimpleAddressValidation class. @return void
[ "Register", "the", "SimpleAddressValidation", "class", "." ]
fb794c49fca498e6421f9bf8b4773c2954229e55
https://github.com/ptondereau/Laravel-UPS-Api/blob/fb794c49fca498e6421f9bf8b4773c2954229e55/src/UpsApiServiceProvider.php#L96-L110
train
ptondereau/Laravel-UPS-Api
src/UpsApiServiceProvider.php
UpsApiServiceProvider.registerQuantumView
protected function registerQuantumView() { $this->app->singleton('ups.quantum-view', function (Container $app) { $config = $app->config->get('ups'); return new QuantumView( $config['access_key'], $config['user_id'], $config['password'], $config['sandbox'], null, $app->make('log') ); }); }
php
protected function registerQuantumView() { $this->app->singleton('ups.quantum-view', function (Container $app) { $config = $app->config->get('ups'); return new QuantumView( $config['access_key'], $config['user_id'], $config['password'], $config['sandbox'], null, $app->make('log') ); }); }
[ "protected", "function", "registerQuantumView", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'ups.quantum-view'", ",", "function", "(", "Container", "$", "app", ")", "{", "$", "config", "=", "$", "app", "->", "config", "->", "get", "...
Register the QuantumView class. @return void
[ "Register", "the", "QuantumView", "class", "." ]
fb794c49fca498e6421f9bf8b4773c2954229e55
https://github.com/ptondereau/Laravel-UPS-Api/blob/fb794c49fca498e6421f9bf8b4773c2954229e55/src/UpsApiServiceProvider.php#L117-L131
train
ptondereau/Laravel-UPS-Api
src/UpsApiServiceProvider.php
UpsApiServiceProvider.registerTracking
protected function registerTracking() { $this->app->singleton('ups.tracking', function (Container $app) { $config = $app->config->get('ups'); return new Tracking( $config['access_key'], $config['user_id'], $config['password'], $config['sandbox'], null, $app->make('log') ); }); }
php
protected function registerTracking() { $this->app->singleton('ups.tracking', function (Container $app) { $config = $app->config->get('ups'); return new Tracking( $config['access_key'], $config['user_id'], $config['password'], $config['sandbox'], null, $app->make('log') ); }); }
[ "protected", "function", "registerTracking", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'ups.tracking'", ",", "function", "(", "Container", "$", "app", ")", "{", "$", "config", "=", "$", "app", "->", "config", "->", "get", "(", "...
Register the Tracking class. @return void
[ "Register", "the", "Tracking", "class", "." ]
fb794c49fca498e6421f9bf8b4773c2954229e55
https://github.com/ptondereau/Laravel-UPS-Api/blob/fb794c49fca498e6421f9bf8b4773c2954229e55/src/UpsApiServiceProvider.php#L138-L152
train
ptondereau/Laravel-UPS-Api
src/UpsApiServiceProvider.php
UpsApiServiceProvider.registerRate
protected function registerRate() { $this->app->singleton('ups.rate', function (Container $app) { $config = $app->config->get('ups'); return new Rate( $config['access_key'], $config['user_id'], $config['password'], $config['sandbox'], null, $app->make('log') ); }); }
php
protected function registerRate() { $this->app->singleton('ups.rate', function (Container $app) { $config = $app->config->get('ups'); return new Rate( $config['access_key'], $config['user_id'], $config['password'], $config['sandbox'], null, $app->make('log') ); }); }
[ "protected", "function", "registerRate", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'ups.rate'", ",", "function", "(", "Container", "$", "app", ")", "{", "$", "config", "=", "$", "app", "->", "config", "->", "get", "(", "'ups'", ...
Register the Rate class. @return void
[ "Register", "the", "Rate", "class", "." ]
fb794c49fca498e6421f9bf8b4773c2954229e55
https://github.com/ptondereau/Laravel-UPS-Api/blob/fb794c49fca498e6421f9bf8b4773c2954229e55/src/UpsApiServiceProvider.php#L159-L173
train
ptondereau/Laravel-UPS-Api
src/UpsApiServiceProvider.php
UpsApiServiceProvider.registerTimeInTransit
protected function registerTimeInTransit() { $this->app->singleton('ups.time-in-transit', function (Container $app) { $config = $app->config->get('ups'); return new TimeInTransit( $config['access_key'], $config['user_id'], $config['password'], $config['sandbox'], null, $app->make('log') ); }); }
php
protected function registerTimeInTransit() { $this->app->singleton('ups.time-in-transit', function (Container $app) { $config = $app->config->get('ups'); return new TimeInTransit( $config['access_key'], $config['user_id'], $config['password'], $config['sandbox'], null, $app->make('log') ); }); }
[ "protected", "function", "registerTimeInTransit", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'ups.time-in-transit'", ",", "function", "(", "Container", "$", "app", ")", "{", "$", "config", "=", "$", "app", "->", "config", "->", "get"...
Register the TimeInTransit class. @return void
[ "Register", "the", "TimeInTransit", "class", "." ]
fb794c49fca498e6421f9bf8b4773c2954229e55
https://github.com/ptondereau/Laravel-UPS-Api/blob/fb794c49fca498e6421f9bf8b4773c2954229e55/src/UpsApiServiceProvider.php#L180-L194
train
ptondereau/Laravel-UPS-Api
src/UpsApiServiceProvider.php
UpsApiServiceProvider.registerLocator
protected function registerLocator() { $this->app->singleton('ups.locator', function (Container $app) { $config = $app->config->get('ups'); return new Locator( $config['access_key'], $config['user_id'], $config['password'], $config['sandbox'], null, $app->make('log') ); }); }
php
protected function registerLocator() { $this->app->singleton('ups.locator', function (Container $app) { $config = $app->config->get('ups'); return new Locator( $config['access_key'], $config['user_id'], $config['password'], $config['sandbox'], null, $app->make('log') ); }); }
[ "protected", "function", "registerLocator", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'ups.locator'", ",", "function", "(", "Container", "$", "app", ")", "{", "$", "config", "=", "$", "app", "->", "config", "->", "get", "(", "'u...
Register the Locator class. @return void
[ "Register", "the", "Locator", "class", "." ]
fb794c49fca498e6421f9bf8b4773c2954229e55
https://github.com/ptondereau/Laravel-UPS-Api/blob/fb794c49fca498e6421f9bf8b4773c2954229e55/src/UpsApiServiceProvider.php#L201-L215
train
greenfieldtech-nirs/phpari
src/interfaces/endpoints.php
endpoints.endpoint_sendmessage
public function endpoint_sendmessage($to = NULL, $from = NULL, $body = NULL) { return $this->sendmessage($to, $from, $body); }
php
public function endpoint_sendmessage($to = NULL, $from = NULL, $body = NULL) { return $this->sendmessage($to, $from, $body); }
[ "public", "function", "endpoint_sendmessage", "(", "$", "to", "=", "NULL", ",", "$", "from", "=", "NULL", ",", "$", "body", "=", "NULL", ")", "{", "return", "$", "this", "->", "sendmessage", "(", "$", "to", ",", "$", "from", ",", "$", "body", ")", ...
This function is an alias to 'sendmessage' - will be deprecated in phpari 2.0 @return mixed
[ "This", "function", "is", "an", "alias", "to", "sendmessage", "-", "will", "be", "deprecated", "in", "phpari", "2", ".", "0" ]
b53169dbd8548dfd3514dfe5942c7139db3a5a85
https://github.com/greenfieldtech-nirs/phpari/blob/b53169dbd8548dfd3514dfe5942c7139db3a5a85/src/interfaces/endpoints.php#L184-L187
train
greenfieldtech-nirs/phpari
src/interfaces/applications.php
applications.unsubscribe
public function unsubscribe($applicationName = NULL, $eventSources = NULL) { try { if (is_null($applicationName)) throw new Exception("Application name not provided or is null", 503); if (is_null($eventSources)) throw new Exception("eventSources not provided or is null", 503); $this->validate_event_sources($eventSources); $postObjParams = array( 'eventSource' => $eventSources ); $uri = "/applications/" . $applicationName . "/subscription"; $this->ariEndpointOptions['json'] = $postObjParams; $result = json_decode($this->ariEndpointClient->delete($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); return $result; } catch (\GuzzleHttp\Exception\RequestException $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return (int)$e->getCode(); } catch (\GuzzleHttp\Exception\ClientException $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return (int)$e->getCode(); } catch (\GuzzleHttp\Exception\ServerException $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return (int)$e->getCode(); } catch (Exception $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } }
php
public function unsubscribe($applicationName = NULL, $eventSources = NULL) { try { if (is_null($applicationName)) throw new Exception("Application name not provided or is null", 503); if (is_null($eventSources)) throw new Exception("eventSources not provided or is null", 503); $this->validate_event_sources($eventSources); $postObjParams = array( 'eventSource' => $eventSources ); $uri = "/applications/" . $applicationName . "/subscription"; $this->ariEndpointOptions['json'] = $postObjParams; $result = json_decode($this->ariEndpointClient->delete($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); return $result; } catch (\GuzzleHttp\Exception\RequestException $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return (int)$e->getCode(); } catch (\GuzzleHttp\Exception\ClientException $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return (int)$e->getCode(); } catch (\GuzzleHttp\Exception\ServerException $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return (int)$e->getCode(); } catch (Exception $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } }
[ "public", "function", "unsubscribe", "(", "$", "applicationName", "=", "NULL", ",", "$", "eventSources", "=", "NULL", ")", "{", "try", "{", "if", "(", "is_null", "(", "$", "applicationName", ")", ")", "throw", "new", "Exception", "(", "\"Application name not...
DELETE Unsubscribe an application from an event source. Returns the state of the application after the subscriptions have changed @param string $applicationName @param string $eventSources @return mixed
[ "DELETE", "Unsubscribe", "an", "application", "from", "an", "event", "source", ".", "Returns", "the", "state", "of", "the", "application", "after", "the", "subscriptions", "have", "changed" ]
b53169dbd8548dfd3514dfe5942c7139db3a5a85
https://github.com/greenfieldtech-nirs/phpari/blob/b53169dbd8548dfd3514dfe5942c7139db3a5a85/src/interfaces/applications.php#L218-L261
train
greenfieldtech-nirs/phpari
src/interfaces/channels.php
channels.show
public function show() { try { $result = FALSE; if (is_null($this->pestObject)) throw new Exception("PEST Object not provided or is null", 503); $uri = "/channels"; $result = $this->pestObject->get($uri); return $result; } catch (Pest_NotFound $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } catch (Pest_BadRequest $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } catch (Exception $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } }
php
public function show() { try { $result = FALSE; if (is_null($this->pestObject)) throw new Exception("PEST Object not provided or is null", 503); $uri = "/channels"; $result = $this->pestObject->get($uri); return $result; } catch (Pest_NotFound $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } catch (Pest_BadRequest $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } catch (Exception $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } }
[ "public", "function", "show", "(", ")", "{", "try", "{", "$", "result", "=", "FALSE", ";", "if", "(", "is_null", "(", "$", "this", "->", "pestObject", ")", ")", "throw", "new", "Exception", "(", "\"PEST Object not provided or is null\"", ",", "503", ")", ...
Get the current list of active channels @return object|bool - false for a failure, JSON object for all other results
[ "Get", "the", "current", "list", "of", "active", "channels" ]
b53169dbd8548dfd3514dfe5942c7139db3a5a85
https://github.com/greenfieldtech-nirs/phpari/blob/b53169dbd8548dfd3514dfe5942c7139db3a5a85/src/interfaces/channels.php#L52-L83
train
greenfieldtech-nirs/phpari
src/interfaces/channels.php
channels.originate
public function originate($endpoint = NULL, $channel_id = NULL, $data = NULL, $variables = NULL) { try { $inputParser = new parsing_helper(); if (is_null($endpoint)) throw new Exception("End point not provided or is null", 503); $originateData = array(); $originateData['endpoint'] = $endpoint; if (!is_null($data)) $originateData = array_merge($originateData, $inputParser->parseRequestData($data)); if (!is_null($variables)) $originateData['variables'] = $inputParser->parseRequestData($variables); $uri = (is_null($channel_id)) ? "/channels" : "/channels/" . $channel_id; $result = $this->pestObject->post($uri, $originateData); return $result; } catch (Pest_NotFound $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } catch (Pest_BadRequest $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } catch (Exception $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } }
php
public function originate($endpoint = NULL, $channel_id = NULL, $data = NULL, $variables = NULL) { try { $inputParser = new parsing_helper(); if (is_null($endpoint)) throw new Exception("End point not provided or is null", 503); $originateData = array(); $originateData['endpoint'] = $endpoint; if (!is_null($data)) $originateData = array_merge($originateData, $inputParser->parseRequestData($data)); if (!is_null($variables)) $originateData['variables'] = $inputParser->parseRequestData($variables); $uri = (is_null($channel_id)) ? "/channels" : "/channels/" . $channel_id; $result = $this->pestObject->post($uri, $originateData); return $result; } catch (Pest_NotFound $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } catch (Pest_BadRequest $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } catch (Exception $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } }
[ "public", "function", "originate", "(", "$", "endpoint", "=", "NULL", ",", "$", "channel_id", "=", "NULL", ",", "$", "data", "=", "NULL", ",", "$", "variables", "=", "NULL", ")", "{", "try", "{", "$", "inputParser", "=", "new", "parsing_helper", "(", ...
Originate a call on a channel @param null (string) $endpoint - endpoint to originate the call to, eg: SIP/alice @param null (string) $channel_id - Assign a channel ID for the newly created channel @param null (JSON_STRING|JSON_OBJECT|ASSOC_ARRAY) $data - originate data @param null (JSON_STRING|JSON_OBJECT|ASSOC_ARRAY) $variables - originate assigned variables @return bool - false on success, Integer or True on failure $data structure: { "extension": (String) "The extension to dial after the endpoint answers", "context": (String) "The context to dial after the endpoint answers. If omitted, uses 'default'", "priority": (Long) "he priority to dial after the endpoint answers. If omitted, uses 1", "app": (String) "The application that is subscribed to the originated channel, and passed to the Stasis application", "appArgs": (String) "The application arguments to pass to the Stasis application", "callerId": (String) "CallerID to use when dialing the endpoint or extension", "timeout": (Integer) "Timeout (in seconds) before giving up dialing, or -1 for no timeout", "channelId": (String) "The unique id to assign the channel on creation", "otherChannelId": (String) "The unique id to assign the second channel when using local channels" } $variables structure: { "variable_name": "value", } eg. { "CALLERID(name): "Mark Spencer" }
[ "Originate", "a", "call", "on", "a", "channel" ]
b53169dbd8548dfd3514dfe5942c7139db3a5a85
https://github.com/greenfieldtech-nirs/phpari/blob/b53169dbd8548dfd3514dfe5942c7139db3a5a85/src/interfaces/channels.php#L131-L173
train
greenfieldtech-nirs/phpari
src/interfaces/channels.php
channels.hold
public function hold($channel_id = NULL, $action = "start") { try { // $result = false; if (is_null($channel_id)) throw new Exception("Channel ID not provided or is null", 503); switch ($action) { case "stop": $result = $this->pestObject->delete("/channels/" . $channel_id . "/hold"); break; case "start": default: $result = $this->pestObject->post("/channels/" . $channel_id . "/hold", array()); break; } return $result; } catch (Pest_NotFound $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } catch (Pest_BadRequest $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } catch (Exception $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } }
php
public function hold($channel_id = NULL, $action = "start") { try { // $result = false; if (is_null($channel_id)) throw new Exception("Channel ID not provided or is null", 503); switch ($action) { case "stop": $result = $this->pestObject->delete("/channels/" . $channel_id . "/hold"); break; case "start": default: $result = $this->pestObject->post("/channels/" . $channel_id . "/hold", array()); break; } return $result; } catch (Pest_NotFound $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } catch (Pest_BadRequest $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } catch (Exception $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } }
[ "public", "function", "hold", "(", "$", "channel_id", "=", "NULL", ",", "$", "action", "=", "\"start\"", ")", "{", "try", "{", "// $result = false;", "if", "(", "is_null", "(", "$", "channel_id", ")", ")", "throw", "new", "Exception", "(", "\"Channel ID no...
Hold a channel @param null $channel_id @return bool
[ "Hold", "a", "channel" ]
b53169dbd8548dfd3514dfe5942c7139db3a5a85
https://github.com/greenfieldtech-nirs/phpari/blob/b53169dbd8548dfd3514dfe5942c7139db3a5a85/src/interfaces/channels.php#L616-L653
train
greenfieldtech-nirs/phpari
src/interfaces/mailboxes.php
mailboxes.mailbox_change_state
public function mailbox_change_state($mailBoxName = NULL, $oldMessages = NULL, $newMessages = NULL) { return $this->state($mailBoxName, $oldMessages, $newMessages); }
php
public function mailbox_change_state($mailBoxName = NULL, $oldMessages = NULL, $newMessages = NULL) { return $this->state($mailBoxName, $oldMessages, $newMessages); }
[ "public", "function", "mailbox_change_state", "(", "$", "mailBoxName", "=", "NULL", ",", "$", "oldMessages", "=", "NULL", ",", "$", "newMessages", "=", "NULL", ")", "{", "return", "$", "this", "->", "state", "(", "$", "mailBoxName", ",", "$", "oldMessages"...
This function is an alias to 'state' - will be deprecated in phpari 2.0 @return mixed
[ "This", "function", "is", "an", "alias", "to", "state", "-", "will", "be", "deprecated", "in", "phpari", "2", ".", "0" ]
b53169dbd8548dfd3514dfe5942c7139db3a5a85
https://github.com/greenfieldtech-nirs/phpari/blob/b53169dbd8548dfd3514dfe5942c7139db3a5a85/src/interfaces/mailboxes.php#L141-L144
train
greenfieldtech-nirs/phpari
src/interfaces/recordings.php
recordings.live
public function live($action = NULL, $recordingName = NULL) { try { $uri = "/recordings/live"; if (is_null($action)) throw new Exception("action not specified or is null", 503); switch ($action) { case "show": $uri .= (!is_null($recordingName)) ? "/" . $recordingName : ""; $result = $this->pestObject->get($uri); break; default: if (is_null($recordingName)) throw new Exception("recording name not specified or is null", 503); $uri = "/recordings/live/" . $recordingName; $postData = array(); switch ($action) { case "start": throw new Exception("Starting a recording is done via channels interface - have you forgotten?", 503); break; case "stop": $uri .= "/stop"; $result = $this->pestObject->post($uri, $postData); break; case "discard": $result = $this->pestObject->delete($uri); break; case "pause": $uri .= "/pause"; $result = $this->pestObject->post($uri, $postData); break; case "unpause": $uri .= "/pause"; $result = $this->pestObject->delete($uri); break; case "mute": $uri .= "/mute"; $result = $this->pestObject->post($uri, $postData); break; case "unmute": $uri .= "/mute"; $result = $this->pestObject->delete($uri); break; default: throw new Exception("unknown action specified", 503); break; } break; } return $result; } catch (Exception $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } }
php
public function live($action = NULL, $recordingName = NULL) { try { $uri = "/recordings/live"; if (is_null($action)) throw new Exception("action not specified or is null", 503); switch ($action) { case "show": $uri .= (!is_null($recordingName)) ? "/" . $recordingName : ""; $result = $this->pestObject->get($uri); break; default: if (is_null($recordingName)) throw new Exception("recording name not specified or is null", 503); $uri = "/recordings/live/" . $recordingName; $postData = array(); switch ($action) { case "start": throw new Exception("Starting a recording is done via channels interface - have you forgotten?", 503); break; case "stop": $uri .= "/stop"; $result = $this->pestObject->post($uri, $postData); break; case "discard": $result = $this->pestObject->delete($uri); break; case "pause": $uri .= "/pause"; $result = $this->pestObject->post($uri, $postData); break; case "unpause": $uri .= "/pause"; $result = $this->pestObject->delete($uri); break; case "mute": $uri .= "/mute"; $result = $this->pestObject->post($uri, $postData); break; case "unmute": $uri .= "/mute"; $result = $this->pestObject->delete($uri); break; default: throw new Exception("unknown action specified", 503); break; } break; } return $result; } catch (Exception $e) { $this->phpariObject->lasterror = $e->getMessage(); $this->phpariObject->lasttrace = $e->getTraceAsString(); return FALSE; } }
[ "public", "function", "live", "(", "$", "action", "=", "NULL", ",", "$", "recordingName", "=", "NULL", ")", "{", "try", "{", "$", "uri", "=", "\"/recordings/live\"", ";", "if", "(", "is_null", "(", "$", "action", ")", ")", "throw", "new", "Exception", ...
Perform actions on live recordings. Start, Stop, Pause, Unpause, Mute, Unmute @param null $action @param null $recordingName @return mixed
[ "Perform", "actions", "on", "live", "recordings", ".", "Start", "Stop", "Pause", "Unpause", "Mute", "Unmute" ]
b53169dbd8548dfd3514dfe5942c7139db3a5a85
https://github.com/greenfieldtech-nirs/phpari/blob/b53169dbd8548dfd3514dfe5942c7139db3a5a85/src/interfaces/recordings.php#L154-L217
train
greenfieldtech-nirs/phpari
src/interfaces/bridges.php
bridges.bridge_addchannel
public function bridge_addchannel($bridgeId = NULL, $channel = NULL, $role = NULL) { return $this->addChannel($bridgeId, $channel, $role); }
php
public function bridge_addchannel($bridgeId = NULL, $channel = NULL, $role = NULL) { return $this->addChannel($bridgeId, $channel, $role); }
[ "public", "function", "bridge_addchannel", "(", "$", "bridgeId", "=", "NULL", ",", "$", "channel", "=", "NULL", ",", "$", "role", "=", "NULL", ")", "{", "return", "$", "this", "->", "addChannel", "(", "$", "bridgeId", ",", "$", "channel", ",", "$", "...
This function is an alias to 'addChannel' - will be deprecated in phpari 2.0 @return mixed
[ "This", "function", "is", "an", "alias", "to", "addChannel", "-", "will", "be", "deprecated", "in", "phpari", "2", ".", "0" ]
b53169dbd8548dfd3514dfe5942c7139db3a5a85
https://github.com/greenfieldtech-nirs/phpari/blob/b53169dbd8548dfd3514dfe5942c7139db3a5a85/src/interfaces/bridges.php#L269-L272
train
greenfieldtech-nirs/phpari
src/interfaces/bridges.php
bridges.bridge_start_playback
public function bridge_start_playback($bridgeId = NULL, $media = NULL, $lang = NULL, $offsetms = NULL, $skipms = NULL, $playbackId = NULL) { return $this->playback_start($bridgeId, $media, $lang, $offsetms, $skipms, $playbackId); }
php
public function bridge_start_playback($bridgeId = NULL, $media = NULL, $lang = NULL, $offsetms = NULL, $skipms = NULL, $playbackId = NULL) { return $this->playback_start($bridgeId, $media, $lang, $offsetms, $skipms, $playbackId); }
[ "public", "function", "bridge_start_playback", "(", "$", "bridgeId", "=", "NULL", ",", "$", "media", "=", "NULL", ",", "$", "lang", "=", "NULL", ",", "$", "offsetms", "=", "NULL", ",", "$", "skipms", "=", "NULL", ",", "$", "playbackId", "=", "NULL", ...
This function is an alias to 'playback_start' - will be deprecated in phpari 2.0 @return mixed
[ "This", "function", "is", "an", "alias", "to", "playback_start", "-", "will", "be", "deprecated", "in", "phpari", "2", ".", "0" ]
b53169dbd8548dfd3514dfe5942c7139db3a5a85
https://github.com/greenfieldtech-nirs/phpari/blob/b53169dbd8548dfd3514dfe5942c7139db3a5a85/src/interfaces/bridges.php#L473-L476
train
greenfieldtech-nirs/phpari
src/interfaces/bridges.php
bridges.bridge_start_recording
public function bridge_start_recording( $bridgeId = NULL, $name = NULL, $format = NULL, $maxDurationSeconds = 0, $maxSilenceSeconds = 0, $ifExists = "fail", $beep = FALSE, $terminateOn = "none" ) { return $this->record($bridgeId, $name, $format, $maxDurationSeconds, $maxSilenceSeconds, $ifExists, $beep, $terminateOn); }
php
public function bridge_start_recording( $bridgeId = NULL, $name = NULL, $format = NULL, $maxDurationSeconds = 0, $maxSilenceSeconds = 0, $ifExists = "fail", $beep = FALSE, $terminateOn = "none" ) { return $this->record($bridgeId, $name, $format, $maxDurationSeconds, $maxSilenceSeconds, $ifExists, $beep, $terminateOn); }
[ "public", "function", "bridge_start_recording", "(", "$", "bridgeId", "=", "NULL", ",", "$", "name", "=", "NULL", ",", "$", "format", "=", "NULL", ",", "$", "maxDurationSeconds", "=", "0", ",", "$", "maxSilenceSeconds", "=", "0", ",", "$", "ifExists", "=...
This function is an alias to 'record' - will be deprecated in phpari 2.0 @return mixed
[ "This", "function", "is", "an", "alias", "to", "record", "-", "will", "be", "deprecated", "in", "phpari", "2", ".", "0" ]
b53169dbd8548dfd3514dfe5942c7139db3a5a85
https://github.com/greenfieldtech-nirs/phpari/blob/b53169dbd8548dfd3514dfe5942c7139db3a5a85/src/interfaces/bridges.php#L555-L568
train
aimeos/ai-client-html
client/html/src/Client/Html/Catalog/Lists/Items/Standard.php
Standard.getProductIds
protected function getProductIds( array $productItems ) { $prodIds = []; foreach( $productItems as $product ) { if( $product->getType() === 'select' ) { $prodIds = array_merge( $prodIds, array_keys( $product->getRefItems( 'product', 'default', 'default' ) ) ); } } return $prodIds; }
php
protected function getProductIds( array $productItems ) { $prodIds = []; foreach( $productItems as $product ) { if( $product->getType() === 'select' ) { $prodIds = array_merge( $prodIds, array_keys( $product->getRefItems( 'product', 'default', 'default' ) ) ); } } return $prodIds; }
[ "protected", "function", "getProductIds", "(", "array", "$", "productItems", ")", "{", "$", "prodIds", "=", "[", "]", ";", "foreach", "(", "$", "productItems", "as", "$", "product", ")", "{", "if", "(", "$", "product", "->", "getType", "(", ")", "===",...
Returns the product IDs of the selection products @param \Aimeos\MShop\Product\Item\Iface[] $productItems List of product items @return string[] List of product IDs
[ "Returns", "the", "product", "IDs", "of", "the", "selection", "products" ]
06738c091041e959f7ddc4674acdb1f1b18474c3
https://github.com/aimeos/ai-client-html/blob/06738c091041e959f7ddc4674acdb1f1b18474c3/client/html/src/Client/Html/Catalog/Lists/Items/Standard.php#L368-L380
train
aimeos/ai-client-html
client/html/src/Client/Html/Base.php
Base.getView
public function getView() { if( !isset( $this->view ) ) { throw new \Aimeos\Client\Html\Exception( sprintf( 'No view available' ) ); } return $this->view; }
php
public function getView() { if( !isset( $this->view ) ) { throw new \Aimeos\Client\Html\Exception( sprintf( 'No view available' ) ); } return $this->view; }
[ "public", "function", "getView", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "view", ")", ")", "{", "throw", "new", "\\", "Aimeos", "\\", "Client", "\\", "Html", "\\", "Exception", "(", "sprintf", "(", "'No view available'", ")", ...
Returns the view object that will generate the HTML output. @return \Aimeos\MW\View\Iface $view The view object which generates the HTML output
[ "Returns", "the", "view", "object", "that", "will", "generate", "the", "HTML", "output", "." ]
06738c091041e959f7ddc4674acdb1f1b18474c3
https://github.com/aimeos/ai-client-html/blob/06738c091041e959f7ddc4674acdb1f1b18474c3/client/html/src/Client/Html/Base.php#L112-L119
train
aimeos/ai-client-html
client/html/src/Client/Html/Base.php
Base.addMetaItemRef
private function addMetaItemRef( \Aimeos\MShop\Common\Item\ListRef\Iface $item, array &$expires, array &$tags, $tagAll ) { foreach( $item->getListItems() as $listitem ) { if( ( $refItem = $listitem->getRefItem() ) === null ) { continue; } if( $tagAll === true ) { $tags[] = str_replace( '/', '_', $listitem->getDomain() ) . '-' . $listitem->getRefId(); } if( ( $date = $listitem->getDateEnd() ) !== null ) { $expires[] = $date; } $this->addMetaItemSingle( $refItem, $expires, $tags, $tagAll ); } }
php
private function addMetaItemRef( \Aimeos\MShop\Common\Item\ListRef\Iface $item, array &$expires, array &$tags, $tagAll ) { foreach( $item->getListItems() as $listitem ) { if( ( $refItem = $listitem->getRefItem() ) === null ) { continue; } if( $tagAll === true ) { $tags[] = str_replace( '/', '_', $listitem->getDomain() ) . '-' . $listitem->getRefId(); } if( ( $date = $listitem->getDateEnd() ) !== null ) { $expires[] = $date; } $this->addMetaItemSingle( $refItem, $expires, $tags, $tagAll ); } }
[ "private", "function", "addMetaItemRef", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Common", "\\", "Item", "\\", "ListRef", "\\", "Iface", "$", "item", ",", "array", "&", "$", "expires", ",", "array", "&", "$", "tags", ",", "$", "tagAll", ")", "{", "...
Adds expire date and tags for referenced items @param \Aimeos\MShop\Common\Item\ListRef\Iface $item Item with associated list items @param array &$expires Will contain the list of expiration dates @param array &$tags List of tags the new tags will be added to @param boolean $tagAll True of tags for all items should be added, false if only for the main item
[ "Adds", "expire", "date", "and", "tags", "for", "referenced", "items" ]
06738c091041e959f7ddc4674acdb1f1b18474c3
https://github.com/aimeos/ai-client-html/blob/06738c091041e959f7ddc4674acdb1f1b18474c3/client/html/src/Client/Html/Base.php#L393-L411
train
aimeos/ai-client-html
client/html/src/Client/Html/Base.php
Base.getTemplatePath
protected function getTemplatePath( $confkey, $default ) { if( ( $type = $this->view->param( 'l_type' ) ) !== null && ctype_alnum( $type ) !== false ) { return $this->view->config( $confkey . '-' . $type, $this->view->config( $confkey, $default ) ); } return $this->view->config( $confkey, $default ); }
php
protected function getTemplatePath( $confkey, $default ) { if( ( $type = $this->view->param( 'l_type' ) ) !== null && ctype_alnum( $type ) !== false ) { return $this->view->config( $confkey . '-' . $type, $this->view->config( $confkey, $default ) ); } return $this->view->config( $confkey, $default ); }
[ "protected", "function", "getTemplatePath", "(", "$", "confkey", ",", "$", "default", ")", "{", "if", "(", "(", "$", "type", "=", "$", "this", "->", "view", "->", "param", "(", "'l_type'", ")", ")", "!==", "null", "&&", "ctype_alnum", "(", "$", "type...
Returns the template for the given configuration key If the "l_type" parameter is present, a specific template for this given type is used if available. @param string $confkey Key to the configuration setting for the template @param string $default Default template if none is configured or not found @return string Relative template path
[ "Returns", "the", "template", "for", "the", "given", "configuration", "key" ]
06738c091041e959f7ddc4674acdb1f1b18474c3
https://github.com/aimeos/ai-client-html/blob/06738c091041e959f7ddc4674acdb1f1b18474c3/client/html/src/Client/Html/Base.php#L553-L560
train
aimeos/ai-client-html
client/html/src/Client/Html/Base.php
Base.logException
protected function logException( \Exception $e ) { $logger = $this->context->getLogger(); $logger->log( $e->getMessage(), \Aimeos\MW\Logger\Base::WARN, 'client/html' ); $logger->log( $e->getTraceAsString(), \Aimeos\MW\Logger\Base::WARN, 'client/html' ); }
php
protected function logException( \Exception $e ) { $logger = $this->context->getLogger(); $logger->log( $e->getMessage(), \Aimeos\MW\Logger\Base::WARN, 'client/html' ); $logger->log( $e->getTraceAsString(), \Aimeos\MW\Logger\Base::WARN, 'client/html' ); }
[ "protected", "function", "logException", "(", "\\", "Exception", "$", "e", ")", "{", "$", "logger", "=", "$", "this", "->", "context", "->", "getLogger", "(", ")", ";", "$", "logger", "->", "log", "(", "$", "e", "->", "getMessage", "(", ")", ",", "...
Writes the exception details to the log @param \Exception $e Exception object
[ "Writes", "the", "exception", "details", "to", "the", "log" ]
06738c091041e959f7ddc4674acdb1f1b18474c3
https://github.com/aimeos/ai-client-html/blob/06738c091041e959f7ddc4674acdb1f1b18474c3/client/html/src/Client/Html/Base.php#L660-L666
train
aimeos/ai-client-html
client/html/src/Client/Html/Account/Download/Standard.php
Standard.addDownload
protected function addDownload( \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface $item ) { $fs = $this->getContext()->getFilesystemManager()->get( 'fs-secure' ); $response = $this->getView()->response(); $value = (string) $item->getValue(); if( $fs->has( $value ) ) { $name = $item->getName(); if( pathinfo( $name, PATHINFO_EXTENSION ) == null && ( $ext = pathinfo( $value, PATHINFO_EXTENSION ) ) != null ) { $name .= '.' . $ext; } $response->withHeader( 'Content-Description', 'File Transfer' ); $response->withHeader( 'Content-Type', 'application/octet-stream' ); $response->withHeader( 'Content-Disposition', 'attachment; filename="' . $name . '"' ); $response->withHeader( 'Content-Length', (string) $fs->size( $value ) ); $response->withHeader( 'Cache-Control', 'must-revalidate' ); $response->withHeader( 'Pragma', 'private' ); $response->withHeader( 'Expires', '0' ); $response->withBody( $response->createStream( $fs->reads( $value ) ) ); } elseif( filter_var( $value, FILTER_VALIDATE_URL ) !== false ) { $response->withHeader( 'Location', $value ); $response->withStatus( 303 ); } else { $response->withStatus( 404 ); } }
php
protected function addDownload( \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface $item ) { $fs = $this->getContext()->getFilesystemManager()->get( 'fs-secure' ); $response = $this->getView()->response(); $value = (string) $item->getValue(); if( $fs->has( $value ) ) { $name = $item->getName(); if( pathinfo( $name, PATHINFO_EXTENSION ) == null && ( $ext = pathinfo( $value, PATHINFO_EXTENSION ) ) != null ) { $name .= '.' . $ext; } $response->withHeader( 'Content-Description', 'File Transfer' ); $response->withHeader( 'Content-Type', 'application/octet-stream' ); $response->withHeader( 'Content-Disposition', 'attachment; filename="' . $name . '"' ); $response->withHeader( 'Content-Length', (string) $fs->size( $value ) ); $response->withHeader( 'Cache-Control', 'must-revalidate' ); $response->withHeader( 'Pragma', 'private' ); $response->withHeader( 'Expires', '0' ); $response->withBody( $response->createStream( $fs->reads( $value ) ) ); } elseif( filter_var( $value, FILTER_VALIDATE_URL ) !== false ) { $response->withHeader( 'Location', $value ); $response->withStatus( 303 ); } else { $response->withStatus( 404 ); } }
[ "protected", "function", "addDownload", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Order", "\\", "Item", "\\", "Base", "\\", "Product", "\\", "Attribute", "\\", "Iface", "$", "item", ")", "{", "$", "fs", "=", "$", "this", "->", "getContext", "(", ")", ...
Adds the necessary headers and the download content to the reponse object @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface $item Order product attribute item with file reference
[ "Adds", "the", "necessary", "headers", "and", "the", "download", "content", "to", "the", "reponse", "object" ]
06738c091041e959f7ddc4674acdb1f1b18474c3
https://github.com/aimeos/ai-client-html/blob/06738c091041e959f7ddc4674acdb1f1b18474c3/client/html/src/Client/Html/Account/Download/Standard.php#L236-L271
train
aimeos/ai-client-html
client/html/src/Client/Html/Account/Download/Standard.php
Standard.checkAccess
protected function checkAccess( $id ) { $context = $this->getContext(); if( ( $customerId = $context->getUserId() ) !== null && $id !== null ) { $manager = \Aimeos\MShop::create( $context, 'order/base' ); $search = $manager->createSearch(); $expr = array( $search->compare( '==', 'order.base.customerid', $customerId ), $search->compare( '==', 'order.base.product.attribute.id', $id ), ); $search->setConditions( $search->combine( '&&', $expr ) ); $search->setSlice( 0, 1 ); if( count( $manager->searchItems( $search ) ) > 0 ) { return true; } } return false; }
php
protected function checkAccess( $id ) { $context = $this->getContext(); if( ( $customerId = $context->getUserId() ) !== null && $id !== null ) { $manager = \Aimeos\MShop::create( $context, 'order/base' ); $search = $manager->createSearch(); $expr = array( $search->compare( '==', 'order.base.customerid', $customerId ), $search->compare( '==', 'order.base.product.attribute.id', $id ), ); $search->setConditions( $search->combine( '&&', $expr ) ); $search->setSlice( 0, 1 ); if( count( $manager->searchItems( $search ) ) > 0 ) { return true; } } return false; }
[ "protected", "function", "checkAccess", "(", "$", "id", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "if", "(", "(", "$", "customerId", "=", "$", "context", "->", "getUserId", "(", ")", ")", "!==", "null", "&&", "$...
Checks if the customer is allowed to download the file @param string $id Unique order base product attribute ID referencing the download file @return boolean True if download is allowed, false if not
[ "Checks", "if", "the", "customer", "is", "allowed", "to", "download", "the", "file" ]
06738c091041e959f7ddc4674acdb1f1b18474c3
https://github.com/aimeos/ai-client-html/blob/06738c091041e959f7ddc4674acdb1f1b18474c3/client/html/src/Client/Html/Account/Download/Standard.php#L280-L302
train
aimeos/ai-client-html
client/html/src/Client/Html/Account/Download/Standard.php
Standard.checkDownload
protected function checkDownload( $id ) { $context = $this->getContext(); /** client/html/account/download/maxcount * Maximum number of file downloads allowed for an ordered product * * This configuration setting enables you to limit the number of downloads * of a product download file. The count is the maximum number for each * bought product and customer, i.e. setting the count to "3" allows * a customer to download the bought product file up to three times. * * The default value of null enforces no limit. * * @param integer Maximum number of downloads * @since 2016.02 * @category Developer * @category User */ $maxcnt = $context->getConfig()->get( 'client/html/account/download/maxcount' ); $cntl = \Aimeos\Controller\Frontend::create( $context, 'customer' ); $item = $cntl->uses( ['order' => ['download']] )->get(); if( ( $listItem = $item->getListItem( 'order', 'download', $id ) ) === null ) { $listItem = $cntl->createListItem()->setType( 'download' )->setRefId( $id ); } $config = $listItem->getConfig(); $count = (int) $listItem->getConfigValue( 'count', 0 ); if( $maxcnt === null || $count < $maxcnt ) { $config['count'] = $count++; $cntl->addListItem( 'order', $listItem->setConfig( $config ) )->store(); return true; } return false; }
php
protected function checkDownload( $id ) { $context = $this->getContext(); /** client/html/account/download/maxcount * Maximum number of file downloads allowed for an ordered product * * This configuration setting enables you to limit the number of downloads * of a product download file. The count is the maximum number for each * bought product and customer, i.e. setting the count to "3" allows * a customer to download the bought product file up to three times. * * The default value of null enforces no limit. * * @param integer Maximum number of downloads * @since 2016.02 * @category Developer * @category User */ $maxcnt = $context->getConfig()->get( 'client/html/account/download/maxcount' ); $cntl = \Aimeos\Controller\Frontend::create( $context, 'customer' ); $item = $cntl->uses( ['order' => ['download']] )->get(); if( ( $listItem = $item->getListItem( 'order', 'download', $id ) ) === null ) { $listItem = $cntl->createListItem()->setType( 'download' )->setRefId( $id ); } $config = $listItem->getConfig(); $count = (int) $listItem->getConfigValue( 'count', 0 ); if( $maxcnt === null || $count < $maxcnt ) { $config['count'] = $count++; $cntl->addListItem( 'order', $listItem->setConfig( $config ) )->store(); return true; } return false; }
[ "protected", "function", "checkDownload", "(", "$", "id", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "/** client/html/account/download/maxcount\n\t\t * Maximum number of file downloads allowed for an ordered product\n\t\t *\n\t\t * This configu...
Updates the download counter for the downloaded file @param string $id Unique order base product attribute ID referencing the download file @return boolean True if download is allowed, false if not
[ "Updates", "the", "download", "counter", "for", "the", "downloaded", "file" ]
06738c091041e959f7ddc4674acdb1f1b18474c3
https://github.com/aimeos/ai-client-html/blob/06738c091041e959f7ddc4674acdb1f1b18474c3/client/html/src/Client/Html/Account/Download/Standard.php#L311-L351
train
aimeos/ai-client-html
client/html/src/Client/Html/Email/Payment/Standard.php
Standard.addAttachments
protected function addAttachments( \Aimeos\MW\Mail\Message\Iface $msg, array $files ) { foreach( $files as $filename ) { if( ( $content = @file_get_contents( $filename ) ) === false ) { throw new \Aimeos\Client\Html\Exception( sprintf( 'File "%1$s" doesn\'t exist', $filename ) ); } if( class_exists( 'finfo' ) ) { try { $finfo = new \finfo( FILEINFO_MIME_TYPE ); $mimetype = $finfo->file( $filename ); } catch( \Exception $e ) { throw new \Aimeos\Client\Html\Exception( $e->getMessage() ); } } else if( function_exists( 'mime_content_type' ) ) { $mimetype = mime_content_type( $filename ); } else { $mimetype = 'application/binary'; } $msg->addAttachment( $content, $mimetype, basename( $filename ) ); } }
php
protected function addAttachments( \Aimeos\MW\Mail\Message\Iface $msg, array $files ) { foreach( $files as $filename ) { if( ( $content = @file_get_contents( $filename ) ) === false ) { throw new \Aimeos\Client\Html\Exception( sprintf( 'File "%1$s" doesn\'t exist', $filename ) ); } if( class_exists( 'finfo' ) ) { try { $finfo = new \finfo( FILEINFO_MIME_TYPE ); $mimetype = $finfo->file( $filename ); } catch( \Exception $e ) { throw new \Aimeos\Client\Html\Exception( $e->getMessage() ); } } else if( function_exists( 'mime_content_type' ) ) { $mimetype = mime_content_type( $filename ); } else { $mimetype = 'application/binary'; } $msg->addAttachment( $content, $mimetype, basename( $filename ) ); } }
[ "protected", "function", "addAttachments", "(", "\\", "Aimeos", "\\", "MW", "\\", "Mail", "\\", "Message", "\\", "Iface", "$", "msg", ",", "array", "$", "files", ")", "{", "foreach", "(", "$", "files", "as", "$", "filename", ")", "{", "if", "(", "(",...
Adds the given list of files as attachments to the mail message object @param \Aimeos\MW\Mail\Message\Iface $msg Mail message @param array $files List of absolute file paths
[ "Adds", "the", "given", "list", "of", "files", "as", "attachments", "to", "the", "mail", "message", "object" ]
06738c091041e959f7ddc4674acdb1f1b18474c3
https://github.com/aimeos/ai-client-html/blob/06738c091041e959f7ddc4674acdb1f1b18474c3/client/html/src/Client/Html/Email/Payment/Standard.php#L441-L472
train
aimeos/ai-client-html
client/html/src/Client/Html/Checkout/Standard/Address/Billing/Standard.php
Standard.checkSalutation
protected function checkSalutation( array &$params, array &$mandatory ) { if( isset( $params['order.base.address.salutation'] ) && $params['order.base.address.salutation'] === \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_COMPANY && in_array( 'order.base.address.company', $mandatory ) === false ) { $mandatory[] = 'order.base.address.company'; } }
php
protected function checkSalutation( array &$params, array &$mandatory ) { if( isset( $params['order.base.address.salutation'] ) && $params['order.base.address.salutation'] === \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_COMPANY && in_array( 'order.base.address.company', $mandatory ) === false ) { $mandatory[] = 'order.base.address.company'; } }
[ "protected", "function", "checkSalutation", "(", "array", "&", "$", "params", ",", "array", "&", "$", "mandatory", ")", "{", "if", "(", "isset", "(", "$", "params", "[", "'order.base.address.salutation'", "]", ")", "&&", "$", "params", "[", "'order.base.addr...
Additional checks for the salutation @param array &$params Associative list of address keys (order.base.address.* or customer.address.*) and their values @param array &$mandatory List of mandatory field names @since 2016.05
[ "Additional", "checks", "for", "the", "salutation" ]
06738c091041e959f7ddc4674acdb1f1b18474c3
https://github.com/aimeos/ai-client-html/blob/06738c091041e959f7ddc4674acdb1f1b18474c3/client/html/src/Client/Html/Checkout/Standard/Address/Billing/Standard.php#L523-L531
train
aimeos/ai-client-html
client/html/src/Client/Html/Common/Client/Summary/Base.php
Base.getDownloadPaymentStatus
protected function getDownloadPaymentStatus() { $config = $this->getContext()->getConfig(); $default = \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED; /** client/html/common/summary/detail/download/payment-status * Minium payment status value for product download files * * This setting specifies the payment status value of an order for which * links to bought product download files are shown on the "thank you" * page, in the "MyAccount" and in the e-mails sent to the customers. * * The value is one of the payment constant values from * {@link https://github.com/aimeos/aimeos-core/blob/master/lib/mshoplib/src/MShop/Order/Item/Base.php#L105}. * Most of the time, only two values are of interest: * * 5: payment authorized * * 6: payment received * * @param integer Order payment constant value * @since 2016.3 * @category User * @category Developer */ return $config->get( 'client/html/common/summary/detail/download/payment-status', $default ); }
php
protected function getDownloadPaymentStatus() { $config = $this->getContext()->getConfig(); $default = \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED; /** client/html/common/summary/detail/download/payment-status * Minium payment status value for product download files * * This setting specifies the payment status value of an order for which * links to bought product download files are shown on the "thank you" * page, in the "MyAccount" and in the e-mails sent to the customers. * * The value is one of the payment constant values from * {@link https://github.com/aimeos/aimeos-core/blob/master/lib/mshoplib/src/MShop/Order/Item/Base.php#L105}. * Most of the time, only two values are of interest: * * 5: payment authorized * * 6: payment received * * @param integer Order payment constant value * @since 2016.3 * @category User * @category Developer */ return $config->get( 'client/html/common/summary/detail/download/payment-status', $default ); }
[ "protected", "function", "getDownloadPaymentStatus", "(", ")", "{", "$", "config", "=", "$", "this", "->", "getContext", "(", ")", "->", "getConfig", "(", ")", ";", "$", "default", "=", "\\", "Aimeos", "\\", "MShop", "\\", "Order", "\\", "Item", "\\", ...
Returns the payment status at which download files are shown @return integer Payment status from \Aimeos\MShop\Order\Item\Base
[ "Returns", "the", "payment", "status", "at", "which", "download", "files", "are", "shown" ]
06738c091041e959f7ddc4674acdb1f1b18474c3
https://github.com/aimeos/ai-client-html/blob/06738c091041e959f7ddc4674acdb1f1b18474c3/client/html/src/Client/Html/Common/Client/Summary/Base.php#L78-L102
train
aimeos/ai-client-html
client/html/src/Client/Html/Basket/Related/Bought/Standard.php
Standard.getProductIdsFromBasket
protected function getProductIdsFromBasket( \Aimeos\MShop\Order\Item\Base\Iface $basket ) { $list = []; foreach( $basket->getProducts() as $orderProduct ) { $list[ $orderProduct->getProductId() ] = true; foreach( $orderProduct->getProducts() as $subProduct ) { $list[ $subProduct->getProductId() ] = true; } } return array_keys( $list ); }
php
protected function getProductIdsFromBasket( \Aimeos\MShop\Order\Item\Base\Iface $basket ) { $list = []; foreach( $basket->getProducts() as $orderProduct ) { $list[ $orderProduct->getProductId() ] = true; foreach( $orderProduct->getProducts() as $subProduct ) { $list[ $subProduct->getProductId() ] = true; } } return array_keys( $list ); }
[ "protected", "function", "getProductIdsFromBasket", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Order", "\\", "Item", "\\", "Base", "\\", "Iface", "$", "basket", ")", "{", "$", "list", "=", "[", "]", ";", "foreach", "(", "$", "basket", "->", "getProducts"...
Returns the IDs of the products in the current basket. @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object @return string[] List of product IDs
[ "Returns", "the", "IDs", "of", "the", "products", "in", "the", "current", "basket", "." ]
06738c091041e959f7ddc4674acdb1f1b18474c3
https://github.com/aimeos/ai-client-html/blob/06738c091041e959f7ddc4674acdb1f1b18474c3/client/html/src/Client/Html/Basket/Related/Bought/Standard.php#L293-L307
train
aimeos/ai-client-html
controller/jobs/src/Controller/Jobs/Customer/Email/Watch/Standard.php
Standard.execute
protected function execute( \Aimeos\MShop\Context\Item\Iface $context, array $customers ) { $prodIds = $custIds = []; $listItems = $this->getListItems( $context, array_keys( $customers ) ); $listManager = \Aimeos\MShop::create( $context, 'customer/lists' ); foreach( $listItems as $id => $listItem ) { $refId = $listItem->getRefId(); $custIds[ $listItem->getParentId() ][$id] = $refId; $prodIds[$refId] = $refId; } $date = date( 'Y-m-d H:i:s' ); $products = $this->getProducts( $context, $prodIds, 'default' ); foreach( $custIds as $custId => $list ) { $custListItems = $listIds = []; foreach( $list as $listId => $prodId ) { $listItem = $listItems[$listId]; if( $listItem->getDateEnd() < $date ) { $listIds[] = $listId; } $custListItems[$listId] = $listItems[$listId]; } try { $custProducts = $this->getProductList( $products, $custListItems ); if( !empty( $custProducts ) ) { $addr = $customers[$custId]->getPaymentAddress(); $this->sendMail( $context, $addr, $custProducts ); $str = sprintf( 'Sent product notification e-mail to "%1$s"', $addr->getEmail() ); $context->getLogger()->log( $str, \Aimeos\MW\Logger\Base::DEBUG ); $listIds += array_keys( $custProducts ); } } catch( \Exception $e ) { $str = 'Error while trying to send product notification e-mail for customer ID "%1$s": %2$s'; $context->getLogger()->log( sprintf( $str, $custId, $e->getMessage() ) ); } $listManager->deleteItems( $listIds ); } }
php
protected function execute( \Aimeos\MShop\Context\Item\Iface $context, array $customers ) { $prodIds = $custIds = []; $listItems = $this->getListItems( $context, array_keys( $customers ) ); $listManager = \Aimeos\MShop::create( $context, 'customer/lists' ); foreach( $listItems as $id => $listItem ) { $refId = $listItem->getRefId(); $custIds[ $listItem->getParentId() ][$id] = $refId; $prodIds[$refId] = $refId; } $date = date( 'Y-m-d H:i:s' ); $products = $this->getProducts( $context, $prodIds, 'default' ); foreach( $custIds as $custId => $list ) { $custListItems = $listIds = []; foreach( $list as $listId => $prodId ) { $listItem = $listItems[$listId]; if( $listItem->getDateEnd() < $date ) { $listIds[] = $listId; } $custListItems[$listId] = $listItems[$listId]; } try { $custProducts = $this->getProductList( $products, $custListItems ); if( !empty( $custProducts ) ) { $addr = $customers[$custId]->getPaymentAddress(); $this->sendMail( $context, $addr, $custProducts ); $str = sprintf( 'Sent product notification e-mail to "%1$s"', $addr->getEmail() ); $context->getLogger()->log( $str, \Aimeos\MW\Logger\Base::DEBUG ); $listIds += array_keys( $custProducts ); } } catch( \Exception $e ) { $str = 'Error while trying to send product notification e-mail for customer ID "%1$s": %2$s'; $context->getLogger()->log( sprintf( $str, $custId, $e->getMessage() ) ); } $listManager->deleteItems( $listIds ); } }
[ "protected", "function", "execute", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Context", "\\", "Item", "\\", "Iface", "$", "context", ",", "array", "$", "customers", ")", "{", "$", "prodIds", "=", "$", "custIds", "=", "[", "]", ";", "$", "listItems", ...
Sends product notifications for the given customers in their language @param \Aimeos\MShop\Context\Item\Iface $context Context item object @param array $customers List of customer items implementing \Aimeos\MShop\Customer\Item\Iface
[ "Sends", "product", "notifications", "for", "the", "given", "customers", "in", "their", "language" ]
06738c091041e959f7ddc4674acdb1f1b18474c3
https://github.com/aimeos/ai-client-html/blob/06738c091041e959f7ddc4674acdb1f1b18474c3/controller/jobs/src/Controller/Jobs/Customer/Email/Watch/Standard.php#L111-L165
train
aimeos/ai-client-html
controller/jobs/src/Controller/Jobs/Customer/Email/Watch/Standard.php
Standard.getClient
protected function getClient( \Aimeos\MShop\Context\Item\Iface $context ) { if( !isset( $this->client ) ) { $this->client = \Aimeos\Client\Html\Email\Watch\Factory::create( $context ); } return $this->client; }
php
protected function getClient( \Aimeos\MShop\Context\Item\Iface $context ) { if( !isset( $this->client ) ) { $this->client = \Aimeos\Client\Html\Email\Watch\Factory::create( $context ); } return $this->client; }
[ "protected", "function", "getClient", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Context", "\\", "Item", "\\", "Iface", "$", "context", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "client", ")", ")", "{", "$", "this", "->", "client", ...
Returns the product notification e-mail client @param \Aimeos\MShop\Context\Item\Iface $context Context item object @return \Aimeos\Client\Html\Iface Product notification e-mail client
[ "Returns", "the", "product", "notification", "e", "-", "mail", "client" ]
06738c091041e959f7ddc4674acdb1f1b18474c3
https://github.com/aimeos/ai-client-html/blob/06738c091041e959f7ddc4674acdb1f1b18474c3/controller/jobs/src/Controller/Jobs/Customer/Email/Watch/Standard.php#L174-L181
train