_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q8300
Manifest.delete
train
public function delete() { if ($this->files->exists($path = $this->manifestPath.'/collections.json')) { return $this->files->delete($path); } else { return false; } }
php
{ "resource": "" }
q8301
Builder.createTwigEnvironmentBuilder
train
public function createTwigEnvironmentBuilder() { $this->ensureCsrfTokenManagerAndTranslatorExist(); $builder = new TwigEnvironmentBuilder(); return $builder->setCsrfTokenManager($this->csrf_token_manager)->setTranslator($this->translator); }
php
{ "resource": "" }
q8302
FilesystemCleaner.cleanAll
train
public function cleanAll() { $collections = array_keys($this->environment->all()) + array_keys($this->manifest->all()); foreach ($collections as $collection) { $this->clean($collection); } }
php
{ "resource": "" }
q8303
FilesystemCleaner.clean
train
public function clean($collection) { $entry = $this->manifest->get($collection); // If the collection exists on the environment then we'll proceed with cleaning the filesystem // This removes any double-up production and development builds. if (isset($this->environment[$collection])...
php
{ "resource": "" }
q8304
FilesystemCleaner.cleanFilesystem
train
protected function cleanFilesystem(Collection $collection, Entry $entry) { $this->cleanProductionFiles($collection, $entry); $this->cleanDevelopmentFiles($collection, $entry); }
php
{ "resource": "" }
q8305
FilesystemCleaner.cleanManifestFiles
train
protected function cleanManifestFiles($collection, Entry $entry) { if ( ! $entry->hasProductionFingerprints() or ! isset($this->environment[$collection])) { $this->deleteMatchingFiles($this->buildPath.'/'.$collection.'-*.*'); $entry->resetProductionFingerprints(); } ...
php
{ "resource": "" }
q8306
FilesystemCleaner.cleanProductionFiles
train
protected function cleanProductionFiles(Collection $collection, Entry $entry) { foreach ($entry->getProductionFingerprints() as $fingerprint) { $wildcardPath = $this->replaceFingerprintWithWildcard($fingerprint); $this->deleteMatchingFiles($this->buildPath.'/'.$wildcardPath,...
php
{ "resource": "" }
q8307
FilesystemCleaner.cleanDevelopmentFiles
train
protected function cleanDevelopmentFiles(Collection $collection, Entry $entry) { foreach ($entry->getDevelopmentAssets() as $assets) { foreach ($assets as $asset) { $wildcardPath = $this->replaceFingerprintWithWildcard($asset); $this->deleteMa...
php
{ "resource": "" }
q8308
FilesystemCleaner.deleteMatchingFiles
train
protected function deleteMatchingFiles($wildcard, $ignored = null) { if (is_array($files = $this->files->glob($wildcard))) { foreach ($files as $path) { if ( ! is_null($ignored)) { // Spin through each of the ignored assets ...
php
{ "resource": "" }
q8309
ReadsJsonTrait.load
train
protected function load( $file ) { if ( ! file_exists( $file ) ) { throw new JsonFileNotFoundException( 'The required ' . basename( $file ) . ' file is missing.' ); } $contents = file_get_contents( $file ); $json = json_decode( $contents, true ); $json_error = json_last_error(); if ( $json_error !== JS...
php
{ "resource": "" }
q8310
ReadsJsonTrait.getAll
train
protected function getAll() { if ($this->cache === null) { $this->cache = $this->load( $this->getJsonPath() ); } return $this->cache; }
php
{ "resource": "" }
q8311
Coordinate.setLocation
train
public function setLocation(Coordinate $coordinate) { return $this->setX($coordinate->getX())->setY($coordinate->getY()); }
php
{ "resource": "" }
q8312
StringsAssertTrait.assertNotSameStrings
train
public static function assertNotSameStrings($expected, $actual, string $message = '') { self::assertStringsIdentity($actual, $message, __FUNCTION__, new LogicalNot(new SameStringsConstraint($expected))); }
php
{ "resource": "" }
q8313
StringsAssertTrait.assertSameStrings
train
public static function assertSameStrings($expected, $actual, string $message = '') { self::assertStringsIdentity($actual, $message, __FUNCTION__, new SameStringsConstraint($expected)); }
php
{ "resource": "" }
q8314
StringsAssertTrait.assertStringIsEmpty
train
public static function assertStringIsEmpty($actual, string $message = '') { AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertStringIsEmpty', ['assertThat', 'assertEmpty']); self::assertThat($actual, new IsType('string'), $message); self::assertEmpty($actual, $message); }
php
{ "resource": "" }
q8315
StringsAssertTrait.assertStringIsNotEmpty
train
public static function assertStringIsNotEmpty($actual, string $message = '') { AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertStringIsNotEmpty', ['assertThat', 'assertNotEmpty']); self::assertThat($actual, new IsType('string'), $message); self::assertNotEmpty($actual, $mes...
php
{ "resource": "" }
q8316
SlackService.exception
train
public function exception(\Exception $e) { $fields = []; $addToField = function($name, $value, $short = false) use (&$fields) { if (!empty($value)) { $fields[] = [ 'title' => $name, 'value' => $value, 'short' =>...
php
{ "resource": "" }
q8317
ClassLoader.addPath
train
private function addPath(& $list, $path, $namespace) { if ($namespace !== null) { $paths = [$namespace => $path]; } else { $paths = is_array($path) ? $path : ['' => $path]; } foreach ($paths as $ns => $directories) { $this->addNamespacePaths($list...
php
{ "resource": "" }
q8318
ClassLoader.addNamespacePaths
train
private function addNamespacePaths(& $list, $namespace, $paths) { $namespace = $namespace === '' ? '' : trim($namespace, '\\') . '\\'; if (!isset($list[$namespace])) { $list[$namespace] = []; } if (is_array($paths)) { $list[$namespace] = array_merge($list[$n...
php
{ "resource": "" }
q8319
ClassLoader.load
train
private function load($class) { if ($this->isLoaded($class)) { throw new \InvalidArgumentException(sprintf( "Error loading class '%s', the class already exists", $class )); } if ($file = $this->findFile($class)) { return $t...
php
{ "resource": "" }
q8320
ClassLoader.findFile
train
public function findFile($class) { return $this->finder->findFile($class, $this->prefixPaths, $this->basePaths, $this->useIncludePath); }
php
{ "resource": "" }
q8321
Routing.&
train
public function & SetOrCreateDefaultRouteAsCurrent ($routeName, $controllerPc, $actionPc, $fallbackCall = FALSE) { $controllerPc = strtr($controllerPc, '/', '\\'); $ctrlActionRouteName = $controllerPc.':'. $actionPc; $request = & $this->request; if (isset($this->routes[$ctrlActionRouteName])) { $defaultRoute...
php
{ "resource": "" }
q8322
Routing.queryStringRouting
train
protected function queryStringRouting ($requestCtrlName, $requestActionName) { $toolClass = self::$toolClass; list($ctrlDfltName, $actionDfltName) = $this->application->GetDefaultControllerAndActionNames(); $this->SetOrCreateDefaultRouteAsCurrent( \MvcCore\IRouter::DEFAULT_ROUTE_NAME, $toolClass::GetPascalC...
php
{ "resource": "" }
q8323
Routing.routeSetUpDefaultForHomeIfNoMatch
train
protected function routeSetUpDefaultForHomeIfNoMatch () { /** @var $this \MvcCore\Router */ if ($this->currentRoute === NULL) { $request = & $this->request; if ($this->routeToDefaultIfNotMatch) { $requestIsHome = ( trim($request->GetPath(), '/') == '' || $request->GetPath() == $request->GetScri...
php
{ "resource": "" }
q8324
Poll.hasVoted
train
public function hasVoted($user) { $votes = elgg_get_annotations(array( 'guid' => $this->guid, 'type' => "object", 'subtype' => "poll", 'annotation_name' => "vote", 'annotation_owner_guid' => $user->guid, 'limit' => 1 )); if ($votes) { return true; } else { return false; } }
php
{ "resource": "" }
q8325
Poll.deleteVotes
train
public function deleteVotes() { $access = elgg_set_ignore_access(true); $access_status = access_get_show_hidden_status(); access_show_hidden_entities(true); $river_items = new ElggBatch('elgg_get_river', array( 'action_type' => 'vote', 'object_guid' => $this->guid, 'limit' => false, 'wheres' => arr...
php
{ "resource": "" }
q8326
Poll.setChoices
train
public function setChoices(array $choices) { if (empty($choices)) { return false; } $this->deleteChoices(); // Ignore access (necessary in case a group admin is editing the poll of another group member) $ia = elgg_set_ignore_access(true); $i = 0; foreach ($choices as $choice) { $poll_choice = new...
php
{ "resource": "" }
q8327
Poll.updateChoices
train
public function updateChoices(array $choices, $former_access_id) { if (empty($choices)) { return false; } $choices_changed = false; $old_choices = $this->getChoices(); if (count($choices) != count($old_choices)) { $choices_changed = true; } else { $i = 0; foreach ($old_choices as $old_choice) ...
php
{ "resource": "" }
q8328
Poll.isOpen
train
public function isOpen() { if (empty($this->close_date)) { // There is no closing date so this poll is always open return true; } $now = time(); // input/date saves beginning of day and we want to include closing date day in poll $deadline = $this->close_date + 86400; return $deadline > $now; }
php
{ "resource": "" }
q8329
Poll.fetchResponses
train
private function fetchResponses() { if ($this->responses_by_choice) { return; } // Make sure choices without responses are included in the result foreach ($this->getChoices() as $choice) { $this->responses_by_choice[$choice->text] = 0; } // Get responses $responses = new ElggBatch('elgg_get_annota...
php
{ "resource": "" }
q8330
DoctrineObject.tryConvertArrayToObject
train
protected function tryConvertArrayToObject($data, $object) { $metadata = $this->metadata; $identifierNames = $metadata->getIdentifierFieldNames($object); $identifierValues = array(); if (empty($identifierNames)) { return $object; } foreach ($ide...
php
{ "resource": "" }
q8331
FactoryManager.createAssetDriver
train
public function createAssetDriver() { $asset = new AssetFactory($this->app['files'], $this->app['env'], $this->app['path.public']); return $this->factory($asset); }
php
{ "resource": "" }
q8332
FactoryManager.createFilterDriver
train
public function createFilterDriver() { $aliases = $this->app['config']->get('basset.aliases.filters', array()); $node = $this->app['config']->get('basset.node_paths', array()); $filter = new FilterFactory($aliases, $node, $this->app['env']); return $this->factory($filter); }
php
{ "resource": "" }
q8333
FactoryManager.factory
train
protected function factory(Factory $factory) { $factory->setLogger($this->getLogger()); return $factory->setFactoryManager($this); }
php
{ "resource": "" }
q8334
Assets.isExternalUrl
train
protected function isExternalUrl( $url, $home_url ) { $delimiter = '~'; $pattern_home_url = preg_quote( $home_url, $delimiter ); $pattern = $delimiter . '^' . $pattern_home_url . $delimiter . 'i'; return ! preg_match( $pattern, $url ); }
php
{ "resource": "" }
q8335
Assets.generateFileVersion
train
protected function generateFileVersion( $src ) { // Normalize both URLs in order to avoid problems with http, https // and protocol-less cases $src = $this->removeProtocol( $src ); $home_url = $this->removeProtocol( site_url( '/' ) ); $version = false; if ( ! $this->isExternalUrl( $src, $home_url ) ) { ...
php
{ "resource": "" }
q8336
Assets.getAssetUri
train
public function getAssetUri( $asset ) { // Path with unix-style slashes. $path = $this->manifest->get( $asset, '' ); if ( ! $path ) { return ''; } return $this->getThemeUri() . '/' . APP_DIST_DIR_NAME . '/' . $path; }
php
{ "resource": "" }
q8337
Assets.enqueueStyle
train
public function enqueueStyle( $handle, $src, $dependencies = [], $media = 'all' ) { wp_enqueue_style( $handle, $src, $dependencies, $this->generateFileVersion( $src ), $media ); }
php
{ "resource": "" }
q8338
Assets.enqueueScript
train
public function enqueueScript( $handle, $src, $dependencies = [], $in_footer = false ) { wp_enqueue_script( $handle, $src, $dependencies, $this->generateFileVersion( $src ), $in_footer ); }
php
{ "resource": "" }
q8339
Blendable.loadObject
train
protected function loadObject() { $this->xPDOSimpleObject = $this->modx->getObject($this->xpdo_simple_object_class, $this->getUniqueCriteria()); if (is_object($this->xPDOSimpleObject)) { $this->exists = true; $this->current_xpdo_simple_object_data = $this->xPDOSimpleObject->...
php
{ "resource": "" }
q8340
MelisPlatformIdsTable.getPlatformIdsByPlatformName
train
public function getPlatformIdsByPlatformName($platformName) { $select = $this->tableGateway->getSql()->select(); $select->columns(array('*')); $select->join('melis_core_platform', 'melis_core_platform.plf_id = melis_cms_platform_ids.pids_id', array('*')); $select->where("plf_name = '$platformName'"); $re...
php
{ "resource": "" }
q8341
MelisPlatformIdsTable.getLastPlatformRange
train
public function getLastPlatformRange() { $select = $this->tableGateway->getSql()->select(); $select->columns(array( 'pids_page_id_end_max' => new Expression('max(pids_page_id_end)'), 'pids_tpl_id_end_max' => new Expression('max(pids_tpl_id_end)'), ) ); ...
php
{ "resource": "" }
q8342
ClassFinder.findFile
train
public function findFile($class, array $prefixPaths, array $basePaths = [], $useIncludePath = false) { if ($file = $this->searchNamespaces($prefixPaths, $class, true)) { return $file; } $class = preg_replace('/_(?=[^\\\\]*$)/', '\\', $class); if ($file = $this->searchNa...
php
{ "resource": "" }
q8343
ClassFinder.searchNamespaces
train
private function searchNamespaces($paths, $class, $truncate) { foreach ($paths as $namespace => $directories) { $canonized = $this->canonizeClass($namespace, $class, $truncate); if ($canonized && $file = $this->searchDirectories($directories, $canonized)) { return $f...
php
{ "resource": "" }
q8344
ClassFinder.canonizeClass
train
private function canonizeClass($namespace, $class, $truncate) { $class = ltrim($class, '\\'); $namespace = (string) $namespace; $namespace = $namespace === '' ? '' : trim($namespace, '\\') . '\\'; if (strncmp($class, $namespace, strlen($namespace)) !== 0) { return false...
php
{ "resource": "" }
q8345
ClassFinder.searchDirectories
train
private function searchDirectories(array $directories, $class) { foreach ($directories as $directory) { $directory = trim($directory); $path = preg_replace('/[\\/\\\\]+/', DIRECTORY_SEPARATOR, $directory . '/' . $class); if ($directory && $file = $this->searchExtensions(...
php
{ "resource": "" }
q8346
ClassFinder.searchExtensions
train
private function searchExtensions($path) { foreach ($this->fileExtensions as $ext) { if (file_exists($path . $ext)) { return $path . $ext; } } return false; }
php
{ "resource": "" }
q8347
Asset.getBuildPath
train
public function getBuildPath() { $path = pathinfo($this->relativePath); $fingerprint = md5($this->filters->map(function($f) { return $f->getFilter(); })->toJson().$this->getLastModified()); return "{$path['dirname']}/{$path['filename']}-{$fingerprint}.{$this->getBuildExtension()}"; }
php
{ "resource": "" }
q8348
Asset.getLastModified
train
public function getLastModified() { if ($this->lastModified) { return $this->lastModified; } return $this->lastModified = $this->isRemote() ? null : $this->files->lastModified($this->absolutePath); }
php
{ "resource": "" }
q8349
Asset.getGroup
train
public function getGroup() { if ($this->group) { return $this->group; } return $this->group = $this->detectGroupFromExtension() ?: $this->detectGroupFromContentType(); }
php
{ "resource": "" }
q8350
Asset.detectGroupFromContentType
train
protected function detectGroupFromContentType() { if (extension_loaded('curl')) { $this->getLogger()->warning('Attempting to determine asset group using cURL. This may have a considerable effect on application speed.'); $handler = curl_init($this->absolutePath); ...
php
{ "resource": "" }
q8351
Asset.detectGroupFromExtension
train
protected function detectGroupFromExtension() { $extension = pathinfo($this->absolutePath, PATHINFO_EXTENSION); foreach (array('stylesheets', 'javascripts') as $group) { if (in_array($extension, $this->allowedExtensions[$group])) { return $group; ...
php
{ "resource": "" }
q8352
Asset.rawOnEnvironment
train
public function rawOnEnvironment() { $environments = array_flatten(func_get_args()); if (in_array($this->appEnvironment, $environments)) { return $this->raw(); } return $this; }
php
{ "resource": "" }
q8353
Asset.build
train
public function build($production = false) { $filters = $this->prepareFilters($production); $asset = new StringAsset($this->getContent(), $filters->all(), dirname($this->absolutePath), basename($this->absolutePath)); return $asset->dump(); }
php
{ "resource": "" }
q8354
Asset.prepareFilters
train
public function prepareFilters($production = false) { $filters = $this->filters->map(function($filter) use ($production) { $filter->setProduction($production); return $filter->getInstance(); }); return $filters->filter(function($filter) { return $filter inst...
php
{ "resource": "" }
q8355
InternalInits.initCli
train
protected function initCli () { $this->phpSapi = php_sapi_name(); $phpSapiCHasCli = FALSE; if (substr($this->phpSapi, 0, 3) === 'cli') { $this->phpSapi = 'cli'; $phpSapiCHasCli = TRUE; } $this->cli = FALSE; if ($phpSapiCHasCli && !isset($this->globalServer['REQUEST_URI'])) { $this->cli = TRUE; ...
php
{ "resource": "" }
q8356
Sidebar.getSidebarPostId
train
protected function getSidebarPostId() { $post_id = intval( get_the_ID() ); if ( $this->isBlog() ) { $post_id = intval( get_option( 'page_for_posts' ) ); } $post_id = intval( apply_filters( 'app_sidebar_context_post_id', $post_id ) ); return $post_id; }
php
{ "resource": "" }
q8357
Sidebar.getCurrentSidebarId
train
public function getCurrentSidebarId( $default = 'default-sidebar', $meta_key = '_app_custom_sidebar' ) { $post_id = $this->getSidebarPostId(); $sidebar = $default; if ( $post_id ) { $sidebar = get_post_meta( $post_id, $meta_key, true ); } if ( empty( $sidebar ) ) { $sidebar = $default; } return $...
php
{ "resource": "" }
q8358
MelisTreeService.getPageChildren
train
public function getPageChildren($idPage, $publishedOnly = 0) { if (empty($idPage)) return null; // Retrieve cache version if front mode to avoid multiple calls /* $cacheKey = 'getPageChildren_' . $idPage . '_' . $publishedOnly; $cacheConfig = 'engine_page_services'; ...
php
{ "resource": "" }
q8359
MelisTreeService.getPageFather
train
public function getPageFather($idPage, $type = 'published') { if (empty($idPage)) return null; // Retrieve cache version if front mode to avoid multiple calls $cacheKey = 'getPageFather_' . $idPage; $cacheConfig = 'engine_page_services'; $melisEngineCacheSystem = $th...
php
{ "resource": "" }
q8360
MelisTreeService.getPageBreadcrumb
train
public function getPageBreadcrumb($idPage, $typeLinkOnly = 1, $allPages = true) { if (empty($idPage)) return null; // Retrieve cache version if front mode to avoid multiple calls $cacheKey = 'getPageBreadcrumb_' . $idPage . '_' . $typeLinkOnly . '_' . $allPages; $cacheConfig...
php
{ "resource": "" }
q8361
MelisTreeService.cleanLink
train
public function cleanLink($link) { $link = strtolower(preg_replace( array('#[\\s-]+#', '#[^A-Za-z0-9/ -]+#'), array('-', ''), $this->cleanString(urldecode($link)) )); $link = preg_replace('/\/+/', '/', $link); $link = preg_replace('/-+/', '-', $link); return $link; }
php
{ "resource": "" }
q8362
MelisTreeService.getDomainByPageId
train
public function getDomainByPageId($idPage) { if (empty($idPage)) return null; // Retrieve cache version if front mode to avoid multiple calls $cacheKey = 'getDomainByPageId_' . $idPage; $cacheConfig = 'engine_page_services'; $melisEngineCacheSystem = $this->servic...
php
{ "resource": "" }
q8363
MelisTreeService.getSiteByPageId
train
public function getSiteByPageId($idPage) { if (empty($idPage)) return null; // Retrieve cache version if front mode to avoid multiple calls $cacheKey = 'getSiteByPageId_' . $idPage; $cacheConfig = 'engine_page_services'; $melisEngineCacheSystem = $this->serviceLocato...
php
{ "resource": "" }
q8364
MelisTreeService.getPrevNextPage
train
public function getPrevNextPage($idPage, $publishedOnly = 1) { $output = array( 'prev' => null, 'next' => null ); $melisPage = $this->getServiceLocator()->get('MelisEnginePage'); $datasPagePublished = $melisPage->getDatasPage($idPage, 'published'); $datasPagePublishedTree ...
php
{ "resource": "" }
q8365
HttpMessage.addHeader
train
public function addHeader(string $name, string $value) { $key = strtolower($name); $this->headerNames[$key] = $name; $this->headers[$key][] = $value; return $this; }
php
{ "resource": "" }
q8366
HttpMessage.getHeader
train
public function getHeader(string $name): string { $lines = $this->getHeaderLines($name); return implode(',', $lines); }
php
{ "resource": "" }
q8367
HttpMessage.getHeaders
train
public function getHeaders(): array { $result = []; foreach ($this->headers as $key => $lines) { $name = $this->headerNames[$key]; $result[$name] = $lines; } return $result; }
php
{ "resource": "" }
q8368
HttpMessage.parseHeaders
train
private function parseHeaders($headers): array { if (is_string($headers)) { $headers = explode("\r\n", $headers); } if (empty($headers)) { return []; } $result = []; foreach ($headers as $key => $line) { if (is_numeric($key)) { ...
php
{ "resource": "" }
q8369
HttpMessage.setHeader
train
public function setHeader(string $name, $value) { $key = strtolower($name); if ($value === null) { unset($this->headerNames[$key], $this->headers[$key]); } else { $this->headerNames[$key] = $name; $this->headers[$key] = (array)$value; } retur...
php
{ "resource": "" }
q8370
Gd.isGdFile
train
public static function isGdFile($filename) { if (!is_file($filename) || !is_readable($filename)) { throw new \InvalidArgumentException(sprintf( '"%s" Is Not A Readable File', $filename )); } $result = false; $f = null; if (($f = @fo...
php
{ "resource": "" }
q8371
Gd.partFromFile
train
public function partFromFile($file, Box $box) { $this->isValidFile($file); $this->assertGdFile($file); $x = $box->getX(); $y = $box->getY(); $width = $box->getWidth(); $height = $box->getHeight(); $result = @imagecreatefromgd2part($file, $x, $y, $width, $heigh...
php
{ "resource": "" }
q8372
MelisSiteDomainTable.getDataBySiteIdAndEnv
train
public function getDataBySiteIdAndEnv($siteId, $siteEnv) { $select = $this->tableGateway->getSql()->select(); $select->columns(array('*')); $select->where(array("sdom_site_id" => $siteId, 'sdom_env' => $siteEnv)); $resultSet = $this->tableGateway->selectWith($select); return...
php
{ "resource": "" }
q8373
MelisSiteDomainTable.getDataByEnv
train
public function getDataByEnv($siteEnv) { $select = $this->tableGateway->getSql()->select(); $select->columns(array('*')); $select->group('melis_cms_site_domain.sdom_env'); $select->where(array('sdom_env' => $siteEnv)); $resultSet = $this->tableGateway->selectWith($select); ...
php
{ "resource": "" }
q8374
MagicMethods.__isset
train
public function __isset ($name) { $store = & $this->__protected['store']; // if property is in view store - return it if (array_key_exists($name, $store)) return TRUE; // if property is not in view store - try to get it from controller and set it into local view store if ($controllerType = $this->getReflectio...
php
{ "resource": "" }
q8375
VGS_Client.getVerifiedEmails
train
public function getVerifiedEmails() { $emails = array(); try { $user = $this->api('/me'); if (isset($user['emails']) && is_array($user['emails']) && count($user['emails']) > 0) { foreach ($user['emails'] as $key => $value) { if (isset($value['v...
php
{ "resource": "" }
q8376
VGS_Client.isEmailVerified
train
public function isEmailVerified($email) { try { $user = $this->api('/user/'.$email); if (isset($user['emails']) && is_array($user['emails']) && count($user['emails']) > 0) { foreach ($user['emails'] as $key => $value) { if (isset($value['verified']) &&...
php
{ "resource": "" }
q8377
VGS_Client.refreshAccessToken
train
public function refreshAccessToken($refresh_token = null) { $return = array(); if ($refresh_token) { // todo get access_token via refresh_token request $params['client_id'] = $this->getClientID(); $params['client_secret'] = $this->getClientSecret(); $p...
php
{ "resource": "" }
q8378
VGS_Client.getFlowURI
train
public function getFlowURI($flow_name, array $params = array()) { if (empty($flow_name)) { throw new VGS_Client_Exception("Unspecified flow name"); } $default_params = array( 'client_id' => $this->getClientID(), 'response_type' => 'code', 'redirec...
php
{ "resource": "" }
q8379
VGS_Client.getPurchaseHistoryURI
train
public function getPurchaseHistoryURI($params = array()) { $default_params = array( 'client_id' => $this->getClientID(), 'response_type' => 'code', 'redirect_uri' => $this->getCurrentURI(), ); if ($this->xiti) { $default_params['xiti_json'] = $this...
php
{ "resource": "" }
q8380
VGS_Client.getApiURI
train
public function getApiURI($path = '', $params = array()) { if (!$path) { throw new Exception('Missing argument'); } return $this->getUrl('api', $path, array_merge(array('oauth_token' => $this->getAccessToken()),$params)); }
php
{ "resource": "" }
q8381
VGS_Client.getLogoutURI
train
public function getLogoutURI($params = array()) { $default_params = array( 'redirect_uri'=> $this->getCurrentURI(), 'oauth_token' => $this->getAccessToken() ); if ($this->xiti) { $default_params['xiti_json'] = $this->getXitiConfiguration(); } $...
php
{ "resource": "" }
q8382
VGS_Client.getLoginStatusUrl
train
public function getLoginStatusUrl($params = array()) { return $this->getUrl('www', 'login_status', array_merge(array( 'client_id' => $this->getClientID(), 'no_session' => $this->getCurrentURI(), 'no_user' => $this->getCurrentURI(), 'ok_session' ...
php
{ "resource": "" }
q8383
VGS_Client._restserver
train
protected function _restserver($path, $method = 'GET', $params = array(), $getParams = array()) { $this->container = null; if ($this->debug) { $start = microtime(true); } if (is_array($method) && empty($params)) { $params = $method; $method = 'GET'; } $get...
php
{ "resource": "" }
q8384
VGS_Client._oauthRequest
train
protected function _oauthRequest($uri, $params, $getParams = array()) { if ($this->debug) { $start = microtime(true); } if (!isset($getParams['oauth_token']) && isset($params['oauth_token'])) { $getParams['oauth_token'] = $params['oauth_token']; } if (!isset($getParams['oaut...
php
{ "resource": "" }
q8385
VGS_Client.recursiveHash
train
private function recursiveHash($data) { if (!is_array($data)) { return $data; } $ret = ""; uksort($data, 'strnatcmp'); foreach ($data as $v) { $ret .= $this->recursiveHash($v); } return $ret; }
php
{ "resource": "" }
q8386
VGS_Client.createHash
train
public function createHash($data) { $string = $this->recursiveHash($data); $secret = $this->getClientSignSecret(); return self::base64UrlEncode(hash_hmac("sha256", $string, $secret, true)); }
php
{ "resource": "" }
q8387
VGS_Client.validateAndDecodeSignedRequest
train
public function validateAndDecodeSignedRequest($encoded_signature, $payload, $algorithm = 'HMAC-SHA256') { $sig = self::base64UrlDecode($encoded_signature); switch ($algorithm) { case 'HMAC-SHA256' : $expected_sig = hash_hmac('sha256', $payload, $this->getClientSignSecret(),...
php
{ "resource": "" }
q8388
VGS_Client.getUrl
train
protected function getUrl($name, $path = '', $params = array()) { $uri = self::getBaseURL($name); if ($path) { if ($path[0] === '/') { $path = substr($path, 1); } $uri .= $path; } if ($params) { $uri .= '?' . http_build_quer...
php
{ "resource": "" }
q8389
VGS_Client.getCurrentURI
train
public function getCurrentURI($extra_params = array(), $drop_params = array()) { $drop_params = array_merge(self::$DROP_QUERY_PARAMS, $drop_params); $server_https = $this->_getServerParam('HTTPS'); $server_http_host = $this->_getServerParam('HTTP_HOST') ?: ''; $server_request_uri = $thi...
php
{ "resource": "" }
q8390
Container.set
train
public function set($id, \Closure $value) { $this->definitions[$id] = function ($container) use ($value) { static $object; if (is_null($object)) { $object = $value($container); } return $object; }; }
php
{ "resource": "" }
q8391
Rendering.RenderError
train
public function RenderError ($exceptionMessage = '') { if ($this->application->IsErrorDispatched()) return; throw new \ErrorException( $exceptionMessage ? $exceptionMessage : "Server error: `" . htmlspecialchars($this->request->GetFullUrl()) . "`.", 500 ); }
php
{ "resource": "" }
q8392
Rendering.renderGetViewScriptPath
train
protected function renderGetViewScriptPath ($controllerOrActionNameDashed = NULL, $actionNameDashed = NULL) { $currentCtrlIsTopMostParent = $this->parentController === NULL; if ($this->viewScriptsPath !== NULL) { $resultPathItems = [$this->viewScriptsPath]; if ($controllerOrActionNameDashed !== NULL) $resultP...
php
{ "resource": "" }
q8393
BassetServiceProvider.registerBladeExtensions
train
protected function registerBladeExtensions() : void { $blade = $this->app['view']->getEngineResolver()->resolve('blade')->getCompiler(); $blade->directive('javascripts', function($value){ return "<?php echo basset_javascripts($value); ?>"; }); $blade->directive('stylesheets', function($value){ return "<...
php
{ "resource": "" }
q8394
BassetServiceProvider.registerAssetFinder
train
protected function registerAssetFinder() : void { $this->app->singleton('basset.finder', function($app) { return new AssetFinder($app['files'], $app['config'], base_path() . '/resources/assets'); }); }
php
{ "resource": "" }
q8395
BassetServiceProvider.registerLogger
train
protected function registerLogger() : void { $this->app->singleton('basset.log', function($app) { return new Logger(new \Monolog\Logger('basset'), $app['events']); }); }
php
{ "resource": "" }
q8396
BassetServiceProvider.registerBuilder
train
protected function registerBuilder() : void { $this->app->singleton('basset.builder', function($app) { return new Builder($app['files'], $app['basset.manifest'], $app['basset.path.build']); }); $this->app->singleton('basset.builder.cleaner', function($app) { return new FilesystemCleaner($app['basset'], $ap...
php
{ "resource": "" }
q8397
Redirecting.redirect
train
protected function redirect ($url, $code = 301) { $app = \MvcCore\Application::GetInstance(); $app->GetResponse() ->SetCode($code) ->SetHeader('Location', $url); $app->Terminate(); }
php
{ "resource": "" }
q8398
UriRewriteFilter.filterDump
train
public function filterDump(AssetInterface $asset) { $this->assetDirectory = $this->realPath($asset->getSourceRoot()); $content = $asset->getContent(); // Spin through the symlinks and normalize them. We'll first unset the original // symlink so that it doesn't clash with the new sy...
php
{ "resource": "" }
q8399
Initializations.Init
train
public static function Init ($forceDevelopmentMode = NULL) { if (static::$debugging !== NULL) return; if (self::$strictExceptionsMode === NULL) self::initStrictExceptionsMode(self::$strictExceptionsMode); $app = static::$app ?: (static::$app = & \MvcCore\Application::GetInstance()); static::$requestBegi...
php
{ "resource": "" }