_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])) { $this->cleanFilesystem($this->environment[$collection], $entry); } // If the collection does not exist on the environment then we'll instrcut the manifest to // forget this collection. else { $this->manifest->forget($collection); } // Cleaning the manifest is important as it will also remove unnecessary files from the // filesystem if a collection has been removed. $this->cleanManifestFiles($collection, $entry); $this->manifest->save(); }
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(); } if ( ! $entry->hasDevelopmentAssets() or ! isset($this->environment[$collection])) { $this->files->deleteDirectory($this->buildPath.'/'.$collection); $entry->resetDevelopmentAssets(); } }
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, $fingerprint); } }
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->deleteMatchingFiles($this->buildPath.'/'.$collection->getIdentifier().'/'.$wildcardPath, array_values($assets)); } } }
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 and if the current file path ends // with any of the ignored asset paths then we'll skip this asset as it // needs to be kept. foreach ((array) $ignored as $ignore) { if (ends_with($path, $ignore)) continue 2; } } $this->files->delete($path); } } }
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 !== JSON_ERROR_NONE ) { throw new JsonFileInvalidException( 'The required ' . basename( $file ) . ' file is not valid JSON (error code ' . $json_error . ').' ); } return $json; }
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, $message); }
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' => $short, ]; } }; $addToField('Environment', app()->environment(), true); $addToField('Exception', get_class($e), true); $addToField( 'Http code', $e instanceof \Symfony\Component\HttpKernel\Exception\HttpException ? $e->getStatusCode() : 500, true ); $addToField('Code', $e->getCode(), true); $addToField('File', $e->getFile(), true); $addToField('Line', $e->getLine(), true); $addToField('Request url', request()->url(), true); $addToField('Request method', request()->method(), true); $addToField('Request param', json_encode(request()->all()), true); $message = ':bug: Error Occurs on '.app()->environment(); $type = 'serious-alert'; $pretext = 'Error Occurs on '.app()->environment(); $attachment = [ 'color' => 'danger', 'title' => $e->getMessage(), 'fallback' => !empty($e->getMessage()) ? $e->getMessage() : get_class($e), 'pretext' => $pretext, 'fields' => $fields, 'text' => $e->getTraceAsString(), ]; // notify to slack $this->post($message, $type, $attachment); }
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, ltrim($ns, '0..9'), $directories); } }
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[$namespace], $paths); } else { $list[$namespace][] = $paths; } }
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 $this->loadFile($file, $class); } return false; }
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 = $this->routes[$ctrlActionRouteName]; } else if (isset($this->routes[$routeName])) { $defaultRoute = $this->routes[$routeName]; } else { $routeClass = self::$routeClass; $pathParamName = static::URL_PARAM_PATH; $defaultRoute = $routeClass::CreateInstance() ->SetMatch("#/(?<$pathParamName>.*)#") ->SetReverse("/<$pathParamName>") ->SetName($routeName) ->SetController($controllerPc) ->SetAction($actionPc) ->SetDefaults([ $pathParamName => NULL, static::URL_PARAM_CONTROLLER => NULL, static::URL_PARAM_ACTION => NULL, ]); $anyRoutesConfigured = $this->anyRoutesConfigured; $this->AddRoute($defaultRoute, NULL, TRUE, FALSE); $this->anyRoutesConfigured = $anyRoutesConfigured; if (!$request->IsInternalRequest()) $request->SetParam(static::URL_PARAM_PATH, ($request->HasParam(static::URL_PARAM_PATH) ? $request->GetParam(static::URL_PARAM_PATH, '.*') : $request->GetPath()) ); } $toolClass = self::$toolClass; $request ->SetControllerName(str_replace('\\', '/', $toolClass::GetDashedFromPascalCase($defaultRoute->GetController()) )) ->SetActionName( $toolClass::GetDashedFromPascalCase($defaultRoute->GetAction()) ); $this->currentRoute = $defaultRoute; if (!$fallbackCall) $this->selfRouteName = $routeName; return $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::GetPascalCaseFromDashed($requestCtrlName ?: $ctrlDfltName), $toolClass::GetPascalCaseFromDashed($requestActionName ?: $actionDfltName) ); // default params are merged with previous default params to have // possibility to add domain params by extended module router $this->defaultParams = array_merge([], $this->defaultParams, $this->request->GetParams(FALSE)); $this->requestedParams = array_merge([], $this->defaultParams); }
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->GetScriptName() ); if ($requestIsHome) { list($dfltCtrl, $dftlAction) = $this->application->GetDefaultControllerAndActionNames(); $this->SetOrCreateDefaultRouteAsCurrent( static::DEFAULT_ROUTE_NAME, $dfltCtrl, $dftlAction ); // set up requested params from query string if there are any // (and path if there is path from previous function) $requestParams = array_merge([], $this->request->GetParams(FALSE)); unset($requestParams[static::URL_PARAM_CONTROLLER], $requestParams[static::URL_PARAM_ACTION]); $this->requestedParams = & $requestParams; } } } return $this; }
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' => array("rv.view = \"river/object/poll/vote\""), )); $river_items->setIncrementOffset(false); foreach ($river_items as $river_item) { $river_item->delete(); } access_show_hidden_entities($access_status); elgg_set_ignore_access($access); elgg_delete_annotations(array( 'guid' => $this->guid, 'type' => "object", 'subtype' => "poll", 'annotation_name' => "vote", )); $this->responses_by_choice = array(); $this->response_count = 0; $this->voter_count = 0; }
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 ElggObject(); $poll_choice->owner_guid = $this->owner_guid; $poll_choice->container_guid = $this->container_guid; $poll_choice->subtype = "poll_choice"; $poll_choice->text = $choice; $poll_choice->display_order = $i*10; $poll_choice->access_id = $this->access_id; $poll_choice->save(); add_entity_relationship($poll_choice->guid, 'poll_choice', $this->guid); $i += 1; } elgg_set_ignore_access($ia); }
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) { if ($old_choice->text != $choices[$i]) { $choices_changed = true; } $i += 1; } } if ($choices_changed) { $this->deleteVotes(); $this->setChoices($choices); } else if ($former_access_id != $this->access_id) { $this->updateChoicesAccessID(); } return $choices_changed; }
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_annotations', array( 'guid' => $this->guid, 'annotation_name' => 'vote', 'limit' => false, )); $users = array(); // Cache the amount of results for each choice foreach ($responses as $response) { $users[] = $response->owner_guid; $this->responses_by_choice[$response->value] += 1; } $this->voter_count = count(array_unique($users)); // Cache the total amount of responses $this->response_count = array_sum($this->responses_by_choice); }
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 ($identifierNames as $identifierName) { if (!isset($data[$identifierName])) { return $object; } $identifierValues[$identifierName] = $data[$identifierName]; } return $this->find($identifierValues, $metadata->getName()); }
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 ) ) { // Generate the absolute path to the file $file_path = str_replace( [$home_url, '/'], [ABSPATH, DIRECTORY_SEPARATOR], $src ); if ( file_exists( $file_path ) ) { // Use the last modified time of the file as a version $version = filemtime( $file_path ); } } return $version; }
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->toArray(); $this->loadFromArray($this->current_xpdo_simple_object_data); // load related data: $this->loadRelatedData(); } return $this; }
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'"); $resultSet = $this->tableGateway->selectWith($select); return $resultSet; }
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)'), ) ); $resultSet = $this->tableGateway->selectWith($select); return $resultSet; }
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->searchNamespaces($basePaths, $class, false)) { return $file; } elseif ($useIncludePath) { return $this->searchDirectories(explode(PATH_SEPARATOR, get_include_path()), $class); } return false; }
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 $file; } } return false; }
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; } return $truncate ? substr($class, strlen($namespace)) : $class; }
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($path)) { return $file; } } return false; }
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); curl_setopt($handler, CURLOPT_RETURNTRANSFER, true); curl_setopt($handler, CURLOPT_FOLLOWLOCATION, true); curl_setopt($handler, CURLOPT_HEADER, true); curl_setopt($handler, CURLOPT_NOBODY, true); curl_setopt($handler, CURLOPT_SSL_VERIFYPEER, false); curl_exec($handler); if ( ! curl_errno($handler)) { $contentType = curl_getinfo($handler, CURLINFO_CONTENT_TYPE); return starts_with($contentType, 'text/css') ? 'stylesheets' : 'javascripts'; } } }
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 instanceof FilterInterface; }); }
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; $hostName = gethostname(); $this->scheme = 'file:'; $this->secure = FALSE; $this->hostName = $hostName; $this->host = $hostName; $this->port = ''; $this->path = ''; $this->query = ''; $this->fragment = ''; $this->ajax = FALSE; $this->basePath = ''; $this->requestPath = ''; $this->domainUrl = ''; $this->baseUrl = ''; $this->requestUrl = ''; $this->fullUrl = ''; $this->referer = ''; $this->serverIp = '127.0.0.1'; $this->clientIp = $this->serverIp; $this->contentLength = 0; $this->headers = []; $this->params = []; $this->appRequest = FALSE; $this->method = 'GET'; // sometimes `$_SERVER['SCRIPT_FILENAME']` is missing, when script // is running in CLI or it could have relative path only $backtraceItems = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); $indexFilePath = str_replace('\\', '/', $backtraceItems[count($backtraceItems) - 1]['file']); $lastSlashPos = mb_strrpos($indexFilePath, '/'); $this->appRoot = mb_substr($indexFilePath, 0, $lastSlashPos); $this->scriptName = mb_substr($indexFilePath, $lastSlashPos); $args = $this->globalServer['argv']; array_shift($args); $params = []; if ($args) { foreach ($args as $arg) { parse_str($arg, $paramsLocal); if (!$paramsLocal) continue; foreach ($paramsLocal as $paramName => $paramValue) { if (is_array($paramValue)) { $params = array_merge( $params, [$paramName => array_merge( $params[$paramName] ?: [], $paramValue )] ); } else { $params[$paramName] = $paramValue; } } } } $this->params = $params; $this->globalGet = $params; } }
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 $sidebar; }
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'; $melisEngineCacheSystem = $this->serviceLocator->get('MelisEngineCacheSystem'); $results = $melisEngineCacheSystem->getCacheByKey($cacheKey, $cacheConfig); if (!empty($results)) return $results; */ $tablePageTree = $this->getServiceLocator()->get('MelisEngineTablePageTree'); $datasPage = $tablePageTree->getPageChildrenByidPage($idPage, $publishedOnly); // Save cache key /* $melisEngineCacheSystem->setCacheByKey($cacheKey, $cacheConfig, $datasPage); */ return $datasPage; }
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 = $this->serviceLocator->get('MelisEngineCacheSystem'); $results = $melisEngineCacheSystem->getCacheByKey($cacheKey, $cacheConfig); if (!empty($results)) return $results; $tablePageTree = $this->getServiceLocator()->get('MelisEngineTablePageTree'); $datasPage = $tablePageTree->getFatherPageById($idPage, $type); // Save cache key $melisEngineCacheSystem->setCacheByKey($cacheKey, $cacheConfig, $datasPage); return $datasPage; }
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 = 'engine_page_services'; $melisEngineCacheSystem = $this->serviceLocator->get('MelisEngineCacheSystem'); $results = $melisEngineCacheSystem->getCacheByKey($cacheKey, $cacheConfig); if (!empty($results)) return $results; $results = array(); $tmp = $idPage; $melisPage = $this->getServiceLocator()->get('MelisEnginePage'); $datasPageRes = $melisPage->getDatasPage($idPage); $datasPageTreeRes = $datasPageRes->getMelisPageTree(); if (!empty($datasPageTreeRes)) { if ($datasPageTreeRes->page_status == 1 || $allPages) { if ($typeLinkOnly && $datasPageTreeRes->page_menu != 'NONE') array_push($results, $datasPageTreeRes); if (!$typeLinkOnly) array_push($results, $datasPageTreeRes); } } else return array(); while ($tmp != -1) { $datasPageFatherRes = $this->getPageFather($tmp); $datas = $datasPageFatherRes->current(); if (!empty($datas)) { $tmp = $datas->tree_father_page_id; unset($datas->tree_page_id); unset($datas->tree_father_page_id); unset($datas->tree_page_order); $datas->tree_page_id = $tmp; if ($datasPageTreeRes->page_status == 1|| $allPages) { if ($typeLinkOnly && $datas->page_menu != 'NONE') array_push($results, $datas); if (!$typeLinkOnly) array_push($results, $datas); } } else break; } krsort($results); // Save cache key $melisEngineCacheSystem->setCacheByKey($cacheKey, $cacheConfig, $results); return $results; }
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->serviceLocator->get('MelisEngineCacheSystem'); $results = $melisEngineCacheSystem->getCacheByKey($cacheKey, $cacheConfig); if (!empty($results)) return $results; $domainStr = ''; $melisPage = $this->getServiceLocator()->get('MelisEnginePage'); $datasPage = $melisPage->getDatasPage($idPage); $datasTemplate = $datasPage->getMelisTemplate(); if (!empty($datasTemplate) && !empty($datasTemplate->tpl_site_id)) { $melisEngineTableSite = $this->getServiceLocator()->get('MelisEngineTableSite'); $datasSite = $melisEngineTableSite->getSiteById($datasTemplate->tpl_site_id, getenv('MELIS_PLATFORM')); if ($datasSite) { $datasSite = $datasSite->current(); if (!empty($datasSite)) { $scheme = 'http'; if (!empty($datasSite->sdom_scheme)) $scheme = $datasSite->sdom_scheme; $domain = $datasSite->sdom_domain; if ($domain != '') $domainStr = $scheme . '://' . $domain; } } } // Save cache key $melisEngineCacheSystem->setCacheByKey($cacheKey, $cacheConfig, $domainStr); return $domainStr; }
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->serviceLocator->get('MelisEngineCacheSystem'); $results = $melisEngineCacheSystem->getCacheByKey($cacheKey, $cacheConfig); if (!empty($results)) return $results; $datasSite = null; $melisPage = $this->getServiceLocator()->get('MelisEnginePage'); $datasPage = $melisPage->getDatasPage($idPage); $datasTemplate = $datasPage->getMelisTemplate(); if (!empty($datasTemplate) && !empty($datasTemplate->tpl_site_id)) { $melisEngineTableSite = $this->getServiceLocator()->get('MelisEngineTableSite'); $datasSite = $melisEngineTableSite->getSiteById($datasTemplate->tpl_site_id, getenv('MELIS_PLATFORM')); if ($datasSite) { $datasSite = $datasSite->current(); } } // Save cache key $melisEngineCacheSystem->setCacheByKey($cacheKey, $cacheConfig, $datasSite); return $datasSite; }
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 = $datasPagePublished->getMelisPageTree(); $melisTree = $this->getServiceLocator()->get('MelisEngineTree'); $sisters = $melisTree->getPageChildren($datasPagePublishedTree->tree_father_page_id, $publishedOnly); $sisters = $sisters->toArray(); if(!empty($sisters)) { // Get column list for sort foreach ($sisters as $key => $row) { $order[$key] = $row['tree_page_order']; } // Sort sisters pages by order field array_multisort($order, SORT_ASC, $sisters); $posInArray = false; foreach($sisters as $key => $uneSister) { if($uneSister['tree_page_id'] == $datasPagePublishedTree->tree_page_id) $posInArray = $key; } // If page found, get prev/next if($posInArray !== false) { $posPrevPage = (($posInArray-1) >= 0) ? ($posInArray-1) : null; $posNextPage = (($posInArray+1) && array_key_exists($posInArray+1, $sisters)) ? ($posInArray+1) : null; if(!is_null($posPrevPage)) { $prevItem = $sisters[$posPrevPage]; $prevLink = $melisTree->getPageLink($sisters[$posPrevPage]['tree_page_id']); // Check if page have a name and link if(!empty($prevItem['page_name']) && !empty($prevLink)) { $output['prev'] = $prevItem; $output['prev']['link'] = $prevLink; } } if(!is_null($posNextPage)) { $nextItem = $sisters[$posNextPage]; $nextLink = $melisTree->getPageLink($sisters[$posNextPage]['tree_page_id']); // Check if page have a name and link if(!empty($nextItem['page_name']) && !empty($nextLink)) { $output['next'] = $nextItem; $output['next']['link'] = $nextLink; } } } } return $output; }
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)) { if (strpos($line, 'HTTP/') === 0) { // Strip the status line and restart. $result = []; continue; } elseif (strstr($line, ': ')) { list($key, $line) = explode(': ', $line); } else { continue; } } if (is_array($line)) { $result[$key] = array_merge($result[$key] ?? [], $line); } else { $result[$key][] = $line; } } return $result; }
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; } return $this; }
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 = @fopen($filename, 'r'))) { if (($id = @fread($f, 3))) { $result = ('gd2' === strtolower($id)) ? true : false; } } @fclose($f); return $result; }
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, $height); if (false == $result) { throw new CanvasCreationException(sprintf( 'Faild To Create The Part "%s" Of The Gd Canvas From The File "%s"' , $file, (string) $box )); } $this->setHandler($result); return $this; }
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 $resultSet; }
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); return $resultSet; }
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->getReflectionClass('controller')) { if ($controllerType->hasProperty($name)) { /** @var $property \ReflectionProperty */ $property = $controllerType->getProperty($name); if (!$property->isStatic()) { if (!$property->isPublic()) $property->setAccessible (TRUE); // protected or private $value = $property->getValue($this->controller); $store[$name] = & $value; return TRUE; } } } // property is not in local store and even in controller instance, return `FALSE` return FALSE; }
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['verified']) && $value['verified'] == true) { $emails[] = $value['value']; } } } } catch (VGS_Client_Exception $e) { self::errorLog('Exception thrown when getting logged in user:'. $e->getMessage()); } return $emails; }
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']) && $value['verified'] == true && $value['value'] == $email) { return true; } } } } catch (VGS_Client_Exception $e) { self::errorLog('Exception thrown when getting logged in user:'. $e->getMessage()); } return false; }
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(); $params['redirect_uri'] = $this->getRedirectUri(); $params['grant_type'] = 'refresh_token'; $params['scope'] = ''; $params['state'] = ''; $params['refresh_token'] = $refresh_token; $return = (array) json_decode($this->makeRequest($this->getTokenURL(), $params)); } if (is_array($return) && isset($return['access_token'])) { $this->session = $return; if (isset($return['access_token'])) { $this->setAccessToken($return['access_token']); } if (isset($return['refresh_token'])) { $this->setRefreshToken($return['refresh_token']); } } else { // No success! Defaults to $this->setAccessToken($this->getClientID()); } return $this->getAccessToken(); }
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', 'redirect_uri' => $this->getCurrentURI(), ); if ($this->xiti) { $default_params['xiti_json'] = $this->getXitiConfiguration(); } $default_params['v'] = self::VERSION; $parameters = array_merge($default_params, $params); return $this->getUrl('flow', $flow_name, $parameters); }
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->getXitiConfiguration(); } $default_params['v'] = self::VERSION; return $this->getUrl('www', 'account/purchasehistory', array_merge($default_params, $params)); }
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(); } $default_params['v'] = self::VERSION; return $this->getUrl('www', 'logout', array_merge($default_params, $params)); }
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' => $this->getCurrentURI(), 'session_version' => 1), $params)); }
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'; } $getParams['method'] = $method; // method override as we always do a POST $uri = $this->getUrl('api', $path); $result = $this->_oauthRequest($uri, $params, $getParams); if (floatval($this->api_version) >= 2) { $container = json_decode($result, true); if ($container && array_key_exists('name', $container) && $container['name'] == 'SPP Container') { $this->container = $container; } } preg_match("/\.(json|jsonp|html|xml|serialize|php|csv|tgz)$/", $path, $matches); if ($matches) { switch ($matches[1]) { case 'json': $result = json_decode($result, true); break; default: if ($this->debug) { $this->timer[__FUNCTION__]['elapsed'][] = microtime(true)-$start; } return $result; break; } } else $result = json_decode($result, true); // results are returned, errors are thrown if (is_array($result) && isset($result['error']) && $result['error']) { $e = new VGS_Client_Exception($result, $this->raw); switch ($e->getType()) { case 'ApiException': break; // OAuth 2.0 Draft 00 style case 'OAuthException': // OAuth 2.0 Draft 10 style case 'invalid_token': $this->setSession(null); } throw $e; } if (floatval($this->api_version) >= 2 && $result && is_array($result) && array_key_exists('name', $result) && $result['name'] == 'SPP Container') { if (isset($result['sig']) && isset($result['algorithm'])) { $result = $this->validateAndDecodeSignedRequest($result['sig'], $result['data'], $result['algorithm']); } else { $result = $result['data']; } } if ($this->debug) { $this->timer[__FUNCTION__]['elapsed'][] = microtime(true)-$start; } return $result; }
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['oauth_token'])) { $getParams['oauth_token'] = $this->getAccessToken(); } // json_encode all params values that are not strings foreach ((array)$params as $key => $value) { if (!is_string($value)) { $params[$key] = json_encode($value); } } if ($this->debug) { $this->timer[__FUNCTION__]['elapsed'][] = microtime(true)-$start; } return $this->makeRequest($uri, $params, null, $getParams); }
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(), true); // check sig if (!hash_equals($sig, $expected_sig)) { self::errorLog('Bad Signed JSON signature!'); return null; } return json_decode(self::base64UrlDecode($payload), true); break; default: self::errorLog('Unknown algorithm. Expected HMAC-SHA256'); break; } return null; }
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_query($params, null, $this->argSeparator); } return $uri; }
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 = $this->_getServerParam('REQUEST_URI') ?: ''; $protocol = isset($server_https) && $server_https == 'on' ? 'https://' : 'http://'; $currentUrl = $protocol . $server_http_host . $server_request_uri; $parts = parse_url($currentUrl); // drop known params $query = ''; if (!empty($parts['query'])) { $params = array(); parse_str($parts['query'], $params); $params = array_merge($params, $extra_params); //print_r($params); foreach ($drop_params as $key) { unset($params[$key]); } if (!empty($params)) { $query = '?' . http_build_query($params, null, $this->argSeparator); } } elseif (!empty($extra_params)) { $query = '?' . http_build_query($extra_params, null, $this->argSeparator); } // use port if non default $port = isset($parts['port']) && (($protocol === 'http://' && $parts['port'] !== 80) || ($protocol === 'https://' && $parts['port'] !== 443)) ? ':' . $parts['port'] : ''; // rebuild return $protocol . (isset($parts['host'])?$parts['host']:'') . $port . (isset($parts['path'])?$parts['path']:'') . $query; }
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) $resultPathItems[] = $controllerOrActionNameDashed; if ($actionNameDashed !== NULL) $resultPathItems[] = $actionNameDashed; return str_replace(['_', '\\'], '/', implode('/', $resultPathItems)); } if ($actionNameDashed !== NULL) { // if action defined - take first argument controller $controllerNameDashed = $controllerOrActionNameDashed; } else { // if no action defined - we need to complete controller dashed name $toolClass = ''; if ($currentCtrlIsTopMostParent) { // if controller is tom most one - take routed controller name $controllerNameDashed = $this->controllerName; } else { // if controller is child controller - translate class name // without default controllers directory into dashed name $ctrlsDefaultNamespace = $this->application->GetAppDir() . '\\' . $this->application->GetControllersDir(); $currentCtrlClassName = get_class($this); if (mb_strpos($currentCtrlClassName, $ctrlsDefaultNamespace) === 0) $currentCtrlClassName = mb_substr($currentCtrlClassName, mb_strlen($ctrlsDefaultNamespace) + 1); $currentCtrlClassName = str_replace('\\', '/', $currentCtrlClassName); $toolClass = $this->application->GetToolClass(); $controllerNameDashed = $toolClass::GetDashedFromPascalCase($currentCtrlClassName); } if ($controllerOrActionNameDashed !== NULL) { $actionNameDashed = $controllerOrActionNameDashed; } else { if ($currentCtrlIsTopMostParent) {// if controller is top most parent - use routed action name $actionNameDashed = $this->actionName; } else {// if no action name defined - use default action name from core - usually `index` $defaultCtrlAction = $this->application->GetDefaultControllerAndActionNames(); $actionNameDashed = $toolClass::GetDashedFromPascalCase($defaultCtrlAction[1]); } } } $controllerPath = str_replace(['_', '\\'], '/', $controllerNameDashed); return implode('/', [$controllerPath, $actionNameDashed]); }
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 echo basset_stylesheets($value); ?>"; }); $blade->directive('assets', function($value){ return "<?php echo basset_assets($value); ?>"; }); }
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'], $app['basset.manifest'], $app['files'], $app['basset.path.build']); }); }
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 symlinks once they are added // back in. foreach ($this->symlinks as $link => $target) { unset($this->symlinks[$link]); if ($link == '//') { $link = $this->documentRoot; } else { $link = str_replace('//', $this->documentRoot.'/', $link); } $link = strtr($link, '/', DIRECTORY_SEPARATOR); $this->symlinks[$link] = $this->realPath($target); } $content = $this->trimUrls($content); $content = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/', array($this, 'processUriCallback'), $content); $content = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/', array($this, 'processUriCallback'), $content); $asset->setContent($content); }
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::$requestBegin = $app->GetRequest()->GetMicrotime(); if (gettype($forceDevelopmentMode) == 'boolean') { static::$debugging = $forceDevelopmentMode; } else { $configClass = $app->GetConfigClass(); static::$debugging = $configClass::IsDevelopment(TRUE) || $configClass::IsAlpha(TRUE); } // do not initialize log directory here every time, initialize log // directory only if there is necessary to log something - later. $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; static::$originalDebugClass = ltrim($app->GetDebugClass(), '\\') == $selfClass; static::initHandlers(); $initGlobalShortHandsHandler = static::$InitGlobalShortHands; $initGlobalShortHandsHandler(static::$debugging); }
php
{ "resource": "" }