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
zencoder/zencoder-php
Services/Zencoder.php
Services_Zencoder.retrieveData
public function retrieveData($path, array $params = array(), array $opts = array()) { return empty($params) ? $this->_processResponse($this->http->get($this->_getApiPath($opts) . $path)) : $this->_processResponse( $this->http->get($this->_getApiPath($opts) . $path . "?" . http_build_query($params, '', '&')) ); }
php
public function retrieveData($path, array $params = array(), array $opts = array()) { return empty($params) ? $this->_processResponse($this->http->get($this->_getApiPath($opts) . $path)) : $this->_processResponse( $this->http->get($this->_getApiPath($opts) . $path . "?" . http_build_query($params, '', '&')) ); }
[ "public", "function", "retrieveData", "(", "$", "path", ",", "array", "$", "params", "=", "array", "(", ")", ",", "array", "$", "opts", "=", "array", "(", ")", ")", "{", "return", "empty", "(", "$", "params", ")", "?", "$", "this", "->", "_processR...
GET the resource at the specified path. @param string $path Path to the resource @param array $params Query string parameters @param array $opts Optional overrides @return object The object representation of the resource
[ "GET", "the", "resource", "at", "the", "specified", "path", "." ]
a945431352da25357dc3f82b0dc13625a142d2e1
https://github.com/zencoder/zencoder-php/blob/a945431352da25357dc3f82b0dc13625a142d2e1/Services/Zencoder.php#L149-L156
train
zencoder/zencoder-php
Services/Zencoder.php
Services_Zencoder.deleteData
public function deleteData($path, array $opts = array()) { return $this->_processResponse($this->http->delete($this->_getApiPath($opts) . $path)); }
php
public function deleteData($path, array $opts = array()) { return $this->_processResponse($this->http->delete($this->_getApiPath($opts) . $path)); }
[ "public", "function", "deleteData", "(", "$", "path", ",", "array", "$", "opts", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "_processResponse", "(", "$", "this", "->", "http", "->", "delete", "(", "$", "this", "->", "_getApiPath", ...
DELETE the resource at the specified path. @param string $path Path to the resource @param array $opts Optional overrides @return object The object representation of the resource
[ "DELETE", "the", "resource", "at", "the", "specified", "path", "." ]
a945431352da25357dc3f82b0dc13625a142d2e1
https://github.com/zencoder/zencoder-php/blob/a945431352da25357dc3f82b0dc13625a142d2e1/Services/Zencoder.php#L166-L169
train
zencoder/zencoder-php
Services/Zencoder.php
Services_Zencoder.createData
public function createData($path, $body = "", array $opts = array()) { $headers = array('Content-Type' => 'application/json'); return empty($body) ? $this->_processResponse($this->http->post($this->_getApiPath($opts) . $path, $headers)) : $this->_processResponse( $this->http->post( $this->_getApiPath($opts) . $path, $headers, $body ) ); }
php
public function createData($path, $body = "", array $opts = array()) { $headers = array('Content-Type' => 'application/json'); return empty($body) ? $this->_processResponse($this->http->post($this->_getApiPath($opts) . $path, $headers)) : $this->_processResponse( $this->http->post( $this->_getApiPath($opts) . $path, $headers, $body ) ); }
[ "public", "function", "createData", "(", "$", "path", ",", "$", "body", "=", "\"\"", ",", "array", "$", "opts", "=", "array", "(", ")", ")", "{", "$", "headers", "=", "array", "(", "'Content-Type'", "=>", "'application/json'", ")", ";", "return", "empt...
POST to the resource at the specified path. @param string $path Path to the resource @param string $body Raw body to post @param array $opts Optional overrides @return object The object representation of the resource
[ "POST", "to", "the", "resource", "at", "the", "specified", "path", "." ]
a945431352da25357dc3f82b0dc13625a142d2e1
https://github.com/zencoder/zencoder-php/blob/a945431352da25357dc3f82b0dc13625a142d2e1/Services/Zencoder.php#L180-L192
train
zencoder/zencoder-php
Services/Zencoder.php
Services_Zencoder.updateData
public function updateData($path, $body = "", array $opts = array()) { $headers = array('Content-Type' => 'application/json'); return empty($params) ? $this->_processResponse($this->http->put($this->_getApiPath($opts) . $path, $headers)) : $this->_processResponse( $this->http->put( $this->_getApiPath($opts) . $path, $headers, $body ) ); }
php
public function updateData($path, $body = "", array $opts = array()) { $headers = array('Content-Type' => 'application/json'); return empty($params) ? $this->_processResponse($this->http->put($this->_getApiPath($opts) . $path, $headers)) : $this->_processResponse( $this->http->put( $this->_getApiPath($opts) . $path, $headers, $body ) ); }
[ "public", "function", "updateData", "(", "$", "path", ",", "$", "body", "=", "\"\"", ",", "array", "$", "opts", "=", "array", "(", ")", ")", "{", "$", "headers", "=", "array", "(", "'Content-Type'", "=>", "'application/json'", ")", ";", "return", "empt...
PUT to the resource at the specified path. @param string $path Path to the resource @param string $body Raw body to post @param array $opts Optional overrides @return object The object representation of the resource
[ "PUT", "to", "the", "resource", "at", "the", "specified", "path", "." ]
a945431352da25357dc3f82b0dc13625a142d2e1
https://github.com/zencoder/zencoder-php/blob/a945431352da25357dc3f82b0dc13625a142d2e1/Services/Zencoder.php#L203-L215
train
Codeception/base
src/Codeception/Module/XMLRPC.php
XMLRPC.seeResponseCodeIs
public function seeResponseCodeIs($num) { \PHPUnit\Framework\Assert::assertEquals($num, $this->client->getInternalResponse()->getStatus()); }
php
public function seeResponseCodeIs($num) { \PHPUnit\Framework\Assert::assertEquals($num, $this->client->getInternalResponse()->getStatus()); }
[ "public", "function", "seeResponseCodeIs", "(", "$", "num", ")", "{", "\\", "PHPUnit", "\\", "Framework", "\\", "Assert", "::", "assertEquals", "(", "$", "num", ",", "$", "this", "->", "client", "->", "getInternalResponse", "(", ")", "->", "getStatus", "("...
Checks response code. @param $num
[ "Checks", "response", "code", "." ]
aace5bab5593c93d8473b620f70754135a1eb4f0
https://github.com/Codeception/base/blob/aace5bab5593c93d8473b620f70754135a1eb4f0/src/Codeception/Module/XMLRPC.php#L119-L122
train
Codeception/base
src/Codeception/Module/XMLRPC.php
XMLRPC.seeResponseIsXMLRPC
public function seeResponseIsXMLRPC() { $result = xmlrpc_decode($this->response); \PHPUnit\Framework\Assert::assertNotNull($result, 'Invalid response document returned from XmlRpc server'); }
php
public function seeResponseIsXMLRPC() { $result = xmlrpc_decode($this->response); \PHPUnit\Framework\Assert::assertNotNull($result, 'Invalid response document returned from XmlRpc server'); }
[ "public", "function", "seeResponseIsXMLRPC", "(", ")", "{", "$", "result", "=", "xmlrpc_decode", "(", "$", "this", "->", "response", ")", ";", "\\", "PHPUnit", "\\", "Framework", "\\", "Assert", "::", "assertNotNull", "(", "$", "result", ",", "'Invalid respo...
Checks weather last response was valid XMLRPC. This is done with xmlrpc_decode function.
[ "Checks", "weather", "last", "response", "was", "valid", "XMLRPC", ".", "This", "is", "done", "with", "xmlrpc_decode", "function", "." ]
aace5bab5593c93d8473b620f70754135a1eb4f0
https://github.com/Codeception/base/blob/aace5bab5593c93d8473b620f70754135a1eb4f0/src/Codeception/Module/XMLRPC.php#L129-L133
train
Codeception/base
src/Codeception/Module/XMLRPC.php
XMLRPC.sendXMLRPCMethodCall
public function sendXMLRPCMethodCall($methodName, $parameters = []) { if (!array_key_exists('Content-Type', $this->headers)) { $this->headers['Content-Type'] = 'text/xml'; } foreach ($this->headers as $header => $val) { $this->client->setServerParameter("HTTP_$header", $val); } $url = $this->config['url']; if (is_array($parameters)) { $parameters = $this->scalarizeArray($parameters); } $requestBody = xmlrpc_encode_request($methodName, array_values($parameters)); $this->debugSection('Request', $url . PHP_EOL . $requestBody); $this->client->request('POST', $url, [], [], [], $requestBody); $this->response = $this->client->getInternalResponse()->getContent(); $this->debugSection('Response', $this->response); }
php
public function sendXMLRPCMethodCall($methodName, $parameters = []) { if (!array_key_exists('Content-Type', $this->headers)) { $this->headers['Content-Type'] = 'text/xml'; } foreach ($this->headers as $header => $val) { $this->client->setServerParameter("HTTP_$header", $val); } $url = $this->config['url']; if (is_array($parameters)) { $parameters = $this->scalarizeArray($parameters); } $requestBody = xmlrpc_encode_request($methodName, array_values($parameters)); $this->debugSection('Request', $url . PHP_EOL . $requestBody); $this->client->request('POST', $url, [], [], [], $requestBody); $this->response = $this->client->getInternalResponse()->getContent(); $this->debugSection('Response', $this->response); }
[ "public", "function", "sendXMLRPCMethodCall", "(", "$", "methodName", ",", "$", "parameters", "=", "[", "]", ")", "{", "if", "(", "!", "array_key_exists", "(", "'Content-Type'", ",", "$", "this", "->", "headers", ")", ")", "{", "$", "this", "->", "header...
Sends a XMLRPC method call to remote XMLRPC-server. @param string $methodName @param array $parameters
[ "Sends", "a", "XMLRPC", "method", "call", "to", "remote", "XMLRPC", "-", "server", "." ]
aace5bab5593c93d8473b620f70754135a1eb4f0
https://github.com/Codeception/base/blob/aace5bab5593c93d8473b620f70754135a1eb4f0/src/Codeception/Module/XMLRPC.php#L141-L164
train
Codeception/base
src/Codeception/Lib/InnerBrowser.php
InnerBrowser.clickButton
private function clickButton(\DOMNode $node) { $formParams = []; $buttonName = (string)$node->getAttribute('name'); $buttonValue = $node->getAttribute('value'); if ($buttonName !== '' && $buttonValue !== null) { $formParams = [$buttonName => $buttonValue]; } while ($node->parentNode !== null) { $node = $node->parentNode; if (!isset($node->tagName)) { // this is the top most node, it has no parent either break; } if ($node->tagName === 'a') { $this->openHrefFromDomNode($node); return true; } elseif ($node->tagName === 'form') { $this->proceedSubmitForm( new Crawler($node, $this->getAbsoluteUrlFor($this->_getCurrentUri()), $this->getBaseUrl()), $formParams ); return true; } } codecept_debug('Button is not inside a link or a form'); return false; }
php
private function clickButton(\DOMNode $node) { $formParams = []; $buttonName = (string)$node->getAttribute('name'); $buttonValue = $node->getAttribute('value'); if ($buttonName !== '' && $buttonValue !== null) { $formParams = [$buttonName => $buttonValue]; } while ($node->parentNode !== null) { $node = $node->parentNode; if (!isset($node->tagName)) { // this is the top most node, it has no parent either break; } if ($node->tagName === 'a') { $this->openHrefFromDomNode($node); return true; } elseif ($node->tagName === 'form') { $this->proceedSubmitForm( new Crawler($node, $this->getAbsoluteUrlFor($this->_getCurrentUri()), $this->getBaseUrl()), $formParams ); return true; } } codecept_debug('Button is not inside a link or a form'); return false; }
[ "private", "function", "clickButton", "(", "\\", "DOMNode", "$", "node", ")", "{", "$", "formParams", "=", "[", "]", ";", "$", "buttonName", "=", "(", "string", ")", "$", "node", "->", "getAttribute", "(", "'name'", ")", ";", "$", "buttonValue", "=", ...
Clicks the link or submits the form when the button is clicked @param \DOMNode $node @return boolean clicked something
[ "Clicks", "the", "link", "or", "submits", "the", "form", "when", "the", "button", "is", "clicked" ]
aace5bab5593c93d8473b620f70754135a1eb4f0
https://github.com/Codeception/base/blob/aace5bab5593c93d8473b620f70754135a1eb4f0/src/Codeception/Lib/InnerBrowser.php#L421-L450
train
Codeception/base
src/Codeception/Module/Phalcon.php
Phalcon.haveServiceInDi
public function haveServiceInDi($name, $definition, $shared = false) { return $this->addServiceToContainer($name, $definition, $shared); }
php
public function haveServiceInDi($name, $definition, $shared = false) { return $this->addServiceToContainer($name, $definition, $shared); }
[ "public", "function", "haveServiceInDi", "(", "$", "name", ",", "$", "definition", ",", "$", "shared", "=", "false", ")", "{", "return", "$", "this", "->", "addServiceToContainer", "(", "$", "name", ",", "$", "definition", ",", "$", "shared", ")", ";", ...
Alias for `addServiceToContainer`. Note: Deprecated. Will be removed in Codeception 2.3. @param string $name @param mixed $definition @param boolean $shared @return mixed|null @part services
[ "Alias", "for", "addServiceToContainer", "." ]
aace5bab5593c93d8473b620f70754135a1eb4f0
https://github.com/Codeception/base/blob/aace5bab5593c93d8473b620f70754135a1eb4f0/src/Codeception/Module/Phalcon.php#L498-L501
train
Codeception/base
src/Codeception/Lib/Connector/ZF1.php
ZF1.formatResponseHeaders
private function formatResponseHeaders(\Zend_Controller_Response_Abstract $response) { $headers = []; foreach ($response->getHeaders() as $header) { $name = $header['name']; if (array_key_exists($name, $headers)) { if ($header['replace']) { $headers[$name] = $header['value']; } } else { $headers[$name] = $header['value']; } } return $headers; }
php
private function formatResponseHeaders(\Zend_Controller_Response_Abstract $response) { $headers = []; foreach ($response->getHeaders() as $header) { $name = $header['name']; if (array_key_exists($name, $headers)) { if ($header['replace']) { $headers[$name] = $header['value']; } } else { $headers[$name] = $header['value']; } } return $headers; }
[ "private", "function", "formatResponseHeaders", "(", "\\", "Zend_Controller_Response_Abstract", "$", "response", ")", "{", "$", "headers", "=", "[", "]", ";", "foreach", "(", "$", "response", "->", "getHeaders", "(", ")", "as", "$", "header", ")", "{", "$", ...
Format up the ZF1 response headers into Symfony\Component\BrowserKit\Response headers format. @param \Zend_Controller_Response_Abstract $response The ZF1 Response Object. @return array the clean key/value headers
[ "Format", "up", "the", "ZF1", "response", "headers", "into", "Symfony", "\\", "Component", "\\", "BrowserKit", "\\", "Response", "headers", "format", "." ]
aace5bab5593c93d8473b620f70754135a1eb4f0
https://github.com/Codeception/base/blob/aace5bab5593c93d8473b620f70754135a1eb4f0/src/Codeception/Lib/Connector/ZF1.php#L103-L117
train
Codeception/base
src/Codeception/Module/Yii1.php
Yii1.getDomainRegex
private function getDomainRegex($template, $parameters = []) { if ($host = parse_url($template, PHP_URL_HOST)) { $template = $host; } if (strpos($template, '<') !== false) { $template = str_replace(['<', '>'], '#', $template); } $template = preg_quote($template); foreach ($parameters as $name => $value) { $template = str_replace("#$name#", $value, $template); } return '/^' . $template . '$/u'; }
php
private function getDomainRegex($template, $parameters = []) { if ($host = parse_url($template, PHP_URL_HOST)) { $template = $host; } if (strpos($template, '<') !== false) { $template = str_replace(['<', '>'], '#', $template); } $template = preg_quote($template); foreach ($parameters as $name => $value) { $template = str_replace("#$name#", $value, $template); } return '/^' . $template . '$/u'; }
[ "private", "function", "getDomainRegex", "(", "$", "template", ",", "$", "parameters", "=", "[", "]", ")", "{", "if", "(", "$", "host", "=", "parse_url", "(", "$", "template", ",", "PHP_URL_HOST", ")", ")", "{", "$", "template", "=", "$", "host", ";"...
Getting domain regex from rule template and parameters @param string $template @param array $parameters @return string
[ "Getting", "domain", "regex", "from", "rule", "template", "and", "parameters" ]
aace5bab5593c93d8473b620f70754135a1eb4f0
https://github.com/Codeception/base/blob/aace5bab5593c93d8473b620f70754135a1eb4f0/src/Codeception/Module/Yii1.php#L225-L238
train
Codeception/base
src/Codeception/Module/Yii1.php
Yii1.getInternalDomains
public function getInternalDomains() { $domains = [$this->getDomainRegex(Yii::app()->request->getHostInfo())]; if (Yii::app()->urlManager->urlFormat === 'path') { $parent = Yii::app()->urlManager instanceof \CUrlManager ? '\CUrlManager' : null; $rules = ReflectionHelper::readPrivateProperty(Yii::app()->urlManager, '_rules', $parent); foreach ($rules as $rule) { if ($rule->hasHostInfo === true) { $domains[] = $this->getDomainRegex($rule->template, $rule->params); } } } return array_unique($domains); }
php
public function getInternalDomains() { $domains = [$this->getDomainRegex(Yii::app()->request->getHostInfo())]; if (Yii::app()->urlManager->urlFormat === 'path') { $parent = Yii::app()->urlManager instanceof \CUrlManager ? '\CUrlManager' : null; $rules = ReflectionHelper::readPrivateProperty(Yii::app()->urlManager, '_rules', $parent); foreach ($rules as $rule) { if ($rule->hasHostInfo === true) { $domains[] = $this->getDomainRegex($rule->template, $rule->params); } } } return array_unique($domains); }
[ "public", "function", "getInternalDomains", "(", ")", "{", "$", "domains", "=", "[", "$", "this", "->", "getDomainRegex", "(", "Yii", "::", "app", "(", ")", "->", "request", "->", "getHostInfo", "(", ")", ")", "]", ";", "if", "(", "Yii", "::", "app",...
Returns a list of regex patterns for recognized domain names @return array
[ "Returns", "a", "list", "of", "regex", "patterns", "for", "recognized", "domain", "names" ]
aace5bab5593c93d8473b620f70754135a1eb4f0
https://github.com/Codeception/base/blob/aace5bab5593c93d8473b620f70754135a1eb4f0/src/Codeception/Module/Yii1.php#L246-L259
train
Codeception/base
src/Codeception/Util/Debug.php
Debug.pause
public static function pause() { if (!self::$output) { return; } self::$output->writeln("<info>The execution has been paused. Press ENTER to continue</info>"); if (trim(fgets(STDIN)) != chr(13)) { return; } }
php
public static function pause() { if (!self::$output) { return; } self::$output->writeln("<info>The execution has been paused. Press ENTER to continue</info>"); if (trim(fgets(STDIN)) != chr(13)) { return; } }
[ "public", "static", "function", "pause", "(", ")", "{", "if", "(", "!", "self", "::", "$", "output", ")", "{", "return", ";", "}", "self", "::", "$", "output", "->", "writeln", "(", "\"<info>The execution has been paused. Press ENTER to continue</info>\"", ")", ...
Pauses execution and waits for user input to proceed.
[ "Pauses", "execution", "and", "waits", "for", "user", "input", "to", "proceed", "." ]
aace5bab5593c93d8473b620f70754135a1eb4f0
https://github.com/Codeception/base/blob/aace5bab5593c93d8473b620f70754135a1eb4f0/src/Codeception/Util/Debug.php#L42-L53
train
Codeception/base
src/Codeception/Module/Asserts.php
Asserts.assertEquals
public function assertEquals($expected, $actual, $message = '', $delta = 0.0) { parent::assertEquals($expected, $actual, $message, $delta); }
php
public function assertEquals($expected, $actual, $message = '', $delta = 0.0) { parent::assertEquals($expected, $actual, $message, $delta); }
[ "public", "function", "assertEquals", "(", "$", "expected", ",", "$", "actual", ",", "$", "message", "=", "''", ",", "$", "delta", "=", "0.0", ")", "{", "parent", "::", "assertEquals", "(", "$", "expected", ",", "$", "actual", ",", "$", "message", ",...
Checks that two variables are equal. If you're comparing floating-point values, you can specify the optional "delta" parameter which dictates how great of a precision error are you willing to tolerate in order to consider the two values equal. Regular example: ```php <?php $I->assertEquals(5, $element->getChildrenCount()); ``` Floating-point example: ```php <?php $I->assertEquals(0.3, $calculator->add(0.1, 0.2), 'Calculator should add the two numbers correctly.', 0.01); ``` @param $expected @param $actual @param string $message @param float $delta
[ "Checks", "that", "two", "variables", "are", "equal", ".", "If", "you", "re", "comparing", "floating", "-", "point", "values", "you", "can", "specify", "the", "optional", "delta", "parameter", "which", "dictates", "how", "great", "of", "a", "precision", "err...
aace5bab5593c93d8473b620f70754135a1eb4f0
https://github.com/Codeception/base/blob/aace5bab5593c93d8473b620f70754135a1eb4f0/src/Codeception/Module/Asserts.php#L34-L37
train
Codeception/base
src/Codeception/Module/Asserts.php
Asserts.assertNotEquals
public function assertNotEquals($expected, $actual, $message = '', $delta = 0.0) { parent::assertNotEquals($expected, $actual, $message, $delta); }
php
public function assertNotEquals($expected, $actual, $message = '', $delta = 0.0) { parent::assertNotEquals($expected, $actual, $message, $delta); }
[ "public", "function", "assertNotEquals", "(", "$", "expected", ",", "$", "actual", ",", "$", "message", "=", "''", ",", "$", "delta", "=", "0.0", ")", "{", "parent", "::", "assertNotEquals", "(", "$", "expected", ",", "$", "actual", ",", "$", "message"...
Checks that two variables are not equal. If you're comparing floating-point values, you can specify the optional "delta" parameter which dictates how great of a precision error are you willing to tolerate in order to consider the two values not equal. Regular example: ```php <?php $I->assertNotEquals(0, $element->getChildrenCount()); ``` Floating-point example: ```php <?php $I->assertNotEquals(0.4, $calculator->add(0.1, 0.2), 'Calculator should add the two numbers correctly.', 0.01); ``` @param $expected @param $actual @param string $message @param float $delta
[ "Checks", "that", "two", "variables", "are", "not", "equal", ".", "If", "you", "re", "comparing", "floating", "-", "point", "values", "you", "can", "specify", "the", "optional", "delta", "parameter", "which", "dictates", "how", "great", "of", "a", "precision...
aace5bab5593c93d8473b620f70754135a1eb4f0
https://github.com/Codeception/base/blob/aace5bab5593c93d8473b620f70754135a1eb4f0/src/Codeception/Module/Asserts.php#L61-L64
train
fedemotta/yii2-aws-sdk
AwsSdk.php
AwsSdk.setAwsSdk
public function setAwsSdk() { $this->_awssdk = new Aws\Sdk(array_merge([ 'credentials' => $this->credentials, 'region'=>$this->region, 'version'=>$this->version ],$this->extra)); }
php
public function setAwsSdk() { $this->_awssdk = new Aws\Sdk(array_merge([ 'credentials' => $this->credentials, 'region'=>$this->region, 'version'=>$this->version ],$this->extra)); }
[ "public", "function", "setAwsSdk", "(", ")", "{", "$", "this", "->", "_awssdk", "=", "new", "Aws", "\\", "Sdk", "(", "array_merge", "(", "[", "'credentials'", "=>", "$", "this", "->", "credentials", ",", "'region'", "=>", "$", "this", "->", "region", "...
Sets the AWS SDK instance
[ "Sets", "the", "AWS", "SDK", "instance" ]
7ef80f53a048dff3d5a3e08f09071c09f5eb803a
https://github.com/fedemotta/yii2-aws-sdk/blob/7ef80f53a048dff3d5a3e08f09071c09f5eb803a/AwsSdk.php#L57-L64
train
silverstripe/recipe-plugin
src/RecipeInstaller.php
RecipeInstaller.installProjectFiles
protected function installProjectFiles( $recipe, $sourceRoot, $destinationRoot, $filePatterns, $registrationKey, $name = 'project' ) { // load composer json data $composerFile = new JsonFile(Factory::getComposerFile(), null, $this->io); $composerData = $composerFile->read(); $installedFiles = isset($composerData['extra'][$registrationKey]) ? $composerData['extra'][$registrationKey] : []; // Load all project files $fileIterator = $this->getFileIterator($sourceRoot, $filePatterns); $any = false; foreach ($fileIterator as $path => $info) { // Write header on first file if (!$any) { $this->io->write("Installing {$name} files for recipe <info>{$recipe}</info>:"); $any = true; } // Install this file $relativePath = $this->installProjectFile($sourceRoot, $destinationRoot, $path, $installedFiles); // Add file to installed (even if already exists) if (!in_array($relativePath, $installedFiles)) { $installedFiles[] = $relativePath; } } // If any files are written, modify composer.json with newly installed files if ($installedFiles) { sort($installedFiles); if (!isset($composerData['extra'])) { $composerData['extra'] = []; } $composerData['extra'][$registrationKey] = $installedFiles; $composerFile->write($composerData); } }
php
protected function installProjectFiles( $recipe, $sourceRoot, $destinationRoot, $filePatterns, $registrationKey, $name = 'project' ) { // load composer json data $composerFile = new JsonFile(Factory::getComposerFile(), null, $this->io); $composerData = $composerFile->read(); $installedFiles = isset($composerData['extra'][$registrationKey]) ? $composerData['extra'][$registrationKey] : []; // Load all project files $fileIterator = $this->getFileIterator($sourceRoot, $filePatterns); $any = false; foreach ($fileIterator as $path => $info) { // Write header on first file if (!$any) { $this->io->write("Installing {$name} files for recipe <info>{$recipe}</info>:"); $any = true; } // Install this file $relativePath = $this->installProjectFile($sourceRoot, $destinationRoot, $path, $installedFiles); // Add file to installed (even if already exists) if (!in_array($relativePath, $installedFiles)) { $installedFiles[] = $relativePath; } } // If any files are written, modify composer.json with newly installed files if ($installedFiles) { sort($installedFiles); if (!isset($composerData['extra'])) { $composerData['extra'] = []; } $composerData['extra'][$registrationKey] = $installedFiles; $composerFile->write($composerData); } }
[ "protected", "function", "installProjectFiles", "(", "$", "recipe", ",", "$", "sourceRoot", ",", "$", "destinationRoot", ",", "$", "filePatterns", ",", "$", "registrationKey", ",", "$", "name", "=", "'project'", ")", "{", "// load composer json data", "$", "comp...
Install project files in the specified directory @param string $recipe Recipe name @param string $sourceRoot Base of source files (no trailing slash) @param string $destinationRoot Base of destination directory (no trailing slash) @param array $filePatterns List of file patterns in wildcard format (e.g. `code/My*.php`) @param string $registrationKey Registration key for installed files @param string $name Name of project file type being installed
[ "Install", "project", "files", "in", "the", "specified", "directory" ]
88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e
https://github.com/silverstripe/recipe-plugin/blob/88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e/src/RecipeInstaller.php#L35-L78
train
silverstripe/recipe-plugin
src/RecipeInstaller.php
RecipeInstaller.getFileIterator
protected function getFileIterator($sourceRoot, $patterns) { // Build regexp pattern $expressions = []; foreach ($patterns as $pattern) { $expressions[] = $this->globToRegexp($pattern); } $regExp = '#^' . $this->globToRegexp($sourceRoot . '/').'(('.implode(')|(', $expressions).'))$#'; // Build directory iterator $directoryIterator = new RecursiveDirectoryIterator( $sourceRoot, FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS | FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO ); // Return filtered iterator $iterator = new RecursiveIteratorIterator($directoryIterator); return new RegexIterator($iterator, $regExp); }
php
protected function getFileIterator($sourceRoot, $patterns) { // Build regexp pattern $expressions = []; foreach ($patterns as $pattern) { $expressions[] = $this->globToRegexp($pattern); } $regExp = '#^' . $this->globToRegexp($sourceRoot . '/').'(('.implode(')|(', $expressions).'))$#'; // Build directory iterator $directoryIterator = new RecursiveDirectoryIterator( $sourceRoot, FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS | FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO ); // Return filtered iterator $iterator = new RecursiveIteratorIterator($directoryIterator); return new RegexIterator($iterator, $regExp); }
[ "protected", "function", "getFileIterator", "(", "$", "sourceRoot", ",", "$", "patterns", ")", "{", "// Build regexp pattern", "$", "expressions", "=", "[", "]", ";", "foreach", "(", "$", "patterns", "as", "$", "pattern", ")", "{", "$", "expressions", "[", ...
Get iterator of matching source files to copy @param string $sourceRoot Root directory of sources (no trailing slash) @param array $patterns List of wildcard patterns to match @return Iterator File iterator, where key is path and value is file info object
[ "Get", "iterator", "of", "matching", "source", "files", "to", "copy" ]
88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e
https://github.com/silverstripe/recipe-plugin/blob/88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e/src/RecipeInstaller.php#L127-L148
train
silverstripe/recipe-plugin
src/RecipeInstaller.php
RecipeInstaller.globToRegexp
protected function globToRegexp($glob) { $sourceParts = explode('*', $glob); $regexParts = array_map(function ($part) { return preg_quote($part, '#'); }, $sourceParts); return implode('(.+)', $regexParts); }
php
protected function globToRegexp($glob) { $sourceParts = explode('*', $glob); $regexParts = array_map(function ($part) { return preg_quote($part, '#'); }, $sourceParts); return implode('(.+)', $regexParts); }
[ "protected", "function", "globToRegexp", "(", "$", "glob", ")", "{", "$", "sourceParts", "=", "explode", "(", "'*'", ",", "$", "glob", ")", ";", "$", "regexParts", "=", "array_map", "(", "function", "(", "$", "part", ")", "{", "return", "preg_quote", "...
Convert glob pattern to regexp @param string $glob @return string
[ "Convert", "glob", "pattern", "to", "regexp" ]
88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e
https://github.com/silverstripe/recipe-plugin/blob/88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e/src/RecipeInstaller.php#L156-L163
train
silverstripe/recipe-plugin
src/RecipeCommandBehaviour.php
RecipeCommandBehaviour.updateProject
protected function updateProject(OutputInterface $output) { /** @var UpdateCommand $command */ $command = $this->getApplication()->find('update'); $arguments = [ 'command' => 'update' ]; $requireInput = new ArrayInput($arguments); $returnCode = $command->run($requireInput, $output); // Flush modified composer object $this->resetComposer(); return $returnCode; }
php
protected function updateProject(OutputInterface $output) { /** @var UpdateCommand $command */ $command = $this->getApplication()->find('update'); $arguments = [ 'command' => 'update' ]; $requireInput = new ArrayInput($arguments); $returnCode = $command->run($requireInput, $output); // Flush modified composer object $this->resetComposer(); return $returnCode; }
[ "protected", "function", "updateProject", "(", "OutputInterface", "$", "output", ")", "{", "/** @var UpdateCommand $command */", "$", "command", "=", "$", "this", "->", "getApplication", "(", ")", "->", "find", "(", "'update'", ")", ";", "$", "arguments", "=", ...
Update the project @param OutputInterface $output @return int
[ "Update", "the", "project" ]
88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e
https://github.com/silverstripe/recipe-plugin/blob/88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e/src/RecipeCommandBehaviour.php#L74-L85
train
silverstripe/recipe-plugin
src/RecipeCommandBehaviour.php
RecipeCommandBehaviour.findInstalledVersion
protected function findInstalledVersion($recipe) { // Check locker $installed = $this->getComposer()->getLocker()->getLockedRepository()->findPackage($recipe, '*'); if ($installed) { return $installed->getPrettyVersion(); } // Check provides $provides = $this->getComposer()->getPackage()->getProvides(); if (isset($provides[$recipe])) { return $provides[$recipe]->getPrettyConstraint(); } // Check requires $requires = $this->getComposer()->getPackage()->getRequires(); if (isset($requires[$recipe])) { return $requires[$recipe]->getPrettyConstraint(); } // No existing version return null; }
php
protected function findInstalledVersion($recipe) { // Check locker $installed = $this->getComposer()->getLocker()->getLockedRepository()->findPackage($recipe, '*'); if ($installed) { return $installed->getPrettyVersion(); } // Check provides $provides = $this->getComposer()->getPackage()->getProvides(); if (isset($provides[$recipe])) { return $provides[$recipe]->getPrettyConstraint(); } // Check requires $requires = $this->getComposer()->getPackage()->getRequires(); if (isset($requires[$recipe])) { return $requires[$recipe]->getPrettyConstraint(); } // No existing version return null; }
[ "protected", "function", "findInstalledVersion", "(", "$", "recipe", ")", "{", "// Check locker", "$", "installed", "=", "$", "this", "->", "getComposer", "(", ")", "->", "getLocker", "(", ")", "->", "getLockedRepository", "(", ")", "->", "findPackage", "(", ...
Find installed version or constraint @param string $recipe @return string
[ "Find", "installed", "version", "or", "constraint" ]
88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e
https://github.com/silverstripe/recipe-plugin/blob/88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e/src/RecipeCommandBehaviour.php#L93-L115
train
silverstripe/recipe-plugin
src/RecipeCommandBehaviour.php
RecipeCommandBehaviour.findBestConstraint
protected function findBestConstraint($existingVersion) { // Cannot guess without existing version if (!$existingVersion) { return null; } // Existing version is already a ^1.0.0 or ~1.0.0 constraint if (preg_match('#^[~^]#', $existingVersion)) { return $existingVersion; } // Existing version is already a dev constraint if (stristr($existingVersion, 'dev') !== false) { return $existingVersion; } // Numeric-only version maps to semver constraint if (preg_match('#^([\d.]+)$#', $existingVersion)) { return "^{$existingVersion}"; } // Cannot guess; Let composer choose (equivalent to `composer require vendor/library`) return null; }
php
protected function findBestConstraint($existingVersion) { // Cannot guess without existing version if (!$existingVersion) { return null; } // Existing version is already a ^1.0.0 or ~1.0.0 constraint if (preg_match('#^[~^]#', $existingVersion)) { return $existingVersion; } // Existing version is already a dev constraint if (stristr($existingVersion, 'dev') !== false) { return $existingVersion; } // Numeric-only version maps to semver constraint if (preg_match('#^([\d.]+)$#', $existingVersion)) { return "^{$existingVersion}"; } // Cannot guess; Let composer choose (equivalent to `composer require vendor/library`) return null; }
[ "protected", "function", "findBestConstraint", "(", "$", "existingVersion", ")", "{", "// Cannot guess without existing version", "if", "(", "!", "$", "existingVersion", ")", "{", "return", "null", ";", "}", "// Existing version is already a ^1.0.0 or ~1.0.0 constraint", "i...
Guess constraint to use if not provided @param string $existingVersion Known installed version @return string
[ "Guess", "constraint", "to", "use", "if", "not", "provided" ]
88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e
https://github.com/silverstripe/recipe-plugin/blob/88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e/src/RecipeCommandBehaviour.php#L123-L147
train
silverstripe/recipe-plugin
src/RecipeCommandBehaviour.php
RecipeCommandBehaviour.modifyComposer
protected function modifyComposer($callable) { // Begin modification of composer.json $composerFile = new JsonFile(Factory::getComposerFile(), null, $this->getIO()); $composerData = $composerFile->read(); // Note: Respect call by ref $composerData $result = $callable($composerData); if ($result === false) { return; } if ($result) { $composerData = $result; } // Update composer.json and refresh local composer instance $composerFile->write($composerData); $this->resetComposer(); }
php
protected function modifyComposer($callable) { // Begin modification of composer.json $composerFile = new JsonFile(Factory::getComposerFile(), null, $this->getIO()); $composerData = $composerFile->read(); // Note: Respect call by ref $composerData $result = $callable($composerData); if ($result === false) { return; } if ($result) { $composerData = $result; } // Update composer.json and refresh local composer instance $composerFile->write($composerData); $this->resetComposer(); }
[ "protected", "function", "modifyComposer", "(", "$", "callable", ")", "{", "// Begin modification of composer.json", "$", "composerFile", "=", "new", "JsonFile", "(", "Factory", "::", "getComposerFile", "(", ")", ",", "null", ",", "$", "this", "->", "getIO", "("...
callback to safely modify composer.json data @param callable $callable Callable which will safely take and return the composer data. This should return false if no content changed, or the updated data
[ "callback", "to", "safely", "modify", "composer", ".", "json", "data" ]
88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e
https://github.com/silverstripe/recipe-plugin/blob/88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e/src/RecipeCommandBehaviour.php#L273-L291
train
silverstripe/recipe-plugin
src/RecipePlugin.php
RecipePlugin.cleanupProject
public function cleanupProject(Event $event) { $file = new JsonFile(Factory::getComposerFile()); $data = $file->read(); // Remove project and public files from project unset($data['extra'][self::PROJECT_FILES]); unset($data['extra'][self::PUBLIC_FILES]); // Remove redundant empty extra if (empty($data['extra'])) { unset($data['extra']); } // Save back to composer.json $file->write($data); }
php
public function cleanupProject(Event $event) { $file = new JsonFile(Factory::getComposerFile()); $data = $file->read(); // Remove project and public files from project unset($data['extra'][self::PROJECT_FILES]); unset($data['extra'][self::PUBLIC_FILES]); // Remove redundant empty extra if (empty($data['extra'])) { unset($data['extra']); } // Save back to composer.json $file->write($data); }
[ "public", "function", "cleanupProject", "(", "Event", "$", "event", ")", "{", "$", "file", "=", "new", "JsonFile", "(", "Factory", "::", "getComposerFile", "(", ")", ")", ";", "$", "data", "=", "$", "file", "->", "read", "(", ")", ";", "// Remove proje...
Cleanup the root package on create-project @param Event $event
[ "Cleanup", "the", "root", "package", "on", "create", "-", "project" ]
88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e
https://github.com/silverstripe/recipe-plugin/blob/88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e/src/RecipePlugin.php#L94-L110
train
silverstripe/recipe-plugin
src/RecipePlugin.php
RecipePlugin.getOperationPackage
protected function getOperationPackage(PackageEvent $event) { $operation = $event->getOperation(); if ($operation instanceof UpdateOperation) { return $operation->getTargetPackage(); } if ($operation instanceof InstallOperation) { return $operation->getPackage(); } return null; }
php
protected function getOperationPackage(PackageEvent $event) { $operation = $event->getOperation(); if ($operation instanceof UpdateOperation) { return $operation->getTargetPackage(); } if ($operation instanceof InstallOperation) { return $operation->getPackage(); } return null; }
[ "protected", "function", "getOperationPackage", "(", "PackageEvent", "$", "event", ")", "{", "$", "operation", "=", "$", "event", "->", "getOperation", "(", ")", ";", "if", "(", "$", "operation", "instanceof", "UpdateOperation", ")", "{", "return", "$", "ope...
Get target package from operation @param PackageEvent $event @return PackageInterface
[ "Get", "target", "package", "from", "operation" ]
88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e
https://github.com/silverstripe/recipe-plugin/blob/88cd7ed3a0c07a0b24b70ee43d855488d7f1ac7e/src/RecipePlugin.php#L118-L128
train
eclipxe13/CfdiUtils
src/CfdiUtils/CfdiValidator33.php
CfdiValidator33.validate
public function validate(string $xmlString, NodeInterface $node): Asserts { if ('' === $xmlString) { throw new \UnexpectedValueException('The xml string to validate cannot be empty'); } $factory = new MultiValidatorFactory(); $validator = $factory->newReceived33(); $hydrater = new Hydrater(); $hydrater->setXmlString($xmlString); $hydrater->setXmlResolver(($this->hasXmlResolver()) ? $this->getXmlResolver() : null); $hydrater->setXsltBuilder($this->getXsltBuilder()); $validator->hydrate($hydrater); $asserts = new Asserts(); $validator->validate($node, $asserts); return $asserts; }
php
public function validate(string $xmlString, NodeInterface $node): Asserts { if ('' === $xmlString) { throw new \UnexpectedValueException('The xml string to validate cannot be empty'); } $factory = new MultiValidatorFactory(); $validator = $factory->newReceived33(); $hydrater = new Hydrater(); $hydrater->setXmlString($xmlString); $hydrater->setXmlResolver(($this->hasXmlResolver()) ? $this->getXmlResolver() : null); $hydrater->setXsltBuilder($this->getXsltBuilder()); $validator->hydrate($hydrater); $asserts = new Asserts(); $validator->validate($node, $asserts); return $asserts; }
[ "public", "function", "validate", "(", "string", "$", "xmlString", ",", "NodeInterface", "$", "node", ")", ":", "Asserts", "{", "if", "(", "''", "===", "$", "xmlString", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'The xml string to valid...
Validate and return the asserts from the validation process. This method can use a xml string and a NodeInterface, is your responsability that the node is the representation of the content. @param string $xmlString @param NodeInterface $node @return Asserts|\CfdiUtils\Validate\Assert[]
[ "Validate", "and", "return", "the", "asserts", "from", "the", "validation", "process", ".", "This", "method", "can", "use", "a", "xml", "string", "and", "a", "NodeInterface", "is", "your", "responsability", "that", "the", "node", "is", "the", "representation",...
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/CfdiValidator33.php#L44-L63
train
eclipxe13/CfdiUtils
src/CfdiUtils/CfdiValidator33.php
CfdiValidator33.validateXml
public function validateXml(string $xmlString): Asserts { return $this->validate($xmlString, XmlNodeUtils::nodeFromXmlString($xmlString)); }
php
public function validateXml(string $xmlString): Asserts { return $this->validate($xmlString, XmlNodeUtils::nodeFromXmlString($xmlString)); }
[ "public", "function", "validateXml", "(", "string", "$", "xmlString", ")", ":", "Asserts", "{", "return", "$", "this", "->", "validate", "(", "$", "xmlString", ",", "XmlNodeUtils", "::", "nodeFromXmlString", "(", "$", "xmlString", ")", ")", ";", "}" ]
Validate and return the asserts from the validation process based on a xml string @param string $xmlString @return Asserts|\CfdiUtils\Validate\Assert[]
[ "Validate", "and", "return", "the", "asserts", "from", "the", "validation", "process", "based", "on", "a", "xml", "string" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/CfdiValidator33.php#L71-L74
train
eclipxe13/CfdiUtils
src/CfdiUtils/CfdiValidator33.php
CfdiValidator33.validateNode
public function validateNode(NodeInterface $node): Asserts { return $this->validate(XmlNodeUtils::nodeToXmlString($node), $node); }
php
public function validateNode(NodeInterface $node): Asserts { return $this->validate(XmlNodeUtils::nodeToXmlString($node), $node); }
[ "public", "function", "validateNode", "(", "NodeInterface", "$", "node", ")", ":", "Asserts", "{", "return", "$", "this", "->", "validate", "(", "XmlNodeUtils", "::", "nodeToXmlString", "(", "$", "node", ")", ",", "$", "node", ")", ";", "}" ]
Validate and return the asserts from the validation process based on a node interface object @param NodeInterface $node @return Asserts|\CfdiUtils\Validate\Assert[]
[ "Validate", "and", "return", "the", "asserts", "from", "the", "validation", "process", "based", "on", "a", "node", "interface", "object" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/CfdiValidator33.php#L82-L85
train
eclipxe13/CfdiUtils
src/CfdiUtils/PemPrivateKey/PemPrivateKey.php
PemPrivateKey.isPEM
public static function isPEM(string $keyContents): bool { if ('' === $keyContents) { return false; } $openSSL = new OpenSSL(); return $openSSL->readPemContents($keyContents)->hasPrivateKey(); }
php
public static function isPEM(string $keyContents): bool { if ('' === $keyContents) { return false; } $openSSL = new OpenSSL(); return $openSSL->readPemContents($keyContents)->hasPrivateKey(); }
[ "public", "static", "function", "isPEM", "(", "string", "$", "keyContents", ")", ":", "bool", "{", "if", "(", "''", "===", "$", "keyContents", ")", "{", "return", "false", ";", "}", "$", "openSSL", "=", "new", "OpenSSL", "(", ")", ";", "return", "$",...
Check if a string has an obvious signature of a PEM file @param string $keyContents @return bool @deprecated 2.9.0 Replaced with OpenSSL utility @see OpenSSL
[ "Check", "if", "a", "string", "has", "an", "obvious", "signature", "of", "a", "PEM", "file" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/PemPrivateKey/PemPrivateKey.php#L128-L136
train
eclipxe13/CfdiUtils
src/CfdiUtils/Cfdi.php
Cfdi.newFromString
public static function newFromString(string $content): self { $document = Xml::newDocumentContent($content); // populate source since it is already available // in this way we avoid the conversion from document to string $cfdi = new self($document); $cfdi->source = $content; return $cfdi; }
php
public static function newFromString(string $content): self { $document = Xml::newDocumentContent($content); // populate source since it is already available // in this way we avoid the conversion from document to string $cfdi = new self($document); $cfdi->source = $content; return $cfdi; }
[ "public", "static", "function", "newFromString", "(", "string", "$", "content", ")", ":", "self", "{", "$", "document", "=", "Xml", "::", "newDocumentContent", "(", "$", "content", ")", ";", "// populate source since it is already available", "// in this way we avoid ...
Create a Cfdi object from a xml string @param string $content @return static
[ "Create", "a", "Cfdi", "object", "from", "a", "xml", "string" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Cfdi.php#L71-L79
train
eclipxe13/CfdiUtils
src/CfdiUtils/Cfdi.php
Cfdi.getSource
public function getSource(): string { if (null === $this->source) { // pass the document element to avoid xml header $this->source = $this->document->saveXML($this->document->documentElement); } return $this->source; }
php
public function getSource(): string { if (null === $this->source) { // pass the document element to avoid xml header $this->source = $this->document->saveXML($this->document->documentElement); } return $this->source; }
[ "public", "function", "getSource", "(", ")", ":", "string", "{", "if", "(", "null", "===", "$", "this", "->", "source", ")", "{", "// pass the document element to avoid xml header", "$", "this", "->", "source", "=", "$", "this", "->", "document", "->", "save...
Get the xml string source
[ "Get", "the", "xml", "string", "source" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Cfdi.php#L102-L109
train
eclipxe13/CfdiUtils
src/CfdiUtils/Cfdi.php
Cfdi.getNode
public function getNode(): NodeInterface { if (null === $this->node) { $this->node = XmlNodeUtils::nodeFromXmlElement($this->document->documentElement); } return $this->node; }
php
public function getNode(): NodeInterface { if (null === $this->node) { $this->node = XmlNodeUtils::nodeFromXmlElement($this->document->documentElement); } return $this->node; }
[ "public", "function", "getNode", "(", ")", ":", "NodeInterface", "{", "if", "(", "null", "===", "$", "this", "->", "node", ")", "{", "$", "this", "->", "node", "=", "XmlNodeUtils", "::", "nodeFromXmlElement", "(", "$", "this", "->", "document", "->", "...
Get the node object to iterate in the CFDI
[ "Get", "the", "node", "object", "to", "iterate", "in", "the", "CFDI" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Cfdi.php#L114-L120
train
eclipxe13/CfdiUtils
src/CfdiUtils/Certificado/NodeCertificado.php
NodeCertificado.extract
public function extract(): string { $version = $this->getVersion(); if ('3.2' === $version) { $attr = 'certificado'; } elseif ('3.3' === $version) { $attr = 'Certificado'; } else { throw new \RuntimeException('Unsupported or unknown version'); } $certificateBase64 = $this->comprobante->searchAttribute($attr); if ('' === $certificateBase64) { return ''; } $certificateBin = (string) base64_decode($certificateBase64, true); if ('' === $certificateBin) { throw new \RuntimeException('The certificado attribute is not a valid base64 encoded string'); } return $certificateBin; }
php
public function extract(): string { $version = $this->getVersion(); if ('3.2' === $version) { $attr = 'certificado'; } elseif ('3.3' === $version) { $attr = 'Certificado'; } else { throw new \RuntimeException('Unsupported or unknown version'); } $certificateBase64 = $this->comprobante->searchAttribute($attr); if ('' === $certificateBase64) { return ''; } $certificateBin = (string) base64_decode($certificateBase64, true); if ('' === $certificateBin) { throw new \RuntimeException('The certificado attribute is not a valid base64 encoded string'); } return $certificateBin; }
[ "public", "function", "extract", "(", ")", ":", "string", "{", "$", "version", "=", "$", "this", "->", "getVersion", "(", ")", ";", "if", "(", "'3.2'", "===", "$", "version", ")", "{", "$", "attr", "=", "'certificado'", ";", "}", "elseif", "(", "'3...
Extract the certificate from Comprobante->certificado If the node does not exists return an empty string The returned string is no longer base64 encoded @return string @throws \RuntimeException if the certificado attribute is not a valid base64 encoded string
[ "Extract", "the", "certificate", "from", "Comprobante", "-", ">", "certificado", "If", "the", "node", "does", "not", "exists", "return", "an", "empty", "string", "The", "returned", "string", "is", "no", "longer", "base64", "encoded" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Certificado/NodeCertificado.php#L26-L47
train
eclipxe13/CfdiUtils
src/CfdiUtils/Certificado/NodeCertificado.php
NodeCertificado.save
public function save(string $filename) { if ('' === $filename) { throw new \UnexpectedValueException('The filename to store the certificate is empty'); } $certificado = $this->extract(); if ('' === $certificado) { throw new \RuntimeException('The certificado attribute is empty'); } try { if (false === file_put_contents($filename, $certificado)) { throw new \RuntimeException('file_put_contents returns FALSE'); } } catch (\Throwable $error) { throw new \RuntimeException("Unable to write the certificate contents into $filename", 0, $error); } }
php
public function save(string $filename) { if ('' === $filename) { throw new \UnexpectedValueException('The filename to store the certificate is empty'); } $certificado = $this->extract(); if ('' === $certificado) { throw new \RuntimeException('The certificado attribute is empty'); } try { if (false === file_put_contents($filename, $certificado)) { throw new \RuntimeException('file_put_contents returns FALSE'); } } catch (\Throwable $error) { throw new \RuntimeException("Unable to write the certificate contents into $filename", 0, $error); } }
[ "public", "function", "save", "(", "string", "$", "filename", ")", "{", "if", "(", "''", "===", "$", "filename", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'The filename to store the certificate is empty'", ")", ";", "}", "$", "certificado...
Extract and save the certificate into an specified location @see extract @param string $filename @return void @throws \UnexpectedValueException if the filename to store the certificate is empty @throws \RuntimeException if the certificado attribute is empty @throws \RuntimeException if cannot write the contents of the certificate
[ "Extract", "and", "save", "the", "certificate", "into", "an", "specified", "location" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Certificado/NodeCertificado.php#L72-L88
train
eclipxe13/CfdiUtils
src/CfdiUtils/Certificado/NodeCertificado.php
NodeCertificado.obtain
public function obtain(): Certificado { $temporaryFile = TemporaryFile::create(); // the temporary name was created try { $this->save($temporaryFile->getPath()); $certificado = new Certificado($temporaryFile->getPath()); return $certificado; } finally { $temporaryFile->remove(); } }
php
public function obtain(): Certificado { $temporaryFile = TemporaryFile::create(); // the temporary name was created try { $this->save($temporaryFile->getPath()); $certificado = new Certificado($temporaryFile->getPath()); return $certificado; } finally { $temporaryFile->remove(); } }
[ "public", "function", "obtain", "(", ")", ":", "Certificado", "{", "$", "temporaryFile", "=", "TemporaryFile", "::", "create", "(", ")", ";", "// the temporary name was created", "try", "{", "$", "this", "->", "save", "(", "$", "temporaryFile", "->", "getPath"...
Return a Certificado object from the Comprobante->Certificado attribute The temporary certificate is stored into a temporary folder and removed after the certificado is loaded. If you need to persist the certificate use the saveCertificado method instead @see save @return Certificado
[ "Return", "a", "Certificado", "object", "from", "the", "Comprobante", "-", ">", "Certificado", "attribute", "The", "temporary", "certificate", "is", "stored", "into", "a", "temporary", "folder", "and", "removed", "after", "the", "certificado", "is", "loaded", "....
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Certificado/NodeCertificado.php#L100-L111
train
eclipxe13/CfdiUtils
src/CfdiUtils/Cleaner/Cleaner.php
Cleaner.staticClean
public static function staticClean($content): string { $cleaner = new self($content); $cleaner->clean(); return $cleaner->retrieveXml(); }
php
public static function staticClean($content): string { $cleaner = new self($content); $cleaner->clean(); return $cleaner->retrieveXml(); }
[ "public", "static", "function", "staticClean", "(", "$", "content", ")", ":", "string", "{", "$", "cleaner", "=", "new", "self", "(", "$", "content", ")", ";", "$", "cleaner", "->", "clean", "(", ")", ";", "return", "$", "cleaner", "->", "retrieveXml",...
Method to clean content and return the result If an error occurs, an exception is thrown @param string $content @return string
[ "Method", "to", "clean", "content", "and", "return", "the", "result", "If", "an", "error", "occurs", "an", "exception", "is", "thrown" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Cleaner/Cleaner.php#L39-L44
train
eclipxe13/CfdiUtils
src/CfdiUtils/Cleaner/Cleaner.php
Cleaner.load
public function load(string $content) { try { $cfdi = Cfdi::newFromString($content); } catch (\Throwable $exception) { throw new CleanerException($exception->getMessage(), $exception->getCode(), $exception->getPrevious()); } $version = $cfdi->getVersion(); if (! $this->isVersionAllowed($version)) { throw new CleanerException("The CFDI version '$version' is not allowed"); } $this->dom = $cfdi->getDocument(); }
php
public function load(string $content) { try { $cfdi = Cfdi::newFromString($content); } catch (\Throwable $exception) { throw new CleanerException($exception->getMessage(), $exception->getCode(), $exception->getPrevious()); } $version = $cfdi->getVersion(); if (! $this->isVersionAllowed($version)) { throw new CleanerException("The CFDI version '$version' is not allowed"); } $this->dom = $cfdi->getDocument(); }
[ "public", "function", "load", "(", "string", "$", "content", ")", "{", "try", "{", "$", "cfdi", "=", "Cfdi", "::", "newFromString", "(", "$", "content", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "exception", ")", "{", "throw", "new", "Clea...
Load the string content as a CFDI This is exposed to reuse the current object instead of create a new instance @param string $content @throws CleanerException when the content is not valid xml @throws CleanerException when the document does not use the namespace http://www.sat.gob.mx/cfd/3 @throws CleanerException when cannot find a Comprobante version (or Version) attribute @throws CleanerException when the version is not compatible @return void
[ "Load", "the", "string", "content", "as", "a", "CFDI", "This", "is", "exposed", "to", "reuse", "the", "current", "object", "instead", "of", "create", "a", "new", "instance" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Cleaner/Cleaner.php#L109-L121
train
eclipxe13/CfdiUtils
src/CfdiUtils/Cleaner/Cleaner.php
Cleaner.removeIncompleteSchemaLocations
public function removeIncompleteSchemaLocations() { $schemaLocations = $this->obtainXsiSchemaLocations(); for ($s = 0; $s < $schemaLocations->length; $s++) { $element = $schemaLocations->item($s); if (null !== $element) { $element->nodeValue = $this->removeIncompleteSchemaLocation($element->nodeValue); } } }
php
public function removeIncompleteSchemaLocations() { $schemaLocations = $this->obtainXsiSchemaLocations(); for ($s = 0; $s < $schemaLocations->length; $s++) { $element = $schemaLocations->item($s); if (null !== $element) { $element->nodeValue = $this->removeIncompleteSchemaLocation($element->nodeValue); } } }
[ "public", "function", "removeIncompleteSchemaLocations", "(", ")", "{", "$", "schemaLocations", "=", "$", "this", "->", "obtainXsiSchemaLocations", "(", ")", ";", "for", "(", "$", "s", "=", "0", ";", "$", "s", "<", "$", "schemaLocations", "->", "length", "...
Procedure to drop schemaLocations where second part does not ends with '.xsd' @return void
[ "Procedure", "to", "drop", "schemaLocations", "where", "second", "part", "does", "not", "ends", "with", ".", "xsd" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Cleaner/Cleaner.php#L166-L175
train
eclipxe13/CfdiUtils
src/CfdiUtils/Cleaner/Cleaner.php
Cleaner.removeNonSatNSschemaLocations
public function removeNonSatNSschemaLocations() { $schemaLocations = $this->obtainXsiSchemaLocations(); for ($s = 0; $s < $schemaLocations->length; $s++) { $element = $schemaLocations->item($s); if (null !== $element) { $this->removeNonSatNSschemaLocation($element); } } }
php
public function removeNonSatNSschemaLocations() { $schemaLocations = $this->obtainXsiSchemaLocations(); for ($s = 0; $s < $schemaLocations->length; $s++) { $element = $schemaLocations->item($s); if (null !== $element) { $this->removeNonSatNSschemaLocation($element); } } }
[ "public", "function", "removeNonSatNSschemaLocations", "(", ")", "{", "$", "schemaLocations", "=", "$", "this", "->", "obtainXsiSchemaLocations", "(", ")", ";", "for", "(", "$", "s", "=", "0", ";", "$", "s", "<", "$", "schemaLocations", "->", "length", ";"...
Procedure to drop schemaLocations that are not allowed If the schemaLocation is empty then remove the attribute @return void
[ "Procedure", "to", "drop", "schemaLocations", "that", "are", "not", "allowed", "If", "the", "schemaLocation", "is", "empty", "then", "remove", "the", "attribute" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Cleaner/Cleaner.php#L198-L207
train
eclipxe13/CfdiUtils
src/CfdiUtils/Cleaner/Cleaner.php
Cleaner.removeNonSatNSNode
private function removeNonSatNSNode(string $namespace) { foreach ($this->dom()->getElementsByTagNameNS($namespace, '*') as $children) { $children->parentNode->removeChild($children); } }
php
private function removeNonSatNSNode(string $namespace) { foreach ($this->dom()->getElementsByTagNameNS($namespace, '*') as $children) { $children->parentNode->removeChild($children); } }
[ "private", "function", "removeNonSatNSNode", "(", "string", "$", "namespace", ")", "{", "foreach", "(", "$", "this", "->", "dom", "(", ")", "->", "getElementsByTagNameNS", "(", "$", "namespace", ",", "'*'", ")", "as", "$", "children", ")", "{", "$", "chi...
Procedure to remove all nodes from an specific namespace @param string $namespace @return void
[ "Procedure", "to", "remove", "all", "nodes", "from", "an", "specific", "namespace" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Cleaner/Cleaner.php#L266-L271
train
eclipxe13/CfdiUtils
src/CfdiUtils/Nodes/Attributes.php
Attributes.set
public function set(string $name, string $value = null): self { if (null === $value) { $this->remove($name); return $this; } if (! Xml::isValidXmlName($name)) { throw new \UnexpectedValueException(sprintf('Cannot set attribute with an invalid xml name: "%s"', $name)); } $this->attributes[$name] = $value; return $this; }
php
public function set(string $name, string $value = null): self { if (null === $value) { $this->remove($name); return $this; } if (! Xml::isValidXmlName($name)) { throw new \UnexpectedValueException(sprintf('Cannot set attribute with an invalid xml name: "%s"', $name)); } $this->attributes[$name] = $value; return $this; }
[ "public", "function", "set", "(", "string", "$", "name", ",", "string", "$", "value", "=", "null", ")", ":", "self", "{", "if", "(", "null", "===", "$", "value", ")", "{", "$", "this", "->", "remove", "(", "$", "name", ")", ";", "return", "$", ...
Set a value in the collection @param string $name @param string|null $value If null then it will remove the value instead of setting to empty string @return self
[ "Set", "a", "value", "in", "the", "collection" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Nodes/Attributes.php#L31-L42
train
eclipxe13/CfdiUtils
src/CfdiUtils/Validate/Cfdi33/RecepcionPagos/Pagos/DoctoRelacionado.php
DoctoRelacionado.registerInAssets
public function registerInAssets(Asserts $asserts) { foreach ($this->validators as $validator) { $validator->registerInAssets($asserts); } }
php
public function registerInAssets(Asserts $asserts) { foreach ($this->validators as $validator) { $validator->registerInAssets($asserts); } }
[ "public", "function", "registerInAssets", "(", "Asserts", "$", "asserts", ")", "{", "foreach", "(", "$", "this", "->", "validators", "as", "$", "validator", ")", "{", "$", "validator", "->", "registerInAssets", "(", "$", "asserts", ")", ";", "}", "}" ]
override registerInAssets to add validators instead of itself
[ "override", "registerInAssets", "to", "add", "validators", "instead", "of", "itself" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Validate/Cfdi33/RecepcionPagos/Pagos/DoctoRelacionado.php#L46-L51
train
eclipxe13/CfdiUtils
src/CfdiUtils/XmlResolver/XmlResolver.php
XmlResolver.setDownloader
public function setDownloader(DownloaderInterface $downloader = null) { if (null === $downloader) { $downloader = $this->defaultDownloader(); } $this->downloader = $downloader; }
php
public function setDownloader(DownloaderInterface $downloader = null) { if (null === $downloader) { $downloader = $this->defaultDownloader(); } $this->downloader = $downloader; }
[ "public", "function", "setDownloader", "(", "DownloaderInterface", "$", "downloader", "=", "null", ")", "{", "if", "(", "null", "===", "$", "downloader", ")", "{", "$", "downloader", "=", "$", "this", "->", "defaultDownloader", "(", ")", ";", "}", "$", "...
Set the downloader object. If send a NULL value the object return by defaultDownloader will be set. @param DownloaderInterface|null $downloader
[ "Set", "the", "downloader", "object", ".", "If", "send", "a", "NULL", "value", "the", "object", "return", "by", "defaultDownloader", "will", "be", "set", "." ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/XmlResolver/XmlResolver.php#L87-L93
train
eclipxe13/CfdiUtils
src/CfdiUtils/XmlResolver/XmlResolver.php
XmlResolver.resolve
public function resolve(string $resource, string $type = ''): string { if (! $this->hasLocalPath()) { return $resource; } if ('' === $type) { $type = $this->obtainTypeFromUrl($resource); } else { $type = strtoupper($type); } $retriever = $this->newRetriever($type); if (null === $retriever) { throw new \RuntimeException("Unable to handle the resource (Type: $type) $resource"); } $local = $retriever->buildPath($resource); if (! file_exists($local)) { $retriever->retrieve($resource); } return $local; }
php
public function resolve(string $resource, string $type = ''): string { if (! $this->hasLocalPath()) { return $resource; } if ('' === $type) { $type = $this->obtainTypeFromUrl($resource); } else { $type = strtoupper($type); } $retriever = $this->newRetriever($type); if (null === $retriever) { throw new \RuntimeException("Unable to handle the resource (Type: $type) $resource"); } $local = $retriever->buildPath($resource); if (! file_exists($local)) { $retriever->retrieve($resource); } return $local; }
[ "public", "function", "resolve", "(", "string", "$", "resource", ",", "string", "$", "type", "=", "''", ")", ":", "string", "{", "if", "(", "!", "$", "this", "->", "hasLocalPath", "(", ")", ")", "{", "return", "$", "resource", ";", "}", "if", "(", ...
Resolve a resource to a local path. If it does not have a localPath then it will return the exact same resource @param string $resource The url @param string $type Allows XSD, XSLT and CER @return string
[ "Resolve", "a", "resource", "to", "a", "local", "path", ".", "If", "it", "does", "not", "have", "a", "localPath", "then", "it", "will", "return", "the", "exact", "same", "resource" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/XmlResolver/XmlResolver.php#L113-L132
train
eclipxe13/CfdiUtils
src/CfdiUtils/XmlResolver/XmlResolver.php
XmlResolver.newRetriever
public function newRetriever(string $type) { if (! $this->hasLocalPath()) { throw new \LogicException('Cannot create a retriever if no local path was found'); } if (static::TYPE_XSLT === $type) { return $this->newXsltRetriever(); } if (static::TYPE_XSD === $type) { return $this->newXsdRetriever(); } if (static::TYPE_CER === $type) { return $this->newCerRetriever(); } return null; }
php
public function newRetriever(string $type) { if (! $this->hasLocalPath()) { throw new \LogicException('Cannot create a retriever if no local path was found'); } if (static::TYPE_XSLT === $type) { return $this->newXsltRetriever(); } if (static::TYPE_XSD === $type) { return $this->newXsdRetriever(); } if (static::TYPE_CER === $type) { return $this->newCerRetriever(); } return null; }
[ "public", "function", "newRetriever", "(", "string", "$", "type", ")", "{", "if", "(", "!", "$", "this", "->", "hasLocalPath", "(", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Cannot create a retriever if no local path was found'", ")", ";", ...
Create a new retriever depending on the type parameter, only allow TYPE_XSLT and TYPE_XSD @param string $type @return RetrieverInterface|null
[ "Create", "a", "new", "retriever", "depending", "on", "the", "type", "parameter", "only", "allow", "TYPE_XSLT", "and", "TYPE_XSD" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/XmlResolver/XmlResolver.php#L164-L179
train
eclipxe13/CfdiUtils
src/CfdiUtils/Certificado/Certificado.php
Certificado.belongsTo
public function belongsTo(string $pemKeyFile, string $passPhrase = ''): bool { $this->assertFileExists($pemKeyFile); $openSSL = $this->getOpenSSL(); $keyContents = $openSSL->readPemContents( // intentionally silence this error, if return false then cast it to string strval(@file_get_contents($pemKeyFile)) )->privateKey(); if ('' === $keyContents) { throw new \UnexpectedValueException("The file $pemKeyFile is not a PEM private key"); } $privateKey = openssl_get_privatekey($keyContents, $passPhrase); if (false === $privateKey) { throw new \RuntimeException("Cannot open the private key file $pemKeyFile"); } $belongs = openssl_x509_check_private_key($this->getPemContents(), $privateKey); openssl_free_key($privateKey); return $belongs; }
php
public function belongsTo(string $pemKeyFile, string $passPhrase = ''): bool { $this->assertFileExists($pemKeyFile); $openSSL = $this->getOpenSSL(); $keyContents = $openSSL->readPemContents( // intentionally silence this error, if return false then cast it to string strval(@file_get_contents($pemKeyFile)) )->privateKey(); if ('' === $keyContents) { throw new \UnexpectedValueException("The file $pemKeyFile is not a PEM private key"); } $privateKey = openssl_get_privatekey($keyContents, $passPhrase); if (false === $privateKey) { throw new \RuntimeException("Cannot open the private key file $pemKeyFile"); } $belongs = openssl_x509_check_private_key($this->getPemContents(), $privateKey); openssl_free_key($privateKey); return $belongs; }
[ "public", "function", "belongsTo", "(", "string", "$", "pemKeyFile", ",", "string", "$", "passPhrase", "=", "''", ")", ":", "bool", "{", "$", "this", "->", "assertFileExists", "(", "$", "pemKeyFile", ")", ";", "$", "openSSL", "=", "$", "this", "->", "g...
Check if this certificate belongs to a private key @param string $pemKeyFile @param string $passPhrase @return bool @throws \UnexpectedValueException if the file does not exists or is not readable @throws \UnexpectedValueException if the file is not a PEM private key @throws \RuntimeException if cannot open the private key file
[ "Check", "if", "this", "certificate", "belongs", "to", "a", "private", "key" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Certificado/Certificado.php#L109-L127
train
eclipxe13/CfdiUtils
src/CfdiUtils/Certificado/Certificado.php
Certificado.verify
public function verify(string $data, string $signature, int $algorithm = OPENSSL_ALGO_SHA256): bool { $pubKey = openssl_get_publickey($this->getPubkey()); if (false === $pubKey) { throw new \RuntimeException('Cannot open public key from certificate'); } try { $verify = openssl_verify($data, $signature, $pubKey, $algorithm); if (-1 === $verify) { throw new \RuntimeException('OpenSSL Error: ' . openssl_error_string()); } } finally { openssl_free_key($pubKey); } return (1 === $verify); }
php
public function verify(string $data, string $signature, int $algorithm = OPENSSL_ALGO_SHA256): bool { $pubKey = openssl_get_publickey($this->getPubkey()); if (false === $pubKey) { throw new \RuntimeException('Cannot open public key from certificate'); } try { $verify = openssl_verify($data, $signature, $pubKey, $algorithm); if (-1 === $verify) { throw new \RuntimeException('OpenSSL Error: ' . openssl_error_string()); } } finally { openssl_free_key($pubKey); } return (1 === $verify); }
[ "public", "function", "verify", "(", "string", "$", "data", ",", "string", "$", "signature", ",", "int", "$", "algorithm", "=", "OPENSSL_ALGO_SHA256", ")", ":", "bool", "{", "$", "pubKey", "=", "openssl_get_publickey", "(", "$", "this", "->", "getPubkey", ...
Verify the signature of some data @param string $data @param string $signature @param int $algorithm @return bool @throws \RuntimeException if cannot open the public key from certificate @throws \RuntimeException if openssl report an error
[ "Verify", "the", "signature", "of", "some", "data" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Certificado/Certificado.php#L223-L238
train
eclipxe13/CfdiUtils
src/CfdiUtils/CadenaOrigen/CadenaOrigenLocations.php
CadenaOrigenLocations.getXsltLocation
public function getXsltLocation(string $version): string { if (array_key_exists($version, $this->xsltLocations)) { return $this->xsltLocations[$version]; } return ''; }
php
public function getXsltLocation(string $version): string { if (array_key_exists($version, $this->xsltLocations)) { return $this->xsltLocations[$version]; } return ''; }
[ "public", "function", "getXsltLocation", "(", "string", "$", "version", ")", ":", "string", "{", "if", "(", "array_key_exists", "(", "$", "version", ",", "$", "this", "->", "xsltLocations", ")", ")", "{", "return", "$", "this", "->", "xsltLocations", "[", ...
Return the registered location of the xslt file to perform the xml transformation depending on the cfdi version. This value can be changed using setXsltLocation @see setXsltLocation @param string $version @return string
[ "Return", "the", "registered", "location", "of", "the", "xslt", "file", "to", "perform", "the", "xml", "transformation", "depending", "on", "the", "cfdi", "version", ".", "This", "value", "can", "be", "changed", "using", "setXsltLocation" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/CadenaOrigen/CadenaOrigenLocations.php#L33-L39
train
eclipxe13/CfdiUtils
src/CfdiUtils/Nodes/NodesSorter.php
NodesSorter.setOrder
public function setOrder(array $names): bool { $order = array_flip($this->parseNames($names)); if ($this->order === $order) { return false; } $this->order = $order; $this->count = count($order); return true; }
php
public function setOrder(array $names): bool { $order = array_flip($this->parseNames($names)); if ($this->order === $order) { return false; } $this->order = $order; $this->count = count($order); return true; }
[ "public", "function", "setOrder", "(", "array", "$", "names", ")", ":", "bool", "{", "$", "order", "=", "array_flip", "(", "$", "this", "->", "parseNames", "(", "$", "names", ")", ")", ";", "if", "(", "$", "this", "->", "order", "===", "$", "order"...
It takes only the unique string names and sort using the order of appearance @param string[] $names @return bool true if the new names list is different from previous
[ "It", "takes", "only", "the", "unique", "string", "names", "and", "sort", "using", "the", "order", "of", "appearance" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Nodes/NodesSorter.php#L26-L35
train
eclipxe13/CfdiUtils
src/CfdiUtils/ConsultaCfdiSat/WebService.php
WebService.doRequestConsulta
protected function doRequestConsulta(string $expression) { /** @var int $encoding Override because inspectors does not know that second argument can be NULL */ $encoding = null; return $this->getSoapClient()->__soapCall( 'Consulta', [new \SoapVar($expression, $encoding, '', '', 'expresionImpresa', 'http://tempuri.org/')], ['soapaction' => 'http://tempuri.org/IConsultaCFDIService/Consulta'] ); }
php
protected function doRequestConsulta(string $expression) { /** @var int $encoding Override because inspectors does not know that second argument can be NULL */ $encoding = null; return $this->getSoapClient()->__soapCall( 'Consulta', [new \SoapVar($expression, $encoding, '', '', 'expresionImpresa', 'http://tempuri.org/')], ['soapaction' => 'http://tempuri.org/IConsultaCFDIService/Consulta'] ); }
[ "protected", "function", "doRequestConsulta", "(", "string", "$", "expression", ")", "{", "/** @var int $encoding Override because inspectors does not know that second argument can be NULL */", "$", "encoding", "=", "null", ";", "return", "$", "this", "->", "getSoapClient", "...
This method exists to be able to mock SOAP call @internal @param string $expression @return null|\stdClass
[ "This", "method", "exists", "to", "be", "able", "to", "mock", "SOAP", "call" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/ConsultaCfdiSat/WebService.php#L100-L109
train
eclipxe13/CfdiUtils
src/CfdiUtils/Utils/Rfc.php
Rfc.obtainDate
public static function obtainDate(string $rfc): int { // rfc is multibyte $begin = (mb_strlen($rfc) === 12) ? 3 : 4; // strdate is not multibyte $strdate = strval(mb_substr($rfc, $begin, 6)); $parts = str_split($strdate, 2); // year 2000 is leap year (%4 & %100 & %400) /** @var int|false $date phpstan does not know that mktime can return false */ $date = mktime(0, 0, 0, (int) $parts[1], (int) $parts[2], (int) ('20' . $parts[0])); if (false === $date) { return 0; } if (date('ymd', $date) !== $strdate) { return 0; } return $date; }
php
public static function obtainDate(string $rfc): int { // rfc is multibyte $begin = (mb_strlen($rfc) === 12) ? 3 : 4; // strdate is not multibyte $strdate = strval(mb_substr($rfc, $begin, 6)); $parts = str_split($strdate, 2); // year 2000 is leap year (%4 & %100 & %400) /** @var int|false $date phpstan does not know that mktime can return false */ $date = mktime(0, 0, 0, (int) $parts[1], (int) $parts[2], (int) ('20' . $parts[0])); if (false === $date) { return 0; } if (date('ymd', $date) !== $strdate) { return 0; } return $date; }
[ "public", "static", "function", "obtainDate", "(", "string", "$", "rfc", ")", ":", "int", "{", "// rfc is multibyte", "$", "begin", "=", "(", "mb_strlen", "(", "$", "rfc", ")", "===", "12", ")", "?", "3", ":", "4", ";", "// strdate is not multibyte", "$"...
The date is always from the year 2000 since RFC does not provide century and 000229 is valid. Please, change this function on year 2100! @param string $rfc @return int
[ "The", "date", "is", "always", "from", "the", "year", "2000", "since", "RFC", "does", "not", "provide", "century", "and", "000229", "is", "valid", ".", "Please", "change", "this", "function", "on", "year", "2100!" ]
e252bc8f8272aecb82646523809dcc4640a3fb60
https://github.com/eclipxe13/CfdiUtils/blob/e252bc8f8272aecb82646523809dcc4640a3fb60/src/CfdiUtils/Utils/Rfc.php#L142-L159
train
commercetools/commercetools-php-sdk
src/Core/Cache/CacheAdapterFactory.php
CacheAdapterFactory.get
public function get($cache = null) { if (is_null($cache)) { $cache = $this->getDefaultCache(); } if ($cache instanceof CacheItemPoolInterface) { return $cache; } if ($cache instanceof CacheInterface) { return $cache; } foreach ($this->callbacks as $callBack) { $result = call_user_func($callBack, $cache); if ($result instanceof CacheItemPoolInterface) { return $result; } if ($result instanceof CacheInterface) { return $result; } } throw new InvalidArgumentException(Message::INVALID_CACHE_ADAPTER); }
php
public function get($cache = null) { if (is_null($cache)) { $cache = $this->getDefaultCache(); } if ($cache instanceof CacheItemPoolInterface) { return $cache; } if ($cache instanceof CacheInterface) { return $cache; } foreach ($this->callbacks as $callBack) { $result = call_user_func($callBack, $cache); if ($result instanceof CacheItemPoolInterface) { return $result; } if ($result instanceof CacheInterface) { return $result; } } throw new InvalidArgumentException(Message::INVALID_CACHE_ADAPTER); }
[ "public", "function", "get", "(", "$", "cache", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "cache", ")", ")", "{", "$", "cache", "=", "$", "this", "->", "getDefaultCache", "(", ")", ";", "}", "if", "(", "$", "cache", "instanceof", "Ca...
returns the cache adapter interface for the application cache @param $cache @return CacheItemPoolInterface|CacheInterface @throws \InvalidArgumentException
[ "returns", "the", "cache", "adapter", "interface", "for", "the", "application", "cache" ]
53ac8b0929b56e10bc7f05d1b363688cd7038184
https://github.com/commercetools/commercetools-php-sdk/blob/53ac8b0929b56e10bc7f05d1b363688cd7038184/src/Core/Cache/CacheAdapterFactory.php#L77-L101
train
commercetools/commercetools-php-sdk
src/Core/Cache/CacheAdapterFactory.php
CacheAdapterFactory.getDefaultCache
protected function getDefaultCache() { if (extension_loaded('apcu')) { return new ApcuCachePool(); } if (class_exists('\Cache\Adapter\Filesystem\FilesystemCachePool')) { $filesystemAdapter = new Local($this->cacheDir); $filesystem = new Filesystem($filesystemAdapter); return new FilesystemCachePool($filesystem); } return null; }
php
protected function getDefaultCache() { if (extension_loaded('apcu')) { return new ApcuCachePool(); } if (class_exists('\Cache\Adapter\Filesystem\FilesystemCachePool')) { $filesystemAdapter = new Local($this->cacheDir); $filesystem = new Filesystem($filesystemAdapter); return new FilesystemCachePool($filesystem); } return null; }
[ "protected", "function", "getDefaultCache", "(", ")", "{", "if", "(", "extension_loaded", "(", "'apcu'", ")", ")", "{", "return", "new", "ApcuCachePool", "(", ")", ";", "}", "if", "(", "class_exists", "(", "'\\Cache\\Adapter\\Filesystem\\FilesystemCachePool'", ")"...
creates a default cache adapter if no cache has been provided @return CacheItemPoolInterface|null
[ "creates", "a", "default", "cache", "adapter", "if", "no", "cache", "has", "been", "provided" ]
53ac8b0929b56e10bc7f05d1b363688cd7038184
https://github.com/commercetools/commercetools-php-sdk/blob/53ac8b0929b56e10bc7f05d1b363688cd7038184/src/Core/Cache/CacheAdapterFactory.php#L108-L121
train
commercetools/commercetools-php-sdk
src/Core/Helper/State/Renderer.php
Renderer.getNodeRendererByStateName
public function getNodeRendererByStateName($stateName) { if (isset($this->nodeRenderers[$stateName])) { return $this->nodeRenderers[$stateName]; } return new NodeRenderer(); }
php
public function getNodeRendererByStateName($stateName) { if (isset($this->nodeRenderers[$stateName])) { return $this->nodeRenderers[$stateName]; } return new NodeRenderer(); }
[ "public", "function", "getNodeRendererByStateName", "(", "$", "stateName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "nodeRenderers", "[", "$", "stateName", "]", ")", ")", "{", "return", "$", "this", "->", "nodeRenderers", "[", "$", "stateName"...
Get the renderer for the given state name. If no renderer was set the default renderer Bob_StateMachine_Renderer_Node_DefaultRenderer() is returned @param $stateName @return NodeRenderer
[ "Get", "the", "renderer", "for", "the", "given", "state", "name", "." ]
53ac8b0929b56e10bc7f05d1b363688cd7038184
https://github.com/commercetools/commercetools-php-sdk/blob/53ac8b0929b56e10bc7f05d1b363688cd7038184/src/Core/Helper/State/Renderer.php#L155-L161
train
commercetools/commercetools-php-sdk
src/Core/Helper/State/Renderer.php
Renderer.runDot
public function runDot($dotString) { $descriptorSpec = array( 0 => array("pipe", "r"), // stdin 1 => array("pipe", "w"), // stdout 2 => array("pipe", "a") // stderr ); $process = proc_open('dot -Tsvg', $descriptorSpec, $pipes); if (is_resource($process)) { fwrite($pipes[0], $dotString); fclose($pipes[0]); $svg = stream_get_contents($pipes[1]); fclose($pipes[1]); proc_close($process); $svg = explode('<svg ', $svg); // has it worked out? if (count($svg) < 2) { return false; } return '<svg ' . $svg[1]; } return false; }
php
public function runDot($dotString) { $descriptorSpec = array( 0 => array("pipe", "r"), // stdin 1 => array("pipe", "w"), // stdout 2 => array("pipe", "a") // stderr ); $process = proc_open('dot -Tsvg', $descriptorSpec, $pipes); if (is_resource($process)) { fwrite($pipes[0], $dotString); fclose($pipes[0]); $svg = stream_get_contents($pipes[1]); fclose($pipes[1]); proc_close($process); $svg = explode('<svg ', $svg); // has it worked out? if (count($svg) < 2) { return false; } return '<svg ' . $svg[1]; } return false; }
[ "public", "function", "runDot", "(", "$", "dotString", ")", "{", "$", "descriptorSpec", "=", "array", "(", "0", "=>", "array", "(", "\"pipe\"", ",", "\"r\"", ")", ",", "// stdin", "1", "=>", "array", "(", "\"pipe\"", ",", "\"w\"", ")", ",", "// stdout"...
Renders a dot graph into an svg @param string $dotString The dot graph that is fed into the @return string|bool the resulting SVG
[ "Renders", "a", "dot", "graph", "into", "an", "svg" ]
53ac8b0929b56e10bc7f05d1b363688cd7038184
https://github.com/commercetools/commercetools-php-sdk/blob/53ac8b0929b56e10bc7f05d1b363688cd7038184/src/Core/Helper/State/Renderer.php#L177-L206
train
commercetools/commercetools-php-sdk
src/Core/Helper/State/Renderer.php
Renderer.renderDot
public function renderDot(StateCollection $stateCollection) { // define the graph $graph = 'digraph ' . 'test' . ' { dpi="56";compound="true";fontname="Arial";margin="";nodesep="0.6";rankdir="TD";ranksep="0.4";' . PHP_EOL; // add all states to the graph foreach ($stateCollection as $state) { $nodeRenderer = $this->getNodeRendererByStateName($state->getKey()); $graph .= ' ' . $nodeRenderer->render($state); } // add all transitions to the graph foreach ($stateCollection as $state) { $nodeRenderer = $this->getTransitionRendererByStateName($state->getKey()); $graph .= ' ' . $nodeRenderer->render($state); } $graph .= '}' . PHP_EOL; return $graph; }
php
public function renderDot(StateCollection $stateCollection) { // define the graph $graph = 'digraph ' . 'test' . ' { dpi="56";compound="true";fontname="Arial";margin="";nodesep="0.6";rankdir="TD";ranksep="0.4";' . PHP_EOL; // add all states to the graph foreach ($stateCollection as $state) { $nodeRenderer = $this->getNodeRendererByStateName($state->getKey()); $graph .= ' ' . $nodeRenderer->render($state); } // add all transitions to the graph foreach ($stateCollection as $state) { $nodeRenderer = $this->getTransitionRendererByStateName($state->getKey()); $graph .= ' ' . $nodeRenderer->render($state); } $graph .= '}' . PHP_EOL; return $graph; }
[ "public", "function", "renderDot", "(", "StateCollection", "$", "stateCollection", ")", "{", "// define the graph", "$", "graph", "=", "'digraph '", ".", "'test'", ".", "' { dpi=\"56\";compound=\"true\";fontname=\"Arial\";margin=\"\";nodesep=\"0.6\";rankdir=\"TD\";ranksep=\"0.4\";'...
Creates a dot graph for a process @param StateCollection $stateCollection @return string A dot graph
[ "Creates", "a", "dot", "graph", "for", "a", "process" ]
53ac8b0929b56e10bc7f05d1b363688cd7038184
https://github.com/commercetools/commercetools-php-sdk/blob/53ac8b0929b56e10bc7f05d1b363688cd7038184/src/Core/Helper/State/Renderer.php#L214-L237
train
commercetools/commercetools-php-sdk
src/Core/Response/AbstractApiResponse.php
AbstractApiResponse.wait
public function wait() { if (!$this->getResponse() instanceof AdapterPromiseInterface) { throw new \BadMethodCallException(Message::FUTURE_BAD_METHOD_CALL); } return $this->getResponse()->wait(); }
php
public function wait() { if (!$this->getResponse() instanceof AdapterPromiseInterface) { throw new \BadMethodCallException(Message::FUTURE_BAD_METHOD_CALL); } return $this->getResponse()->wait(); }
[ "public", "function", "wait", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getResponse", "(", ")", "instanceof", "AdapterPromiseInterface", ")", "{", "throw", "new", "\\", "BadMethodCallException", "(", "Message", "::", "FUTURE_BAD_METHOD_CALL", ")", ";"...
Returns the result of the future either from cache or by blocking until it is complete. This method must block until the future has a result or is cancelled. Throwing an exception in the wait() method will mark the future as realized and will throw the exception each time wait() is called. Throwing an instance of GuzzleHttp\Ring\CancelledException will mark the future as realized, will not throw immediately, but will throw the exception if the future's wait() method is called again. @return mixed
[ "Returns", "the", "result", "of", "the", "future", "either", "from", "cache", "or", "by", "blocking", "until", "it", "is", "complete", "." ]
53ac8b0929b56e10bc7f05d1b363688cd7038184
https://github.com/commercetools/commercetools-php-sdk/blob/53ac8b0929b56e10bc7f05d1b363688cd7038184/src/Core/Response/AbstractApiResponse.php#L190-L197
train
commercetools/commercetools-php-sdk
src/Core/Client.php
Client.execute
public function execute(ClientRequestInterface $request, array $headers = null, array $clientOptions = []) { if ($request instanceof ContextAwareInterface) { $request->setContextIfNull($this->getConfig()->getContext()); } $httpRequest = $this->createHttpRequest($request, $headers); try { $client = $this->getHttpClient(); if ($client instanceof AdapterOptionInterface) { $httpResponse = $client->execute($httpRequest, $clientOptions); } else { $httpResponse = $client->execute($httpRequest); } $response = $request->buildResponse($httpResponse); } catch (ApiException $exception) { if ($exception instanceof InvalidTokenException && !$this->tokenRefreshed) { $this->tokenRefreshed = true; $this->getOauthManager()->refreshToken(); return $this->execute($request); } if ($this->getConfig()->getThrowExceptions() || !$exception->getResponse() instanceof ResponseInterface) { throw $exception; } $httpResponse = $exception->getResponse(); $this->logException($exception); $response = new ErrorResponse($exception, $request, $httpResponse); } $this->logDeprecatedRequest($httpResponse, $httpRequest); return $response; }
php
public function execute(ClientRequestInterface $request, array $headers = null, array $clientOptions = []) { if ($request instanceof ContextAwareInterface) { $request->setContextIfNull($this->getConfig()->getContext()); } $httpRequest = $this->createHttpRequest($request, $headers); try { $client = $this->getHttpClient(); if ($client instanceof AdapterOptionInterface) { $httpResponse = $client->execute($httpRequest, $clientOptions); } else { $httpResponse = $client->execute($httpRequest); } $response = $request->buildResponse($httpResponse); } catch (ApiException $exception) { if ($exception instanceof InvalidTokenException && !$this->tokenRefreshed) { $this->tokenRefreshed = true; $this->getOauthManager()->refreshToken(); return $this->execute($request); } if ($this->getConfig()->getThrowExceptions() || !$exception->getResponse() instanceof ResponseInterface) { throw $exception; } $httpResponse = $exception->getResponse(); $this->logException($exception); $response = new ErrorResponse($exception, $request, $httpResponse); } $this->logDeprecatedRequest($httpResponse, $httpRequest); return $response; }
[ "public", "function", "execute", "(", "ClientRequestInterface", "$", "request", ",", "array", "$", "headers", "=", "null", ",", "array", "$", "clientOptions", "=", "[", "]", ")", "{", "if", "(", "$", "request", "instanceof", "ContextAwareInterface", ")", "{"...
Executes an API request synchronously @param ClientRequestInterface $request @param array $headers @param array $clientOptions @return ApiResponseInterface @throws ApiException @throws InvalidTokenException
[ "Executes", "an", "API", "request", "synchronously" ]
53ac8b0929b56e10bc7f05d1b363688cd7038184
https://github.com/commercetools/commercetools-php-sdk/blob/53ac8b0929b56e10bc7f05d1b363688cd7038184/src/Core/Client.php#L250-L282
train
commercetools/commercetools-php-sdk
src/Core/Client.php
Client.executeAsync
public function executeAsync(ClientRequestInterface $request, array $headers = null, array $clientOptions = []) { if ($request instanceof ContextAwareInterface) { $request->setContextIfNull($this->getConfig()->getContext()); } $httpRequest = $this->createHttpRequest($request, $headers); $client = $this->getHttpClient(); if ($client instanceof AdapterOptionInterface) { $response = $request->buildResponse($client->executeAsync($httpRequest, $clientOptions)); } else { $response = $request->buildResponse($client->executeAsync($httpRequest)); } $response = $response->then( function ($httpResponse) use ($httpRequest) { $this->logDeprecatedRequest($httpResponse, $httpRequest); return $httpResponse; } ); return $response; }
php
public function executeAsync(ClientRequestInterface $request, array $headers = null, array $clientOptions = []) { if ($request instanceof ContextAwareInterface) { $request->setContextIfNull($this->getConfig()->getContext()); } $httpRequest = $this->createHttpRequest($request, $headers); $client = $this->getHttpClient(); if ($client instanceof AdapterOptionInterface) { $response = $request->buildResponse($client->executeAsync($httpRequest, $clientOptions)); } else { $response = $request->buildResponse($client->executeAsync($httpRequest)); } $response = $response->then( function ($httpResponse) use ($httpRequest) { $this->logDeprecatedRequest($httpResponse, $httpRequest); return $httpResponse; } ); return $response; }
[ "public", "function", "executeAsync", "(", "ClientRequestInterface", "$", "request", ",", "array", "$", "headers", "=", "null", ",", "array", "$", "clientOptions", "=", "[", "]", ")", "{", "if", "(", "$", "request", "instanceof", "ContextAwareInterface", ")", ...
Executes an API request asynchronously @param ClientRequestInterface $request @param array $clientOptions @return ApiResponseInterface
[ "Executes", "an", "API", "request", "asynchronously" ]
53ac8b0929b56e10bc7f05d1b363688cd7038184
https://github.com/commercetools/commercetools-php-sdk/blob/53ac8b0929b56e10bc7f05d1b363688cd7038184/src/Core/Client.php#L290-L311
train
commercetools/commercetools-php-sdk
src/Core/Client.php
Client.executeBatch
public function executeBatch(array $headers = null, array $clientOptions = []) { $requests = $this->getBatchHttpRequests($headers); $client = $this->getHttpClient(); if ($client instanceof AdapterOptionInterface) { $httpResponses = $client->executeBatch($requests, $clientOptions); } else { $httpResponses = $client->executeBatch($requests); } $responses = []; foreach ($httpResponses as $key => $httpResponse) { $request = $this->batchRequests[$key]; $httpRequest = $requests[$key]; if ($httpResponse instanceof ApiException) { $exception = $httpResponse; if ($this->getConfig()->getThrowExceptions() || !$httpResponse->getResponse() instanceof ResponseInterface ) { throw $exception; } $this->logException($httpResponse); $httpResponse = $exception->getResponse(); $responses[$request->getIdentifier()] = new ErrorResponse( $exception, $request, $httpResponse ); } else { $responses[$request->getIdentifier()] = $request->buildResponse($httpResponse); } $this->logDeprecatedRequest($httpResponse, $httpRequest); } unset($this->batchRequests); $this->batchRequests = []; return $responses; }
php
public function executeBatch(array $headers = null, array $clientOptions = []) { $requests = $this->getBatchHttpRequests($headers); $client = $this->getHttpClient(); if ($client instanceof AdapterOptionInterface) { $httpResponses = $client->executeBatch($requests, $clientOptions); } else { $httpResponses = $client->executeBatch($requests); } $responses = []; foreach ($httpResponses as $key => $httpResponse) { $request = $this->batchRequests[$key]; $httpRequest = $requests[$key]; if ($httpResponse instanceof ApiException) { $exception = $httpResponse; if ($this->getConfig()->getThrowExceptions() || !$httpResponse->getResponse() instanceof ResponseInterface ) { throw $exception; } $this->logException($httpResponse); $httpResponse = $exception->getResponse(); $responses[$request->getIdentifier()] = new ErrorResponse( $exception, $request, $httpResponse ); } else { $responses[$request->getIdentifier()] = $request->buildResponse($httpResponse); } $this->logDeprecatedRequest($httpResponse, $httpRequest); } unset($this->batchRequests); $this->batchRequests = []; return $responses; }
[ "public", "function", "executeBatch", "(", "array", "$", "headers", "=", "null", ",", "array", "$", "clientOptions", "=", "[", "]", ")", "{", "$", "requests", "=", "$", "this", "->", "getBatchHttpRequests", "(", "$", "headers", ")", ";", "$", "client", ...
Executes API requests in batch @param array $headers @param array $clientOptions @return ApiResponseInterface[] @throws ApiException
[ "Executes", "API", "requests", "in", "batch" ]
53ac8b0929b56e10bc7f05d1b363688cd7038184
https://github.com/commercetools/commercetools-php-sdk/blob/53ac8b0929b56e10bc7f05d1b363688cd7038184/src/Core/Client.php#L345-L382
train
commercetools/commercetools-php-sdk
src/Core/Client.php
Client.addBatchRequest
public function addBatchRequest(ClientRequestInterface $request) { if ($request instanceof ContextAwareInterface) { $request->setContextIfNull($this->getConfig()->getContext()); } $this->batchRequests[] = $request; return $this; }
php
public function addBatchRequest(ClientRequestInterface $request) { if ($request instanceof ContextAwareInterface) { $request->setContextIfNull($this->getConfig()->getContext()); } $this->batchRequests[] = $request; return $this; }
[ "public", "function", "addBatchRequest", "(", "ClientRequestInterface", "$", "request", ")", "{", "if", "(", "$", "request", "instanceof", "ContextAwareInterface", ")", "{", "$", "request", "->", "setContextIfNull", "(", "$", "this", "->", "getConfig", "(", ")",...
Adds a request to the batch execution queue @param ClientRequestInterface $request @return $this
[ "Adds", "a", "request", "to", "the", "batch", "execution", "queue" ]
53ac8b0929b56e10bc7f05d1b363688cd7038184
https://github.com/commercetools/commercetools-php-sdk/blob/53ac8b0929b56e10bc7f05d1b363688cd7038184/src/Core/Client.php#L467-L474
train
commercetools/commercetools-php-sdk
src/Core/Client/Adapter/Guzzle6Adapter.php
Guzzle6Adapter.log
private static function log(LoggerInterface $logger, MessageFormatter $formatter, $logLevel = LogLevel::INFO) { return function (callable $handler) use ($logger, $formatter, $logLevel) { return function ($request, array $options) use ($handler, $logger, $formatter, $logLevel) { return $handler($request, $options)->then( function ($response) use ($logger, $request, $formatter, $logLevel) { $message = $formatter->format($request, $response); $context = [ AbstractApiResponse::X_CORRELATION_ID => $response->getHeader( AbstractApiResponse::X_CORRELATION_ID ) ]; $logger->log($logLevel, $message, $context); return $response; }, function ($reason) use ($logger, $request, $formatter) { $response = null; $context = []; if ($reason instanceof RequestException) { $response = $reason->getResponse(); if (!is_null($response)) { $context[AbstractApiResponse::X_CORRELATION_ID] = $response->getHeader( AbstractApiResponse::X_CORRELATION_ID ); } } $message = $formatter->format($request, $response, $reason); $logger->notice($message, $context); return \GuzzleHttp\Promise\rejection_for($reason); } ); }; }; }
php
private static function log(LoggerInterface $logger, MessageFormatter $formatter, $logLevel = LogLevel::INFO) { return function (callable $handler) use ($logger, $formatter, $logLevel) { return function ($request, array $options) use ($handler, $logger, $formatter, $logLevel) { return $handler($request, $options)->then( function ($response) use ($logger, $request, $formatter, $logLevel) { $message = $formatter->format($request, $response); $context = [ AbstractApiResponse::X_CORRELATION_ID => $response->getHeader( AbstractApiResponse::X_CORRELATION_ID ) ]; $logger->log($logLevel, $message, $context); return $response; }, function ($reason) use ($logger, $request, $formatter) { $response = null; $context = []; if ($reason instanceof RequestException) { $response = $reason->getResponse(); if (!is_null($response)) { $context[AbstractApiResponse::X_CORRELATION_ID] = $response->getHeader( AbstractApiResponse::X_CORRELATION_ID ); } } $message = $formatter->format($request, $response, $reason); $logger->notice($message, $context); return \GuzzleHttp\Promise\rejection_for($reason); } ); }; }; }
[ "private", "static", "function", "log", "(", "LoggerInterface", "$", "logger", ",", "MessageFormatter", "$", "formatter", ",", "$", "logLevel", "=", "LogLevel", "::", "INFO", ")", "{", "return", "function", "(", "callable", "$", "handler", ")", "use", "(", ...
Middleware that logs requests, responses, and errors using a message formatter. @param LoggerInterface $logger Logs messages. @param MessageFormatter $formatter Formatter used to create message strings. @param string $logLevel Level at which to log requests. @return callable Returns a function that accepts the next handler.
[ "Middleware", "that", "logs", "requests", "responses", "and", "errors", "using", "a", "message", "formatter", "." ]
53ac8b0929b56e10bc7f05d1b363688cd7038184
https://github.com/commercetools/commercetools-php-sdk/blob/53ac8b0929b56e10bc7f05d1b363688cd7038184/src/Core/Client/Adapter/Guzzle6Adapter.php#L89-L122
train
crisu83/yiistrap
behaviors/TbWidget.php
TbWidget.resolveId
public function resolveId($id = null) { if ($id === null) { $id = $this->owner->getId(); } if (isset($this->owner->htmlOptions['id'])) { $id = $this->owner->htmlOptions['id']; } else { $this->owner->htmlOptions['id'] = $id; } return $id; }
php
public function resolveId($id = null) { if ($id === null) { $id = $this->owner->getId(); } if (isset($this->owner->htmlOptions['id'])) { $id = $this->owner->htmlOptions['id']; } else { $this->owner->htmlOptions['id'] = $id; } return $id; }
[ "public", "function", "resolveId", "(", "$", "id", "=", "null", ")", "{", "if", "(", "$", "id", "===", "null", ")", "{", "$", "id", "=", "$", "this", "->", "owner", "->", "getId", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->"...
Returns the widget id and copies it to HTML attributes or vice versa. @param string $id the widget id. @return string the widget id.
[ "Returns", "the", "widget", "id", "and", "copies", "it", "to", "HTML", "attributes", "or", "vice", "versa", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/behaviors/TbWidget.php#L25-L36
train
crisu83/yiistrap
behaviors/TbWidget.php
TbWidget.copyId
public function copyId() { // todo: remove this when it's safe to do so. if (!isset($this->owner->htmlOptions['id'])) { $this->owner->htmlOptions['id'] = $this->owner->id; } else { $this->owner->id = $this->owner->htmlOptions['id']; } }
php
public function copyId() { // todo: remove this when it's safe to do so. if (!isset($this->owner->htmlOptions['id'])) { $this->owner->htmlOptions['id'] = $this->owner->id; } else { $this->owner->id = $this->owner->htmlOptions['id']; } }
[ "public", "function", "copyId", "(", ")", "{", "// todo: remove this when it's safe to do so.", "if", "(", "!", "isset", "(", "$", "this", "->", "owner", "->", "htmlOptions", "[", "'id'", "]", ")", ")", "{", "$", "this", "->", "owner", "->", "htmlOptions", ...
Copies the id to the widget HTML attributes or vise versa. @deprecated by TbWidget::resolveId
[ "Copies", "the", "id", "to", "the", "widget", "HTML", "attributes", "or", "vise", "versa", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/behaviors/TbWidget.php#L42-L50
train
crisu83/yiistrap
behaviors/TbWidget.php
TbWidget.publishAssets
public function publishAssets($path, $forceCopy = false) { if (!Yii::app()->hasComponent('assetManager')) { throw new CException('Failed to locate the asset manager component.'); } /* @var CAssetManager $assetManager */ $assetManager = Yii::app()->getComponent('assetManager'); $assetsUrl = $assetManager->publish($path, false, -1, $forceCopy); return $this->_assetsUrl = $assetsUrl; }
php
public function publishAssets($path, $forceCopy = false) { if (!Yii::app()->hasComponent('assetManager')) { throw new CException('Failed to locate the asset manager component.'); } /* @var CAssetManager $assetManager */ $assetManager = Yii::app()->getComponent('assetManager'); $assetsUrl = $assetManager->publish($path, false, -1, $forceCopy); return $this->_assetsUrl = $assetsUrl; }
[ "public", "function", "publishAssets", "(", "$", "path", ",", "$", "forceCopy", "=", "false", ")", "{", "if", "(", "!", "Yii", "::", "app", "(", ")", "->", "hasComponent", "(", "'assetManager'", ")", ")", "{", "throw", "new", "CException", "(", "'Faile...
Publishes an asset path. @param string $path the assets path. @param boolean $forceCopy whether we should copy the asset files even if they are already published before. @return string the url. @throws CException if the asset manager cannot be located.
[ "Publishes", "an", "asset", "path", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/behaviors/TbWidget.php#L59-L68
train
crisu83/yiistrap
behaviors/TbWidget.php
TbWidget.resolveScriptVersion
public function resolveScriptVersion($filename, $minified = false) { list($name, $extension) = str_split($filename, strrpos($filename, '.') + 1); return !$minified ? $name . $extension : $name . 'min.' . $extension; }
php
public function resolveScriptVersion($filename, $minified = false) { list($name, $extension) = str_split($filename, strrpos($filename, '.') + 1); return !$minified ? $name . $extension : $name . 'min.' . $extension; }
[ "public", "function", "resolveScriptVersion", "(", "$", "filename", ",", "$", "minified", "=", "false", ")", "{", "list", "(", "$", "name", ",", "$", "extension", ")", "=", "str_split", "(", "$", "filename", ",", "strrpos", "(", "$", "filename", ",", "...
Returns the name of the correct script file to use. @param string $filename the base file name. @param boolean $minified whether to include the minified version (defaults to false). @return string the full filename.
[ "Returns", "the", "name", "of", "the", "correct", "script", "file", "to", "use", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/behaviors/TbWidget.php#L102-L106
train
crisu83/yiistrap
behaviors/TbWidget.php
TbWidget.registerPlugin
public function registerPlugin($name, $selector, $options = array(), $position = CClientScript::POS_END) { if (($api = $this->getApi()) !== null) { $api->registerPlugin($name, $selector, $options, $position); return true; } return false; }
php
public function registerPlugin($name, $selector, $options = array(), $position = CClientScript::POS_END) { if (($api = $this->getApi()) !== null) { $api->registerPlugin($name, $selector, $options, $position); return true; } return false; }
[ "public", "function", "registerPlugin", "(", "$", "name", ",", "$", "selector", ",", "$", "options", "=", "array", "(", ")", ",", "$", "position", "=", "CClientScript", "::", "POS_END", ")", "{", "if", "(", "(", "$", "api", "=", "$", "this", "->", ...
Registers the given plugin with the API. @param string $name the plugin name. @param string $selector the CSS selector. @param array $options the JavaScript options for the plugin. @param int $position the position of the JavaScript code. @return boolean whether the plugin was registered.
[ "Registers", "the", "given", "plugin", "with", "the", "API", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/behaviors/TbWidget.php#L116-L123
train
crisu83/yiistrap
behaviors/TbWidget.php
TbWidget.registerEvents
public function registerEvents($selector, $events, $position = CClientScript::POS_END) { if (($api = $this->getApi()) !== null) { $api->registerEvents($selector, $events, $position); return true; } return false; }
php
public function registerEvents($selector, $events, $position = CClientScript::POS_END) { if (($api = $this->getApi()) !== null) { $api->registerEvents($selector, $events, $position); return true; } return false; }
[ "public", "function", "registerEvents", "(", "$", "selector", ",", "$", "events", ",", "$", "position", "=", "CClientScript", "::", "POS_END", ")", "{", "if", "(", "(", "$", "api", "=", "$", "this", "->", "getApi", "(", ")", ")", "!==", "null", ")", ...
Registers plugin events with the API. @param string $selector the CSS selector. @param string[] $events the JavaScript event configuration (name=>handler). @param int $position the position of the JavaScript code. @return boolean whether the events were registered.
[ "Registers", "plugin", "events", "with", "the", "API", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/behaviors/TbWidget.php#L132-L139
train
crisu83/yiistrap
behaviors/TbWidget.php
TbWidget.getApi
protected function getApi() { if (isset($this->_api)) { return $this->_api; } else { return $this->_api = Yii::app()->getComponent('bootstrap'); } }
php
protected function getApi() { if (isset($this->_api)) { return $this->_api; } else { return $this->_api = Yii::app()->getComponent('bootstrap'); } }
[ "protected", "function", "getApi", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_api", ")", ")", "{", "return", "$", "this", "->", "_api", ";", "}", "else", "{", "return", "$", "this", "->", "_api", "=", "Yii", "::", "app", "(", ...
Returns the API instance. @return TbApi the api.
[ "Returns", "the", "API", "instance", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/behaviors/TbWidget.php#L145-L152
train
crisu83/yiistrap
behaviors/TbWidget.php
TbWidget.getClientScript
protected function getClientScript() { if (isset($this->_clientScript)) { return $this->_clientScript; } else { if (!Yii::app()->hasComponent('clientScript')) { return false; } return $this->_clientScript = Yii::app()->getComponent('clientScript'); } }
php
protected function getClientScript() { if (isset($this->_clientScript)) { return $this->_clientScript; } else { if (!Yii::app()->hasComponent('clientScript')) { return false; } return $this->_clientScript = Yii::app()->getComponent('clientScript'); } }
[ "protected", "function", "getClientScript", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_clientScript", ")", ")", "{", "return", "$", "this", "->", "_clientScript", ";", "}", "else", "{", "if", "(", "!", "Yii", "::", "app", "(", ")", ...
Returns the client script component. @return CClientScript the component.
[ "Returns", "the", "client", "script", "component", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/behaviors/TbWidget.php#L158-L168
train
crisu83/yiistrap
form/TbForm.php
TbForm.init
public function init() { TbArray::defaultValue('layout', $this->layout, $this->activeForm); TbArray::defaultValue('class', '\TbActiveForm', $this->activeForm); }
php
public function init() { TbArray::defaultValue('layout', $this->layout, $this->activeForm); TbArray::defaultValue('class', '\TbActiveForm', $this->activeForm); }
[ "public", "function", "init", "(", ")", "{", "TbArray", "::", "defaultValue", "(", "'layout'", ",", "$", "this", "->", "layout", ",", "$", "this", "->", "activeForm", ")", ";", "TbArray", "::", "defaultValue", "(", "'class'", ",", "'\\TbActiveForm'", ",", ...
Initializes this form.
[ "Initializes", "this", "form", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/form/TbForm.php#L38-L42
train
crisu83/yiistrap
form/TbForm.php
TbForm.renderButtons
public function renderButtons() { $buttons = array(); foreach ($this->getButtons() as $button) { $buttons[] = $this->renderElement($button); } return $this->getActiveFormWidget()->createFormActions($buttons); }
php
public function renderButtons() { $buttons = array(); foreach ($this->getButtons() as $button) { $buttons[] = $this->renderElement($button); } return $this->getActiveFormWidget()->createFormActions($buttons); }
[ "public", "function", "renderButtons", "(", ")", "{", "$", "buttons", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getButtons", "(", ")", "as", "$", "button", ")", "{", "$", "buttons", "[", "]", "=", "$", "this", "->", "renderEl...
Renders the buttons in this form. @return string the rendering result.
[ "Renders", "the", "buttons", "in", "this", "form", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/form/TbForm.php#L73-L80
train
crisu83/yiistrap
widgets/TbPager.php
TbPager.createPageLink
protected function createPageLink($label, $page, $disabled, $active) { return array( 'label' => $label, 'url' => $this->createPageUrl($page), 'disabled' => $disabled, 'active' => $active, ); }
php
protected function createPageLink($label, $page, $disabled, $active) { return array( 'label' => $label, 'url' => $this->createPageUrl($page), 'disabled' => $disabled, 'active' => $active, ); }
[ "protected", "function", "createPageLink", "(", "$", "label", ",", "$", "page", ",", "$", "disabled", ",", "$", "active", ")", "{", "return", "array", "(", "'label'", "=>", "$", "label", ",", "'url'", "=>", "$", "this", "->", "createPageUrl", "(", "$",...
Creates a page link. @param string $label the link label text. @param integer $page the page number. @param boolean $visible whether the link is disabled. @param boolean $active whether the link is active. @return string the generated link.
[ "Creates", "a", "page", "link", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbPager.php#L134-L142
train
crisu83/yiistrap
widgets/TbDataColumn.php
TbDataColumn.renderFilterCellContent
protected function renderFilterCellContent() { if (is_string($this->filter)) { echo $this->filter; } else { if ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos( $this->name, '.' ) === false ) { if ($this->filterInputOptions) { $filterInputOptions = $this->filterInputOptions; if (empty($filterInputOptions['id'])) { $filterInputOptions['id'] = false; } } else { $filterInputOptions = array(); } if (is_array($this->filter)) { $filterInputOptions['prompt'] = ''; echo TbHtml::activeDropDownList( $this->grid->filter, $this->name, $this->filter, $filterInputOptions ); } else { if ($this->filter === null) { echo TbHtml::activeTextField($this->grid->filter, $this->name, $filterInputOptions); } } } else { parent::renderFilterCellContent(); } } }
php
protected function renderFilterCellContent() { if (is_string($this->filter)) { echo $this->filter; } else { if ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos( $this->name, '.' ) === false ) { if ($this->filterInputOptions) { $filterInputOptions = $this->filterInputOptions; if (empty($filterInputOptions['id'])) { $filterInputOptions['id'] = false; } } else { $filterInputOptions = array(); } if (is_array($this->filter)) { $filterInputOptions['prompt'] = ''; echo TbHtml::activeDropDownList( $this->grid->filter, $this->name, $this->filter, $filterInputOptions ); } else { if ($this->filter === null) { echo TbHtml::activeTextField($this->grid->filter, $this->name, $filterInputOptions); } } } else { parent::renderFilterCellContent(); } } }
[ "protected", "function", "renderFilterCellContent", "(", ")", "{", "if", "(", "is_string", "(", "$", "this", "->", "filter", ")", ")", "{", "echo", "$", "this", "->", "filter", ";", "}", "else", "{", "if", "(", "$", "this", "->", "filter", "!==", "fa...
Renders the filter cell content. Here we can provide HTML options for actual filter input
[ "Renders", "the", "filter", "cell", "content", ".", "Here", "we", "can", "provide", "HTML", "options", "for", "actual", "filter", "input" ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbDataColumn.php#L67-L102
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.textField
public function textField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_TEXT, $model, $attribute, $htmlOptions); }
php
public function textField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_TEXT, $model, $attribute, $htmlOptions); }
[ "public", "function", "textField", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_TEXT", ",", "$", "model", ",", "$", "at...
Generates a text field for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $htmlOptions additional HTML attributes. @return string the generated input field. @see TbHtml::activeTextField
[ "Generates", "a", "text", "field", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L185-L188
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.passwordField
public function passwordField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_PASSWORD, $model, $attribute, $htmlOptions); }
php
public function passwordField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_PASSWORD, $model, $attribute, $htmlOptions); }
[ "public", "function", "passwordField", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_PASSWORD", ",", "$", "model", ",", "$...
Generates a password field for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $htmlOptions additional HTML attributes. @return string the generated input field. @see TbHtml::activePasswordField
[ "Generates", "a", "password", "field", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L198-L201
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.urlField
public function urlField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_URL, $model, $attribute, $htmlOptions); }
php
public function urlField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_URL, $model, $attribute, $htmlOptions); }
[ "public", "function", "urlField", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_URL", ",", "$", "model", ",", "$", "attr...
Generates an url field for a model attribute. @param CModel $model the data model @param string $attribute the attribute @param array $htmlOptions additional HTML attributes. @return string the generated input field @see TbHtml::activeUrlField
[ "Generates", "an", "url", "field", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L211-L214
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.emailField
public function emailField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_EMAIL, $model, $attribute, $htmlOptions); }
php
public function emailField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_EMAIL, $model, $attribute, $htmlOptions); }
[ "public", "function", "emailField", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_EMAIL", ",", "$", "model", ",", "$", "...
Generates an email field for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $htmlOptions additional HTML attributes. @return string the generated input field. @see TbHtml::activeEmailField
[ "Generates", "an", "email", "field", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L224-L227
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.numberField
public function numberField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_NUMBER, $model, $attribute, $htmlOptions); }
php
public function numberField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_NUMBER, $model, $attribute, $htmlOptions); }
[ "public", "function", "numberField", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_NUMBER", ",", "$", "model", ",", "$", ...
Generates a number field for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $htmlOptions additional HTML attributes. @return string the generated input field. @see TbHtml::activeNumberField
[ "Generates", "a", "number", "field", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L237-L240
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.rangeField
public function rangeField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_RANGE, $model, $attribute, $htmlOptions); }
php
public function rangeField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_RANGE, $model, $attribute, $htmlOptions); }
[ "public", "function", "rangeField", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_RANGE", ",", "$", "model", ",", "$", "...
Generates a range field for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $htmlOptions additional HTML attributes. @return string the generated input field. @see TbHtml::activeRangeField
[ "Generates", "a", "range", "field", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L250-L253
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.dateField
public function dateField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_DATE, $model, $attribute, $htmlOptions); }
php
public function dateField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_DATE, $model, $attribute, $htmlOptions); }
[ "public", "function", "dateField", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_DATE", ",", "$", "model", ",", "$", "at...
Generates a date field for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $htmlOptions additional HTML attributes. @return string the generated input field.
[ "Generates", "a", "date", "field", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L262-L265
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.textArea
public function textArea($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_TEXTAREA, $model, $attribute, $htmlOptions); }
php
public function textArea($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_TEXTAREA, $model, $attribute, $htmlOptions); }
[ "public", "function", "textArea", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_TEXTAREA", ",", "$", "model", ",", "$", ...
Generates a text area for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $htmlOptions additional HTML attributes. @return string the generated text area. @see TbHtml::activeTextArea
[ "Generates", "a", "text", "area", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L275-L278
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.fileField
public function fileField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_FILE, $model, $attribute, $htmlOptions); }
php
public function fileField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_FILE, $model, $attribute, $htmlOptions); }
[ "public", "function", "fileField", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_FILE", ",", "$", "model", ",", "$", "at...
Generates a file field for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $htmlOptions additional HTML attributes @return string the generated input field. @see TbHtml::activeFileField
[ "Generates", "a", "file", "field", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L288-L291
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.radioButton
public function radioButton($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_RADIOBUTTON, $model, $attribute, $htmlOptions); }
php
public function radioButton($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_RADIOBUTTON, $model, $attribute, $htmlOptions); }
[ "public", "function", "radioButton", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_RADIOBUTTON", ",", "$", "model", ",", "...
Generates a radio button for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $htmlOptions additional HTML attributes. @return string the generated radio button. @see TbHtml::activeRadioButton
[ "Generates", "a", "radio", "button", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L301-L304
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.checkBox
public function checkBox($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_CHECKBOX, $model, $attribute, $htmlOptions); }
php
public function checkBox($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_CHECKBOX, $model, $attribute, $htmlOptions); }
[ "public", "function", "checkBox", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_CHECKBOX", ",", "$", "model", ",", "$", ...
Generates a checkbox for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $htmlOptions additional HTML attributes. @return string the generated check box. @see TbHtml::activeCheckBox
[ "Generates", "a", "checkbox", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L314-L317
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.dropDownList
public function dropDownList($model, $attribute, $data, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_DROPDOWNLIST, $model, $attribute, $htmlOptions, $data); }
php
public function dropDownList($model, $attribute, $data, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_DROPDOWNLIST, $model, $attribute, $htmlOptions, $data); }
[ "public", "function", "dropDownList", "(", "$", "model", ",", "$", "attribute", ",", "$", "data", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_DROPDOWNLIST", ",", ...
Generates a dropdown list for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $data data for generating the list options (value=>display). @param array $htmlOptions additional HTML attributes. @return string the generated drop down list. @see TbHtml::activeDropDownList
[ "Generates", "a", "dropdown", "list", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L328-L331
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.radioButtonList
public function radioButtonList($model, $attribute, $data, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_RADIOBUTTONLIST, $model, $attribute, $htmlOptions, $data); }
php
public function radioButtonList($model, $attribute, $data, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_RADIOBUTTONLIST, $model, $attribute, $htmlOptions, $data); }
[ "public", "function", "radioButtonList", "(", "$", "model", ",", "$", "attribute", ",", "$", "data", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_RADIOBUTTONLIST", "...
Generates a radio button list for a model attribute @param CModel $model the data model. @param string $attribute the attribute. @param array $data data for generating the list options (value=>display) @param array $htmlOptions additional HTML attributes. @return string the generated radio button list. @see TbHtml::activeRadioButtonList
[ "Generates", "a", "radio", "button", "list", "for", "a", "model", "attribute" ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L356-L359
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.inlineRadioButtonList
public function inlineRadioButtonList($model, $attribute, $data, $htmlOptions = array()) { $htmlOptions['inline'] = true; return $this->createInput(TbHtml::INPUT_TYPE_RADIOBUTTONLIST, $model, $attribute, $htmlOptions, $data); }
php
public function inlineRadioButtonList($model, $attribute, $data, $htmlOptions = array()) { $htmlOptions['inline'] = true; return $this->createInput(TbHtml::INPUT_TYPE_RADIOBUTTONLIST, $model, $attribute, $htmlOptions, $data); }
[ "public", "function", "inlineRadioButtonList", "(", "$", "model", ",", "$", "attribute", ",", "$", "data", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "$", "htmlOptions", "[", "'inline'", "]", "=", "true", ";", "return", "$", "this", "->...
Generates an inline radio button list for a model attribute @param CModel $model the data model. @param string $attribute the attribute. @param array $data data for generating the list options (value=>display) @param array $htmlOptions additional HTML attributes. @return string the generated radio button list. @see TbHtml::activeInlineRadioButtonList
[ "Generates", "an", "inline", "radio", "button", "list", "for", "a", "model", "attribute" ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L370-L374
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.checkBoxList
public function checkBoxList($model, $attribute, $data, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_CHECKBOXLIST, $model, $attribute, $htmlOptions, $data); }
php
public function checkBoxList($model, $attribute, $data, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_CHECKBOXLIST, $model, $attribute, $htmlOptions, $data); }
[ "public", "function", "checkBoxList", "(", "$", "model", ",", "$", "attribute", ",", "$", "data", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_CHECKBOXLIST", ",", ...
Generates a checkbox list for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $data data for generating the list options (value=>display) @param array $htmlOptions additional HTML attributes. @return string the generated checkbox list. @see TbHtml::activeCheckBoxList
[ "Generates", "a", "checkbox", "list", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L385-L388
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.inlineCheckBoxList
public function inlineCheckBoxList($model, $attribute, $data, $htmlOptions = array()) { $htmlOptions['inline'] = true; return $this->createInput(TbHtml::INPUT_TYPE_CHECKBOXLIST, $model, $attribute, $htmlOptions, $data); }
php
public function inlineCheckBoxList($model, $attribute, $data, $htmlOptions = array()) { $htmlOptions['inline'] = true; return $this->createInput(TbHtml::INPUT_TYPE_CHECKBOXLIST, $model, $attribute, $htmlOptions, $data); }
[ "public", "function", "inlineCheckBoxList", "(", "$", "model", ",", "$", "attribute", ",", "$", "data", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "$", "htmlOptions", "[", "'inline'", "]", "=", "true", ";", "return", "$", "this", "->", ...
Generates an inline checkbox list for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $data data for generating the list options (value=>display) @param array $htmlOptions additional HTML attributes. @return string the generated checkbox list. @see TbHtml::activeInlineCheckBoxList
[ "Generates", "an", "inline", "checkbox", "list", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L399-L403
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.uneditableField
public function uneditableField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_UNEDITABLE, $model, $attribute, $htmlOptions); }
php
public function uneditableField($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_UNEDITABLE, $model, $attribute, $htmlOptions); }
[ "public", "function", "uneditableField", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_UNEDITABLE", ",", "$", "model", ",", ...
Generates an uneditable field for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $htmlOptions additional HTML attributes. @return string the generated field. @see TbHtml::activeUneditableField
[ "Generates", "an", "uneditable", "field", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L413-L416
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.searchQuery
public function searchQuery($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_SEARCH, $model, $attribute, $htmlOptions); }
php
public function searchQuery($model, $attribute, $htmlOptions = array()) { return $this->createInput(TbHtml::INPUT_TYPE_SEARCH, $model, $attribute, $htmlOptions); }
[ "public", "function", "searchQuery", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createInput", "(", "TbHtml", "::", "INPUT_TYPE_SEARCH", ",", "$", "model", ",", "$", ...
Generates a search query field for a model attribute. @param CModel $model the data model. @param string $attribute the attribute. @param array $htmlOptions additional HTML attributes. @return string the generated input. @see TbHtml::activeSearchField
[ "Generates", "a", "search", "query", "field", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L426-L429
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.createInput
public function createInput($type, $model, $attribute, $htmlOptions = array(), $data = array()) { return TbHtml::createActiveInput($type, $model, $attribute, $htmlOptions, $data); }
php
public function createInput($type, $model, $attribute, $htmlOptions = array(), $data = array()) { return TbHtml::createActiveInput($type, $model, $attribute, $htmlOptions, $data); }
[ "public", "function", "createInput", "(", "$", "type", ",", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ",", "$", "data", "=", "array", "(", ")", ")", "{", "return", "TbHtml", "::", "createActiveInput", "(", ...
Generates an input for a model attribute. @param string $type the input type. @param CModel $model the data model. @param string $attribute the attribute. @param array $htmlOptions additional HTML attributes. @param array $data data for generating the list options (value=>display). @return string the generated input. @see TbHtml::createActiveInput
[ "Generates", "an", "input", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L441-L444
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.urlFieldControlGroup
public function urlFieldControlGroup($model, $attribute, $htmlOptions = array()) { return $this->createControlGroup(TbHtml::INPUT_TYPE_URL, $model, $attribute, $htmlOptions); }
php
public function urlFieldControlGroup($model, $attribute, $htmlOptions = array()) { return $this->createControlGroup(TbHtml::INPUT_TYPE_URL, $model, $attribute, $htmlOptions); }
[ "public", "function", "urlFieldControlGroup", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createControlGroup", "(", "TbHtml", "::", "INPUT_TYPE_URL", ",", "$", "model", ...
Generates a control group with an url field for a model attribute. @param CModel $model the data model. @param string $attribute the attribute name. @param array $htmlOptions additional HTML attributes. @return string the generated control group. @see TbHtml::activeUrlFieldControlGroup
[ "Generates", "a", "control", "group", "with", "an", "url", "field", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L480-L483
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.emailFieldControlGroup
public function emailFieldControlGroup($model, $attribute, $htmlOptions = array()) { return $this->createControlGroup(TbHtml::INPUT_TYPE_EMAIL, $model, $attribute, $htmlOptions); }
php
public function emailFieldControlGroup($model, $attribute, $htmlOptions = array()) { return $this->createControlGroup(TbHtml::INPUT_TYPE_EMAIL, $model, $attribute, $htmlOptions); }
[ "public", "function", "emailFieldControlGroup", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createControlGroup", "(", "TbHtml", "::", "INPUT_TYPE_EMAIL", ",", "$", "model"...
Generates a control group with an email field for a model attribute. @param CModel $model the data model. @param string $attribute the attribute name. @param array $htmlOptions additional HTML attributes. @return string the generated control group. @see TbHtml::activeEmailFieldControlGroup
[ "Generates", "a", "control", "group", "with", "an", "email", "field", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L493-L496
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.uneditableFieldControlGroup
public function uneditableFieldControlGroup($model, $attribute, $htmlOptions = array()) { return $this->createControlGroup(TbHtml::INPUT_TYPE_UNEDITABLE, $model, $attribute, $htmlOptions); }
php
public function uneditableFieldControlGroup($model, $attribute, $htmlOptions = array()) { return $this->createControlGroup(TbHtml::INPUT_TYPE_UNEDITABLE, $model, $attribute, $htmlOptions); }
[ "public", "function", "uneditableFieldControlGroup", "(", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "createControlGroup", "(", "TbHtml", "::", "INPUT_TYPE_UNEDITABLE", ",", "$",...
Generates a control group with an uneditable field for a model attribute. @param CModel $model the data model. @param string $attribute the attribute name. @param array $htmlOptions additional HTML attributes. @return string the generated control group. @see TbHtml::activeUneditableFieldControlGroup
[ "Generates", "a", "control", "group", "with", "an", "uneditable", "field", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L683-L686
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.createControlGroup
public function createControlGroup($type, $model, $attribute, $htmlOptions = array(), $data = array()) { $htmlOptions = $this->processControlGroupOptions($model, $attribute, $htmlOptions); return TbHtml::activeControlGroup($type, $model, $attribute, $htmlOptions, $data); }
php
public function createControlGroup($type, $model, $attribute, $htmlOptions = array(), $data = array()) { $htmlOptions = $this->processControlGroupOptions($model, $attribute, $htmlOptions); return TbHtml::activeControlGroup($type, $model, $attribute, $htmlOptions, $data); }
[ "public", "function", "createControlGroup", "(", "$", "type", ",", "$", "model", ",", "$", "attribute", ",", "$", "htmlOptions", "=", "array", "(", ")", ",", "$", "data", "=", "array", "(", ")", ")", "{", "$", "htmlOptions", "=", "$", "this", "->", ...
Generates a control group for a model attribute. @param string $type the input type. @param CModel $model the data model. @param string $attribute the attribute name. @param array $htmlOptions additional HTML attributes. @param array $data data for generating the list options (value=>display). @return string the generated control group. @see TbHtml::activeControlGroup
[ "Generates", "a", "control", "group", "for", "a", "model", "attribute", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L726-L730
train
crisu83/yiistrap
widgets/TbActiveForm.php
TbActiveForm.processControlGroupOptions
protected function processControlGroupOptions($model, $attribute, $options) { $errorOptions = TbArray::popValue('errorOptions', $options, array()); $enableAjaxValidation = TbArray::popValue('enableAjaxValidation', $errorOptions, true); $enableClientValidation = TbArray::popValue('enableClientValidation', $errorOptions, true); $errorOptions['type'] = $this->helpType; $error = $this->error($model, $attribute, $errorOptions, $enableAjaxValidation, $enableClientValidation); // kind of a hack for ajax forms but this works for now. if (!empty($error) && strpos($error, 'display:none') === false) { $options['color'] = TbHtml::INPUT_COLOR_ERROR; } if (!$this->hideInlineErrors) { $options['error'] = $error; } $helpOptions = TbArray::popValue('helpOptions', $options, array()); $helpOptions['type'] = $this->helpType; $options['helpOptions'] = $helpOptions; if (!TbArray::getValue('formLayout', $options, false)) { $options['formLayout'] = $this->layout; } $options['labelWidthClass'] = TbArray::getValue('labelWidthClass', $options, $this->labelWidthClass); $options['controlWidthClass'] = TbArray::getValue('controlWidthClass', $options, $this->controlWidthClass); return $options; }
php
protected function processControlGroupOptions($model, $attribute, $options) { $errorOptions = TbArray::popValue('errorOptions', $options, array()); $enableAjaxValidation = TbArray::popValue('enableAjaxValidation', $errorOptions, true); $enableClientValidation = TbArray::popValue('enableClientValidation', $errorOptions, true); $errorOptions['type'] = $this->helpType; $error = $this->error($model, $attribute, $errorOptions, $enableAjaxValidation, $enableClientValidation); // kind of a hack for ajax forms but this works for now. if (!empty($error) && strpos($error, 'display:none') === false) { $options['color'] = TbHtml::INPUT_COLOR_ERROR; } if (!$this->hideInlineErrors) { $options['error'] = $error; } $helpOptions = TbArray::popValue('helpOptions', $options, array()); $helpOptions['type'] = $this->helpType; $options['helpOptions'] = $helpOptions; if (!TbArray::getValue('formLayout', $options, false)) { $options['formLayout'] = $this->layout; } $options['labelWidthClass'] = TbArray::getValue('labelWidthClass', $options, $this->labelWidthClass); $options['controlWidthClass'] = TbArray::getValue('controlWidthClass', $options, $this->controlWidthClass); return $options; }
[ "protected", "function", "processControlGroupOptions", "(", "$", "model", ",", "$", "attribute", ",", "$", "options", ")", "{", "$", "errorOptions", "=", "TbArray", "::", "popValue", "(", "'errorOptions'", ",", "$", "options", ",", "array", "(", ")", ")", ...
Processes the options for a input row. @param CModel $model the data model. @param string $attribute the attribute name. @param array $options the options. @return array the processed options.
[ "Processes", "the", "options", "for", "a", "input", "row", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbActiveForm.php#L753-L776
train
crisu83/yiistrap
form/TbFormInputElement.php
TbFormInputElement.render
public function render() { /** @var TbForm $parent */ $parent = $this->getParent(); /** @var TbActiveForm $form */ $form = $parent->getActiveFormWidget(); /** @var CModel $model */ $model = $parent->getModel(); // Hidden fields do not require control groups. if ($this->type === TbHtml::INPUT_TYPE_HIDDEN) { return $form->hiddenField($model, $this->name, $this->attributes); } if (isset(self::$coreTypes[$this->type])) { $type = self::$coreTypes[$this->type]; } else { $type = TbHtml::INPUT_TYPE_CUSTOM; $properties = $this->attributes; $properties['model'] = $model; $properties['attribute'] = $this->name; $this->attributes['input'] = $parent->getOwner()->widget($this->type, $properties, true); } return $form->createControlGroup($type, $model, $this->name, $this->attributes, $this->items); }
php
public function render() { /** @var TbForm $parent */ $parent = $this->getParent(); /** @var TbActiveForm $form */ $form = $parent->getActiveFormWidget(); /** @var CModel $model */ $model = $parent->getModel(); // Hidden fields do not require control groups. if ($this->type === TbHtml::INPUT_TYPE_HIDDEN) { return $form->hiddenField($model, $this->name, $this->attributes); } if (isset(self::$coreTypes[$this->type])) { $type = self::$coreTypes[$this->type]; } else { $type = TbHtml::INPUT_TYPE_CUSTOM; $properties = $this->attributes; $properties['model'] = $model; $properties['attribute'] = $this->name; $this->attributes['input'] = $parent->getOwner()->widget($this->type, $properties, true); } return $form->createControlGroup($type, $model, $this->name, $this->attributes, $this->items); }
[ "public", "function", "render", "(", ")", "{", "/** @var TbForm $parent */", "$", "parent", "=", "$", "this", "->", "getParent", "(", ")", ";", "/** @var TbActiveForm $form */", "$", "form", "=", "$", "parent", "->", "getActiveFormWidget", "(", ")", ";", "/** ...
Renders a control group for this input. @return string the rendered control group.
[ "Renders", "a", "control", "group", "for", "this", "input", "." ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/form/TbFormInputElement.php#L46-L71
train
crisu83/yiistrap
widgets/TbTypeAhead.php
TbTypeAhead.initOptions
public function initOptions() { $options = array(); foreach (array('matcher', 'sorter', 'updater', 'highlighter') as $fn) { if ($this->$fn !== null) { if ($this->$fn instanceof CJavaScriptExpression) { $options[$fn] = $this->$fn; } else { $options[$fn] = new CJavaScriptExpression($this->$fn); } } } $this->pluginOptions = TbArray::merge( array( 'source' => $this->source, 'items' => $this->items, 'minLength' => $this->minLength ), $options ); }
php
public function initOptions() { $options = array(); foreach (array('matcher', 'sorter', 'updater', 'highlighter') as $fn) { if ($this->$fn !== null) { if ($this->$fn instanceof CJavaScriptExpression) { $options[$fn] = $this->$fn; } else { $options[$fn] = new CJavaScriptExpression($this->$fn); } } } $this->pluginOptions = TbArray::merge( array( 'source' => $this->source, 'items' => $this->items, 'minLength' => $this->minLength ), $options ); }
[ "public", "function", "initOptions", "(", ")", "{", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "array", "(", "'matcher'", ",", "'sorter'", ",", "'updater'", ",", "'highlighter'", ")", "as", "$", "fn", ")", "{", "if", "(", "$", "this...
Initializes the plugin options
[ "Initializes", "the", "plugin", "options" ]
0375cf186f2af76e4b26bbaa95a7be4996590b86
https://github.com/crisu83/yiistrap/blob/0375cf186f2af76e4b26bbaa95a7be4996590b86/widgets/TbTypeAhead.php#L75-L96
train