_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q254200 | Db.update | validation | public function update($table, $data = array(), $where = '1=1')
{
if (! $this->getDb()->update($table, $data, $where)) {
throw new DbException("Failed updating " . $table);
}
return true;
} | php | {
"resource": ""
} |
q254201 | Db.query | validation | public function query($sql, $return = false)
{
$query = $this->getDb()->query($sql, true);
if ($return) {
return $query;
}
} | php | {
"resource": ""
} |
q254202 | Db.getDb | validation | public function getDb()
{
if (is_null($this->db)) {
//try explicit type setting
if( $this->getAccessType() == 'mysqli' && function_exists('mysqli_select_db') ){
$this->db = new Db\Mysqli();
}
else
{
if ... | php | {
"resource": ""
} |
q254203 | Db.getTables | validation | public function getTables()
{
$tables = $this->getDb()->getAllTables();
$return = array();
foreach ($tables as $name => $table) {
foreach ($table as $key => $value) {
$return[$table[$key]] = $table[$key];
}
}
return $return;
... | php | {
"resource": ""
} |
q254204 | Db.checkDbExists | validation | public function checkDbExists($name)
{
$data = $this->query("SELECT COUNT(*) AS total FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '".$this->escape($name)."'", true);
if( isset($data['0']['total']) && $data['0']['total'] == '1' )
{
return true;
}
... | php | {
"resource": ""
} |
q254205 | LoggerReport.getPerMonth | validation | private function getPerMonth($months)
{
$per_month = [];
$log = $this->logger->perMonth($months);
foreach($log as $date => $hits) {
array_push($per_month, [$date, $hits]);
}
return $per_month;
} | php | {
"resource": ""
} |
q254206 | SearchTermResult.getIcon | validation | public function getIcon()
{
if (is_null($this->_icon) && isset($this->object)) {
$this->_icon = ['class' => $this->object->objectType->icon, 'title' => $this->objectTypeDescriptor];
}
return $this->_icon;
} | php | {
"resource": ""
} |
q254207 | SearchTermResult.getObjectTypeDescriptor | validation | public function getObjectTypeDescriptor()
{
if (is_null($this->_objectTypeDescriptor) && isset($this->object)) {
$this->_objectTypeDescriptor = $this->object->objectType->title->upperSingular;
}
return $this->_objectTypeDescriptor;
} | php | {
"resource": ""
} |
q254208 | SearchTermResult.getObjectType | validation | public function getObjectType()
{
if (is_null($this->_objectType) && isset($this->object)) {
$this->_objectType = $this->object->objectType->systemId;
}
return $this->_objectType;
} | php | {
"resource": ""
} |
q254209 | FrontendController.renderPage | validation | protected function renderPage()
{
$page = $this->options["page"];
$request = $this->options["request"];
$username = $this->options["username"];
$pageOptions = array(
'page' => $request->get('page'),
'language' => $request->get('_locale'),
'country'... | php | {
"resource": ""
} |
q254210 | FieldsRules.transformFromFront | validation | public function transformFromFront(array $array)
{
$transformation = $this->getTransformation();
$fillables = $this->getFillable();
$transformed = [];
/* Add fillables to array transformed */
foreach ($fillables as $name) {
if (! key_exists($name,... | php | {
"resource": ""
} |
q254211 | ReflectableTrait.getReflectionAndClassObject | validation | private function getReflectionAndClassObject()
{
if ($this->isCalledAfterOn) {
$this->isCalledAfterOn = false;
$classObj = $this->classObjOn;
$reflection = $this->reflectionOn;
unset($this->classObjOn);
unset($this->reflectionOn);
... | php | {
"resource": ""
} |
q254212 | SeekableTrait.seek | validation | public function seek($position)
{
if (!array_key_exists($position, $this->elements)) {
throw new \InvalidArgumentException(
sprintf('Position %s does not exist in collection', $position)
);
}
reset($this->elements);
while (key($this->elements... | php | {
"resource": ""
} |
q254213 | Manager.createEntityManager | validation | protected function createEntityManager()
{
// Cache can be null in case of auto setup
if ($cache = $this->getConfig('cache_driver', 'array'))
{
$cache = 'doctrine.cache.'.$cache;
$cache = DiC::resolve($cache);
}
// Auto or manual setup
if ($this->getConfig('auto_config', false))
{
$dev = $this... | php | {
"resource": ""
} |
q254214 | Manager.setMappings | validation | public function setMappings($mappingName, array $mappingConfig = null)
{
if (is_array($mappingName) === false)
{
$mappingName = array($mappingName => $mappingConfig);
}
\Arr::set($this->config['mappings'], $mappingName);
return $this;
} | php | {
"resource": ""
} |
q254215 | Manager.autoLoadMappingInfo | validation | protected function autoLoadMappingInfo()
{
$mappings = array();
foreach (\Package::loaded() as $package => $path)
{
$mappings[] = $package . '::package';
}
foreach (\Module::loaded() as $module => $path)
{
$mappings[] = $module . '::module';
}
$mappings[] = 'app';
$mappings = array_fill_key... | php | {
"resource": ""
} |
q254216 | Manager.registerMapping | validation | public function registerMapping(Configuration $config)
{
$driverChain = new DriverChain;
$aliasMap = array();
$drivers = array();
$this->parseMappingInfo();
// Get actual drivers
foreach ($this->getMappings() as $mappingName => $mappingConfig)
{
if (empty($mappingConfig['prefix']))
{
$mapping... | php | {
"resource": ""
} |
q254217 | Manager.parseMappingInfo | validation | public function parseMappingInfo()
{
$mappings = array();
foreach ($this->getMappings() as $mappingName => $mappingConfig)
{
// This is from symfony DoctrineBundle, should be reviewed
if (is_array($mappingConfig) === false or \Arr::get($mappingConfig, 'mapping', true) === false)
{
continue;
}
... | php | {
"resource": ""
} |
q254218 | Manager.getComponentDefaults | validation | protected function getComponentDefaults($mappingName, array $mappingConfig)
{
if (strpos($mappingName, '::'))
{
list($componentName, $componentType) = explode('::', $mappingName);
}
else
{
$componentName = $mappingName;
$componentType = $this->detectComponentType($componentName);
if ($component... | php | {
"resource": ""
} |
q254219 | Manager.detectMetadataDriver | validation | protected function detectMetadataDriver($dir, $configPath)
{
foreach ((array) $configPath as $cPath)
{
$path = $dir.DS.$cPath.DS;
if (($files = glob($path.'*.dcm.xml')) && count($files))
{
return 'xml';
}
elseif (($files = glob($path.'*.orm.xml')) && count($files))
{
return 'simplified_x... | php | {
"resource": ""
} |
q254220 | Manager.registerBehaviors | validation | protected function registerBehaviors(EventManager $evm, Configuration $config)
{
$reader = new AnnotationReader;
if ($cache = $config->getMetadataCacheImpl())
{
$reader = new CachedReader($reader, $cache);
}
foreach ($this->getConfig('behaviors', array()) as $behavior)
{
if ($class = DiC::resolve('... | php | {
"resource": ""
} |
q254221 | Manager.configureBehavior | validation | protected function configureBehavior($behavior, EventSubscriber $es)
{
switch ($behavior) {
case 'translatable':
$es->setTranslatableLocale(\Config::get('language', 'en'));
$es->setDefaultLocale(\Config::get('language_fallback', 'en'));
break;
}
} | php | {
"resource": ""
} |
q254222 | Benri_Rest_Controller_Action.preDispatch | validation | public function preDispatch()
{
$error = null;
$request = $this->getRequest();
if (!$request->isGet() && !$request->isHead()) {
// read data from the request body.
$this->_input = json_decode($request->getRawBody());
if (JSON_ERROR_NONE === json_last_e... | php | {
"resource": ""
} |
q254223 | AdminCommand.getAdministratorRole | test | protected function getAdministratorRole()
{
$role = Voyager::model('Role')->firstOrNew([
'name' => 'admin',
]);
if (!$role->exists) {
$role->fill([
'display_name' => 'Administrator',
])->save();
}
return $role;
} | php | {
"resource": ""
} |
q254224 | AdminCommand.getUser | test | protected function getUser($create = false)
{
$email = $this->argument('email');
$model = config('voyager.user.namespace') ?: config('auth.providers.users.model');
// If we need to create a new user go ahead and create it
if ($create) {
$name = $this->ask('Enter the adm... | php | {
"resource": ""
} |
q254225 | DeleteBreadMenuItem.handle | test | public function handle(BreadDeleted $bread)
{
if (config('voyager.bread.add_menu_item')) {
$menuItem = Voyager::model('MenuItem')->where('route', 'voyager.'.$bread->dataType->slug.'.index');
if ($menuItem->exists()) {
$menuItem->delete();
}
}
... | php | {
"resource": ""
} |
q254226 | TranslationsTableSeeder.categoriesTranslations | test | private function categoriesTranslations()
{
// Adding translations for 'categories'
//
$cat = Category::where('slug', 'category-1')->firstOrFail();
if ($cat->exists) {
$this->trans('pt', $this->arr(['categories', 'slug'], $cat->id), 'categoria-1');
$this->tran... | php | {
"resource": ""
} |
q254227 | MenuItem.highestOrderMenuItem | test | public function highestOrderMenuItem($parent = null)
{
$order = 1;
$item = $this->where('parent_id', '=', $parent)
->orderBy('order', 'DESC')
->first();
if (!is_null($item)) {
$order = intval($item->order) + 1;
}
return $order;
} | php | {
"resource": ""
} |
q254228 | Index.createName | test | public static function createName(array $columns, $type, $table = null)
{
$table = isset($table) ? trim($table).'_' : '';
$type = trim($type);
$name = strtolower($table.implode('_', $columns).'_'.$type);
return str_replace(['-', '.'], '_', $name);
} | php | {
"resource": ""
} |
q254229 | AddBreadMenuItem.handle | test | public function handle(BreadAdded $bread)
{
if (config('voyager.bread.add_menu_item') && file_exists(base_path('routes/web.php'))) {
require base_path('routes/web.php');
$menu = Voyager::model('Menu')->where('name', config('voyager.bread.default_menu'))->firstOrFail();
... | php | {
"resource": ""
} |
q254230 | DatabaseUpdater.update | test | public static function update($table)
{
if (!is_array($table)) {
$table = json_decode($table, true);
}
if (!SchemaManager::tableExists($table['oldName'])) {
throw SchemaException::tableDoesNotExist($table['oldName']);
}
$updater = new self($table);
... | php | {
"resource": ""
} |
q254231 | DatabaseUpdater.updateTable | test | public function updateTable()
{
// Get table new name
if (($newName = $this->table->getName()) != $this->originalTable->getName()) {
// Make sure the new name doesn't already exist
if (SchemaManager::tableExists($newName)) {
throw SchemaException::tableAlready... | php | {
"resource": ""
} |
q254232 | DatabaseUpdater.getRenamedColumnsDiff | test | protected function getRenamedColumnsDiff()
{
$renamedColumns = $this->getRenamedColumns();
if (empty($renamedColumns)) {
return false;
}
$renamedColumnsDiff = new TableDiff($this->tableArr['oldName']);
$renamedColumnsDiff->fromTable = $this->originalTable;
... | php | {
"resource": ""
} |
q254233 | DatabaseUpdater.getRenamedDiff | test | protected function getRenamedDiff()
{
$renamedColumns = $this->getRenamedColumns();
$renamedIndexes = $this->getRenamedIndexes();
if (empty($renamedColumns) && empty($renamedIndexes)) {
return false;
}
$renamedDiff = new TableDiff($this->tableArr['oldName']);
... | php | {
"resource": ""
} |
q254234 | DatabaseUpdater.getRenamedColumns | test | protected function getRenamedColumns()
{
$renamedColumns = [];
foreach ($this->tableArr['columns'] as $column) {
$oldName = $column['oldName'];
// make sure this is an existing column and not a new one
if ($this->originalTable->hasColumn($oldName)) {
... | php | {
"resource": ""
} |
q254235 | DatabaseUpdater.getRenamedIndexes | test | protected function getRenamedIndexes()
{
$renamedIndexes = [];
foreach ($this->tableArr['indexes'] as $index) {
$oldName = $index['oldName'];
// make sure this is an existing index and not a new one
if ($this->originalTable->hasIndex($oldName)) {
... | php | {
"resource": ""
} |
q254236 | Resizable.thumbnail | test | public function thumbnail($type, $attribute = 'image')
{
// Return empty string if the field not found
if (!isset($this->attributes[$attribute])) {
return '';
}
// We take image from posts field
$image = $this->attributes[$attribute];
return $this->getTh... | php | {
"resource": ""
} |
q254237 | Resizable.getThumbnail | test | public function getThumbnail($image, $type)
{
// We need to get extension type ( .jpeg , .png ...)
$ext = pathinfo($image, PATHINFO_EXTENSION);
// We remove extension from file name so we can append thumbnail type
$name = Str::replaceLast('.'.$ext, '', $image);
// We merge ... | php | {
"resource": ""
} |
q254238 | UserPolicy.editRoles | test | public function editRoles(User $user, $model)
{
// Does this record belong to another user?
$another = $user->id != $model->id;
return $another && $user->hasPermission('edit_users');
} | php | {
"resource": ""
} |
q254239 | Voyager.dimmers | test | public function dimmers()
{
$widgetClasses = config('voyager.dashboard.widgets');
$dimmers = Widget::group('voyager::dimmers');
foreach ($widgetClasses as $widgetClass) {
$widget = app($widgetClass);
if ($widget->shouldBeDisplayed()) {
$dimmers->addW... | php | {
"resource": ""
} |
q254240 | VoyagerMenuController.prepareMenuTranslations | test | protected function prepareMenuTranslations(&$data)
{
$trans = json_decode($data['title_i18n'], true);
// Set field value with the default locale
$data['title'] = $trans[config('voyager.multilingual.default', 'en')];
unset($data['title_i18n']); // Remove hidden input holding tra... | php | {
"resource": ""
} |
q254241 | Translator.save | test | public function save()
{
$attributes = $this->getModifiedAttributes();
$savings = [];
foreach ($attributes as $key => $attribute) {
if ($attribute['exists']) {
$translation = $this->getTranslationModel($key);
} else {
$translation = Vo... | php | {
"resource": ""
} |
q254242 | PostPolicy.read | test | public function read(User $user, $model)
{
// Does this post belong to the current user?
$current = $user->id === $model->author_id;
return $current || $this->checkPermission($user, $model, 'read');
} | php | {
"resource": ""
} |
q254243 | VoyagerBreadController.create | test | public function create(Request $request, $table)
{
$this->authorize('browse_bread');
$dataType = Voyager::model('DataType')->whereName($table)->first();
$data = $this->prepopulateBreadInfo($table);
$data['fieldOptions'] = SchemaManager::describeTable((isset($dataType) && strlen($da... | php | {
"resource": ""
} |
q254244 | VoyagerBreadController.store | test | public function store(Request $request)
{
$this->authorize('browse_bread');
try {
$dataType = Voyager::model('DataType');
$res = $dataType->updateDataType($request->all(), true);
$data = $res
? $this->alertSuccess(__('voyager::bread.success_create... | php | {
"resource": ""
} |
q254245 | VoyagerBreadController.edit | test | public function edit($table)
{
$this->authorize('browse_bread');
$dataType = Voyager::model('DataType')->whereName($table)->first();
$fieldOptions = SchemaManager::describeTable((strlen($dataType->model_name) != 0)
? app($dataType->model_name)->getTable()
: $dataTyp... | php | {
"resource": ""
} |
q254246 | VoyagerBreadController.update | test | public function update(Request $request, $id)
{
$this->authorize('browse_bread');
/* @var \TCG\Voyager\Models\DataType $dataType */
try {
$dataType = Voyager::model('DataType')->find($id);
// Prepare Translations and Transform data
$translations = is_bre... | php | {
"resource": ""
} |
q254247 | VoyagerBreadController.destroy | test | public function destroy($id)
{
$this->authorize('browse_bread');
/* @var \TCG\Voyager\Models\DataType $dataType */
$dataType = Voyager::model('DataType')->find($id);
// Delete Translations, if present
if (is_bread_translatable($dataType)) {
$dataType->deleteAttr... | php | {
"resource": ""
} |
q254248 | VoyagerBreadController.addRelationship | test | public function addRelationship(Request $request)
{
$relationshipField = $this->getRelationshipField($request);
if (!class_exists($request->relationship_model)) {
return back()->with([
'message' => 'Model Class '.$request->relationship_model.' does not exist. Please c... | php | {
"resource": ""
} |
q254249 | VoyagerBreadController.getRelationshipField | test | private function getRelationshipField($request)
{
// We need to make sure that we aren't creating an already existing field
$dataType = Voyager::model('DataType')->find($request->data_type_id);
$field = Str::singular($dataType->name).'_'.$request->relationship_type.'_'.Str::singular($reque... | php | {
"resource": ""
} |
q254250 | Password.handle | test | public function handle()
{
return empty($this->request->input($this->row->field)) ? null :
bcrypt($this->request->input($this->row->field));
} | php | {
"resource": ""
} |
q254251 | VoyagerDatabaseController.store | test | public function store(Request $request)
{
$this->authorize('browse_database');
try {
$conn = 'database.connections.'.config('database.default');
Type::registerCustomPlatformTypes();
$table = $request->table;
if (!is_array($request->table)) {
... | php | {
"resource": ""
} |
q254252 | VoyagerDatabaseController.edit | test | public function edit($table)
{
$this->authorize('browse_database');
if (!SchemaManager::tableExists($table)) {
return redirect()
->route('voyager.database.index')
->with($this->alertError(__('voyager::database.edit_table_not_exist')));
}
... | php | {
"resource": ""
} |
q254253 | VoyagerDatabaseController.update | test | public function update(Request $request)
{
$this->authorize('browse_database');
$table = json_decode($request->table, true);
try {
DatabaseUpdater::update($table);
// TODO: synch BREAD with Table
// $this->cleanOldAndCreateNew($request->original_name, $r... | php | {
"resource": ""
} |
q254254 | VoyagerDatabaseController.show | test | public function show($table)
{
$this->authorize('browse_database');
$additional_attributes = [];
$model_name = Voyager::model('DataType')->where('name', $table)->pluck('model_name')->first();
if (isset($model_name)) {
$model = app($model_name);
if (isset($mod... | php | {
"resource": ""
} |
q254255 | VoyagerDatabaseController.destroy | test | public function destroy($table)
{
$this->authorize('browse_database');
try {
SchemaManager::dropTable($table);
event(new TableDeleted($table));
return redirect()
->route('voyager.database.index')
->with($this->alertSuccess(__('voy... | php | {
"resource": ""
} |
q254256 | DataRow.sortByUrl | test | public function sortByUrl($orderBy, $sortOrder)
{
$params = [];
$isDesc = $sortOrder != 'asc';
if ($this->isCurrentSortField($orderBy) && $isDesc) {
$params['sort_order'] = 'asc';
} else {
$params['sort_order'] = 'desc';
}
$params['order_by'] =... | php | {
"resource": ""
} |
q254257 | Menu.display | test | public static function display($menuName, $type = null, array $options = [])
{
// GET THE MENU - sort collection in blade
$menu = \Cache::remember('voyager_menu_'.$menuName, \Carbon\Carbon::now()->addDays(30), function () use ($menuName) {
return static::where('name', '=', $menuName)
... | php | {
"resource": ""
} |
q254258 | Translatable.translatable | test | public function translatable()
{
if (isset($this->translatable) && $this->translatable == false) {
return false;
}
return !empty($this->getTranslatableAttributes());
} | php | {
"resource": ""
} |
q254259 | Translatable.translations | test | public function translations()
{
return $this->hasMany(Voyager::model('Translation'), 'foreign_key', $this->getKeyName())
->where('table_name', $this->getTable())
->whereIn('locale', config('voyager.multilingual.locales', []));
} | php | {
"resource": ""
} |
q254260 | Translatable.getTranslatedAttribute | test | public function getTranslatedAttribute($attribute, $language = null, $fallback = true)
{
list($value) = $this->getTranslatedAttributeMeta($attribute, $language, $fallback);
return $value;
} | php | {
"resource": ""
} |
q254261 | Translatable.scopeWhereTranslation | test | public static function scopeWhereTranslation($query, $field, $operator, $value = null, $locales = null, $default = true)
{
if ($locales && !is_array($locales)) {
$locales = [$locales];
}
if (!isset($value)) {
$value = $operator;
$operator = '=';
}
... | php | {
"resource": ""
} |
q254262 | Translatable.saveTranslations | test | public function saveTranslations($translations)
{
foreach ($translations as $field => $locales) {
foreach ($locales as $locale => $translation) {
$translation->save();
}
}
} | php | {
"resource": ""
} |
q254263 | SchemaManager.describeTable | test | public static function describeTable($tableName)
{
Type::registerCustomPlatformTypes();
$table = static::listTableDetails($tableName);
return collect($table->columns)->map(function ($column) use ($table) {
$columnArr = Column::toArray($column);
$columnArr['field'] ... | php | {
"resource": ""
} |
q254264 | AddBreadPermission.handle | test | public function handle(BreadAdded $bread)
{
if (config('voyager.bread.add_permission') && file_exists(base_path('routes/web.php'))) {
// Create permission
//
// Permission::generateFor(snake_case($bread->dataType->slug));
$role = Voyager::model('Role')->where(... | php | {
"resource": ""
} |
q254265 | VoyagerServiceProvider.addStorageSymlinkAlert | test | protected function addStorageSymlinkAlert()
{
if (app('router')->current() !== null) {
$currentRouteAction = app('router')->current()->getAction();
} else {
$currentRouteAction = null;
}
$routeName = is_array($currentRouteAction) ? Arr::get($currentRouteAction... | php | {
"resource": ""
} |
q254266 | VoyagerServiceProvider.registerConsoleCommands | test | private function registerConsoleCommands()
{
$this->commands(Commands\InstallCommand::class);
$this->commands(Commands\ControllersCommand::class);
$this->commands(Commands\AdminCommand::class);
} | php | {
"resource": ""
} |
q254267 | VoyagerBaseController.cleanup | test | protected function cleanup($dataType, $data)
{
// Delete Translations, if present
if (is_bread_translatable($data)) {
$data->deleteAttributeTranslations($data->getTranslatableAttributes());
}
// Delete Images
$this->deleteBreadImages($data, $dataType->deleteRows-... | php | {
"resource": ""
} |
q254268 | VoyagerBaseController.deleteBreadImages | test | public function deleteBreadImages($data, $rows)
{
foreach ($rows as $row) {
if ($data->{$row->field} != config('voyager.user.default_avatar')) {
$this->deleteFileIfExists($data->{$row->field});
}
if (isset($row->details->thumbnails)) {
for... | php | {
"resource": ""
} |
q254269 | VoyagerBaseController.order | test | public function order(Request $request)
{
$slug = $this->getSlug($request);
$dataType = Voyager::model('DataType')->where('slug', '=', $slug)->first();
// Check permission
$this->authorize('edit', app($dataType->model_name));
if (!isset($dataType->order_column) || !isset($... | php | {
"resource": ""
} |
q254270 | VoyagerBaseController.relation | test | public function relation(Request $request)
{
$slug = $this->getSlug($request);
$page = $request->input('page');
$on_page = 50;
$search = $request->input('search', false);
$dataType = Voyager::model('DataType')->where('slug', '=', $slug)->first();
foreach ($dataType->... | php | {
"resource": ""
} |
q254271 | BreadRelationshipParser.resolveRelations | test | protected function resolveRelations($dataTypeContent, DataType $dataType)
{
// In case of using server-side pagination, we need to work on the Collection (BROWSE)
if ($dataTypeContent instanceof LengthAwarePaginator) {
$dataTypeCollection = $dataTypeContent->getCollection();
}
... | php | {
"resource": ""
} |
q254272 | MakeModelCommand.addSoftDelete | test | protected function addSoftDelete(&$stub)
{
$traitIncl = $trait = '';
if ($this->option('softdelete')) {
$traitIncl = 'use Illuminate\Database\Eloquent\SoftDeletes;';
$trait = 'use SoftDeletes;';
}
$stub = str_replace('//DummySDTraitInclude', $traitIncl, $stu... | php | {
"resource": ""
} |
q254273 | Controller.validateBread | test | public function validateBread($request, $data, $name = null, $id = null)
{
$rules = [];
$messages = [];
$customAttributes = [];
$is_update = $name && $id;
$fieldsWithValidationRules = $this->getFieldsWithValidationRules($data);
foreach ($fieldsWithValidationRules as... | php | {
"resource": ""
} |
q254274 | Controller.getFieldsWithValidationRules | test | protected function getFieldsWithValidationRules($fieldsConfig)
{
return $fieldsConfig->filter(function ($value) {
if (empty($value->details)) {
return false;
}
return !empty($value->details->validation->rule);
});
} | php | {
"resource": ""
} |
q254275 | Google_AccessToken_Verify.verifyIdToken | test | public function verifyIdToken($idToken, $audience = null)
{
if (empty($idToken)) {
throw new LogicException('id_token cannot be null');
}
// set phpseclib constants if applicable
$this->setPhpsecConstants();
// Check signature
$certs = $this->getFederatedSignOnCerts();
foreach ($ce... | php | {
"resource": ""
} |
q254276 | Google_AccessToken_Verify.retrieveCertsFromLocation | test | private function retrieveCertsFromLocation($url)
{
// If we're retrieving a local file, just grab it.
if (0 !== strpos($url, 'http')) {
if (!$file = file_get_contents($url)) {
throw new Google_Exception(
"Failed to retrieve verification certificates: '" .
$url . "'."
... | php | {
"resource": ""
} |
q254277 | Google_AccessToken_Verify.getFederatedSignOnCerts | test | private function getFederatedSignOnCerts()
{
$certs = null;
if ($cache = $this->getCache()) {
$cacheItem = $cache->getItem('federated_signon_certs_v3');
$certs = $cacheItem->get();
}
if (!$certs) {
$certs = $this->retrieveCertsFromLocation(
self::FEDERATED_SIGNON_CERT_URL... | php | {
"resource": ""
} |
q254278 | Google_AccessToken_Verify.setPhpsecConstants | test | private function setPhpsecConstants()
{
if (filter_var(getenv('GAE_VM'), FILTER_VALIDATE_BOOLEAN)) {
if (!defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) {
define('MATH_BIGINTEGER_OPENSSL_ENABLED', true);
}
if (!defined('CRYPT_RSA_MODE')) {
define('CRYPT_RSA_MODE', constant($this->ge... | php | {
"resource": ""
} |
q254279 | Google_Client.fetchAccessTokenWithAuthCode | test | public function fetchAccessTokenWithAuthCode($code)
{
if (strlen($code) == 0) {
throw new InvalidArgumentException("Invalid code");
}
$auth = $this->getOAuth2Service();
$auth->setCode($code);
$auth->setRedirectUri($this->getRedirectUri());
$httpHandler = HttpHandlerFactory::build($this... | php | {
"resource": ""
} |
q254280 | Google_Client.fetchAccessTokenWithAssertion | test | public function fetchAccessTokenWithAssertion(ClientInterface $authHttp = null)
{
if (!$this->isUsingApplicationDefaultCredentials()) {
throw new DomainException(
'set the JSON service account credentials using'
. ' Google_Client::setAuthConfig or set the path to your JSON file'
... | php | {
"resource": ""
} |
q254281 | Google_Client.fetchAccessTokenWithRefreshToken | test | public function fetchAccessTokenWithRefreshToken($refreshToken = null)
{
if (null === $refreshToken) {
if (!isset($this->token['refresh_token'])) {
throw new LogicException(
'refresh token must be passed in or set as part of setAccessToken'
);
}
$refreshToken = $this-... | php | {
"resource": ""
} |
q254282 | Google_Client.authorize | test | public function authorize(ClientInterface $http = null)
{
$credentials = null;
$token = null;
$scopes = null;
if (null === $http) {
$http = $this->getHttpClient();
}
// These conditionals represent the decision tree for authentication
// 1. Check for Application Default Credentia... | php | {
"resource": ""
} |
q254283 | Google_Client.isAccessTokenExpired | test | public function isAccessTokenExpired()
{
if (!$this->token) {
return true;
}
$created = 0;
if (isset($this->token['created'])) {
$created = $this->token['created'];
} elseif (isset($this->token['id_token'])) {
// check the ID token for "iat"
// signature verification is no... | php | {
"resource": ""
} |
q254284 | Google_Client.verifyIdToken | test | public function verifyIdToken($idToken = null)
{
$tokenVerifier = new Google_AccessToken_Verify(
$this->getHttpClient(),
$this->getCache(),
$this->config['jwt']
);
if (null === $idToken) {
$token = $this->getAccessToken();
if (!isset($token['id_token'])) {
thro... | php | {
"resource": ""
} |
q254285 | Google_Client.addScope | test | public function addScope($scope_or_scopes)
{
if (is_string($scope_or_scopes) && !in_array($scope_or_scopes, $this->requestedScopes)) {
$this->requestedScopes[] = $scope_or_scopes;
} else if (is_array($scope_or_scopes)) {
foreach ($scope_or_scopes as $scope) {
$this->addScope($scope);
... | php | {
"resource": ""
} |
q254286 | Google_Client.execute | test | public function execute(RequestInterface $request, $expectedClass = null)
{
$request = $request->withHeader(
'User-Agent',
$this->config['application_name']
. " " . self::USER_AGENT_SUFFIX
. $this->getLibraryVersion()
);
// call the authorize method
// this is where mo... | php | {
"resource": ""
} |
q254287 | Google_Client.setAuthConfig | test | public function setAuthConfig($config)
{
if (is_string($config)) {
if (!file_exists($config)) {
throw new InvalidArgumentException(sprintf('file "%s" does not exist', $config));
}
$json = file_get_contents($config);
if (!$config = json_decode($json, true)) {
throw new Log... | php | {
"resource": ""
} |
q254288 | Google_Client.createOAuth2Service | test | protected function createOAuth2Service()
{
$auth = new OAuth2(
[
'clientId' => $this->getClientId(),
'clientSecret' => $this->getClientSecret(),
'authorizationUri' => self::OAUTH2_AUTH_URL,
'tokenCredentialUri' => self::OAUTH2_TOKEN_URI,
'r... | php | {
"resource": ""
} |
q254289 | Google_Task_Runner.allowedRetries | test | public function allowedRetries($code, $errors = array())
{
if (isset($this->retryMap[$code])) {
return $this->retryMap[$code];
}
if (
!empty($errors) &&
isset($errors[0]['reason'], $this->retryMap[$errors[0]['reason']])
) {
return $this->retryMap[$errors[0]['reason']];
... | php | {
"resource": ""
} |
q254290 | Google_Http_MediaFileUpload.nextChunk | test | public function nextChunk($chunk = false)
{
$resumeUri = $this->getResumeUri();
if (false == $chunk) {
$chunk = substr($this->data, $this->progress, $this->chunkSize);
}
$lastBytePos = $this->progress + strlen($chunk) - 1;
$headers = array(
'content-range' => "bytes $this->progress-$... | php | {
"resource": ""
} |
q254291 | Google_Http_Batch.parseHttpResponse | test | private function parseHttpResponse($respData, $headerSize)
{
// check proxy header
foreach (self::$CONNECTION_ESTABLISHED_HEADERS as $established_header) {
if (stripos($respData, $established_header) !== false) {
// existed, remove it
$respData = str_ireplace($established_header, '', $re... | php | {
"resource": ""
} |
q254292 | Google_Utils_UriTemplate.getDataType | test | private function getDataType($data)
{
if (is_array($data)) {
reset($data);
if (key($data) !== 0) {
return self::TYPE_MAP;
}
return self::TYPE_LIST;
}
return self::TYPE_SCALAR;
} | php | {
"resource": ""
} |
q254293 | Google_Utils_UriTemplate.combineList | test | private function combineList(
$vars,
$sep,
$parameters,
$combine,
$reserved,
$tag_empty,
$combine_on_empty
) {
$ret = array();
foreach ($vars as $var) {
$response = $this->combine(
$var,
$parameters,
$sep,
$combine,
... | php | {
"resource": ""
} |
q254294 | Google_Utils_UriTemplate.getValue | test | private function getValue($value, $length)
{
if ($length) {
$value = substr($value, 0, $length);
}
$value = rawurlencode($value);
return $value;
} | php | {
"resource": ""
} |
q254295 | Google_Http_REST.doExecute | test | public static function doExecute(ClientInterface $client, RequestInterface $request, $expectedClass = null)
{
try {
$httpHandler = HttpHandlerFactory::build($client);
$response = $httpHandler($request);
} catch (RequestException $e) {
// if Guzzle throws an exception, catch it and handle the... | php | {
"resource": ""
} |
q254296 | Google_Http_REST.decodeHttpResponse | test | public static function decodeHttpResponse(
ResponseInterface $response,
RequestInterface $request = null,
$expectedClass = null
) {
$code = $response->getStatusCode();
// retry strategy
if (intVal($code) >= 400) {
// if we errored out, it should be safe to grab the response body
... | php | {
"resource": ""
} |
q254297 | Google_Model.mapTypes | test | protected function mapTypes($array)
{
// Hard initialise simple types, lazy load more complex ones.
foreach ($array as $key => $val) {
if ($keyType = $this->keyType($key)) {
$dataType = $this->dataType($key);
if ($dataType == 'array' || $dataType == 'map') {
$this->$key = array... | php | {
"resource": ""
} |
q254298 | Google_Model.toSimpleObject | test | public function toSimpleObject()
{
$object = new stdClass();
// Process all other data.
foreach ($this->modelData as $key => $val) {
$result = $this->getSimpleValue($val);
if ($result !== null) {
$object->$key = $this->nullPlaceholderCheck($result);
}
}
// Process all p... | php | {
"resource": ""
} |
q254299 | Google_Model.getSimpleValue | test | private function getSimpleValue($value)
{
if ($value instanceof Google_Model) {
return $value->toSimpleObject();
} else if (is_array($value)) {
$return = array();
foreach ($value as $key => $a_value) {
$a_value = $this->getSimpleValue($a_value);
if ($a_value !== null) {
... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.