_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q237700
ParseEnvTrait.getReference
train
protected function getReference(/*# string */ $name) { // default value $default = $this->defaultValue($name); // found in environment if (false !== getenv($name)) { return getenv($name); } elseif (null !== $default) { return $default; // PHP...
php
{ "resource": "" }
q237701
ParseEnvTrait.matchGlobalVars
train
protected function matchGlobalVars(/*# string */ $name)/*# : string */ { if (false !== strpos($name, '.')) { list($n, $k) = explode('.', $name, 2); if (isset($GLOBALS[$n]) && isset($GLOBALS[$n][$k])) { return $GLOBALS[$n][$k]; } } return ''...
php
{ "resource": "" }
q237702
ParseEnvTrait.setEnv
train
protected function setEnv( /*# string */ $key, /*# string */ $val, /*# bool */ $overload ) { if ($overload || false === getenv($key)) { // set env putenv("$key=$val"); // also populate $_ENV $_ENV[$key] = $val; } }
php
{ "resource": "" }
q237703
Response.setGlob_step
train
public static function setGlob_step() { $project = $_POST['project_name']; $name = $_POST['dev_name']; // if (isset($_POST['ckeck_loggin'])) { $loggin = true; } else { $loggin = false; } // if (isset($_POST['ckeck_maintenance'])...
php
{ "resource": "" }
q237704
WasabiCms.page
train
public static function page($page = null) { if ($page !== null) { self::$_page = $page; } return self::$_page; }
php
{ "resource": "" }
q237705
WasabiCms.startPage
train
public static function startPage($page = null) { if ($page !== null) { self::$_startPage = $page; } return self::$_startPage; }
php
{ "resource": "" }
q237706
Renderer.getHint
train
protected function getHint() { // Map a new array with [group => namespace]. $groups = collect(config('flame'))->mapWithKeys(function ($item, $key) { return [$key => $item['namespace']]; }); //Map a new array only with namespaces. $namespaces = $groups->values();...
php
{ "resource": "" }
q237707
Renderer.getIntermediatePath
train
protected function getIntermediatePath($hint) { $namespace = config("flame.{$hint}.namespace"); $namespaceTail = substr($this->controllerNamespace(), strlen($namespace) + 1); return collect(explode('\\', $namespaceTail))->splice(0, -2)->implode('.'); }
php
{ "resource": "" }
q237708
WebDriver_Cache.createScreenshot
train
protected function createScreenshot() { $image = imagecreatefromstring($this->webDriver->screenshotAsImage()); if (false === $image) { throw new WebDriver_Exception("Invalid screenshot data"); } return $image; }
php
{ "resource": "" }
q237709
Logger.getBackend
train
public static function getBackend() { if(!is_object(self::$backend)) { self::$backend = new \Monolog\Logger(self::$name); self::$backend->pushHandler(self::getStreamHandler()); self::setLogFormat(self::$logFormat); } return self::$backend; }
php
{ "resource": "" }
q237710
Logger.setLogFormat
train
public static function setLogFormat($format) { self::$logFormat = $format; self::getStreamHandler()->setFormatter(new LineFormatter($format)); }
php
{ "resource": "" }
q237711
Logger.getStreamHandler
train
private static function getStreamHandler() { if(!is_object(self::$stream)) { self::$stream = new StreamHandler(self::$logFilePath, self::$minimumLevel); } return self::$stream; }
php
{ "resource": "" }
q237712
Logger.init
train
public static function init($path, $name = 'log', $minimumLevel = self::DEBUG) { if($path === 'php://output') { self::$active = true; } else if(is_writable($path)) { self::$active = true; } else { self::$active = fa...
php
{ "resource": "" }
q237713
Logger.log
train
public static function log($level, $message) { if(self::$active) { self::getBackend()->addRecord($level, $message); } }
php
{ "resource": "" }
q237714
Route.currentPath
train
public function currentPath($params = null, $withParams = true, array $queries = null) { $base = Base::instance(); return $this->build( $base['ALIAS'], ((array) $params) + ($withParams?$base['PARAMS']:[]), $queries ); }
php
{ "resource": "" }
q237715
Debug.isHtmlView
train
public static function isHtmlView() { if (self::$_isHtmlView === NULL) { self::$_isHtmlView = false; $view = Registry::get('view'); if ($view === NULL) { $template = ViewAbstract::getTemplateConfig(); if (is_array($template) ...
php
{ "resource": "" }
q237716
Debug.log
train
public static function log($pMessage) { if (is_array($pMessage) or is_object($pMessage)) { $message = json_encode($pMessage); } else { $message = (string)$pMessage; } $logId = mt_rand(); if (Agl::isInitialized()) { $message = '[agl_' . $l...
php
{ "resource": "" }
q237717
Debug.getInfos
train
public static function getInfos() { $xDebugEnabled = self::isXdebugEnabled(); $debugInfos = array(); $debugInfos['app']['path'] = APP_PATH; $debugInfos['app']['cache'] = Agl::app()->isCacheEnabled(); if ($xDebugEnabled) { $debugInfos['time'] = xdebug_time_...
php
{ "resource": "" }
q237718
permission.check
train
public static function check() { if (R::count("permission") < 1) { $role = R::dispense("permission"); $role->name = "guest"; R::store($role); } }
php
{ "resource": "" }
q237719
RenderExpressionTrait._render
train
protected function _render($context = null) { if ($context === null) { throw $this->_createInvalidArgumentException( $this->__('Cannot render with a null context'), null, null, $context ); } try { ...
php
{ "resource": "" }
q237720
Select.options2html
train
public static function options2html(array $options = [], $selectedValue = null){ // buffer prepared html codes $buffer = []; // loop options foreach ($options as $key => $value) { // make optgroup if(is_array($value)){ // turn optgroup optio...
php
{ "resource": "" }
q237721
RouteCacheCommand.getFreshApplicationRoutes
train
protected function getFreshApplicationRoutes() { $app = require $this->laravel->basePath().'/bootstrap/app.php'; $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap(); return $app['router']->getRoutes(); }
php
{ "resource": "" }
q237722
ThemeNavigation.registerNavigation
train
protected function registerNavigation() { do_action("before_theme_register_navigation"); foreach ($this->getConfig("navigation") as $name => $description): register_nav_menu($name, $description); endforeach; do_action("after_theme_register_navigation"); }
php
{ "resource": "" }
q237723
JQueryPluginManager.getRenderer
train
public function getRenderer() { $locator = $this->getServiceLocator(); if (null === $this->renderer && $locator->has(Renderer\RendererInterface::class)) { $this->setRenderer($locator->get(Renderer\RendererInterface::class)); } return $this->renderer; }
php
{ "resource": "" }
q237724
JQueryPluginManager.injectRenderer
train
public function injectRenderer($helper) { $renderer = $this->getRenderer(); if (null === $renderer) { return; } $helper->setView($renderer); }
php
{ "resource": "" }
q237725
JQueryPluginManager.injectTranslator
train
public function injectTranslator($helper) { if (!$helper instanceof TranslatorAwareInterface) { return; } $locator = $this->getServiceLocator(); if (!$locator) { return; } if ($locator->has('MvcTranslator')) { $helper->setTransla...
php
{ "resource": "" }
q237726
DirectoryStrategy.setDirPermissions
train
public function setDirPermissions($permissions) { if (! is_int($permissions)) { throw new InvalidArgumentException(sprintf( 'Invalid directory permissins provided; must be an ' . 'integer, "%s" received.', is_object($permissions) ? get_class($permi...
php
{ "resource": "" }
q237727
HtmlFormParser._getName
train
function _getName($string) { if (preg_match('/name=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $string, $match)) { //preg_match('/name=["\']?([\w\s]*)["\']?[\s>]/i', $string, $match)) { -- did not work as expected $val_match = trim($match[1]); $val_match = trim($val_match, '"\''); unset($string); r...
php
{ "resource": "" }
q237728
HtmlFormParser._getValue
train
function _getValue($string) { if (preg_match('/value=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $string, $match)) { $val_match = trim($match[1]); $val_match = trim($val_match, '"\''); unset($string); return $val_match; } return false; }
php
{ "resource": "" }
q237729
HtmlFormParser._getId
train
function _getId($string) { if (preg_match('/id=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $string, $match)) { //preg_match('/name=["\']?([\w\s]*)["\']?[\s>]/i', $string, $match)) { -- did not work as expected $val_match = trim($match[1]); $val_match = trim($val_match, '"\''); unset($string); retur...
php
{ "resource": "" }
q237730
HtmlFormParser._getClass
train
function _getClass($string) { if (preg_match('/class=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $string, $match)) { $val_match = trim($match[1]); $val_match = trim($val_match, '"\''); unset($string); return $val_match; } return false; }
php
{ "resource": "" }
q237731
QuoteRepository.beforeDelete
train
public function beforeDelete( $subject, \Magento\Quote\Api\Data\CartInterface $quote ) { $quoteId = $quote->getId(); $this->daoPartialQuote->deleteById($quoteId); return [$quote]; }
php
{ "resource": "" }
q237732
AbstractRequest.setParameter
train
public function setParameter($key, $value) { if (is_bool($value)) $value = ($value ? 'true' : 'false'); $this->parameters[$key] = $value; }
php
{ "resource": "" }
q237733
AbstractRequest.get
train
public function get() { // Include the API key into the request parameters. $this->appendApiKeyToRequestParameters(); // Create the query target. $target = $this->generateRequestTarget(); // Execute the request and return the parsed response. return $this->performGetRequest($target, $this->parameter...
php
{ "resource": "" }
q237734
AbstractRequest.performGetRequest
train
protected function performGetRequest($target, $parameters) { $response = $this->doGetRequest($target, $parameters); $result = $this->parseResponse($response); return $result; }
php
{ "resource": "" }
q237735
AbstractRequest.doGetRequest
train
private function doGetRequest($target, $parameters) { // Execute the GET request to the given target, along with the given parameters. $guzzle = $this->client->getGuzzle(); $response = $guzzle->get($target, ['query' => $parameters]); return $response; }
php
{ "resource": "" }
q237736
AbstractRequest.appendApiKeyToRequestParameters
train
private function appendApiKeyToRequestParameters() { if (! $this->client->getApiKey()) throw new AuthorizationException('Missing API key.'); $this->setParameter( Client::API_KEY_PARAM_NAME, $this->client->getApiKey() ); }
php
{ "resource": "" }
q237737
Mail.driver
train
public function driver($driver = '', array $configs = []) { $driverList = $this->defaultDriverList; if (isset($driverList[$driver])) { $driver = $driverList[$driver]; $driver = new $driver($configs); if ($driver instanceof DriverInterface) { retur...
php
{ "resource": "" }
q237738
Mail.send
train
public function send($name = '', callable $callback) { $configs = Config::get($name); $driver = $this->driver(isset($configs['driver']) ? $configs['driver']: 'swift', $configs); return $callback($driver); }
php
{ "resource": "" }
q237739
TemplateLayout.getAvailableTemplateLayouts
train
public function getAvailableTemplateLayouts($pageUid) { $templateLayouts = []; // Check if the layouts are extended by ext_tables if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['dvoconnector']['templateLayouts']) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['dvoconnector']['temp...
php
{ "resource": "" }
q237740
TemplateLayout.getTemplateLayoutsFromTsConfig
train
protected function getTemplateLayoutsFromTsConfig($pageUid) { $templateLayouts = []; $pagesTsConfig = BackendUtility::getPagesTSconfig($pageUid); if (isset($pagesTsConfig['tx_dvoconnector.']['templateLayouts.']) && is_array($pagesTsConfig['tx_dvoconnector.']['templateLayouts.'])) { ...
php
{ "resource": "" }
q237741
ProductRepository.findSameCategoryProduct
train
public function findSameCategoryProduct($product, $direction) { $qb = $this->getQueryBuilder() ->select('p') ->andWhere('p.category = :category') ->setMaxResults(1) ->setParameter('category', $product->getCategory()); if ('next' == $direction) { ...
php
{ "resource": "" }
q237742
ProductRepository.findNews
train
public function findNews($family, $limit = null) { $qb = $this->getQueryBuilder() ->orderBy('p.highlighted', 'desc') ->addOrderBy('p.createdAt', 'desc'); // filter by family if (!is_null($family)) { $qb->innerJoin('p.category', 'c') ->inne...
php
{ "resource": "" }
q237743
ProductRepository.findAttributeValues
train
public function findAttributeValues($product) { // select $qb = $this->getQueryBuilder() ->select('a.name attributeName, av.name, i.path imagePath'); // join $qb->join('p.attributeValues', 'av') ->join('av.attribute', 'a') ->leftJoin('av.image', '...
php
{ "resource": "" }
q237744
ProductRepository.getQueryProductsAssembly
train
public function getQueryProductsAssembly() { $category_id = $this->getEntityManager()->getRepository('EcommerceBundle:Category')->AssemblyCategory(); return $this->createQueryBuilder('p') ->where('p.category = :category_id') ->setParameter('category_id', $category_id); }
php
{ "resource": "" }
q237745
Compiler.start
train
private function start($message, $hook = true) { if (!isset($this->status)) $this->status = new \SplStack; if($hook) $this->applyHooks ('Pre', $message); $this->status->push([ microtime(true), $message, ]); if ($this->verbose >= 1) echo PHP_EOL, str_repeat("\t", $this->status->count() - 1)...
php
{ "resource": "" }
q237746
Compiler.rglob
train
protected final static function rglob($pattern, $flags = 0) { $files = glob($pattern, $flags); foreach (glob(dirname($pattern) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) $files = array_merge(self::rglob($dir . DIRECTORY_SEPARATOR . basename($pattern), $flags), $files); return $files; }
php
{ "resource": "" }
q237747
Compiler.readyDir
train
protected final static function readyDir($dir) { if(is_file($dir)) return false; if (!is_dir(dirname($dir))) return mkdir(dirname($dir), 0777, true); return true; }
php
{ "resource": "" }
q237748
Compiler.wipeDir
train
protected final static function wipeDir($dir, $rmdir = false) { if (file_exists($dir)) { $it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS); $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST); foreach ($files as $file) if ($file->isDir(...
php
{ "resource": "" }
q237749
Compiler.commandExists
train
private static function commandExists($command) { $whereIsCommand = (PHP_OS == 'WINNT') ? 'where' : 'which'; $process = proc_open("$whereIsCommand $command", [ 0 => array("pipe", "r"), //STDIN 1 => array("pipe", "w"), //STDOUT 2 => array("pipe", "w"), //STDERR ], $pipes); if ($process !== false) { ...
php
{ "resource": "" }
q237750
Compiler.checkBinaries
train
public static function checkBinaries(\Composer\Script\Event $event) { foreach (self::$binaries as $cmd) { if (!self::commandExists($cmd)) throw new \Exception('Binary "' . $cmd . '" not found in PATH'); // $event->getIO()->write($cmd . ' found.'); } }
php
{ "resource": "" }
q237751
Compiler.makeTpl
train
private function makeTpl() { $this->localTpl = rtrim($this->localTpl, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; $this->wipe[] = $output = self::path(sys_get_temp_dir()) . 'twigjs' . time() . DIRECTORY_SEPARATOR; self::readyDir($output); $data = array(); foreach (self::rglob($this->localTpl . '*.twig')...
php
{ "resource": "" }
q237752
Compiler.makeDoc
train
private function makeDoc() { //wipe destination directory manually $neon = file_get_contents($this->localDoc); $data = \Nette\Neon\Neon::decode($neon); $dest = $data['destination']; // wipe before and after self::wipeDir($dest, true); $this->wipe[] = $dest; return $this->runLocal([self::BIN . 'apige...
php
{ "resource": "" }
q237753
Compiler.sass
train
private function sass() { // get all sass dirs foreach ($this->localStatic[ __FUNCTION__ ] as $dir) { $this->start('Converting SASS to CSS in ' . $dir); foreach (glob($dir . DIRECTORY_SEPARATOR . '*.{scss,sass}', GLOB_BRACE) as $file) { //skip if partial $output = basename($file); if (substr($out...
php
{ "resource": "" }
q237754
Compiler.js
train
private function js() { foreach ($this->localStatic[ __FUNCTION__ ] as $jswip) { // r.js optimization if($this->compress) { $rjsBuild = $jswip .DIRECTORY_SEPARATOR. self::RJS_BUILD; if(is_file($rjsBuild)) { $this ->start('Optimizing '. self::RJS_BUILD .' with r.js') ->runLocal(['r.js.cmd...
php
{ "resource": "" }
q237755
Compiler.img
train
protected function img() { foreach ($this->localStatic[ __FUNCTION__ ] as $imgDir) { //if(is_file($imgDir . DIRECTORY_SEPARATOR . 'Thumbs.db')) // unlink($imgDir . DIRECTORY_SEPARATOR . 'Thumbs.db'); /* $this->start('Optimizing '. $imgDir) ->runLocal([ self::IMGMIN, '-o', 7, $imgDir,...
php
{ "resource": "" }
q237756
Compiler.runRemote
train
private function runRemote($command) { // make commands a list if (!is_array($command)) $command = array($command); $command = strval(implode(';', $command)); return $this->runLocal(['plink', '-ssh', // interacting method '-i', static::safeDir($this->ppk), // Private key file to access serv...
php
{ "resource": "" }
q237757
Compiler.runLocal
train
private function runLocal($command) { // make commands a list if (!is_array($command)) $command = array($command); $command = strval(implode(' ', $command)); // run if ($this->verbose >= 3) { echo "\n$ $command\n"; passthru($command); } else exec($command); return $this; }
php
{ "resource": "" }
q237758
Compiler.uploadStatic
train
protected function uploadStatic() { // copy to all destination folders foreach($this->remoteStatic as $type => $destDir) { // copy from all static if(isset($this->s3)) { foreach(self::rglob($this->tmp[ $type ] . '*') as $file) { $info = new \SplFileInfo($file); if($info->isDir() || !$in...
php
{ "resource": "" }
q237759
Compiler.setS3
train
public function setS3($key = null, $secret = null) { $this->s3 = new \S3($key, $secret); $this->setCompress(true); }
php
{ "resource": "" }
q237760
FstabLine.setFieldValue
train
public function setFieldValue($fieldName, $value) { if (isset($this->originalValues[$fieldName]) && $this->originalValues[$fieldName] === $value ) { # the given value is the same as the original value; # ignore any given value unset($this->givenValues[...
php
{ "resource": "" }
q237761
Alias.set
train
public static function set($enabled, $params) { $docs = self::documentations(); $content = $docs['enabled'].self::enbaledFormat($enabled); $content .= $docs['kernel'].self::arrayFormat($params['kernel'], 'kernel'); $content .= $docs['exceptions'].self::arrayFormat($params['exceptions...
php
{ "resource": "" }
q237762
Alias.setFile
train
protected static function setFile($content) { $root = Process::root; if (file_exists(Process::root.'config/alias.php')) { $file = fopen(Process::root.'config/alias.php', 'w'); fwrite($file, $content); fclose($file); // return true; ...
php
{ "resource": "" }
q237763
Alias.arrayFormat
train
protected static function arrayFormat(array $data, $name) { $format = "\t'$name' => [\n"; if (count($data) > 0) { foreach ($data as $key => $value) { $format .= "\t\t'$key' => $value::class , \n"; } } else { $format .= "\t\t//\n"; ...
php
{ "resource": "" }
q237764
DateTime.create
train
public static function create( int $year, int $month, int $day, int $hour, int $minute, int $second, ?string $timezone = null ): DateTime { $timezone = $timezone ?: date_default_timezone_get(); assert(Validate::isTimezone($timezone), sprintf('I...
php
{ "resource": "" }
q237765
DateTime.now
train
public static function now(?string $timezone = null): DateTime { $timezone = $timezone ?: date_default_timezone_get(); assert(Validate::isTimezone($timezone), sprintf('Invalid timezone: %s', $timezone)); $dateTime = new DateTimeImmutable('now', new DateTimeZone($timezone)); $year = ...
php
{ "resource": "" }
q237766
DateTime.withYear
train
public function withYear(int $year): DateTime { return new static( Date::create($year, $this->month(), $this->day()), $this->time(), $this->timezone() ); }
php
{ "resource": "" }
q237767
DateTime.withHour
train
public function withHour(int $hour): DateTime { return new static( $this->date(), Time::create($hour, $this->minute(), $this->second()), $this->timezone() ); }
php
{ "resource": "" }
q237768
DateTime.withTimezone
train
public function withTimezone($timezone): DateTime { return new static( $this->date(), $this->time(), Timezone::create($timezone) ); }
php
{ "resource": "" }
q237769
DateTime.localeFormat
train
public function localeFormat(string $format): string { // http://php.net/manual/en/function.strftime.php#refsect1-function.strftime-examples // Example #3 Cross platform compatible example using the %e modifier // @codeCoverageIgnoreStart if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'...
php
{ "resource": "" }
q237770
DateTime.modify
train
public function modify(string $modify): DateTime { $dateTime = $this->dateTime()->modify($modify); return static::fromNative($dateTime); }
php
{ "resource": "" }
q237771
DateTime.createNative
train
private static function createNative( int $year, int $month, int $day, int $hour, int $minute, int $second, string $timezone ): DateTimeImmutable { $time = sprintf('%04d-%02d-%02dT%02d:%02d:%02d', $year, $month, $day, $hour, $minute, $second); ...
php
{ "resource": "" }
q237772
Translit.get
train
public static function get( $string, $rule = 'Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();' ) { $trans = self::createTranslit( $rule ); $string = preg_replace( '/[-\s]+/', '-', $trans->transliterate( $string ) ); $out = trim( $string, '-' ); return $out; }
php
{ "resource": "" }
q237773
DataSelect.build
train
public function build() { foreach ($this->datasource as $index => $val) { $option = $this->createOption(); // inner will always be used $option->setInner($val); $option->setValue($this->index_is_value ? $index : $val); // in dependence of the da...
php
{ "resource": "" }
q237774
Structure.setRules
train
public function setRules( $rules ) { $this->rules = array(); foreach ( $rules as $rule ) { $this->addRule( $rule ); } return $this; }
php
{ "resource": "" }
q237775
Structure.addRule
train
public function addRule( $rule ) { if ( ! ( $rule instanceof RuleStructure ) ) { $rule = new RuleStructure( $rule ); } $this->rules[] = $rule; return $this; }
php
{ "resource": "" }
q237776
Structure.resetContents
train
public function resetContents() { $this->setImports( array() ) ->setRules( array() ); if ( $this->hasExtraContent() ) { $this->setExtraContent( null ); } return $this; }
php
{ "resource": "" }
q237777
Structure.render
train
public function render( $file = null, $eol = null ) { static $escape = array( '"' => '\\"' ); $renderer = AbstractRenderer::factory( $file, $eol ); $eol = $renderer->getEol(); $renderer->writeLine( '@charset "' . strtr( static::RENDER_CHARSET, $escape ) . '";' ...
php
{ "resource": "" }
q237778
UserTable.getColumns
train
public function getColumns() { $translationManager = $this->framework->getInstance('\\Zepi\\Core\\Language\\Manager\\TranslationManager'); return array( new Column('name', $translationManager->translate('Username', '\\Zepi\\Web\\AccessControl'), 50, true, true, Column::DATA_TYPE...
php
{ "resource": "" }
q237779
SeoBehavior.checkSeoAttributes
train
private function checkSeoAttributes() { $model = $this->owner; $transliterationFunction = $this->transliterationFunction; // if slug field is empty, filling one with generated slug if ($this->slugAttribute && $model->{$this->slugAttribute} == null) { $model->{$this->slug...
php
{ "resource": "" }
q237780
BaseController.create
train
public function create($request, $response, $args) { $params=$this->getCreateParams($request); if($this->createWithClientID){ $params['client_id']=$request->getAttribute('client_id'); } $validation= $this->validator->validateParams($params,$this->getValidation(0)); if($validation->failed()){ ...
php
{ "resource": "" }
q237781
AuthenticationListener.onAuthenticationSuccess
train
public function onAuthenticationSuccess(AuthenticationEvent $event) { if (!$this->config['admin_login']) { return; } $token = $event->getAuthenticationToken(); $userIsAdmin = $this->accessDecisionManager->decide($token, ['ROLE_ADMIN']); // Only for Admins and fu...
php
{ "resource": "" }
q237782
FlashSession.read
train
public function read() { parent::read(); if (isset($_SESSION[static::SESSION_NAME])) { $sess_table = $this->_uncrypt($_SESSION[static::SESSION_NAME]); if (isset($sess_table[static::SESSION_FLASHESNAME])) { $this->old_flashes = $sess_table[static::SESSION_FLASH...
php
{ "resource": "" }
q237783
FlashSession.getFlash
train
public function getFlash($index) { if ( ! $this->isOpened()) { $this->start(); } $_oldf = null; if (!empty($index) && isset($this->old_flashes[$index])) { $_oldf = $this->old_flashes[$index]; unset($this->old_flashes[$index]); return $_...
php
{ "resource": "" }
q237784
FlashSession.setFlash
train
public function setFlash($value, $index = null) { if ( ! $this->isOpened()) { $this->start(); } if (!empty($index)) { $this->flashes[$index] = $value; } else { $this->flashes[] = $value; } return $this; }
php
{ "resource": "" }
q237785
FlashSession.allFlashes
train
public function allFlashes() { if ( ! $this->isOpened()) { $this->start(); } if (!empty($this->old_flashes)) { $_oldf = $this->old_flashes; $this->old_flashes = array(); return $_oldf; } return null; }
php
{ "resource": "" }
q237786
FlashSession.clearFlashes
train
public function clearFlashes() { if ( ! $this->isOpened()) { $this->start(); } $this->flashes = array(); $this->old_flashes = array(); return $this; }
php
{ "resource": "" }
q237787
StatisticApi.addVisitor
train
public function addVisitor(UserInterface $user, Request $request) { $days = 30; $ip = $request->getClientIp(); $data = $this->getVisitors(); $date = new \DateTime(); $currTimestamp = $date->getTimestamp(); // entries should be only hourly $date->setTime($date...
php
{ "resource": "" }
q237788
CommandLocatorStrategy.get
train
public function get() { foreach ($this->_commands as $command) { $location = $this->_commandLocator->locate(basename($command)); if ($location !== null) { return $location; } } return null; }
php
{ "resource": "" }
q237789
FormDataDecoder.readUntil
train
protected function readUntil($search) { while (($position = strpos($this->buffer, $search)) === false) { if (feof($this->fp)) { fclose($this->fp); throw new DecodeException( "Invalid multipart data encountered; " . "end of c...
php
{ "resource": "" }
q237790
FormDataDecoder.addValue
train
protected function addValue(&$fieldsArray, $name, $value) { $arrayCheck = substr($name, -2); if ($arrayCheck == '[]') { $nameSubstr = substr($name, 0, -2); if (!isset($fieldsArray[$nameSubstr])) $fieldsArray[$nameSubstr] = []; $fieldsArray[$nameS...
php
{ "resource": "" }
q237791
UserOptionTrait.getUserOption
train
public function getUserOption($option, $defaultValue=null) { return isset($this->_options[$option]) ? $this->_options[$option] : $defaultValue; }
php
{ "resource": "" }
q237792
UserOptionTrait._setDefaultUserOptions
train
protected function _setDefaultUserOptions(array $options) { foreach ($options as $option=>$value) { if (!$this->getUserOption($option)) $this->setUserOption($option,$value); } return $this; }
php
{ "resource": "" }
q237793
Gateway.city
train
public function city() { $requestParams = $this->initRequestParams('city'); $this->request('city', $requestParams); return empty($this->error); }
php
{ "resource": "" }
q237794
Gateway.fee
train
public function fee($cityId, $orderAmount) { $params = compact('cityId', 'orderAmount'); $requestParams = $this->initRequestParams('fee', $params); $this->request('fee', $requestParams); return empty($this->error); }
php
{ "resource": "" }
q237795
Gateway.getFeeValue
train
public function getFeeValue($cityId, $orderAmount) { $result = $this->fee($cityId, $orderAmount); if (!$result) { dd($this->getResultRaw()); return null; } return $this->getResultFeeValue(); }
php
{ "resource": "" }
q237796
Gateway.status
train
public function status($orderCode, $toNumber) { $params = compact('orderCode', 'toNumber'); $requestParams = $this->initRequestParams('status', $params); $this->request('status', $requestParams); return empty($this->error); }
php
{ "resource": "" }
q237797
Gateway.request
train
private function request($type, $requestParams) { $this->cleanup(); $curl = new Curl(); $curl->setCheckCertificates($this->configParams['strongSSL']); $curl->post($this->configParams['gatewayUrl'], array( 'type' => $type, 'input' => $requestParams, )); $this->parseErrors($curl); if (!$this->err...
php
{ "resource": "" }
q237798
Gateway.parseErrors
train
private function parseErrors(Curl $curl) { $this->rawResponse = $curl->result; if ($curl->error) { $this->error = array( 'type' => self::C_ERROR_HTTP, 'message' => 'Curl error: ' . $curl->error, ); return; } if ($curl->code != '200') { $this->error = array( 'type' => self::C_E...
php
{ "resource": "" }
q237799
Xml2Object.simpleArrayToObject
train
public static function simpleArrayToObject($array, $object = null) { foreach ($array as $key => $value) { $object->$key = $value; } return $object; }
php
{ "resource": "" }