_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q237800
HTMLWriter.visitForm
train
public function visitForm(FormInterface $form) { $template = "form/{$form->getType()}.twig"; return $this ->loadTemplate($template) ->render( [ "id" => $form->getId(), "classes" => $form->getClasses(), ...
php
{ "resource": "" }
q237801
HTMLWriter.visitFormAction
train
public function visitFormAction(FormActionInterface $formAction) { $template = "form-action/{$formAction->getType()}.twig"; return $this ->loadTemplate($template) ->render( [ "label" => $formAction->getLabel(), "target"...
php
{ "resource": "" }
q237802
HTMLWriter.visitFilter
train
public function visitFilter(FilterInterface $filter) { if ($filter instanceof DummyFilter) { $type = 'dummy'; } elseif ($filter instanceof SelectFilter) { $type = 'select'; } elseif ($filter instanceof SearchFilter) { $type = 'search'; } elseif ($f...
php
{ "resource": "" }
q237803
Zend_Http_UserAgent_AbstractDevice._restoreFromArray
train
protected function _restoreFromArray(array $spec) { foreach ($spec as $key => $value) { if (property_exists($this, $key)) { $this->{$key} = $value; } } }
php
{ "resource": "" }
q237804
Zend_Http_UserAgent_AbstractDevice.setGroup
train
public function setGroup($group, $feature) { if (!isset($this->_aGroup[$group])) { $this->_aGroup[$group] = array(); } if (!in_array($feature, $this->_aGroup[$group])) { $this->_aGroup[$group][] = $feature; } return $this; }
php
{ "resource": "" }
q237805
Zend_Http_UserAgent_AbstractDevice._matchAgentAgainstSignatures
train
protected static function _matchAgentAgainstSignatures($userAgent, $signatures) { $userAgent = strtolower($userAgent); foreach ($signatures as $signature) { if (!empty($signature)) { if (strpos($userAgent, $signature) !== false) { // Browser signature ...
php
{ "resource": "" }
q237806
ehough_chaingang_impl_StandardContext.get
train
public final function get($key) { if (isset($this->_map[$key])) { return $this->_map[$key]; } return null; }
php
{ "resource": "" }
q237807
ehough_chaingang_impl_StandardContext.putAll
train
public final function putAll(array $values) { if (! is_array($values)) { return; } foreach ($values as $key => $value) { $this->put($key, $value); } }
php
{ "resource": "" }
q237808
ehough_chaingang_impl_StandardContext.remove
train
public final function remove($key) { $previous = $this->get($key); if (isset($this->_map[$key])) { unset($this->_map[$key]); } return $previous; }
php
{ "resource": "" }
q237809
ArrayTranslator.initLocale
train
protected function initLocale($locale) { $file = $this->localeDir . '/' . $locale . '.php'; if (file_exists($file)) { $data = include $file; if (!is_array($data)) { $data = []; } } else { $data = []; } if (!iss...
php
{ "resource": "" }
q237810
ArrayTranslator.getPluralIndex
train
protected function getPluralIndex(callable $pluralForm, $number) { $nplurals = 0; $plural = 0; call_user_func_array($pluralForm, [&$nplurals, &$plural, $number]); if (is_bool($plural)) { $plural = $plural ? 1 : 0; } if ($plural < 0) { $plura...
php
{ "resource": "" }
q237811
ClassLoader.addNamespace
train
public function addNamespace($prefix, $baseDir) { $prefix = trim($prefix, '\\').'\\'; $baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; if (!isset($this->namespaceMap[$prefix])) { $this->namespaceMap[$prefix] = []; } array_push($this->namespaceM...
php
{ "resource": "" }
q237812
ClassLoader.register
train
public function register() { spl_autoload_register(function ($class) { $prefix = $class; while (false !== $pos = strrpos($prefix, '\\')) { $prefix = substr($class, 0, $pos + 1); $relativeClass = substr($class, $pos + 1); $paths = $this-...
php
{ "resource": "" }
q237813
ViewModelTemplate.setRenderer
train
function setRenderer($renderer) { if (!$renderer instanceof iViewRenderer && !is_callable($renderer)) throw new \InvalidArgumentException(sprintf( 'Renderer must extend of (iViewRenderer) or callable. given: (%s)' , \Poirot\Std\flatten($renderer) )); ...
php
{ "resource": "" }
q237814
ViewModelTemplate.setResolverOptions
train
protected function setResolverOptions($options) { $resolver = $this->resolver(); $resolver->with($resolver::parseWith($options)); }
php
{ "resource": "" }
q237815
chartObject.getMaxValue
train
public function getMaxValue() { $retour = 0; foreach($this->listeValues as $indice => $value) { if(is_array($value)) { for($i=0 ; $i<count($value) ; $i++) { if($value[$i]>$retour) $retour = $value[$i]; } } else { if($value>$retour) $retour = $value; } } re...
php
{ "resource": "" }
q237816
Election.getStateCandidates
train
public function getStateCandidates(int $state): array { $candidates = []; foreach ($this->candidates as $candidateId => $candidate) { if ($candidate->getState() == $state) { $candidates[$candidateId] = $candidate; } } return $candidates; ...
php
{ "resource": "" }
q237817
Election.getCandidateIds
train
public function getCandidateIds(): array { $candidateIds = []; foreach ($this->candidates as $candidate) { $candidateIds[] = $candidate->getId(); } return $candidateIds; }
php
{ "resource": "" }
q237818
Election.getCandidatesStatus
train
public function getCandidatesStatus(): array { $candidates = []; foreach ($this->getElectedCandidates() as $candidate) { $candidates['elected'][] = $candidate->getId(); } foreach ($this->getActiveCandidates() as $candidate) { $candidates['active'][] = [$cand...
php
{ "resource": "" }
q237819
PullPlugin.process
train
public function process(Payload $payload) { $directory = $this->getDirectorySettingOrFail(); $branch = $this->getSettingValue(self::OPTION_BRANCH, $payload->getRepository()->getMasterBranch()); $url = $this->getSettingValue(self::OPTION_REPOSITORY, $payload->getRepository()->getUrl()); $git = $this->resolveGitC...
php
{ "resource": "" }
q237820
CheckerCollection.set
train
public function set(CheckerInterface $checker): self { $this->checkers[$checker->getId()] = $checker; return $this; }
php
{ "resource": "" }
q237821
ValidationManager.validator
train
public static function validator (EntityStructure $entityStructure, $data) { switch (gettype($data)) { case 'array': return new ArrayValidator($entityStructure, $data); default: return false; } }
php
{ "resource": "" }
q237822
UserController.init
train
public function init() { $this->userService = $this->di->get("userService"); $this->session = $this->di->get("session"); $this->response = $this->di->get("response"); $this->view = $this->di->get("view"); $this->pageRender = $this->di->get("pageRender"); }
php
{ "resource": "" }
q237823
UserController.getPostLogin
train
public function getPostLogin() { if ($this->userService->checkLoggedin()) { $this->response->redirect(""); } $title = "Administration - Login"; $form = new UserLoginForm($this->di); $form->check(); $data = [ "form" => $form->getHT...
php
{ "resource": "" }
q237824
Sanitizer.stripBadChars
train
public function stripBadChars(string $parameter, array $optionalChars = []): string { return str_replace(self::badChars . $optionalChars, "", $parameter); }
php
{ "resource": "" }
q237825
ConfigReader.readFromArray
train
public function readFromArray(array $data) : array { foreach($data as $key => $value) { if (is_string($value)){ $value = $this->macro_processor->process($value); $data[$key] = $value; } else if(is_array($value)){ $da...
php
{ "resource": "" }
q237826
Object.offsetGet
train
public function offsetGet($offset) { if($this->ResolveTraitOffsetExists($offset)) { return $this->ResolveTraitOffsetGet($offset); } if($this->AccessTraitOffsetExists($offset)) { return $this->AccessTraitOffsetGet($offset); } //return service if one exist...
php
{ "resource": "" }
q237827
RoutesService.add
train
public function add(...$parameters) { if (count($parameters) === 1) { $this->routes['regular'][] = ['closure' => $parameters[0], 'groupArgs' => []]; } elseif (count($parameters) === 2) { $this->routes['regular'][] = ['closure' => $parameters[1], 'groupArgs' => $parameters[0]]...
php
{ "resource": "" }
q237828
RoutesService.addMultiLanguage
train
public function addMultiLanguage(...$parameters) { if (count($parameters) === 1) { $this->routes['ml'][] = ['closure' => $parameters[0], 'groupArgs' => []]; } elseif (count($parameters) === 2) { $this->routes['ml'][] = ['closure' => $parameters[1], 'groupArgs' => $parameters[...
php
{ "resource": "" }
q237829
RoutesService.setCatchAll
train
public function setCatchAll(...$parameters) { if (count($parameters) === 1) { $this->routes['catchAll'] = ['closure' => $parameters[0], 'groupArgs' => []]; } elseif (count($parameters) === 2) { $this->routes['catchAll'] = ['closure' => $parameters[1], 'groupArgs' => $paramete...
php
{ "resource": "" }
q237830
RoutesService.registerAll
train
public function registerAll() { /** @var LanguageService $service */ $service = resolve(LanguageService::class); $languages = $service->getAllEnabled(); foreach ($this->routes['ml'] as $value) { foreach ($languages as $language) { $prefix = null; ...
php
{ "resource": "" }
q237831
ColumnCollection.get
train
public function get($identifier) : ColumnInterface { if (false === $this->has($identifier)) { throw new ColumnNotFoundException($identifier); } return $this->items[$identifier]; }
php
{ "resource": "" }
q237832
Debug.elapsedTime
train
public static function elapsedTime(string $point_name) : string { if (isset(Debug::$time[$point_name])) return sprintf("%01.4f", microtime(true) - Debug::$time[$point_name]); }
php
{ "resource": "" }
q237833
Debug.memoryUsage
train
public static function memoryUsage(string $point_name) : string { if (isset(Debug::$memory[$point_name])) { $unit = array('B', 'KB', 'MB', 'GB', 'TiB', 'PiB'); $size = memory_get_usage() - Debug::$memory[$point_name]; $memory_usage = @round($size/pow(1024, ($i=floor(log($...
php
{ "resource": "" }
q237834
CPS_Request.setShape
train
public function setShape($value, $replace = true) { $name = 'shapes'; if (!(is_array($value) || is_string($value))) { throw new CPS_Exception(array(array('long_message' => 'Invalid request parameter', 'code' => ERROR_CODE_INVALID_PARAMETER, 'level' => 'REJECTED', 'source' => 'CPS_API')))...
php
{ "resource": "" }
q237835
CPS_Request.setParam
train
public function setParam($name, $value) { if (in_array($name, $this->_textParamNames)) { $this->_setTextParam($name, $value); } else if (in_array($name, $this->_rawParamNames)) { $this->_setRawParam($name, $value); } else { throw new CPS_Exception(array(array(...
php
{ "resource": "" }
q237836
CPS_Request._setTextParam
train
private function _setTextParam(&$name, &$value) { if (!is_array($value)) $value = array($value); $this->_textParams[$name] = $value; }
php
{ "resource": "" }
q237837
CPS_Request._setRawParam
train
private function _setRawParam(&$name, &$value) { if (!is_array($value)) $value = array($value); $this->_rawParams[$name] = $value; }
php
{ "resource": "" }
q237838
CPS_Request._setDocId
train
private static function _setDocId(&$subdoc, &$parentNode, $id, &$docIdXpath, $curLevel = 0) { if ($parentNode->nodeName == $docIdXpath[$curLevel]) { if ($curLevel == count($docIdXpath) - 1) { // remove all sub-nodes $curChild = $parentNode->firstChild; ...
php
{ "resource": "" }
q237839
CrudMemcachedRepository.delete
train
public function delete($object) { $deleted = $object->delete(); if( ! $deleted) { return new Payload($object, 'not_deleted'); } // Remove the deleted model from cache. Cache::tags($this->model->getTable())->flush($updated->getKey()); return new Payload(null, 'deleted'); }
php
{ "resource": "" }
q237840
GenerateInstallCommand.execute
train
public function execute(InputInterface $input, OutputInterface $output) { $outputPath = DATADIR; $output->write(['', ' Generating install files...', ''], true); $this->dumpStructure($outputPath); $output->writeln(' Exported DB structure'); $this->dumpData($outputPath); ...
php
{ "resource": "" }
q237841
GenerateInstallCommand.getDumpStructureCommand
train
public function getDumpStructureCommand($database, $username, $password, $outputPath) { return sprintf( 'mysqldump %s -u %s -p%s --no-data | sed "s/AUTO_INCREMENT=[0-9]*//" > %s', escapeshellarg($database), escapeshellarg($username), escapeshellarg($password),...
php
{ "resource": "" }
q237842
GenerateInstallCommand.getDumpDataCommand
train
public function getDumpDataCommand($database, $username, $password, $outputPath, $tables = array()) { $tables = array_map('escapeshellarg', $tables); $command = sprintf( 'mysqldump %s %s -u %s -p%s --no-create-info > %s', escapeshellarg($database), implode(' ', $...
php
{ "resource": "" }
q237843
GenerateInstallCommand.dumpStructure
train
protected function dumpStructure($outputPath) { return shell_exec($this->getDumpStructureCommand( $this->dbConfig['database'], $this->dbConfig['username'], $this->dbConfig['password'], $outputPath.'/'.self::STRUCTURE_FILE )); }
php
{ "resource": "" }
q237844
GenerateInstallCommand.dumpData
train
protected function dumpData($outputPath) { $tables = Arr::get($this->installConfig, 'dataTables', []); /** * Do not attempt to create an empty data install file if no tables are to be exported. * Otherwise all tables will be exported. */ if (! count($tables)) { ...
php
{ "resource": "" }
q237845
APIClient.pushEvent
train
public function pushEvent($collectionName, $event) { $url = self::BASE_API_URL . $collectionName; $result = Request::post($url) ->sendsAndExpectsType(Mime::JSON) ->addHeaders([ 'X-Project-Id' => $this->projectId, 'X-Api-Key' => $this->apiKey ...
php
{ "resource": "" }
q237846
APIClient.buildResponse
train
private function buildResponse($event, $response) { $success = !$response->hasErrors(); $duplicate = ($response->code == 409); $statusCode = $response->code; $errorMessage = null; if ($response->code == 401) { $errorMessage = 'Unauthorised. Please check your Project I...
php
{ "resource": "" }
q237847
APIClient.buildBatchResponse
train
private function buildBatchResponse($batch, $response) { $result = []; $responseBody = json_decode($response->raw_body, true); foreach ($batch as $collection => $events) { $eventResults = []; $eventResponses = $responseBody[$collection]; foreach($events as $in...
php
{ "resource": "" }
q237848
DocNormalizerContext.thenPathNamedShouldHaveTheFollowingResponse
train
public function thenPathNamedShouldHaveTheFollowingResponse($httpMethod, $pathName, PyStringNode $data) { $this->thenIShouldHaveAPathNamed($httpMethod, $pathName); $operation = $this->extractPath($httpMethod, $pathName); $operationResponseSchemaList = $operation['responses']['200']['schema'...
php
{ "resource": "" }
q237849
Merger.merge
train
public function merge(array $newConfig, array &$config) { foreach ($newConfig as $routeName => $routeInfo) { if (!isset($config[$routeName])) { $config[$routeName] = $this->newRoute($routeName, $routeInfo); } if (isset($routeInfo['child_routes'])) { ...
php
{ "resource": "" }
q237850
Settings.get
train
public function get($name, $default = null) { if (! str_contains($name, '::')) { throw new InvalidArgumentException("Setting key must be in the format '[module]::[setting]', '$name' given."); } $defaultFromConfig = $this->getDefaultFromConfigFor($name); if ($this->setti...
php
{ "resource": "" }
q237851
Settings.setFromRequest
train
public function setFromRequest($settings) { $this->removeTokenKey($settings); foreach ($settings as $settingName => $settingValues) { $this->set($settingName, $settingValues); } }
php
{ "resource": "" }
q237852
Settings.moduleConfig
train
public function moduleConfig($modules) { if (is_string($modules)) { $config = config('society.'.strtolower($modules).'.settings'); return $config; } $config = []; foreach ($modules as $module) { if ($moduleSettings = config('society.'.strtolower(...
php
{ "resource": "" }
q237853
Settings.getConfigFor
train
private function getConfigFor($name) { list($module, $settingName) = explode('::', $name); $result = []; foreach (config("society.$module.settings") as $sub) { $result = array_merge($result, $sub); } return Arr::get($result, "$settingName"); }
php
{ "resource": "" }
q237854
AccessEntitiesDataSourceDoctrine.find
train
public function find($class, DataRequest $dataRequest) { try { $dataRequest->setSelectedFields(array('*')); $queryBuilder = $this->entityManager->getQueryBuilder(); $this->entityManager->buildDataRequestQuery($dataRequest, $queryBuilder, $class, 'a'); ...
php
{ "resource": "" }
q237855
AccessEntitiesDataSourceDoctrine.count
train
public function count($class, DataRequest $dataRequest) { try { $request = clone $dataRequest; $request->setPage(0); $request->setNumberOfEntries(0); $queryBuilder = $this->entityManager->getQueryBuilder(); $this->entityMa...
php
{ "resource": "" }
q237856
AccessEntitiesDataSourceDoctrine.has
train
public function has($class, $entityId) { try { $em = $this->entityManager->getDoctrineEntityManager(); $data = $em->getRepository($class)->findOneBy(array( 'id' => $entityId, )); if ($data !== null) { return true; ...
php
{ "resource": "" }
q237857
AccessEntitiesDataSourceDoctrine.get
train
public function get($class, $entityId) { try { $em = $this->entityManager->getDoctrineEntityManager(); $accessEntity = $em->getRepository($class)->findOneBy(array( 'id' => $entityId, )); if ($accessEntity !== null) { ...
php
{ "resource": "" }
q237858
AccessEntitiesDataSourceDoctrine.hasAccessEntityForUuid
train
public function hasAccessEntityForUuid($class, $uuid) { try { $em = $this->entityManager->getDoctrineEntityManager(); $data = $em->getRepository($class)->findOneBy(array( 'uuid' => $uuid, )); if ($data !== null) { ...
php
{ "resource": "" }
q237859
AccessEntitiesDataSourceDoctrine.hasAccessEntityForName
train
public function hasAccessEntityForName($class, $name) { try { $em = $this->entityManager->getDoctrineEntityManager(); $data = $em->getRepository($class)->findOneBy(array( 'name' => $name, )); if ($data !== null) { r...
php
{ "resource": "" }
q237860
AccessEntitiesDataSourceDoctrine.getAccessEntityForUuid
train
public function getAccessEntityForUuid($class, $uuid) { try { $em = $this->entityManager->getDoctrineEntityManager(); $accessEntity = $em->getRepository($class)->findOneBy(array( 'uuid' => $uuid, )); if ($accessEntity !== null) { ...
php
{ "resource": "" }
q237861
AccessEntitiesDataSourceDoctrine.getAccessEntityForName
train
public function getAccessEntityForName($class, $name) { try { $em = $this->entityManager->getDoctrineEntityManager(); $accessEntity = $em->getRepository($class)->findOneBy(array( 'name' => $name, )); if ($accessEntity !== null) { ...
php
{ "resource": "" }
q237862
AccessEntitiesDataSourceDoctrine.addAccessEntity
train
public function addAccessEntity(AccessEntity $accessEntity) { try { $em = $this->entityManager->getDoctrineEntityManager(); $em->persist($accessEntity); $em->flush(); return $accessEntity->getUuid(); } catch (\Exception $e) { t...
php
{ "resource": "" }
q237863
AccessEntitiesDataSourceDoctrine.updateAccessEntity
train
public function updateAccessEntity(AccessEntity $accessEntity) { try { $em = $this->entityManager->getDoctrineEntityManager(); $em->flush(); return true; } catch (\Exception $e) { throw new Exception('Cannot update the access entitiy "' . ...
php
{ "resource": "" }
q237864
AccessEntitiesDataSourceDoctrine.deleteAccessEntity
train
public function deleteAccessEntity(AccessEntity $accessEntity) { try { $em = $this->entityManager->getDoctrineEntityManager(); $em->remove($accessEntity); $em->flush(); return true; } catch (\Exception $e) { throw new Exception...
php
{ "resource": "" }
q237865
AccessEntitiesDataSourceDoctrine.loadPermissions
train
protected function loadPermissions(AccessEntity $accessEntity) { $permissions = $this->permissionsDataSource->getPermissionsForUuid($accessEntity->getUuid()); if ($permissions === false) { return; } $accessEntity->setPermissions($permissions); }
php
{ "resource": "" }
q237866
LockBox.set
train
public function set($name, $value) { if (isset($this->locked[$name])) { throw new LockedItemException($name); } $this->items[$name] = $value; }
php
{ "resource": "" }
q237867
LockBox.get
train
public function get($name) { if (!$this->has($name)) { throw new ItemNotFoundException($name); } return $this->items[$name]; }
php
{ "resource": "" }
q237868
LockBox.lock
train
public function lock($name) { if (!$this->has($name)) { throw new ItemNotFoundException($name); } $this->locked[$name] = true; return $this; }
php
{ "resource": "" }
q237869
LockBox.unlock
train
public function unlock($name) { if (!$this->has($name)) { throw new ItemNotFoundException($name); } unset($this->locked[$name]); return $this; }
php
{ "resource": "" }
q237870
LockBox.isLocked
train
public function isLocked($name) { if (!$this->has($name)) { throw new ItemNotFoundException($name); } return isset($this->locked[$name]); }
php
{ "resource": "" }
q237871
Tinymce.init
train
public function init(){ parent::init(); $id = $this->getRandomId(); $view = $this->getView(); TinymceAsset::register($view); TinymceLanguageAsset::register($view); $view->registerJs("tinymce.init({selector:'#$id',plugins:'$this->plugins',font_formats:'$this->font_formats',fontsize_formats:'$this->fontsize_...
php
{ "resource": "" }
q237872
LanguagesController.sort
train
public function sort() { if (!$this->request->is('ajax') || !$this->request->is('post')) { throw new MethodNotAllowedException(); } if (empty($this->request->data)) { throw new BadRequestException(); } // save the new language positions $langu...
php
{ "resource": "" }
q237873
LanguagesController.change
train
public function change($id = null) { if ($id === null || !$this->Languages->exists(['id' => $id])) { $this->Flash->error($this->invalidRequestMessage); $this->redirect($this->referer()); return; } $this->request->session()->write('contentLanguageId', (int)...
php
{ "resource": "" }
q237874
SiteTreeReflectionTemplate.getTemplateAccessors
train
public function getTemplateAccessors() { if($this->templateAccessors) return $this->templateAccessors; $vars = parent::getTemplateAccessors(); $cc = new ReflectionClass('ContentController'); $site_tree = new ReflectionClass('SiteTree'); $hierarchy = new ReflectionClass('Hierarchy'); $methods = array...
php
{ "resource": "" }
q237875
AbstractExtension.generateUrl
train
final protected function generateUrl(string $name, array $params = []) : string { return $this->urlGenerator ->generate($name, $params); }
php
{ "resource": "" }
q237876
Node_Container.replace_child
train
public function replace_child(Node $what, $with) { $replace_key = array_search($what, $this->children); if($replace_key === false) return false; if(is_array($with)) foreach($with as $child) $child->set_parent($this); array_splice($this->children, $replace_key, 1, $with); return true; }
php
{ "resource": "" }
q237877
Node_Container.remove_child
train
public function remove_child(Node $child) { $key = array_search($what, $this->children); if($key === false) return false; $this->children[$key]->set_parent(); unset($this->children[$key]); return true; }
php
{ "resource": "" }
q237878
Node_Container.last_tag_node
train
public function last_tag_node() { $children_len = count($this->children); for($i=$children_len-1; $i >= 0; $i--) if($this->children[$i] instanceof Node_Container_Tag) return $this->children[$i]; return null; }
php
{ "resource": "" }
q237879
Node_Container.get_html
train
public function get_html($nl2br=true, $htmlEntities = true) { $html = ''; foreach($this->children as $child) $html .= $child->get_html($nl2br, $htmlEntities); if($this instanceof Node_Container_Document) return $html; $bbcode = $this->root()->get_bbcode($this->tag); if(is_callable($bbcode->handler(...
php
{ "resource": "" }
q237880
Node_Container.get_text
train
public function get_text() { $text = ''; foreach($this->children as $child) $text .= $child->get_text(); return $text; }
php
{ "resource": "" }
q237881
mf_custom_fields.edit_field
train
function edit_field() { global $mf_domain; //check param custom_field_id $data = $this->fields_form(); $field = $this->get_custom_field($_GET['custom_field_id']); //check if exist field if(!$field){ $this->mf_flash('error'); }else{ $no_set = array('options','active','display_or...
php
{ "resource": "" }
q237882
mf_custom_fields.get_custom_fields_name
train
function get_custom_fields_name () { $path = MF_PATH.'/field_types/*'; $folders = glob($path,GLOB_ONLYDIR); $fields = array(); foreach($folders as $folder) { $name = preg_match('/\/([\w\_]+)\_field$/i',$folder,$name_match); $fields[$name_match[1]] = preg_replace('/_/',' ',$name_match[1]); ...
php
{ "resource": "" }
q237883
mf_custom_fields.save_order_field
train
public static function save_order_field( $group_id, $order ) { global $wpdb; if( !is_numeric($group_id) ) { return false; } foreach( $order as $key => $value ) { $update = $wpdb->update( MF_TABLE_CUSTOM_FIELDS, array( 'display_order' => $key ), array( 'custom_group_...
php
{ "resource": "" }
q237884
mf_custom_fields.has_fields
train
public static function has_fields($post_type_name) { global $wpdb; $sql = $wpdb->prepare("SELECT COUNT(1) FROM ".MF_TABLE_CUSTOM_FIELDS. " WHERE post_type = %s",$post_type_name); return $wpdb->get_var( $sql ) > 0; }
php
{ "resource": "" }
q237885
mf_custom_fields.delete_custom_field
train
function delete_custom_field() { global $wpdb; //checking the nonce check_admin_referer('delete_custom_field'); if( isset($_GET['custom_field_id']) ) { $id = (int)$_GET['custom_field_id']; if( is_int($id) ){ $sql = $wpdb->prepare( "DELETE FROM ".MF_TABLE_CUSTOM_FIELDS." WHERE id ...
php
{ "resource": "" }
q237886
MasterViewComposer.provideAPIRoutes
train
protected function provideAPIRoutes() { $routes = Cache::rememberForever('provideAPIRoutes', function () { $router = app(Router::class); $routes = []; foreach ($router->getRoutes() as $collection) { foreach ($collection->getRoutes() as $route) { ...
php
{ "resource": "" }
q237887
Uri.fromEnvironment
train
public static function fromEnvironment(): UriInterface { parse_str($_SERVER['QUERY_STRING'] ?? '', $query); $uri = (new static()) ->withScheme((isset($_SERVER['HTTPS']) === true && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http') ->withHost($_SERVER['HTTP_HOST']) ...
php
{ "resource": "" }
q237888
MoipResponse.analyzeResponseErrors
train
protected function analyzeResponseErrors() { $content = $this->content; if ($content && property_exists($content, 'errors')) { $this->setErrors($content, 'errors'); } elseif ($content && property_exists($content, 'ERROR')) { $this->setError('Unknown', $content->ERROR...
php
{ "resource": "" }
q237889
MoipResponse.setErrors
train
protected function setErrors($response, $key) { foreach ($response->{$key} as $error) { $this->setError($error->code, $error->description); } }
php
{ "resource": "" }
q237890
MoipResponse.setError
train
public function setError($code, $description) { $error = new stdClass; $error->code = $code; $error->description = $description; $this->errors[] = $error; }
php
{ "resource": "" }
q237891
MoipResponse.throwExceptions
train
protected function throwExceptions() { $status = $this->getStatusCode(); switch ($status) { case 400: throw new ValidationException($this); break; case 401: throw new UnauthorizedException($this); break; ...
php
{ "resource": "" }
q237892
MoipResponse.getResults
train
public function getResults() { $key = $this->dataKey; $content = $this->content; if (is_object($content) && property_exists($content, $key)) { return new Collection($content->{$key}); } elseif (is_array($content)) { return new Collection($content); } ...
php
{ "resource": "" }
q237893
RelationApi.registerRelations
train
protected static function registerRelations() { if (!static::$relations) { $supported = [ HasOne::class => HasOneWrapper::class, BelongsTo::class => BelongsToWrapper::class, BelongsToMany::class => BelongsToManyWrapper::class, HasMa...
php
{ "resource": "" }
q237894
Breadcrumb.createActiveItem
train
public function createActiveItem($text, $title = '') { $breadcrumb = new BreadcrumbObject(); $breadcrumb->setText($text); $breadcrumb->setActive(true); if ($title) { $breadcrumb->setTitle($title); } $this->breadcrumbs[] = $breadcrumb; return $b...
php
{ "resource": "" }
q237895
Breadcrumb.createItem
train
public function createItem($text, $href, $title = '') { $breadcrumb = new BreadcrumbObject(); $breadcrumb->setText($text); $breadcrumb->setHref($href); if ($title) { $breadcrumb->setTitle($title); } $this->breadcrumbs[] = $breadcrumb; return $b...
php
{ "resource": "" }
q237896
Auth_Login_Driver.get_user_array
train
final public function get_user_array(Array $additional_fields = array()) { $user = array( 'email' => $this->get_email(), 'screen_name' => $this->get_screen_name(), 'groups' => $this->get_groups(), ); $additional_fields = array_merge($this->config['additional_fields'], $additional_fields);...
php
{ "resource": "" }
q237897
Auth_Login_Driver.member
train
public function member($group, $driver = null, $user = null) { $user = $user ?: $this->get_user_id(); if ($driver === null) { foreach (\Auth::group(true) as $g) { if ($g->member($group, $user)) { return true; } } return false; } return \Auth::group($driver)->member($group, $us...
php
{ "resource": "" }
q237898
Auth_Login_Driver.hash_password
train
public function hash_password($password) { return base64_encode($this->hasher()->pbkdf2($password, \Config::get('auth.salt'), \Config::get('auth.iterations', 10000), 32)); }
php
{ "resource": "" }
q237899
Auth_Login_Driver.hasher
train
public function hasher() { is_null($this->hasher) and $this->hasher = new \PHPSecLib\Crypt_Hash(); return $this->hasher; }
php
{ "resource": "" }