_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q263200
VerifyDeployRequest.handle
test
public function handle($request, Closure $next) { if ($request->path() === config('auto-deploy.route')) { if (!config('auto-deploy.require-ssl') || $request->secure()) { $origin = $this->determineOrigin(); if (null !== $origin) { if ($origin->i...
php
{ "resource": "" }
q263201
ContainerNamespace.importFromVendor
test
public function importFromVendor(string $vendorDir) { $mappingFile = $vendorDir . '/container_map.php'; if (!(file_exists($mappingFile) && is_readable($mappingFile)))
php
{ "resource": "" }
q263202
ContainerNamespace.has
test
public function has(string $name) : bool { return
php
{ "resource": "" }
q263203
ContainerNamespace.getCodeFromFile
test
protected function getCodeFromFile(string $containerFilePath) : string { if (!file_exists($containerFilePath) || !is_readable($containerFilePath)) {
php
{ "resource": "" }
q263204
ContainerNamespace.getCode
test
public function getCode(string $name) : string { if (!$this->has($name)) { throw new ContainerNamespaceException("There is no path named '" . $name .
php
{ "resource": "" }
q263205
ContainerNamespace.parse
test
public function parse(string $containerFilePath) { // create a lexer from the given file $lexer = new ContainerLexer($this->getCodeFromFile($containerFilePath)); // parse the file $parser = new ScopeParser($lexer->tokens()); // interpret
php
{ "resource": "" }
q263206
ContainerInterpreter.handleScope
test
public function handleScope(ScopeNode $scope) { foreach($scope->getNodes() as $node) { if ($node instanceof ScopeImportNode) { $this->handleScopeImport($node); } elseif ($node instanceof ParameterDefinitionNode) { $this->handleParameterDefi...
php
{ "resource": "" }
q263207
ContainerInterpreter.handleScopeImport
test
public function handleScopeImport(ScopeImportNode $import) { $path = $import->getPath(); if (is_null($path) || empty($path)) { throw new ContainerInterpreterException("An import statement cannot be empty."); } $code = $this->namespace->getCode($path); /...
php
{ "resource": "" }
q263208
ContainerInterpreter.handleParameterDefinition
test
public function handleParameterDefinition(ParameterDefinitionNode $definition) { if ($this->namespace->hasParameter($definition->getName()) && $definition->isOverride() === false) { throw new ContainerInterpreterException("A parameter named \"{$definition->getName()}\" is already define...
php
{ "resource": "" }
q263209
ContainerInterpreter.createServiceArgumentsFromNode
test
protected function createServiceArgumentsFromNode(ArgumentArrayNode $argumentsNode) : ServiceArguments { $arguments = $argumentsNode ->getArguments(); $definition = new ServiceArguments(); foreach($arguments as $argument) { if ($argument instanceof ServiceR...
php
{ "resource": "" }
q263210
ContainerInterpreter.handleServiceDefinition
test
public function handleServiceDefinition(ServiceDefinitionNode $definition) { if ($this->namespace->hasService($definition->getName()) && $definition->isOverride() === false) { throw new ContainerInterpreterException("A service named \"{$definition->getName()}\" is already defined, you c...
php
{ "resource": "" }
q263211
ServiceDefinition.fromArray
test
public static function fromArray(array $serviceConfiguration) { if (!isset($serviceConfiguration['class'])) { throw new InvalidServiceException('The service configuration must define a "class" attribute.'); } // construct the service definition $defintion = new s...
php
{ "resource": "" }
q263212
ServiceDefinition.calls
test
public function calls(string $method, array $arguments = []) : ServiceDefinition {
php
{ "resource": "" }
q263213
ServiceDefinition.addMethodCall
test
public function addMethodCall(string $methodName, ServiceArguments $arguments) :
php
{ "resource": "" }
q263214
ServiceDefinition.addMetaData
test
public function addMetaData(string $key, array $values) { if (!isset($this->metaData[$key])) { $this->metaData[$key] = [];
php
{ "resource": "" }
q263215
Github.isOrigin
test
public function isOrigin() { // Correct IP range for Github maintained here: // https://help.github.com/articles/what-ip-addresses-does-github-use-that-i-should-whitelist/ $hasGithubHeader = false !== strpos($this->request->header('User-Agent'), 'GitHub-Hookshot');
php
{ "resource": "" }
q263216
Github.isAuthentic
test
public function isAuthentic() { // get the Github signature $xhub = $this->request->header('X-Hub-Signature') ?: 'nothing'; // reconstruct the hash on this side
php
{ "resource": "" }
q263217
ParameterDefinitionNode.setValue
test
public function setValue(AssignableNode $value) { // we currently only allow Arrays & scalar values // it not yet possible assign a reference to a parameter
php
{ "resource": "" }
q263218
WorkoutType.getName
test
static function getName($id) { try { return self::TYPES_NAMES[$id]; } catch (\Exception $e) { throw
php
{ "resource": "" }
q263219
Point.toString
test
public function toString() { if ($this->getTime() !== null) { $time = $this->getTime()->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i:s \U\T\C'); } else { $time = ''; } return $time . ';' .
php
{ "resource": "" }
q263220
Webhook.send
test
public function send(): bool { $response = $this->client->request( 'POST', $this->client->getConfig('base_uri')->getPath(),
php
{ "resource": "" }
q263221
Workout.setTypeId
test
public function setTypeId($id) { if (!WorkoutType::exist($id)) { throw new EndomondoWorkoutException('Unknown workout type');
php
{ "resource": "" }
q263222
Workout.getEnd
test
public function getEnd() { // if end property is defined, use it if ($this->end) { return clone $this->end; } $numberOfPosts = count($this->getPoints()); // try to find last time of point and use it as end date if ($this->haveGPSData()) { ret...
php
{ "resource": "" }
q263223
Workout.getPointsAsString
test
public function getPointsAsString() { $points = ''; foreach ($this->getPoints() as $point) { $points .=
php
{ "resource": "" }
q263224
Workout.getGPX
test
public function getGPX() { // @TODO use some library to generate GPX files $xml = new \SimpleXMLElement( '<gpx xmlns="http://www.topografix.com/GPX/1/1" ' . 'xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" ' . '/>' ); $trk = ...
php
{ "resource": "" }
q263225
SlimResponseCollector.collect
test
function collect() { return [ 'content-type' => $this->response->header('Content-Type'), 'status_code' => $this->response->getStatus(),
php
{ "resource": "" }
q263226
Builder.getModels
test
public function getModels($columns = ['*']) { $results = $this->query->get($columns); $connection = $this->model->getConnectionName(); // Check for joined relations if (!empty($this->joined)) { foreach ($results as $key => $result) { $relation_values = [...
php
{ "resource": "" }
q263227
Utility.get_ajax_payload
test
public static function get_ajax_payload( $handle = '' ) { $payload = null; if ( ! empty( $_POST['payload'] ) ) { $payload = $_POST['payload']; // Could be either a string or an array. } /** * Filter the Ajax payload. * * @param mixed $payload The ajax payload. *
php
{ "resource": "" }
q263228
Utility.get_callback_response
test
public static function get_callback_response( $handle, $callback, $callback_args ) { $ajax_payload = static::get_ajax_payload( $handle ); $response = static::run_callback( $callback, array( $ajax_payload, $callback_args, ) ); /** * Filter the callback response. * * @param mixed $re...
php
{ "resource": "" }
q263229
Utility.run_callback
test
public static function run_callback( $callback = '', $callback_args = array() ) { if ( ! is_callable( $callback ) ) { return null; } try { $result = call_user_func_array( $callback, $callback_args );
php
{ "resource": "" }
q263230
Utility.sanitize_handle
test
public static function sanitize_handle( $handle = null ) { $handle
php
{ "resource": "" }
q263231
Validator.validate_all
test
public function validate_all() { foreach ( (array) $this->registered_validations as $condition => $value ) {
php
{ "resource": "" }
q263232
Validator.validate_single
test
private function validate_single( $condition, $value ) { $validator = array( $this->validations_class, $condition );
php
{ "resource": "" }
q263233
Column.forDevice
test
public function forDevice($device, $width, $offset = null, $push = null, $resets = false) { $this->sizes[$device] = array('width' => $width, 'offset' => $offset, 'push' => $push);
php
{ "resource": "" }
q263234
Column.addReset
test
public function addReset($device) { if (!in_array($device, $this->resets))
php
{ "resource": "" }
q263235
Column.getSize
test
public function getSize($device) { if (isset($this->sizes[$device])) {
php
{ "resource": "" }
q263236
Column.build
test
public function build() { $classes = array(); foreach ($this->sizes as $device => $size) { if ($size['width']) { $classes[] = sprintf('col-%s-%s', $device, $size['width']); } else { $classes[] = 'hidden-' . $device; } ...
php
{ "resource": "" }
q263237
Validations.user_is
test
public function user_is( $role ) { if ( ! is_user_logged_in() ) { return false; }
php
{ "resource": "" }
q263238
Walker.begin
test
public function begin() { $this->index = 0; $this->infiniteIndex++; if ($this->classesOnly) { return $this->grid->getColumnAsString($this->index);
php
{ "resource": "" }
q263239
Walker.column
test
public function column() { $this->index++; $this->infiniteIndex++; if (!$this->grid->hasColumn($this->index)) { $this->index = 0; } if ($this->classesOnly) { return $this->grid->getColumnAsString($this->index);
php
{ "resource": "" }
q263240
Walker.walk
test
public function walk() { if ($this->index < 0) { return $this->begin(); } if (!$this->grid->hasColumn($this->index + 1)) {
php
{ "resource": "" }
q263241
Walker.beginRow
test
public function beginRow() { if ($this->classesOnly) { return trim('row ' . $this->grid->getRowClass()); }
php
{ "resource": "" }
q263242
Walker.getColumnResets
test
public function getColumnResets($tag = null) { if (!$this->infinite || $this->infiniteIndex === 0 || $this->grid->hasColumn($this->infiniteIndex)) {
php
{ "resource": "" }
q263243
Walker.getIndex
test
public function getIndex($ignoreInfinite = false) { if ($this->infinite &&
php
{ "resource": "" }
q263244
migrate.migrateFromLegacy
test
private function migrateFromLegacy() { if (!$this->database->fieldExists('bootstrap_grid', 'tl_content') && $this->database->fieldExists('columnset_id', 'tl_content') ) { $this->database->query(
php
{ "resource": "" }
q263245
Handler.handle
test
public function handle( $handle ) { // Sanitize the handle name. $this->handle = $this->utility->sanitize_handle( $handle ); // Register this handle with the frontend class. $this->frontend->register_handle( $this->handle ); // Register the Ajax handler in the WordPress hook system. add_action(
php
{ "resource": "" }
q263246
Handler.ajax_handler
test
public function ajax_handler() { if ( $this->utility->validate_nonce( $this->handle ) && $this->validator->validate_all() ) { $callback_response = $this->utility->get_callback_response(
php
{ "resource": "" }
q263247
Handler.with_callback
test
public function with_callback( $callback = '', $callback_args = array() ) { $this->handle_callback
php
{ "resource": "" }
q263248
Handler.with_validation
test
public function with_validation( $validations = array() ) { foreach ( (array) $validations as $condition => $value ) {
php
{ "resource": "" }
q263249
Responder.handle_response
test
public function handle_response( $callback_response ) { $this->callback_response = $callback_response; $this->response_type =
php
{ "resource": "" }
q263250
Responder.get_response_type
test
protected function get_response_type() { if ( is_array( $this->callback_response ) ) { $response_type = 'json'; } elseif ( is_string( $this->callback_response ) ) { $response_type = 'plain'; } else {
php
{ "resource": "" }
q263251
Responder.send_response_headers
test
protected function send_response_headers() { $http_content_type = 'text/plain'; // Set an HTTP error code if the response type is an error. if ( 'error' === $this->response_type ) { http_response_code( 500 ); // Internal server error. } // Set the content type to JSON if the callback response is an arra...
php
{ "resource": "" }
q263252
Responder.send_response_body
test
protected function send_response_body() { if ( 'json' === $this->response_type ) { $response_json = wp_json_encode( $this->callback_response ); if ( false !== $response_json ) { echo $response_json;
php
{ "resource": "" }
q263253
GeoIP2Adapter.getContent
test
public function getContent(string $url): string { if (false === filter_var($url, FILTER_VALIDATE_URL)) { throw new InvalidArgument( sprintf('"%s" must be called with a valid url. Got "%s" instead.', __METHOD__, $url) ); } $ipAddress = parse_url($url, ...
php
{ "resource": "" }
q263254
GeoIP2Adapter.isSupportedGeoIP2Model
test
protected function isSupportedGeoIP2Model(string $method): bool { $availableMethods = [ self::GEOIP2_MODEL_CITY,
php
{ "resource": "" }
q263255
ToggleIconCallback.toggleVisibility
test
private function toggleVisibility($recordId, $newState) { if (!$this->hasAccess()) { $this->log( sprintf('Not enough permission to show/shide record ID "%s"', $recordId), __METHOD__, TL_ERROR ); $this->redirect('contao/main...
php
{ "resource": "" }
q263256
ToggleIconCallback.hasAccess
test
private function hasAccess() { if ($this->user instanceof \BackendUser) {
php
{ "resource": "" }
q263257
GridBuilder.build
test
public function build() { $grid = new Grid(); foreach ($this->columns as $index => $column) { $grid->addColumn($column->build());
php
{ "resource": "" }
q263258
Grid.getColumnAsString
test
public function getColumnAsString($index) { if (isset($this->columns[$index])) {
php
{ "resource": "" }
q263259
Grid.addColumnReset
test
public function addColumnReset($column, $size) { if (!isset($this->columnResets[$column])) { $this->columnResets[$column] = array(); }
php
{ "resource": "" }
q263260
Grid.addColumnResets
test
public function addColumnResets($column, array $sizes) { if (!isset($this->columnResets[$column])) { $this->columnResets[$column] = $sizes; } else {
php
{ "resource": "" }
q263261
Grid.getColumnResets
test
public function getColumnResets($index) { $index = intval($index); if
php
{ "resource": "" }
q263262
Grid.hasColumnResetForSize
test
public function hasColumnResetForSize($column, $size) { if (!isset($this->columnResets[$column])) { return false;
php
{ "resource": "" }
q263263
Grid.getColumnResetsAsString
test
public function getColumnResetsAsString($index, $tag = null) { $tag = $tag ?: 'div'; return implode( PHP_EOL, array_map( function ($item) use ($tag) { return sprintf( '<%s class="clearfix visible-%s-block"></%s>' . ...
php
{ "resource": "" }
q263264
Frontend.register_handle
test
public function register_handle( $handle = '' ) { $this->registered_handles[] = $handle; // Only call add_actions() the first
php
{ "resource": "" }
q263265
Frontend.enqueue_scripts
test
public function enqueue_scripts() { if ( empty( $this->registered_handles ) ) { return; } $script_url = plugin_dir_url( trailingslashit( __DIR__ ) . '../../../' ) . 'assets/js/wp-ajax-helper.js'; wp_enqueue_script( 'wp-ajax-helper', $script_url, array( 'jquery' ), null, true ); wp_localize_script(
php
{ "resource": "" }
q263266
Frontend.get_nonces
test
protected function get_nonces() { $nonces = array(); foreach ( (array) $this->registered_handles
php
{ "resource": "" }
q263267
SemanticHtml5.getGrids
test
public static function getGrids(GetGridsEvent $event) { $model = $event->getModel(); $grids = $event->getGrids(); if ($model->type == 'semantic_html5') { $query = 'SELECT * FROM tl_columnset WHERE published=1 ORDER BY title'; $result = \Database::getInstance()->quer...
php
{ "resource": "" }
q263268
SemanticHtml5.hookParseTemplate
test
public function hookParseTemplate(\Template $template) { if (substr($template->getName(), 0, 3) != 'ce_' || $template->type != 'semantic_html5' || $template->sh5_tag != 'start' ) {
php
{ "resource": "" }
q263269
SemanticHtml5.hookGetContentElement
test
public function hookGetContentElement($model, $buffer) { if ($model->type === 'semantic_html5' && $model->sh5_tag === 'start' && $model->bootstrap_isGridElement === 'column' && static::$grids[$model->bootstrap_gridRow] ) { $row = $model->bootstrap_gri...
php
{ "resource": "" }
q263270
SemanticHtml5.getGridElements
test
public function getGridElements($dataContainer) { $elements = array(); if ($dataContainer->activeRecord) { $query = <<<SQL SELECT c.*, g.title as gridTitle, g.columns as gridColumns FROM tl_content c LEFT JOIN tl_columnset g ON g.id = c.bootstrap_grid WHERE (c.ptable...
php
{ "resource": "" }
q263271
SemanticHtml5.createRow
test
private function createRow($template) { // semantic html5 element is marked as beginning of new grid row if ($template->bootstrap_isGridElement == 'row') { try { static::$grids[$template->id] = Factory::createById($template->bootstrap_grid); static::$count...
php
{ "resource": "" }
q263272
SemanticHtml5.createColumn
test
private function createColumn($template) { // semantic html5 element is marked as an grid column if ($template->bootstrap_isGridElement == 'column') { if (static::$grids[$template->bootstrap_gridRow]) {
php
{ "resource": "" }
q263273
Factory.buildGridColumns
test
private static function buildGridColumns($builder, $result, $classes) { $columns = $result->columns; $sizes = deserialize($result->sizes, true); for ($i = 0; $i < $columns; $i++) { $column = $builder->addColumn(); foreach ($sizes as $size) { $key ...
php
{ "resource": "" }
q263274
Factory.fetchResult
test
private static function fetchResult($gridId, $ignoreError = false) { $result = \Database::getInstance() ->prepare('SELECT * FROM tl_columnset WHERE id=? AND published=1') ->limit(1) ->execute($gridId);
php
{ "resource": "" }
q263275
Factory.prepareClasses
test
private static function prepareClasses($result) { $classes = array(); foreach (deserialize($result->customClasses, true)
php
{ "resource": "" }
q263276
Factory.buildColumnResets
test
private static function buildColumnResets($result, $grid) { foreach (deserialize($result->resets, true) as $row) { foreach (array('xs', 'sm', 'md', 'lg') as $size) { if (isset($row[$size]) && $row[$size]) {
php
{ "resource": "" }
q263277
Factory.createById
test
public static function createById($gridId, $ignoreError = false) { if (isset(static::$cache[$gridId])) { return static::$cache[$gridId]; } $result = self::fetchResult($gridId, $ignoreError); if ($result) { $builder = GridBuilder::create(); ...
php
{ "resource": "" }
q263278
Subcolumns.hookParseTemplate
test
public function hookParseTemplate(\Template $template) { if (TL_MODE == 'BE' && $template->getName() == 'be_subcolumns'
php
{ "resource": "" }
q263279
Subcolumns.hookIsVisibleElement
test
public function hookIsVisibleElement(\Model $model, $isVisible) { if (static::isActive() && ( ($model->getTable() == 'tl_module' && $model->type == 'subcolumns') || $model->getTable() == 'tl_content' && ($model->type == 'colsetStart' || $model->type == 'colsetPart' ...
php
{ "resource": "" }
q263280
Subcolumns.hookLoadFormField
test
public function hookLoadFormField($widget) { if ($widget->type === 'formcolstart') { $type = $widget->fsc_type; $gridId = $widget->bootstrap_grid; $grid = Factory::createById($gridId); $GLOBALS['TL_SUBCL'][static::$name]['sets'][$type] = $this->prepareCon...
php
{ "resource": "" }
q263281
Subcolumns.getGrids
test
public static function getGrids(GetGridsEvent $event) { $model = $event->getModel(); $grids = $event->getGrids(); if ($model->type == 'colsetStart' || $model->type == 'subcolumns') { $query = 'SELECT * FROM tl_columnset WHERE published=1 AND columns=? ORDER BY title'; ...
php
{ "resource": "" }
q263282
Subcolumns.prepareContainer
test
protected function prepareContainer(Grid $grid) { $container = array(); foreach ($grid->getColumns() as $column) { $container[] =
php
{ "resource": "" }
q263283
Subcolumns.updateSubcolumnsDefinition
test
private function updateSubcolumnsDefinition($gridId, $type) { $grid = Factory::createById($gridId); $GLOBALS['TL_SUBCL'][static::$name]['sets'][$type] = $this->prepareContainer($grid); if ($grid->getRowClass()) {
php
{ "resource": "" }
q263284
ColumnSet.appendColumnsetIdToPalette
test
public function appendColumnsetIdToPalette($dataContainer) { if ($GLOBALS['TL_CONFIG']['subcolumns'] != 'bootstrap_customizable') { return; } if ($dataContainer->table == 'tl_content') { $model = \ContentModel::findByPK($dataContainer->id); if ($model->s...
php
{ "resource": "" }
q263285
ColumnSet.appendColumnSizesToPalette
test
public function appendColumnSizesToPalette($dataContainer) { $model = \Database::getInstance() ->prepare('SELECT * FROM tl_columnset WHERE id=?') ->limit(1) ->execute($dataContainer->id); $sizes = array_merge(deserialize($model->sizes, true)); foreach
php
{ "resource": "" }
q263286
ColumnSet.getAllTypes
test
public function getAllTypes() { if ($GLOBALS['TL_CONFIG']['subcolumns'] != 'bootstrap_customizable') { return array_keys($GLOBALS['TL_SUBCL'][$GLOBALS['TL_CONFIG']['subcolumns']]['sets']); } $this->import('Database'); $collection = $this->Database->execute('SELECT column...
php
{ "resource": "" }
q263287
ColumnSet.getGrids
test
public function getGrids($dataContainer) { if ($dataContainer->activeRecord) { $dispatcher = $GLOBALS['container']['event-dispatcher'];
php
{ "resource": "" }
q263288
ColumnSet.getColumnsForModule
test
public function getColumnsForModule($dataContainer) { if ($GLOBALS['TL_CONFIG']['subcolumns'] != 'bootstrap_customizable') { $subcolumns = new \tl_module_sc(); return $subcolumns->getColumns($dataContainer); } $model = \ModuleModel::findByPK($dataContainer->currentR...
php
{ "resource": "" }
q263289
ColumnSet.getColumnOrders
test
public function getColumnOrders() { $columns = Bootstrap::getConfigVar('grid-editor.columns'); $values = array();
php
{ "resource": "" }
q263290
ColumnSet.getColumnNumbers
test
public function getColumnNumbers($dataContainer) { if ($dataContainer->activeRecord) { $columns = $dataContainer->activeRecord->columns; } else {
php
{ "resource": "" }
q263291
Flash.get
test
public function get(string $key, $default = null) { if (array_key_exists($key, $this->data)) {
php
{ "resource": "" }
q263292
Flash.has
test
public function has(string $key): bool { return
php
{ "resource": "" }
q263293
Flash.delete
test
public function delete(string $key): self { unset($this->data[$key]);
php
{ "resource": "" }
q263294
Flash.load
test
public function load(string $key, callable $callback) { if (!$this->has($key)) {
php
{ "resource": "" }
q263295
Flash.reflash
test
public function reflash(array $keys = null): self { if ($keys === null) { return $this->clear($this->data + $this->session); }
php
{ "resource": "" }
q263296
InsertTag.parseInsertTag
test
public function parseInsertTag(ReplaceInsertTagsEvent $event) { if ($event->getTag() != 'grid') { return; } if (TL_MODE !== 'FE') { $event->setHtml(sprintf('[[%s]]', $event->getRaw())); return; } $walker = $this->getWalker($event); ...
php
{ "resource": "" }
q263297
InsertTag.getWalker
test
private function getWalker(ReplaceInsertTagsEvent $event) { $identifier = $event->getParam(0); if (!isset(static::$walkers[$identifier])) { list($columnSetId, $infinite) = $this->translateParams($event); try { static::$walkers[$identifier] = new Walker(Facto...
php
{ "resource": "" }
q263298
InsertTag.translateParams
test
private function translateParams(ReplaceInsertTagsEvent $event) { $infinite = false; $columnSetId = $event->getParam(0); if ($event->getParam(1) === 'begin'
php
{ "resource": "" }
q263299
GestPayCryptWS.getEncParams
test
private function getEncParams() { // Parametri obbligatori $params = array( 'shopLogin' => $this->getShopLogin(),
php
{ "resource": "" }