id
int32
0
241k
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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
240,200
gossi/trixionary
src/model/Base/SkillPartQuery.php
SkillPartQuery.filterByCompositeId
public function filterByCompositeId($compositeId = null, $comparison = null) { if (is_array($compositeId)) { $useMinMax = false; if (isset($compositeId['min'])) { $this->addUsingAlias(SkillPartTableMap::COL_COMPOSITE_ID, $compositeId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($compositeId['max'])) { $this->addUsingAlias(SkillPartTableMap::COL_COMPOSITE_ID, $compositeId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(SkillPartTableMap::COL_COMPOSITE_ID, $compositeId, $comparison); }
php
public function filterByCompositeId($compositeId = null, $comparison = null) { if (is_array($compositeId)) { $useMinMax = false; if (isset($compositeId['min'])) { $this->addUsingAlias(SkillPartTableMap::COL_COMPOSITE_ID, $compositeId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($compositeId['max'])) { $this->addUsingAlias(SkillPartTableMap::COL_COMPOSITE_ID, $compositeId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(SkillPartTableMap::COL_COMPOSITE_ID, $compositeId, $comparison); }
[ "public", "function", "filterByCompositeId", "(", "$", "compositeId", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "compositeId", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "compositeId", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "SkillPartTableMap", "::", "COL_COMPOSITE_ID", ",", "$", "compositeId", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "compositeId", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "SkillPartTableMap", "::", "COL_COMPOSITE_ID", ",", "$", "compositeId", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "SkillPartTableMap", "::", "COL_COMPOSITE_ID", ",", "$", "compositeId", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the composite_id column Example usage: <code> $query->filterByCompositeId(1234); // WHERE composite_id = 1234 $query->filterByCompositeId(array(12, 34)); // WHERE composite_id IN (12, 34) $query->filterByCompositeId(array('min' => 12)); // WHERE composite_id > 12 </code> @see filterBySkillRelatedByCompositeId() @param mixed $compositeId The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildSkillPartQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "composite_id", "column" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/SkillPartQuery.php#L315-L336
240,201
gossi/trixionary
src/model/Base/SkillPartQuery.php
SkillPartQuery.useSkillRelatedByPartIdQuery
public function useSkillRelatedByPartIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinSkillRelatedByPartId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'SkillRelatedByPartId', '\gossi\trixionary\model\SkillQuery'); }
php
public function useSkillRelatedByPartIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinSkillRelatedByPartId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'SkillRelatedByPartId', '\gossi\trixionary\model\SkillQuery'); }
[ "public", "function", "useSkillRelatedByPartIdQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinSkillRelatedByPartId", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'SkillRelatedByPartId'", ",", "'\\gossi\\trixionary\\model\\SkillQuery'", ")", ";", "}" ]
Use the SkillRelatedByPartId relation Skill object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \gossi\trixionary\model\SkillQuery A secondary query class using the current class as primary query
[ "Use", "the", "SkillRelatedByPartId", "relation", "Skill", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/SkillPartQuery.php#L408-L413
240,202
gossi/trixionary
src/model/Base/SkillPartQuery.php
SkillPartQuery.useSkillRelatedByCompositeIdQuery
public function useSkillRelatedByCompositeIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinSkillRelatedByCompositeId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'SkillRelatedByCompositeId', '\gossi\trixionary\model\SkillQuery'); }
php
public function useSkillRelatedByCompositeIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinSkillRelatedByCompositeId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'SkillRelatedByCompositeId', '\gossi\trixionary\model\SkillQuery'); }
[ "public", "function", "useSkillRelatedByCompositeIdQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinSkillRelatedByCompositeId", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'SkillRelatedByCompositeId'", ",", "'\\gossi\\trixionary\\model\\SkillQuery'", ")", ";", "}" ]
Use the SkillRelatedByCompositeId relation Skill object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \gossi\trixionary\model\SkillQuery A secondary query class using the current class as primary query
[ "Use", "the", "SkillRelatedByCompositeId", "relation", "Skill", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/SkillPartQuery.php#L485-L490
240,203
n0m4dz/laracasa
Zend/Gdata/HttpClient.php
Zend_Gdata_HttpClient.setAuthSubPrivateKeyFile
public function setAuthSubPrivateKeyFile($file, $passphrase = null, $useIncludePath = false) { $fp = @fopen($file, "r", $useIncludePath); if (!$fp) { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException('Failed to open private key file for AuthSub.'); } $key = ''; while (!feof($fp)) { $key .= fread($fp, 8192); } $this->setAuthSubPrivateKey($key, $passphrase); fclose($fp); }
php
public function setAuthSubPrivateKeyFile($file, $passphrase = null, $useIncludePath = false) { $fp = @fopen($file, "r", $useIncludePath); if (!$fp) { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException('Failed to open private key file for AuthSub.'); } $key = ''; while (!feof($fp)) { $key .= fread($fp, 8192); } $this->setAuthSubPrivateKey($key, $passphrase); fclose($fp); }
[ "public", "function", "setAuthSubPrivateKeyFile", "(", "$", "file", ",", "$", "passphrase", "=", "null", ",", "$", "useIncludePath", "=", "false", ")", "{", "$", "fp", "=", "@", "fopen", "(", "$", "file", ",", "\"r\"", ",", "$", "useIncludePath", ")", ";", "if", "(", "!", "$", "fp", ")", "{", "require_once", "'Zend/Gdata/App/InvalidArgumentException.php'", ";", "throw", "new", "Zend_Gdata_App_InvalidArgumentException", "(", "'Failed to open private key file for AuthSub.'", ")", ";", "}", "$", "key", "=", "''", ";", "while", "(", "!", "feof", "(", "$", "fp", ")", ")", "{", "$", "key", ".=", "fread", "(", "$", "fp", ",", "8192", ")", ";", "}", "$", "this", "->", "setAuthSubPrivateKey", "(", "$", "key", ",", "$", "passphrase", ")", ";", "fclose", "(", "$", "fp", ")", ";", "}" ]
Sets the PEM formatted private key, as read from a file. This method reads the file and then calls setAuthSubPrivateKey() with the file contents. @param string $file The location of the file containing the PEM key @param string $passphrase The optional private key passphrase @param bool $useIncludePath Whether to search the include_path for the file @return void
[ "Sets", "the", "PEM", "formatted", "private", "key", "as", "read", "from", "a", "file", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/HttpClient.php#L97-L111
240,204
n0m4dz/laracasa
Zend/Gdata/HttpClient.php
Zend_Gdata_HttpClient.setAuthSubPrivateKey
public function setAuthSubPrivateKey($key, $passphrase = null) { if ($key != null && !function_exists('openssl_pkey_get_private')) { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'You cannot enable secure AuthSub if the openssl module ' . 'is not enabled in your PHP installation.'); } $this->_authSubPrivateKeyId = openssl_pkey_get_private( $key, $passphrase); return $this; }
php
public function setAuthSubPrivateKey($key, $passphrase = null) { if ($key != null && !function_exists('openssl_pkey_get_private')) { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'You cannot enable secure AuthSub if the openssl module ' . 'is not enabled in your PHP installation.'); } $this->_authSubPrivateKeyId = openssl_pkey_get_private( $key, $passphrase); return $this; }
[ "public", "function", "setAuthSubPrivateKey", "(", "$", "key", ",", "$", "passphrase", "=", "null", ")", "{", "if", "(", "$", "key", "!=", "null", "&&", "!", "function_exists", "(", "'openssl_pkey_get_private'", ")", ")", "{", "require_once", "'Zend/Gdata/App/InvalidArgumentException.php'", ";", "throw", "new", "Zend_Gdata_App_InvalidArgumentException", "(", "'You cannot enable secure AuthSub if the openssl module '", ".", "'is not enabled in your PHP installation.'", ")", ";", "}", "$", "this", "->", "_authSubPrivateKeyId", "=", "openssl_pkey_get_private", "(", "$", "key", ",", "$", "passphrase", ")", ";", "return", "$", "this", ";", "}" ]
Sets the PEM formatted private key to be used for secure AuthSub auth. In order to call this method, openssl must be enabled in your PHP installation. Otherwise, a Zend_Gdata_App_InvalidArgumentException will be thrown. @param string $key The private key @param string $passphrase The optional private key passphrase @throws Zend_Gdata_App_InvalidArgumentException @return Zend_Gdata_HttpClient Provides a fluent interface
[ "Sets", "the", "PEM", "formatted", "private", "key", "to", "be", "used", "for", "secure", "AuthSub", "auth", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/HttpClient.php#L125-L135
240,205
n0m4dz/laracasa
Zend/Gdata/HttpClient.php
Zend_Gdata_HttpClient.filterHttpRequest
public function filterHttpRequest($method, $url, $headers = array(), $body = null, $contentType = null) { if ($this->getAuthSubToken() != null) { // AuthSub authentication if ($this->getAuthSubPrivateKeyId() != null) { // secure AuthSub $time = time(); $nonce = mt_rand(0, 999999999); $dataToSign = $method . ' ' . $url . ' ' . $time . ' ' . $nonce; // compute signature $pKeyId = $this->getAuthSubPrivateKeyId(); $signSuccess = openssl_sign($dataToSign, $signature, $pKeyId, OPENSSL_ALGO_SHA1); if (!$signSuccess) { require_once 'Zend/Gdata/App/Exception.php'; throw new Zend_Gdata_App_Exception( 'openssl_signing failure - returned false'); } // encode signature $encodedSignature = base64_encode($signature); // final header $headers['authorization'] = 'AuthSub token="' . $this->getAuthSubToken() . '" ' . 'data="' . $dataToSign . '" ' . 'sig="' . $encodedSignature . '" ' . 'sigalg="rsa-sha1"'; } else { // AuthSub without secure tokens $headers['authorization'] = 'AuthSub token="' . $this->getAuthSubToken() . '"'; } } elseif ($this->getClientLoginToken() != null) { $headers['authorization'] = 'GoogleLogin auth=' . $this->getClientLoginToken(); } return array('method' => $method, 'url' => $url, 'body' => $body, 'headers' => $headers, 'contentType' => $contentType); }
php
public function filterHttpRequest($method, $url, $headers = array(), $body = null, $contentType = null) { if ($this->getAuthSubToken() != null) { // AuthSub authentication if ($this->getAuthSubPrivateKeyId() != null) { // secure AuthSub $time = time(); $nonce = mt_rand(0, 999999999); $dataToSign = $method . ' ' . $url . ' ' . $time . ' ' . $nonce; // compute signature $pKeyId = $this->getAuthSubPrivateKeyId(); $signSuccess = openssl_sign($dataToSign, $signature, $pKeyId, OPENSSL_ALGO_SHA1); if (!$signSuccess) { require_once 'Zend/Gdata/App/Exception.php'; throw new Zend_Gdata_App_Exception( 'openssl_signing failure - returned false'); } // encode signature $encodedSignature = base64_encode($signature); // final header $headers['authorization'] = 'AuthSub token="' . $this->getAuthSubToken() . '" ' . 'data="' . $dataToSign . '" ' . 'sig="' . $encodedSignature . '" ' . 'sigalg="rsa-sha1"'; } else { // AuthSub without secure tokens $headers['authorization'] = 'AuthSub token="' . $this->getAuthSubToken() . '"'; } } elseif ($this->getClientLoginToken() != null) { $headers['authorization'] = 'GoogleLogin auth=' . $this->getClientLoginToken(); } return array('method' => $method, 'url' => $url, 'body' => $body, 'headers' => $headers, 'contentType' => $contentType); }
[ "public", "function", "filterHttpRequest", "(", "$", "method", ",", "$", "url", ",", "$", "headers", "=", "array", "(", ")", ",", "$", "body", "=", "null", ",", "$", "contentType", "=", "null", ")", "{", "if", "(", "$", "this", "->", "getAuthSubToken", "(", ")", "!=", "null", ")", "{", "// AuthSub authentication", "if", "(", "$", "this", "->", "getAuthSubPrivateKeyId", "(", ")", "!=", "null", ")", "{", "// secure AuthSub", "$", "time", "=", "time", "(", ")", ";", "$", "nonce", "=", "mt_rand", "(", "0", ",", "999999999", ")", ";", "$", "dataToSign", "=", "$", "method", ".", "' '", ".", "$", "url", ".", "' '", ".", "$", "time", ".", "' '", ".", "$", "nonce", ";", "// compute signature", "$", "pKeyId", "=", "$", "this", "->", "getAuthSubPrivateKeyId", "(", ")", ";", "$", "signSuccess", "=", "openssl_sign", "(", "$", "dataToSign", ",", "$", "signature", ",", "$", "pKeyId", ",", "OPENSSL_ALGO_SHA1", ")", ";", "if", "(", "!", "$", "signSuccess", ")", "{", "require_once", "'Zend/Gdata/App/Exception.php'", ";", "throw", "new", "Zend_Gdata_App_Exception", "(", "'openssl_signing failure - returned false'", ")", ";", "}", "// encode signature", "$", "encodedSignature", "=", "base64_encode", "(", "$", "signature", ")", ";", "// final header", "$", "headers", "[", "'authorization'", "]", "=", "'AuthSub token=\"'", ".", "$", "this", "->", "getAuthSubToken", "(", ")", ".", "'\" '", ".", "'data=\"'", ".", "$", "dataToSign", ".", "'\" '", ".", "'sig=\"'", ".", "$", "encodedSignature", ".", "'\" '", ".", "'sigalg=\"rsa-sha1\"'", ";", "}", "else", "{", "// AuthSub without secure tokens", "$", "headers", "[", "'authorization'", "]", "=", "'AuthSub token=\"'", ".", "$", "this", "->", "getAuthSubToken", "(", ")", ".", "'\"'", ";", "}", "}", "elseif", "(", "$", "this", "->", "getClientLoginToken", "(", ")", "!=", "null", ")", "{", "$", "headers", "[", "'authorization'", "]", "=", "'GoogleLogin auth='", ".", "$", "this", "->", "getClientLoginToken", "(", ")", ";", "}", "return", "array", "(", "'method'", "=>", "$", "method", ",", "'url'", "=>", "$", "url", ",", "'body'", "=>", "$", "body", ",", "'headers'", "=>", "$", "headers", ",", "'contentType'", "=>", "$", "contentType", ")", ";", "}" ]
Filters the HTTP requests being sent to add the Authorization header. If both AuthSub and ClientLogin tokens are set, AuthSub takes precedence. If an AuthSub key is set, then secure AuthSub authentication is used, and the request is signed. Requests must be signed only with the private key corresponding to the public key registered with Google. If an AuthSub key is set, but openssl support is not enabled in the PHP installation, an exception is thrown. @param string $method The HTTP method @param string $url The URL @param array $headers An associate array of headers to be sent with the request or null @param string $body The body of the request or null @param string $contentType The MIME content type of the body or null @throws Zend_Gdata_App_Exception if there was a signing failure @return array The processed values in an associative array, using the same names as the params
[ "Filters", "the", "HTTP", "requests", "being", "sent", "to", "add", "the", "Authorization", "header", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/HttpClient.php#L207-L241
240,206
codebobbly/dvoconnector
Classes/Controller/EventStaticController.php
EventStaticController.singleEventAction
public function singleEventAction() { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $this->settings[self::SETTINGS_ASSOCIATION_ID], self::VIEW_VARIABLE_EVENT_ID => $this->settings[self::SETTINGS_EVENT_ID] ], __CLASS__, __FUNCTION__); return $this->view->render(); }
php
public function singleEventAction() { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $this->settings[self::SETTINGS_ASSOCIATION_ID], self::VIEW_VARIABLE_EVENT_ID => $this->settings[self::SETTINGS_EVENT_ID] ], __CLASS__, __FUNCTION__); return $this->view->render(); }
[ "public", "function", "singleEventAction", "(", ")", "{", "$", "this", "->", "checkStaticTemplateIsIncluded", "(", ")", ";", "$", "this", "->", "checkSettings", "(", ")", ";", "$", "this", "->", "slotExtendedAssignMultiple", "(", "[", "self", "::", "VIEW_VARIABLE_ASSOCIATION_ID", "=>", "$", "this", "->", "settings", "[", "self", "::", "SETTINGS_ASSOCIATION_ID", "]", ",", "self", "::", "VIEW_VARIABLE_EVENT_ID", "=>", "$", "this", "->", "settings", "[", "self", "::", "SETTINGS_EVENT_ID", "]", "]", ",", "__CLASS__", ",", "__FUNCTION__", ")", ";", "return", "$", "this", "->", "view", "->", "render", "(", ")", ";", "}" ]
single event action. @return string
[ "single", "event", "action", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/EventStaticController.php#L30-L41
240,207
broeser/wellid
src/ValidationResultSet.php
ValidationResultSet.getErrorMessages
public function getErrorMessages() { $messages = array(); foreach($this->entries as $entry) { if($entry->isError()) { $messages[] = $entry->getMessage(); } } return $messages; }
php
public function getErrorMessages() { $messages = array(); foreach($this->entries as $entry) { if($entry->isError()) { $messages[] = $entry->getMessage(); } } return $messages; }
[ "public", "function", "getErrorMessages", "(", ")", "{", "$", "messages", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "entries", "as", "$", "entry", ")", "{", "if", "(", "$", "entry", "->", "isError", "(", ")", ")", "{", "$", "messages", "[", "]", "=", "$", "entry", "->", "getMessage", "(", ")", ";", "}", "}", "return", "$", "messages", ";", "}" ]
Returns an array of error message strings @return string[]
[ "Returns", "an", "array", "of", "error", "message", "strings" ]
0de2e6119382530221f4f7285158f19d45c78704
https://github.com/broeser/wellid/blob/0de2e6119382530221f4f7285158f19d45c78704/src/ValidationResultSet.php#L82-L92
240,208
zerospam/sdk-framework
src/Utils/Data/ArrayableData.php
ArrayableData.toArray
public function toArray(): array { $data = ReflectionUtil::objToSnakeArray($this, static::blacklist()); foreach ($this->renamed as $name => $newName) { if (!array_key_exists($name, $data)) { continue; } $data[$newName] = $data[$name]; unset($data[$name]); } return $data; }
php
public function toArray(): array { $data = ReflectionUtil::objToSnakeArray($this, static::blacklist()); foreach ($this->renamed as $name => $newName) { if (!array_key_exists($name, $data)) { continue; } $data[$newName] = $data[$name]; unset($data[$name]); } return $data; }
[ "public", "function", "toArray", "(", ")", ":", "array", "{", "$", "data", "=", "ReflectionUtil", "::", "objToSnakeArray", "(", "$", "this", ",", "static", "::", "blacklist", "(", ")", ")", ";", "foreach", "(", "$", "this", "->", "renamed", "as", "$", "name", "=>", "$", "newName", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "data", ")", ")", "{", "continue", ";", "}", "$", "data", "[", "$", "newName", "]", "=", "$", "data", "[", "$", "name", "]", ";", "unset", "(", "$", "data", "[", "$", "name", "]", ")", ";", "}", "return", "$", "data", ";", "}" ]
Return the object as Array. @return array @throws \ReflectionException
[ "Return", "the", "object", "as", "Array", "." ]
6780b81584619cb177d5d5e14fd7e87a9d8e48fd
https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Utils/Data/ArrayableData.php#L65-L77
240,209
setrun/setrun-component-sys
src/repositories/DomainRepository.php
DomainRepository.get
public function get($id): Domain { if (!$model = Domain::findOne($id)) { throw new NotFoundException($this->i18n->t('setrun/sys/domain', 'Domain is not found')); } return $model; }
php
public function get($id): Domain { if (!$model = Domain::findOne($id)) { throw new NotFoundException($this->i18n->t('setrun/sys/domain', 'Domain is not found')); } return $model; }
[ "public", "function", "get", "(", "$", "id", ")", ":", "Domain", "{", "if", "(", "!", "$", "model", "=", "Domain", "::", "findOne", "(", "$", "id", ")", ")", "{", "throw", "new", "NotFoundException", "(", "$", "this", "->", "i18n", "->", "t", "(", "'setrun/sys/domain'", ",", "'Domain is not found'", ")", ")", ";", "}", "return", "$", "model", ";", "}" ]
Find a domain item. @param $id @return Domain
[ "Find", "a", "domain", "item", "." ]
ad9a6442a2921e0f061ed4e455b050c56029d565
https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/repositories/DomainRepository.php#L34-L40
240,210
setrun/setrun-component-sys
src/repositories/DomainRepository.php
DomainRepository.save
public function save(Domain $model): void { if (!$model->save()) { throw new \RuntimeException($this->i18n->t('setrun/sys', 'Saving error')); } }
php
public function save(Domain $model): void { if (!$model->save()) { throw new \RuntimeException($this->i18n->t('setrun/sys', 'Saving error')); } }
[ "public", "function", "save", "(", "Domain", "$", "model", ")", ":", "void", "{", "if", "(", "!", "$", "model", "->", "save", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "$", "this", "->", "i18n", "->", "t", "(", "'setrun/sys'", ",", "'Saving error'", ")", ")", ";", "}", "}" ]
Save a domain item. @param Domain $model @return void
[ "Save", "a", "domain", "item", "." ]
ad9a6442a2921e0f061ed4e455b050c56029d565
https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/repositories/DomainRepository.php#L47-L52
240,211
b2r/php-exception
ExceptionTrait.php
ExceptionTrait.encodeArray
protected function encodeArray(array $args): array { foreach ($args as $key => $value) { if (is_object($value)) { $args[$key] = get_class($value); } } return $args; }
php
protected function encodeArray(array $args): array { foreach ($args as $key => $value) { if (is_object($value)) { $args[$key] = get_class($value); } } return $args; }
[ "protected", "function", "encodeArray", "(", "array", "$", "args", ")", ":", "array", "{", "foreach", "(", "$", "args", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "args", "[", "$", "key", "]", "=", "get_class", "(", "$", "value", ")", ";", "}", "}", "return", "$", "args", ";", "}" ]
Default array encoder - Convert object to class name
[ "Default", "array", "encoder" ]
419aa03ab7fc2cba9a66d5b7b9845b3b82a80d1d
https://github.com/b2r/php-exception/blob/419aa03ab7fc2cba9a66d5b7b9845b3b82a80d1d/ExceptionTrait.php#L46-L54
240,212
delboy1978uk/bone
src/Mvc/Application.php
Application.ahoy
public static function ahoy(array $config = []) { static $inst = null; if ($inst === null) { $inst = new Application(); $inst->registry = Registry::ahoy(); $inst->treasureChest = new Container(); $inst->setConfig($config); $env = getenv('APPLICATION_ENV'); if ($env) { $inst->setEnvironment($env); } } return $inst; }
php
public static function ahoy(array $config = []) { static $inst = null; if ($inst === null) { $inst = new Application(); $inst->registry = Registry::ahoy(); $inst->treasureChest = new Container(); $inst->setConfig($config); $env = getenv('APPLICATION_ENV'); if ($env) { $inst->setEnvironment($env); } } return $inst; }
[ "public", "static", "function", "ahoy", "(", "array", "$", "config", "=", "[", "]", ")", "{", "static", "$", "inst", "=", "null", ";", "if", "(", "$", "inst", "===", "null", ")", "{", "$", "inst", "=", "new", "Application", "(", ")", ";", "$", "inst", "->", "registry", "=", "Registry", "::", "ahoy", "(", ")", ";", "$", "inst", "->", "treasureChest", "=", "new", "Container", "(", ")", ";", "$", "inst", "->", "setConfig", "(", "$", "config", ")", ";", "$", "env", "=", "getenv", "(", "'APPLICATION_ENV'", ")", ";", "if", "(", "$", "env", ")", "{", "$", "inst", "->", "setEnvironment", "(", "$", "env", ")", ";", "}", "}", "return", "$", "inst", ";", "}" ]
Ahoy! There nay be boardin without yer configuration @param array $config @return Application
[ "Ahoy!", "There", "nay", "be", "boardin", "without", "yer", "configuration" ]
dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268
https://github.com/delboy1978uk/bone/blob/dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268/src/Mvc/Application.php#L39-L54
240,213
delboy1978uk/bone
src/Mvc/Application.php
Application.setSail
public function setSail() { $env = new Environment($_SERVER); if (!count($this->registry->getAll())) { $config = $env->fetchConfig($this->configFolder, $this->environment); $this->setConfig($config); } $request = ServerRequestFactory::fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES); $response = new Response(); $dispatcher = new Dispatcher($request, $response, $env); $dispatcher->fireCannons(); }
php
public function setSail() { $env = new Environment($_SERVER); if (!count($this->registry->getAll())) { $config = $env->fetchConfig($this->configFolder, $this->environment); $this->setConfig($config); } $request = ServerRequestFactory::fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES); $response = new Response(); $dispatcher = new Dispatcher($request, $response, $env); $dispatcher->fireCannons(); }
[ "public", "function", "setSail", "(", ")", "{", "$", "env", "=", "new", "Environment", "(", "$", "_SERVER", ")", ";", "if", "(", "!", "count", "(", "$", "this", "->", "registry", "->", "getAll", "(", ")", ")", ")", "{", "$", "config", "=", "$", "env", "->", "fetchConfig", "(", "$", "this", "->", "configFolder", ",", "$", "this", "->", "environment", ")", ";", "$", "this", "->", "setConfig", "(", "$", "config", ")", ";", "}", "$", "request", "=", "ServerRequestFactory", "::", "fromGlobals", "(", "$", "_SERVER", ",", "$", "_GET", ",", "$", "_POST", ",", "$", "_COOKIE", ",", "$", "_FILES", ")", ";", "$", "response", "=", "new", "Response", "(", ")", ";", "$", "dispatcher", "=", "new", "Dispatcher", "(", "$", "request", ",", "$", "response", ",", "$", "env", ")", ";", "$", "dispatcher", "->", "fireCannons", "(", ")", ";", "}" ]
T' the high seas! Garrr! @throws \Exception
[ "T", "the", "high", "seas!", "Garrr!" ]
dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268
https://github.com/delboy1978uk/bone/blob/dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268/src/Mvc/Application.php#L73-L84
240,214
perinatologie/hub-client-php
src/V3/HubV3Client.php
HubV3Client.listResources
private function listResources($filters = array(), $listType = null) { $uri = '/resources'; $query = array(); if ($listType) { $query[] = $listType; } foreach ($filters as $name => $value) { $query[] = "{$name}={$value}"; } if (sizeof($query)) { $uri .= '?' . implode('&', $query); } $body = $this->sendRequest($uri); $node = $this->parseXml((string)$body); return $this->parseResourcesXmlToResources($node); }
php
private function listResources($filters = array(), $listType = null) { $uri = '/resources'; $query = array(); if ($listType) { $query[] = $listType; } foreach ($filters as $name => $value) { $query[] = "{$name}={$value}"; } if (sizeof($query)) { $uri .= '?' . implode('&', $query); } $body = $this->sendRequest($uri); $node = $this->parseXml((string)$body); return $this->parseResourcesXmlToResources($node); }
[ "private", "function", "listResources", "(", "$", "filters", "=", "array", "(", ")", ",", "$", "listType", "=", "null", ")", "{", "$", "uri", "=", "'/resources'", ";", "$", "query", "=", "array", "(", ")", ";", "if", "(", "$", "listType", ")", "{", "$", "query", "[", "]", "=", "$", "listType", ";", "}", "foreach", "(", "$", "filters", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "query", "[", "]", "=", "\"{$name}={$value}\"", ";", "}", "if", "(", "sizeof", "(", "$", "query", ")", ")", "{", "$", "uri", ".=", "'?'", ".", "implode", "(", "'&'", ",", "$", "query", ")", ";", "}", "$", "body", "=", "$", "this", "->", "sendRequest", "(", "$", "uri", ")", ";", "$", "node", "=", "$", "this", "->", "parseXml", "(", "(", "string", ")", "$", "body", ")", ";", "return", "$", "this", "->", "parseResourcesXmlToResources", "(", "$", "node", ")", ";", "}" ]
Get a list of Resources. @param array $filters @param null|string one of 'shared_with', 'owned_by' and 'provided_by' @return \Hub\Client\Model\Resource[]
[ "Get", "a", "list", "of", "Resources", "." ]
3a0cf7ec6e3e5bf465167c283ee3dad9f4daaca3
https://github.com/perinatologie/hub-client-php/blob/3a0cf7ec6e3e5bf465167c283ee3dad9f4daaca3/src/V3/HubV3Client.php#L241-L258
240,215
AlexHowansky/ork-base
src/String/Base32.php
Base32.decode
public function decode($data) { // Make sure we have a valid data string. $mod = strlen($data) % 8; if ($mod === 1 || $mod === 3 || $mod === 6) { throw new \DomainException('Invalid input.'); } // Convert the data to a binary string. $bits = ''; foreach (str_split(strtoupper($data)) as $char) { $index = strpos($this->getConfig('alphabet'), $char); if ($index === false) { throw new \DomainException('Invalid character in input.'); } $bits .= sprintf('%05b', $index); } // Make sure padding is all zeroes. if (preg_match('/[^0]/', substr($bits, 0 - strlen($bits) % 8)) === 1) { throw new \DomainException('Invalid input.'); } // Decode the binary string. $output = ''; foreach (str_split($bits, 8) as $chunk) { $output .= chr(bindec($chunk)); } return rtrim($output); }
php
public function decode($data) { // Make sure we have a valid data string. $mod = strlen($data) % 8; if ($mod === 1 || $mod === 3 || $mod === 6) { throw new \DomainException('Invalid input.'); } // Convert the data to a binary string. $bits = ''; foreach (str_split(strtoupper($data)) as $char) { $index = strpos($this->getConfig('alphabet'), $char); if ($index === false) { throw new \DomainException('Invalid character in input.'); } $bits .= sprintf('%05b', $index); } // Make sure padding is all zeroes. if (preg_match('/[^0]/', substr($bits, 0 - strlen($bits) % 8)) === 1) { throw new \DomainException('Invalid input.'); } // Decode the binary string. $output = ''; foreach (str_split($bits, 8) as $chunk) { $output .= chr(bindec($chunk)); } return rtrim($output); }
[ "public", "function", "decode", "(", "$", "data", ")", "{", "// Make sure we have a valid data string.", "$", "mod", "=", "strlen", "(", "$", "data", ")", "%", "8", ";", "if", "(", "$", "mod", "===", "1", "||", "$", "mod", "===", "3", "||", "$", "mod", "===", "6", ")", "{", "throw", "new", "\\", "DomainException", "(", "'Invalid input.'", ")", ";", "}", "// Convert the data to a binary string.", "$", "bits", "=", "''", ";", "foreach", "(", "str_split", "(", "strtoupper", "(", "$", "data", ")", ")", "as", "$", "char", ")", "{", "$", "index", "=", "strpos", "(", "$", "this", "->", "getConfig", "(", "'alphabet'", ")", ",", "$", "char", ")", ";", "if", "(", "$", "index", "===", "false", ")", "{", "throw", "new", "\\", "DomainException", "(", "'Invalid character in input.'", ")", ";", "}", "$", "bits", ".=", "sprintf", "(", "'%05b'", ",", "$", "index", ")", ";", "}", "// Make sure padding is all zeroes.", "if", "(", "preg_match", "(", "'/[^0]/'", ",", "substr", "(", "$", "bits", ",", "0", "-", "strlen", "(", "$", "bits", ")", "%", "8", ")", ")", "===", "1", ")", "{", "throw", "new", "\\", "DomainException", "(", "'Invalid input.'", ")", ";", "}", "// Decode the binary string.", "$", "output", "=", "''", ";", "foreach", "(", "str_split", "(", "$", "bits", ",", "8", ")", "as", "$", "chunk", ")", "{", "$", "output", ".=", "chr", "(", "bindec", "(", "$", "chunk", ")", ")", ";", "}", "return", "rtrim", "(", "$", "output", ")", ";", "}" ]
Decode a base32 string. @param string $data The string to decode. @return string The decoded string.
[ "Decode", "a", "base32", "string", "." ]
5f4ab14e63bbc8b17898639fd1fff86ee6659bb0
https://github.com/AlexHowansky/ork-base/blob/5f4ab14e63bbc8b17898639fd1fff86ee6659bb0/src/String/Base32.php#L44-L75
240,216
AlexHowansky/ork-base
src/String/Base32.php
Base32.encode
public function encode($data) { // Convert the data to a binary string. $bits = ''; foreach (str_split($data) as $char) { $bits .= sprintf('%08b', ord($char)); } // Make sure the string length is a multiple of 5, padding if needed. $len = strlen($bits); $mod = $len % 5; if ($mod !== 0) { $bits = str_pad($bits, $len + 5 - $mod, '0', STR_PAD_RIGHT); } // Split the binary string into 5-bit chunks and encode each chunk. $output = ''; foreach (str_split($bits, 5) as $chunk) { $output .= substr($this->getConfig('alphabet'), bindec($chunk), 1); } return $output; }
php
public function encode($data) { // Convert the data to a binary string. $bits = ''; foreach (str_split($data) as $char) { $bits .= sprintf('%08b', ord($char)); } // Make sure the string length is a multiple of 5, padding if needed. $len = strlen($bits); $mod = $len % 5; if ($mod !== 0) { $bits = str_pad($bits, $len + 5 - $mod, '0', STR_PAD_RIGHT); } // Split the binary string into 5-bit chunks and encode each chunk. $output = ''; foreach (str_split($bits, 5) as $chunk) { $output .= substr($this->getConfig('alphabet'), bindec($chunk), 1); } return $output; }
[ "public", "function", "encode", "(", "$", "data", ")", "{", "// Convert the data to a binary string.", "$", "bits", "=", "''", ";", "foreach", "(", "str_split", "(", "$", "data", ")", "as", "$", "char", ")", "{", "$", "bits", ".=", "sprintf", "(", "'%08b'", ",", "ord", "(", "$", "char", ")", ")", ";", "}", "// Make sure the string length is a multiple of 5, padding if needed.", "$", "len", "=", "strlen", "(", "$", "bits", ")", ";", "$", "mod", "=", "$", "len", "%", "5", ";", "if", "(", "$", "mod", "!==", "0", ")", "{", "$", "bits", "=", "str_pad", "(", "$", "bits", ",", "$", "len", "+", "5", "-", "$", "mod", ",", "'0'", ",", "STR_PAD_RIGHT", ")", ";", "}", "// Split the binary string into 5-bit chunks and encode each chunk.", "$", "output", "=", "''", ";", "foreach", "(", "str_split", "(", "$", "bits", ",", "5", ")", "as", "$", "chunk", ")", "{", "$", "output", ".=", "substr", "(", "$", "this", "->", "getConfig", "(", "'alphabet'", ")", ",", "bindec", "(", "$", "chunk", ")", ",", "1", ")", ";", "}", "return", "$", "output", ";", "}" ]
Base32 encode a string. @param string $data The string to encode. @return string The base32 encoded string.
[ "Base32", "encode", "a", "string", "." ]
5f4ab14e63bbc8b17898639fd1fff86ee6659bb0
https://github.com/AlexHowansky/ork-base/blob/5f4ab14e63bbc8b17898639fd1fff86ee6659bb0/src/String/Base32.php#L84-L108
240,217
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/file/area.php
File_Area.get_handler
public function get_handler($path, array $config = array(), $content = array()) { $path = $this->get_path($path); if (is_file($path)) { $info = pathinfo($path); // deal with path names without an extension isset($info['extension']) or $info['extension'] = ''; // check file extension if ( ! empty($this->extensions) && ! in_array($info['extension'], $this->extensions)) { throw new \FileAccessException('File operation not allowed: disallowed file extension.'); } // create specific handler when available if (array_key_exists($info['extension'], $this->file_handlers)) { $class = '\\'.ltrim($this->file_handlers[$info['extension']], '\\'); return $class::forge($path, $config, $this); } return \File_Handler_File::forge($path, $config, $this); } elseif (is_dir($path)) { return \File_Handler_Directory::forge($path, $config, $this, $content); } // still here? path is invalid throw new \FileAccessException('Invalid path for file or directory.'); }
php
public function get_handler($path, array $config = array(), $content = array()) { $path = $this->get_path($path); if (is_file($path)) { $info = pathinfo($path); // deal with path names without an extension isset($info['extension']) or $info['extension'] = ''; // check file extension if ( ! empty($this->extensions) && ! in_array($info['extension'], $this->extensions)) { throw new \FileAccessException('File operation not allowed: disallowed file extension.'); } // create specific handler when available if (array_key_exists($info['extension'], $this->file_handlers)) { $class = '\\'.ltrim($this->file_handlers[$info['extension']], '\\'); return $class::forge($path, $config, $this); } return \File_Handler_File::forge($path, $config, $this); } elseif (is_dir($path)) { return \File_Handler_Directory::forge($path, $config, $this, $content); } // still here? path is invalid throw new \FileAccessException('Invalid path for file or directory.'); }
[ "public", "function", "get_handler", "(", "$", "path", ",", "array", "$", "config", "=", "array", "(", ")", ",", "$", "content", "=", "array", "(", ")", ")", "{", "$", "path", "=", "$", "this", "->", "get_path", "(", "$", "path", ")", ";", "if", "(", "is_file", "(", "$", "path", ")", ")", "{", "$", "info", "=", "pathinfo", "(", "$", "path", ")", ";", "// deal with path names without an extension", "isset", "(", "$", "info", "[", "'extension'", "]", ")", "or", "$", "info", "[", "'extension'", "]", "=", "''", ";", "// check file extension", "if", "(", "!", "empty", "(", "$", "this", "->", "extensions", ")", "&&", "!", "in_array", "(", "$", "info", "[", "'extension'", "]", ",", "$", "this", "->", "extensions", ")", ")", "{", "throw", "new", "\\", "FileAccessException", "(", "'File operation not allowed: disallowed file extension.'", ")", ";", "}", "// create specific handler when available", "if", "(", "array_key_exists", "(", "$", "info", "[", "'extension'", "]", ",", "$", "this", "->", "file_handlers", ")", ")", "{", "$", "class", "=", "'\\\\'", ".", "ltrim", "(", "$", "this", "->", "file_handlers", "[", "$", "info", "[", "'extension'", "]", "]", ",", "'\\\\'", ")", ";", "return", "$", "class", "::", "forge", "(", "$", "path", ",", "$", "config", ",", "$", "this", ")", ";", "}", "return", "\\", "File_Handler_File", "::", "forge", "(", "$", "path", ",", "$", "config", ",", "$", "this", ")", ";", "}", "elseif", "(", "is_dir", "(", "$", "path", ")", ")", "{", "return", "\\", "File_Handler_Directory", "::", "forge", "(", "$", "path", ",", "$", "config", ",", "$", "this", ",", "$", "content", ")", ";", "}", "// still here? path is invalid", "throw", "new", "\\", "FileAccessException", "(", "'Invalid path for file or directory.'", ")", ";", "}" ]
Handler factory for given path @param string path to file or directory @param array optional config @return File_Handler_File @throws FileAccessException when outside basedir restriction or disallowed file extension
[ "Handler", "factory", "for", "given", "path" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/file/area.php#L80-L113
240,218
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/file/area.php
File_Area.get_path
public function get_path($path) { $pathinfo = is_dir($path) ? array('dirname' => $path, 'extension' => null, 'basename' => '') : pathinfo($path); // make sure we have a dirname to work with isset($pathinfo['dirname']) or $pathinfo['dirname'] = ''; // do we have a basedir, and is the path already prefixed by the basedir? then just deal with the double dots... if ( ! empty($this->basedir) && substr($pathinfo['dirname'], 0, strlen($this->basedir)) == $this->basedir) { $pathinfo['dirname'] = realpath($pathinfo['dirname']); } else { // attempt to get the realpath(), otherwise just use path with any double dots taken out when basedir is set (for security) $pathinfo['dirname'] = ( ! empty($this->basedir) ? realpath($this->basedir.DS.$pathinfo['dirname']) : realpath($pathinfo['dirname']) ) ?: ( ! empty($this->basedir) ? $this->basedir.DS.str_replace('..', '', $pathinfo['dirname']) : $pathinfo['dirname']); } // basedir prefix is required when it is set (may cause unexpected errors when realpath doesn't work) if ( ! empty($this->basedir) && substr($pathinfo['dirname'], 0, strlen($this->basedir)) != $this->basedir) { throw new \OutsideAreaException('File operation not allowed: given path is outside the basedir for this area.'); } // check file extension if ( ! empty(static::$extensions) && array_key_exists($pathinfo['extension'], static::$extensions)) { throw new \FileAccessException('File operation not allowed: disallowed file extension.'); } return $pathinfo['dirname'].DS.$pathinfo['basename']; }
php
public function get_path($path) { $pathinfo = is_dir($path) ? array('dirname' => $path, 'extension' => null, 'basename' => '') : pathinfo($path); // make sure we have a dirname to work with isset($pathinfo['dirname']) or $pathinfo['dirname'] = ''; // do we have a basedir, and is the path already prefixed by the basedir? then just deal with the double dots... if ( ! empty($this->basedir) && substr($pathinfo['dirname'], 0, strlen($this->basedir)) == $this->basedir) { $pathinfo['dirname'] = realpath($pathinfo['dirname']); } else { // attempt to get the realpath(), otherwise just use path with any double dots taken out when basedir is set (for security) $pathinfo['dirname'] = ( ! empty($this->basedir) ? realpath($this->basedir.DS.$pathinfo['dirname']) : realpath($pathinfo['dirname']) ) ?: ( ! empty($this->basedir) ? $this->basedir.DS.str_replace('..', '', $pathinfo['dirname']) : $pathinfo['dirname']); } // basedir prefix is required when it is set (may cause unexpected errors when realpath doesn't work) if ( ! empty($this->basedir) && substr($pathinfo['dirname'], 0, strlen($this->basedir)) != $this->basedir) { throw new \OutsideAreaException('File operation not allowed: given path is outside the basedir for this area.'); } // check file extension if ( ! empty(static::$extensions) && array_key_exists($pathinfo['extension'], static::$extensions)) { throw new \FileAccessException('File operation not allowed: disallowed file extension.'); } return $pathinfo['dirname'].DS.$pathinfo['basename']; }
[ "public", "function", "get_path", "(", "$", "path", ")", "{", "$", "pathinfo", "=", "is_dir", "(", "$", "path", ")", "?", "array", "(", "'dirname'", "=>", "$", "path", ",", "'extension'", "=>", "null", ",", "'basename'", "=>", "''", ")", ":", "pathinfo", "(", "$", "path", ")", ";", "// make sure we have a dirname to work with", "isset", "(", "$", "pathinfo", "[", "'dirname'", "]", ")", "or", "$", "pathinfo", "[", "'dirname'", "]", "=", "''", ";", "// do we have a basedir, and is the path already prefixed by the basedir? then just deal with the double dots...", "if", "(", "!", "empty", "(", "$", "this", "->", "basedir", ")", "&&", "substr", "(", "$", "pathinfo", "[", "'dirname'", "]", ",", "0", ",", "strlen", "(", "$", "this", "->", "basedir", ")", ")", "==", "$", "this", "->", "basedir", ")", "{", "$", "pathinfo", "[", "'dirname'", "]", "=", "realpath", "(", "$", "pathinfo", "[", "'dirname'", "]", ")", ";", "}", "else", "{", "// attempt to get the realpath(), otherwise just use path with any double dots taken out when basedir is set (for security)", "$", "pathinfo", "[", "'dirname'", "]", "=", "(", "!", "empty", "(", "$", "this", "->", "basedir", ")", "?", "realpath", "(", "$", "this", "->", "basedir", ".", "DS", ".", "$", "pathinfo", "[", "'dirname'", "]", ")", ":", "realpath", "(", "$", "pathinfo", "[", "'dirname'", "]", ")", ")", "?", ":", "(", "!", "empty", "(", "$", "this", "->", "basedir", ")", "?", "$", "this", "->", "basedir", ".", "DS", ".", "str_replace", "(", "'..'", ",", "''", ",", "$", "pathinfo", "[", "'dirname'", "]", ")", ":", "$", "pathinfo", "[", "'dirname'", "]", ")", ";", "}", "// basedir prefix is required when it is set (may cause unexpected errors when realpath doesn't work)", "if", "(", "!", "empty", "(", "$", "this", "->", "basedir", ")", "&&", "substr", "(", "$", "pathinfo", "[", "'dirname'", "]", ",", "0", ",", "strlen", "(", "$", "this", "->", "basedir", ")", ")", "!=", "$", "this", "->", "basedir", ")", "{", "throw", "new", "\\", "OutsideAreaException", "(", "'File operation not allowed: given path is outside the basedir for this area.'", ")", ";", "}", "// check file extension", "if", "(", "!", "empty", "(", "static", "::", "$", "extensions", ")", "&&", "array_key_exists", "(", "$", "pathinfo", "[", "'extension'", "]", ",", "static", "::", "$", "extensions", ")", ")", "{", "throw", "new", "\\", "FileAccessException", "(", "'File operation not allowed: disallowed file extension.'", ")", ";", "}", "return", "$", "pathinfo", "[", "'dirname'", "]", ".", "DS", ".", "$", "pathinfo", "[", "'basename'", "]", ";", "}" ]
Translate relative path to real path, throws error when operation is not allowed @param string @return string @throws FileAccessException when outside basedir restriction or disallowed file extension
[ "Translate", "relative", "path", "to", "real", "path", "throws", "error", "when", "operation", "is", "not", "allowed" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/file/area.php#L142-L174
240,219
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/file/area.php
File_Area.get_url
public function get_url($path) { if(empty($this->url)) { throw new \LogicException('File operation now allowed: cannot create a file url without an area url.'); } $path = $this->get_path($path); $basedir = $this->basedir; empty($basedir) and $basedir = DOCROOT; if(stripos($path, $basedir) !== 0) { throw new \LogicException('File operation not allowed: cannot create file url whithout a basedir and file outside DOCROOT.'); } return rtrim($this->url, '/').'/'.ltrim(str_replace(DS, '/', substr($path, strlen($basedir))),'/'); }
php
public function get_url($path) { if(empty($this->url)) { throw new \LogicException('File operation now allowed: cannot create a file url without an area url.'); } $path = $this->get_path($path); $basedir = $this->basedir; empty($basedir) and $basedir = DOCROOT; if(stripos($path, $basedir) !== 0) { throw new \LogicException('File operation not allowed: cannot create file url whithout a basedir and file outside DOCROOT.'); } return rtrim($this->url, '/').'/'.ltrim(str_replace(DS, '/', substr($path, strlen($basedir))),'/'); }
[ "public", "function", "get_url", "(", "$", "path", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "url", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'File operation now allowed: cannot create a file url without an area url.'", ")", ";", "}", "$", "path", "=", "$", "this", "->", "get_path", "(", "$", "path", ")", ";", "$", "basedir", "=", "$", "this", "->", "basedir", ";", "empty", "(", "$", "basedir", ")", "and", "$", "basedir", "=", "DOCROOT", ";", "if", "(", "stripos", "(", "$", "path", ",", "$", "basedir", ")", "!==", "0", ")", "{", "throw", "new", "\\", "LogicException", "(", "'File operation not allowed: cannot create file url whithout a basedir and file outside DOCROOT.'", ")", ";", "}", "return", "rtrim", "(", "$", "this", "->", "url", ",", "'/'", ")", ".", "'/'", ".", "ltrim", "(", "str_replace", "(", "DS", ",", "'/'", ",", "substr", "(", "$", "path", ",", "strlen", "(", "$", "basedir", ")", ")", ")", ",", "'/'", ")", ";", "}" ]
Translate relative path to accessible path, throws error when operation is not allowed @param string @return string @throws LogicException when no url is set or no basedir is set and file is outside DOCROOT
[ "Translate", "relative", "path", "to", "accessible", "path", "throws", "error", "when", "operation", "is", "not", "allowed" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/file/area.php#L183-L201
240,220
eclogue/hayrick
src/Http/Request.php
Request.getPayload
public function getPayload(string $key, $default = null) { if ($this->payload === null) { $contentType = $this->getHeader('Content-Type', ''); if (!$contentType) { $contentType = $this->getHeader('Content-type'); } if ($contentType) { $contentTypeParts = preg_split('/\s*[;,]\s*/', $contentType); $contentType = $contentTypeParts[0]; $contentType = strtolower($contentType); if (isset($this->bodyParsers[$contentType])) { $parser = $this->bodyParsers[$contentType]; $this->payload = $parser($this->body); } } } return $this->payload[$key] ?? $default; }
php
public function getPayload(string $key, $default = null) { if ($this->payload === null) { $contentType = $this->getHeader('Content-Type', ''); if (!$contentType) { $contentType = $this->getHeader('Content-type'); } if ($contentType) { $contentTypeParts = preg_split('/\s*[;,]\s*/', $contentType); $contentType = $contentTypeParts[0]; $contentType = strtolower($contentType); if (isset($this->bodyParsers[$contentType])) { $parser = $this->bodyParsers[$contentType]; $this->payload = $parser($this->body); } } } return $this->payload[$key] ?? $default; }
[ "public", "function", "getPayload", "(", "string", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "$", "this", "->", "payload", "===", "null", ")", "{", "$", "contentType", "=", "$", "this", "->", "getHeader", "(", "'Content-Type'", ",", "''", ")", ";", "if", "(", "!", "$", "contentType", ")", "{", "$", "contentType", "=", "$", "this", "->", "getHeader", "(", "'Content-type'", ")", ";", "}", "if", "(", "$", "contentType", ")", "{", "$", "contentTypeParts", "=", "preg_split", "(", "'/\\s*[;,]\\s*/'", ",", "$", "contentType", ")", ";", "$", "contentType", "=", "$", "contentTypeParts", "[", "0", "]", ";", "$", "contentType", "=", "strtolower", "(", "$", "contentType", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "bodyParsers", "[", "$", "contentType", "]", ")", ")", "{", "$", "parser", "=", "$", "this", "->", "bodyParsers", "[", "$", "contentType", "]", ";", "$", "this", "->", "payload", "=", "$", "parser", "(", "$", "this", "->", "body", ")", ";", "}", "}", "}", "return", "$", "this", "->", "payload", "[", "$", "key", "]", "??", "$", "default", ";", "}" ]
get body param @param $key string @param null $default mixed @return mixed|null
[ "get", "body", "param" ]
06c31988b7b23cb11aaaced54e22b4c151f582da
https://github.com/eclogue/hayrick/blob/06c31988b7b23cb11aaaced54e22b4c151f582da/src/Http/Request.php#L197-L217
240,221
serebro/reach-common
src/Bench.php
Bench.end
public function end($name = self::DEFAULT_NAME) { $this->end_time[$name] = microtime(true); $this->memory_usage[$name] = memory_get_usage(true); }
php
public function end($name = self::DEFAULT_NAME) { $this->end_time[$name] = microtime(true); $this->memory_usage[$name] = memory_get_usage(true); }
[ "public", "function", "end", "(", "$", "name", "=", "self", "::", "DEFAULT_NAME", ")", "{", "$", "this", "->", "end_time", "[", "$", "name", "]", "=", "microtime", "(", "true", ")", ";", "$", "this", "->", "memory_usage", "[", "$", "name", "]", "=", "memory_get_usage", "(", "true", ")", ";", "}" ]
Sets end microtime @param string $name @return void
[ "Sets", "end", "microtime" ]
e62e606cfd16677653adfc1db00327cc49d7f7a1
https://github.com/serebro/reach-common/blob/e62e606cfd16677653adfc1db00327cc49d7f7a1/src/Bench.php#L32-L36
240,222
serebro/reach-common
src/Bench.php
Bench.getTime
public function getTime($raw = false, $format = null, $name = self::DEFAULT_NAME) { $elapsed = $this->end_time[$name] - $this->start_time[$name]; return $raw ? $elapsed : self::readableElapsedTime($elapsed, $format, $name); }
php
public function getTime($raw = false, $format = null, $name = self::DEFAULT_NAME) { $elapsed = $this->end_time[$name] - $this->start_time[$name]; return $raw ? $elapsed : self::readableElapsedTime($elapsed, $format, $name); }
[ "public", "function", "getTime", "(", "$", "raw", "=", "false", ",", "$", "format", "=", "null", ",", "$", "name", "=", "self", "::", "DEFAULT_NAME", ")", "{", "$", "elapsed", "=", "$", "this", "->", "end_time", "[", "$", "name", "]", "-", "$", "this", "->", "start_time", "[", "$", "name", "]", ";", "return", "$", "raw", "?", "$", "elapsed", ":", "self", "::", "readableElapsedTime", "(", "$", "elapsed", ",", "$", "format", ",", "$", "name", ")", ";", "}" ]
Returns the elapsed time, readable or not @param boolean $raw Whether the result must be human readable @param string $format The format to display (printf format) @param string $name @return string|float
[ "Returns", "the", "elapsed", "time", "readable", "or", "not" ]
e62e606cfd16677653adfc1db00327cc49d7f7a1
https://github.com/serebro/reach-common/blob/e62e606cfd16677653adfc1db00327cc49d7f7a1/src/Bench.php#L46-L50
240,223
serebro/reach-common
src/Bench.php
Bench.getMemoryUsage
public function getMemoryUsage($raw = false, $format = null, $name = self::DEFAULT_NAME) { return $raw ? $this->memory_usage[$name] : self::readableSize($this->memory_usage[$name], $format); }
php
public function getMemoryUsage($raw = false, $format = null, $name = self::DEFAULT_NAME) { return $raw ? $this->memory_usage[$name] : self::readableSize($this->memory_usage[$name], $format); }
[ "public", "function", "getMemoryUsage", "(", "$", "raw", "=", "false", ",", "$", "format", "=", "null", ",", "$", "name", "=", "self", "::", "DEFAULT_NAME", ")", "{", "return", "$", "raw", "?", "$", "this", "->", "memory_usage", "[", "$", "name", "]", ":", "self", "::", "readableSize", "(", "$", "this", "->", "memory_usage", "[", "$", "name", "]", ",", "$", "format", ")", ";", "}" ]
Returns the memory usage at the end checkpoint @param boolean $raw Whether the result must be human readable @param string $format The format to display (printf format) @param string $name @return string|float
[ "Returns", "the", "memory", "usage", "at", "the", "end", "checkpoint" ]
e62e606cfd16677653adfc1db00327cc49d7f7a1
https://github.com/serebro/reach-common/blob/e62e606cfd16677653adfc1db00327cc49d7f7a1/src/Bench.php#L60-L63
240,224
serebro/reach-common
src/Bench.php
Bench.getMemoryPeak
public function getMemoryPeak($raw = false, $format = null) { $memory = memory_get_peak_usage(true); return $raw ? $memory : self::readableSize($memory, $format); }
php
public function getMemoryPeak($raw = false, $format = null) { $memory = memory_get_peak_usage(true); return $raw ? $memory : self::readableSize($memory, $format); }
[ "public", "function", "getMemoryPeak", "(", "$", "raw", "=", "false", ",", "$", "format", "=", "null", ")", "{", "$", "memory", "=", "memory_get_peak_usage", "(", "true", ")", ";", "return", "$", "raw", "?", "$", "memory", ":", "self", "::", "readableSize", "(", "$", "memory", ",", "$", "format", ")", ";", "}" ]
Returns the memory peak, readable or not @param boolean $raw Whether the result must be human readable @param string $format The format to display (printf format) @return string|float
[ "Returns", "the", "memory", "peak", "readable", "or", "not" ]
e62e606cfd16677653adfc1db00327cc49d7f7a1
https://github.com/serebro/reach-common/blob/e62e606cfd16677653adfc1db00327cc49d7f7a1/src/Bench.php#L71-L75
240,225
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/WidgetController.php
WidgetController.mostRecentOrdersAction
public function mostRecentOrdersAction($max = 20) { $em = $this->getDoctrine()->getManager(); /** @var ProductOrderRepository $productOrderRepo */ $productOrderRepo = $em->getRepository('AmulenShopBundle:ProductOrder'); $orders = $productOrderRepo->recentOrders($max); return [ 'orders' => $orders, ]; }
php
public function mostRecentOrdersAction($max = 20) { $em = $this->getDoctrine()->getManager(); /** @var ProductOrderRepository $productOrderRepo */ $productOrderRepo = $em->getRepository('AmulenShopBundle:ProductOrder'); $orders = $productOrderRepo->recentOrders($max); return [ 'orders' => $orders, ]; }
[ "public", "function", "mostRecentOrdersAction", "(", "$", "max", "=", "20", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "/** @var ProductOrderRepository $productOrderRepo */", "$", "productOrderRepo", "=", "$", "em", "->", "getRepository", "(", "'AmulenShopBundle:ProductOrder'", ")", ";", "$", "orders", "=", "$", "productOrderRepo", "->", "recentOrders", "(", "$", "max", ")", ";", "return", "[", "'orders'", "=>", "$", "orders", ",", "]", ";", "}" ]
Last n product orders. @Template()
[ "Last", "n", "product", "orders", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/WidgetController.php#L19-L30
240,226
sebardo/ecommerce
EcommerceBundle/Factory/Providers/BankTransferProvider.php
BankTransferProvider.process
public function process(Request $request, Transaction $transaction, Delivery $delivery) { //UPDATE TRANSACTION $em = $this->container->get('doctrine')->getManager(); $pm = $em->getRepository('EcommerceBundle:PaymentMethod')->findOneBySlug('bank-transfer-test'); $transaction->setStatus(Transaction::STATUS_PAID); $transaction->setPaymentMethod($pm); $em->persist($transaction); $em->flush(); //confirmation payment $answer = new stdClass(); $answer->redirectUrl = $this->container->get('router')->generate('ecommerce_checkout_confirmationpayment'); return $answer; }
php
public function process(Request $request, Transaction $transaction, Delivery $delivery) { //UPDATE TRANSACTION $em = $this->container->get('doctrine')->getManager(); $pm = $em->getRepository('EcommerceBundle:PaymentMethod')->findOneBySlug('bank-transfer-test'); $transaction->setStatus(Transaction::STATUS_PAID); $transaction->setPaymentMethod($pm); $em->persist($transaction); $em->flush(); //confirmation payment $answer = new stdClass(); $answer->redirectUrl = $this->container->get('router')->generate('ecommerce_checkout_confirmationpayment'); return $answer; }
[ "public", "function", "process", "(", "Request", "$", "request", ",", "Transaction", "$", "transaction", ",", "Delivery", "$", "delivery", ")", "{", "//UPDATE TRANSACTION", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", ")", ";", "$", "pm", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:PaymentMethod'", ")", "->", "findOneBySlug", "(", "'bank-transfer-test'", ")", ";", "$", "transaction", "->", "setStatus", "(", "Transaction", "::", "STATUS_PAID", ")", ";", "$", "transaction", "->", "setPaymentMethod", "(", "$", "pm", ")", ";", "$", "em", "->", "persist", "(", "$", "transaction", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "//confirmation payment", "$", "answer", "=", "new", "stdClass", "(", ")", ";", "$", "answer", "->", "redirectUrl", "=", "$", "this", "->", "container", "->", "get", "(", "'router'", ")", "->", "generate", "(", "'ecommerce_checkout_confirmationpayment'", ")", ";", "return", "$", "answer", ";", "}" ]
Process payment OK @param Request $request @return stdClass
[ "Process", "payment", "OK" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Factory/Providers/BankTransferProvider.php#L45-L59
240,227
AnonymPHP/Anonym-Library
src/Anonym/Html/Form/FormHaveOptions.php
FormHaveOptions.buildOptions
protected function buildOptions() { $created = ''; foreach($this->getOptions() as $key => $value){ if ($key === 'class') { $value = $this->buildClassString($value); } $created .= "$key='$value' "; } return rtrim($created, ' '); }
php
protected function buildOptions() { $created = ''; foreach($this->getOptions() as $key => $value){ if ($key === 'class') { $value = $this->buildClassString($value); } $created .= "$key='$value' "; } return rtrim($created, ' '); }
[ "protected", "function", "buildOptions", "(", ")", "{", "$", "created", "=", "''", ";", "foreach", "(", "$", "this", "->", "getOptions", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "===", "'class'", ")", "{", "$", "value", "=", "$", "this", "->", "buildClassString", "(", "$", "value", ")", ";", "}", "$", "created", ".=", "\"$key='$value' \"", ";", "}", "return", "rtrim", "(", "$", "created", ",", "' '", ")", ";", "}" ]
build options string @return string
[ "build", "options", "string" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Html/Form/FormHaveOptions.php#L62-L76
240,228
phlexible/indexer-bundle
Result/ResultSet.php
ResultSet.add
public function add(DocumentInterface $document) { $this->documents[(string) $document->getIdentity()] = $document; return $this; }
php
public function add(DocumentInterface $document) { $this->documents[(string) $document->getIdentity()] = $document; return $this; }
[ "public", "function", "add", "(", "DocumentInterface", "$", "document", ")", "{", "$", "this", "->", "documents", "[", "(", "string", ")", "$", "document", "->", "getIdentity", "(", ")", "]", "=", "$", "document", ";", "return", "$", "this", ";", "}" ]
Adds a document to the result set. @param \Phlexible\Bundle\IndexerBundle\Document\DocumentInterface $document @return $this
[ "Adds", "a", "document", "to", "the", "result", "set", "." ]
5c568d056f6c71f7cb80a7ff9e36d35bc487f7f8
https://github.com/phlexible/indexer-bundle/blob/5c568d056f6c71f7cb80a7ff9e36d35bc487f7f8/Result/ResultSet.php#L65-L70
240,229
mgufrone/silex-assets-provider
src/Gufy/Service/Provider/AssetsServiceProvider.php
AssetsServiceProvider.register
public function register(Application $app) { $assets = $this; $app['assets'] = $app->share(function() use($app, $assets){ return $assets; }); }
php
public function register(Application $app) { $assets = $this; $app['assets'] = $app->share(function() use($app, $assets){ return $assets; }); }
[ "public", "function", "register", "(", "Application", "$", "app", ")", "{", "$", "assets", "=", "$", "this", ";", "$", "app", "[", "'assets'", "]", "=", "$", "app", "->", "share", "(", "function", "(", ")", "use", "(", "$", "app", ",", "$", "assets", ")", "{", "return", "$", "assets", ";", "}", ")", ";", "}" ]
implementation of Silex Service Provider register method
[ "implementation", "of", "Silex", "Service", "Provider", "register", "method" ]
072ca09f997225f1f298ca5f77dc23280dd6aa7a
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsServiceProvider.php#L83-L90
240,230
mgufrone/silex-assets-provider
src/Gufy/Service/Provider/AssetsServiceProvider.php
AssetsServiceProvider.boot
public function boot(Application $app) { $assets = $this; $app->before(function(Request $request) use($app, $assets){ $baseUrl = rtrim($request->getScheme().'://'.$request->getHttpHost().$request->getBasePath()).'/'; $assets->setCoreUrl($baseUrl); $assets->setOption('baseUrl', $baseUrl); $assets->setOption('jsPosition',$assets::ON_BODY); return $assets; }); // Registering preloaded options $options = isset($app['assets.options'])?$app['assets.options']:array(); if(!empty($options)) array_walk($options, function($optionValue, $optionName) use($assets){ $assets->setOption($optionName, $optionValue); }); // Registering preloaded javascript files $js = isset($app['assets.js'])?$app['assets.js']:array(); if(!empty($js)) array_walk($js, function($value) use($assets){ $assets->registerJs($value); }); // Registering preloaded css files $css = isset($app['assets.css'])?$app['assets.css']:array(); if(!empty($css)) array_walk($css, function($value) use($assets){ $assets->registerCss($value); }); $app->after(function(Request $request, Response $response) use($app, $assets){ // print_r($response->headers->get('content_type')); if($response->headers->get('content_type')!='application/json') { $content = $response->getContent(); $assets->renderAssets($content); $response->setContent($content); } return $response; }); }
php
public function boot(Application $app) { $assets = $this; $app->before(function(Request $request) use($app, $assets){ $baseUrl = rtrim($request->getScheme().'://'.$request->getHttpHost().$request->getBasePath()).'/'; $assets->setCoreUrl($baseUrl); $assets->setOption('baseUrl', $baseUrl); $assets->setOption('jsPosition',$assets::ON_BODY); return $assets; }); // Registering preloaded options $options = isset($app['assets.options'])?$app['assets.options']:array(); if(!empty($options)) array_walk($options, function($optionValue, $optionName) use($assets){ $assets->setOption($optionName, $optionValue); }); // Registering preloaded javascript files $js = isset($app['assets.js'])?$app['assets.js']:array(); if(!empty($js)) array_walk($js, function($value) use($assets){ $assets->registerJs($value); }); // Registering preloaded css files $css = isset($app['assets.css'])?$app['assets.css']:array(); if(!empty($css)) array_walk($css, function($value) use($assets){ $assets->registerCss($value); }); $app->after(function(Request $request, Response $response) use($app, $assets){ // print_r($response->headers->get('content_type')); if($response->headers->get('content_type')!='application/json') { $content = $response->getContent(); $assets->renderAssets($content); $response->setContent($content); } return $response; }); }
[ "public", "function", "boot", "(", "Application", "$", "app", ")", "{", "$", "assets", "=", "$", "this", ";", "$", "app", "->", "before", "(", "function", "(", "Request", "$", "request", ")", "use", "(", "$", "app", ",", "$", "assets", ")", "{", "$", "baseUrl", "=", "rtrim", "(", "$", "request", "->", "getScheme", "(", ")", ".", "'://'", ".", "$", "request", "->", "getHttpHost", "(", ")", ".", "$", "request", "->", "getBasePath", "(", ")", ")", ".", "'/'", ";", "$", "assets", "->", "setCoreUrl", "(", "$", "baseUrl", ")", ";", "$", "assets", "->", "setOption", "(", "'baseUrl'", ",", "$", "baseUrl", ")", ";", "$", "assets", "->", "setOption", "(", "'jsPosition'", ",", "$", "assets", "::", "ON_BODY", ")", ";", "return", "$", "assets", ";", "}", ")", ";", "// Registering preloaded options", "$", "options", "=", "isset", "(", "$", "app", "[", "'assets.options'", "]", ")", "?", "$", "app", "[", "'assets.options'", "]", ":", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "options", ")", ")", "array_walk", "(", "$", "options", ",", "function", "(", "$", "optionValue", ",", "$", "optionName", ")", "use", "(", "$", "assets", ")", "{", "$", "assets", "->", "setOption", "(", "$", "optionName", ",", "$", "optionValue", ")", ";", "}", ")", ";", "// Registering preloaded javascript files", "$", "js", "=", "isset", "(", "$", "app", "[", "'assets.js'", "]", ")", "?", "$", "app", "[", "'assets.js'", "]", ":", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "js", ")", ")", "array_walk", "(", "$", "js", ",", "function", "(", "$", "value", ")", "use", "(", "$", "assets", ")", "{", "$", "assets", "->", "registerJs", "(", "$", "value", ")", ";", "}", ")", ";", "// Registering preloaded css files", "$", "css", "=", "isset", "(", "$", "app", "[", "'assets.css'", "]", ")", "?", "$", "app", "[", "'assets.css'", "]", ":", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "css", ")", ")", "array_walk", "(", "$", "css", ",", "function", "(", "$", "value", ")", "use", "(", "$", "assets", ")", "{", "$", "assets", "->", "registerCss", "(", "$", "value", ")", ";", "}", ")", ";", "$", "app", "->", "after", "(", "function", "(", "Request", "$", "request", ",", "Response", "$", "response", ")", "use", "(", "$", "app", ",", "$", "assets", ")", "{", "// print_r($response->headers->get('content_type'));", "if", "(", "$", "response", "->", "headers", "->", "get", "(", "'content_type'", ")", "!=", "'application/json'", ")", "{", "$", "content", "=", "$", "response", "->", "getContent", "(", ")", ";", "$", "assets", "->", "renderAssets", "(", "$", "content", ")", ";", "$", "response", "->", "setContent", "(", "$", "content", ")", ";", "}", "return", "$", "response", ";", "}", ")", ";", "}" ]
implementation of Silex Service Provider boot method
[ "implementation", "of", "Silex", "Service", "Provider", "boot", "method" ]
072ca09f997225f1f298ca5f77dc23280dd6aa7a
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsServiceProvider.php#L93-L135
240,231
mgufrone/silex-assets-provider
src/Gufy/Service/Provider/AssetsServiceProvider.php
AssetsServiceProvider.renderAssets
public function renderAssets(&$content) { $this->prepareAssets(); $js = $this->renderJs(); $css = $this->renderCss(); $bodyJs = $this->renderJs(self::ON_BODY); if(!empty($css)) { if(strpos($content, "</head>")>0) $content = str_replace("</head>","####replace-css-here####</head>",$content); else $content = "####replace-css-here####".$content; $content = str_replace("####replace-css-here####",$css,$content); } if(!empty($js)) { if(strpos($content, "</body>")>0) $content = str_replace("</body>","####replace-js-here####</body>",$content); else $content .= "####replace-js-here####"; $content = str_replace("####replace-js-here####",$js,$content); } if(!empty($bodyJs)) { if(strpos($content, "</body>")>0) $content = str_replace("</body>","####replace-js-here####</body>",$content); else $content .= "####replace-js-here####"; $content = str_replace("####replace-js-here####",$bodyJs,$content); } return $content; }
php
public function renderAssets(&$content) { $this->prepareAssets(); $js = $this->renderJs(); $css = $this->renderCss(); $bodyJs = $this->renderJs(self::ON_BODY); if(!empty($css)) { if(strpos($content, "</head>")>0) $content = str_replace("</head>","####replace-css-here####</head>",$content); else $content = "####replace-css-here####".$content; $content = str_replace("####replace-css-here####",$css,$content); } if(!empty($js)) { if(strpos($content, "</body>")>0) $content = str_replace("</body>","####replace-js-here####</body>",$content); else $content .= "####replace-js-here####"; $content = str_replace("####replace-js-here####",$js,$content); } if(!empty($bodyJs)) { if(strpos($content, "</body>")>0) $content = str_replace("</body>","####replace-js-here####</body>",$content); else $content .= "####replace-js-here####"; $content = str_replace("####replace-js-here####",$bodyJs,$content); } return $content; }
[ "public", "function", "renderAssets", "(", "&", "$", "content", ")", "{", "$", "this", "->", "prepareAssets", "(", ")", ";", "$", "js", "=", "$", "this", "->", "renderJs", "(", ")", ";", "$", "css", "=", "$", "this", "->", "renderCss", "(", ")", ";", "$", "bodyJs", "=", "$", "this", "->", "renderJs", "(", "self", "::", "ON_BODY", ")", ";", "if", "(", "!", "empty", "(", "$", "css", ")", ")", "{", "if", "(", "strpos", "(", "$", "content", ",", "\"</head>\"", ")", ">", "0", ")", "$", "content", "=", "str_replace", "(", "\"</head>\"", ",", "\"####replace-css-here####</head>\"", ",", "$", "content", ")", ";", "else", "$", "content", "=", "\"####replace-css-here####\"", ".", "$", "content", ";", "$", "content", "=", "str_replace", "(", "\"####replace-css-here####\"", ",", "$", "css", ",", "$", "content", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "js", ")", ")", "{", "if", "(", "strpos", "(", "$", "content", ",", "\"</body>\"", ")", ">", "0", ")", "$", "content", "=", "str_replace", "(", "\"</body>\"", ",", "\"####replace-js-here####</body>\"", ",", "$", "content", ")", ";", "else", "$", "content", ".=", "\"####replace-js-here####\"", ";", "$", "content", "=", "str_replace", "(", "\"####replace-js-here####\"", ",", "$", "js", ",", "$", "content", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "bodyJs", ")", ")", "{", "if", "(", "strpos", "(", "$", "content", ",", "\"</body>\"", ")", ">", "0", ")", "$", "content", "=", "str_replace", "(", "\"</body>\"", ",", "\"####replace-js-here####</body>\"", ",", "$", "content", ")", ";", "else", "$", "content", ".=", "\"####replace-js-here####\"", ";", "$", "content", "=", "str_replace", "(", "\"####replace-js-here####\"", ",", "$", "bodyJs", ",", "$", "content", ")", ";", "}", "return", "$", "content", ";", "}" ]
begin rendering assets when response is valid and has been processed. this is automatically triggered, so you don't need to trigger it manually @param String $content @return String $content content that has been preprocessed with registered assets and returned back
[ "begin", "rendering", "assets", "when", "response", "is", "valid", "and", "has", "been", "processed", ".", "this", "is", "automatically", "triggered", "so", "you", "don", "t", "need", "to", "trigger", "it", "manually" ]
072ca09f997225f1f298ca5f77dc23280dd6aa7a
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsServiceProvider.php#L153-L186
240,232
mgufrone/silex-assets-provider
src/Gufy/Service/Provider/AssetsServiceProvider.php
AssetsServiceProvider.renderJs
public function renderJs($position=self::ON_HEAD) { $result = ""; $js = $this->getJs($position); if(!empty($js)) array_walk($js, function($value) use (&$result){ $result .= '<script src="'.$value.'" type="text/javascript"></script>'; }); $custom = $this->getCustomJs($position); if(!empty($custom)) { $customJs = '<script type="text/javascript" id="silex-assets-service-js-'.substr(md5(time()),0,5).'">'; if($custom !== array()) array_walk($custom, function($value) use (&$customJs){ $customJs .= $value."\n"; }); $customJs .= "</script>"; $result .= $customJs; } return $result; }
php
public function renderJs($position=self::ON_HEAD) { $result = ""; $js = $this->getJs($position); if(!empty($js)) array_walk($js, function($value) use (&$result){ $result .= '<script src="'.$value.'" type="text/javascript"></script>'; }); $custom = $this->getCustomJs($position); if(!empty($custom)) { $customJs = '<script type="text/javascript" id="silex-assets-service-js-'.substr(md5(time()),0,5).'">'; if($custom !== array()) array_walk($custom, function($value) use (&$customJs){ $customJs .= $value."\n"; }); $customJs .= "</script>"; $result .= $customJs; } return $result; }
[ "public", "function", "renderJs", "(", "$", "position", "=", "self", "::", "ON_HEAD", ")", "{", "$", "result", "=", "\"\"", ";", "$", "js", "=", "$", "this", "->", "getJs", "(", "$", "position", ")", ";", "if", "(", "!", "empty", "(", "$", "js", ")", ")", "array_walk", "(", "$", "js", ",", "function", "(", "$", "value", ")", "use", "(", "&", "$", "result", ")", "{", "$", "result", ".=", "'<script src=\"'", ".", "$", "value", ".", "'\" type=\"text/javascript\"></script>'", ";", "}", ")", ";", "$", "custom", "=", "$", "this", "->", "getCustomJs", "(", "$", "position", ")", ";", "if", "(", "!", "empty", "(", "$", "custom", ")", ")", "{", "$", "customJs", "=", "'<script type=\"text/javascript\" id=\"silex-assets-service-js-'", ".", "substr", "(", "md5", "(", "time", "(", ")", ")", ",", "0", ",", "5", ")", ".", "'\">'", ";", "if", "(", "$", "custom", "!==", "array", "(", ")", ")", "array_walk", "(", "$", "custom", ",", "function", "(", "$", "value", ")", "use", "(", "&", "$", "customJs", ")", "{", "$", "customJs", ".=", "$", "value", ".", "\"\\n\"", ";", "}", ")", ";", "$", "customJs", ".=", "\"</script>\"", ";", "$", "result", ".=", "$", "customJs", ";", "}", "return", "$", "result", ";", "}" ]
Begin processing registering Javascripts if available @return String $result if app has javascript files, all registered javascripts will be converted as readable html script
[ "Begin", "processing", "registering", "Javascripts", "if", "available" ]
072ca09f997225f1f298ca5f77dc23280dd6aa7a
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsServiceProvider.php#L192-L212
240,233
mgufrone/silex-assets-provider
src/Gufy/Service/Provider/AssetsServiceProvider.php
AssetsServiceProvider.renderCss
public function renderCss() { $result = ""; $css = $this->getCss(); if(!empty($css)) array_walk($css, function($value) use (&$result){ $result .= '<link href="'.$value.'" type="text/css" rel="stylesheet">'; }); $custom = $this->getCustomCss(); if(!empty($custom)) { $customCss = '<style type="text/css" rel="stylesheet" id="silex-assets-service-css-'.substr(md5(time()),0,5).'">'; if($custom !== array()) array_walk($custom, function($value) use (&$customCss){ $customCss .= $value."\n"; }); $customCss .= "</style>"; $result .= $customCss; } return $result; }
php
public function renderCss() { $result = ""; $css = $this->getCss(); if(!empty($css)) array_walk($css, function($value) use (&$result){ $result .= '<link href="'.$value.'" type="text/css" rel="stylesheet">'; }); $custom = $this->getCustomCss(); if(!empty($custom)) { $customCss = '<style type="text/css" rel="stylesheet" id="silex-assets-service-css-'.substr(md5(time()),0,5).'">'; if($custom !== array()) array_walk($custom, function($value) use (&$customCss){ $customCss .= $value."\n"; }); $customCss .= "</style>"; $result .= $customCss; } return $result; }
[ "public", "function", "renderCss", "(", ")", "{", "$", "result", "=", "\"\"", ";", "$", "css", "=", "$", "this", "->", "getCss", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "css", ")", ")", "array_walk", "(", "$", "css", ",", "function", "(", "$", "value", ")", "use", "(", "&", "$", "result", ")", "{", "$", "result", ".=", "'<link href=\"'", ".", "$", "value", ".", "'\" type=\"text/css\" rel=\"stylesheet\">'", ";", "}", ")", ";", "$", "custom", "=", "$", "this", "->", "getCustomCss", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "custom", ")", ")", "{", "$", "customCss", "=", "'<style type=\"text/css\" rel=\"stylesheet\" id=\"silex-assets-service-css-'", ".", "substr", "(", "md5", "(", "time", "(", ")", ")", ",", "0", ",", "5", ")", ".", "'\">'", ";", "if", "(", "$", "custom", "!==", "array", "(", ")", ")", "array_walk", "(", "$", "custom", ",", "function", "(", "$", "value", ")", "use", "(", "&", "$", "customCss", ")", "{", "$", "customCss", ".=", "$", "value", ".", "\"\\n\"", ";", "}", ")", ";", "$", "customCss", ".=", "\"</style>\"", ";", "$", "result", ".=", "$", "customCss", ";", "}", "return", "$", "result", ";", "}" ]
Begin processing registering Css Files if available @return String $result if app has css files, all registered css will be converted as readable html script
[ "Begin", "processing", "registering", "Css", "Files", "if", "available" ]
072ca09f997225f1f298ca5f77dc23280dd6aa7a
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsServiceProvider.php#L218-L238
240,234
mgufrone/silex-assets-provider
src/Gufy/Service/Provider/AssetsServiceProvider.php
AssetsServiceProvider.getJs
public function getJs($position=self::ON_HEAD) { if($this->js===array()) return array(); $js = isset($this->js[$position])&&!empty($this->js[$position])?$this->js[$position]:array(); if($js===array()) return $js; $options = $this->options; if($this->isCombineEnabled()) $this->combine('js', $js); // avoiding duplicate assets $js = array_flip(array_flip($js)); array_walk($js, function(&$value) use($options){ if(!empty($options['baseUrl'])&&strpos($value,'http://')===false) $value = $options['baseUrl'].$value; }); return $js; }
php
public function getJs($position=self::ON_HEAD) { if($this->js===array()) return array(); $js = isset($this->js[$position])&&!empty($this->js[$position])?$this->js[$position]:array(); if($js===array()) return $js; $options = $this->options; if($this->isCombineEnabled()) $this->combine('js', $js); // avoiding duplicate assets $js = array_flip(array_flip($js)); array_walk($js, function(&$value) use($options){ if(!empty($options['baseUrl'])&&strpos($value,'http://')===false) $value = $options['baseUrl'].$value; }); return $js; }
[ "public", "function", "getJs", "(", "$", "position", "=", "self", "::", "ON_HEAD", ")", "{", "if", "(", "$", "this", "->", "js", "===", "array", "(", ")", ")", "return", "array", "(", ")", ";", "$", "js", "=", "isset", "(", "$", "this", "->", "js", "[", "$", "position", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "js", "[", "$", "position", "]", ")", "?", "$", "this", "->", "js", "[", "$", "position", "]", ":", "array", "(", ")", ";", "if", "(", "$", "js", "===", "array", "(", ")", ")", "return", "$", "js", ";", "$", "options", "=", "$", "this", "->", "options", ";", "if", "(", "$", "this", "->", "isCombineEnabled", "(", ")", ")", "$", "this", "->", "combine", "(", "'js'", ",", "$", "js", ")", ";", "// avoiding duplicate assets", "$", "js", "=", "array_flip", "(", "array_flip", "(", "$", "js", ")", ")", ";", "array_walk", "(", "$", "js", ",", "function", "(", "&", "$", "value", ")", "use", "(", "$", "options", ")", "{", "if", "(", "!", "empty", "(", "$", "options", "[", "'baseUrl'", "]", ")", "&&", "strpos", "(", "$", "value", ",", "'http://'", ")", "===", "false", ")", "$", "value", "=", "$", "options", "[", "'baseUrl'", "]", ".", "$", "value", ";", "}", ")", ";", "return", "$", "js", ";", "}" ]
Get all registered javascripts @return array $this->js all available javascripts
[ "Get", "all", "registered", "javascripts" ]
072ca09f997225f1f298ca5f77dc23280dd6aa7a
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsServiceProvider.php#L244-L262
240,235
mgufrone/silex-assets-provider
src/Gufy/Service/Provider/AssetsServiceProvider.php
AssetsServiceProvider.getCss
public function getCss() { $css = $this->css; $options = $this->options; if($this->isCombineEnabled()) $this->combine('css', $css); // avoiding duplicate assets $css = array_flip(array_flip($css)); array_walk($css, function(&$value) use($options){ if(!empty($options['baseUrl'])&&strpos($value,'http://')===false) $value = $options['baseUrl'].$value; }); return $css; }
php
public function getCss() { $css = $this->css; $options = $this->options; if($this->isCombineEnabled()) $this->combine('css', $css); // avoiding duplicate assets $css = array_flip(array_flip($css)); array_walk($css, function(&$value) use($options){ if(!empty($options['baseUrl'])&&strpos($value,'http://')===false) $value = $options['baseUrl'].$value; }); return $css; }
[ "public", "function", "getCss", "(", ")", "{", "$", "css", "=", "$", "this", "->", "css", ";", "$", "options", "=", "$", "this", "->", "options", ";", "if", "(", "$", "this", "->", "isCombineEnabled", "(", ")", ")", "$", "this", "->", "combine", "(", "'css'", ",", "$", "css", ")", ";", "// avoiding duplicate assets", "$", "css", "=", "array_flip", "(", "array_flip", "(", "$", "css", ")", ")", ";", "array_walk", "(", "$", "css", ",", "function", "(", "&", "$", "value", ")", "use", "(", "$", "options", ")", "{", "if", "(", "!", "empty", "(", "$", "options", "[", "'baseUrl'", "]", ")", "&&", "strpos", "(", "$", "value", ",", "'http://'", ")", "===", "false", ")", "$", "value", "=", "$", "options", "[", "'baseUrl'", "]", ".", "$", "value", ";", "}", ")", ";", "return", "$", "css", ";", "}" ]
Get all registered css files @return array $this->js all available javascripts
[ "Get", "all", "registered", "css", "files" ]
072ca09f997225f1f298ca5f77dc23280dd6aa7a
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsServiceProvider.php#L268-L283
240,236
mgufrone/silex-assets-provider
src/Gufy/Service/Provider/AssetsServiceProvider.php
AssetsServiceProvider.customJs
public function customJs($id, $script="", $position=self::ON_HEAD) { if(!isset($this->customJs[$position])) $this->customJs[$position] = array(); $this->customJs[$position][$id] = $script; return $this; }
php
public function customJs($id, $script="", $position=self::ON_HEAD) { if(!isset($this->customJs[$position])) $this->customJs[$position] = array(); $this->customJs[$position][$id] = $script; return $this; }
[ "public", "function", "customJs", "(", "$", "id", ",", "$", "script", "=", "\"\"", ",", "$", "position", "=", "self", "::", "ON_HEAD", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "customJs", "[", "$", "position", "]", ")", ")", "$", "this", "->", "customJs", "[", "$", "position", "]", "=", "array", "(", ")", ";", "$", "this", "->", "customJs", "[", "$", "position", "]", "[", "$", "id", "]", "=", "$", "script", ";", "return", "$", "this", ";", "}" ]
Add custom script on your apps. It is useful when you want to attach some custom script on the fly. @param string $id identity name of the script @param string $script script you want to attach @param int $position position where you want to place you script. it must be @link(ON_BODY) or @link(ON_HEAD) @return AssetsServiceProvider so you can use it as method-chaining mode
[ "Add", "custom", "script", "on", "your", "apps", ".", "It", "is", "useful", "when", "you", "want", "to", "attach", "some", "custom", "script", "on", "the", "fly", "." ]
072ca09f997225f1f298ca5f77dc23280dd6aa7a
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsServiceProvider.php#L310-L316
240,237
mgufrone/silex-assets-provider
src/Gufy/Service/Provider/AssetsServiceProvider.php
AssetsServiceProvider.getCustomJs
public function getCustomJs($position=self::ON_HEAD) { return isset($this->customJs[$position])?$this->customJs[$position]:array(); }
php
public function getCustomJs($position=self::ON_HEAD) { return isset($this->customJs[$position])?$this->customJs[$position]:array(); }
[ "public", "function", "getCustomJs", "(", "$", "position", "=", "self", "::", "ON_HEAD", ")", "{", "return", "isset", "(", "$", "this", "->", "customJs", "[", "$", "position", "]", ")", "?", "$", "this", "->", "customJs", "[", "$", "position", "]", ":", "array", "(", ")", ";", "}" ]
It is used to get custom javascript by reserved position. @param int $position position where you want to place you script. it must be @link(ON_BODY) or @link(ON_HEAD) @return array if $position on $customJs is available it will return as is, if not it just return an empty array
[ "It", "is", "used", "to", "get", "custom", "javascript", "by", "reserved", "position", "." ]
072ca09f997225f1f298ca5f77dc23280dd6aa7a
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsServiceProvider.php#L323-L326
240,238
mgufrone/silex-assets-provider
src/Gufy/Service/Provider/AssetsServiceProvider.php
AssetsServiceProvider.customCss
public function customCss($id, $css="") { if(func_num_args()==1) { $css = $id; $id = uniqid(); } $this->customCss[$id] = $css; return $this; }
php
public function customCss($id, $css="") { if(func_num_args()==1) { $css = $id; $id = uniqid(); } $this->customCss[$id] = $css; return $this; }
[ "public", "function", "customCss", "(", "$", "id", ",", "$", "css", "=", "\"\"", ")", "{", "if", "(", "func_num_args", "(", ")", "==", "1", ")", "{", "$", "css", "=", "$", "id", ";", "$", "id", "=", "uniqid", "(", ")", ";", "}", "$", "this", "->", "customCss", "[", "$", "id", "]", "=", "$", "css", ";", "return", "$", "this", ";", "}" ]
Register custom style on your apps. It is useful when you want to attach some custom style on the fly. @param string $id identity name of the style @param string $css style you want to attach @return AssetsServiceProvider so you can use it as method-chaining mode
[ "Register", "custom", "style", "on", "your", "apps", ".", "It", "is", "useful", "when", "you", "want", "to", "attach", "some", "custom", "style", "on", "the", "fly", "." ]
072ca09f997225f1f298ca5f77dc23280dd6aa7a
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsServiceProvider.php#L350-L359
240,239
mgufrone/silex-assets-provider
src/Gufy/Service/Provider/AssetsServiceProvider.php
AssetsServiceProvider.combine
public function combine($type, &$files) { $basePath = realpath($this->getOption('basePath')); if(empty($basePath))return $files; $cacheName = $this->createCachePath($this->getOption('cacheFileName')?$this->getOption('cacheFileName'):$this->createFileName($type,$files)).'.'.$type; $this->setOption('coreUrl',$this->coreUrl); $minifier = new AssetsMinifier($this->options); $cacheUrl = $minifier->compress($type, $files, $cacheName); if(!empty($files)) array_walk($files, function(&$value, $key) use($cacheUrl) { $value = $cacheUrl; }); $this->cached[$type] = $cacheUrl; }
php
public function combine($type, &$files) { $basePath = realpath($this->getOption('basePath')); if(empty($basePath))return $files; $cacheName = $this->createCachePath($this->getOption('cacheFileName')?$this->getOption('cacheFileName'):$this->createFileName($type,$files)).'.'.$type; $this->setOption('coreUrl',$this->coreUrl); $minifier = new AssetsMinifier($this->options); $cacheUrl = $minifier->compress($type, $files, $cacheName); if(!empty($files)) array_walk($files, function(&$value, $key) use($cacheUrl) { $value = $cacheUrl; }); $this->cached[$type] = $cacheUrl; }
[ "public", "function", "combine", "(", "$", "type", ",", "&", "$", "files", ")", "{", "$", "basePath", "=", "realpath", "(", "$", "this", "->", "getOption", "(", "'basePath'", ")", ")", ";", "if", "(", "empty", "(", "$", "basePath", ")", ")", "return", "$", "files", ";", "$", "cacheName", "=", "$", "this", "->", "createCachePath", "(", "$", "this", "->", "getOption", "(", "'cacheFileName'", ")", "?", "$", "this", "->", "getOption", "(", "'cacheFileName'", ")", ":", "$", "this", "->", "createFileName", "(", "$", "type", ",", "$", "files", ")", ")", ".", "'.'", ".", "$", "type", ";", "$", "this", "->", "setOption", "(", "'coreUrl'", ",", "$", "this", "->", "coreUrl", ")", ";", "$", "minifier", "=", "new", "AssetsMinifier", "(", "$", "this", "->", "options", ")", ";", "$", "cacheUrl", "=", "$", "minifier", "->", "compress", "(", "$", "type", ",", "$", "files", ",", "$", "cacheName", ")", ";", "if", "(", "!", "empty", "(", "$", "files", ")", ")", "array_walk", "(", "$", "files", ",", "function", "(", "&", "$", "value", ",", "$", "key", ")", "use", "(", "$", "cacheUrl", ")", "{", "$", "value", "=", "$", "cacheUrl", ";", "}", ")", ";", "$", "this", "->", "cached", "[", "$", "type", "]", "=", "$", "cacheUrl", ";", "}" ]
Combining cache path @param String $type type files that will be combined @param String $files files that will be combined and cached @return void
[ "Combining", "cache", "path" ]
072ca09f997225f1f298ca5f77dc23280dd6aa7a
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsServiceProvider.php#L473-L486
240,240
mgufrone/silex-assets-provider
src/Gufy/Service/Provider/AssetsServiceProvider.php
AssetsServiceProvider.prepareAssets
private function prepareAssets() { $lib = $this; $attached_groups = $this->getAttachedGroups(); array_walk($lib->attached_groups, function($group_name) use($lib){ $groups = $lib->getGroups(); $group_contents = $groups[$group_name]; array_walk($group_contents, function($value, $key) use($lib, $group_name){ switch($key) { case 'css': array_walk($value, function($value, $key) use($lib, $group_name){ $lib->registerCss($group_name.'/'.$value,$group_name); }); break; case 'js': array_walk($value, function($value, $key) use($lib, $group_name){ $lib->registerJs($group_name.'/'.$value,$lib->getOption('jsPosition'),$group_name); }); break; } }); }); return $this; }
php
private function prepareAssets() { $lib = $this; $attached_groups = $this->getAttachedGroups(); array_walk($lib->attached_groups, function($group_name) use($lib){ $groups = $lib->getGroups(); $group_contents = $groups[$group_name]; array_walk($group_contents, function($value, $key) use($lib, $group_name){ switch($key) { case 'css': array_walk($value, function($value, $key) use($lib, $group_name){ $lib->registerCss($group_name.'/'.$value,$group_name); }); break; case 'js': array_walk($value, function($value, $key) use($lib, $group_name){ $lib->registerJs($group_name.'/'.$value,$lib->getOption('jsPosition'),$group_name); }); break; } }); }); return $this; }
[ "private", "function", "prepareAssets", "(", ")", "{", "$", "lib", "=", "$", "this", ";", "$", "attached_groups", "=", "$", "this", "->", "getAttachedGroups", "(", ")", ";", "array_walk", "(", "$", "lib", "->", "attached_groups", ",", "function", "(", "$", "group_name", ")", "use", "(", "$", "lib", ")", "{", "$", "groups", "=", "$", "lib", "->", "getGroups", "(", ")", ";", "$", "group_contents", "=", "$", "groups", "[", "$", "group_name", "]", ";", "array_walk", "(", "$", "group_contents", ",", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "$", "lib", ",", "$", "group_name", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "'css'", ":", "array_walk", "(", "$", "value", ",", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "$", "lib", ",", "$", "group_name", ")", "{", "$", "lib", "->", "registerCss", "(", "$", "group_name", ".", "'/'", ".", "$", "value", ",", "$", "group_name", ")", ";", "}", ")", ";", "break", ";", "case", "'js'", ":", "array_walk", "(", "$", "value", ",", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "$", "lib", ",", "$", "group_name", ")", "{", "$", "lib", "->", "registerJs", "(", "$", "group_name", ".", "'/'", ".", "$", "value", ",", "$", "lib", "->", "getOption", "(", "'jsPosition'", ")", ",", "$", "group_name", ")", ";", "}", ")", ";", "break", ";", "}", "}", ")", ";", "}", ")", ";", "return", "$", "this", ";", "}" ]
preparing auto attached groups before registering any asset files @return self object
[ "preparing", "auto", "attached", "groups", "before", "registering", "any", "asset", "files" ]
072ca09f997225f1f298ca5f77dc23280dd6aa7a
https://github.com/mgufrone/silex-assets-provider/blob/072ca09f997225f1f298ca5f77dc23280dd6aa7a/src/Gufy/Service/Provider/AssetsServiceProvider.php#L568-L592
240,241
Smile-SA/EzToolsBundle
Service/ContentTypeGroup.php
ContentTypeGroup.add
public function add($name) { $this->repository->setCurrentUser($this->repository->getUserService()->loadUser($this->adminID)); $contentTypeService = $this->repository->getContentTypeService(); $contentTypeGroupStruct = $contentTypeService->newContentTypeGroupCreateStruct($name); try { $contentTypeGroup = $contentTypeService->createContentTypeGroup($contentTypeGroupStruct); return $contentTypeGroup; } catch (UnauthorizedException $e) { throw new \RuntimeException($e->getMessage()); } catch (InvalidArgumentException $e) { throw new \RuntimeException($e->getMessage()); } }
php
public function add($name) { $this->repository->setCurrentUser($this->repository->getUserService()->loadUser($this->adminID)); $contentTypeService = $this->repository->getContentTypeService(); $contentTypeGroupStruct = $contentTypeService->newContentTypeGroupCreateStruct($name); try { $contentTypeGroup = $contentTypeService->createContentTypeGroup($contentTypeGroupStruct); return $contentTypeGroup; } catch (UnauthorizedException $e) { throw new \RuntimeException($e->getMessage()); } catch (InvalidArgumentException $e) { throw new \RuntimeException($e->getMessage()); } }
[ "public", "function", "add", "(", "$", "name", ")", "{", "$", "this", "->", "repository", "->", "setCurrentUser", "(", "$", "this", "->", "repository", "->", "getUserService", "(", ")", "->", "loadUser", "(", "$", "this", "->", "adminID", ")", ")", ";", "$", "contentTypeService", "=", "$", "this", "->", "repository", "->", "getContentTypeService", "(", ")", ";", "$", "contentTypeGroupStruct", "=", "$", "contentTypeService", "->", "newContentTypeGroupCreateStruct", "(", "$", "name", ")", ";", "try", "{", "$", "contentTypeGroup", "=", "$", "contentTypeService", "->", "createContentTypeGroup", "(", "$", "contentTypeGroupStruct", ")", ";", "return", "$", "contentTypeGroup", ";", "}", "catch", "(", "UnauthorizedException", "$", "e", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "catch", "(", "InvalidArgumentException", "$", "e", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Create eZ ContentTypeGroup @param string $name ContentTypeGroup name @return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup|RuntimeException
[ "Create", "eZ", "ContentTypeGroup" ]
5f384f552a83dd723fb4dca468ac0a2e56442be8
https://github.com/Smile-SA/EzToolsBundle/blob/5f384f552a83dd723fb4dca468ac0a2e56442be8/Service/ContentTypeGroup.php#L40-L55
240,242
Danzabar/masquerade
src/Data/Replacement.php
Replacement.replace
public function replace() { foreach($this->matches as $match) { $value = $this->extractValue($match); $this->insertValue($value, $match['raw']); } }
php
public function replace() { foreach($this->matches as $match) { $value = $this->extractValue($match); $this->insertValue($value, $match['raw']); } }
[ "public", "function", "replace", "(", ")", "{", "foreach", "(", "$", "this", "->", "matches", "as", "$", "match", ")", "{", "$", "value", "=", "$", "this", "->", "extractValue", "(", "$", "match", ")", ";", "$", "this", "->", "insertValue", "(", "$", "value", ",", "$", "match", "[", "'raw'", "]", ")", ";", "}", "}" ]
Loops through the matches and replaces their value with the mask string @return void @author Dan Cox
[ "Loops", "through", "the", "matches", "and", "replaces", "their", "value", "with", "the", "mask", "string" ]
f2db0b23a6765031a59fa41c7c0109a288815396
https://github.com/Danzabar/masquerade/blob/f2db0b23a6765031a59fa41c7c0109a288815396/src/Data/Replacement.php#L54-L61
240,243
Danzabar/masquerade
src/Data/Replacement.php
Replacement.insertValue
public function insertValue($value, $match) { $this->str = str_replace($match, $value, $this->str); }
php
public function insertValue($value, $match) { $this->str = str_replace($match, $value, $this->str); }
[ "public", "function", "insertValue", "(", "$", "value", ",", "$", "match", ")", "{", "$", "this", "->", "str", "=", "str_replace", "(", "$", "match", ",", "$", "value", ",", "$", "this", "->", "str", ")", ";", "}" ]
Performs str_replace with value and match on the str @return void @author Dan Cox
[ "Performs", "str_replace", "with", "value", "and", "match", "on", "the", "str" ]
f2db0b23a6765031a59fa41c7c0109a288815396
https://github.com/Danzabar/masquerade/blob/f2db0b23a6765031a59fa41c7c0109a288815396/src/Data/Replacement.php#L69-L72
240,244
Danzabar/masquerade
src/Data/Replacement.php
Replacement.extractValue
public function extractValue(Array $match) { switch(gettype($match['value'])) { case 'string': return $match['value']; break; case 'object': // Extract Closures if(get_class($match['value']) == 'Closure') { return $this->closureExtract($match); } // Extract Classes return $this->classExtract($match); break; } throw new Exceptions\UnexpectedMaskValue($match['value'], $match['raw']); }
php
public function extractValue(Array $match) { switch(gettype($match['value'])) { case 'string': return $match['value']; break; case 'object': // Extract Closures if(get_class($match['value']) == 'Closure') { return $this->closureExtract($match); } // Extract Classes return $this->classExtract($match); break; } throw new Exceptions\UnexpectedMaskValue($match['value'], $match['raw']); }
[ "public", "function", "extractValue", "(", "Array", "$", "match", ")", "{", "switch", "(", "gettype", "(", "$", "match", "[", "'value'", "]", ")", ")", "{", "case", "'string'", ":", "return", "$", "match", "[", "'value'", "]", ";", "break", ";", "case", "'object'", ":", "// Extract Closures", "if", "(", "get_class", "(", "$", "match", "[", "'value'", "]", ")", "==", "'Closure'", ")", "{", "return", "$", "this", "->", "closureExtract", "(", "$", "match", ")", ";", "}", "// Extract Classes", "return", "$", "this", "->", "classExtract", "(", "$", "match", ")", ";", "break", ";", "}", "throw", "new", "Exceptions", "\\", "UnexpectedMaskValue", "(", "$", "match", "[", "'value'", "]", ",", "$", "match", "[", "'raw'", "]", ")", ";", "}" ]
Checks the type of value and formats it, as we could be getting closures passed @return void @author Dan Cox
[ "Checks", "the", "type", "of", "value", "and", "formats", "it", "as", "we", "could", "be", "getting", "closures", "passed" ]
f2db0b23a6765031a59fa41c7c0109a288815396
https://github.com/Danzabar/masquerade/blob/f2db0b23a6765031a59fa41c7c0109a288815396/src/Data/Replacement.php#L80-L98
240,245
Danzabar/masquerade
src/Data/Replacement.php
Replacement.classExtract
public function classExtract(Array $match) { $extract = new ClassExtraction(get_class($match['value']), $match); return $extract->extract(); }
php
public function classExtract(Array $match) { $extract = new ClassExtraction(get_class($match['value']), $match); return $extract->extract(); }
[ "public", "function", "classExtract", "(", "Array", "$", "match", ")", "{", "$", "extract", "=", "new", "ClassExtraction", "(", "get_class", "(", "$", "match", "[", "'value'", "]", ")", ",", "$", "match", ")", ";", "return", "$", "extract", "->", "extract", "(", ")", ";", "}" ]
Extracts value from class @return void @author Dan Cox
[ "Extracts", "value", "from", "class" ]
f2db0b23a6765031a59fa41c7c0109a288815396
https://github.com/Danzabar/masquerade/blob/f2db0b23a6765031a59fa41c7c0109a288815396/src/Data/Replacement.php#L117-L122
240,246
wbadrh/api-json
src/Response.php
Response.dispatch
public function dispatch(ResponseInterface $response, int $status, $result) { // Build output array $contents = [ 'status' => $status, 'result' => $result, ]; // Convert output to JSON $contents = json_encode($contents, JSON_PRETTY_PRINT); // Write Response to Body $response->getBody()->write($contents); // PSR-7 response return $response->withStatus($status); }
php
public function dispatch(ResponseInterface $response, int $status, $result) { // Build output array $contents = [ 'status' => $status, 'result' => $result, ]; // Convert output to JSON $contents = json_encode($contents, JSON_PRETTY_PRINT); // Write Response to Body $response->getBody()->write($contents); // PSR-7 response return $response->withStatus($status); }
[ "public", "function", "dispatch", "(", "ResponseInterface", "$", "response", ",", "int", "$", "status", ",", "$", "result", ")", "{", "// Build output array", "$", "contents", "=", "[", "'status'", "=>", "$", "status", ",", "'result'", "=>", "$", "result", ",", "]", ";", "// Convert output to JSON", "$", "contents", "=", "json_encode", "(", "$", "contents", ",", "JSON_PRETTY_PRINT", ")", ";", "// Write Response to Body", "$", "response", "->", "getBody", "(", ")", "->", "write", "(", "$", "contents", ")", ";", "// PSR-7 response", "return", "$", "response", "->", "withStatus", "(", "$", "status", ")", ";", "}" ]
JSON response class @param ResponseInterface $response PSR-7 HTTP response message @param Integer $status HTTP status (e.g: 200) @param Mixed $result Array, String or Object to send as JSON response
[ "JSON", "response", "class" ]
2b394afbb96cb12358773d6abc29e7551054795e
https://github.com/wbadrh/api-json/blob/2b394afbb96cb12358773d6abc29e7551054795e/src/Response.php#L20-L36
240,247
rozaverta/cmf
core/Support/Collection.php
Collection.sort
public function sort( bool $desc = false ) { $items = $this->items; asort($items); if($desc) { $items = array_reverse($items, true); } return new static($items); }
php
public function sort( bool $desc = false ) { $items = $this->items; asort($items); if($desc) { $items = array_reverse($items, true); } return new static($items); }
[ "public", "function", "sort", "(", "bool", "$", "desc", "=", "false", ")", "{", "$", "items", "=", "$", "this", "->", "items", ";", "asort", "(", "$", "items", ")", ";", "if", "(", "$", "desc", ")", "{", "$", "items", "=", "array_reverse", "(", "$", "items", ",", "true", ")", ";", "}", "return", "new", "static", "(", "$", "items", ")", ";", "}" ]
Sort an collection and maintain index association @param bool $desc in reverse order @return static
[ "Sort", "an", "collection", "and", "maintain", "index", "association" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Support/Collection.php#L60-L69
240,248
rozaverta/cmf
core/Support/Collection.php
Collection.sortKeys
public function sortKeys( int $options = SORT_REGULAR, bool $desc = false ) { $items = $this->items; $desc ? krsort($items, $options) : ksort($items, $options); return new static($items); }
php
public function sortKeys( int $options = SORT_REGULAR, bool $desc = false ) { $items = $this->items; $desc ? krsort($items, $options) : ksort($items, $options); return new static($items); }
[ "public", "function", "sortKeys", "(", "int", "$", "options", "=", "SORT_REGULAR", ",", "bool", "$", "desc", "=", "false", ")", "{", "$", "items", "=", "$", "this", "->", "items", ";", "$", "desc", "?", "krsort", "(", "$", "items", ",", "$", "options", ")", ":", "ksort", "(", "$", "items", ",", "$", "options", ")", ";", "return", "new", "static", "(", "$", "items", ")", ";", "}" ]
Sort an collection by key @param int $options Sorting type flags @param bool $desc In reverse order @return static
[ "Sort", "an", "collection", "by", "key" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Support/Collection.php#L88-L93
240,249
rozaverta/cmf
core/Support/Collection.php
Collection.sortBy
public function sortBy( \Closure $callback, bool $save_keys = true ) { $items = $this->items; $save_keys ? uasort($items, $callback) : usort($items, $callback); return new static($items); }
php
public function sortBy( \Closure $callback, bool $save_keys = true ) { $items = $this->items; $save_keys ? uasort($items, $callback) : usort($items, $callback); return new static($items); }
[ "public", "function", "sortBy", "(", "\\", "Closure", "$", "callback", ",", "bool", "$", "save_keys", "=", "true", ")", "{", "$", "items", "=", "$", "this", "->", "items", ";", "$", "save_keys", "?", "uasort", "(", "$", "items", ",", "$", "callback", ")", ":", "usort", "(", "$", "items", ",", "$", "callback", ")", ";", "return", "new", "static", "(", "$", "items", ")", ";", "}" ]
Sort an collection by values using a user-defined comparison function @param \Closure $callback @param bool $save_keys maintain index association @return static
[ "Sort", "an", "collection", "by", "values", "using", "a", "user", "-", "defined", "comparison", "function" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Support/Collection.php#L113-L118
240,250
rozaverta/cmf
core/Support/Collection.php
Collection.sortByKeys
public function sortByKeys( \Closure $callback ) { $items = $this->items; uksort($items, $callback); return new static($items); }
php
public function sortByKeys( \Closure $callback ) { $items = $this->items; uksort($items, $callback); return new static($items); }
[ "public", "function", "sortByKeys", "(", "\\", "Closure", "$", "callback", ")", "{", "$", "items", "=", "$", "this", "->", "items", ";", "uksort", "(", "$", "items", ",", "$", "callback", ")", ";", "return", "new", "static", "(", "$", "items", ")", ";", "}" ]
Sort an collection by keys using a user-defined comparison function @param \Closure $callback @return static
[ "Sort", "an", "collection", "by", "keys", "using", "a", "user", "-", "defined", "comparison", "function" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Support/Collection.php#L126-L131
240,251
flowcode/ceibo
src/flowcode/ceibo/support/ScriptRunner.php
ScriptRunner.remove_remarks
private function remove_remarks($sql) { $lines = explode("\n", $sql); // try to keep mem. use down $sql = ""; $linecount = count($lines); $output = ""; for ($i = 0; $i < $linecount; $i++) { if (($i != ($linecount - 1)) || (strlen($lines[$i]) > 0)) { if (isset($lines[$i][0]) && $lines[$i][0] != "#") { $output .= $lines[$i] . "\n"; } else { $output .= "\n"; } // Trading a bit of speed for lower mem. use here. $lines[$i] = ""; } } return $output; }
php
private function remove_remarks($sql) { $lines = explode("\n", $sql); // try to keep mem. use down $sql = ""; $linecount = count($lines); $output = ""; for ($i = 0; $i < $linecount; $i++) { if (($i != ($linecount - 1)) || (strlen($lines[$i]) > 0)) { if (isset($lines[$i][0]) && $lines[$i][0] != "#") { $output .= $lines[$i] . "\n"; } else { $output .= "\n"; } // Trading a bit of speed for lower mem. use here. $lines[$i] = ""; } } return $output; }
[ "private", "function", "remove_remarks", "(", "$", "sql", ")", "{", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "sql", ")", ";", "// try to keep mem. use down", "$", "sql", "=", "\"\"", ";", "$", "linecount", "=", "count", "(", "$", "lines", ")", ";", "$", "output", "=", "\"\"", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "linecount", ";", "$", "i", "++", ")", "{", "if", "(", "(", "$", "i", "!=", "(", "$", "linecount", "-", "1", ")", ")", "||", "(", "strlen", "(", "$", "lines", "[", "$", "i", "]", ")", ">", "0", ")", ")", "{", "if", "(", "isset", "(", "$", "lines", "[", "$", "i", "]", "[", "0", "]", ")", "&&", "$", "lines", "[", "$", "i", "]", "[", "0", "]", "!=", "\"#\"", ")", "{", "$", "output", ".=", "$", "lines", "[", "$", "i", "]", ".", "\"\\n\"", ";", "}", "else", "{", "$", "output", ".=", "\"\\n\"", ";", "}", "// Trading a bit of speed for lower mem. use here.", "$", "lines", "[", "$", "i", "]", "=", "\"\"", ";", "}", "}", "return", "$", "output", ";", "}" ]
Remove_remarks will strip the sql comment lines out of an uploaded sql file. @param string $sql @return string
[ "Remove_remarks", "will", "strip", "the", "sql", "comment", "lines", "out", "of", "an", "uploaded", "sql", "file", "." ]
ba264dc681a9d803885fd35d10b0e37776f66659
https://github.com/flowcode/ceibo/blob/ba264dc681a9d803885fd35d10b0e37776f66659/src/flowcode/ceibo/support/ScriptRunner.php#L92-L114
240,252
MINISTRYGmbH/morrow-core
src/Core/Modules.php
Modules.removeModuleQueueItem
public function removeModuleQueueItem($key_or_regex){ $removed_queue_items = []; // user passed the numeric key of queue item if(is_numeric($key_or_regex)){ $removed_queue_items[] = $this->_module_queue[$key_or_regex]; unset($this->_module_queue[$key_or_regex]); // user passed a regex that will be matched against the module namespace }else{ foreach($this->_module_queue as $key => $queueItem){ if(preg_match($key_or_regex, $queueItem['class'])){ $removed_queue_items[] = $this->_module_queue[$key]; unset($this->_module_queue[$key]); } } } return $removed_queue_items; }
php
public function removeModuleQueueItem($key_or_regex){ $removed_queue_items = []; // user passed the numeric key of queue item if(is_numeric($key_or_regex)){ $removed_queue_items[] = $this->_module_queue[$key_or_regex]; unset($this->_module_queue[$key_or_regex]); // user passed a regex that will be matched against the module namespace }else{ foreach($this->_module_queue as $key => $queueItem){ if(preg_match($key_or_regex, $queueItem['class'])){ $removed_queue_items[] = $this->_module_queue[$key]; unset($this->_module_queue[$key]); } } } return $removed_queue_items; }
[ "public", "function", "removeModuleQueueItem", "(", "$", "key_or_regex", ")", "{", "$", "removed_queue_items", "=", "[", "]", ";", "// user passed the numeric key of queue item", "if", "(", "is_numeric", "(", "$", "key_or_regex", ")", ")", "{", "$", "removed_queue_items", "[", "]", "=", "$", "this", "->", "_module_queue", "[", "$", "key_or_regex", "]", ";", "unset", "(", "$", "this", "->", "_module_queue", "[", "$", "key_or_regex", "]", ")", ";", "// user passed a regex that will be matched against the module namespace", "}", "else", "{", "foreach", "(", "$", "this", "->", "_module_queue", "as", "$", "key", "=>", "$", "queueItem", ")", "{", "if", "(", "preg_match", "(", "$", "key_or_regex", ",", "$", "queueItem", "[", "'class'", "]", ")", ")", "{", "$", "removed_queue_items", "[", "]", "=", "$", "this", "->", "_module_queue", "[", "$", "key", "]", ";", "unset", "(", "$", "this", "->", "_module_queue", "[", "$", "key", "]", ")", ";", "}", "}", "}", "return", "$", "removed_queue_items", ";", "}" ]
Removes a module from the module queue either by key or by a regex matched against the module controller namespace. @param string $key_or_regex The numeric key of the queue item or a regex matched against the controller namespace @return array An array containing all removed queue items
[ "Removes", "a", "module", "from", "the", "module", "queue", "either", "by", "key", "or", "by", "a", "regex", "matched", "against", "the", "module", "controller", "namespace", "." ]
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Core/Modules.php#L186-L203
240,253
MINISTRYGmbH/morrow-core
src/Core/Modules.php
Modules._insertModuleConfig
private function _insertModuleConfig($namespace, $overwrite){ // get module name from namespace $namespace_array = explode('\\', trim($namespace,'\\')); $path_array = array_slice($namespace_array, 1, 2); $module_config_path = ROOT_PATH . implode('/', $path_array) . '/configs/'; $module_config_path = str_replace('\\', '/', $module_config_path); $module_name = $path_array[1]; // create module config instance and load default params $module_config = Factory::load('Config:' . $module_name); $module_config->load($module_config_path); // overwrite default params with specified params in modules.php foreach($overwrite as $key => $value){ $module_config->set($key, $value); } // insert into modules global config $this->_global_config->set('modules.' . $module_name, $module_config->get()); }
php
private function _insertModuleConfig($namespace, $overwrite){ // get module name from namespace $namespace_array = explode('\\', trim($namespace,'\\')); $path_array = array_slice($namespace_array, 1, 2); $module_config_path = ROOT_PATH . implode('/', $path_array) . '/configs/'; $module_config_path = str_replace('\\', '/', $module_config_path); $module_name = $path_array[1]; // create module config instance and load default params $module_config = Factory::load('Config:' . $module_name); $module_config->load($module_config_path); // overwrite default params with specified params in modules.php foreach($overwrite as $key => $value){ $module_config->set($key, $value); } // insert into modules global config $this->_global_config->set('modules.' . $module_name, $module_config->get()); }
[ "private", "function", "_insertModuleConfig", "(", "$", "namespace", ",", "$", "overwrite", ")", "{", "// get module name from namespace", "$", "namespace_array", "=", "explode", "(", "'\\\\'", ",", "trim", "(", "$", "namespace", ",", "'\\\\'", ")", ")", ";", "$", "path_array", "=", "array_slice", "(", "$", "namespace_array", ",", "1", ",", "2", ")", ";", "$", "module_config_path", "=", "ROOT_PATH", ".", "implode", "(", "'/'", ",", "$", "path_array", ")", ".", "'/configs/'", ";", "$", "module_config_path", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "module_config_path", ")", ";", "$", "module_name", "=", "$", "path_array", "[", "1", "]", ";", "// create module config instance and load default params", "$", "module_config", "=", "Factory", "::", "load", "(", "'Config:'", ".", "$", "module_name", ")", ";", "$", "module_config", "->", "load", "(", "$", "module_config_path", ")", ";", "// overwrite default params with specified params in modules.php", "foreach", "(", "$", "overwrite", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "module_config", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}", "// insert into modules global config", "$", "this", "->", "_global_config", "->", "set", "(", "'modules.'", ".", "$", "module_name", ",", "$", "module_config", "->", "get", "(", ")", ")", ";", "}" ]
Inserts a module's config params into the global config instance. @param string $namespace namespace of called module controller @param array $overwrite config overwrite array
[ "Inserts", "a", "module", "s", "config", "params", "into", "the", "global", "config", "instance", "." ]
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Core/Modules.php#L210-L229
240,254
MINISTRYGmbH/morrow-core
src/Core/Modules.php
Modules._runModuleController
private function _runModuleController($page_module){ // execute module controller $view = (new $page_module['class'])->run($this->_dom); // set the handle variable according to this module's controller return value if(is_resource($view) && get_resource_type($view) == 'stream'){ return [ 'handle' => $view, 'type' => 'stream', ]; } if(is_object($view) && is_subclass_of($view, '\Morrow\Views\AbstractView')){ $view->init($page_module['class']); return [ 'handle' => $view->getOutput(), 'type' => 'html', ]; } if(is_string($view)){ $handle = fopen('php://temp/maxmemory:'.(1*1024*1024), 'r+'); // 1MB fwrite($handle, $view); return [ 'handle' => $handle, 'type' => 'string', ]; } if(is_null($view)){ return [ 'handle' => null, 'type' => null, ]; } if(!isset($handle)){ throw new \Exception(__CLASS__.': The return value of a controller has to be of type "stream", "string" or a child of \Morrow\Views\AbstractView.'); } }
php
private function _runModuleController($page_module){ // execute module controller $view = (new $page_module['class'])->run($this->_dom); // set the handle variable according to this module's controller return value if(is_resource($view) && get_resource_type($view) == 'stream'){ return [ 'handle' => $view, 'type' => 'stream', ]; } if(is_object($view) && is_subclass_of($view, '\Morrow\Views\AbstractView')){ $view->init($page_module['class']); return [ 'handle' => $view->getOutput(), 'type' => 'html', ]; } if(is_string($view)){ $handle = fopen('php://temp/maxmemory:'.(1*1024*1024), 'r+'); // 1MB fwrite($handle, $view); return [ 'handle' => $handle, 'type' => 'string', ]; } if(is_null($view)){ return [ 'handle' => null, 'type' => null, ]; } if(!isset($handle)){ throw new \Exception(__CLASS__.': The return value of a controller has to be of type "stream", "string" or a child of \Morrow\Views\AbstractView.'); } }
[ "private", "function", "_runModuleController", "(", "$", "page_module", ")", "{", "// execute module controller", "$", "view", "=", "(", "new", "$", "page_module", "[", "'class'", "]", ")", "->", "run", "(", "$", "this", "->", "_dom", ")", ";", "// set the handle variable according to this module's controller return value", "if", "(", "is_resource", "(", "$", "view", ")", "&&", "get_resource_type", "(", "$", "view", ")", "==", "'stream'", ")", "{", "return", "[", "'handle'", "=>", "$", "view", ",", "'type'", "=>", "'stream'", ",", "]", ";", "}", "if", "(", "is_object", "(", "$", "view", ")", "&&", "is_subclass_of", "(", "$", "view", ",", "'\\Morrow\\Views\\AbstractView'", ")", ")", "{", "$", "view", "->", "init", "(", "$", "page_module", "[", "'class'", "]", ")", ";", "return", "[", "'handle'", "=>", "$", "view", "->", "getOutput", "(", ")", ",", "'type'", "=>", "'html'", ",", "]", ";", "}", "if", "(", "is_string", "(", "$", "view", ")", ")", "{", "$", "handle", "=", "fopen", "(", "'php://temp/maxmemory:'", ".", "(", "1", "*", "1024", "*", "1024", ")", ",", "'r+'", ")", ";", "// 1MB", "fwrite", "(", "$", "handle", ",", "$", "view", ")", ";", "return", "[", "'handle'", "=>", "$", "handle", ",", "'type'", "=>", "'string'", ",", "]", ";", "}", "if", "(", "is_null", "(", "$", "view", ")", ")", "{", "return", "[", "'handle'", "=>", "null", ",", "'type'", "=>", "null", ",", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "handle", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "__CLASS__", ".", "': The return value of a controller has to be of type \"stream\", \"string\" or a child of \\Morrow\\Views\\AbstractView.'", ")", ";", "}", "}" ]
Execute any module. @param array $page_module the module config array: [ 'action' => 'append'|'replace'|'prepend', (optional) 'class' => '\\app\\modules\\Foo\\Bar', 'config' => ['anyConfigKey' => 'anyConfigValue'], (optional) 'selector' => '#anyCssSelector', (optional) ] @return stream $handle handle of executed module data
[ "Execute", "any", "module", "." ]
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Core/Modules.php#L242-L281
240,255
arvici/framework
src/Arvici/Heart/Database/Query/QueryBuilder.php
QueryBuilder.doExecute
private function doExecute($fetch = false, $fetchMode = null, $fetchClass = null) { if ($fetch) { $fetchMode = Database::normalizeFetchType($fetchMode); } // Parse SQL and Bind $sql = $this->query->getSQL(); $bind = $this->query->getBind(); // Connection and execute $statement = $this->connection->prepare($sql); foreach ($bind as $idx => $value) { $statement->bindValue(($idx+1), $value, Database::typeOfValue($value)); } // Fetch if ($fetch) { if ($fetchMode === Database::FETCH_CLASS) { // Verify class new \ReflectionClass($fetchClass); $statement->setFetchMode($fetchMode, $fetchClass); } else { $statement->setFetchMode($fetchMode); } } // Execute $success = $statement->execute(); if (! $success) { return false; } if ($fetch && $fetch === 'single') { return $statement->fetch(); } if ($fetch) { return $statement->fetchAll(); } return true; }
php
private function doExecute($fetch = false, $fetchMode = null, $fetchClass = null) { if ($fetch) { $fetchMode = Database::normalizeFetchType($fetchMode); } // Parse SQL and Bind $sql = $this->query->getSQL(); $bind = $this->query->getBind(); // Connection and execute $statement = $this->connection->prepare($sql); foreach ($bind as $idx => $value) { $statement->bindValue(($idx+1), $value, Database::typeOfValue($value)); } // Fetch if ($fetch) { if ($fetchMode === Database::FETCH_CLASS) { // Verify class new \ReflectionClass($fetchClass); $statement->setFetchMode($fetchMode, $fetchClass); } else { $statement->setFetchMode($fetchMode); } } // Execute $success = $statement->execute(); if (! $success) { return false; } if ($fetch && $fetch === 'single') { return $statement->fetch(); } if ($fetch) { return $statement->fetchAll(); } return true; }
[ "private", "function", "doExecute", "(", "$", "fetch", "=", "false", ",", "$", "fetchMode", "=", "null", ",", "$", "fetchClass", "=", "null", ")", "{", "if", "(", "$", "fetch", ")", "{", "$", "fetchMode", "=", "Database", "::", "normalizeFetchType", "(", "$", "fetchMode", ")", ";", "}", "// Parse SQL and Bind", "$", "sql", "=", "$", "this", "->", "query", "->", "getSQL", "(", ")", ";", "$", "bind", "=", "$", "this", "->", "query", "->", "getBind", "(", ")", ";", "// Connection and execute", "$", "statement", "=", "$", "this", "->", "connection", "->", "prepare", "(", "$", "sql", ")", ";", "foreach", "(", "$", "bind", "as", "$", "idx", "=>", "$", "value", ")", "{", "$", "statement", "->", "bindValue", "(", "(", "$", "idx", "+", "1", ")", ",", "$", "value", ",", "Database", "::", "typeOfValue", "(", "$", "value", ")", ")", ";", "}", "// Fetch", "if", "(", "$", "fetch", ")", "{", "if", "(", "$", "fetchMode", "===", "Database", "::", "FETCH_CLASS", ")", "{", "// Verify class", "new", "\\", "ReflectionClass", "(", "$", "fetchClass", ")", ";", "$", "statement", "->", "setFetchMode", "(", "$", "fetchMode", ",", "$", "fetchClass", ")", ";", "}", "else", "{", "$", "statement", "->", "setFetchMode", "(", "$", "fetchMode", ")", ";", "}", "}", "// Execute", "$", "success", "=", "$", "statement", "->", "execute", "(", ")", ";", "if", "(", "!", "$", "success", ")", "{", "return", "false", ";", "}", "if", "(", "$", "fetch", "&&", "$", "fetch", "===", "'single'", ")", "{", "return", "$", "statement", "->", "fetch", "(", ")", ";", "}", "if", "(", "$", "fetch", ")", "{", "return", "$", "statement", "->", "fetchAll", "(", ")", ";", "}", "return", "true", ";", "}" ]
Execute the query, fetch if provided details to do so. @param bool $fetch Fetch on or off? @param null $fetchMode Fetch mode (null for default) @param null $fetchClass Fetch class (null for none) @throws QueryBuilderParseException @throws QueryBuilderException @throws QueryException @throws DatabaseException @throws \Exception @return bool Boolean when fetching is off. @return array|object|null Result when fetching is on.
[ "Execute", "the", "query", "fetch", "if", "provided", "details", "to", "do", "so", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Database/Query/QueryBuilder.php#L355-L398
240,256
songshenzong/essentials
src/Essentials.php
Essentials.excel
public function excel($filename, $data) { \Excel::create($filename, function ($excel) use ($filename, $data) { $excel->sheet($filename, function ($sheet) use ($data) { $sheet->fromArray($data); }); }) ->export('xlsx'); }
php
public function excel($filename, $data) { \Excel::create($filename, function ($excel) use ($filename, $data) { $excel->sheet($filename, function ($sheet) use ($data) { $sheet->fromArray($data); }); }) ->export('xlsx'); }
[ "public", "function", "excel", "(", "$", "filename", ",", "$", "data", ")", "{", "\\", "Excel", "::", "create", "(", "$", "filename", ",", "function", "(", "$", "excel", ")", "use", "(", "$", "filename", ",", "$", "data", ")", "{", "$", "excel", "->", "sheet", "(", "$", "filename", ",", "function", "(", "$", "sheet", ")", "use", "(", "$", "data", ")", "{", "$", "sheet", "->", "fromArray", "(", "$", "data", ")", ";", "}", ")", ";", "}", ")", "->", "export", "(", "'xlsx'", ")", ";", "}" ]
Export date to Excel file. @param $filename @param $data
[ "Export", "date", "to", "Excel", "file", "." ]
7785bd6d9ecf8829875b5277f27636e0c69cb206
https://github.com/songshenzong/essentials/blob/7785bd6d9ecf8829875b5277f27636e0c69cb206/src/Essentials.php#L27-L35
240,257
songshenzong/essentials
src/Essentials.php
Essentials.geoCoder
public function geoCoder($lat, $lng, $ak, $mcode, $url) { $client = new \GuzzleHttp\Client(); $parameters = [ 'form_params' => [ 'ak' => $ak, 'location' => $lat . ',' . $lng, 'output' => 'json', 'pois' => 0, 'mcode' => $mcode, ], ]; $geo_coder = $client->request('POST', $url, $parameters); $geo_coder = json_decode($geo_coder->getBody()); return $geo_coder; }
php
public function geoCoder($lat, $lng, $ak, $mcode, $url) { $client = new \GuzzleHttp\Client(); $parameters = [ 'form_params' => [ 'ak' => $ak, 'location' => $lat . ',' . $lng, 'output' => 'json', 'pois' => 0, 'mcode' => $mcode, ], ]; $geo_coder = $client->request('POST', $url, $parameters); $geo_coder = json_decode($geo_coder->getBody()); return $geo_coder; }
[ "public", "function", "geoCoder", "(", "$", "lat", ",", "$", "lng", ",", "$", "ak", ",", "$", "mcode", ",", "$", "url", ")", "{", "$", "client", "=", "new", "\\", "GuzzleHttp", "\\", "Client", "(", ")", ";", "$", "parameters", "=", "[", "'form_params'", "=>", "[", "'ak'", "=>", "$", "ak", ",", "'location'", "=>", "$", "lat", ".", "','", ".", "$", "lng", ",", "'output'", "=>", "'json'", ",", "'pois'", "=>", "0", ",", "'mcode'", "=>", "$", "mcode", ",", "]", ",", "]", ";", "$", "geo_coder", "=", "$", "client", "->", "request", "(", "'POST'", ",", "$", "url", ",", "$", "parameters", ")", ";", "$", "geo_coder", "=", "json_decode", "(", "$", "geo_coder", "->", "getBody", "(", ")", ")", ";", "return", "$", "geo_coder", ";", "}" ]
Get geoCoder by Baidu. @param $lat @param $lng @param $ak @param $mcode @param $url @return mixed
[ "Get", "geoCoder", "by", "Baidu", "." ]
7785bd6d9ecf8829875b5277f27636e0c69cb206
https://github.com/songshenzong/essentials/blob/7785bd6d9ecf8829875b5277f27636e0c69cb206/src/Essentials.php#L49-L67
240,258
vphantom/pyritephp
src/Pyrite/Router.php
Router._remoteIP
private static function _remoteIP() { // Catch all possible hints of the client's IP address, not just REMOTE_ADDR foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) { if (array_key_exists($key, $_SERVER)) { foreach (dejoin(',', $_SERVER[$key]) as $ip) { if (filter_var($ip, FILTER_VALIDATE_IP)) { // Return the first one found return $ip; }; }; }; }; return null; }
php
private static function _remoteIP() { // Catch all possible hints of the client's IP address, not just REMOTE_ADDR foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) { if (array_key_exists($key, $_SERVER)) { foreach (dejoin(',', $_SERVER[$key]) as $ip) { if (filter_var($ip, FILTER_VALIDATE_IP)) { // Return the first one found return $ip; }; }; }; }; return null; }
[ "private", "static", "function", "_remoteIP", "(", ")", "{", "// Catch all possible hints of the client's IP address, not just REMOTE_ADDR", "foreach", "(", "array", "(", "'HTTP_CLIENT_IP'", ",", "'HTTP_X_FORWARDED_FOR'", ",", "'HTTP_X_FORWARDED'", ",", "'HTTP_X_CLUSTER_CLIENT_IP'", ",", "'HTTP_FORWARDED_FOR'", ",", "'HTTP_FORWARDED'", ",", "'REMOTE_ADDR'", ")", "as", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "_SERVER", ")", ")", "{", "foreach", "(", "dejoin", "(", "','", ",", "$", "_SERVER", "[", "$", "key", "]", ")", "as", "$", "ip", ")", "{", "if", "(", "filter_var", "(", "$", "ip", ",", "FILTER_VALIDATE_IP", ")", ")", "{", "// Return the first one found", "return", "$", "ip", ";", "}", ";", "}", ";", "}", ";", "}", ";", "return", "null", ";", "}" ]
Get probable browser IP address @return string
[ "Get", "probable", "browser", "IP", "address" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Router.php#L58-L83
240,259
vphantom/pyritephp
src/Pyrite/Router.php
Router._initCommon
private static function _initCommon() { global $PPHP; self::$_req['warnings'] = array(); self::$_req['status'] = 200; self::$_req['redirect'] = false; self::$_req['protocol'] = (self::$_req['ssl'] ? 'https' : 'http'); }
php
private static function _initCommon() { global $PPHP; self::$_req['warnings'] = array(); self::$_req['status'] = 200; self::$_req['redirect'] = false; self::$_req['protocol'] = (self::$_req['ssl'] ? 'https' : 'http'); }
[ "private", "static", "function", "_initCommon", "(", ")", "{", "global", "$", "PPHP", ";", "self", "::", "$", "_req", "[", "'warnings'", "]", "=", "array", "(", ")", ";", "self", "::", "$", "_req", "[", "'status'", "]", "=", "200", ";", "self", "::", "$", "_req", "[", "'redirect'", "]", "=", "false", ";", "self", "::", "$", "_req", "[", "'protocol'", "]", "=", "(", "self", "::", "$", "_req", "[", "'ssl'", "]", "?", "'https'", ":", "'http'", ")", ";", "}" ]
Initialization common to CLI and web @return null
[ "Initialization", "common", "to", "CLI", "and", "web" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Router.php#L90-L98
240,260
vphantom/pyritephp
src/Pyrite/Router.php
Router.initCLI
public static function initCLI() { global $PPHP; self::$_PATH = array(); self::$_req['lang'] = $PPHP['config']['global']['default_lang']; self::$_req['default_lang'] = $PPHP['config']['global']['default_lang']; self::$_req['base'] = ''; self::$_req['binary'] = true; // Keep layout template quiet self::$_req['path'] = ''; self::$_req['query'] = ''; self::$_req['host'] = $PPHP['config']['global']['host']; self::$_req['remote_addr'] = '127.0.0.1'; self::$_req['ssl'] = $PPHP['config']['global']['use_ssl']; self::$_req['get'] = array(); self::$_req['post'] = array(); self::$_req['path_args'] = array(); self::_initCommon(); trigger('language', self::$_req['lang']); }
php
public static function initCLI() { global $PPHP; self::$_PATH = array(); self::$_req['lang'] = $PPHP['config']['global']['default_lang']; self::$_req['default_lang'] = $PPHP['config']['global']['default_lang']; self::$_req['base'] = ''; self::$_req['binary'] = true; // Keep layout template quiet self::$_req['path'] = ''; self::$_req['query'] = ''; self::$_req['host'] = $PPHP['config']['global']['host']; self::$_req['remote_addr'] = '127.0.0.1'; self::$_req['ssl'] = $PPHP['config']['global']['use_ssl']; self::$_req['get'] = array(); self::$_req['post'] = array(); self::$_req['path_args'] = array(); self::_initCommon(); trigger('language', self::$_req['lang']); }
[ "public", "static", "function", "initCLI", "(", ")", "{", "global", "$", "PPHP", ";", "self", "::", "$", "_PATH", "=", "array", "(", ")", ";", "self", "::", "$", "_req", "[", "'lang'", "]", "=", "$", "PPHP", "[", "'config'", "]", "[", "'global'", "]", "[", "'default_lang'", "]", ";", "self", "::", "$", "_req", "[", "'default_lang'", "]", "=", "$", "PPHP", "[", "'config'", "]", "[", "'global'", "]", "[", "'default_lang'", "]", ";", "self", "::", "$", "_req", "[", "'base'", "]", "=", "''", ";", "self", "::", "$", "_req", "[", "'binary'", "]", "=", "true", ";", "// Keep layout template quiet", "self", "::", "$", "_req", "[", "'path'", "]", "=", "''", ";", "self", "::", "$", "_req", "[", "'query'", "]", "=", "''", ";", "self", "::", "$", "_req", "[", "'host'", "]", "=", "$", "PPHP", "[", "'config'", "]", "[", "'global'", "]", "[", "'host'", "]", ";", "self", "::", "$", "_req", "[", "'remote_addr'", "]", "=", "'127.0.0.1'", ";", "self", "::", "$", "_req", "[", "'ssl'", "]", "=", "$", "PPHP", "[", "'config'", "]", "[", "'global'", "]", "[", "'use_ssl'", "]", ";", "self", "::", "$", "_req", "[", "'get'", "]", "=", "array", "(", ")", ";", "self", "::", "$", "_req", "[", "'post'", "]", "=", "array", "(", ")", ";", "self", "::", "$", "_req", "[", "'path_args'", "]", "=", "array", "(", ")", ";", "self", "::", "_initCommon", "(", ")", ";", "trigger", "(", "'language'", ",", "self", "::", "$", "_req", "[", "'lang'", "]", ")", ";", "}" ]
Initialize request for CLI runs @return null
[ "Initialize", "request", "for", "CLI", "runs" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Router.php#L105-L126
240,261
vphantom/pyritephp
src/Pyrite/Router.php
Router.startup
public static function startup() { global $PPHP; trigger('language', self::$_req['lang']); if (isset(self::$_PATH[1]) && listeners('route/' . self::$_PATH[0] . '+' . self::$_PATH[1])) { self::$_base = array_shift(self::$_PATH) . '+' . array_shift(self::$_PATH); } elseif (isset(self::$_PATH[0])) { if (listeners('route/' . self::$_PATH[0])) { self::$_base = array_shift(self::$_PATH); } else { trigger('http_status', 404); }; } elseif (listeners('route/main')) { self::$_base = 'main'; } else { trigger('http_status', 404); }; self::$_req['path_args'] = self::$_PATH; }
php
public static function startup() { global $PPHP; trigger('language', self::$_req['lang']); if (isset(self::$_PATH[1]) && listeners('route/' . self::$_PATH[0] . '+' . self::$_PATH[1])) { self::$_base = array_shift(self::$_PATH) . '+' . array_shift(self::$_PATH); } elseif (isset(self::$_PATH[0])) { if (listeners('route/' . self::$_PATH[0])) { self::$_base = array_shift(self::$_PATH); } else { trigger('http_status', 404); }; } elseif (listeners('route/main')) { self::$_base = 'main'; } else { trigger('http_status', 404); }; self::$_req['path_args'] = self::$_PATH; }
[ "public", "static", "function", "startup", "(", ")", "{", "global", "$", "PPHP", ";", "trigger", "(", "'language'", ",", "self", "::", "$", "_req", "[", "'lang'", "]", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "_PATH", "[", "1", "]", ")", "&&", "listeners", "(", "'route/'", ".", "self", "::", "$", "_PATH", "[", "0", "]", ".", "'+'", ".", "self", "::", "$", "_PATH", "[", "1", "]", ")", ")", "{", "self", "::", "$", "_base", "=", "array_shift", "(", "self", "::", "$", "_PATH", ")", ".", "'+'", ".", "array_shift", "(", "self", "::", "$", "_PATH", ")", ";", "}", "elseif", "(", "isset", "(", "self", "::", "$", "_PATH", "[", "0", "]", ")", ")", "{", "if", "(", "listeners", "(", "'route/'", ".", "self", "::", "$", "_PATH", "[", "0", "]", ")", ")", "{", "self", "::", "$", "_base", "=", "array_shift", "(", "self", "::", "$", "_PATH", ")", ";", "}", "else", "{", "trigger", "(", "'http_status'", ",", "404", ")", ";", "}", ";", "}", "elseif", "(", "listeners", "(", "'route/main'", ")", ")", "{", "self", "::", "$", "_base", "=", "'main'", ";", "}", "else", "{", "trigger", "(", "'http_status'", ",", "404", ")", ";", "}", ";", "self", "::", "$", "_req", "[", "'path_args'", "]", "=", "self", "::", "$", "_PATH", ";", "}" ]
Build route from requested URL - Extract language from initial '/xx/' - Build route/foo+bar if handled, route/foo otherwise - Default to route/main - Trigger 404 status if not handled at all @return null
[ "Build", "route", "from", "requested", "URL" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Router.php#L220-L240
240,262
vphantom/pyritephp
src/Pyrite/Router.php
Router.run
public static function run() { if (!pass('validate_request', 'route/' . self::$_base)) { return; }; if (self::$_base !== null && !pass('route/' . self::$_base, self::$_PATH)) { trigger('http_status', 500); }; }
php
public static function run() { if (!pass('validate_request', 'route/' . self::$_base)) { return; }; if (self::$_base !== null && !pass('route/' . self::$_base, self::$_PATH)) { trigger('http_status', 500); }; }
[ "public", "static", "function", "run", "(", ")", "{", "if", "(", "!", "pass", "(", "'validate_request'", ",", "'route/'", ".", "self", "::", "$", "_base", ")", ")", "{", "return", ";", "}", ";", "if", "(", "self", "::", "$", "_base", "!==", "null", "&&", "!", "pass", "(", "'route/'", ".", "self", "::", "$", "_base", ",", "self", "::", "$", "_PATH", ")", ")", "{", "trigger", "(", "'http_status'", ",", "500", ")", ";", "}", ";", "}" ]
Trigger handler for current route @return null
[ "Trigger", "handler", "for", "current", "route" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Router.php#L247-L256
240,263
vphantom/pyritephp
src/Pyrite/Router.php
Router.addWarning
public static function addWarning($code, $level = 1, $args = null) { if ($args === null) { // Callers may use null as well. $args = array(); }; if (!is_array($args)) { $args = array($args); }; switch ($level) { case 0: case 1: case 2: case 3: break; default: $level = 1; }; self::$_req['warnings'][] = array($level, $code, $args); }
php
public static function addWarning($code, $level = 1, $args = null) { if ($args === null) { // Callers may use null as well. $args = array(); }; if (!is_array($args)) { $args = array($args); }; switch ($level) { case 0: case 1: case 2: case 3: break; default: $level = 1; }; self::$_req['warnings'][] = array($level, $code, $args); }
[ "public", "static", "function", "addWarning", "(", "$", "code", ",", "$", "level", "=", "1", ",", "$", "args", "=", "null", ")", "{", "if", "(", "$", "args", "===", "null", ")", "{", "// Callers may use null as well.", "$", "args", "=", "array", "(", ")", ";", "}", ";", "if", "(", "!", "is_array", "(", "$", "args", ")", ")", "{", "$", "args", "=", "array", "(", "$", "args", ")", ";", "}", ";", "switch", "(", "$", "level", ")", "{", "case", "0", ":", "case", "1", ":", "case", "2", ":", "case", "3", ":", "break", ";", "default", ":", "$", "level", "=", "1", ";", "}", ";", "self", "::", "$", "_req", "[", "'warnings'", "]", "[", "]", "=", "array", "(", "$", "level", ",", "$", "code", ",", "$", "args", ")", ";", "}" ]
Add warning to the list Severity level should be one of: 3: success 2: info 1: warning 0: fatal Any other value will be replaced with 1. If $args is not an array, it will be used directly as a single argument for convenience. @param string $code Warning code string @param int|null $level Lowest=worst severity level @param mixed|null $args Optional list of arguments @return null
[ "Add", "warning", "to", "the", "list" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Router.php#L327-L346
240,264
webriq/core
module/User/src/Grid/User/Model/Authentication/AdapterFactory.php
AdapterFactory.factory
public function factory( $adapter, $options = null ) { $adapter = parent::factory( $adapter, $options ); $adapter->setModel( $this->getModel() ); if ( $adapter instanceof ServiceLocatorAwareInterface ) { $adapter->setServiceLocator( $this->getServiceLocator() ); } return $adapter; }
php
public function factory( $adapter, $options = null ) { $adapter = parent::factory( $adapter, $options ); $adapter->setModel( $this->getModel() ); if ( $adapter instanceof ServiceLocatorAwareInterface ) { $adapter->setServiceLocator( $this->getServiceLocator() ); } return $adapter; }
[ "public", "function", "factory", "(", "$", "adapter", ",", "$", "options", "=", "null", ")", "{", "$", "adapter", "=", "parent", "::", "factory", "(", "$", "adapter", ",", "$", "options", ")", ";", "$", "adapter", "->", "setModel", "(", "$", "this", "->", "getModel", "(", ")", ")", ";", "if", "(", "$", "adapter", "instanceof", "ServiceLocatorAwareInterface", ")", "{", "$", "adapter", "->", "setServiceLocator", "(", "$", "this", "->", "getServiceLocator", "(", ")", ")", ";", "}", "return", "$", "adapter", ";", "}" ]
Factory an object @param string|object|array $adapter @param object|array|null $options @return \Zork\Factory\AdapterInterface
[ "Factory", "an", "object" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/User/src/Grid/User/Model/Authentication/AdapterFactory.php#L49-L60
240,265
pablodip/PablodipModuleBundle
Action/BaseAction.php
BaseAction.generateModuleUrl
public function generateModuleUrl($actionName, array $parameters = array(), $absolute = false) { return $this->module->generateModuleUrl($actionName, $parameters, $absolute); }
php
public function generateModuleUrl($actionName, array $parameters = array(), $absolute = false) { return $this->module->generateModuleUrl($actionName, $parameters, $absolute); }
[ "public", "function", "generateModuleUrl", "(", "$", "actionName", ",", "array", "$", "parameters", "=", "array", "(", ")", ",", "$", "absolute", "=", "false", ")", "{", "return", "$", "this", "->", "module", "->", "generateModuleUrl", "(", "$", "actionName", ",", "$", "parameters", ",", "$", "absolute", ")", ";", "}" ]
Generates a module url. @param string $actionName The action name. @param array $parameters An array of parameters. @param Boolean $absolute Whether to generate an absolute URL. @return string The URL.
[ "Generates", "a", "module", "url", "." ]
6d26df909fa4c57b8b3337d58f8cbecd7781c6ef
https://github.com/pablodip/PablodipModuleBundle/blob/6d26df909fa4c57b8b3337d58f8cbecd7781c6ef/Action/BaseAction.php#L275-L278
240,266
pablodip/PablodipModuleBundle
Action/BaseAction.php
BaseAction.render
public function render($template, array $parameters = array(), $response = null) { if (is_array($template)) { // guessing template $parameters = $template; $bundle = ''; $module = null; foreach (explode('\\', get_class($this->getModule())) as $part) { if (null === $module) { if (strlen($part) > 6 && 'Bundle' === substr($part, -6)) { $bundle .= $part; $module = ''; } elseif ('Bundle' !== $part) { $bundle .= $part; } } elseif (strlen($part) > 6 && 'Module' === substr($part, -6)) { $module = substr($part, 0, strlen($part) - 6); } } if (null === $bundle || null === $module) { throw new \RuntimeException(sprintf('The template for the action "%s" from the module "%s" cannot be guessed.', $this->getName(), get_class($this->getModule()))); } $template = sprintf('%s:%s:%s.html.twig', $bundle, $module, $this->getName()); } $parameters['module'] = $this->module->createView(); return $this->getContainer()->get('templating')->renderResponse($template, $parameters, $response); }
php
public function render($template, array $parameters = array(), $response = null) { if (is_array($template)) { // guessing template $parameters = $template; $bundle = ''; $module = null; foreach (explode('\\', get_class($this->getModule())) as $part) { if (null === $module) { if (strlen($part) > 6 && 'Bundle' === substr($part, -6)) { $bundle .= $part; $module = ''; } elseif ('Bundle' !== $part) { $bundle .= $part; } } elseif (strlen($part) > 6 && 'Module' === substr($part, -6)) { $module = substr($part, 0, strlen($part) - 6); } } if (null === $bundle || null === $module) { throw new \RuntimeException(sprintf('The template for the action "%s" from the module "%s" cannot be guessed.', $this->getName(), get_class($this->getModule()))); } $template = sprintf('%s:%s:%s.html.twig', $bundle, $module, $this->getName()); } $parameters['module'] = $this->module->createView(); return $this->getContainer()->get('templating')->renderResponse($template, $parameters, $response); }
[ "public", "function", "render", "(", "$", "template", ",", "array", "$", "parameters", "=", "array", "(", ")", ",", "$", "response", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "template", ")", ")", "{", "// guessing template", "$", "parameters", "=", "$", "template", ";", "$", "bundle", "=", "''", ";", "$", "module", "=", "null", ";", "foreach", "(", "explode", "(", "'\\\\'", ",", "get_class", "(", "$", "this", "->", "getModule", "(", ")", ")", ")", "as", "$", "part", ")", "{", "if", "(", "null", "===", "$", "module", ")", "{", "if", "(", "strlen", "(", "$", "part", ")", ">", "6", "&&", "'Bundle'", "===", "substr", "(", "$", "part", ",", "-", "6", ")", ")", "{", "$", "bundle", ".=", "$", "part", ";", "$", "module", "=", "''", ";", "}", "elseif", "(", "'Bundle'", "!==", "$", "part", ")", "{", "$", "bundle", ".=", "$", "part", ";", "}", "}", "elseif", "(", "strlen", "(", "$", "part", ")", ">", "6", "&&", "'Module'", "===", "substr", "(", "$", "part", ",", "-", "6", ")", ")", "{", "$", "module", "=", "substr", "(", "$", "part", ",", "0", ",", "strlen", "(", "$", "part", ")", "-", "6", ")", ";", "}", "}", "if", "(", "null", "===", "$", "bundle", "||", "null", "===", "$", "module", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'The template for the action \"%s\" from the module \"%s\" cannot be guessed.'", ",", "$", "this", "->", "getName", "(", ")", ",", "get_class", "(", "$", "this", "->", "getModule", "(", ")", ")", ")", ")", ";", "}", "$", "template", "=", "sprintf", "(", "'%s:%s:%s.html.twig'", ",", "$", "bundle", ",", "$", "module", ",", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "$", "parameters", "[", "'module'", "]", "=", "$", "this", "->", "module", "->", "createView", "(", ")", ";", "return", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'templating'", ")", "->", "renderResponse", "(", "$", "template", ",", "$", "parameters", ",", "$", "response", ")", ";", "}" ]
Renders a view a returns a response. Adds the "module" parameter. @param string $template The template. @param array $parameters An array of parameters (optional). @param Response $response The response (optional). @return Response The response.
[ "Renders", "a", "view", "a", "returns", "a", "response", "." ]
6d26df909fa4c57b8b3337d58f8cbecd7781c6ef
https://github.com/pablodip/PablodipModuleBundle/blob/6d26df909fa4c57b8b3337d58f8cbecd7781c6ef/Action/BaseAction.php#L321-L352
240,267
pablodip/PablodipModuleBundle
Action/BaseAction.php
BaseAction.createFormBuilder
public function createFormBuilder($data = null, array $options = array()) { return $this->getContainer()->get('form.factory')->createBuilder('form', $data, $options); }
php
public function createFormBuilder($data = null, array $options = array()) { return $this->getContainer()->get('form.factory')->createBuilder('form', $data, $options); }
[ "public", "function", "createFormBuilder", "(", "$", "data", "=", "null", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'form.factory'", ")", "->", "createBuilder", "(", "'form'", ",", "$", "data", ",", "$", "options", ")", ";", "}" ]
Creates and returns a form builder instance @param mixed $data The initial data for the form @param array $options Options for the form @return FormBuilder
[ "Creates", "and", "returns", "a", "form", "builder", "instance" ]
6d26df909fa4c57b8b3337d58f8cbecd7781c6ef
https://github.com/pablodip/PablodipModuleBundle/blob/6d26df909fa4c57b8b3337d58f8cbecd7781c6ef/Action/BaseAction.php#L390-L393
240,268
remote-office/libx
src/Net/Rest/Client.php
Client.execute
public function execute(Request $request, Response $response) { // Open curl handler $handle = curl_init(); // Set header callback curl_setopt($handle, CURLOPT_HEADERFUNCTION, array(&$response, 'header')); // Do not reuse connection curl_setopt($handle, CURLOPT_FORBID_REUSE, 1); curl_setopt($handle, CURLOPT_FRESH_CONNECT, 1); // Clear default "Expect: 100-continue" header //curl_setopt($handle, CURLOPT_HTTPHEADER, array('Expect:')); // Set custom headers if($request->hasHeaders()) { curl_setopt($handle, CURLOPT_HEADER, 0); curl_setopt($handle, CURLOPT_HTTPHEADER, $request->getHeaders()); } // Set authentication if needed if($request->hasUsername() && $request->hasPassword()) { curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($handle, CURLOPT_USERPWD, $request->getUsername() . ':' . $request->getPassword()); } // Set timeout if($request->hasTimeout()) curl_setopt($handle, CURLOPT_TIMEOUT, $request->getTimeout()); // Set curl options curl_setopt($handle, CURLOPT_URL, $request->getUrl()); curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, FALSE); //curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 1); // Get method $method = $request->getMethod(); if(!method_exists($this, strtolower($method))) throw new Exception(__METHOD__ . '; Request method "' .$method . '" not supported'); // Call request method handler call_user_func(array($this, strtolower($method)), $handle, $request, $response); // Execute curl request curl_exec($handle); // Get info $info = curl_getinfo($handle); // Set info $response->setInfo($info); // Close curl handler if(!is_null($handle) && is_resource($handle)) curl_close($handle); }
php
public function execute(Request $request, Response $response) { // Open curl handler $handle = curl_init(); // Set header callback curl_setopt($handle, CURLOPT_HEADERFUNCTION, array(&$response, 'header')); // Do not reuse connection curl_setopt($handle, CURLOPT_FORBID_REUSE, 1); curl_setopt($handle, CURLOPT_FRESH_CONNECT, 1); // Clear default "Expect: 100-continue" header //curl_setopt($handle, CURLOPT_HTTPHEADER, array('Expect:')); // Set custom headers if($request->hasHeaders()) { curl_setopt($handle, CURLOPT_HEADER, 0); curl_setopt($handle, CURLOPT_HTTPHEADER, $request->getHeaders()); } // Set authentication if needed if($request->hasUsername() && $request->hasPassword()) { curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($handle, CURLOPT_USERPWD, $request->getUsername() . ':' . $request->getPassword()); } // Set timeout if($request->hasTimeout()) curl_setopt($handle, CURLOPT_TIMEOUT, $request->getTimeout()); // Set curl options curl_setopt($handle, CURLOPT_URL, $request->getUrl()); curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, FALSE); //curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 1); // Get method $method = $request->getMethod(); if(!method_exists($this, strtolower($method))) throw new Exception(__METHOD__ . '; Request method "' .$method . '" not supported'); // Call request method handler call_user_func(array($this, strtolower($method)), $handle, $request, $response); // Execute curl request curl_exec($handle); // Get info $info = curl_getinfo($handle); // Set info $response->setInfo($info); // Close curl handler if(!is_null($handle) && is_resource($handle)) curl_close($handle); }
[ "public", "function", "execute", "(", "Request", "$", "request", ",", "Response", "$", "response", ")", "{", "// Open curl handler", "$", "handle", "=", "curl_init", "(", ")", ";", "// Set header callback", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_HEADERFUNCTION", ",", "array", "(", "&", "$", "response", ",", "'header'", ")", ")", ";", "// Do not reuse connection", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_FORBID_REUSE", ",", "1", ")", ";", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_FRESH_CONNECT", ",", "1", ")", ";", "// Clear default \"Expect: 100-continue\" header", "//curl_setopt($handle, CURLOPT_HTTPHEADER, array('Expect:'));", "// Set custom headers", "if", "(", "$", "request", "->", "hasHeaders", "(", ")", ")", "{", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_HEADER", ",", "0", ")", ";", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_HTTPHEADER", ",", "$", "request", "->", "getHeaders", "(", ")", ")", ";", "}", "// Set authentication if needed", "if", "(", "$", "request", "->", "hasUsername", "(", ")", "&&", "$", "request", "->", "hasPassword", "(", ")", ")", "{", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_HTTPAUTH", ",", "CURLAUTH_BASIC", ")", ";", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_USERPWD", ",", "$", "request", "->", "getUsername", "(", ")", ".", "':'", ".", "$", "request", "->", "getPassword", "(", ")", ")", ";", "}", "// Set timeout", "if", "(", "$", "request", "->", "hasTimeout", "(", ")", ")", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_TIMEOUT", ",", "$", "request", "->", "getTimeout", "(", ")", ")", ";", "// Set curl options", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_URL", ",", "$", "request", "->", "getUrl", "(", ")", ")", ";", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_RETURNTRANSFER", ",", "1", ")", ";", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_SSL_VERIFYPEER", ",", "FALSE", ")", ";", "//curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 2);", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_SSL_VERIFYHOST", ",", "0", ")", ";", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_FOLLOWLOCATION", ",", "1", ")", ";", "// Get method", "$", "method", "=", "$", "request", "->", "getMethod", "(", ")", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "strtolower", "(", "$", "method", ")", ")", ")", "throw", "new", "Exception", "(", "__METHOD__", ".", "'; Request method \"'", ".", "$", "method", ".", "'\" not supported'", ")", ";", "// Call request method handler", "call_user_func", "(", "array", "(", "$", "this", ",", "strtolower", "(", "$", "method", ")", ")", ",", "$", "handle", ",", "$", "request", ",", "$", "response", ")", ";", "// Execute curl request", "curl_exec", "(", "$", "handle", ")", ";", "// Get info", "$", "info", "=", "curl_getinfo", "(", "$", "handle", ")", ";", "// Set info", "$", "response", "->", "setInfo", "(", "$", "info", ")", ";", "// Close curl handler", "if", "(", "!", "is_null", "(", "$", "handle", ")", "&&", "is_resource", "(", "$", "handle", ")", ")", "curl_close", "(", "$", "handle", ")", ";", "}" ]
Do rest call @param Request $request @param Request $response @throws Exception
[ "Do", "rest", "call" ]
8baeaae99a6110e7c588bc0388df89a0dc0768b5
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/Net/Rest/Client.php#L43-L107
240,269
tux-rampage/rampage-php
library/rampage/core/ModuleManifest.php
ModuleManifest.processIncludes
protected function processIncludes() { foreach ($this->getXml()->xpath('/includes/include[@type != "" and @file != ""]') as $include) { $processor = $this->getIncludeProcessor((string)$include['type']); if (!$processor) { trigger_error(sprintf('No include processor for "%s" available. Did you forget to register it?', (string)$include['type']), E_USER_WARNING); continue; } $file = $this->getModulePath((string)$include['file']); $processor->load($file, $this->manifest); } return $this; }
php
protected function processIncludes() { foreach ($this->getXml()->xpath('/includes/include[@type != "" and @file != ""]') as $include) { $processor = $this->getIncludeProcessor((string)$include['type']); if (!$processor) { trigger_error(sprintf('No include processor for "%s" available. Did you forget to register it?', (string)$include['type']), E_USER_WARNING); continue; } $file = $this->getModulePath((string)$include['file']); $processor->load($file, $this->manifest); } return $this; }
[ "protected", "function", "processIncludes", "(", ")", "{", "foreach", "(", "$", "this", "->", "getXml", "(", ")", "->", "xpath", "(", "'/includes/include[@type != \"\" and @file != \"\"]'", ")", "as", "$", "include", ")", "{", "$", "processor", "=", "$", "this", "->", "getIncludeProcessor", "(", "(", "string", ")", "$", "include", "[", "'type'", "]", ")", ";", "if", "(", "!", "$", "processor", ")", "{", "trigger_error", "(", "sprintf", "(", "'No include processor for \"%s\" available. Did you forget to register it?'", ",", "(", "string", ")", "$", "include", "[", "'type'", "]", ")", ",", "E_USER_WARNING", ")", ";", "continue", ";", "}", "$", "file", "=", "$", "this", "->", "getModulePath", "(", "(", "string", ")", "$", "include", "[", "'file'", "]", ")", ";", "$", "processor", "->", "load", "(", "$", "file", ",", "$", "this", "->", "manifest", ")", ";", "}", "return", "$", "this", ";", "}" ]
Process include directives @return self
[ "Process", "include", "directives" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/ModuleManifest.php#L111-L125
240,270
tux-rampage/rampage-php
library/rampage/core/ModuleManifest.php
ModuleManifest.validate
public function validate($xsd = null) { if (!$xsd) { $xsdPath = __DIR__ . '/../../../resources/xsd/'; $xsd = $xsdPath . 'rampage/core/ModuleManifest.xsd'; } try { $dom = new DOMDocument(); $dom->loadXML($this->getXml()->asXML()); $result = $dom->schemaValidate($xsd); unset($dom); } catch (\Exception $e) { return false; } return $result; }
php
public function validate($xsd = null) { if (!$xsd) { $xsdPath = __DIR__ . '/../../../resources/xsd/'; $xsd = $xsdPath . 'rampage/core/ModuleManifest.xsd'; } try { $dom = new DOMDocument(); $dom->loadXML($this->getXml()->asXML()); $result = $dom->schemaValidate($xsd); unset($dom); } catch (\Exception $e) { return false; } return $result; }
[ "public", "function", "validate", "(", "$", "xsd", "=", "null", ")", "{", "if", "(", "!", "$", "xsd", ")", "{", "$", "xsdPath", "=", "__DIR__", ".", "'/../../../resources/xsd/'", ";", "$", "xsd", "=", "$", "xsdPath", ".", "'rampage/core/ModuleManifest.xsd'", ";", "}", "try", "{", "$", "dom", "=", "new", "DOMDocument", "(", ")", ";", "$", "dom", "->", "loadXML", "(", "$", "this", "->", "getXml", "(", ")", "->", "asXML", "(", ")", ")", ";", "$", "result", "=", "$", "dom", "->", "schemaValidate", "(", "$", "xsd", ")", ";", "unset", "(", "$", "dom", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "return", "$", "result", ";", "}" ]
Validate manifest xml @return bool
[ "Validate", "manifest", "xml" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/ModuleManifest.php#L132-L150
240,271
tux-rampage/rampage-php
library/rampage/core/ModuleManifest.php
ModuleManifest.getModulePath
public function getModulePath($file, $asFileInfo = false) { $path = $this->moduleDirectory . ltrim($file, '/'); if ($asFileInfo) { $path = new \SplFileInfo($path); } return $path; }
php
public function getModulePath($file, $asFileInfo = false) { $path = $this->moduleDirectory . ltrim($file, '/'); if ($asFileInfo) { $path = new \SplFileInfo($path); } return $path; }
[ "public", "function", "getModulePath", "(", "$", "file", ",", "$", "asFileInfo", "=", "false", ")", "{", "$", "path", "=", "$", "this", "->", "moduleDirectory", ".", "ltrim", "(", "$", "file", ",", "'/'", ")", ";", "if", "(", "$", "asFileInfo", ")", "{", "$", "path", "=", "new", "\\", "SplFileInfo", "(", "$", "path", ")", ";", "}", "return", "$", "path", ";", "}" ]
Returns the file path for the current module @param string $file @param bool $asFileInfo @return string|\SplFileInfo
[ "Returns", "the", "file", "path", "for", "the", "current", "module" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/ModuleManifest.php#L202-L210
240,272
tux-rampage/rampage-php
library/rampage/core/ModuleManifest.php
ModuleManifest.loadServiceConfig
protected function loadServiceConfig() { $xml = $this->getNode('./servicemanager'); $config = $this->createServiceManagerConfig($xml, true); if ($config) { $this->manifest['application_config']['service_manager'] = $config; } return $this; }
php
protected function loadServiceConfig() { $xml = $this->getNode('./servicemanager'); $config = $this->createServiceManagerConfig($xml, true); if ($config) { $this->manifest['application_config']['service_manager'] = $config; } return $this; }
[ "protected", "function", "loadServiceConfig", "(", ")", "{", "$", "xml", "=", "$", "this", "->", "getNode", "(", "'./servicemanager'", ")", ";", "$", "config", "=", "$", "this", "->", "createServiceManagerConfig", "(", "$", "xml", ",", "true", ")", ";", "if", "(", "$", "config", ")", "{", "$", "this", "->", "manifest", "[", "'application_config'", "]", "[", "'service_manager'", "]", "=", "$", "config", ";", "}", "return", "$", "this", ";", "}" ]
Load service config @return self
[ "Load", "service", "config" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/ModuleManifest.php#L282-L292
240,273
tux-rampage/rampage-php
library/rampage/core/ModuleManifest.php
ModuleManifest.loadPluginManagerConfigs
protected function loadPluginManagerConfigs() { foreach ($this->getXml()->xpath('plugins/pluginmanager[@type != ""]') as $pmConfig) { $key = (string)$pmConfig['type']; $config = $this->createServiceManagerConfig($pmConfig); if ($config) { $this->manifest['application_config'][$key] = $config; } } return $this; }
php
protected function loadPluginManagerConfigs() { foreach ($this->getXml()->xpath('plugins/pluginmanager[@type != ""]') as $pmConfig) { $key = (string)$pmConfig['type']; $config = $this->createServiceManagerConfig($pmConfig); if ($config) { $this->manifest['application_config'][$key] = $config; } } return $this; }
[ "protected", "function", "loadPluginManagerConfigs", "(", ")", "{", "foreach", "(", "$", "this", "->", "getXml", "(", ")", "->", "xpath", "(", "'plugins/pluginmanager[@type != \"\"]'", ")", "as", "$", "pmConfig", ")", "{", "$", "key", "=", "(", "string", ")", "$", "pmConfig", "[", "'type'", "]", ";", "$", "config", "=", "$", "this", "->", "createServiceManagerConfig", "(", "$", "pmConfig", ")", ";", "if", "(", "$", "config", ")", "{", "$", "this", "->", "manifest", "[", "'application_config'", "]", "[", "$", "key", "]", "=", "$", "config", ";", "}", "}", "return", "$", "this", ";", "}" ]
Plugin manager configs
[ "Plugin", "manager", "configs" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/ModuleManifest.php#L373-L385
240,274
tux-rampage/rampage-php
library/rampage/core/ModuleManifest.php
ModuleManifest.loadLocaleConfig
protected function loadLocaleConfig() { $xml = $this->getXml(); $config = &$this->manifest['application_config']; if (!isset($xml->locale->pattern)) { return $this; } foreach ($xml->xpath('locale/pattern[@pattern != ""]') as $node) { $dir = isset($node['basedir'])? (string)$node['basedir'] : 'locale'; $config['translator']['translation_file_patterns'][] = array( 'type' => isset($node['type'])? (string)$node['type'] : 'php', 'base_dir' => $this->getModulePath($dir), 'pattern' => isset($node['pattern'])? (string)$node['pattern'] : '%s.php', ); } return $this; }
php
protected function loadLocaleConfig() { $xml = $this->getXml(); $config = &$this->manifest['application_config']; if (!isset($xml->locale->pattern)) { return $this; } foreach ($xml->xpath('locale/pattern[@pattern != ""]') as $node) { $dir = isset($node['basedir'])? (string)$node['basedir'] : 'locale'; $config['translator']['translation_file_patterns'][] = array( 'type' => isset($node['type'])? (string)$node['type'] : 'php', 'base_dir' => $this->getModulePath($dir), 'pattern' => isset($node['pattern'])? (string)$node['pattern'] : '%s.php', ); } return $this; }
[ "protected", "function", "loadLocaleConfig", "(", ")", "{", "$", "xml", "=", "$", "this", "->", "getXml", "(", ")", ";", "$", "config", "=", "&", "$", "this", "->", "manifest", "[", "'application_config'", "]", ";", "if", "(", "!", "isset", "(", "$", "xml", "->", "locale", "->", "pattern", ")", ")", "{", "return", "$", "this", ";", "}", "foreach", "(", "$", "xml", "->", "xpath", "(", "'locale/pattern[@pattern != \"\"]'", ")", "as", "$", "node", ")", "{", "$", "dir", "=", "isset", "(", "$", "node", "[", "'basedir'", "]", ")", "?", "(", "string", ")", "$", "node", "[", "'basedir'", "]", ":", "'locale'", ";", "$", "config", "[", "'translator'", "]", "[", "'translation_file_patterns'", "]", "[", "]", "=", "array", "(", "'type'", "=>", "isset", "(", "$", "node", "[", "'type'", "]", ")", "?", "(", "string", ")", "$", "node", "[", "'type'", "]", ":", "'php'", ",", "'base_dir'", "=>", "$", "this", "->", "getModulePath", "(", "$", "dir", ")", ",", "'pattern'", "=>", "isset", "(", "$", "node", "[", "'pattern'", "]", ")", "?", "(", "string", ")", "$", "node", "[", "'pattern'", "]", ":", "'%s.php'", ",", ")", ";", "}", "return", "$", "this", ";", "}" ]
Load locale config
[ "Load", "locale", "config" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/ModuleManifest.php#L390-L410
240,275
tux-rampage/rampage-php
library/rampage/core/ModuleManifest.php
ModuleManifest.childToArray
protected function childToArray(SimpleXmlElement $xml, $name) { if (!isset($xml->{$name})) { return array(); } return $xml->{$name}->toPhpValue('array'); }
php
protected function childToArray(SimpleXmlElement $xml, $name) { if (!isset($xml->{$name})) { return array(); } return $xml->{$name}->toPhpValue('array'); }
[ "protected", "function", "childToArray", "(", "SimpleXmlElement", "$", "xml", ",", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "xml", "->", "{", "$", "name", "}", ")", ")", "{", "return", "array", "(", ")", ";", "}", "return", "$", "xml", "->", "{", "$", "name", "}", "->", "toPhpValue", "(", "'array'", ")", ";", "}" ]
Child node to array @param SimpleXmlElement $xml @param string $name @return array
[ "Child", "node", "to", "array" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/ModuleManifest.php#L419-L426
240,276
tux-rampage/rampage-php
library/rampage/core/ModuleManifest.php
ModuleManifest.getRouteConfig
protected function getRouteConfig($node) { if ((!$node instanceof SimpleXmlElement) || !$node->route) { return false; } $config = array(); foreach ($node->route as $route) { $type = (string)$route['type']; $name = (string)$route['name']; if (!$name) { continue; } $routeConfig = $this->getRouteConfigOptions($route, $type); if (!is_array($routeConfig)) { return null; } $config[$name] = $routeConfig; if (isset($route['mayterminate'])) { $config[$name]['may_terminate'] = $route->is('mayterminate'); } $children = $this->getRouteConfig($route->routes); if (!empty($children)) { $config[$name]['child_routes'] = $children; } } return $config; }
php
protected function getRouteConfig($node) { if ((!$node instanceof SimpleXmlElement) || !$node->route) { return false; } $config = array(); foreach ($node->route as $route) { $type = (string)$route['type']; $name = (string)$route['name']; if (!$name) { continue; } $routeConfig = $this->getRouteConfigOptions($route, $type); if (!is_array($routeConfig)) { return null; } $config[$name] = $routeConfig; if (isset($route['mayterminate'])) { $config[$name]['may_terminate'] = $route->is('mayterminate'); } $children = $this->getRouteConfig($route->routes); if (!empty($children)) { $config[$name]['child_routes'] = $children; } } return $config; }
[ "protected", "function", "getRouteConfig", "(", "$", "node", ")", "{", "if", "(", "(", "!", "$", "node", "instanceof", "SimpleXmlElement", ")", "||", "!", "$", "node", "->", "route", ")", "{", "return", "false", ";", "}", "$", "config", "=", "array", "(", ")", ";", "foreach", "(", "$", "node", "->", "route", "as", "$", "route", ")", "{", "$", "type", "=", "(", "string", ")", "$", "route", "[", "'type'", "]", ";", "$", "name", "=", "(", "string", ")", "$", "route", "[", "'name'", "]", ";", "if", "(", "!", "$", "name", ")", "{", "continue", ";", "}", "$", "routeConfig", "=", "$", "this", "->", "getRouteConfigOptions", "(", "$", "route", ",", "$", "type", ")", ";", "if", "(", "!", "is_array", "(", "$", "routeConfig", ")", ")", "{", "return", "null", ";", "}", "$", "config", "[", "$", "name", "]", "=", "$", "routeConfig", ";", "if", "(", "isset", "(", "$", "route", "[", "'mayterminate'", "]", ")", ")", "{", "$", "config", "[", "$", "name", "]", "[", "'may_terminate'", "]", "=", "$", "route", "->", "is", "(", "'mayterminate'", ")", ";", "}", "$", "children", "=", "$", "this", "->", "getRouteConfig", "(", "$", "route", "->", "routes", ")", ";", "if", "(", "!", "empty", "(", "$", "children", ")", ")", "{", "$", "config", "[", "$", "name", "]", "[", "'child_routes'", "]", "=", "$", "children", ";", "}", "}", "return", "$", "config", ";", "}" ]
get route config from manifest xml @param SimpleXmlElement $node @return array|false
[ "get", "route", "config", "from", "manifest", "xml" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/ModuleManifest.php#L544-L576
240,277
tux-rampage/rampage-php
library/rampage/core/ModuleManifest.php
ModuleManifest.loadRouteConfig
protected function loadRouteConfig() { $xml = $this->getNode('router'); if (!$xml instanceof SimpleXmlElement) { return $this; } $config = $this->getRouteConfig($xml); if (!$config) { return $this; } $this->manifest['application_config']['router']['routes'] = $config; return $this; }
php
protected function loadRouteConfig() { $xml = $this->getNode('router'); if (!$xml instanceof SimpleXmlElement) { return $this; } $config = $this->getRouteConfig($xml); if (!$config) { return $this; } $this->manifest['application_config']['router']['routes'] = $config; return $this; }
[ "protected", "function", "loadRouteConfig", "(", ")", "{", "$", "xml", "=", "$", "this", "->", "getNode", "(", "'router'", ")", ";", "if", "(", "!", "$", "xml", "instanceof", "SimpleXmlElement", ")", "{", "return", "$", "this", ";", "}", "$", "config", "=", "$", "this", "->", "getRouteConfig", "(", "$", "xml", ")", ";", "if", "(", "!", "$", "config", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "manifest", "[", "'application_config'", "]", "[", "'router'", "]", "[", "'routes'", "]", "=", "$", "config", ";", "return", "$", "this", ";", "}" ]
Load route config from manifest
[ "Load", "route", "config", "from", "manifest" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/ModuleManifest.php#L628-L642
240,278
tux-rampage/rampage-php
library/rampage/core/ModuleManifest.php
ModuleManifest.loadThemeConfig
protected function loadThemeConfig() { $xml = $this->getXml(); foreach ($xml->xpath('./resources/themes/theme[@name != "" and @path != ""]') as $node) { $path = (string)$node['path']; $name = (string)$node['name']; $this->manifest['application_config']['rampage']['themes'][$name]['path'] = $this->getModulePath($path); if (isset($node['fallbacks'])) { $fallbacks = explode(',', (string)$node['fallbacks']); $fallbacks = array_filter(array_map('trim', $fallbacks)); $this->manifest['application_config']['rampage']['themes'][$name]['fallbacks'] = $fallbacks; } } return $this; }
php
protected function loadThemeConfig() { $xml = $this->getXml(); foreach ($xml->xpath('./resources/themes/theme[@name != "" and @path != ""]') as $node) { $path = (string)$node['path']; $name = (string)$node['name']; $this->manifest['application_config']['rampage']['themes'][$name]['path'] = $this->getModulePath($path); if (isset($node['fallbacks'])) { $fallbacks = explode(',', (string)$node['fallbacks']); $fallbacks = array_filter(array_map('trim', $fallbacks)); $this->manifest['application_config']['rampage']['themes'][$name]['fallbacks'] = $fallbacks; } } return $this; }
[ "protected", "function", "loadThemeConfig", "(", ")", "{", "$", "xml", "=", "$", "this", "->", "getXml", "(", ")", ";", "foreach", "(", "$", "xml", "->", "xpath", "(", "'./resources/themes/theme[@name != \"\" and @path != \"\"]'", ")", "as", "$", "node", ")", "{", "$", "path", "=", "(", "string", ")", "$", "node", "[", "'path'", "]", ";", "$", "name", "=", "(", "string", ")", "$", "node", "[", "'name'", "]", ";", "$", "this", "->", "manifest", "[", "'application_config'", "]", "[", "'rampage'", "]", "[", "'themes'", "]", "[", "$", "name", "]", "[", "'path'", "]", "=", "$", "this", "->", "getModulePath", "(", "$", "path", ")", ";", "if", "(", "isset", "(", "$", "node", "[", "'fallbacks'", "]", ")", ")", "{", "$", "fallbacks", "=", "explode", "(", "','", ",", "(", "string", ")", "$", "node", "[", "'fallbacks'", "]", ")", ";", "$", "fallbacks", "=", "array_filter", "(", "array_map", "(", "'trim'", ",", "$", "fallbacks", ")", ")", ";", "$", "this", "->", "manifest", "[", "'application_config'", "]", "[", "'rampage'", "]", "[", "'themes'", "]", "[", "$", "name", "]", "[", "'fallbacks'", "]", "=", "$", "fallbacks", ";", "}", "}", "return", "$", "this", ";", "}" ]
Load theme config @return \rampage\core\modules\ManifestConfig
[ "Load", "theme", "config" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/ModuleManifest.php#L685-L704
240,279
phlexible/phlexible
src/Phlexible/Bundle/QueueBundle/Entity/Repository/JobRepository.php
JobRepository.getStatistics
public function getStatistics($status) { $qb = $this->createQueryBuilder('q'); $qb->select('SUBSTRING(q.job, 1, 200) AS class'); $qb->where($qb->expr()->eq('q.status', $qb->expr()->literal($status))); $result = $qb->getQuery()->getScalarResult(); $stats = []; foreach ($result as $item) { if (!preg_match('/"(.+?)"/', $item['class'], $match)) { continue; } $class = $match[1]; if (!isset($stats[$class])) { $stats[$class] = 0; } ++$stats[$class]; } return $stats; }
php
public function getStatistics($status) { $qb = $this->createQueryBuilder('q'); $qb->select('SUBSTRING(q.job, 1, 200) AS class'); $qb->where($qb->expr()->eq('q.status', $qb->expr()->literal($status))); $result = $qb->getQuery()->getScalarResult(); $stats = []; foreach ($result as $item) { if (!preg_match('/"(.+?)"/', $item['class'], $match)) { continue; } $class = $match[1]; if (!isset($stats[$class])) { $stats[$class] = 0; } ++$stats[$class]; } return $stats; }
[ "public", "function", "getStatistics", "(", "$", "status", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'q'", ")", ";", "$", "qb", "->", "select", "(", "'SUBSTRING(q.job, 1, 200) AS class'", ")", ";", "$", "qb", "->", "where", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "'q.status'", ",", "$", "qb", "->", "expr", "(", ")", "->", "literal", "(", "$", "status", ")", ")", ")", ";", "$", "result", "=", "$", "qb", "->", "getQuery", "(", ")", "->", "getScalarResult", "(", ")", ";", "$", "stats", "=", "[", "]", ";", "foreach", "(", "$", "result", "as", "$", "item", ")", "{", "if", "(", "!", "preg_match", "(", "'/\"(.+?)\"/'", ",", "$", "item", "[", "'class'", "]", ",", "$", "match", ")", ")", "{", "continue", ";", "}", "$", "class", "=", "$", "match", "[", "1", "]", ";", "if", "(", "!", "isset", "(", "$", "stats", "[", "$", "class", "]", ")", ")", "{", "$", "stats", "[", "$", "class", "]", "=", "0", ";", "}", "++", "$", "stats", "[", "$", "class", "]", ";", "}", "return", "$", "stats", ";", "}" ]
Return job statistics. @param int $status @return array
[ "Return", "job", "statistics", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/QueueBundle/Entity/Repository/JobRepository.php#L66-L87
240,280
iuravic/duktig-core
src/Core/AppFactory.php
AppFactory.getConfigArr
protected function getConfigArr(string $configAppFile) : array { $configCoreFile = __DIR__.'/../Config/config.php'; $configCore = $this->requireFile($configCoreFile); $configApp = $this->requireFile($configAppFile); $services = []; $skipCoreServices = $configApp['skipCoreServices'] ?? false; if (isset($configCore['services']) && !$skipCoreServices) { $services[] = $configCore['services']; } if (isset($configApp['services'])) { $services[] = $configApp['services']; } $configArr = array_replace_recursive($configCore, $configApp); $configArr['services'] = $services; return $configArr; }
php
protected function getConfigArr(string $configAppFile) : array { $configCoreFile = __DIR__.'/../Config/config.php'; $configCore = $this->requireFile($configCoreFile); $configApp = $this->requireFile($configAppFile); $services = []; $skipCoreServices = $configApp['skipCoreServices'] ?? false; if (isset($configCore['services']) && !$skipCoreServices) { $services[] = $configCore['services']; } if (isset($configApp['services'])) { $services[] = $configApp['services']; } $configArr = array_replace_recursive($configCore, $configApp); $configArr['services'] = $services; return $configArr; }
[ "protected", "function", "getConfigArr", "(", "string", "$", "configAppFile", ")", ":", "array", "{", "$", "configCoreFile", "=", "__DIR__", ".", "'/../Config/config.php'", ";", "$", "configCore", "=", "$", "this", "->", "requireFile", "(", "$", "configCoreFile", ")", ";", "$", "configApp", "=", "$", "this", "->", "requireFile", "(", "$", "configAppFile", ")", ";", "$", "services", "=", "[", "]", ";", "$", "skipCoreServices", "=", "$", "configApp", "[", "'skipCoreServices'", "]", "??", "false", ";", "if", "(", "isset", "(", "$", "configCore", "[", "'services'", "]", ")", "&&", "!", "$", "skipCoreServices", ")", "{", "$", "services", "[", "]", "=", "$", "configCore", "[", "'services'", "]", ";", "}", "if", "(", "isset", "(", "$", "configApp", "[", "'services'", "]", ")", ")", "{", "$", "services", "[", "]", "=", "$", "configApp", "[", "'services'", "]", ";", "}", "$", "configArr", "=", "array_replace_recursive", "(", "$", "configCore", ",", "$", "configApp", ")", ";", "$", "configArr", "[", "'services'", "]", "=", "$", "services", ";", "return", "$", "configArr", ";", "}" ]
Gets a configuration array. @param string $configAppFile @return array
[ "Gets", "a", "configuration", "array", "." ]
0e04495324516c2b151163fb42882ab0a319a3a8
https://github.com/iuravic/duktig-core/blob/0e04495324516c2b151163fb42882ab0a319a3a8/src/Core/AppFactory.php#L30-L48
240,281
uthando-cms/uthando-newsletter
src/UthandoNewsletter/Service/SubscriberService.php
SubscriberService.preAdd
public function preAdd(Event $e) { $form = $e->getParam('form'); /* @var $inputFilter \UthandoUser\InputFilter\UserInputFilter */ $inputFilter = $form->getInputFilter(); $inputFilter->addEmailNoRecordExists(); }
php
public function preAdd(Event $e) { $form = $e->getParam('form'); /* @var $inputFilter \UthandoUser\InputFilter\UserInputFilter */ $inputFilter = $form->getInputFilter(); $inputFilter->addEmailNoRecordExists(); }
[ "public", "function", "preAdd", "(", "Event", "$", "e", ")", "{", "$", "form", "=", "$", "e", "->", "getParam", "(", "'form'", ")", ";", "/* @var $inputFilter \\UthandoUser\\InputFilter\\UserInputFilter */", "$", "inputFilter", "=", "$", "form", "->", "getInputFilter", "(", ")", ";", "$", "inputFilter", "->", "addEmailNoRecordExists", "(", ")", ";", "}" ]
Pre subscriber add checks @param Event $e
[ "Pre", "subscriber", "add", "checks" ]
0c61bb05133a77e6c323785177007326fdf3cc5d
https://github.com/uthando-cms/uthando-newsletter/blob/0c61bb05133a77e6c323785177007326fdf3cc5d/src/UthandoNewsletter/Service/SubscriberService.php#L123-L129
240,282
Arcavias/ext-zend
lib/custom/src/MW/Mail/Message/Zend.php
MW_Mail_Message_Zend.getObject
public function getObject() { if( !empty( $this->_embedded ) ) { $parts = array(); if( $this->_html != null ) { $part = new Zend_Mime_Part( $this->_html ); $part->charset = $this->_object->getCharset(); $part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $part->disposition = Zend_Mime::DISPOSITION_INLINE; $part->type = Zend_Mime::TYPE_HTML; $parts = array( $part ); } $msg = new Zend_Mime_Message(); $msg->setParts( array_merge( $parts, $this->_embedded ) ); // create html body (text and maybe embedded), modified afterwards to set it to multipart/related $this->_object->setBodyHtml( $msg->generateMessage() ); $related = $this->_object->getBodyHtml(); $related->type = Zend_Mime::MULTIPART_RELATED; $related->encoding = Zend_Mime::ENCODING_8BIT; $related->boundary = $msg->getMime()->boundary(); $related->disposition = null; $related->charset = null; } else if( $this->_html != null ) { $this->_object->setBodyHtml( $this->_html ); } return $this->_object; }
php
public function getObject() { if( !empty( $this->_embedded ) ) { $parts = array(); if( $this->_html != null ) { $part = new Zend_Mime_Part( $this->_html ); $part->charset = $this->_object->getCharset(); $part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $part->disposition = Zend_Mime::DISPOSITION_INLINE; $part->type = Zend_Mime::TYPE_HTML; $parts = array( $part ); } $msg = new Zend_Mime_Message(); $msg->setParts( array_merge( $parts, $this->_embedded ) ); // create html body (text and maybe embedded), modified afterwards to set it to multipart/related $this->_object->setBodyHtml( $msg->generateMessage() ); $related = $this->_object->getBodyHtml(); $related->type = Zend_Mime::MULTIPART_RELATED; $related->encoding = Zend_Mime::ENCODING_8BIT; $related->boundary = $msg->getMime()->boundary(); $related->disposition = null; $related->charset = null; } else if( $this->_html != null ) { $this->_object->setBodyHtml( $this->_html ); } return $this->_object; }
[ "public", "function", "getObject", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "_embedded", ")", ")", "{", "$", "parts", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "_html", "!=", "null", ")", "{", "$", "part", "=", "new", "Zend_Mime_Part", "(", "$", "this", "->", "_html", ")", ";", "$", "part", "->", "charset", "=", "$", "this", "->", "_object", "->", "getCharset", "(", ")", ";", "$", "part", "->", "encoding", "=", "Zend_Mime", "::", "ENCODING_QUOTEDPRINTABLE", ";", "$", "part", "->", "disposition", "=", "Zend_Mime", "::", "DISPOSITION_INLINE", ";", "$", "part", "->", "type", "=", "Zend_Mime", "::", "TYPE_HTML", ";", "$", "parts", "=", "array", "(", "$", "part", ")", ";", "}", "$", "msg", "=", "new", "Zend_Mime_Message", "(", ")", ";", "$", "msg", "->", "setParts", "(", "array_merge", "(", "$", "parts", ",", "$", "this", "->", "_embedded", ")", ")", ";", "// create html body (text and maybe embedded), modified afterwards to set it to multipart/related", "$", "this", "->", "_object", "->", "setBodyHtml", "(", "$", "msg", "->", "generateMessage", "(", ")", ")", ";", "$", "related", "=", "$", "this", "->", "_object", "->", "getBodyHtml", "(", ")", ";", "$", "related", "->", "type", "=", "Zend_Mime", "::", "MULTIPART_RELATED", ";", "$", "related", "->", "encoding", "=", "Zend_Mime", "::", "ENCODING_8BIT", ";", "$", "related", "->", "boundary", "=", "$", "msg", "->", "getMime", "(", ")", "->", "boundary", "(", ")", ";", "$", "related", "->", "disposition", "=", "null", ";", "$", "related", "->", "charset", "=", "null", ";", "}", "else", "if", "(", "$", "this", "->", "_html", "!=", "null", ")", "{", "$", "this", "->", "_object", "->", "setBodyHtml", "(", "$", "this", "->", "_html", ")", ";", "}", "return", "$", "this", "->", "_object", ";", "}" ]
Returns the internal Zend mail object. @return Zend_Mail Zend mail object
[ "Returns", "the", "internal", "Zend", "mail", "object", "." ]
1d2adc81ae0091a70f1053e0f095d55e656a3c96
https://github.com/Arcavias/ext-zend/blob/1d2adc81ae0091a70f1053e0f095d55e656a3c96/lib/custom/src/MW/Mail/Message/Zend.php#L226-L263
240,283
radnan/rdn-factory
src/RdnFactory/AbstractFactory.php
AbstractFactory.prefixModule
protected function prefixModule($name) { if (strpos($name, ':') === false) { $name = $this->getModuleName() .':'. $name; } return $name; }
php
protected function prefixModule($name) { if (strpos($name, ':') === false) { $name = $this->getModuleName() .':'. $name; } return $name; }
[ "protected", "function", "prefixModule", "(", "$", "name", ")", "{", "if", "(", "strpos", "(", "$", "name", ",", "':'", ")", "===", "false", ")", "{", "$", "name", "=", "$", "this", "->", "getModuleName", "(", ")", ".", "':'", ".", "$", "name", ";", "}", "return", "$", "name", ";", "}" ]
Prefix a service name with the current module name, if one is not already set. @param $name @return string
[ "Prefix", "a", "service", "name", "with", "the", "current", "module", "name", "if", "one", "is", "not", "already", "set", "." ]
7efb4b37ade8f2cb15c675f7b390b6338cdae91a
https://github.com/radnan/rdn-factory/blob/7efb4b37ade8f2cb15c675f7b390b6338cdae91a/src/RdnFactory/AbstractFactory.php#L93-L100
240,284
jamiehannaford/php-opencloud-zf2
src/Helper/CloudFiles/Container.php
Container.checkCache
protected function checkCache($name) { if (!isset($this->files[$name])) { $this->files[$name] = $this->getObject($name); } }
php
protected function checkCache($name) { if (!isset($this->files[$name])) { $this->files[$name] = $this->getObject($name); } }
[ "protected", "function", "checkCache", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "files", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "files", "[", "$", "name", "]", "=", "$", "this", "->", "getObject", "(", "$", "name", ")", ";", "}", "}" ]
Check to see whether a file exists in the local cache @param $name DataObject name
[ "Check", "to", "see", "whether", "a", "file", "exists", "in", "the", "local", "cache" ]
74140adaffc0b46d7bbe1d7b3441c61f2cf6a656
https://github.com/jamiehannaford/php-opencloud-zf2/blob/74140adaffc0b46d7bbe1d7b3441c61f2cf6a656/src/Helper/CloudFiles/Container.php#L58-L63
240,285
jamiehannaford/php-opencloud-zf2
src/Helper/CloudFiles/Container.php
Container.renderFile
public function renderFile($name, array $attrs = array(), $urlType = UrlType::CDN) { $this->checkCache($name); return $this->files[$name]->render($attrs, $urlType); }
php
public function renderFile($name, array $attrs = array(), $urlType = UrlType::CDN) { $this->checkCache($name); return $this->files[$name]->render($attrs, $urlType); }
[ "public", "function", "renderFile", "(", "$", "name", ",", "array", "$", "attrs", "=", "array", "(", ")", ",", "$", "urlType", "=", "UrlType", "::", "CDN", ")", "{", "$", "this", "->", "checkCache", "(", "$", "name", ")", ";", "return", "$", "this", "->", "files", "[", "$", "name", "]", "->", "render", "(", "$", "attrs", ",", "$", "urlType", ")", ";", "}" ]
Render a file into valid HTML markup @param $name File name @param string $urlType Connection type @return mixed
[ "Render", "a", "file", "into", "valid", "HTML", "markup" ]
74140adaffc0b46d7bbe1d7b3441c61f2cf6a656
https://github.com/jamiehannaford/php-opencloud-zf2/blob/74140adaffc0b46d7bbe1d7b3441c61f2cf6a656/src/Helper/CloudFiles/Container.php#L72-L77
240,286
jamiehannaford/php-opencloud-zf2
src/Helper/CloudFiles/Container.php
Container.renderFileUrl
public function renderFileUrl($name, $urlType = UrlType::CDN) { $this->checkCache($name); return $this->files[$name]->renderUrl($urlType); }
php
public function renderFileUrl($name, $urlType = UrlType::CDN) { $this->checkCache($name); return $this->files[$name]->renderUrl($urlType); }
[ "public", "function", "renderFileUrl", "(", "$", "name", ",", "$", "urlType", "=", "UrlType", "::", "CDN", ")", "{", "$", "this", "->", "checkCache", "(", "$", "name", ")", ";", "return", "$", "this", "->", "files", "[", "$", "name", "]", "->", "renderUrl", "(", "$", "urlType", ")", ";", "}" ]
Output a file's URI @param $name File name @param string $urlType Connection type @return string
[ "Output", "a", "file", "s", "URI" ]
74140adaffc0b46d7bbe1d7b3441c61f2cf6a656
https://github.com/jamiehannaford/php-opencloud-zf2/blob/74140adaffc0b46d7bbe1d7b3441c61f2cf6a656/src/Helper/CloudFiles/Container.php#L86-L91
240,287
jamiehannaford/php-opencloud-zf2
src/Helper/CloudFiles/Container.php
Container.renderAllFiles
public function renderAllFiles($limit = 100, $urlType = UrlType::CDN, $htmlPrefix = false, $htmlSuffix = false) { $config = (is_int($limit)) ? array(PaginatedIterator::LIMIT => $limit) : array(); $files = $this->container->objectList($config); $outputString = ''; $outputArray = array(); foreach ($files as $file) { $url = $this->getObject($file->getName())->renderUrl($urlType); if ($htmlPrefix && $htmlSuffix) { $outputString .= $htmlPrefix . $url . $htmlSuffix; } else { $outputArray[] = $url; } } return ($htmlPrefix && $htmlSuffix) ? $outputString : $outputArray; }
php
public function renderAllFiles($limit = 100, $urlType = UrlType::CDN, $htmlPrefix = false, $htmlSuffix = false) { $config = (is_int($limit)) ? array(PaginatedIterator::LIMIT => $limit) : array(); $files = $this->container->objectList($config); $outputString = ''; $outputArray = array(); foreach ($files as $file) { $url = $this->getObject($file->getName())->renderUrl($urlType); if ($htmlPrefix && $htmlSuffix) { $outputString .= $htmlPrefix . $url . $htmlSuffix; } else { $outputArray[] = $url; } } return ($htmlPrefix && $htmlSuffix) ? $outputString : $outputArray; }
[ "public", "function", "renderAllFiles", "(", "$", "limit", "=", "100", ",", "$", "urlType", "=", "UrlType", "::", "CDN", ",", "$", "htmlPrefix", "=", "false", ",", "$", "htmlSuffix", "=", "false", ")", "{", "$", "config", "=", "(", "is_int", "(", "$", "limit", ")", ")", "?", "array", "(", "PaginatedIterator", "::", "LIMIT", "=>", "$", "limit", ")", ":", "array", "(", ")", ";", "$", "files", "=", "$", "this", "->", "container", "->", "objectList", "(", "$", "config", ")", ";", "$", "outputString", "=", "''", ";", "$", "outputArray", "=", "array", "(", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "url", "=", "$", "this", "->", "getObject", "(", "$", "file", "->", "getName", "(", ")", ")", "->", "renderUrl", "(", "$", "urlType", ")", ";", "if", "(", "$", "htmlPrefix", "&&", "$", "htmlSuffix", ")", "{", "$", "outputString", ".=", "$", "htmlPrefix", ".", "$", "url", ".", "$", "htmlSuffix", ";", "}", "else", "{", "$", "outputArray", "[", "]", "=", "$", "url", ";", "}", "}", "return", "(", "$", "htmlPrefix", "&&", "$", "htmlSuffix", ")", "?", "$", "outputString", ":", "$", "outputArray", ";", "}" ]
Render all files in a container. If a prefix and suffix are provided, each object will be wrapped in the tags provided; otherwise they will be populated in a standard array for later use. @param int $limit The total amount of resources to return @param string $urlType The connection type @param bool $htmlPrefix HTML tag prefix @param bool $htmlSuffix HTML tag suffix @return array|string
[ "Render", "all", "files", "in", "a", "container", ".", "If", "a", "prefix", "and", "suffix", "are", "provided", "each", "object", "will", "be", "wrapped", "in", "the", "tags", "provided", ";", "otherwise", "they", "will", "be", "populated", "in", "a", "standard", "array", "for", "later", "use", "." ]
74140adaffc0b46d7bbe1d7b3441c61f2cf6a656
https://github.com/jamiehannaford/php-opencloud-zf2/blob/74140adaffc0b46d7bbe1d7b3441c61f2cf6a656/src/Helper/CloudFiles/Container.php#L114-L134
240,288
nicholasnet/common
src/Swiftmailer/Transport/AbstractTransport.php
AbstractTransport.beforeSendPerformed
protected function beforeSendPerformed(Swift_Mime_Message $message) { $event = new Swift_Events_SendEvent($this, $message); foreach ($this->plugins as $plugin) { if (method_exists($plugin, 'beforeSendPerformed')) { $plugin->beforeSendPerformed($event); } } }
php
protected function beforeSendPerformed(Swift_Mime_Message $message) { $event = new Swift_Events_SendEvent($this, $message); foreach ($this->plugins as $plugin) { if (method_exists($plugin, 'beforeSendPerformed')) { $plugin->beforeSendPerformed($event); } } }
[ "protected", "function", "beforeSendPerformed", "(", "Swift_Mime_Message", "$", "message", ")", "{", "$", "event", "=", "new", "Swift_Events_SendEvent", "(", "$", "this", ",", "$", "message", ")", ";", "foreach", "(", "$", "this", "->", "plugins", "as", "$", "plugin", ")", "{", "if", "(", "method_exists", "(", "$", "plugin", ",", "'beforeSendPerformed'", ")", ")", "{", "$", "plugin", "->", "beforeSendPerformed", "(", "$", "event", ")", ";", "}", "}", "}" ]
Iterate through registered plugins and execute plugins' methods. @param \Swift_Mime_Message $message
[ "Iterate", "through", "registered", "plugins", "and", "execute", "plugins", "methods", "." ]
8b948592ecf2a3a9060d05d04f12e30058dabf3f
https://github.com/nicholasnet/common/blob/8b948592ecf2a3a9060d05d04f12e30058dabf3f/src/Swiftmailer/Transport/AbstractTransport.php#L64-L76
240,289
rusranx/Utils
lib/RusranUtils/Generator.php
Generator.getSymbol
public static function getSymbol($type = self::SYMBOL_LOWER) { switch ($type) { case self::SYMBOL_LOWER: return chr(mt_rand(97, 122)); break; case self::SYMBOL_UPPER: return chr(mt_rand(65, 90)); break; case self::SYMBOL_DIGIT: return mt_rand(0, 9); break; default: return null; } }
php
public static function getSymbol($type = self::SYMBOL_LOWER) { switch ($type) { case self::SYMBOL_LOWER: return chr(mt_rand(97, 122)); break; case self::SYMBOL_UPPER: return chr(mt_rand(65, 90)); break; case self::SYMBOL_DIGIT: return mt_rand(0, 9); break; default: return null; } }
[ "public", "static", "function", "getSymbol", "(", "$", "type", "=", "self", "::", "SYMBOL_LOWER", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "self", "::", "SYMBOL_LOWER", ":", "return", "chr", "(", "mt_rand", "(", "97", ",", "122", ")", ")", ";", "break", ";", "case", "self", "::", "SYMBOL_UPPER", ":", "return", "chr", "(", "mt_rand", "(", "65", ",", "90", ")", ")", ";", "break", ";", "case", "self", "::", "SYMBOL_DIGIT", ":", "return", "mt_rand", "(", "0", ",", "9", ")", ";", "break", ";", "default", ":", "return", "null", ";", "}", "}" ]
Returns random character @param int $type @return int|string
[ "Returns", "random", "character" ]
296cc0c9a2e1717fadac8bc84ca88beac7be9282
https://github.com/rusranx/Utils/blob/296cc0c9a2e1717fadac8bc84ca88beac7be9282/lib/RusranUtils/Generator.php#L26-L41
240,290
rusranx/Utils
lib/RusranUtils/Generator.php
Generator.getPassword
public static function getPassword($length = 8) { $password = ""; for ($i = 0; $i < $length; $i++) { $password .= self::getSymbol(mt_rand(0, 2)); } return $password; }
php
public static function getPassword($length = 8) { $password = ""; for ($i = 0; $i < $length; $i++) { $password .= self::getSymbol(mt_rand(0, 2)); } return $password; }
[ "public", "static", "function", "getPassword", "(", "$", "length", "=", "8", ")", "{", "$", "password", "=", "\"\"", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "length", ";", "$", "i", "++", ")", "{", "$", "password", ".=", "self", "::", "getSymbol", "(", "mt_rand", "(", "0", ",", "2", ")", ")", ";", "}", "return", "$", "password", ";", "}" ]
Returns random string @param int $length @return string
[ "Returns", "random", "string" ]
296cc0c9a2e1717fadac8bc84ca88beac7be9282
https://github.com/rusranx/Utils/blob/296cc0c9a2e1717fadac8bc84ca88beac7be9282/lib/RusranUtils/Generator.php#L49-L58
240,291
MESD/JasperReportViewerBundle
Util/FormErrorConverter.php
FormErrorConverter.convertToArray
public static function convertToArray(\Symfony\Component\Form\Form $form) { //The array of errors messages $errors = array(); $errors['errors'] = array(); $errors['children'] = array(); //Get the errors for this level foreach($form->getErrors() as $error) { $errors['errors'][] = $error->getMessage(); } //Check the errors foreach of this level's children foreach($form->all() as $name => $child) { //If the child is an instance of \Symfony\Component\Form\Form if ($child instanceof \Symfony\Component\Form\Form) { //If the child has errors call the convertToArray $errors['children'][$name] = self::convertToArray($child); } } //Return the errors array return $errors; }
php
public static function convertToArray(\Symfony\Component\Form\Form $form) { //The array of errors messages $errors = array(); $errors['errors'] = array(); $errors['children'] = array(); //Get the errors for this level foreach($form->getErrors() as $error) { $errors['errors'][] = $error->getMessage(); } //Check the errors foreach of this level's children foreach($form->all() as $name => $child) { //If the child is an instance of \Symfony\Component\Form\Form if ($child instanceof \Symfony\Component\Form\Form) { //If the child has errors call the convertToArray $errors['children'][$name] = self::convertToArray($child); } } //Return the errors array return $errors; }
[ "public", "static", "function", "convertToArray", "(", "\\", "Symfony", "\\", "Component", "\\", "Form", "\\", "Form", "$", "form", ")", "{", "//The array of errors messages", "$", "errors", "=", "array", "(", ")", ";", "$", "errors", "[", "'errors'", "]", "=", "array", "(", ")", ";", "$", "errors", "[", "'children'", "]", "=", "array", "(", ")", ";", "//Get the errors for this level", "foreach", "(", "$", "form", "->", "getErrors", "(", ")", "as", "$", "error", ")", "{", "$", "errors", "[", "'errors'", "]", "[", "]", "=", "$", "error", "->", "getMessage", "(", ")", ";", "}", "//Check the errors foreach of this level's children", "foreach", "(", "$", "form", "->", "all", "(", ")", "as", "$", "name", "=>", "$", "child", ")", "{", "//If the child is an instance of \\Symfony\\Component\\Form\\Form", "if", "(", "$", "child", "instanceof", "\\", "Symfony", "\\", "Component", "\\", "Form", "\\", "Form", ")", "{", "//If the child has errors call the convertToArray", "$", "errors", "[", "'children'", "]", "[", "$", "name", "]", "=", "self", "::", "convertToArray", "(", "$", "child", ")", ";", "}", "}", "//Return the errors array", "return", "$", "errors", ";", "}" ]
Converts a form into an array of its error messages @param SymfonyComponentFormForm $form The invalid form @return array The array of error messages in the following format (array('errors' => array(1 => 'oops'), 'children' => array('beginDate' => array())))
[ "Converts", "a", "form", "into", "an", "array", "of", "its", "error", "messages" ]
d51ff079ba79b35c549a7ac472a305d416060d86
https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Util/FormErrorConverter.php#L25-L47
240,292
almrooth/comment
src/Comment/User.php
User.verifyPassword
public function verifyPassword($username, $password) { $this->find("username", $username); return password_verify($password, $this->password); }
php
public function verifyPassword($username, $password) { $this->find("username", $username); return password_verify($password, $this->password); }
[ "public", "function", "verifyPassword", "(", "$", "username", ",", "$", "password", ")", "{", "$", "this", "->", "find", "(", "\"username\"", ",", "$", "username", ")", ";", "return", "password_verify", "(", "$", "password", ",", "$", "this", "->", "password", ")", ";", "}" ]
Verify the username and the password, if successful the object contains all details from the database row. @param string $username username to check. @param string $password the password to use. @return boolean true if username and password matches, else false.
[ "Verify", "the", "username", "and", "the", "password", "if", "successful", "the", "object", "contains", "all", "details", "from", "the", "database", "row", "." ]
792caaa7aa77f3cb002742a9def1fc72007801e9
https://github.com/almrooth/comment/blob/792caaa7aa77f3cb002742a9def1fc72007801e9/src/Comment/User.php#L55-L59
240,293
ongr-archive/ContentBundle
Twig/ContentExtension.php
ContentExtension.getContentsBySlugsFunction
public function getContentsBySlugsFunction($slugs, $keepOrder = false) { $search = $this->repository->createSearch(); $search->addQuery(new TermsQuery('slug', $slugs), 'should'); $result = $this->repository->execute($search); if ($keepOrder) { $orderedResult = []; foreach ($slugs as $slug) { foreach ($result as $document) { if ($document->slug == $slug) { $orderedResult[] = $document; } } } $result = $orderedResult; } return $result; }
php
public function getContentsBySlugsFunction($slugs, $keepOrder = false) { $search = $this->repository->createSearch(); $search->addQuery(new TermsQuery('slug', $slugs), 'should'); $result = $this->repository->execute($search); if ($keepOrder) { $orderedResult = []; foreach ($slugs as $slug) { foreach ($result as $document) { if ($document->slug == $slug) { $orderedResult[] = $document; } } } $result = $orderedResult; } return $result; }
[ "public", "function", "getContentsBySlugsFunction", "(", "$", "slugs", ",", "$", "keepOrder", "=", "false", ")", "{", "$", "search", "=", "$", "this", "->", "repository", "->", "createSearch", "(", ")", ";", "$", "search", "->", "addQuery", "(", "new", "TermsQuery", "(", "'slug'", ",", "$", "slugs", ")", ",", "'should'", ")", ";", "$", "result", "=", "$", "this", "->", "repository", "->", "execute", "(", "$", "search", ")", ";", "if", "(", "$", "keepOrder", ")", "{", "$", "orderedResult", "=", "[", "]", ";", "foreach", "(", "$", "slugs", "as", "$", "slug", ")", "{", "foreach", "(", "$", "result", "as", "$", "document", ")", "{", "if", "(", "$", "document", "->", "slug", "==", "$", "slug", ")", "{", "$", "orderedResult", "[", "]", "=", "$", "document", ";", "}", "}", "}", "$", "result", "=", "$", "orderedResult", ";", "}", "return", "$", "result", ";", "}" ]
Return an array with content documents filtered by slugs array. @param array $slugs @param bool $keepOrder @return mixed
[ "Return", "an", "array", "with", "content", "documents", "filtered", "by", "slugs", "array", "." ]
453a02c0c89c16f66dc9caed000243534dbeffa5
https://github.com/ongr-archive/ContentBundle/blob/453a02c0c89c16f66dc9caed000243534dbeffa5/Twig/ContentExtension.php#L104-L125
240,294
ongr-archive/ContentBundle
Twig/ContentExtension.php
ContentExtension.snippetFunction
public function snippetFunction( $slug, $template = null ) { $result = null; if ($this->handler && $this->router) { $route = $this->router->generate( '_ongr_plain_cms_snippet', [ 'slug' => $slug, 'template' => $template, ] ); try { $result = $this->handler->render($route, $this->renderStrategy); } catch (\InvalidArgumentException $ex) { // ESI is disabled. $result = $this->handler->render($route); } } return $result; }
php
public function snippetFunction( $slug, $template = null ) { $result = null; if ($this->handler && $this->router) { $route = $this->router->generate( '_ongr_plain_cms_snippet', [ 'slug' => $slug, 'template' => $template, ] ); try { $result = $this->handler->render($route, $this->renderStrategy); } catch (\InvalidArgumentException $ex) { // ESI is disabled. $result = $this->handler->render($route); } } return $result; }
[ "public", "function", "snippetFunction", "(", "$", "slug", ",", "$", "template", "=", "null", ")", "{", "$", "result", "=", "null", ";", "if", "(", "$", "this", "->", "handler", "&&", "$", "this", "->", "router", ")", "{", "$", "route", "=", "$", "this", "->", "router", "->", "generate", "(", "'_ongr_plain_cms_snippet'", ",", "[", "'slug'", "=>", "$", "slug", ",", "'template'", "=>", "$", "template", ",", "]", ")", ";", "try", "{", "$", "result", "=", "$", "this", "->", "handler", "->", "render", "(", "$", "route", ",", "$", "this", "->", "renderStrategy", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "ex", ")", "{", "// ESI is disabled.", "$", "result", "=", "$", "this", "->", "handler", "->", "render", "(", "$", "route", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Renders content by given slug. @param string $slug @param bool|string $template @return string
[ "Renders", "content", "by", "given", "slug", "." ]
453a02c0c89c16f66dc9caed000243534dbeffa5
https://github.com/ongr-archive/ContentBundle/blob/453a02c0c89c16f66dc9caed000243534dbeffa5/Twig/ContentExtension.php#L135-L157
240,295
dazarobbo/Cola
src/Json.php
Json.serialise
public static function serialise( $o, $options = 0, $depth = self::DEFAULT_OUTPUT_DEPTH){ $s = \json_encode($o, $options, $depth); static::$_LastError = \json_last_error(); return $s; }
php
public static function serialise( $o, $options = 0, $depth = self::DEFAULT_OUTPUT_DEPTH){ $s = \json_encode($o, $options, $depth); static::$_LastError = \json_last_error(); return $s; }
[ "public", "static", "function", "serialise", "(", "$", "o", ",", "$", "options", "=", "0", ",", "$", "depth", "=", "self", "::", "DEFAULT_OUTPUT_DEPTH", ")", "{", "$", "s", "=", "\\", "json_encode", "(", "$", "o", ",", "$", "options", ",", "$", "depth", ")", ";", "static", "::", "$", "_LastError", "=", "\\", "json_last_error", "(", ")", ";", "return", "$", "s", ";", "}" ]
Serialises an object to a JSON formatted string @param mixed $o @return string
[ "Serialises", "an", "object", "to", "a", "JSON", "formatted", "string" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/Json.php#L63-L72
240,296
erikkubica/netlime-theme-supports
ThemeSupports.php
ThemeSupports.registerSupports
protected function registerSupports() { do_action("before_theme_add_supports"); foreach ($this->getConfig("supports") as $feature => $enabled): if (!$enabled): continue; endif; add_theme_support($feature); endforeach; do_action("after_theme_add_supports"); }
php
protected function registerSupports() { do_action("before_theme_add_supports"); foreach ($this->getConfig("supports") as $feature => $enabled): if (!$enabled): continue; endif; add_theme_support($feature); endforeach; do_action("after_theme_add_supports"); }
[ "protected", "function", "registerSupports", "(", ")", "{", "do_action", "(", "\"before_theme_add_supports\"", ")", ";", "foreach", "(", "$", "this", "->", "getConfig", "(", "\"supports\"", ")", "as", "$", "feature", "=>", "$", "enabled", ")", ":", "if", "(", "!", "$", "enabled", ")", ":", "continue", ";", "endif", ";", "add_theme_support", "(", "$", "feature", ")", ";", "endforeach", ";", "do_action", "(", "\"after_theme_add_supports\"", ")", ";", "}" ]
Add theme features
[ "Add", "theme", "features" ]
205f0a592a33b91e94847fb2088e44063e69eaea
https://github.com/erikkubica/netlime-theme-supports/blob/205f0a592a33b91e94847fb2088e44063e69eaea/ThemeSupports.php#L18-L30
240,297
maestrano/maestrano-php
lib/Saml/Request.php
Maestrano_Saml_Request.getRedirectUrl
public function getRedirectUrl() { // Build the request $id = $this->_generateUniqueID(); $issueInstant = $this->_getTimestamp(); $request = <<<AUTHNREQUEST <samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="$id" Version="2.0" IssueInstant="$issueInstant" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" AssertionConsumerServiceURL="{$this->_settings->spReturnUrl}"> <saml:Issuer>{$this->_settings->spIssuer}</saml:Issuer> <samlp:NameIDPolicy Format="{$this->_settings->requestedNameIdFormat}" AllowCreate="true"></samlp:NameIDPolicy> <samlp:RequestedAuthnContext Comparison="exact"> <saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef> </samlp:RequestedAuthnContext> </samlp:AuthnRequest> AUTHNREQUEST; // Encode the request $deflatedRequest = gzdeflate($request); $base64Request = base64_encode($deflatedRequest); $encodedRequest = urlencode($base64Request); // Build redirect URL $url = $this->_settings->idpSingleSignOnUrl . "?SAMLRequest=" . $encodedRequest; // Keep the original GET parameters foreach ($this->_get_params as $param => $value) { $url .= "&" . $param . "=" . urlencode($value); } return $url; }
php
public function getRedirectUrl() { // Build the request $id = $this->_generateUniqueID(); $issueInstant = $this->_getTimestamp(); $request = <<<AUTHNREQUEST <samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="$id" Version="2.0" IssueInstant="$issueInstant" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" AssertionConsumerServiceURL="{$this->_settings->spReturnUrl}"> <saml:Issuer>{$this->_settings->spIssuer}</saml:Issuer> <samlp:NameIDPolicy Format="{$this->_settings->requestedNameIdFormat}" AllowCreate="true"></samlp:NameIDPolicy> <samlp:RequestedAuthnContext Comparison="exact"> <saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef> </samlp:RequestedAuthnContext> </samlp:AuthnRequest> AUTHNREQUEST; // Encode the request $deflatedRequest = gzdeflate($request); $base64Request = base64_encode($deflatedRequest); $encodedRequest = urlencode($base64Request); // Build redirect URL $url = $this->_settings->idpSingleSignOnUrl . "?SAMLRequest=" . $encodedRequest; // Keep the original GET parameters foreach ($this->_get_params as $param => $value) { $url .= "&" . $param . "=" . urlencode($value); } return $url; }
[ "public", "function", "getRedirectUrl", "(", ")", "{", "// Build the request", "$", "id", "=", "$", "this", "->", "_generateUniqueID", "(", ")", ";", "$", "issueInstant", "=", "$", "this", "->", "_getTimestamp", "(", ")", ";", "$", "request", "=", " <<<AUTHNREQUEST\n<samlp:AuthnRequest\n xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"\n xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\"\n ID=\"$id\"\n Version=\"2.0\"\n IssueInstant=\"$issueInstant\"\n ProtocolBinding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST\"\n AssertionConsumerServiceURL=\"{$this->_settings->spReturnUrl}\">\n <saml:Issuer>{$this->_settings->spIssuer}</saml:Issuer>\n <samlp:NameIDPolicy\n Format=\"{$this->_settings->requestedNameIdFormat}\"\n AllowCreate=\"true\"></samlp:NameIDPolicy>\n <samlp:RequestedAuthnContext Comparison=\"exact\">\n <saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef>\n </samlp:RequestedAuthnContext>\n</samlp:AuthnRequest>\nAUTHNREQUEST", ";", "// Encode the request", "$", "deflatedRequest", "=", "gzdeflate", "(", "$", "request", ")", ";", "$", "base64Request", "=", "base64_encode", "(", "$", "deflatedRequest", ")", ";", "$", "encodedRequest", "=", "urlencode", "(", "$", "base64Request", ")", ";", "// Build redirect URL", "$", "url", "=", "$", "this", "->", "_settings", "->", "idpSingleSignOnUrl", ".", "\"?SAMLRequest=\"", ".", "$", "encodedRequest", ";", "// Keep the original GET parameters", "foreach", "(", "$", "this", "->", "_get_params", "as", "$", "param", "=>", "$", "value", ")", "{", "$", "url", ".=", "\"&\"", ".", "$", "param", ".", "\"=\"", ".", "urlencode", "(", "$", "value", ")", ";", "}", "return", "$", "url", ";", "}" ]
Generate the request. @return string A fully qualified URL that can be redirected to in order to process the authorization request.
[ "Generate", "the", "request", "." ]
757cbefb0f0bf07cb35ea7442041d9bfdcce1558
https://github.com/maestrano/maestrano-php/blob/757cbefb0f0bf07cb35ea7442041d9bfdcce1558/lib/Saml/Request.php#L52-L91
240,298
maestrano/maestrano-php
lib/Saml/Request.php
Maestrano_Saml_Request.setConsumerHost
public function setConsumerHost($host) { $host = rtrim($host, '/'); $this->_settings->spReturnUrl = $host . Maestrano::with($this->_preset)->param('sso.consume_path'); }
php
public function setConsumerHost($host) { $host = rtrim($host, '/'); $this->_settings->spReturnUrl = $host . Maestrano::with($this->_preset)->param('sso.consume_path'); }
[ "public", "function", "setConsumerHost", "(", "$", "host", ")", "{", "$", "host", "=", "rtrim", "(", "$", "host", ",", "'/'", ")", ";", "$", "this", "->", "_settings", "->", "spReturnUrl", "=", "$", "host", ".", "Maestrano", "::", "with", "(", "$", "this", "->", "_preset", ")", "->", "param", "(", "'sso.consume_path'", ")", ";", "}" ]
Override the default host to contact for the consume. The default consume path is appended to this host. @param $host string Host to contact
[ "Override", "the", "default", "host", "to", "contact", "for", "the", "consume", ".", "The", "default", "consume", "path", "is", "appended", "to", "this", "host", "." ]
757cbefb0f0bf07cb35ea7442041d9bfdcce1558
https://github.com/maestrano/maestrano-php/blob/757cbefb0f0bf07cb35ea7442041d9bfdcce1558/lib/Saml/Request.php#L98-L102
240,299
MINISTRYGmbH/morrow-core
src/Config.php
Config.load
public function load($directory, $subkey = null) { $config = []; // load main config $file = $directory.'_default.php'; if (!is_file($file)) return array(); $config = array_merge($config, include($file)); $file = $directory.'_default_app.php'; if (is_file($file)) $config = array_merge($config, include($file)); // overwrite with server specific config if (php_sapi_name() === 'cli') { $file1 = $directory.gethostname().'.php'; if (is_file($file1)) $config = array_merge($config, include($file1)); } else { $file1 = $directory.$_SERVER['HTTP_HOST'].'.php'; $file2 = $directory.(isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR']).'.php'; // On Windows IIS 7 you must use $_SERVER['LOCAL_ADDR'] rather than $_SERVER['SERVER_ADDR'] to get the server's IP address. if (is_file($file1)) $config = array_merge($config, include($file1)); elseif (is_file($file2)) $config = array_merge($config, include($file2)); } foreach ($config as $key => $value) { if ($subkey === null) { $this->arraySet($this->data, $key, $value); } else { $this->arraySet($this->data, $subkey . '.' . $key, $value); } } return $this->data; }
php
public function load($directory, $subkey = null) { $config = []; // load main config $file = $directory.'_default.php'; if (!is_file($file)) return array(); $config = array_merge($config, include($file)); $file = $directory.'_default_app.php'; if (is_file($file)) $config = array_merge($config, include($file)); // overwrite with server specific config if (php_sapi_name() === 'cli') { $file1 = $directory.gethostname().'.php'; if (is_file($file1)) $config = array_merge($config, include($file1)); } else { $file1 = $directory.$_SERVER['HTTP_HOST'].'.php'; $file2 = $directory.(isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR']).'.php'; // On Windows IIS 7 you must use $_SERVER['LOCAL_ADDR'] rather than $_SERVER['SERVER_ADDR'] to get the server's IP address. if (is_file($file1)) $config = array_merge($config, include($file1)); elseif (is_file($file2)) $config = array_merge($config, include($file2)); } foreach ($config as $key => $value) { if ($subkey === null) { $this->arraySet($this->data, $key, $value); } else { $this->arraySet($this->data, $subkey . '.' . $key, $value); } } return $this->data; }
[ "public", "function", "load", "(", "$", "directory", ",", "$", "subkey", "=", "null", ")", "{", "$", "config", "=", "[", "]", ";", "// load main config", "$", "file", "=", "$", "directory", ".", "'_default.php'", ";", "if", "(", "!", "is_file", "(", "$", "file", ")", ")", "return", "array", "(", ")", ";", "$", "config", "=", "array_merge", "(", "$", "config", ",", "include", "(", "$", "file", ")", ")", ";", "$", "file", "=", "$", "directory", ".", "'_default_app.php'", ";", "if", "(", "is_file", "(", "$", "file", ")", ")", "$", "config", "=", "array_merge", "(", "$", "config", ",", "include", "(", "$", "file", ")", ")", ";", "// overwrite with server specific config", "if", "(", "php_sapi_name", "(", ")", "===", "'cli'", ")", "{", "$", "file1", "=", "$", "directory", ".", "gethostname", "(", ")", ".", "'.php'", ";", "if", "(", "is_file", "(", "$", "file1", ")", ")", "$", "config", "=", "array_merge", "(", "$", "config", ",", "include", "(", "$", "file1", ")", ")", ";", "}", "else", "{", "$", "file1", "=", "$", "directory", ".", "$", "_SERVER", "[", "'HTTP_HOST'", "]", ".", "'.php'", ";", "$", "file2", "=", "$", "directory", ".", "(", "isset", "(", "$", "_SERVER", "[", "'SERVER_ADDR'", "]", ")", "?", "$", "_SERVER", "[", "'SERVER_ADDR'", "]", ":", "$", "_SERVER", "[", "'LOCAL_ADDR'", "]", ")", ".", "'.php'", ";", "// On Windows IIS 7 you must use $_SERVER['LOCAL_ADDR'] rather than $_SERVER['SERVER_ADDR'] to get the server's IP address.", "if", "(", "is_file", "(", "$", "file1", ")", ")", "$", "config", "=", "array_merge", "(", "$", "config", ",", "include", "(", "$", "file1", ")", ")", ";", "elseif", "(", "is_file", "(", "$", "file2", ")", ")", "$", "config", "=", "array_merge", "(", "$", "config", ",", "include", "(", "$", "file2", ")", ")", ";", "}", "foreach", "(", "$", "config", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "subkey", "===", "null", ")", "{", "$", "this", "->", "arraySet", "(", "$", "this", "->", "data", ",", "$", "key", ",", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "arraySet", "(", "$", "this", "->", "data", ",", "$", "subkey", ".", "'.'", ".", "$", "key", ",", "$", "value", ")", ";", "}", "}", "return", "$", "this", "->", "data", ";", "}" ]
Loads config files in an array. First it searches for a file _default.php then it tries to load the config for the current HOST and then for the Server IP address. @param string $directory The directory path where the config files are. @param string $subkey Set this subkey if you want all config parameters be created below this subkey. @return array An array with the config.
[ "Loads", "config", "files", "in", "an", "array", ".", "First", "it", "searches", "for", "a", "file", "_default", ".", "php", "then", "it", "tries", "to", "load", "the", "config", "for", "the", "current", "HOST", "and", "then", "for", "the", "Server", "IP", "address", "." ]
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Config.php#L98-L129