_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q6500
AdvancedSearchable.resolveSearchKeywords
train
protected function resolveSearchKeywords(string $keyword): array { $basic = []; $advanced = []; $tags = \array_map(function ($value) { [$tag, ] = \explode(':', $value, 2); return "{$tag}:"; }, \array_keys($this->getSearchableRules())); if (\preg_mat...
php
{ "resource": "" }
q6501
TreeNodeSurv.loadNodeCache
train
public function loadNodeCache($nID = -3, $nCache = []) { if (sizeof($nCache) > 0) { if (isset($nCache["pID"])) { $this->parentID = $nCache["pID"]; } if (isset($nCache["pOrd"])) { $this->parentOrd = $nCache["pOrd"]; } ...
php
{ "resource": "" }
q6502
GlobalsTables.getTblFldTypes
train
public function getTblFldTypes($tbl) { $flds = []; if (isset($this->fldTypes[$tbl]) && sizeof($this->fldTypes[$tbl]) > 0) { $flds = $this->fldTypes[$tbl]; } else { $tblRow = SLTables::where('TblName', $tbl) ->first(); if ($tblRow) { ...
php
{ "resource": "" }
q6503
SurvLoopController.checkSystemInit
train
public function checkSystemInit() { if (!session()->has('chkSysInit') || $GLOBALS["SL"]->REQ->has('refresh')) { $sysChk = User::select('id') ->get(); if ($sysChk->isEmpty()) { return $this->freshUser($GLOBALS["SL"]->REQ); } $sys...
php
{ "resource": "" }
q6504
SurvLoopController.isPageFirstTime
train
protected function isPageFirstTime($currPage = '') { if (trim($currPage) == '') { $currPage = $this->v["currPage"][0]; } $chk = SLUsersActivity::where('UserActUser', Auth::user()->id) ->where('UserActCurrPage', 'LIKE', '%'.$currPage) ->get(); if ($...
php
{ "resource": "" }
q6505
SurvLoopController.doublecheckSurvTables
train
protected function doublecheckSurvTables() { if (!session()->has('doublecheckSurvTables')) { $chks = []; $chks[] = "ALTER TABLE `SL_Tree` CHANGE `TreeRootURL` `TreeSlug` VARCHAR(255)"; $chks[] = "ALTER TABLE `SL_Tree` ADD `TreeOpts` INT(11) DEFAULT 1 AFTER `TreeCoreTable`...
php
{ "resource": "" }
q6506
UpdatePasswordController.runUpdate
train
public function runUpdate(Request $request) { $user = User::find(Auth::id()); $this->validate($request, [ 'old' => 'required', 'password' => 'required|min:8|confirmed', ]); if (Auth::attempt(['name' => $user->name, 'password' => $request->old])) { ...
php
{ "resource": "" }
q6507
PHPArray.encode
train
protected function encode($data) { $data = [ '<?php', '', 'return ' . $this->render($data, 0) . ';', ]; return implode(Data::LE, $data); }
php
{ "resource": "" }
q6508
HumanDate.transform
train
public function transform($date) { if (!$date instanceof DateTime) { $date = new DateTime($date); } $current = new DateTime('now'); if ($this->isToday($date)) { return $this->trans('Today'); } if ($this->isYesterday($date)) { ret...
php
{ "resource": "" }
q6509
AttributeAttributeType.copy
train
public function copy($deepCopy = false) { // we use get_class(), because this might be a subclass $clazz = get_class($this); $copyObj = new $clazz(); $this->copyInto($copyObj, $deepCopy); return $copyObj; }
php
{ "resource": "" }
q6510
AttributeAttributeType.setAttribute
train
public function setAttribute(ChildAttribute $v = null) { if ($v === null) { $this->setAttributeId(NULL); } else { $this->setAttributeId($v->getId()); } $this->aAttribute = $v; // Add binding for other direction of this n:n relationship. // If...
php
{ "resource": "" }
q6511
AttributeAttributeType.getAttribute
train
public function getAttribute(ConnectionInterface $con = null) { if ($this->aAttribute === null && ($this->attribute_id !== null)) { $this->aAttribute = AttributeQuery::create()->findPk($this->attribute_id, $con); /* The following can be used additionally to guarantee ...
php
{ "resource": "" }
q6512
AttributeAttributeType.getAttributeType
train
public function getAttributeType(ConnectionInterface $con = null) { if ($this->aAttributeType === null && ($this->attribute_type_id !== null)) { $this->aAttributeType = ChildAttributeTypeQuery::create()->findPk($this->attribute_type_id, $con); /* The following can be used additionall...
php
{ "resource": "" }
q6513
AttributeAttributeType.initAttributeTypeAvMetas
train
public function initAttributeTypeAvMetas($overrideExisting = true) { if (null !== $this->collAttributeTypeAvMetas && !$overrideExisting) { return; } $this->collAttributeTypeAvMetas = new ObjectCollection(); $this->collAttributeTypeAvMetas->setModel('\AttributeType\Model\A...
php
{ "resource": "" }
q6514
AttributeAttributeType.getAttributeTypeAvMetas
train
public function getAttributeTypeAvMetas($criteria = null, ConnectionInterface $con = null) { $partial = $this->collAttributeTypeAvMetasPartial && !$this->isNew(); if (null === $this->collAttributeTypeAvMetas || null !== $criteria || $partial) { if ($this->isNew() && null === $this->coll...
php
{ "resource": "" }
q6515
AttributeAttributeType.countAttributeTypeAvMetas
train
public function countAttributeTypeAvMetas(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collAttributeTypeAvMetasPartial && !$this->isNew(); if (null === $this->collAttributeTypeAvMetas || null !== $criteria || $partial) { if ($this->is...
php
{ "resource": "" }
q6516
AttributeAttributeType.addAttributeTypeAvMeta
train
public function addAttributeTypeAvMeta(ChildAttributeTypeAvMeta $l) { if ($this->collAttributeTypeAvMetas === null) { $this->initAttributeTypeAvMetas(); $this->collAttributeTypeAvMetasPartial = true; } if (!in_array($l, $this->collAttributeTypeAvMetas->getArrayCopy()...
php
{ "resource": "" }
q6517
AttributeAttributeType.getAttributeTypeAvMetasJoinAttributeAv
train
public function getAttributeTypeAvMetasJoinAttributeAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildAttributeTypeAvMetaQuery::create(null, $criteria); $query->joinWith('AttributeAv', $joinBehavior); return $this->getAttributeTypeAvMetas($query, $con); ...
php
{ "resource": "" }
q6518
ChainSearchProvider.getClient
train
public function getClient() { $client = $this->reduceFirst(function (SearchProviderInterface $provider) { return $provider->getClient(); }); if (null === $client) { throw new \RuntimeException('No provider was able to return a client'); } return $cli...
php
{ "resource": "" }
q6519
ChainSearchProvider.getIndex
train
public function getIndex($indexName) { return $this->reduceFirst(function (SearchProviderInterface $provider) use ($indexName) { return $provider->getIndex($this->indexNamePrefix . $indexName); }); }
php
{ "resource": "" }
q6520
ChainSearchProvider.createDocument
train
public function createDocument($document, $uid, $indexName = '', $indexType = '') { return new DocumentReference($document, $uid, $this->indexNamePrefix . $indexName, $indexType); }
php
{ "resource": "" }
q6521
ChainSearchProvider.addDocument
train
public function addDocument($indexName, $indexType, $document, $uid) { if ("" === $indexName && $document instanceof DocumentReference) { $indexName = $document->getIndexName(); } else { $indexName = $this->indexNamePrefix . $indexName; } $this->mapProviders(...
php
{ "resource": "" }
q6522
ChainSearchProvider.addDocuments
train
public function addDocuments($documents, $indexName = '', $indexType = '') { if ("" === $indexName && isset($documents[0])) { $indexName = $documents[0]->getIndexName(); } else { $indexName = $this->indexNamePrefix . $indexName; } $this->mapProviders(function...
php
{ "resource": "" }
q6523
ChainSearchProvider.deleteDocument
train
public function deleteDocument($indexName, $indexType, $uid) { $this->mapProviders(function (SearchProviderInterface $provider) use ($indexName, $indexType, $uid) { $provider->deleteDocument($this->indexNamePrefix . $indexName, $indexType, $uid); }); }
php
{ "resource": "" }
q6524
ChainSearchProvider.deleteIndex
train
public function deleteIndex($indexName) { $this->mapProviders(function (SearchProviderInterface $provider) use ($indexName) { try { $provider->deleteIndex($this->indexNamePrefix . $indexName); } catch (\Exception $e) { // we don’t care } ...
php
{ "resource": "" }
q6525
ValidatingMiddleware.handle
train
public function handle($command, Closure $next) { if (property_exists($command, 'rules') && is_array($command->rules)) { $this->validate($command); } return $next($command); }
php
{ "resource": "" }
q6526
ValidatingMiddleware.validate
train
protected function validate($command) { if (method_exists($command, 'validate')) { $command->validate(); } $messages = property_exists($command, 'validationMessages') ? $command->validationMessages : []; $validator = $this->factory->make($this->getData($command), $comma...
php
{ "resource": "" }
q6527
ValidatingMiddleware.getData
train
protected function getData($command) { $data = []; foreach ((new ReflectionClass($command))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) { $name = $property->getName(); $value = $property->getValue($command); if (in_array($name, ['rules', 'validat...
php
{ "resource": "" }
q6528
TelegramHandler.send
train
private function send($message) { $url = self::BASE_URI . $this->token . '/sendMessage'; $data = [ 'chat_id' => $this->chatId, 'text' => $message, 'disable_web_page_preview' => true // Just in case there is a link in the messag...
php
{ "resource": "" }
q6529
HttpTrait.getParameter
train
protected function getParameter($key, $type = Validate::TYPE_STRING, array $filter = array(), $title = null, $required = true) { $parameter = $this->request->getUri()->getParameter($key); if (isset($parameter)) { return $this->validate->apply($parameter, $type, $filter, $title, $require...
php
{ "resource": "" }
q6530
HttpTrait.setBody
train
protected function setBody($data) { $this->responseWriter->setBody($this->response, $data, $this->request); }
php
{ "resource": "" }
q6531
RedirectTrait.forward
train
protected function forward($source, array $parameters = array()) { $path = $this->reverseRouter->getPath($source, $parameters); if ($path !== null) { $this->request->setUri($this->request->getUri()->withPath($path)); $this->loader->load($this->request, $this->response, $thi...
php
{ "resource": "" }
q6532
RedirectTrait.redirect
train
protected function redirect($source, array $parameters = array(), $code = 307) { if ($source instanceof Url) { $url = $source->toString(); } elseif (filter_var($source, FILTER_VALIDATE_URL)) { $url = $source; } else { $url = $this->reverseRouter->getUrl($s...
php
{ "resource": "" }
q6533
GeneratorService.generateRemotingApi
train
public function generateRemotingApi() { $list = array(); foreach($this->remotingBundles as $bundle) { $bundleRef = new \ReflectionClass($bundle); $controllerDir = new Finder(); $controllerDir->files()->in(dirname($bundleRef->getFileName()).'/Controller/')->name('/.*Co...
php
{ "resource": "" }
q6534
GeneratorService.tryToGetJoinColumnNameOfMappedBy
train
protected function tryToGetJoinColumnNameOfMappedBy($annotation){ $annotation = $this->tryToGetJoinColumnAnnotationOfMappedBy($annotation); if ($annotation !== null) { if ($annotation instanceof JoinColumn) { return $annotation->name; } else if ($annotation instan...
php
{ "resource": "" }
q6535
GeneratorService.tryToGetJoinColumnAnnotationOfMappedBy
train
protected function tryToGetJoinColumnAnnotationOfMappedBy($annotation){ $result = null; if($annotation->targetEntity && $annotation->mappedBy) { $result = $this->getAnnotation( $annotation->targetEntity, $annotation->mappedBy, 'Doctrine\ORM\Map...
php
{ "resource": "" }
q6536
GeneratorService.getEntityColumnType
train
public function getEntityColumnType($entity, $property) { $classRef = new \ReflectionClass($entity); if ($classRef->hasProperty($property)) { $propertyRef = $classRef->getProperty($property); $columnRef = $this->annoReader->getPropertyAnnotation($propertyRef, 'Doctrine\ORM\Mappin...
php
{ "resource": "" }
q6537
GeneratorService.getValidator
train
protected function getValidator($name, $annotation) { $validate = array(); switch($name) { case 'NotBlank': case 'NotNull': $validate['type'] = "presence"; break; case 'Email': $validate['type'] = "email"; ...
php
{ "resource": "" }
q6538
GeneratorService.getModelName
train
public function getModelName($entity) { $classRef = new \ReflectionClass($entity); $classModelAnnotation = $this->annoReader->getClassAnnotation($classRef, 'Tpg\ExtjsBundle\Annotation\Model'); if ($classModelAnnotation !== null) { if ($classModelAnnotation->name) { re...
php
{ "resource": "" }
q6539
Dispatch.route
train
public function route(RequestInterface $request, ResponseInterface $response, Context $context = null) { $this->level++; $this->eventDispatcher->dispatch(Event::REQUEST_INCOMING, new RequestIncomingEvent($request)); // load controller if ($context === null) { $factory =...
php
{ "resource": "" }
q6540
Queue.consume
train
public static function consume($name) { $config = static::get($name); if (empty($config['consume'])) { throw new Exception('Missing consumer configuration (' . $name . ')'); } $config = $config['consume']; $config += [ 'connection' => 'rabbit', ...
php
{ "resource": "" }
q6541
Queue.publish
train
public static function publish($name, $data, array $options = []) { $config = static::get($name); if (empty($config['publish'])) { throw new Exception('Missing publisher configuration (' . $name . ')'); } $config = $config['publish']; $config += $options; ...
php
{ "resource": "" }
q6542
ExtjsExtension.injectModel
train
public function injectModel() { $params = func_get_args(); $injection = array_shift($params); if ($injection == false) { $url = $this->router->generate('extjs_generate_model', array('model'=>$params), false); return "<script type='text/javascript' src='$url'></script>"; ...
php
{ "resource": "" }
q6543
MenuItemsTable.beforeSave
train
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options): void { // fallback to default icon if (!$entity->get('icon')) { $entity->set('icon', Configure::read('Icons.default')); } // fallback to hashtag as default url if (!$entity->...
php
{ "resource": "" }
q6544
ObjectTrait.set
train
public function set($name, $value, $where = '') { if (($name && $this->canSetProperty($name)) || strpos($name, 'on ') === 0 || strpos($name, 'as ') === 0) { parent::__set($name, $value); } else { $this->setItem($name, $value, $where); } }
php
{ "resource": "" }
q6545
ObjectTrait.add
train
public function add($name, $value = null, $where = '') { if (!$this->has($name)) { $this->set($name, $value, $where); } return $this; }
php
{ "resource": "" }
q6546
FileCommentCopyrightSniff.processCopyrightTags
train
private function processCopyrightTags(File $phpcs_file, $stack_ptr, $comment_start): void { $tokens = $phpcs_file->getTokens(); foreach ($tokens[$comment_start]['comment_tags'] as $tag) { if ($tokens[$tag]['content'] === $this->copyright_tag) { $this->checkForContentInCop...
php
{ "resource": "" }
q6547
ManagerTrait.getItem
train
public function getItem($name, $default = null) { if (empty($this->_items[$name])) { $this->_items[$name] = $default; } $item = &$this->_items[$name]; if (is_array($item) || is_null($item)) { $item = $this->createItem($name, $item ?: []); } re...
php
{ "resource": "" }
q6548
ManagerTrait.getItems
train
public function getItems() { foreach ($this->_items as $name => $item) { $this->getItem($name); } return $this->_items; }
php
{ "resource": "" }
q6549
UriExtended.withoutQueryValue
train
public function withoutQueryValue($key):UriExtended{ $current = $this->getQuery(); if($current === ''){ return $this; } $decodedKey = \rawurldecode($key); $result = \array_filter(\explode('&', $current), function($part) use ($decodedKey){ return \rawurldecode(\explode('=', $part)[0]) !== $decodedKey;...
php
{ "resource": "" }
q6550
AttributeType.initAttributeAttributeTypes
train
public function initAttributeAttributeTypes($overrideExisting = true) { if (null !== $this->collAttributeAttributeTypes && !$overrideExisting) { return; } $this->collAttributeAttributeTypes = new ObjectCollection(); $this->collAttributeAttributeTypes->setModel('\Attribute...
php
{ "resource": "" }
q6551
AttributeType.getAttributeAttributeTypes
train
public function getAttributeAttributeTypes($criteria = null, ConnectionInterface $con = null) { $partial = $this->collAttributeAttributeTypesPartial && !$this->isNew(); if (null === $this->collAttributeAttributeTypes || null !== $criteria || $partial) { if ($this->isNew() && null === $t...
php
{ "resource": "" }
q6552
AttributeType.countAttributeAttributeTypes
train
public function countAttributeAttributeTypes(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collAttributeAttributeTypesPartial && !$this->isNew(); if (null === $this->collAttributeAttributeTypes || null !== $criteria || $partial) { if (...
php
{ "resource": "" }
q6553
AttributeType.addAttributeAttributeType
train
public function addAttributeAttributeType(ChildAttributeAttributeType $l) { if ($this->collAttributeAttributeTypes === null) { $this->initAttributeAttributeTypes(); $this->collAttributeAttributeTypesPartial = true; } if (!in_array($l, $this->collAttributeAttributeTyp...
php
{ "resource": "" }
q6554
AttributeType.getAttributeAttributeTypesJoinAttribute
train
public function getAttributeAttributeTypesJoinAttribute($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildAttributeAttributeTypeQuery::create(null, $criteria); $query->joinWith('Attribute', $joinBehavior); return $this->getAttributeAttributeTypes($query, $c...
php
{ "resource": "" }
q6555
AttributeType.initAttributeTypeI18ns
train
public function initAttributeTypeI18ns($overrideExisting = true) { if (null !== $this->collAttributeTypeI18ns && !$overrideExisting) { return; } $this->collAttributeTypeI18ns = new ObjectCollection(); $this->collAttributeTypeI18ns->setModel('\AttributeType\Model\Attribute...
php
{ "resource": "" }
q6556
AttributeType.getAttributeTypeI18ns
train
public function getAttributeTypeI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collAttributeTypeI18nsPartial && !$this->isNew(); if (null === $this->collAttributeTypeI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAttrib...
php
{ "resource": "" }
q6557
AttributeType.countAttributeTypeI18ns
train
public function countAttributeTypeI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collAttributeTypeI18nsPartial && !$this->isNew(); if (null === $this->collAttributeTypeI18ns || null !== $criteria || $partial) { if ($this->isNew() ...
php
{ "resource": "" }
q6558
AttributeType.addAttributeTypeI18n
train
public function addAttributeTypeI18n(ChildAttributeTypeI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); $this->currentTranslations[$locale] = $l; } if ($this->collAttributeTypeI18ns === null) { $this->initAttributeTypeI18ns(); ...
php
{ "resource": "" }
q6559
AttributeType.validate
train
public function validate(Validator $validator = null) { if (null === $validator) { $validator = new Validator(new ClassMetadataFactory(new StaticMethodLoader()), new ConstraintValidatorFactory(), new DefaultTranslator()); } $failureMap = new ConstraintViolationList(); i...
php
{ "resource": "" }
q6560
RabbitMQConnection.logQueries
train
public function logQueries($enable = null) { if ($enable !== null) { $this->_logQueries = $enable; } if ($this->_logQueries) { return $this->_logQueries; } return $this->_logQueries = $enable; }
php
{ "resource": "" }
q6561
RabbitMQConnection.logger
train
public function logger($logger = null) { if ($logger) { $this->_logger = $logger; } if ($this->_logger) { return $this->_logger; } $this->_logger = new QueryLogger(); return $this->_logger; }
php
{ "resource": "" }
q6562
RabbitMQConnection.connect
train
public function connect() { $connection = $this->_connection; $connection->setLogin($this->_config['user']); $connection->setPassword($this->_config['password']); $connection->setHost($this->_config['host']); $connection->setPort($this->_config['port']); $connection->...
php
{ "resource": "" }
q6563
RabbitMQConnection.channel
train
public function channel($name, $options = []) { if (empty($this->_channels[$name])) { $this->_channels[$name] = new AMQPChannel($this->connection()); if (!empty($options['prefetchCount'])) { $this->_channels[$name]->setPrefetchCount((int)$options['prefetchCount']); ...
php
{ "resource": "" }
q6564
RabbitMQConnection.exchange
train
public function exchange($name, $options = []) { if (empty($this->_exchanges[$name])) { $channel = $this->channel($name, $options); $exchange = new AMQPExchange($channel); $exchange->setName($name); if (!empty($options['type'])) { $exchange->s...
php
{ "resource": "" }
q6565
RabbitMQConnection.queue
train
public function queue($name, $options = []) { if (empty($this->_queues[$name])) { $channel = $this->channel($name, $options); $queue = new AMQPQueue($channel); $queue->setName($name); if (!empty($options['flags'])) { $queue->setFlags($options[...
php
{ "resource": "" }
q6566
RabbitMQConnection._prepareMessage
train
protected function _prepareMessage($data, array $options) { $attributes = []; $options += [ 'silent' => false, 'compress' => true, 'serializer' => extension_loaded('msgpack') ? 'msgpack' : 'json', 'delivery_mode' => 1 ]; switch ($opti...
php
{ "resource": "" }
q6567
TreeSurvBasicNav.chkKidMapTrue
train
protected function chkKidMapTrue($nID) { $found = false; if (sizeof($this->kidMaps) > 0) { foreach ($this->kidMaps as $parent => $kids) { if (sizeof($kids) > 0) { foreach ($kids as $nKid => $ress) { if ($nID == $nKid && sizeof($...
php
{ "resource": "" }
q6568
Contentful.getContentTypeByName
train
public function getContentTypeByName($name, $space, array $options = []) { $envelope = $this->findEnvelopeForSpace($space); $promise = coroutine( function () use ($name, $space, $envelope, $options) { $contentTypeFromEnvelope = $envelope->findContentTypeByName($name); ...
php
{ "resource": "" }
q6569
Contentful.flushCache
train
public function flushCache($spaceName) { $spaceData = $this->getSpaceDataForName($spaceName); return $this->ensureCache($spaceData['cache'])->clear(); }
php
{ "resource": "" }
q6570
Contentful.completeParameter
train
private function completeParameter(ParameterInterface $parameter, $spaceName) { if (!$parameter instanceof IncompleteParameterInterface) { return $parameter; } switch ($parameter->getName()) { case 'content_type_name': $contentTypeFilter = $this->reso...
php
{ "resource": "" }
q6571
SchemaApiAbstract.parseRequest
train
protected function parseRequest(RequestInterface $request, MethodAbstract $method) { if ($method->hasRequest()) { $schema = $method->getRequest(); if ($schema instanceof Passthru) { $data = $this->requestReader->getBody($request); } elseif ($schema instanc...
php
{ "resource": "" }
q6572
SchemaApiAbstract.sendResponse
train
private function sendResponse(MethodAbstract $method, RequestInterface $request, ResponseInterface $response, $data) { $statusCode = $response->getStatusCode(); if (empty($statusCode)) { // in case we have only one defined response use this code $responses = $method->getRespo...
php
{ "resource": "" }
q6573
SchemaApiAbstract.getResource
train
private function getResource() { $resource = $this->resourceListing->getResource($this->context->getPath(), $this->context->getVersion()); if (!$resource instanceof Resource) { throw new StatusCode\InternalServerErrorException('Resource is not available'); } return $res...
php
{ "resource": "" }
q6574
ContentTypePromise.getField
train
public function getField($fieldId) { $resolved = $this->getResolved(); if (!$resolved instanceof ContentTypeInterface) { return null; } return $resolved->getField($fieldId); }
php
{ "resource": "" }
q6575
UserProvider.get
train
public function get(string $key = null, $default = null) { $key = \str_replace('.', '/user-', $key); $value = Arr::get($this->items, $key); // We need to consider if the value pending to be deleted, // in this case return the default. if ($value === ':to-be-deleted:') { ...
php
{ "resource": "" }
q6576
Python.isJson
train
protected function isJson($string) { $output = json_decode($string, true); if ($output === null) { return false; } return true; }
php
{ "resource": "" }
q6577
BasicDocumentor.getTemplate
train
protected static function getTemplate($path) { if(file_exists($path)) $template = file_get_contents($path); elseif(file_exists(__DIR__ . '/templates/' . $path)) $template = file_get_contents(__DIR__ . '/templates/' . $path); else throw new \InvalidArgument...
php
{ "resource": "" }
q6578
RedisSessionHandler.read
train
public function read($sessionId) { $sessionId = $this->keyPrefix . $sessionId; $sessionData = $this->redis->get($sessionId); $this->redis->expire($sessionId, $this->maxLifetime); return $sessionData; }
php
{ "resource": "" }
q6579
NotFoundManager.removeForRedirect
train
public function removeForRedirect(Redirect $redirect) { $notFounds = $this->om->getRepository($this->class)->findBy(array('path' => $redirect->getSource())); foreach ($notFounds as $notFound) { $this->om->remove($notFound); } $this->om->flush(); }
php
{ "resource": "" }
q6580
PublicNodeVersions.getRef
train
public function getRef($nodeVersionId) { $this->initNodeVersions(); return isset($this->refs[$nodeVersionId]) ? $this->refs[$nodeVersionId] : null; }
php
{ "resource": "" }
q6581
PublicNodeVersions.getNodeRef
train
public function getNodeRef($nodeId, $lang = null) { $this->initNodeVersions(); $lang = $lang ?: $this->currentLocale->getCurrentLocale(); return isset($this->nodeRefs[$lang][$nodeId]) ? $this->nodeRefs[$lang][$nodeId] : null; }
php
{ "resource": "" }
q6582
Parser.read
train
public function read($filePath) { $this->rawEntries = array(); $this->currentEntry = $this->createNewEntryAsArray(); $this->state = null; $this->justNewEntry = false; $handle = $this->openFile($filePath); while (!feof($handle)) { $line = trim(fgets($handl...
php
{ "resource": "" }
q6583
Parser.prepareResults
train
protected function prepareResults() { $this->entriesAsArrays = array(); $this->entries = array(); $this->headers = array(); $counter = 0; foreach ($this->rawEntries as $entry) { $entry = $this->prepareEntry($entry, $counter); $id = $this->getMsgId($e...
php
{ "resource": "" }
q6584
Parser.removeFuzzyFlagForMsgId
train
protected function removeFuzzyFlagForMsgId($msgid) { if (!isset($this->entriesAsArrays[$msgid])) { throw new \Exception('Entry does not exist'); } if ($this->entriesAsArrays[$msgid]['fuzzy']) { $flags = $this->entriesAsArrays[$msgid]['flags']; unset($flags...
php
{ "resource": "" }
q6585
Parser.updateEntries
train
public function updateEntries($msgid, $translation) { if ( !isset($this->entriesAsArrays[$msgid]) || !is_array($translation) || sizeof($translation) != sizeof($this->entriesAsArrays[$msgid]['msgstr']) ) { throw new \Exception('Cannot update entry trans...
php
{ "resource": "" }
q6586
Parser.updateEntry
train
public function updateEntry($msgid, $translation, $positionMsgstr = 0) { if ( !isset($this->entriesAsArrays[$msgid]) || !is_string($translation) || !isset($this->entriesAsArrays[$msgid]['msgstr'][$positionMsgstr]) ) { throw new \Exception('Cannot updat...
php
{ "resource": "" }
q6587
AdminDatabaseInstall.manualMySql
train
public function manualMySql(Request $request) { $this->admControlInit($request, '/dashboard/db/all'); if ($this->v["uID"] == 1) { // && in_array($_SERVER["REMOTE_ADDR"], ['192.168.10.1'])) { $this->v["manualMySql"] = 'Connected successfully<br />'; $db = mysqli_connect(env('DB_HOST...
php
{ "resource": "" }
q6588
Metable.getOriginalMetaData
train
public function getOriginalMetaData(string $key, $default = null) { $meta = $this->accessMetableAttribute($this->getOriginal('meta')); return $meta->get($key, $default); }
php
{ "resource": "" }
q6589
Metable.getMetaData
train
public function getMetaData(string $key, $default = null) { $meta = $this->getAttribute('meta'); return $meta->get($key, $default); }
php
{ "resource": "" }
q6590
Metable.putMetaData
train
public function putMetaData($key, $value = null): void { $meta = $this->getAttribute('meta'); if (\is_array($key)) { foreach ($key as $name => $value) { $meta->put($name, $value); } } else { $meta->put($key, $value); } $th...
php
{ "resource": "" }
q6591
Metable.forgetMetaData
train
public function forgetMetaData($key): void { $meta = $this->getAttribute('meta'); if (\is_array($key)) { foreach ($key as $name) { $meta->forget($name); } } else { $meta->forget($key); } $this->setMetaAttribute($meta); ...
php
{ "resource": "" }
q6592
Metable.accessMetableAttribute
train
protected function accessMetableAttribute($value): Meta { $meta = []; if ($value instanceof Meta) { return $value; } elseif (! \is_null($value)) { $meta = $this->fromJson($value); } return new Meta($meta); }
php
{ "resource": "" }
q6593
TreeSurvNodeEdit.updateTreeOpts
train
public function updateTreeOpts($treeID = -3) { $treeRow = $GLOBALS["SL"]->treeRow; if ($treeID <= 0) { $treeID = $GLOBALS["SL"]->treeID; } else { $treeRow = SLTree::find($treeID); } if ($treeRow->TreeType == 'Page') { /* // auto-setting ...
php
{ "resource": "" }
q6594
Model.shard
train
static function shard($collector = null) { if (func_num_args()) { if ($collector) { static::$_shards[static::class] = $collector; } else { unset(static::$_shards[static::class]); } return; } if (!isset(static::$_shards[static::class])) { stat...
php
{ "resource": "" }
q6595
Model.find
train
public static function find($options = []) { $options = Set::extend(static::query(), $options); $schema = static::definition(); return $schema->query(['query' => $options] + ['finders' => static::finders()]); }
php
{ "resource": "" }
q6596
Model.load
train
public static function load($id, $options = [], $fetchOptions = []) { $options = ['conditions' => [static::definition()->key() => $id]] + $options; return static::find($options)->first($fetchOptions); }
php
{ "resource": "" }
q6597
Model.reset
train
public static function reset() { unset(static::$_dependencies[static::class]); static::conventions(null); static::connection(null); static::definition(null); static::validator(null); static::query([]); unset(static::$_unicities[static::class]); unset(s...
php
{ "resource": "" }
q6598
Model.fetch
train
public function fetch($name) { return $this->get($name, function($instance, $name) { $collection = [$instance]; $this->schema()->embed($collection, $name); return isset($this->_data[$name]) ? $this->_data[$name] : null; }); }
php
{ "resource": "" }
q6599
Model.sync
train
public function sync($data = false) { if ($this->_exists !== null) { return; } $id = $this->id(); if ($id !== null) { $persisted = static::load($id); if ($persisted && $data) { $this->amend($persisted->data(), ['exists' => true]); ...
php
{ "resource": "" }