_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q263700
|
Account.numbers
|
test
|
public function numbers($index = 1, $size = 10, $pattern = null, $searchPattern = MatchingStrategy::STARTS_WITH)
|
php
|
{
"resource": ""
}
|
q263701
|
Cache.factory
|
test
|
static function factory($driver = null)
{
try {
switch ($driver) {
case APC:
return static::getDriver('APC');
case MEMCACHED:
try {
return static::getDriver('Memcached');
} catch (Exception $e) {
|
php
|
{
"resource": ""
}
|
q263702
|
Manialink.load
|
test
|
final public static function load($root = true, $timeout = 0, $version = 1, $background = self::DEFAULT_BACKGROUND, $navigable3d = false)
{
if (class_exists('\ManiaLib\Application\Config')) {
$config = \ManiaLib\Application\Config::getInstance();
self::$langsURL = $config->getLangsURL();
self::$imagesURL = $config->getImagesURL();
self::$mediaURL = $config->getMediaURL();
}
// Load the XML object
self::$domDocument = new \DOMDocument('1.0', 'utf-8');
self::$parentNodes = array();
self::$parentLayouts = array();
self::$parentFrames = array();
if ($root) {
$nodeManialink = self::$domDocument->createElement('manialink');
$nodeManialink->setAttribute('version', $version);
|
php
|
{
"resource": ""
}
|
q263703
|
Manialink.beginFrame
|
test
|
final public static function beginFrame($x = 0, $y = 0, $z = 0, $scale = null,
\ManiaLib\Gui\Layouts\AbstractLayout $layout = null)
{
$frame = new Elements\Frame();
$frame->setPosition($x, $y, $z);
$frame->setScale($scale);
if ($layout instanceof Layouts\AbstractLayout) {
|
php
|
{
"resource": ""
}
|
q263704
|
Manialink.endFrame
|
test
|
final public static function endFrame()
{
if (!end(self::$parentNodes)->hasChildNodes()) {
end(self::$parentNodes)->nodeValue = ' ';
}
|
php
|
{
"resource": ""
}
|
q263705
|
Manialink.redirect
|
test
|
final public static function redirect($link, $render = true)
{
self::$domDocument = new \DOMDocument('1.0', 'utf-8');
self::$parentNodes = array();
self::$parentLayouts = array();
$redirect = self::$domDocument->createElement('redirect');
$redirect->appendChild(self::$domDocument->createTextNode($link));
self::$domDocument->appendChild($redirect);
self::$parentNodes[] = $redirect;
if ($render) {
|
php
|
{
"resource": ""
}
|
q263706
|
Manialink.appendXML
|
test
|
static function appendXML($XML)
{
$doc = new \DOMDocument('1.0', 'utf-8');
$doc->loadXML($XML);
$node
|
php
|
{
"resource": ""
}
|
q263707
|
RedirectorManager.buildDriver
|
test
|
private function buildDriver($driver, array $extra = [])
{
$router = $this->app->make(\Illuminate\Contracts\Routing\Registrar::class);
$class = Seo::getConfig("redirector.drivers.$driver.class");
|
php
|
{
"resource": ""
}
|
q263708
|
AbstractLayout.setBorder
|
test
|
function setBorder($borderWidth = 0, $borderHeight = 0)
{
$this->borderWidth = $borderWidth;
$this->xIndex = $borderWidth;
|
php
|
{
"resource": ""
}
|
q263709
|
StyleParser.declareFont
|
test
|
static function declareFont($name, $normal, $bold = null, $italic = null, $boldItalic = null)
{
self::$fonts[$name] = array(
0 => $normal,
StyleParser::BOLD => $bold ?: $normal,
StyleParser::ITALIC => $italic ?: $normal,
|
php
|
{
"resource": ""
}
|
q263710
|
StyleParser.onImage
|
test
|
static function onImage($string, $image, $fontName, $x = 0, $y = 0, $size = 10, $defaultColor = '000')
{
if ($size <= 5)
self::onImageQuality($string, $image, $fontName, $x, $y, $size, $defaultColor, 3);
else if ($size <= 10)
self::onImageQuality($string, $image, $fontName, $x, $y, $size, $defaultColor, 2);
else if
|
php
|
{
"resource": ""
}
|
q263711
|
StyleParser.onImageFast
|
test
|
static function onImageFast($string, $image, $fontName, $x = 0, $y = 0, $size = 10, $defaultColor = '000')
{
$defaultColor = Color::StringToRgb24($defaultColor);
$xOffset = 0;
|
php
|
{
"resource": ""
}
|
q263712
|
StyleParser.onImageQuality
|
test
|
static function onImageQuality($string, $image, $fontName, $x = 0, $y = 0, $size = 10, $defaultColor = '000', $precision = 2)
{
$defaultColor = Color::StringToRgb24($defaultColor);
$factor = 1 << ($precision > 31 ? 31 : $precision);
$tokens = self::parseString($string);
$rawText = '';
foreach ($tokens as $token)
$rawText .= $token->text;
$maxBBox = imagettfbbox($size, 0, self::$fonts[$fontName]->getFile(), $rawText);
$brush = imagecreatetruecolor($maxBBox[2] * 2, -$maxBBox[5] + 5);
imagefill($brush, 0, 0, 0x7fffffff);
$hugeBrush = imagecreatetruecolor(imagesx($brush) * $factor, imagesy($brush) * $factor);
imagefill($hugeBrush, 0, 0, 0x7fffffff);
$xOffset = 0;
foreach ($tokens as $token)
|
php
|
{
"resource": ""
}
|
q263713
|
AbstractRedirector.getRedirectFor
|
test
|
public function getRedirectFor(Request $request)
{
$this->request = $request;
collect($this->getRedirectedUrls())->each(function ($redirects, $missingUrl) {
$this->router->get($missingUrl, function () use ($redirects) {
return redirect()->to(
$this->determineRedirectUrl($redirects),
$this->determineRedirectStatusCode($redirects)
|
php
|
{
"resource": ""
}
|
q263714
|
EloquentRedirector.getRedirectedUrls
|
test
|
public function getRedirectedUrls()
{
return $this->getCachedRedirects()
->keyBy('old_url')
|
php
|
{
"resource": ""
}
|
q263715
|
EloquentRedirector.getCachedRedirects
|
test
|
protected function getCachedRedirects()
{
return cache()->remember($this->getOption('cache.key'), $this->getOption('cache.duration'), function () {
|
php
|
{
"resource": ""
}
|
q263716
|
PageNavigator.setSize
|
test
|
function setSize($iconSize = 5, $nullValue = null)
{
$this->arrowNext->setSize($iconSize, $iconSize);
$this->arrowPrev->setSize($iconSize, $iconSize);
$this->arrowFastNext->setSize($iconSize, $iconSize);
|
php
|
{
"resource": ""
}
|
q263717
|
Button.setSelected
|
test
|
function setSelected()
{
$this->isSelected = true;
$this->selectedIcon = new \ManiaLib\Gui\Elements\Icons64x64_1(11);
$this->selectedIcon->setSubStyle(\ManiaLib\Gui\Elements\Icons64x64_1::ShowRight);
|
php
|
{
"resource": ""
}
|
q263718
|
MarketingMessage.invoke
|
test
|
public function invoke($from = null, $keyword = null, $to = null, $text = '')
{
if(!$from) {
throw new Exception("\$from parameter cannot be blank");
}
if(!$keyword) {
throw new Exception("\$keyword parameter cannot be blank");
}
if(!$to) {
throw new Exception("\$to parameter cannot be blank");
}
if(!$text) {
|
php
|
{
"resource": ""
}
|
q263719
|
Music.setData
|
test
|
function setData($filename, $absoluteUrl = false)
{
if (!$absoluteUrl) {
$this->data = \ManiaLib\Gui\Manialink::$mediaURL .
|
php
|
{
"resource": ""
}
|
q263720
|
Tools.getLimitString
|
test
|
static function getLimitString($offset, $length)
{
$offset = (int)$offset;
$length = (int)$length;
if (!$offset && !$length) {
return '';
} elseif (!$offset && $length == 1) {
|
php
|
{
"resource": ""
}
|
q263721
|
Tools.getUpdateString
|
test
|
static function getUpdateString(array $values)
{
$tmp = array();
foreach ($values as $key => $value) {
|
php
|
{
"resource": ""
}
|
q263722
|
Request.get
|
test
|
function get($name, $default = null)
{
if (array_key_exists($name, $this->params)) {
|
php
|
{
"resource": ""
}
|
q263723
|
Request.getStrict
|
test
|
function getStrict($name, $message = null)
{
if (array_key_exists($name, $this->params) && $this->params[$name]) {
|
php
|
{
"resource": ""
}
|
q263724
|
Request.getPostStrict
|
test
|
function getPostStrict($name, $message = null)
{
if (array_key_exists($name, $_POST) && $_POST[$name]) {
return $_POST[$name];
} elseif ($message) {
|
php
|
{
"resource": ""
}
|
q263725
|
Request.restore
|
test
|
function restore($name)
{
if (array_key_exists($name, $this->requestParams)) {
|
php
|
{
"resource": ""
}
|
q263726
|
Request.redirectArgList
|
test
|
function redirectArgList($route = '')
{
$args = func_get_args();
array_shift($args);
$args = $this->filterArgs($args);
$manialink =
|
php
|
{
"resource": ""
}
|
q263727
|
Request.createLinkArgList
|
test
|
function createLinkArgList($route = '')
{
$args = func_get_args();
array_shift($args);
|
php
|
{
"resource": ""
}
|
q263728
|
Request.createAbsoluteLinkArgList
|
test
|
function createAbsoluteLinkArgList($absoluteLink)
{
$args = func_get_args();
array_shift($args);
$args = $this->filterArgs($args);
|
php
|
{
"resource": ""
}
|
q263729
|
Component.incPosX
|
test
|
function incPosX($posX)
{
$oldX = $this->posX;
|
php
|
{
"resource": ""
}
|
q263730
|
Component.incPosY
|
test
|
function incPosY($posY)
{
$oldY = $this->posY;
|
php
|
{
"resource": ""
}
|
q263731
|
Component.incPosZ
|
test
|
function incPosZ($posZ)
{
$oldZ = $this->posZ;
|
php
|
{
"resource": ""
}
|
q263732
|
Component.setPosition
|
test
|
function setPosition()
{
$oldX = $this->posX;
$oldY = $this->posY;
$oldZ = $this->posZ;
$args = func_get_args();
if (!empty($args)) $this->posX = array_shift($args);
|
php
|
{
"resource": ""
}
|
q263733
|
Component.setScale
|
test
|
function setScale($scale)
{
$oldScale = $this->scale;
$this->scale
|
php
|
{
"resource": ""
}
|
q263734
|
Component.setValign
|
test
|
function setValign($valign)
{
$old = $this->valign;
|
php
|
{
"resource": ""
}
|
q263735
|
Component.setHalign
|
test
|
function setHalign($halign)
{
$old = $this->halign;
|
php
|
{
"resource": ""
}
|
q263736
|
Component.setAlign
|
test
|
function setAlign($halign = null, $valign = null)
{
$oldHalign = $this->halign;
$oldValign = $this->valign;
$this->valign = $valign;
|
php
|
{
"resource": ""
}
|
q263737
|
Component.setSizeX
|
test
|
function setSizeX($sizeX)
{
$oldX = $this->sizeX;
$this->sizeX = $sizeX;
|
php
|
{
"resource": ""
}
|
q263738
|
Component.setSizeY
|
test
|
function setSizeY($sizeY)
{
$oldY = $this->sizeY;
$this->sizeY = $sizeY;
|
php
|
{
"resource": ""
}
|
q263739
|
Component.setSize
|
test
|
function setSize()
{
$oldX = $this->sizeX;
$oldY = $this->sizeY;
$args = func_get_args();
if (!empty($args)) $this->sizeX = array_shift($args);
|
php
|
{
"resource": ""
}
|
q263740
|
Menu.addItem
|
test
|
function addItem($topItem = self::BUTTONS_TOP)
{
$item = new Button();
$item->setSubStyle(Bgs1::BgEmpty);
if ($topItem == self::BUTTONS_TOP) {
$this->items[] = $item;
|
php
|
{
"resource": ""
}
|
q263741
|
Menu.addGap
|
test
|
function addGap($gap = 4)
{
$item = new
|
php
|
{
"resource": ""
}
|
q263742
|
RedirectStatuses.keys
|
test
|
public static function keys()
{
return collect([
Response::HTTP_MOVED_PERMANENTLY,
Response::HTTP_SEE_OTHER,
|
php
|
{
"resource": ""
}
|
q263743
|
RedirectStatuses.all
|
test
|
public static function all($locale = null)
{
return static::keys()->mapWithKeys(function ($code) use ($locale) {
return [$code
|
php
|
{
"resource": ""
}
|
q263744
|
ErrorHandling.fatalExceptionHandler
|
test
|
static function fatalExceptionHandler(\Exception $exception)
{
throw $exception;
file_put_contents(MANIALIB_APP_PATH . 'fatal-error.log', print_r($exception, true),
FILE_APPEND);
if (array_key_exists('HTTP_USER_AGENT', $_SERVER) && $_SERVER['HTTP_USER_AGENT'] == 'GameBox') {
echo '<manialink><timeout>0</timeout><label text="Fatal error." /></manialink>';
} else {
|
php
|
{
"resource": ""
}
|
q263745
|
ErrorHandling.computeMessage
|
test
|
final static function computeMessage(\Exception $e, $styles = array(),
$additionalLines = array())
{
if (!$styles) {
$styles = static::$messageConfigs['default'];
}
$trace = $e->getTraceAsString();
$trace = explode("\n", $trace);
foreach ($trace as $key => $value) {
$trace[$key] = sprintf($styles['simpleLine'],
preg_replace('/#[0-9]*\s*/u', '', $value));
}
$file = sprintf($styles['simpleLine'], $e->getFile() . ' (' . $e->getLine() . ')');
$lines[] = sprintf($styles['title'], get_class($e));
$lines[] = '';
|
php
|
{
"resource": ""
}
|
q263746
|
ErrorHandling.computeShortMessage
|
test
|
final static function computeShortMessage(\Exception $e)
{
$message = get_class($e) .
|
php
|
{
"resource": ""
}
|
q263747
|
RedirectsMissingPages.handle
|
test
|
public function handle(Request $request, Closure $next)
{
$response = $next($request);
if ($response->getStatusCode() !==
|
php
|
{
"resource": ""
}
|
q263748
|
Upload.uploadFile
|
test
|
static function uploadFile($path, $filename, $maxSize = 2097152)
{
$inputFile = file_get_contents('php://input', null, null, null, $maxSize);
// Else try to get GET data
if ($inputFile === false && array_key_exists('input', $_GET)) {
$inputFile = $_GET['input'];
}
// Check for error
if ($inputFile === false) {
throw new \Exception('Couldn\'t read input file');
}
if (!file_put_contents($path . $filename, $inputFile)) {
throw new \Exception('Couldn\'t save
|
php
|
{
"resource": ""
}
|
q263749
|
URI.getCurrent
|
test
|
static function getCurrent()
{
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://'
: 'http://';
$current_uri = $protocol . $_SERVER['HTTP_HOST'] . self::getRequestURI();
$parts = parse_url($current_uri);
$query = '';
if (!empty($parts['query'])) {
$params = array();
parse_str($parts['query'], $params);
$params = array_filter($params);
if (!empty($params)) {
$query = '?' . http_build_query($params, '', '&');
|
php
|
{
"resource": ""
}
|
q263750
|
Tools.getAlignedPosX
|
test
|
final public static function getAlignedPosX($posX, $sizeX, $halign, $newAlign)
{
if (!$halign) {
$halign = 'left';
}
$alignmentString = $halign . '|' . $newAlign;
switch ($alignmentString) {
case 'center|center':
case 'center|center2':
case 'left|left':
case 'right|right':
$factor = 0;
break;
case 'center|left':
case 'right|center':
case 'right|center2':
$factor = -0.5;
break;
case 'center|right':
case 'left|center':
case 'left|center2':
$factor = 0.5;
|
php
|
{
"resource": ""
}
|
q263751
|
Tools.getAlignedPosY
|
test
|
final public static function getAlignedPosY($posY, $sizeY, $valign, $newAlign)
{
switch ($valign) {
case 'top':
case null:
$valign = 'right';
break;
case 'bottom':
$valign = 'left';
break;
}
switch ($newAlign) {
case 'top':
|
php
|
{
"resource": ""
}
|
q263752
|
Tools.getAlignedPos
|
test
|
final public static function getAlignedPos(\ManiaLib\Gui\Element $object,
$newHalign, $newValign)
{
$newPosX = self::getAlignedPosX(
$object->getPosX(), $object->getRealSizeX(), $object->getHalign(),
$newHalign);
$newPosY = self::getAlignedPosY(
|
php
|
{
"resource": ""
}
|
q263753
|
GetMinDateTrans.build
|
test
|
public function build(\Magento\Framework\DB\Select $source = null)
{
/* this is root query builder (started from SELECT) */
$result = $this->conn->select();
/* define tables aliases for internal usage (in this method) */
$asAcc = self::AS_ACC;
$asTran = self::AS_TRAN;
/* FROM prxgt_acc_transaction */
$tbl = $this->resource->getTableName(self::E_TRAN); // name with prefix
$as = $asTran; // alias for 'current table' (currently processed in this block of code)
$exp = $this->expMin();
$cols = [
self::A_MIN_DATE => $exp
];
$result->from([$as => $tbl], $cols);
|
php
|
{
"resource": ""
}
|
q263754
|
Reset.quote
|
test
|
private function quote($data)
{
$conn = $this->resource->getConnection();
$result
|
php
|
{
"resource": ""
}
|
q263755
|
Reset.resetAll
|
test
|
private function resetAll($dateFrom)
{
$quoted = $this->quote($dateFrom);
$where = EBalance::A_DATE . '>' . $quoted;
|
php
|
{
"resource": ""
}
|
q263756
|
Reset.queryDeleteByAssets
|
test
|
private function queryDeleteByAssets($assetTypeIds, $dateFrom)
{
$tblAcc = $this->resource->getTableName(EAccount::ENTITY_NAME);
$tblBal = $this->resource->getTableName(EBalance::ENTITY_NAME);
$conn = $this->resource->getConnection();
$quoted = $conn->quote($dateFrom);
$in = '';
foreach ($assetTypeIds as $id) {
$in .= (int)$id . ',';
}
$in = substr($in, 0, strlen($in) - 1);
$select =
|
php
|
{
"resource": ""
}
|
q263757
|
ComposerBridge.configure
|
test
|
static function configure(ClassLoader $classLoader, string $vendorDirPath, bool $usePrefixes = true): void
{
$composerBasePath = $vendorDirPath . '/composer/';
$classLoader->addClassMap(require $composerBasePath . 'autoload_classmap.php');
$classLoader->setUsePrefixes($usePrefixes);
if ($usePrefixes) {
$classLoader->addPrefixes(require $composerBasePath . 'autoload_psr4.php');
$classLoader->addPrefixes(require $composerBasePath
|
php
|
{
"resource": ""
}
|
q263758
|
Container.getServiceIds
|
test
|
public function getServiceIds()
{
$services = [];
$reserved = ['get', 'getParameter', 'getServiceIds', 'getReturnType'];
$container = new \ReflectionClass($this);
foreach ($this->factories as $name => $factory) {
$services[] = self::underscore($name);
}
foreach ($container->getMethods()
|
php
|
{
"resource": ""
}
|
q263759
|
Container.getReturnType
|
test
|
public function getReturnType($name)
{
$container = new ReflectionClass($this);
try {
$method = $container->getMethod('get' . self::normalizeName($name));
$doc = $method->getDocComment();
if (!empty($doc)) {
preg_match('/@return ([a-zA-Z0-9_\x7f-\xff\x5c]+)/', $doc, $matches);
if (isset($matches[1])) {
return $matches[1];
}
|
php
|
{
"resource": ""
}
|
q263760
|
CollectTransactions.exec
|
test
|
public function exec($balances, $trans)
{
$result = [];
foreach ($trans as $one) {
$accDebit = $one->getDebitAccId();
$accCredit = $one->getCreditAccId();
$timestamp = $one->getDateApplied();
$value = $one->getValue();
/* date_applied is in UTC format */
$date = $this->hlpPeriod->getPeriodCurrent($timestamp);
/**
* Process debit account:
*/
/** @var EBalance $entry Get balance on the transaction date (calculated or new) */
$entry = $this->getBalanceEntry($balances, $result, $accDebit, $date);
/* change total debit for the entry */
$totalDebit = $entry->getTotalDebit() + $value;
$entry->setTotalDebit($totalDebit);
/* change close balance for the entry */
$balanceClose = $entry->getBalanceClose() - $value;
$entry->setBalanceClose($balanceClose);
/* update calculated entries for result balances */
$result[$accDebit][$date] = $entry;
/* update current balances in the working var */
if (isset($balances[$accDebit])) {
$balances[$accDebit] -= $value;
} else {
$balances[$accDebit] = -$value;
|
php
|
{
"resource": ""
}
|
q263761
|
CollectTransactions.getBalanceEntry
|
test
|
private function getBalanceEntry($current, $balances, $accId, $datestamp)
{
if (isset($balances[$accId][$datestamp])) {
/* there is data for this account on this date */
$result = $balances[$accId][$datestamp];
} else {
/* there is NO data for this account on this date */
$result = new EBalance();
$result->setAccountId($accId);
$result->setDate($datestamp);
$result->setBalanceOpen(0);
$result->setTotalDebit(0);
$result->setTotalCredit(0);
|
php
|
{
"resource": ""
}
|
q263762
|
THierarchical.hierarchy
|
test
|
protected final static function hierarchy(){
$Hierarchy = [get_called_class()];
while(class_exists($class = get_parent_class($Hierarchy[count($Hierarchy)
|
php
|
{
"resource": ""
}
|
q263763
|
EasyCurl.changeContentType
|
test
|
public function changeContentType($type)
{
$mime = [
'json' => 'application/json',
'javascript' => 'application/javascript',
'js' => 'application/javascript',
'ogg' => 'audio/ogg',
|
php
|
{
"resource": ""
}
|
q263764
|
EasyCurl.headerParse
|
test
|
private function headerParse($rawHeader)
{
$headers = array();
$headerLine = substr($rawHeader, 0, strpos($rawHeader, "\r\n\r\n"));
foreach (explode("\r\n", $headerLine) as $i => $line)
|
php
|
{
"resource": ""
}
|
q263765
|
Str.convertToArray
|
test
|
public function convertToArray($string, $value)
{
$keys = explode('.', $string);
|
php
|
{
"resource": ""
}
|
q263766
|
Str.buildDimensionalArray
|
test
|
private function buildDimensionalArray(array $keys, $dimensions, $value)
{
$result = [];
// add first dimension
$result[$keys[0]] = [];
$pointer = &$result[$keys[0]];
|
php
|
{
"resource": ""
}
|
q263767
|
Calc.getAssetTypes
|
test
|
private function getAssetTypes($typeIds, $typeCodes)
{
$result = [];
$types = $this->daoTypeAsset->get();
if (
empty($typeIds) &&
empty($typeCodes)
) {
/* return all asset types */
/** @var ETypeAsset $type */
foreach ($types as $type) {
$typeId = $type->getId();
$typeCode = $type->getCode();
|
php
|
{
"resource": ""
}
|
q263768
|
ProcessOneAsset.exec
|
test
|
public function exec($assetTypeId)
{
/* get the last date with balances for given asset then take previous date */
$dsLast = $this->getDateBalanceClose($assetTypeId);
$dsPrev = $this->hlpPeriod->getPeriodPrev($dsLast);
/* get all closing balances for previous date */
$balances = $this->getBalances($assetTypeId, $dsPrev);
/* get all accounts with given asset type */
|
php
|
{
"resource": ""
}
|
q263769
|
ProcessOneAsset.getDateBalanceClose
|
test
|
private function getDateBalanceClose($typeId)
{
$req = new ARequestLastDate();
$req->setAssetTypeId($typeId);
/** @var AResponseLastDate $resp */
|
php
|
{
"resource": ""
}
|
q263770
|
ResponseController.checkAction
|
test
|
public function checkAction($strategy)
{
$config = $this->get('dcs_opauth.strategy_parser')->get($strategy);
$opauth = new \Opauth($config, false);
$this->dispatchEvent(DCSOpauthEvents::BEFORE_PARSE_RESPONSE, new OpauthEvent($opauth));
$responseData = $this->get('dcs_opauth.response_parser')->parse($opauth);
// Check if there are errors from the provider
$isValid = !isset($responseData['error']);
$event = new OpauthResponseEvent($opauth, $responseData, $isValid);
$this->dispatchEvent(DCSOpauthEvents::AFTER_PARSE_RESPONSE, $event);
// If there are no errors, and authentication is enabled, create the token with the data provider
if ($isValid && $event->getAuthenticate()) {
$this->get('dcs_opauth.authenticator')->authenticate($responseData);
}
// Verify if the response is set
if (null === $response = $event->getResponse()) {
if ($isValid) {
if (null === $routeRedirect = $this->container->getParameter('dcs_opauth.redirect_after_response')) {
$url = '/'.ltrim($this->get('request')->getBaseUrl(), '/');
} else {
|
php
|
{
"resource": ""
}
|
q263771
|
TMutatable.mutate
|
test
|
protected final function mutate(string $prefix, string $name, $value = null) {
return method_exists($this, $method = Src::tcm(strtolower(Str::join('_', $prefix,
|
php
|
{
"resource": ""
}
|
q263772
|
Client.fetch
|
test
|
public function fetch($url)
{
$this->builder = new Builder(urlencode($url));
foreach ($this->defaults as $key => $value)
|
php
|
{
"resource": ""
}
|
q263773
|
Client.url
|
test
|
public function url()
{
if (!isset($this->config['url'])) {
throw InvalidConfigurationException::urlNotDefined();
}
if (!isset($this->config['client'])) {
throw InvalidConfigurationException::clientNotDefined();
}
return implode('/', array_filter([
$this->config['url'],
|
php
|
{
"resource": ""
}
|
q263774
|
LazyStrings.generate
|
test
|
public function generate()
{
// validate doc url and sheets
if (!$this->validator->validateDocUrl($this->csvUrl)) {
throw new Exception('Provided doc url is not valid.');
}
$this->validator->validateSheets($this->sheets);
$strings = [];
foreach ($this->sheets as $locale => $csvId) {
// create locale directories
$this->createDirectory($this->target . '/' . $locale);
$localized = $this->localize($csvId);
$strings[$locale] = $localized;
// create strings in language file
$stringsFile = $this->target
|
php
|
{
"resource": ""
}
|
q263775
|
LazyStrings.parse
|
test
|
private function parse($csvUrl)
{
$csvFile = fopen($csvUrl, 'r');
$strings = [];
if ($csvFile !== false) {
while (($row = fgetcsv($csvFile, 1000, ',')) !== false) {
if ($row[0] !== '' && $row[0] !== 'id') {
$id = $this->str->strip($row[0]);
$value = $row[1];
|
php
|
{
"resource": ""
}
|
q263776
|
LazyStrings.localize
|
test
|
private function localize($csvId)
{
$strings = [];
$urlPart = '&single=true&gid=';
if (is_array($csvId)) {
foreach ($csvId as $id) {
$parsed = $this->parse($this->csvUrl . $urlPart . $id);
$strings = array_merge($strings,
|
php
|
{
"resource": ""
}
|
q263777
|
LazyStrings.backup
|
test
|
private function backup(array $strings, $path, $filename)
{
$stringsFile = $path . '/' . $filename;
$jsonStrings = json_encode($strings, JSON_PRETTY_PRINT);
|
php
|
{
"resource": ""
}
|
q263778
|
Account.getAllByAssetTypeCode
|
test
|
public function getAllByAssetTypeCode($assetTypeCode)
{
/* aliases and tables */
$asType = 'at';
$asAcc = 'acc';
/* SELECT FROM prxgt_acc_type_asset */
$query = $this->conn->select();
$tbl = $this->resource->getTableName(TypeAsset::ENTITY_NAME);
$cols = [];
$query->from([$asType => $tbl], $cols);
/* LEFT JOIN prxgt_acc_account */
$tbl = $this->resource->getTableName(Entity::ENTITY_NAME);
$on = $asAcc . '.' . Entity::A_ASSET_TYPE_ID . '=' . $asType . '.' . TypeAsset::A_ID;
$cols = [
Entity::A_ID,
Entity::A_ASSET_TYPE_ID,
Entity::A_BALANCE,
|
php
|
{
"resource": ""
}
|
q263779
|
Account.getAssetTypeId
|
test
|
public function getAssetTypeId($accountId)
{
$result = null;
/** @var Entity $entity */
|
php
|
{
"resource": ""
}
|
q263780
|
Account.getCustomerAccByAssetCode
|
test
|
public function getCustomerAccByAssetCode($customerId, $assetTypeCode)
{
$assetTypeId = $this->daoTypeAsset->getIdByCode($assetTypeCode);
|
php
|
{
"resource": ""
}
|
q263781
|
Account.getSystemCustomerId
|
test
|
public function getSystemCustomerId()
{
if (is_null($this->cachedSysCustId)) {
$conn = $this->conn;
/* there is no cached value for the customer ID, select data from DB */
$where = Cfg::E_CUSTOMER_A_EMAIL . '=' . $conn->quote(Cfg::SYS_CUSTOMER_EMAIL);
$data = $this->daoGeneric->getEntities(Cfg::ENTITY_MAGE_CUSTOMER, Cfg::E_CUSTOMER_A_ENTITY_ID,
$where);
if (count($data) == 0) {
$bind = [
Cfg::E_CUSTOMER_A_WEBSITE_ID => Cfg::DEF_WEBSITE_ID_ADMIN,
|
php
|
{
"resource": ""
}
|
q263782
|
Create.exec
|
test
|
public function exec($request)
{
assert($request instanceof ARequest);
$result = new AResponse();
$debitAccId = $request->getDebitAccId();
$creditAccId = $request->getCreditAccId();
$operationId = $request->getOperationId();
$dateApplied = $request->getDateApplied();
$value = $request->getValue();
$note = $request->getNote();
/* limit amount by MIN & MAX */
if (
($value > Cfg::LIMIT_AMOUNT_MAX) ||
($value < Cfg::LIMIT_AMOUNT_MIN)
) {
throw new \Exception("Illegal value for amount transaction: $value.");
}
/* get account type for debit account */
$debitAcc = $this->daoAcc->getById($debitAccId);
$debitAssetTypeId = $debitAcc->getAssetTypeId();
/* get account type for credit account */
$creditAcc = $this->daoAcc->getById($creditAccId);
$creditAssetTypeId = $creditAcc->getAssetTypeId();
/* asset types should be equals */
if (
!is_null($debitAssetTypeId) &&
($debitAssetTypeId == $creditAssetTypeId)
) {
/* add transaction */
$toAdd = [
|
php
|
{
"resource": ""
}
|
q263783
|
DCSOpauthExtension.buildStrategiesKey
|
test
|
private function buildStrategiesKey($strategies)
{
foreach ($strategies as $name => $config) {
switch ($config['strategy_class']) {
case 'Basecamp':
case 'Behance':
case 'Bitly':
case 'Do':
case 'Dropbox':
case 'Evernote':
case 'Foursquare':
case 'GitHub':
case 'Google':
case 'Harvest':
case 'Instagram':
case 'Live':
case 'Mixi':
case 'Strava':
case 'Yahoojp':
case 'Yammer':
case 'ResourceGuru':
$config['client_id'] = $config['id'];
$config['client_secret'] = $config['secret'];
unset($config['id']);
unset($config['secret']);
break;
case 'Bitbucket':
case 'Flickr':
case 'SinaWeibo':
case 'Twitter':
case 'Vimeo':
$config['key'] = $config['id'];
unset($config['id']);
break;
case 'Disqus':
$config['api_key'] = $config['id'];
$config['api_secret'] = $config['secret'];
unset($config['id']);
unset($config['secret']);
break;
case 'LinkedIn':
$config['api_key'] = $config['id'];
|
php
|
{
"resource": ""
}
|
q263784
|
ResponseParser.parse
|
test
|
public function parse(\Opauth $opauth)
{
$callbackTransport = $opauth->env['callback_transport'];
switch($callbackTransport) {
case 'session':
$response = $_SESSION['opauth'];
unset($_SESSION['opauth']);
break;
case 'post':
$response = unserialize(base64_decode($_POST['opauth']));
break;
case 'get':
$response = unserialize(base64_decode($_GET['opauth']));
|
php
|
{
"resource": ""
}
|
q263785
|
ConnectController.loginAction
|
test
|
public function loginAction($strategy)
{
$config = $this->get('dcs_opauth.strategy_parser'
|
php
|
{
"resource": ""
}
|
q263786
|
View.render
|
test
|
public function render($path, $data = [])
{
$this->data = array_merge($this->data, $data);
$this->setPath($path);
|
php
|
{
"resource": ""
}
|
q263787
|
Validate.getAssetTypes
|
test
|
private function getAssetTypes()
{
$result = [];
$types = $this->daoTypeAsset->get();
/** @var ETypeAsset $type */
foreach ($types as $type) {
$typeId = $type->getId();
|
php
|
{
"resource": ""
}
|
q263788
|
ServerResponse.send
|
test
|
public function send()
{
if ($this->getProtocolVersion() && $this->getStatusCode()) {
header(static::VERSION_DELIMITER . $this->getProtocolVersion() . ' ' . $this->getStatusCode() . ' ' . $this->getReasonPhrase());
}
foreach ($this->getHeaders() as $key => $value)
|
php
|
{
"resource": ""
}
|
q263789
|
Authenticator.authenticate
|
test
|
public function authenticate($responseData)
{
$token = new
|
php
|
{
"resource": ""
}
|
q263790
|
VerifyApiToken.verifyToken
|
test
|
protected function verifyToken(Request $request)
{
$time = (int) ($request->input('_time') ?: $request->header('X-API-TIME'));
$token = $request->input('_token') ?: $request->header('X-API-TOKEN');
return abs(time() - $time) <
|
php
|
{
"resource": ""
}
|
q263791
|
Validator.validateDocUrl
|
test
|
public function validateDocUrl($url)
{
$pattern = '/http:\/\/docs\.google\.com\/spreadsheets\/d\/.*\/export\?format=csv/';
|
php
|
{
"resource": ""
}
|
q263792
|
ApiServiceProvider.registerClient
|
test
|
protected function registerClient()
{
$this->app->singleton('api.client', function ($app) {
$client = new Client(
$app['encrypter'],
$app['config']->get('api.clients', [])
);
|
php
|
{
"resource": ""
}
|
q263793
|
ApiServiceProvider.registerToken
|
test
|
protected function registerToken()
{
$this->app->singleton('api.token', function ($app) {
return new Token($app['api.client']);
|
php
|
{
"resource": ""
}
|
q263794
|
ApiServiceProvider.registerForConsole
|
test
|
protected function registerForConsole()
{
$this->publishes([
__DIR__.'/../config/api.php' => base_path('config/api.php'),
|
php
|
{
"resource": ""
}
|
q263795
|
Session.start
|
test
|
public static function start($name = null)
{
if (session_status() !== PHP_SESSION_NONE) {
throw new \RuntimeException('Can\'t start a new session.');
|
php
|
{
"resource": ""
}
|
q263796
|
TRetrospective.retrospect
|
test
|
protected final static function retrospect(string $name){
return call_user_func_array('array_merge',
|
php
|
{
"resource": ""
}
|
q263797
|
Response.setStatus
|
test
|
private function setStatus($statusCode, $reasonPhrase = '')
{
if ($reasonPhrase === '' && isset(self::$reasonPhrases[$statusCode])) {
$reasonPhrase = self::$reasonPhrases[$statusCode];
|
php
|
{
"resource": ""
}
|
q263798
|
Tokenizer.tree
|
test
|
public function tree($css) {
// Do stuff
$this->_tokens = $this->tokenize($css);
$results = $this->_parseTokens(array_shift($this->_tokens));
// Add remaining items to root element
while (count($this->_tokens)) {
if (!$this->ignoreErrors) {
$this->errors[]
|
php
|
{
"resource": ""
}
|
q263799
|
Tokenizer._findTokens
|
test
|
protected function _findTokens($tokens) {
$list = [];
foreach ($tokens as $token) {
$index = 0;
while (true) {
$index = strpos($this->_cssLC, $token, $index);
if ($index === false) {
break;
}
$list[] = [
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.