_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q1200
Dispatcher.close
train
public function close(Server $server, int $fd) { try { if (!$path = WebSocketContext::getMeta('path', $fd)) { throw new ContextLostException( "The connection info has lost of the fd#$fd, on connection closed" ); } $clas...
php
{ "resource": "" }
q1201
UserAgentStringParser.parse
train
public function parse($string, $strict = true) { // Parse quickly (with medium accuracy) $information = $this->doParse($string); // Run some filters to increase accuracy if ($strict) { $information = $this->definition->filter($information); } return $inf...
php
{ "resource": "" }
q1202
UserAgentStringParser.parseFromGlobal
train
public function parseFromGlobal($strict = true) { $string = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; return $this->parse($string, $strict); }
php
{ "resource": "" }
q1203
UserAgentStringParser.doParse
train
protected function doParse($string) { $userAgent = array( 'string' => $this->cleanString($string), 'browser_name' => null, 'browser_version' => null, 'browser_engine' => null, 'operating_system' => null, 'device' => 'Other' ); ...
php
{ "resource": "" }
q1204
UserAgentStringParser.matchBrowser
train
protected function matchBrowser(array $regexes, $string) { // Build regex that matches phrases for known browsers (e.g. "Firefox/2.0" or "MSIE 6.0"). // This only matches the major and minor version numbers (e.g. "2.0.0.6" is parsed as simply "2.0"). $pattern = '#('.join('|', $regexes).')[/ ...
php
{ "resource": "" }
q1205
DeleteCommand.removeByPrefix
train
private function removeByPrefix(InputInterface $input, OutputInterface $output) { $prefix = $input->getOption('prefix'); $output->writeln( sprintf('<comment>Removing all resources from <info>%s</info></comment>', $prefix) ); $api = $this->getCloudinaryApi(); $re...
php
{ "resource": "" }
q1206
DeleteCommand.removeResource
train
private function removeResource(InputInterface $input, OutputInterface $output) { $resource = $input->getOption('resource'); $output->writeln( sprintf('<comment>Removing resource <info>%s</info></comment>', $resource) ); $api = $this->getCloudinaryApi(); $respon...
php
{ "resource": "" }
q1207
DeleteCommand.outputApiResponse
train
private function outputApiResponse(Response $response, $part, OutputInterface $output) { $table = new Table($output); $table->setHeaders(['Resource', 'Status']); foreach ($response[$part] as $file => $status) { $table->addRow([$file, $status]); } $table->render()...
php
{ "resource": "" }
q1208
CategoriesController.publish
train
public function publish(Category $category) { $category->togglePublishedState(); $category->getDescendants()->each( function (Category $cat) use ($category) { $cat->published = $category->published; $cat->save(); } ); $message...
php
{ "resource": "" }
q1209
LogoutGuard.isActiveGuard
train
public function isActiveGuard(Request $request, $guard) { $name = Auth::guard($guard)->getName(); return ($this->sessionHas($request, $name) && $this->sessionGet($request, $name) === $this->getAuthIdentifier($guard)); }
php
{ "resource": "" }
q1210
Push.open
train
public function open($id, $label = null) { return $this->webService->post("SELECT FROM 'PUSH'.'DOCUMENT'", array_filter([ "id" => $id, "label" => $label ])); }
php
{ "resource": "" }
q1211
Push.changeInterval
train
public function changeInterval($id, $interval) { return $this->webService->post("UPDATE 'PUSH'.'PUSHINTERVAL'", [ self::PARAMETER_PUSH_ID => $id, self::PARAMETER_PUSH_INTERVAL => $interval ]); }
php
{ "resource": "" }
q1212
MenuPresenter.url
train
public function url() { /** @var \Yajra\CMS\Repositories\Extension\Repository $repository */ $repository = app('extensions'); /** @var \Yajra\CMS\Entities\Extension $extension */ $extension = $repository->findOrFail($this->entity->extension_id); $class = $extension->param...
php
{ "resource": "" }
q1213
MenuPresenter.linkTitle
train
public function linkTitle() { return $this->entity->param('link_title') ? $this->entity->param('link_title') : $this->entity->title; }
php
{ "resource": "" }
q1214
ConfigurationsController.store
train
public function store(Request $request) { $config = $request->input('config'); foreach (array_dot($request->input('data')) as $key => $value) { $path = $config . '.' . $key; $this->destroy($path); if (is_array($value)) { $value = implode(',', $val...
php
{ "resource": "" }
q1215
ConfigurationsController.show
train
public function show($key) { $config = config($key) ?? []; if (! isset($this->limits[$key])) { return $this->filter($config); } return response()->json( $this->filter(array_only($config, $this->limits[$key])) ); }
php
{ "resource": "" }
q1216
ConfigurationsController.filter
train
protected function filter(array $array) { $config = collect(array_dot($array))->map(function ($value, $key) { if (str_contains($key, $this->hidden)) { return ''; } if (in_array($key, $this->boolean)) { return (bool) $value; } ...
php
{ "resource": "" }
q1217
ProfileController.removeAvatar
train
public function removeAvatar() { $profile = auth()->user(); $profile->avatar = ''; $profile->save(); event(new ProfileWasUpdated($profile)); return redirect()->route('administrator.profile.edit'); }
php
{ "resource": "" }
q1218
UserAgent.configureFromUserAgentString
train
public function configureFromUserAgentString($string, UserAgentStringParser $parser = null) { $parser = $parser ?: new UserAgentStringParser(); $result = $string !== null ? $parser->parse($string) : $parser->parseFromGlobal(); $this->setUserAgentString($string); $this->fromArray($re...
php
{ "resource": "" }
q1219
UserAgent.toArray
train
public function toArray() { return array( 'browser_name' => $this->getBrowserName(), 'browser_version' => $this->getBrowserVersion(), 'browser_engine' => $this->getBrowserEngine(), 'operating_system' => $this->getOperatingSystem(), 'device' => $thi...
php
{ "resource": "" }
q1220
UserAgent.fromArray
train
private function fromArray(array $data) { $this->browserName = $data['browser_name']; $this->browserVersion = $data['browser_version']; $this->browserEngine = $data['browser_engine']; $this->operatingSystem = $data['operating_system']; $this->device = $data['device']; }
php
{ "resource": "" }
q1221
BundleDependency.registerBundleDependencies
train
protected function registerBundleDependencies(ContainerBuilder $container) { if (true === $this->booted) { return; } $this->bundles = $container->getParameter('kernel.bundles'); if ($this->createBundles($this->getBundleDependencies())) { $container->setParam...
php
{ "resource": "" }
q1222
BundleDependency.createBundles
train
protected function createBundles(array $dependencies) { foreach ($dependencies as $bundleClass) { $name = substr($bundleClass, strrpos($bundleClass, '\\') + 1); if (false === isset($this->bundles[$name])) { $bundle = new $bundleClass(); $this->bundles...
php
{ "resource": "" }
q1223
Extractor.extractFromFile
train
public function extractFromFile($filePath) { if (!is_file($filePath)) { throw new FileNotFoundException($filePath); } $extension = pathinfo($filePath, PATHINFO_EXTENSION); $this->checkDirectory(); $extractorAdapterNamespace = $this->getAdapterNamespaceGivenExte...
php
{ "resource": "" }
q1224
Extractor.checkDirectory
train
protected function checkDirectory() { $directoryPath = $this ->directory ->getDirectoryPath(); if (!is_dir($directoryPath)) { mkdir($directoryPath); } return $this; }
php
{ "resource": "" }
q1225
Extractor.getAdapterNamespaceGivenExtension
train
protected function getAdapterNamespaceGivenExtension($fileExtension) { $adapterNamespace = '\Mmoreram\Extractor\Adapter\\'; switch ($fileExtension) { case 'zip': $adapterNamespace .= 'ZipExtractorAdapter'; break; case 'rar': ...
php
{ "resource": "" }
q1226
Extension.widget
train
public static function widget($name) { $builder = static::query(); return $builder->where('type', 'widget') ->whereRaw('LOWER(name) = ?', [Str::lower($name)]) ->first(); }
php
{ "resource": "" }
q1227
JsonPretty.prettify
train
public function prettify($json, $flags = null, $indent = "\t", $is_json=null) { if (!isset($is_json)) { $is_json = $this->isJson($json); } if (!$is_json) { return $this->process(json_encode($json, $flags), $indent); } return $this->process($json, $in...
php
{ "resource": "" }
q1228
NavigationController.store
train
public function store(Request $request) { $this->validate($request, [ 'title' => 'required|max:255', 'type' => 'required|max:255|alpha|unique:navigation,type', ]); $navigation = new Navigation; $navigation->fill($request->all()); $navigation->publish...
php
{ "resource": "" }
q1229
OpenGraphHelper.html
train
public function html(array $options = [], array $namespaces = []) { $this->addNamespace('og', 'http://ogp.me/ns#'); $this->addNamespace('fb', 'http://ogp.me/ns/fb#'); if ($namespaces) { foreach ($namespaces as $ns => $url) { $this->addNamespace($ns, $url); ...
php
{ "resource": "" }
q1230
BoletoBuilder.cedente
train
public function cedente($nome, $documento, Endereco $endereco) { $this->cedente = new Cedente($nome, $documento, $endereco); return $this; }
php
{ "resource": "" }
q1231
BoletoBuilder.banco
train
public function banco($agencia, $conta) { $reflection = new ReflectionClass($this->namespace . '\\' . $this->type); $this->banco = $reflection->newInstanceArgs(array($agencia, $conta)); return $this; }
php
{ "resource": "" }
q1232
BoletoBuilder.carteira
train
public function carteira($carteira) { $reflection = new ReflectionClass($this->namespace . '\\Carteira\\Carteira' . $carteira); $this->carteira = $reflection->newInstanceArgs(); return $this; }
php
{ "resource": "" }
q1233
EloquentRepository.getPublished
train
public function getPublished() { return $this->getModel()->with([ 'menus' => function ($query) { $query->limitDepth(1)->orderBy('order', 'asc'); }, 'menus.permissions', 'menus.children', ])->published()->get(); }
php
{ "resource": "" }
q1234
FuelPHP_Sniffs_NamingConventions_UnderscoredWithScopeFunctionNameSniff.isUnderscoreName
train
public static function isUnderscoreName($string) { // If there are space in the name, it can't be valid. if (strpos($string, ' ') !== false) { return false; } if ($string !== strtolower($string)) { return false; } $validName = true; $...
php
{ "resource": "" }
q1235
ByteCodeCacheDataCollector.getByteCodeCache
train
public function getByteCodeCache() { if (count($this->data) === 0) { return $this->byteCodeCache; } $mapper = new ArrayMapper(); return $mapper->fromArray($this->data); }
php
{ "resource": "" }
q1236
RouteServiceProvider.mapWebRoutes
train
protected function mapWebRoutes(Router $router) { $this->mapArticleRoutes($router); $this->mapCategoryRoutes($router); $this->mapTagsRoutes($router); $this->mapAdministratorAuthenticationRoutes($router); $this->mapAdministratorRoutes($router); $this->mapFrontendRoutes...
php
{ "resource": "" }
q1237
RouteServiceProvider.mapAdministratorAuthenticationRoutes
train
protected function mapAdministratorAuthenticationRoutes(Router $router) { $router->group(['prefix' => admin_prefix(), 'middleware' => 'web'], function () use ($router) { $router->get('login', AuthController::class . '@showLoginForm')->name('administrator.login'); $router->get('logout...
php
{ "resource": "" }
q1238
ReflectionTools.getClassMethods
train
public function getClassMethods(\ReflectionClass $class) : array { $classes = $this->getClassHierarchy($class); $methods = []; foreach ($classes as $hClass) { $hClassName = $hClass->getName(); foreach ($hClass->getMethods() as $method) { if ($method...
php
{ "resource": "" }
q1239
ReflectionTools.getClassProperties
train
public function getClassProperties(\ReflectionClass $class) : array { $classes = $this->getClassHierarchy($class); /** @var \ReflectionProperty[] $properties */ $properties = []; foreach ($classes as $hClass) { $hClassName = $hClass->getName(); foreach ($hC...
php
{ "resource": "" }
q1240
ReflectionTools.filterReflectors
train
private function filterReflectors(array $reflectors) : array { $filteredReflectors = []; foreach ($reflectors as $index => $reflector) { if ($reflector->isPrivate()) { $filteredReflectors[] = $reflector; continue; } foreach ($refl...
php
{ "resource": "" }
q1241
ReflectionTools.getFunctionParameterTypes
train
public function getFunctionParameterTypes(\ReflectionFunctionAbstract $function) : array { return $this->cache(__FUNCTION__, $function, static function() use ($function) { $docComment = $function->getDocComment(); if ($docComment === false) { return []; }...
php
{ "resource": "" }
q1242
ReflectionTools.getParameterTypes
train
public function getParameterTypes(\ReflectionParameter $parameter) : array { $name = $parameter->getName(); $function = $parameter->getDeclaringFunction(); $types = $this->getFunctionParameterTypes($function); return isset($types[$name]) ? $types[$name] : []; }
php
{ "resource": "" }
q1243
ReflectionTools.getPropertyTypes
train
public function getPropertyTypes(\ReflectionProperty $property) : array { $docComment = $property->getDocComment(); if ($docComment === false) { return []; } if (preg_match('/@var\s+(\S+)/', $docComment, $matches) !== 1) { return []; } retur...
php
{ "resource": "" }
q1244
ReflectionTools.getPropertyClass
train
public function getPropertyClass(\ReflectionProperty $property) : ?string { $types = $this->getPropertyTypes($property); if (count($types) === 1) { $type = $types[0]; if ($type[0] === '\\') { return substr($type, 1); } } return n...
php
{ "resource": "" }
q1245
ReflectionTools.exportFunction
train
public function exportFunction(\ReflectionFunctionAbstract $function, int $excludeModifiers = 0) : string { $result = ''; if ($function instanceof \ReflectionMethod) { $modifiers = $function->getModifiers(); $modifiers &= ~ $excludeModifiers; foreach (\Reflectio...
php
{ "resource": "" }
q1246
ReflectionTools.cache
train
private function cache(string $method, $object, callable $callback) { $hash = spl_object_hash($object); if (! isset($this->cache[$method][$hash])) { $this->cache[$method][$hash] = $callback(); } return $this->cache[$method][$hash]; }
php
{ "resource": "" }
q1247
Widget.getAssignmentAttribute
train
public function getAssignmentAttribute() { if (! $this->exists) { return static::ALL_PAGES; } $count = $this->menuPivot()->count(); if ($count === 0) { return static::NO_PAGES; } elseif ($count > 1) { return static::SELECTED_PAGES; ...
php
{ "resource": "" }
q1248
Widget.menuPivot
train
public function menuPivot() { return $this->getConnection()->table('widget_menu') ->where('widget_id', $this->id) ->orWhere(function ($query) { $query->where('menu_id', 0) ->where('widget_id', $this->id); ...
php
{ "resource": "" }
q1249
Widget.syncMenuAssignment
train
public function syncMenuAssignment($menu, $assignment) { switch ($assignment) { case static::ALL_PAGES: $this->menus()->sync([static::ALL_PAGES]); break; case static::NO_PAGES: $this->menus()->detach(); break; ...
php
{ "resource": "" }
q1250
EloquentRepository.install
train
public function install($type, array $attributes) { $extension = new Extension; $extension->type = $type; $extension->name = $attributes['name']; if (isset($attributes['parameters'])) { $extension->parameters = $attributes['parameters']; } $extension...
php
{ "resource": "" }
q1251
EloquentRepository.uninstall
train
public function uninstall($id) { $extension = $this->getModel()->query()->findOrFail($id); // TODO: remove extension files. $extension->delete(); }
php
{ "resource": "" }
q1252
EloquentRepository.registerManifest
train
public function registerManifest($path) { if (! File::exists($path)) { throw new \Exception('Extension manifest file does not exist! Path: ' . $path); } $manifest = File::get($path); $manifest = json_decode($manifest, true); $this->register($manifest); }
php
{ "resource": "" }
q1253
FuelPHP_Sniffs_WhiteSpace_ControlStructureSpacingSniff.isNextTokenAnException
train
protected function isNextTokenAnException($tokens, $ptr) { return in_array($tokens[($ptr + 1)]['code'], $this->exceptions) && $tokens[($ptr + 1)]['column'] - $tokens[($ptr)]['column'] == 1; }
php
{ "resource": "" }
q1254
Convenio.ajustarNossoNumero
train
public function ajustarNossoNumero(ArrayObject $data) { $carteira = $this->carteira; switch (strlen($this->convenio)) { case 6: if (!$carteira instanceof Carteira21) { $data['NossoNumero'] = $this->convenio . $data['NossoNumero']; } ...
php
{ "resource": "" }
q1255
RedirectService.buildResponseIfApplicable
train
public function buildResponseIfApplicable(Request $httpRequest) { try { $redirect = $this->redirectStorage->getOneBySourceUriPathAndHost($httpRequest->getRelativePath(), $httpRequest->getBaseUri()->getHost()); if ($redirect === null) { return null; } ...
php
{ "resource": "" }
q1256
SphinxClient.setServer
train
public function setServer($host, $port = 0) { assert(is_string($host)); if ($host[0] == '/') { $this->_path = 'unix://'.$host; return; } if (substr($host, 0, 7) == 'unix://') { $this->_path = $host; return; } $this->_...
php
{ "resource": "" }
q1257
SphinxClient.setLimits
train
public function setLimits($offset, $limit, $max = 0, $cutoff = 0) { assert(is_int($offset)); assert(is_int($limit)); assert(is_int($max)); assert(is_int($cutoff)); assert($offset >= 0); assert($limit > 0); assert($max >= 0); assert($cutoff >= 0); ...
php
{ "resource": "" }
q1258
SphinxClient.setMaxQueryTime
train
public function setMaxQueryTime($max) { assert(is_int($max)); assert($max >= 0); $this->_maxquerytime = $max; return $this; }
php
{ "resource": "" }
q1259
SphinxClient.setMatchMode
train
public function setMatchMode($mode) { assert($mode == SPH_MATCH_ALL || $mode == SPH_MATCH_ANY || $mode == SPH_MATCH_PHRASE || $mode == SPH_MATCH_BOOLEAN || $mode == SPH_MATCH_EXTENDED || $mode == SPH_MATCH_FULLSCAN || $mode == SPH_MATCH...
php
{ "resource": "" }
q1260
SphinxClient.setRankingMode
train
public function setRankingMode($ranker, $rankexpr = '') { assert($ranker === 0 || $ranker >= 1 && $ranker < SPH_RANK_TOTAL); assert(is_string($rankexpr)); $this->_ranker = $ranker; $this->_rankexpr = $rankexpr; return $this; }
php
{ "resource": "" }
q1261
SphinxClient.setIndexWeights
train
public function setIndexWeights(array $weights) { assert(is_array($weights)); foreach ($weights as $index => $weight) { assert(is_string($index)); assert(is_int($weight)); } $this->_indexweights = $weights; return $this; }
php
{ "resource": "" }
q1262
SphinxClient.setRetries
train
public function setRetries($count, $delay = 0) { assert(is_int($count) && $count >= 0); assert(is_int($delay) && $delay >= 0); $this->_retrycount = $count; $this->_retrydelay = $delay; return $this; }
php
{ "resource": "" }
q1263
SphinxClient.query
train
public function query($query, $index = '*', $comment = '') { assert(empty($this->_reqs)); $this->AddQuery($query, $index, $comment); $results = $this->RunQueries(); $this->_reqs = array(); // just in case it failed too early if (!is_array($results)) { return fal...
php
{ "resource": "" }
q1264
SphinxClient.runQueries
train
public function runQueries() { if (empty($this->_reqs)) { $this->_error = 'no queries defined, issue AddQuery() first'; return false; } // mbstring workaround $this->_MBPush(); if (!($fp = $this->_Connect())) { $this->_MBPop(); ...
php
{ "resource": "" }
q1265
SphinxClient.open
train
public function open() { if ($this->_socket !== false) { $this->_error = 'already connected'; return false; } if (!$fp = $this->_Connect()) { return false; } // command, command version = 0, body length = 4, body = 1 $req = pack('...
php
{ "resource": "" }
q1266
SphinxClient.close
train
public function close() { if ($this->_socket === false) { $this->_error = 'not connected'; return false; } fclose($this->_socket); $this->_socket = false; return true; }
php
{ "resource": "" }
q1267
SphinxClient.status
train
public function status() { $this->_MBPush(); if (!($fp = $this->_Connect())) { $this->_MBPop(); return false; } $req = pack('nnNN', SEARCHD_COMMAND_STATUS, VER_COMMAND_STATUS, 4, 1); // len=4, body=1 if (!($this->_Send($fp, $req, 12)) || ...
php
{ "resource": "" }
q1268
SphinxClient.removeFilter
train
public function removeFilter($attribute) { assert(is_string($attribute)); foreach ($this->_filters as $key => $filter) { if ($filter['attr'] == $attribute) { unset($this->_filters[$key]); return $this; } } return $this; }
php
{ "resource": "" }
q1269
SphinxClient._Connect
train
protected function _Connect() { if ($this->_socket !== false) { // we are in persistent connection mode, so we have a socket // however, need to check whether it's still alive if (!@feof($this->_socket)) { return $this->_socket; } ...
php
{ "resource": "" }
q1270
SphinxClient._GetResponse
train
protected function _GetResponse($fp, $client_ver) { $status = ''; $response = ''; $len = 0; $ver = ''; $header = fread($fp, 8); if (strlen($header) == 8) { list($status, $ver, $len) = array_values(unpack('n2a/Nb', $header)); $left = $len; ...
php
{ "resource": "" }
q1271
SphinxClient.sphPackI64
train
protected function sphPackI64($v) { assert(is_numeric($v)); // x64 if (PHP_INT_SIZE >= 8) { $v = (int) $v; return pack('NN', $v >> 32, $v & 0xFFFFFFFF); } // x32, int if (is_int($v)) { return pack('NN', $v < 0 ? -1 : 0, $v); ...
php
{ "resource": "" }
q1272
SphinxClient.sphPackU64
train
protected function sphPackU64($v) { assert(is_numeric($v)); // x64 if (PHP_INT_SIZE >= 8) { assert($v >= 0); // x64, int if (is_int($v)) { return pack('NN', $v >> 32, $v & 0xFFFFFFFF); } // x64, bcmath ...
php
{ "resource": "" }
q1273
SphinxClient.sphUnpackU64
train
protected function sphUnpackU64($v) { list($hi, $lo) = array_values(unpack('N*N*', $v)); if (PHP_INT_SIZE >= 8) { if ($hi < 0) { $hi += (1 << 32); } // because php 5.2.2 to 5.2.5 is totally fucked up again if ($lo < 0) { $lo += (1 ...
php
{ "resource": "" }
q1274
SphinxClient.sphUnpackI64
train
protected function sphUnpackI64($v) { list($hi, $lo) = array_values(unpack('N*N*', $v)); // x64 if (PHP_INT_SIZE >= 8) { if ($hi < 0) { $hi += (1 << 32); } // because php 5.2.2 to 5.2.5 is totally fucked up again if ($lo < 0) { ...
php
{ "resource": "" }
q1275
CategoryController.actionTree
train
public function actionTree() { $models = Category::find()->orderBy('position DESC, title')->all(); $model = new Category(); return $this->render('tree', [ 'model' => $model, 'models' => $models, ]); }
php
{ "resource": "" }
q1276
ThemesController.store
train
public function store(Request $request) { $this->validate($request, [ 'theme' => 'required', ]); /** @var Configuration $config */ $config = Configuration::query()->firstOrCreate(['key' => 'theme.frontend']); $config->value = $request->get('theme'); ...
php
{ "resource": "" }
q1277
CategoriesDataTable.dataTable
train
public function dataTable() { return (new EloquentDataTable($this->query())) ->editColumn('lft', '<i class="fa fa-dot-circle-o"></i>') ->addColumn('action', function (Category $category) { return view('administrator.categories.datatables.action', $category->toArray())...
php
{ "resource": "" }
q1278
Category.getPublishedPosts
train
public function getPublishedPosts() { return PostSearch::find() ->joinWith('category') ->where(['publish_status' => Post::STATUS_PUBLISHED, 'blog_category.id' => $this->id]) ->all(); }
php
{ "resource": "" }
q1279
SnapshotAssertions.assertEqualsSnapshot
train
protected function assertEqualsSnapshot($expected, $identifier = null, $message = null) { SnapshotsManager::setSuite($this); $snapshot = SnapshotsManager::upsertSnapshotContents($identifier, $expected); $this->assertEquals($snapshot, $expected, $message); }
php
{ "resource": "" }
q1280
Table.generatePush
train
public function generatePush(Array $parameters, $label, $pushCallback, $pushClass = "\BIPBOP\Client\Push") { $reflection = new \ReflectionClass($pushClass); $query = sprintf("SELECT FROM '%s'.'%s'", $this->database->name(), $this->domNode->getAttribute("name")); $instance = $reflection->newInsta...
php
{ "resource": "" }
q1281
Category.recomputeSlug
train
protected function recomputeSlug() { $slug = $this->computeSlug(); $this->getConnection()->table($this->getTable()) ->where($this->getKeyName(), $this->id) ->update(['slug' => $slug]); $this->articles()->get()->each->touch(); }
php
{ "resource": "" }
q1282
Category.getUrl
train
public function getUrl($layout = null) { $layout = $layout ? '?layout=' . $layout : ''; return url($this->slug) . $layout; }
php
{ "resource": "" }
q1283
Attachment.addAction
train
public function addAction($action) { if ($action instanceof AttachmentAction) { $this->actions[] = $action; return $this; } elseif (is_array($action)) { $this->actions[] = new AttachmentAction($action); return $this; } throw new Inva...
php
{ "resource": "" }
q1284
Article.boot
train
protected static function boot() { parent::boot(); static::saving(function (Article $article) { $article->slug = $article->computeSlug(); }); }
php
{ "resource": "" }
q1285
Article.computeSlug
train
public function computeSlug() { if ($this->is_page) { return $this->alias; } if (! $this->exists) { $category = Category::query()->findOrFail($this->category_id); } else { $category = $this->category; } return $category->slug . '/...
php
{ "resource": "" }
q1286
Article.getRouteName
train
public function getRouteName() { if ($this->is_page) { return $this->alias; } return str_replace('category-', '', $this->category->getRouteName() . '.' . $this->alias); }
php
{ "resource": "" }
q1287
Article.visited
train
public function visited() { $this->hits++; $this->newQuery() ->toBase() ->where($this->getKeyName(), $this->getKey()) ->increment('hits'); return $this; }
php
{ "resource": "" }
q1288
Article.getTemplate
train
public function getTemplate() { $view = 'articles' . str_replace('//', '.', $this->slug); if (view()->exists($view)) { return $view; } return $this->hasTemplate() ? $this->blade_template : 'article.show'; }
php
{ "resource": "" }
q1289
WidgetMakeCommand.createJsonConfig
train
protected function createJsonConfig($name) { if ($this->files->exists($path = $this->getJsonPath())) { $this->error('Widget json config already exists!'); return; } $stub = $this->files->get($this->getJsonStubPath()); $stub = $this->replaceNamespace($stub, $...
php
{ "resource": "" }
q1290
WidgetMakeCommand.getJsonStubPath
train
protected function getJsonStubPath() { $stubPath = $this->laravel->make('config')->get('laravel-widgets.widget_json_stub'); return $this->laravel->basePath() . '/' . $stubPath; }
php
{ "resource": "" }
q1291
WidgetMakeCommand.createView
train
protected function createView() { if ($this->files->exists($path = $this->getViewPath())) { $this->error('View already exists!'); return; } $this->makeDirectory($path); $view = $this->files->get($this->getViewStub('view')); $this->files->put($path, $...
php
{ "resource": "" }
q1292
WidgetMakeCommand.getViewStub
train
public function getViewStub($key) { $stubPath = $this->laravel->make('config')->get('laravel-widgets.widget_' . $key . '_stub'); return $this->laravel->basePath() . '/' . $stubPath; }
php
{ "resource": "" }
q1293
WebService.post
train
public function post($query, Array $parameters = [], $autoParser = true) { curl_setopt_array($this->resource, [ CURLOPT_POSTFIELDS => array_merge($parameters, [ self::PARAMETER_QUERY => $query, self::PARAMETER_APIKEY => $this->apiKey ]) ]); ...
php
{ "resource": "" }
q1294
WebService.assert
train
public static function assert(\DOMDocument $dom) { $queryNode = (new \DOMXPath($dom))->query("/BPQL/header/exception"); if ($queryNode->length) { $nodeException = $queryNode->item(0); $source = $nodeException->getAttribute("source"); $code = $nodeException->getAttribu...
php
{ "resource": "" }
q1295
MediaController.browse
train
public function browse(Request $request, $filter = null) { $this->template = 'layouts.component'; $this->filter = $filter; return $this->index($request); }
php
{ "resource": "" }
q1296
MediaController.folderIsNotAccessible
train
protected function folderIsNotAccessible(Request $request) { if (isset($request['folder']) && empty($request->get('folder'))) { return true; } return ! Storage::exists($this->currentDir) && $request->has('folder') || $request->get('folder') === 'public'; }
php
{ "resource": "" }
q1297
MediaController.scanFiles
train
protected function scanFiles($current_directory) { $files = collect(Storage::files($current_directory)); $files = $files->filter(function ($file) { $ext = File::extension($file); if ($this->filter === 'images') { return in_array($ext, $this->config->get('medi...
php
{ "resource": "" }
q1298
MediaController.buildThumbnails
train
protected function buildThumbnails($files) { $thumbnails = []; foreach ($files as $file) { if (file_can_have_thumbnail($file)) { $thumbnails[$file] = (string) $this->image ->make(Storage::get($file)) ->resize(20, 20)->encode('data-...
php
{ "resource": "" }
q1299
MediaController.buildDirectory
train
protected function buildDirectory($directories, $parent) { $directories = $directories->map(function ($dir) use ($parent) { $dir = str_replace($parent . '/', '', $dir); return $dir; }); $html = '<ul>'; $directories->each(function ($dir) use (&$html, $parent)...
php
{ "resource": "" }