_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q11600 | GroupVersionHydrator.hydrateEntity | train | private function hydrateEntity(EntityInterface $entity, $group, $version)
{
$entity->setEntityGroup($group);
$entity->setAPIVersion($version);
// hydrate all the sub-fields recursively using JMS to extract them and identify their type
$metadata = $this->metadataFactory->getMetadataForClass(\get_class($entity));
/** @var PropertyMetadata $property */
foreach ($metadata->propertyMetadata as $property) {
if ('array' === $property->type['name']) {
$array = $property->getValue($entity);
if (\is_array($array) && \count($array) > 0) {
| php | {
"resource": ""
} |
q11601 | APIRequests.request | train | public static function request(
$arg_endpoint,
$arg_method,
array $arg_data = array(),
array $arg_headers = array()
) {
$return = array();
$headers = array(
'Accept: application/json',
'DUE-API-KEY: '.Due::getApiKey(),
'DUE-PLATFORM-ID: '.Due::getPlatformId(),
);
if($arg_method == APIRequests::METHOD_PUT){
$headers[]= 'Content-Type: application/x-www-form-urlencoded; charset=utf-8';
}
$headers = array_merge($headers, $arg_headers);
$full_url = Due::getRootPath().$arg_endpoint;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $full_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $arg_method);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
if(!empty($arg_data)){
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arg_data));
}
$response = curl_exec($ch);
$err = curl_error($ch);
if (!$err) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($response, 0, $header_size);
$body | php | {
"resource": ""
} |
q11602 | APIRequests.headersToArray | train | public static function headersToArray($header_text)
{
$headers = array();
foreach (explode("\r\n", $header_text) as $i => $line)
if ($i === 0)
$headers['http_code'] = $line;
else
{
if(!empty($line) && strpos($line, ':') !== false){
list ($key, $value) = explode(': ', $line);
| php | {
"resource": ""
} |
q11603 | Application.loadFactory | train | protected function loadFactory(?array $params=[])
{
if (\is_array($params) && !empty($params['class']) && \class_exists($params['class'])) {
$factory = new $params['class']($params['options'] ?? []); | php | {
"resource": ""
} |
q11604 | Application.setCookie | train | public function setCookie(string $name, string $value=null, int $expire=0, string $path='', string $domain='', bool $secure=false, bool $httpOnly=false)
{
if ( \array_key_exists($name,$this->cookies) && \is_null($value) ) {
# Remove the Cookie
$this->cookies = \array_diff_key($this->cookies,[$name=>'']);
} else {
# Set the Cookie
$this->cookies[$name] = [
| php | {
"resource": ""
} |
q11605 | Application.sendResponse | train | public function sendResponse()
{
# Set HTTP Response Code
\http_response_code($this->getResponse()->getStatusCode());
# Set All HTTP headers from Response Object
foreach ($this->getResponse()->getHeaders() as $header => $value) {
if (\is_array($value)) {
$values = \implode(';',$value);
} else {
$values = $value;
}
\header($header.': '.$values);
}
# Remove the "x-powered-by" header set by PHP
if (\function_exists('header_remove')) \header_remove('x-powered-by');
# Set Cookies
foreach ($this->cookies as $cookie)
{
\setCookie( $cookie['name'],
$cookie['value'],
$cookie['expire'] ?? 0,
$cookie['path'] ?? '',
$cookie['domain'] ?? '',
$cookie['secure'] ?? false,
$cookie['httponly'] ?? false
);
}
##
## Send a file or a body?
##
if ( !empty($this->responseFile) ) {
if (\file_exists($this->responseFile)) {
# Debug log
$this->getLogger()->debug('Sending file',[
'code'=>$this->getResponse()->getStatusCode(),
| php | {
"resource": ""
} |
q11606 | TaxModifier.updateTotal | train | public function updateTotal(&$total) {
$rate = (float)self::config()->get('tax_rate') / 100;
$tax = $total * $rate;
$this->setPriceModification($tax);
| php | {
"resource": ""
} |
q11607 | TaxModifier.getTableTitle | train | public function getTableTitle()
{
$rate = _t(
'TaxModifier.TABLE_TITLE',
'{rate}% BTW',
null,
array(
'rate' => (float)self::config()->get('tax_rate')
)
);
| php | {
"resource": ""
} |
q11608 | TaxModifier.findOrMake | train | public static function findOrMake(Reservation $reservation)
{
if (!$modifier = $reservation->PriceModifiers()->find('ClassName', self::class)) | php | {
"resource": ""
} |
q11609 | MapTableMap.doDelete | train | public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(MapTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \eXpansion\Bundle\Maps\Model\Map) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(MapTableMap::DATABASE_NAME);
$criteria->add(MapTableMap::COL_ID, (array) $values, Criteria::IN);
| php | {
"resource": ""
} |
q11610 | FileSystem.getUserData | train | public function getUserData() : FilesystemInterface
{
if ($this->connectionType == self::CONNECTION_TYPE_LOCAL) { | php | {
"resource": ""
} |
q11611 | FileSystem.getLocalAdapter | train | protected function getLocalAdapter() : FilesystemInterface
{
if (is_null($this->localAdapter)) {
$dir = $this->factory->getConnection()->getMapsDirectory();
| php | {
"resource": ""
} |
q11612 | PluginManager.isPluginCompatible | train | protected function isPluginCompatible(PluginDescription $plugin, $enabledPlugins, $title, $mode, $script, Map $map)
{
// first check for other plugins.
foreach ($plugin->getParents() as $parentPluginId) {
if (!isset($enabledPlugins[$parentPluginId])) {
// A parent plugin is missing. Can't enable plugin.
return false;
}
}
// Now check for data providers.
foreach ($plugin->getDataProviders() as $dataProvider) {
$dataProviders = explode("|", $dataProvider);
$foundOne = false;
foreach ($dataProviders as $provider) {
$providerId = $this->dataProviderManager->getCompatibleProviderId($provider, $title, $mode, $script, $map);
if (!is_null($providerId) && isset($enabledPlugins[$providerId])) {
// Either there are no data providers compatible or the only one compatible
$foundOne = true;
break;
}
}
if | php | {
"resource": ""
} |
q11613 | PluginManager.enablePlugin | train | protected function enablePlugin(PluginDescription $plugin, $title, $mode, $script, Map $map)
{
$notify = false;
$plugin->setIsEnabled(true);
$pluginService = $this->container->get($plugin->getPluginId());
if (!isset($this->enabledPlugins[$plugin->getPluginId()])) {
$notify = true;
}
foreach ($plugin->getDataProviders() as $provider) {
$dataProviders = explode("|", $provider);
foreach ($dataProviders as $dataProvider) {
| php | {
"resource": ""
} |
q11614 | InstallHelperService.getDomain | train | public function getDomain()
{
$uri = $this->getServiceLocator()->get('Application')->getMvcEvent()->getRequest()->getUri(); | php | {
"resource": ""
} |
q11615 | InstallHelperService.checkMysqlConnection | train | public function checkMysqlConnection($host, $db, $user, $pass)
{
$results = array();
$isConnected = 0;
$isDatabaseExists = 0;
$isDatabaseCollationNameValid = 0;
$isPassCorrect = 1;
if($this->isDomainExists($host)) {
$isConnected = 1;
try {
$dbAdapter = new DbAdapter(array(
'driver' => 'Pdo',
'dsn' => 'mysql:dbname=INFORMATION_SCHEMA;host='.$host,
'username' => $user,
'password' => $pass,
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
),
));
$sql = new Sql($dbAdapter);
$select = $sql->select();
$select->from('SCHEMATA');
$select->where(array('SCHEMA_NAME' => $db));
$statement = $sql->prepareStatementForSqlObject($select);
| php | {
"resource": ""
} |
q11616 | InstallHelperService.setDbAdapter | train | public function setDbAdapter($config)
{
if(is_array($config)) {
$this->odbAdapter = new DbAdapter(array_merge(array(
'driver' => 'Pdo_Mysql',
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
)
), $config));
$config = | php | {
"resource": ""
} |
q11617 | InstallHelperService.executeRawQuery | train | public function executeRawQuery($query)
{
$resultSet = null;
if($this->odbAdapter) {
if(!empty($query)) {
$resultSet | php | {
"resource": ""
} |
q11618 | InstallHelperService.isDbTableExists | train | public function isDbTableExists($tableName)
{
$status = false;
$resultSet = array();
$query = $this->executeRawQuery("SHOW TABLES LIKE '".trim($tableName)."';");
if($resultSet)
| php | {
"resource": ""
} |
q11619 | InstallHelperService.importSql | train | public function importSql($path, $files = array('setup_structure.sql'))
{
$status = false;
$fImport = null;
if(file_exists($path)) {
foreach($files as $file) {
if(file_exists($path.$file)) {
| php | {
"resource": ""
} |
q11620 | InstallHelperService.getSqlFileTables | train | public function getSqlFileTables($path)
{
$tables = array();
if(file_exists($path)) {
$file = fopen($path, 'r');
$textToFind = 'CREATE TABLE IF NOT EXISTS ';
$found = array();
$tables = array();
while(!feof($file)) {
$output = fgets($file);
$pos = strrpos($output, $textToFind);
| php | {
"resource": ""
} |
q11621 | InstallHelperService.checkEnvironmentVariables | train | public function checkEnvironmentVariables()
{
$settingsValues = array();
$iniSettings = array(
'memory_limit', 'max_execution_time', 'upload_max_filesize'
);
| php | {
"resource": ""
} |
q11622 | InstallHelperService.filePermission | train | public function filePermission($path, $mode = self::CHMOD_775)
{
$results = array();
$success = 0;
if(file_exists($path)) {
if(!is_writable($path))
chmod($path, $mode);
if(!is_readable($path))
chmod($path, $mode);
if(is_readable($path) && is_writable($path))
$status = 1;
}
| php | {
"resource": ""
} |
q11623 | InstallHelperService.replaceFile | train | public function replaceFile($old, $new, array $content)
{
$oldFileContent = file_get_contents($old);
| php | {
"resource": ""
} |
q11624 | MimeTypeFileExtensionGuesser.guess | train | public static function guess(string $guess): ?string
{
if (! \is_file($guess)) {
throw new FileNotFoundException($guess);
}
if (! \is_readable($guess)) {
throw new | php | {
"resource": ""
} |
q11625 | ConfigManager.registerConfig | train | public function registerConfig(ConfigInterface $config, $id)
{
$this->configurationDefinitions[spl_object_hash($config)] = $config;
$this->configurationIds[spl_object_hash($config)] = $id;
| php | {
"resource": ""
} |
q11626 | ModelSearch.run | train | public function run(&$query, $model, $request)
{
$this->query = $query;
| php | {
"resource": ""
} |
q11627 | ModelSearch.query | train | private function query()
{
foreach ($this->search_models as $model_name => $filters) {
// Apply search against the original model.
if ($model_name === 'self') {
self::applySearch($this->query, $filters);
| php | {
"resource": ""
} |
q11628 | ModelSearch.getAttributes | train | public function getAttributes($model)
{
$this->model = $model;
$this->attributes = self::buildRelationshipAttributes($this->model);
$this->attributes | php | {
"resource": ""
} |
q11629 | ModelSearch.buildRelationshipAttributes | train | private function buildRelationshipAttributes($model)
{
$result = [];
foreach ($model->getSearchRelationships() as $method) {
if (!method_exists($model, $method)) {
continue;
}
$relation = self::getRelation($model->$method());
| php | {
"resource": ""
} |
q11630 | ModelSearch.buildAttributes | train | public static function buildAttributes($model)
{
$result = [];
self::buildCastedAttributes($model, $result);
| php | {
"resource": ""
} |
q11631 | ModelSearch.buildCastedAttributes | train | private static function buildCastedAttributes($model, &$result, $method = null)
{
$model_name = 'self';
$name_append = '';
if (!is_null($method)) {
$model_name = $method;
$name_append = $method.'.';
}
// ModelSchema implementation gives us better data.
if (class_exists('HnhDigital\ModelSchema\Model')
&& $model instanceof \HnhDigital\ModelSchema\Model) {
// Build attributes off the schema.
foreach ($model->getSchema() as $name => $config) {
$result[$name_append.$name] = [
'name' => $name,
'title' => Arr::get($config, 'title', $name),
'attributes' => [sprintf('%s.%s', $model->getTable(), $name)],
'filter' => self::convertCast(Arr::get($config, 'cast')),
'model' => &$model,
'model_name' => $model_name,
| php | {
"resource": ""
} |
q11632 | ModelSearch.validateAttributes | train | private static function validateAttributes($model, $name, &$attributes)
{
// Should be an array.
if (!is_array($attributes)) {
$attributes = [$attributes];
}
// Is empty, use the name of the table + name.
if (empty($attributes)) {
| php | {
"resource": ""
} |
q11633 | ModelSearch.parseRequest | train | private function parseRequest($request)
{
if (empty($request)) {
return;
}
$this->request = $request;
// Models used in this request.
$models_used = [];
// Review each request.
foreach ($this->request as $name => $filters) {
// This name is not present in available attributes.
if (!Arr::has($this->attributes, $name)) {
continue;
}
// Get the settings for the given attribute.
$settings = Arr::get($this->attributes, $name);
// Settings is empty.
if (empty($settings)) {
continue;
}
// Check and validate each of the filters.
$filters = self::validateFilters($filters, $settings);
// Search against current model.
if (($model_name = Arr::get($settings, 'model_name')) === 'self') {
| php | {
"resource": ""
} |
q11634 | ModelSearch.validateFilters | train | private static function validateFilters($filters, $settings)
{
if (!is_array($filters)) {
$filters = [$filters];
}
// Each fitler.
foreach ($filters as $index => &$filter) {
// Check this item.
$filter = | php | {
"resource": ""
} |
q11635 | ModelSearch.validateFilterItem | train | private static function validateFilterItem($filter, $settings)
{
// Convert string to filter array.
if (!is_array($filter)) {
$filter = ['', $filter];
}
// Convert string to filter array.
if (Arr::get($settings, 'filter') !== 'boolean' && count($filter) == 1) {
array_unshift($filter, '');
}
// Split the filter array into operator, value1, value2
$operator = Arr::get($filter, 0, '');
$value_one = Arr::get($filter, 1, false);
$value_two = Arr::get($filter, 2, false);
// The wild-all setting was enabled.
// Update value with all characters wildcarded.
if (Arr::has($settings, 'enable.wild-all')) {
self::applyWildAll($operator, $value_one);
}
self::checkInlineOperator($operator, $value_one, $settings);
self::checkNullOperator($operator, $value_one);
self::checkEmptyOperator($operator, $value_one);
// Defaullt operator.
if (empty($operator)) {
$operator = self::getDefaultOperator(Arr::get($settings, 'filter'), $operator);
}
// Return filter as an associative array.
$filter = [
'operator' => $operator,
'method' => 'where',
| php | {
"resource": ""
} |
q11636 | ModelSearch.applyWildAll | train | private static function applyWildAll(&$operator, &$value)
{
$positive = !(stripos($operator, '!') !== false || stripos($operator, 'NOT') !== false);
$operator = $positive ? '*=*' : '*!=*'; | php | {
"resource": ""
} |
q11637 | ModelSearch.parseInlineOperator | train | public static function parseInlineOperator($text)
{
$operator_name = 'contains';
$operator = Arr::get($text, 0, '');
$value = Arr::get($text, 1, false);
self::checkInlineOperator($operator, $value);
if (!empty($operator)) {
| php | {
"resource": ""
} |
q11638 | ModelSearch.checkInlineOperator | train | private static function checkInlineOperator(&$operator, &$value, $settings = [])
{
if (is_array($value)) {
return;
}
// Boolean does not provide inline operations.
if (Arr::get($settings, 'filter') === 'boolean') {
return;
}
$value_array = explode(' ', trim($value), 2);
if (count($value_array) == 1) {
return;
}
| php | {
"resource": ""
} |
q11639 | ModelSearch.filterByUuid | train | public static function filterByUuid($filter)
{
$operator = Arr::get($filter, 'operator');
$method = Arr::get($filter, 'method');
$arguments = Arr::get($filter, 'arguments');
$value_one = Arr::get($filter, 'value_one');
$value_two = Arr::get($filter, 'value_two');
$settings = Arr::get($filter, 'settings');
$positive = Arr::get($filter, 'positive');
switch ($operator) {
case 'IN':
$method = 'whereIn';
$arguments = [static::getListFromString($value_one)];
break;
case 'NOT_IN':
$method = 'whereNotIn';
$arguments = [static::getListFromString($value_one)];
break;
case 'NULL':
$method = 'whereNull';
| php | {
"resource": ""
} |
q11640 | ModelSearch.filterByString | train | public static function filterByString($filter)
{
$operator = Arr::get($filter, 'operator');
$method = Arr::get($filter, 'method');
$arguments = Arr::get($filter, 'arguments');
$value_one = Arr::get($filter, 'value_one');
$value_two = Arr::get($filter, 'value_two');
$settings = Arr::get($filter, 'settings');
$positive = Arr::get($filter, 'positive');
switch ($operator) {
case '=':
case '!=':
$arguments = [$operator, $value_one];
break;
case '*=*':
case '*!=*':
$operator = (stripos($operator, '!') !== false) ? 'not ' : '';
$operator .= 'like';
$arguments = [$operator, '%'.$value_one.'%'];
break;
case '*=':
case '*!=':
$operator = (stripos($operator, '!') !== false) ? 'not ' : '';
$operator .= 'like';
$arguments = [$operator, '%'.$value_one];
break;
case '=*':
case '!=*':
$operator = (stripos($operator, '!') !== false) ? 'not ' : '';
$operator .= 'like';
$arguments = [$operator, $value_one.'%'];
break;
case 'EMPTY':
$method = 'whereRaw';
$arguments = "%s = ''";
break;
case 'NOT_EMPTY':
$method = 'whereRaw';
$arguments = "%s != ''";
| php | {
"resource": ""
} |
q11641 | ModelSearch.filterByScope | train | public static function filterByScope($filter)
{
$operator = Arr::get($filter, 'operator');
$method = Arr::get($filter, 'method');
$source = Arr::get($filter, 'settings.source');
$arguments = Arr::get($filter, 'arguments');
$value_one = Arr::get($filter, 'value_one');
$value_two = Arr::get($filter, 'value_two');
$settings = Arr::get($filter, 'settings');
$positive = Arr::get($filter, 'positive');
if (Arr::has($filter, 'settings.source')) {
$model = Arr::get($filter, 'settings.model');
$method_transform = 'transform'.Str::studly($source).'Value';
if (method_exists($model, $method_transform)) {
$value_one = $model->$method_transform($value_one);
}
| php | {
"resource": ""
} |
q11642 | ModelSearch.modelJoin | train | public function modelJoin($relationships, $operator = '=', $type = 'left', $where = false)
{
if (!is_array($relationships)) {
$relationships = [$relationships];
}
if (empty($this->query->columns)) {
$this->query->selectRaw('DISTINCT '.$this->model->getTable().'.*');
}
foreach ($relationships as $relation_name => $load_relationship) {
// Required variables.
$model = Arr::get($this->relationships, $relation_name.'.model');
$method = Arr::get($this->relationships, $relation_name.'.method');
$table = Arr::get($this->relationships, $relation_name.'.table');
$parent_key = Arr::get($this->relationships, $relation_name.'.parent_key');
| php | {
"resource": ""
} |
q11643 | ModelSearch.applySearch | train | private static function applySearch(&$query, $search)
{
foreach ($search as $name => $filters) { | php | {
"resource": ""
} |
q11644 | ModelSearch.applySearchFilter | train | private static function applySearchFilter(&$query, $filter)
{
$filter_type = Arr::get($filter, 'settings.filter');
$method = Arr::get($filter, 'method');
$arguments = Arr::get($filter, 'arguments');
$attributes = Arr::get($filter, 'settings.attributes');
$positive = Arr::get($filter, 'positive');
if ($filter_type !== 'scope' && is_array($arguments)) {
array_unshift($arguments, '');
}
$query->where(function ($query) use ($filter_type, $attributes, $method, $arguments, $positive) {
$count = 0;
foreach ($attributes as $attribute_name) {
// Place attribute name into argument.
if ($filter_type !== 'scope' && is_array($arguments)) {
$arguments[0] = $attribute_name;
// Argument is raw and using sprintf.
} elseif (!is_array($arguments)) {
| php | {
"resource": ""
} |
q11645 | ModelSearch.getOperator | train | public static function getOperator($type, $operator)
{
$operators = self::getOperators($type);
| php | {
"resource": ""
} |
q11646 | ModelSearch.getOperators | train | public static function getOperators($type)
{
if (!in_array($type, self::getTypes())) {
| php | {
"resource": ""
} |
q11647 | ModelSearch.getListFromString | train | private static function getListFromString($value)
{
if (is_string($value_array = $value)) {
$value = str_replace([',', ' '], ';', $value);
$value_array = explode(';', $value);
}
| php | {
"resource": ""
} |
q11648 | Smarty_Internal_Template.compileTemplateSource | train | public function compileTemplateSource()
{
if (!$this->source->recompiled) {
$this->properties['file_dependency'] = array();
if ($this->source->components) {
// for the extends resource the compiler will fill it
// uses real resource for file dependency
// $source = end($this->source->components);
// $this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $source->type);
} else {
$this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $this->source->type);
}
}
// compile locking
if ($this->smarty->compile_locking && !$this->source->recompiled) {
if ($saved_timestamp = $this->compiled->timestamp) {
touch($this->compiled->filepath);
}
}
// call compiler
try {
$code = $this->compiler->compileTemplate($this);
}
catch (Exception $e) {
// restore old timestamp in case of error
| php | {
"resource": ""
} |
q11649 | Smarty_Internal_Template.getSubTemplate | train | public function getSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope)
{
// already in template cache?
if ($this->smarty->allow_ambiguous_resources) {
$_templateId = Smarty_Resource::getUniqueTemplateName($this, $template) . $cache_id . $compile_id;
} else {
$_templateId = $this->smarty->joined_template_dir . '#' . $template . $cache_id . $compile_id;
}
if (isset($_templateId[150])) {
$_templateId = sha1($_templateId);
}
if (isset($this->smarty->template_objects[$_templateId])) {
// clone cached template object because of possible recursive call
$tpl = clone $this->smarty->template_objects[$_templateId];
$tpl->parent = $this;
$tpl->caching = $caching;
$tpl->cache_lifetime = $cache_lifetime;
} else {
$tpl = new $this->smarty->template_class($template, $this->smarty, $this, $cache_id, $compile_id, $caching, $cache_lifetime);
}
// get variables from calling scope
if ($parent_scope == Smarty::SCOPE_LOCAL) {
$tpl->tpl_vars = $this->tpl_vars;
$tpl->tpl_vars['smarty'] = clone $this->tpl_vars['smarty'];
} elseif ($parent_scope == Smarty::SCOPE_PARENT) {
$tpl->tpl_vars = & $this->tpl_vars;
} elseif ($parent_scope == Smarty::SCOPE_GLOBAL) { | php | {
"resource": ""
} |
q11650 | ServerRequestFactory.createServerRequestFromArray | train | public function createServerRequestFromArray(?array $server)
{
global $app;
# Copied from Guzzles ::fromGlobals(), but we need to support the $server array as
# paramter, so we use that instead of the $_SERVER array guzzle uses by default
$method = isset($server['REQUEST_METHOD']) ? $server['REQUEST_METHOD'] : 'GET';
$headers = \function_exists('getallheaders') ? \getallheaders() : [];
$uri = ServerRequest::getUriFromGlobals();
$body = new LazyOpenStream('php://input', 'r+');
$protocol = isset($server['SERVER_PROTOCOL']) ? \str_replace('HTTP/', '', $server['SERVER_PROTOCOL']) : '1.1';
$serverRequest = new ServerRequest($method, | php | {
"resource": ""
} |
q11651 | Kohana_PayPal.payment | train | public static function payment($amount, $localTrxID = null) {
$impl = new PayPal();
$registration = $impl->registerTransaction($amount, $impl->storeLocalTrx($localTrxID));
Session::instance()->set(self::SESSION_TOKEN, $registration->id);
foreach ($registration->links as $link) {
if ($link->rel == 'approval_url') | php | {
"resource": ""
} |
q11652 | Kohana_PayPal.registerTransaction | train | public function registerTransaction($amount, $localTrxID) {
$token = $this->authenticate();
// paypal like the amount as string, to prevent floating point errors
if (!is_string($amount))
$amount = sprintf("%0.2f", $amount);
$a = (object)[
"amount" => (object)[
"total" => $amount,
"currency" => $this->currency,
]
];
$route = Route::get('paypal_response');
$base = URL::base(true);
$payment_data = (object)[
'intent' => "sale",
'redirect_urls' => (object)[
'return_url' => $base . $route->uri([
| php | {
"resource": ""
} |
q11653 | Kohana_PayPal.storeLocalTrx | train | private function storeLocalTrx($localTrxID) {
if (is_null($localTrxID))
return $localTrxID;
$trxco = sha1(time() . | php | {
"resource": ""
} |
q11654 | Kohana_PayPal.retrieveLocalTrx | train | private function retrieveLocalTrx($localTrxHash) {
if (is_null($localTrxHash))
return $localTrxHash;
$trxid = $this->cache->get($localTrxHash, false);
if ($trxid === false) | php | {
"resource": ""
} |
q11655 | Kohana_PayPal.extractSales | train | private function extractSales($transactions) {
$out = [];
foreach ($transactions as $trx) {
foreach ($trx->related_resources as $src) { | php | {
"resource": ""
} |
q11656 | Kohana_PayPal.getRefundURL | train | private function getRefundURL($paymentDetails) {
if (!is_object($paymentDetails))
throw new Exception("Invalid payment details in getRefundURL");
if (!is_array($paymentDetails->transactions))
throw new Exception("Invalid transaction list in getRefundURL");
foreach ($paymentDetails->transactions as $transact) {
if (!is_array($transact->related_resources))
throw new Exception("Invalid related resources in getRefundURL");
foreach ($transact->related_resources as $res) {
if (!is_array($res->sale->links))
| php | {
"resource": ""
} |
q11657 | Kohana_PayPal.genRequest | train | protected function genRequest($address, $data = [], $token = null, $get = false) {
// compose request URL
if (strstr($address, 'https://'))
$url = $address;
else
$url = $this->endpoint . '/v1/' . $address;
$method = (is_null($data) || $get) ? 'GET' : 'POST';
self::debug("PayPal Auth: " . $token->token_type . ' ' . $token->access_token);
// create HTTP request
$req = (new Request($url))->method($method)
->headers('Accept','application/json')
->headers('Accept-Language', 'en_US')
->headers('Authorization', is_null($token) ?
| php | {
"resource": ""
} |
q11658 | Kohana_PayPal.call | train | protected function call(Request $request) {
$response = $request->execute();
if (!$response->isSuccess()) {
self::debug("Error in PayPal call", $response);
throw new PayPal_Exception_InvalidResponse("Error " . $response->status() . " | php | {
"resource": ""
} |
q11659 | ImageExtension.getBase64 | train | public function getBase64()
{
if ($this->owner->exists()) {
$file = $this->owner->getFullPath();
$mime = mime_content_type($file);
$fileContent = file_get_contents($file);
| php | {
"resource": ""
} |
q11660 | Template_Part.set_var | train | public function set_var( $key, $value ) {
if ( null === $this->wp_query->get( $key, null ) ) {
$this->vars[ | php | {
"resource": ""
} |
q11661 | Template_Part.render | train | public function render() {
$html = '';
ob_start();
if ( $this->_is_root_template() ) {
$this->_root_get_template_part();
} else {
get_template_part( $this->slug, $this->name );
}
$html = ob_get_clean();
// @codingStandardsIgnoreStart
echo apply_filters( | php | {
"resource": ""
} |
q11662 | Template_Part._is_root_template | train | protected function _is_root_template() {
$hierarchy = [];
/**
* @deprecated
*/
$root = apply_filters(
'inc2734_view_controller_template_part_root',
'',
$this->slug,
$this->name,
$this->vars
);
if ( $root ) {
$hierarchy[] = $root;
}
$hierarchy = apply_filters(
'inc2734_view_controller_template_part_root_hierarchy',
$hierarchy,
$this->slug,
$this->name,
$this->vars
);
| php | {
"resource": ""
} |
q11663 | Template_Part._is_root | train | protected function _is_root( $root ) {
$this->root = $root;
$is_root | php | {
"resource": ""
} |
q11664 | Template_Part._get_root_template_part_slugs | train | protected function _get_root_template_part_slugs() {
if ( ! $this->root ) {
return [];
}
if ( $this->name ) {
$templates[] = | php | {
"resource": ""
} |
q11665 | DataCollection.getData | train | public function getData($page)
{
$this->loadData();
$start = | php | {
"resource": ""
} |
q11666 | DataCollection.getLastPageNumber | train | public function getLastPageNumber()
{
$this->loadData();
$count | php | {
"resource": ""
} |
q11667 | DataCollection.setFiltersAndSort | train | public function setFiltersAndSort($filters, $sortField = null, $sortOrder = "ASC")
{
$this->reset();
| php | {
"resource": ""
} |
q11668 | DataCollection.setDataByIndex | train | public function setDataByIndex($line, $data)
{
$this->data[$line] = | php | {
"resource": ""
} |
q11669 | DataCollection.reset | train | public function reset()
{
$this->filteredData = null;
$this->filters = [];
| php | {
"resource": ""
} |
q11670 | DataCollection.loadData | train | protected function loadData()
{
if (is_null($this->filteredData)) {
$this->filteredData = $this->filterHelper->filterData(
$this->data,
$this->filters,
FilterInterface::FILTER_LOGIC_OR
);
if (!is_null($this->sort)) {
$sort = $this->sort;
uasort($this->filteredData, function ($a, $b) use ($sort) {
if (is_numeric($a[$sort[0]])) {
$comp = ($a[$sort[0]] < $b[$sort[0]]) ? -1 : 1;
| php | {
"resource": ""
} |
q11671 | DataProviderManager.isProviderCompatible | train | public function isProviderCompatible($provider, $title, $mode, $script, Map $map)
{
| php | {
"resource": ""
} |
q11672 | DataProviderManager.registerPlugin | train | public function registerPlugin($provider, $pluginId, $title, $mode, $script, Map $map)
{
$providerId = $this->getCompatibleProviderId($provider, $title, $mode, $script, $map);
if (empty($providerId)) {
return;
}
/** @var AbstractDataProvider $providerService */
$providerService = $this->container->get($providerId);
$pluginService = $this->container->get($pluginId);
$interface = $this->providerInterfaces[$provider];
if ($pluginService instanceof $interface) {
| php | {
"resource": ""
} |
q11673 | DataProviderManager.deletePlugin | train | public function deletePlugin($provider, $pluginId)
{
foreach ($this->providersByCompatibility[$provider] as $titleProviders) {
foreach ($titleProviders as $modeProviders) {
foreach ($modeProviders as $providerId) {
| php | {
"resource": ""
} |
q11674 | DataProviderManager.dispatch | train | public function dispatch($eventName, $params)
{
if (isset($this->enabledProviderListeners[$eventName])) {
foreach ($this->enabledProviderListeners[$eventName] as $callback) { | php | {
"resource": ""
} |
q11675 | Service.makeBoletoAsHTML | train | public function makeBoletoAsHTML($codigoBanco, $boleto)
{
$boleto = new Boleto($boleto);
$factory = new BoletoFactory($this->config);
| php | {
"resource": ""
} |
q11676 | CountryIpv4.ipv4For | train | protected function ipv4For($country)
{
$country = self::toUpper($country);
if (!isset(self::$ipv4Ranges[$country])) {
| php | {
"resource": ""
} |
q11677 | Smarty_CacheResource_Memcache.delete | train | protected function delete(array $keys)
{
foreach ($keys as $k) {
$k = sha1($k);
| php | {
"resource": ""
} |
q11678 | Module.initSession | train | public function initSession()
{
$sessionManager = new SessionManager();
$sessionManager->start(); | php | {
"resource": ""
} |
q11679 | FormField.getEditable | train | public function getEditable($is_create = true)
{
return
(
$this->getParent()->getEditable() ||
$this->getParent()->getRequired()
) | php | {
"resource": ""
} |
q11680 | LayoutScrollable.forceContainerSize | train | public function forceContainerSize($x, $y)
{
| php | {
"resource": ""
} |
q11681 | CheckoutSteps.nextStep | train | public static function nextStep($step)
{
$steps = self::getSteps();
$key = self::getStepIndex($step) + 1;
if (key_exists($key, $steps)) {
| php | {
"resource": ""
} |
q11682 | CheckoutSteps.get | train | public static function get(CheckoutStepController $controller)
{
$list = new ArrayList();
$steps = self::getSteps();
foreach ($steps as $step) {
$data = new ViewableData();
$data->Link = $controller->Link($step);
$data->Title = _t("CheckoutSteps.$step", ucfirst($step));
$data->InPast = self::inPast($step, $controller);
| php | {
"resource": ""
} |
q11683 | CheckoutSteps.inPast | train | private static function inPast($step, CheckoutStepController $controller)
{
$currentStep = $controller->getURLParams()['Action'];
| php | {
"resource": ""
} |
q11684 | CheckoutSteps.inFuture | train | private static function inFuture($step, CheckoutStepController $controller)
{
$currentStep = $controller->getURLParams()['Action'];
| php | {
"resource": ""
} |
q11685 | CheckoutSteps.current | train | private static function current($step, CheckoutStepController $controller)
{
$currentStep = $controller->getURLParams()['Action'];
| php | {
"resource": ""
} |
q11686 | ScriptMapDataProvider.dispatchMapEvent | train | protected function dispatchMapEvent($eventName, $params)
{
$map = $this->mapStorage->getMap($params['map']['uid']);
$this->dispatch(
$eventName,
[
$params['count'],
| php | {
"resource": ""
} |
q11687 | MapratingTableMap.doDelete | train | public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(MapratingTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \eXpansion\Bundle\LocalMapRatings\Model\Maprating) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(MapratingTableMap::DATABASE_NAME);
$criteria->add(MapratingTableMap::COL_ID, (array) $values, Criteria::IN);
| php | {
"resource": ""
} |
q11688 | UserProfile.formUserInfo | train | protected function formUserInfo()
{
$form = new XmlFormCollection($this->_context, $this->_url, $this->_myWords->Value("UPDATETITLE"));
$this->_paragraph->addXmlnukeObject($form);
$hidden = new XmlInputHidden("action", "update");
$form->addXmlnukeObject($hidden);
$labelField = new XmlInputLabelField($this->_myWords->Value("LABEL_LOGIN"), $this->_user->getField($this->_users->getUserTable()->username));
$form->addXmlnukeObject($labelField);
$textBox = new XmlInputTextBox($this->_myWords->Value("LABEL_NAME"), "name",$this->_user->getField($this->_users->getUserTable()->name));
$form->addXmlnukeObject($textBox);
| php | {
"resource": ""
} |
q11689 | UserProfile.formPasswordInfo | train | protected function formPasswordInfo()
{
$form = new XmlFormCollection($this->_context, $this->_url, $this->_myWords->Value("CHANGEPASSTITLE"));
$this->_paragraph->addXmlnukeObject($form);
$hidden = new XmlInputHidden("action", "changepassword");
$form->addXmlnukeObject($hidden);
$textbox = new XmlInputTextBox($this->_myWords->Value("CHANGEPASSOLDPASS"), "oldpassword","");
$textbox->setInputTextBoxType(InputTextBoxType::PASSWORD );
$form->addXmlnukeObject($textbox);
$textbox = new XmlInputTextBox($this->_myWords->Value("CHANGEPASSNEWPASS"), "newpassword","");
$textbox->setInputTextBoxType(InputTextBoxType::PASSWORD ); | php | {
"resource": ""
} |
q11690 | UserProfile.formRolesInfo | train | protected function formRolesInfo()
{
$form = new XmlFormCollection($this->_context, $this->_url, $this->_myWords->Value("OTHERTITLE"));
$this->_paragraph->addXmlnukeObject($form);
$easyList = new XmlEasyList(EasyListType::SELECTLIST , "", | php | {
"resource": ""
} |
q11691 | ReservationController.ReservationForm | train | public function ReservationForm()
{
$reservationForm = new ReservationForm($this, 'ReservationForm', ReservationSession::get());
| php | {
"resource": ""
} |
q11692 | UUID.generate | train | public static function generate(): string
{
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
\mt_rand( 0, 0xffff ), \mt_rand( 0, 0xffff ),
// 16 bits for "time_mid"
\mt_rand( 0, 0xffff ),
// 16 bits for "time_hi_and_version",
| php | {
"resource": ""
} |
q11693 | Tokenizer.setInput | train | public function setInput($input)
{
$this->input = $input;
$this->pos = 0;
$this->line | php | {
"resource": ""
} |
q11694 | Tokenizer.nextChar | train | private function nextChar()
{
if( ! $this->isEOF())
{
$this->linePos ++;
| php | {
"resource": ""
} |
q11695 | Environments.init | train | public static function init()
{
$instance = self::getInstance();
$instance->_environments = $instance->_loadEnvironment($instance->_envPath . DS . 'config.php');
if (!isset($instance->_environments['local'])) {
$instance->_environments['local'] = [];
}
$instance->_current = | php | {
"resource": ""
} |
q11696 | Environments._loadEnvironment | train | protected function _loadEnvironment($envFilePath)
{
if (file_exists($envFilePath)) {
include $envFilePath;
// $configure has to be defined in the included environment file.
if (isset($configure) && is_array($configure) && !empty($configure)) {
$config = Hash::merge(Configure::read(), Hash::expand($configure));
| php | {
"resource": ""
} |
q11697 | Environments._getEnvironment | train | protected function _getEnvironment()
{
$environment = self::$forceEnvironment;
// Check if the environment has been manually set (forced).
if ($environment !== null) {
if (!isset($this->_environments[$environment])) {
throw new Exception('Environment configuration for "' . $environment . '" could not be found.');
}
}
// If no manual setting is available, use "host:port" to decide which config to use.
if ($environment === null && !empty($_SERVER['HTTP_HOST'])) {
$host = (string)$_SERVER['HTTP_HOST'];
foreach ($this->_environments as $env => $envConfig) {
if (isset($envConfig['domain']) && in_array($host, $envConfig['domain'])) {
| php | {
"resource": ""
} |
q11698 | Environments._getRealAppPath | train | protected function _getRealAppPath()
{
$path = realpath(APP);
if (substr($path, -1, 1) !== DS) {
| php | {
"resource": ""
} |
q11699 | CryptBehavior.initialize | train | public function initialize(array $config)
{
$config += $this->_defaultConfig;
$this->config('fields', $this->_resolveFields($config['fields']));
| php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.