_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q30200
CssParser._load
train
private function _load($source, $charset = "", $mimetype = "") { // loads the contents $content = null; if ($this->_isURL($source)) { list($content, $charset, $mimetype) = $this->_loadUrl( $source, $charset, $mimetype ); } elseif (!is_file($sou...
php
{ "resource": "" }
q30201
CssParser._loadUrl
train
private function _loadUrl($source, $charset = "", $mimetype = "") { $loadHeaders = (strlen($mimetype) == 0) || (strlen($charset) == 0); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $source); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER,...
php
{ "resource": "" }
q30202
ContextConverter.toSerializationContext
train
public static function toSerializationContext(array $context): SerializationContext { $ctx = new SerializationContext(); if (isset($context['groups'])) { $ctx->setGroups($context['groups']); } return $ctx; }
php
{ "resource": "" }
q30203
ContextConverter.toDeserializationContext
train
public static function toDeserializationContext(array $context): DeserializationContext { $ctx = new DeserializationContext(); if (isset($context['object_to_populate'])) { $ctx->setAttribute('target', $context['object_to_populate']); } if (isset($context['groups'])) { ...
php
{ "resource": "" }
q30204
Represent.arg
train
public static function arg($value): string { switch (gettype($value)) { case 'NULL': return 'NULL'; case 'boolean': return $value ? 'true' : 'false'; case 'array': return 'Array'; case 'object': r...
php
{ "resource": "" }
q30205
Represent.method
train
public static function method(array $item): string { if (empty($item['function'])) { return ''; } $method = $item['function']; if (!empty($item['class'])) { $type = (empty($item['type']) ? '->' : $item['type']); $class = $item['class'].$type; ...
php
{ "resource": "" }
q30206
Represent.point
train
public static function point(array $item): string { if (empty($item['file'])) { $result = '[internal function]'; } else { $result = $item['file']; if (!empty($item['line'])) { $result .= '('.$item['line'].')'; } } return...
php
{ "resource": "" }
q30207
Represent.item
train
public static function item(array $item, ?int $number = null): string { if ($number !== null) { $number = '#'.$number.' '; } return $number.self::point($item).': '.self::method($item); }
php
{ "resource": "" }
q30208
Represent.trace
train
public static function trace(array $items, string $sep = PHP_EOL): string { $lines = []; foreach ($items as $number => $item) { $lines[] = self::item($item, $number); } $lines[] = '#'.(count($items)).' {main}'; return implode($sep, $lines).$sep; }
php
{ "resource": "" }
q30209
Represent.cutString
train
private static function cutString(string $str): string { static $mb; if ($mb === null) { $mb = function_exists('mb_strlen'); } if ($mb) { $len = mb_strlen($str, 'UTF-8'); } else { $len = strlen($str); } if ($len > self::MAX_...
php
{ "resource": "" }
q30210
InstantWin.scheduleOccurrences
train
public function scheduleOccurrences($game, array $data) { // It will be quite long to create these occurrences ! set_time_limit(0); if ($game->getOccurrenceType() === 'code') { return $this->scheduleCodeOccurrences($game, $data); } elseif ($game->getOccurrenceType() === '...
php
{ "resource": "" }
q30211
InstantWin.isInstantWinner
train
public function isInstantWinner($game, $user, $value = null) { $occurrenceMapper = $this->getInstantWinOccurrenceMapper(); if ($game->getOccurrenceType()=='datetime') { $entry = $this->findLastActiveEntry($game, $user); // si date après date de gain et date de gain encore a...
php
{ "resource": "" }
q30212
ResourceMapper.getPayloadForDataIdentifier
train
public function getPayloadForDataIdentifier($dataIdentifier) { if ($dataIdentifier === null) { return null; } $resourceConverter = new ResourceConverter(); /** @var Schema\Resource $resource */ $resource = $resourceConverter->convertFrom($dataIdentifier, Schema\Re...
php
{ "resource": "" }
q30213
ResourceMapper.initializeControllerContext
train
protected function initializeControllerContext() { $request = new ActionRequest(Request::createFromEnvironment()); $request->setDispatched(true); if (isset($this->flowHttpSettings['baseUri'])) { $request->getHttpRequest()->setBaseUri(new Uri($this->flowHttpSettings['baseUri']));...
php
{ "resource": "" }
q30214
UpdatePermalinkOnBlocksListener.onBeforeEditSeoCommit
train
public function onBeforeEditSeoCommit(BeforeEditSeoCommitEvent $event) { if ($event->isAborted()) { return; } $values = $event->getValues(); if (!is_array($values)) { throw new InvalidArgumentException('exception_invalid_value_array_required'); } ...
php
{ "resource": "" }
q30215
PositionColumn.initDefaultButtons
train
protected function initDefaultButtons() { $this->buttons = ArrayHelper::merge( [ 'first' => [ 'icon' => 'triangle-top', 'visible' => function ($model) { /* @var $model \yii\db\BaseActiveRecord */ ...
php
{ "resource": "" }
q30216
PositionColumn.renderButton
train
protected function renderButton($name, $model, $key, $index) { if (!isset($this->buttons[$name])) { return ''; } $button = $this->buttons[$name]; if ($button instanceof \Closure) { $url = $this->createUrl($name, $model, $key, $index); return call_...
php
{ "resource": "" }
q30217
PositionColumn.createUrl
train
public function createUrl($position, $model, $key, $index) { if (is_callable($this->urlCreator)) { return call_user_func($this->urlCreator, $position, $model, $key, $index); } else { $params = array_merge( Yii::$app->getRequest()->getQueryParams(), ...
php
{ "resource": "" }
q30218
ImagesController.index
train
public function index(Request $request) { $images = $this->imageRepository->getPaginated($request->get('limit', 50)); if($request->ajax()) return $images; return view('laramanager::images.index', compact('images')); }
php
{ "resource": "" }
q30219
ImagesController.update
train
public function update(UpdateImageRequest $request, $imageId) { return $this->imageRepository->update($imageId, $request->all()); }
php
{ "resource": "" }
q30220
ImagesController.search
train
public function search(Request $request) { $images = $this->imageRepository->search($request->term); if($request->ajax()) return response()->json([ 'images' => view('laramanager::browser.images', compact('images'))->render() ]); return view('laramanager::images.index', ...
php
{ "resource": "" }
q30221
ImagesController.imageBrowser
train
public function imageBrowser(Request $request) { return view('laramanager::browser.wysiwyg') ->with('funcNum', $request->has('CKEditorFuncNum') ? $request->get('CKEditorFuncNum') : '') ->with('images', $this->imageRepository->getPaginated()); }
php
{ "resource": "" }
q30222
ImagesController.store
train
public function store(UploadImageRequest $request) { $upload = $this->uploader->upload($request->file('image'), storage_path('app/laramanager/images')); return $this->imageRepository->create($upload->toArray()); }
php
{ "resource": "" }
q30223
Sentry.setup
train
public function setup() { $jaxon = jaxon(); // Create the Jaxon response $this->xResponse = $jaxon->getResponse(); // Add the view renderer $this->addViewRenderer('sentry', function () { return new \Jaxon\Sentry\View\View(); }); // Set the pagin...
php
{ "resource": "" }
q30224
Sentry.addClassNamespace
train
public function addClassNamespace($sDirectory, $sNamespace, $sSeparator = '.', array $aProtected = array()) { // Valid separator values are '.' and '_'. Any other value is considered as '.'. $sSeparator = trim($sSeparator); if($sSeparator != '_') { $sSeparator = '.'; ...
php
{ "resource": "" }
q30225
Sentry.addClassNamespaces
train
public function addClassNamespaces($xAppConfig) { if($xAppConfig->hasOption('classes') && is_array($xAppConfig->getOption('classes'))) { $aNamespaces = $xAppConfig->getOption('classes'); // The public methods of the base class must not be exported to javascript $...
php
{ "resource": "" }
q30226
Sentry.mergeClassOptions
train
public function mergeClassOptions($aOptions) { // The new options overwrite those already saved, and the merge // shall be done at option level, and not at class level. foreach($aOptions as $class => $aClassOption) { if(!array_key_exists($class, $this->aClassOptions)) ...
php
{ "resource": "" }
q30227
Sentry.addViewNamespace
train
public function addViewNamespace($sNamespace, $sDirectory, $sExtension, $sRenderer) { $aNamespace = array( 'namespace' => $sNamespace, 'directory' => $sDirectory, 'extension' => $sExtension, ); if(key_exists($sRenderer, $this->aViewNamespaces)) { ...
php
{ "resource": "" }
q30228
Sentry.addViewNamespaces
train
public function addViewNamespaces($xAppConfig) { $sDefaultNamespace = $xAppConfig->getOption('options.views.default', false); if(is_array($namespaces = $xAppConfig->getOptionNames('views'))) { foreach($namespaces as $namespace => $option) { // If no de...
php
{ "resource": "" }
q30229
Sentry.setLibraryOptions
train
public function setLibraryOptions($bExtern, $bMinify, $sJsUri, $sJsDir) { $jaxon = jaxon(); // Jaxon library settings if(!$jaxon->hasOption('js.app.extern')) { $jaxon->setOption('js.app.extern', $bExtern); } if(!$jaxon->hasOption('js.app.minify')) ...
php
{ "resource": "" }
q30230
Sentry.initInstance
train
protected function initInstance(Armada $instance) { // Return if the class instance has already been initialized. if(!($instance) || ($instance->response)) { return; } // Init the class instance $instance->response = $this->xResponse; $instance->rq...
php
{ "resource": "" }
q30231
Sentry.request
train
public function request($classname) { $instance = $this->instance($classname); return ($instance != null ? $instance->request() : null); }
php
{ "resource": "" }
q30232
Sentry.onEventBefore
train
public function onEventBefore(&$bEndRequest) { // Validate the inputs $class = $_POST['jxncls']; $method = $_POST['jxnmthd']; if(!$this->validateClass($class) || !$this->validateMethod($method)) { // End the request processing if the input data are not valid. ...
php
{ "resource": "" }
q30233
Sentry.onEventAfter
train
public function onEventAfter() { if(($this->xAfterCallback)) { call_user_func_array($this->xAfterCallback, array($this->xRequestObject, $this->sRequestMethod)); } return $this->xResponse; }
php
{ "resource": "" }
q30234
Sentry.processRequest
train
public function processRequest() { // Process Jaxon Request $jaxon = jaxon(); if($jaxon->canProcessRequest()) { $jaxon->register(Jaxon::PROCESSING_EVENT, Jaxon::PROCESSING_EVENT_BEFORE, array($this, 'onEventBefore')); $jaxon->register(Jaxon::PROCESSING_EVENT, ...
php
{ "resource": "" }
q30235
HtmlHelper.buildIconClasses
train
protected function buildIconClasses($icon) { //Prepends the string "fa-" to any other class $icon = preg_replace('/(?<![^ ])(?=[^ ])(?!fa)/', 'fa-', $icon); $icon = !is_array($icon) ? preg_split('/\s+/', $icon, -1, PREG_SPLIT_NO_EMPTY) : $icon; //Adds the "fa" class, if no other "ba...
php
{ "resource": "" }
q30236
HtmlHelper.addIconToText
train
public function addIconToText($text, OptionsParser $options) { $icon = $options->consume('icon'); $align = $options->consume('icon-align'); if (!$icon) { return [$text, $options]; } $icon = $this->icon($icon); if (empty($text)) { $text = $ic...
php
{ "resource": "" }
q30237
HtmlHelper.badge
train
public function badge($text, array $options = []) { $options = optionsParser($options)->append('class', 'badge'); return self::tag('span', $text, $options->toArray()); }
php
{ "resource": "" }
q30238
HtmlHelper.css
train
public function css($path, array $options = []) { $options = optionsParser($options, ['block' => true]); return parent::css($path, $options->toArray()); }
php
{ "resource": "" }
q30239
HtmlHelper.cssEnd
train
public function cssEnd() { $buffer = ob_get_clean(); $options = $this->_cssBlockOptions; $this->_cssBlockOptions = []; return $this->cssBlock($buffer, $options); }
php
{ "resource": "" }
q30240
HtmlHelper.heading
train
public function heading($text, array $options = [], $small = null, array $smallOptions = []) { $options = optionsParser($options); $type = $options->consume('type'); $type = is_string($type) && preg_match('/^h[1-6]$/', $type) ? $type : 'h2'; $text = $small ? sprintf('%s %s', $text, ...
php
{ "resource": "" }
q30241
HtmlHelper.icon
train
public function icon($icon) { $icon = func_num_args() > 1 ? func_get_args() : $icon; return $this->formatTemplate('tag', [ 'attrs' => $this->templater()->formatAttributes(['class' => $this->buildIconClasses($icon)]), 'content' => ' ', 'tag' => 'i', ]); ...
php
{ "resource": "" }
q30242
HtmlHelper.label
train
public function label($text, array $options = []) { $options = optionsParser($options); $options->append('class', sprintf('label label-%s', $options->consume('type') ?: 'default')); return self::tag('span', $text, $options->toArray()); }
php
{ "resource": "" }
q30243
HtmlHelper.link
train
public function link($title, $url = null, array $options = []) { $options = optionsParser($options, ['escape' => false, 'title' => $title]); $options->add('title', trim(h(strip_tags($options->get('title')))))->tooltip(); list($title, $options) = $this->addIconToText($title, $options); ...
php
{ "resource": "" }
q30244
HtmlHelper.script
train
public function script($url, array $options = []) { $options = optionsParser($options, ['block' => true]); return parent::script($url, $options->toArray()); }
php
{ "resource": "" }
q30245
HtmlHelper.scriptBlock
train
public function scriptBlock($code, array $options = []) { $options = optionsParser($options, ['block' => true]); return parent::scriptBlock($code, $options->toArray()); }
php
{ "resource": "" }
q30246
HtmlHelper.tag
train
public function tag($name, $text = null, array $options = []) { $options = optionsParser($options)->tooltip(); list($text, $options) = $this->addIconToText($text, $options); return parent::tag($name, is_null($text) ? '' : $text, $options->toArray()); }
php
{ "resource": "" }
q30247
HtmlHelper.viewport
train
public function viewport(array $options = []) { $content = http_build_query([ 'initial-scale' => '1', 'shrink-to-fit' => 'no', 'width' => 'device-width', ], null, ', '); return self::meta(array_merge(['name' => 'viewport'], compact('content')), null, $opt...
php
{ "resource": "" }
q30248
HtmlHelper.youtube
train
public function youtube($id, array $options = []) { $options = optionsParser($options, [ 'allowfullscreen' => 'allowfullscreen', 'height' => 480, 'ratio' => '16by9', 'width' => 640, ]); return self::iframe(sprintf('https://www.youtube.com/embe...
php
{ "resource": "" }
q30249
StyleManager.style
train
public static function style($styleID) { if (!in_array($styleID, static::getKnownStyles())) { throw new Exception("Unknown style ID $styleID"); } $style = new Style($styleID); return $style; }
php
{ "resource": "" }
q30250
StyleManager.getKnownStyles
train
public static function getKnownStyles() { $styles = array( static::BOLD => static::BASH_BOLD, static::UNDERLINE => static::BASH_UNDERLINE, static::BLINK => static::BASH_BLINK, static::INVISIBLE => static::BASH_INVISIBLE, ); return $st...
php
{ "resource": "" }
q30251
TradingCardController.cooAction
train
public function cooAction() { // get models $sg = $this->getAdminGameService(); $this->checkGame(); $models = $sg->getTradingCardModelMapper()->findBy(array('game' => $this->game)); if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->isPost()) { ...
php
{ "resource": "" }
q30252
Chatlink.decode
train
public static function decode($code) { $data = self::getData($code); $chatlinkType = $data[0]; switch ($chatlinkType) { case self::TYPE_ITEM: return ItemChatlink::decode($code); case self::TYPE_COIN: return CoinChatlink::decode($code); ...
php
{ "resource": "" }
q30253
Chatlink.getData
train
protected static function getData($code) { if(preg_match('/^\[&([a-z\d+\/]+=*)\]$/i', $code, $matches) !== 1) { throw new ChatlinkFormatException("Chatcode does not match the expected format."); } $base64 = $matches[1]; $data = []; foreach (str_split(base64_decode($...
php
{ "resource": "" }
q30254
NewRelicServiceProvider.configureNewRelic
train
protected function configureNewRelic(Application $app) { if ( isset($app['newrelic.options']['application_name']) && $app['newrelic.options']['application_name'] ) { $app['newrelic']->setAppName($app['newrelic.options']['application_name']); } /**...
php
{ "resource": "" }
q30255
AbstractConsumer.run
train
final public function run(int $maxRuntime = 300): void { if ($this->isRunning) { $this->logger->notice(sprintf('Consumer [%s] is already running.', $this->consumerName)); return; } /* * In many distributed systems multiple consumers are created and these oft...
php
{ "resource": "" }
q30256
GridHelper.columnSum
train
public static function columnSum($dataProvider, $attributes) { $result = 0; foreach ($dataProvider->models as $model) { foreach ((array) $attributes as $attribute) { $result += $model[$attribute]; } } return $result; }
php
{ "resource": "" }
q30257
GridHelper.viaListFormat
train
public static function viaListFormat($model, $attribute, $options = []) { $relation = $model->getRelation($attribute); $relationClass = $relation->modelClass; $columns = Yii::$app->db->getTableSchema($relationClass::tableName())->columnNames; $titles = array_intersect(['title', 'name...
php
{ "resource": "" }
q30258
GridHelper.dateFormat
train
public static function dateFormat($model, $attribute, $options = [], $pickerOptions = []) { $pickerOptions = array_merge([ 'language' => Yii::$app->language == 'en' ? 'en-US' : Yii::$app->language, 'model' => $model, 'attribute' => $attribute, 'options' => ['c...
php
{ "resource": "" }
q30259
GridHelper.arrayFormat
train
public static function arrayFormat($model, $attribute, $options = []) { $replacer = function($v){ return '<pre>'.preg_replace(['#[\s\n]*\)#', '#Array[\s\n]*\(#'], ['', ''], print_r($v, true)).'</pre>'; }; return array_merge([ 'attribute' => $attribute, 'fo...
php
{ "resource": "" }
q30260
SchedulerTable.create
train
public function create(DynamoDbClient $client, string $tableName): void { try { $client->describeTable(['TableName' => $tableName]); return; } catch (DynamoDbException $e) { // table doesn't exist, create it below } try { $client->crea...
php
{ "resource": "" }
q30261
SchedulerTable.describe
train
public function describe(DynamoDbClient $client, string $tableName): string { try { $result = $client->describeTable(['TableName' => $tableName]); return json_encode($result->toArray(), JSON_PRETTY_PRINT); } catch (\Throwable $e) { throw new SchedulerOperationFail...
php
{ "resource": "" }
q30262
Allocation.release
train
public function release($count) { $count = min($count, $this->size); if (!$count) { return; } $this->size -= $count; call_user_func($this->releaseFn, $count); }
php
{ "resource": "" }
q30263
Style.apply
train
public function apply($element, string $type, string $context = ''): string { if (!empty($style = $this->getStyle($type, $context))) { return \Spiral\interpolate( $this->element, compact('style', 'element') ); } return $element; }
php
{ "resource": "" }
q30264
BaseGridQuery.paginate
train
public function paginate($perPage = null, $page = 1) { $this->paginated(true); $this->perPage = $perPage ?: $this->perPage; $this->page = $page; return $this; }
php
{ "resource": "" }
q30265
BaseGridQuery.makeSelect
train
public function makeSelect(array $columns = null) { $columns = $columns ?: $this->columns(); $selects = []; foreach ($columns as $key => $select) { if (is_int($key)) { $selects[] = $select; } else { $selects[] = DB::raw($select.' as '....
php
{ "resource": "" }
q30266
BaseGridQuery.getColumns
train
public function getColumns(array $columnKeys) { $columns = []; foreach ($columnKeys as $columnKey) { $columns[] = $this->getColumn($columnKey); } return $columns; }
php
{ "resource": "" }
q30267
BaseGridQuery.searchableQuery
train
protected function searchableQuery() { $query = $this->makeQuery(); if ($this->paginated) { $query->limit($this->pageLimitter()->limit()); $query->offset($this->pageLimitter()->offset()); } return $query; }
php
{ "resource": "" }
q30268
BaseGridQuery.searcher
train
public function searcher() { return new SublimeSearch( $this->searchableQuery(), $this->searchOperator === 'having' ? $this->columnKeys() : array_values($this->columns()), $this->sortSearch, method_exists($this, 'sortColumns') ? $this->sortColumns() : $this->c...
php
{ "resource": "" }
q30269
BaseGridQuery.columnKeys
train
public function columnKeys() { $columnKeys = []; foreach ($this->columns() as $key => $column) { if (is_string($key)) { $columnKeys[] = $key; } elseif (str_contains($column, '.')) { list($table, $columnKey) = explode('.', $column); ...
php
{ "resource": "" }
q30270
TransportEnvelope.fromString
train
public static function fromString(string $envelope): self { $envelope = json_decode($envelope, true); if (!is_array($envelope)) { throw new \InvalidArgumentException('Envelope is invalid. ' . json_last_error_msg()); } $serializer = isset($envelope['serializer']) ? $envel...
php
{ "resource": "" }
q30271
eZPageType.initializeClassAttribute
train
function initializeClassAttribute( $classAttribute ) { if ( $classAttribute->attribute( self::DEFAULT_ZONE_LAYOUT_FIELD ) === null ) $classAttribute->setAttribute( self::DEFAULT_ZONE_LAYOUT_FIELD, '' ); $classAttribute->store(); }
php
{ "resource": "" }
q30272
eZPageType.serializeContentClassAttribute
train
function serializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode ) { $defaultZoneLayout = $classAttribute->attribute( self::DEFAULT_ZONE_LAYOUT_FIELD ); $dom = $attributeParametersNode->ownerDocument; $defaultLayoutNode = $dom->createElement( 'default-layou...
php
{ "resource": "" }
q30273
eZPageType.unserializeContentClassAttribute
train
function unserializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode ) { $defaultZoneLayoutItem = $attributeParametersNode->getElementsByTagName( 'default-layout' )->item( 0 ); if ( $defaultZoneLayoutItem !== null && $defaultZoneLayoutItem->textContent !== false ) ...
php
{ "resource": "" }
q30274
eZPageType.hasObjectAttributeContent
train
function hasObjectAttributeContent( $contentObjectAttribute ) { $page = $contentObjectAttribute->content(); $zones = $page->attribute( 'zones' ); if ( !is_array( $zones ) ) return false; foreach ( $zones as $zone ) { if ( $zone->getBlockCount() > 0 ) ...
php
{ "resource": "" }
q30275
eZPageType.fetchClassAttributeHTTPInput
train
function fetchClassAttributeHTTPInput( $http, $base, $classAttribute ) { if ( $http->hasPostVariable( $base . '_ezpage_default_layout_' . $classAttribute->attribute( 'id' ) ) ) { $defaultLayout = $http->postVariable( $base . '_ezpage_default_layout_' . $classAttribute->attribute( 'id' ) ...
php
{ "resource": "" }
q30276
eZPageType.objectAttributeContent
train
function objectAttributeContent( $contentObjectAttribute ) { $source = $contentObjectAttribute->attribute( 'data_text' ); $page = eZPage::createFromXML( $source ); return $page; }
php
{ "resource": "" }
q30277
ApiController.initializeActionMethodArguments
train
protected function initializeActionMethodArguments() { if ($this->getOriginalRequest()->getControllerActionName() === 'index') { switch ($this->request->getHttpRequest()->getMethod()) { case 'POST': case 'PUT': $arguments = $this->request->getA...
php
{ "resource": "" }
q30278
ApiController.extractRequestBody
train
protected function extractRequestBody() { $propertyMappingConfiguration = new PropertyMappingConfiguration(); $propertyMappingConfiguration->setTypeConverter($this->objectManager->get(MediaTypeConverterInterface::class)); $propertyMappingConfiguration->setTypeConverterOption(MediaTypeConvert...
php
{ "resource": "" }
q30279
Str.overlapLeftMerge
train
public static function overlapLeftMerge($overlap, $attribute, $field) { $overlap = explode('.', $overlap); $attribute = explode('.', $attribute); $field = explode('.', $field); for ($i=0; $i<count($overlap); $i++) { $field[$i] = $attribute[$i]; } re...
php
{ "resource": "" }
q30280
ObjectStorage.newFromSwiftAuth
train
public static function newFromSwiftAuth($account, $key, $url) { $headers = array( 'X-Auth-User' => $account, 'X-Auth-Key' => $key, ); $client = \HPCloud\Transport::instance(); // This will throw an exception if it cannot connect or // authenticate. $res = $client->doRequest($url, '...
php
{ "resource": "" }
q30281
ObjectStorage.newFromIdentity
train
public static function newFromIdentity($identity, $region) { $cat = $identity->serviceCatalog(); $tok = $identity->token(); return self::newFromServiceCatalog($cat, $tok, $region); }
php
{ "resource": "" }
q30282
ObjectStorage.newFromServiceCatalog
train
public static function newFromServiceCatalog($catalog, $authToken, $region) { $c = count($catalog); for ($i = 0; $i < $c; ++$i) { if ($catalog[$i]['type'] == self::SERVICE_TYPE) { foreach ($catalog[$i]['endpoints'] as $endpoint) { if (isset($endpoint['publicURL']) && $endpoint['region'] ...
php
{ "resource": "" }
q30283
ObjectStorage.useCDN
train
public function useCDN($cdn) { // This should not happen, but has happened when service // catalog was bad. if (empty($cdn)) { throw new \HPCloud\Exception('Cannot use CDN: No CDN provided.'); } $containers = $cdn->containers(TRUE); $buffer = array(); foreach ($containers as $item) ...
php
{ "resource": "" }
q30284
ObjectStorage.cdnUrl
train
public function cdnUrl($containerName, $ssl = TRUE) { if (!empty($this->cdnContainers[$containerName])) { $key = $ssl ? 'sslUrl' : 'url'; return $this->cdnContainers[$containerName][$key]; } }
php
{ "resource": "" }
q30285
ObjectStorage.containers
train
public function containers($limit = 0, $marker = NULL) { $url = $this->url() . '?format=json'; if ($limit > 0) { $url .= sprintf('&limit=%d', $limit); } if (!empty($marker)) { $url .= sprintf('&marker=%d', $marker); } $containers = $this->get($url); $containerList = array(); ...
php
{ "resource": "" }
q30286
ObjectStorage.container
train
public function container($name) { $url = $this->url() . '/' . rawurlencode($name); $data = $this->req($url, 'HEAD', FALSE); $status = $data->status(); if ($status == 200 || $status == 204) { $container = Container::newFromResponse($name, $data, $this->token(), $this->url()); if (isset($t...
php
{ "resource": "" }
q30287
ObjectStorage.hasContainer
train
public function hasContainer($name) { try { $container = $this->container($name); } catch (\HPCloud\Transport\FileNotFoundException $fnfe) { return FALSE; } return TRUE; }
php
{ "resource": "" }
q30288
ObjectStorage.createContainer
train
public function createContainer($name, ACL $acl = NULL, $metadata = array()) { $url = $this->url() . '/' . rawurlencode($name); $headers = array( 'X-Auth-Token' => $this->token(), ); if (!empty($metadata)) { $prefix = Container::CONTAINER_METADATA_HEADER_PREFIX; $headers += Container:...
php
{ "resource": "" }
q30289
ObjectStorage.deleteContainer
train
public function deleteContainer($name) { $url = $this->url() . '/' . rawurlencode($name); try { $data = $this->req($url, 'DELETE', FALSE); } catch (\HPCloud\Transport\FileNotFoundException $e) { return FALSE; } // XXX: I'm not terribly sure about this. Why not just throw the // ...
php
{ "resource": "" }
q30290
ObjectStorage.req
train
protected function req($url, $method = 'GET', $jsonDecode = TRUE, $body = '') { $client = \HPCloud\Transport::instance(); $headers = array( 'X-Auth-Token' => $this->token(), ); $raw = $client->doRequest($url, $method, $headers, $body); if (!$jsonDecode) { return $raw; } return...
php
{ "resource": "" }
q30291
TemplateAssetsManager.setUp
train
public function setUp(Template $template, array $options) { $this->template = $template; $this->assets = array(); $methods = array( 'getExternalStylesheets', 'getExternalJavascripts', 'getInternalStylesheets', 'getInternalJavascripts', ...
php
{ "resource": "" }
q30292
TemplateAssetsManager.mergeAssets
train
protected function mergeAssets($method, Template $template, array $options) { $assetsCollection = $template->$method(); if (null !== $assetsCollection) { $assetsCollection = clone($assetsCollection); // merges extra assets from current theme $assetsCollection = ...
php
{ "resource": "" }
q30293
TemplateAssetsManager.mergeAppBlocksAssets
train
protected function mergeAppBlocksAssets(AssetCollection $assetsCollection, array $options) { // When a block has examined, it is saved in this array to avoid parsing it again $appsAssets = array(); // merges assets from installed apps foreach ($this->availableBlocks as $className) ...
php
{ "resource": "" }
q30294
TemplateAssetsManager.addAssetsFromContainer
train
protected function addAssetsFromContainer(AssetCollection &$assetsCollection, $parameter) { if ( ! $this->container->hasParameter($parameter)) { return; } $assets = $this->container->getParameter($parameter); $assetsCollection->addRange($assets); }
php
{ "resource": "" }
q30295
TemplateAssetsManager.addExtraAssets
train
protected function addExtraAssets(&$assetsCollection, $baseParam) { if (! $this->extraAssets) { return; } $parameter = sprintf('%s.cms', $baseParam); $this->addAssetsFromContainer($assetsCollection, $parameter); }
php
{ "resource": "" }
q30296
Curl.run
train
public function run() { $ch = curl_init(); $query = ''; if (!empty($this->parameters)) { $query = '?' . http_build_query ($this->parameters); } $this->query = $this->url . $query; if ($this->method == "GET") { curl_setopt($ch, CURLOPT_URL, $th...
php
{ "resource": "" }
q30297
Model.find
train
public function find(array $where = [], array $field = []) { return $this ->createQuery( $this->getQueryBuilder() ->select(array() === $field ? $this->getAlias() : $field) ->from($this->getTable()) ->where($where) ...
php
{ "resource": "" }
q30298
Model.findAll
train
public function findAll(array $where = [], array $field = []) { return $this ->createQuery( $this->getQueryBuilder() ->select(array() === $field ? $this->getAlias() : $field) ->from($this->getTable()) ->where($where) ...
php
{ "resource": "" }
q30299
Model.save
train
public function save(array $data = [], array $params = [], array $where = []) { if (empty($where)) { return $this ->createQuery( $this->getQueryBuilder() ->insert(array() === $data ? $this->data : $data) ->from($...
php
{ "resource": "" }