_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q29100
CompositeComponent.provideShadowDOM
train
function provideShadowDOM () { return $this->shadowDOM ?: ( $this->view && $this->view->getEngine () instanceof MatisseEngine ? $this->view->getCompiled () : null // Shadow DOMs are only available for Matisse templates. ); }
php
{ "resource": "" }
q29101
Group.addFilters
train
public function addFilters() { foreach (func_get_args() as $filter) { if (is_a($filter, 'Rhubarb\Stem\Filters\Filter')) { $this->filters[] = $filter; } else { throw new \Exception('Non filter object added to Group filter'); } } ...
php
{ "resource": "" }
q29102
Script.parseString
train
public function parseString($script, array $tokens = []) { $values = array_values($tokens); $tokens = array_map( function ($token) { return '{{' . strtolower($token) . '}}'; }, array_keys($tokens) ); $this->script = str_replace($tokens, $val...
php
{ "resource": "" }
q29103
Script.parseFile
train
public function parseFile($file, array $tokens = []) { $this->filePath = $file; $template = accioPath('resources/scripts/' . str_replace('.', '/', $this->filePath) . '.sh'); if ($this->filesystem->exists($template)) { $this->parseString($this->filesystem->get($template), $tokens...
php
{ "resource": "" }
q29104
File.setSavePath
train
public function setSavePath($savePath) { if (empty($savePath)) return $this; $this->savePath = $savePath; if (!is_dir($this->savePath)) { mkdir($this->savePath); } return $this; }
php
{ "resource": "" }
q29105
PackageServiceProvider.mapRoutes
train
protected function mapRoutes() { if (!$this->app->routesAreCached()) { Route::group( ['middleware' => ['web']], function () { $routes = new Routes(); // Backend Routes $routes->mapBackendRoutes() ...
php
{ "resource": "" }
q29106
PackageServiceProvider.forceHTTPSScheme
train
private function forceHTTPSScheme($url) { if(env('FORCE_HTTPS_SCHEME')) { $url->formatScheme('https'); $this->app['request']->server->set('HTTPS', true); } }
php
{ "resource": "" }
q29107
PackageServiceProvider.boot
train
public function boot(UrlGenerator $url) { /** * Register commands, so you may execute them using the Artisan CLI. */ if ($this->app->runningInConsole()) { $this->commands($this->commands); } /* * redirect http to https */ $this...
php
{ "resource": "" }
q29108
TokenController.tokenAction
train
public function tokenAction() { // Can't do anything if not HTTP request... if (!$this->request instanceof HttpRequest) { return null; } // Currently, ZF2 Http Request object is not PSR-7 compliant, therefore we need to create a new one from // globals, and then ...
php
{ "resource": "" }
q29109
TokenController.revokeAction
train
public function revokeAction() { // Can't do anything if not HTTP request... if (!$this->request instanceof HttpRequest) { return null; } // Currently, ZF2 Http Request object is not PSR-7 compliant, therefore we need to create a new one from // globals, and then...
php
{ "resource": "" }
q29110
TokenController.deleteExpiredTokensAction
train
public function deleteExpiredTokensAction() { if (!$this->request instanceof ConsoleRequest) { throw new RuntimeException('You can only use this action from console'); } /* @var \ZfrOAuth2\Server\Service\TokenService $accessTokenService */ $accessTokenService = $this->se...
php
{ "resource": "" }
q29111
TokenController.convertToZfResponse
train
private function convertToZfResponse(ResponseInterface $response) { $zfResponse = new HttpResponse(); $zfResponse->setStatusCode($response->getStatusCode()); $zfResponse->setReasonPhrase($response->getReasonPhrase()); $zfResponse->setContent((string) $response->getBody()); ...
php
{ "resource": "" }
q29112
UserTrait.hasOwnership
train
public static function hasOwnership($app, $ownershipPostID) { if($ownershipPostID) { if(isPostType($app)) { $checkDB = DB::table($app) ->where('postID', $ownershipPostID) ->where('createdByUserID', Auth::user()->userID) ->coun...
php
{ "resource": "" }
q29113
UserTrait.getPermissions
train
public function getPermissions() { // return permissions if they have already been requested if(Session::get("usersPermission")) { self::$permissions = Session::get("usersPermission"); return Session::get("usersPermission"); } // return permissions if they hav...
php
{ "resource": "" }
q29114
UserTrait.getPermission
train
public static function getPermission($app, $key, $userID = 0) { //TODO $userID me mujt me i marr permissions e nje useri specifik return (isset(self::$permissions[$app][$key]) ? self::$permissions[$app][$key] : false); }
php
{ "resource": "" }
q29115
UserTrait.avatar
train
public function avatar($width = null, $height = null, $returnGravatarIfNotFound = false) { if($this->profileimage) { if(!$width && !$height) { return url($this->profileimage->url); }else{ return $this->profileimage->thumb($width, $height, $this->profi...
php
{ "resource": "" }
q29116
UserTrait.avatarImage
train
public function avatarImage($width = null, $height = null, $returnGravatarIfNotFound = false) { return new HtmlString( view()->make( "vendor.user.avatar", [ 'width'=>$width, 'height'=>$height, 'returnGravatarIfNotFound'=>$returnGravatarIfNotFou...
php
{ "resource": "" }
q29117
UserTrait.gavatarImage
train
public function gavatarImage($width = null, $height = null) { return new HtmlString( view()->make( "vendor.user.avatar", [ 'width' => $width, 'height' => $height, 'returnGravatarIfNotFound'=>true, 'imageURL'=> asset($this->gravata...
php
{ "resource": "" }
q29118
UserTrait.isActive
train
public static function isActive($guard = "admin") { if (Auth::guard($guard)->check()) { return Auth::user()->isActive; } return false; }
php
{ "resource": "" }
q29119
UserTrait.getAnAdmin
train
public static function getAnAdmin() { $permission = new Permission(); $getPermission = $permission->where('app', 'global')->where('key', 'admin')->where('value', true)->get()->first(); if($getPermission) { $adminRelations = RoleRelation::where('groupID', $getPermission->groupID...
php
{ "resource": "" }
q29120
UserTrait.assignRoles
train
public function assignRoles($groups, $bypassPermissionCheck = false) { // allow permission bypass only in the local environment if(config('app.env') == 'production' && $bypassPermissionCheck) { $bypassPermissionCheck = false; } // check if a user has permissions to acces...
php
{ "resource": "" }
q29121
UserTrait.hasDataInDefaultApps
train
public function hasDataInDefaultApps() { $tables = ["post_type", "categories", "tags", "languages", "media"]; foreach($tables as $table){ $hasData = DB::table($table)->where("createdByUserID", $this->userID)->count(); if($hasData) { return true; }...
php
{ "resource": "" }
q29122
oAuthBase.endpointDiscovery
train
protected function endpointDiscovery() { // Discover the endpoints $client = new Client(); //GuzzleHttp\Client try { $response = $client->get($this->oAuthDiscoveryUrl, [ 'curl' => $this->setDiscoveryCurlopts(), ]); // Parse the response ...
php
{ "resource": "" }
q29123
oAuthBase.parseDiscoveryResponse
train
private function parseDiscoveryResponse($response) { $body = json_decode($response->getBody(), true); $this->authorization_endpoint = $body['authorization_endpoint']; $this->token_endpoint = $body['token_endpoint']; $this->end_session_endpoint = $body['end_session_endpoint']; ...
php
{ "resource": "" }
q29124
oAuthBase.getCongfigParameters
train
protected function getCongfigParameters() { $this->apiEndpoint = getenv('MP_API_ENDPOINT', null); $this->oAuthDiscoveryUrl = getenv('MP_OAUTH_DISCOVERY_ENDPOINT', null); $this->mpClientId = getenv('MP_CLIENT_ID', null); $this->mpClientSecret = getenv('MP_CLIENT_SECRET', null); ...
php
{ "resource": "" }
q29125
oAuthBase.setDiscoveryCurlopts
train
protected function setDiscoveryCurlopts() { $curlopts = [ CURLOPT_POST => 0, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_VERBOSE => false, CURLOPT_RETURNTRANSFER => true ]; return $curlopts; }
php
{ "resource": "" }
q29126
oAuthBase.setOauthCurlopts
train
protected function setOauthCurlopts() { $curlopts = [ CURLOPT_POST => $this->fieldCount, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_VERBOSE => false, CURLOPT_RETURNTRANSFER => true ]; return $curlopts; }
php
{ "resource": "" }
q29127
MySqlComparisonSchema.fromTable
train
public static function fromTable($tableName) { $repos = Repository::getDefaultRepositoryClassName(); // Get the create table syntax for the table - we'll analyse this and build our schema accordingly. $row = $repos::returnFirstRow( "SHOW CREATE TABLE $tableName" ); ...
php
{ "resource": "" }
q29128
DCR_Sniffs_Files_LineLengthSniff.checkLineLength
train
protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr) { if (isset(PHP_CodeSniffer_Tokens::$commentTokens[$tokens[$stackPtr - 1]['code']]) === TRUE) { $doc_comment_tag = $phpcsFile->findFirstOnLine(T_DOC_COMMENT_TAG, $stackPtr - 1); if ($doc_comment_tag !== FALSE) { ...
php
{ "resource": "" }
q29129
DCR_Sniffs_Files_LineLengthSniff.getLineLength
train
public function getLineLength(PHP_CodeSniffer_File $phpcsFile, $currentLine) { $tokens = $phpcsFile->getTokens(); $tokenCount = 0; $currentLineContent = ''; $trim = (strlen($phpcsFile->eolChar) * -1); for (; $tokenCount < $phpcsFile->numTokens; $tokenCount++) { if ($tokens[$tokenCount]['line...
php
{ "resource": "" }
q29130
DCR_Sniffs_Files_LineLengthSniff.isInCodeExample
train
protected function isInCodeExample(PHP_CodeSniffer_File $phpcs_file, $stack_ptr) { $tokens = $phpcs_file->getTokens(); $prev_comment = $stack_ptr; $last_comment = $stack_ptr; while (($prev_comment = $phpcs_file->findPrevious(array(T_COMMENT), ($last_comment - 1), NULL, FALSE)) !== FALSE) { if (iss...
php
{ "resource": "" }
q29131
Navitia.getLineRoutes
train
public function getLineRoutes( $externalCoverageId, $externalNetworkId, $externalLineId ) { $query = array( 'api' => 'coverage', 'parameters' => array( 'region' => $externalCoverageId, 'path_filter' => 'networks/'.$externalNetwo...
php
{ "resource": "" }
q29132
Navitia.getStopPoints
train
public function getStopPoints( $externalCoverageId, $externalNetworkId, $externalLineId, $externalRouteId ) { return $this->navitia_sam->getStopPoints($externalCoverageId, $externalNetworkId, $externalLineId, $externalRouteId); }
php
{ "resource": "" }
q29133
Navitia.findAllLinesByMode
train
public function findAllLinesByMode($coverageId, $networkId) { $count = 30; $result = $this->navitia_sam->getLines($coverageId, $networkId, 1, $count); // no line found for this network if (empty($result) || !isset($result->lines)) { throw new \Exception( $...
php
{ "resource": "" }
q29134
Navitia.getLineTitle
train
public function getLineTitle($coverageId, $networkId, $lineId) { $response = $this->navitia_sam->getLine($coverageId, $networkId, $lineId); return ($response->lines[0]->name); }
php
{ "resource": "" }
q29135
Navitia.getStopPointPois
train
public function getStopPointPois($externalCoverageId, $stopPointId, $distance = 400) { $query = array( 'api' => 'coverage', 'parameters' => array( 'region' => $externalCoverageId, 'action' => 'places_nearby', 'path_filter' => 'stop_poin...
php
{ "resource": "" }
q29136
Navitia.getRouteData
train
public function getRouteData($routeExternalId, $externalCoverageId) { // param depth '3' to get 'administrative_region' in response $response = $this->navitia_sam->getRoute($externalCoverageId, $routeExternalId, 3); if (!isset($response->routes) || empty($response->routes)) { thr...
php
{ "resource": "" }
q29137
Navitia.getRouteCalendars
train
public function getRouteCalendars($externalCoverageId, $externalRouteId, \DateTime $startDate, \DateTime $endDate) { $query = array( 'api' => 'coverage', 'parameters' => array( 'region' => $externalCoverageId, 'action' => 'calendars', '...
php
{ "resource": "" }
q29138
Navitia.getCalendar
train
public function getCalendar($externalCoverageId, $calendarId) { $query = array( 'api' => 'coverage', 'parameters' => array( 'region' => $externalCoverageId, 'action' => $calendarId, 'path_filter' => 'calendars' ), );...
php
{ "resource": "" }
q29139
Navitia.getStopPointCalendarsData
train
public function getStopPointCalendarsData($externalCoverageId, $externalRouteId, $externalStopPointId) { $query = array( 'api' => 'coverage', 'parameters' => array( 'region' => $externalCoverageId, 'action' => 'calendars', 'path_filter'...
php
{ "resource": "" }
q29140
Navitia.getCalendarStopSchedulesByRoute
train
public function getCalendarStopSchedulesByRoute($externalCoverageId, $externalRouteId, $externalStopPointId, $externalCalendarId) { // TODO: Retrieve fromdatetime from FUSIO // cf http://jira.canaltp.fr/browse/METH-196 $fromdatetime = new \DateTime('now'); $fromdatetime->setTime(4, 0...
php
{ "resource": "" }
q29141
Module.theliaModule
train
public function theliaModule($params, \Smarty_Internal_Template $parser) { $content = null; $count = 0; if (false !== $location = $this->getParam($params, 'location', false)) { if ($this->debug === true && $this->requestStack->getCurrentRequest()->get('SHOW_INCLUDE')) { ...
php
{ "resource": "" }
q29142
BaseUserController.getAll
train
public function getAll($lang = "") { // check if user has permissions to access this link if(!User::hasAccess('User', 'read')) { return $this->noPermission(); } $orderBy = (isset($_GET['order'])) ? $orderBy = $_GET['order'] : 'userID'; $orderType = (isset($_GET['...
php
{ "resource": "" }
q29143
BaseUserController.storeProfileImage
train
public function storeProfileImage(Request $request) { // check if user has permissions to access this link if(!User::hasAccess('user', 'update')) { return $this->noPermission(); } return $path = $request->file('profileImageID')->storeAs('images', 'filename.jpg'); }
php
{ "resource": "" }
q29144
BaseUserController.deleteUser
train
private function deleteUser($id) { // check if user has permissions to access this link if(!User::hasAccess('user', 'delete')) { return $this->noPermission(); } $user = User::find($id); // user can't be deleted if it has related data to him, like posts, categorie...
php
{ "resource": "" }
q29145
BaseUserController.bulkDelete
train
public function bulkDelete(Request $request) { foreach ($request->all() as $id){ if (!$this->deleteUser($id)) { return $this->response('Internal server error. Please try again later', 500); } } return $this->response('Users are deleted'); }
php
{ "resource": "" }
q29146
BaseUserController.detailsJSON
train
public function detailsJSON($lang, $id) { // check if user has permissions to access this link if(\Illuminate\Support\Facades\Auth::user()->userID != $id) { if (!User::hasAccess('User', 'read')) { return $this->noPermission(); } } $user = App\...
php
{ "resource": "" }
q29147
BaseUserController.resetPassword
train
public function resetPassword(Request $request) { // check if user has permissions to access this link if(!User::hasAccess('user', 'update')) { return $this->noPermission(); } // validation $validator = Validator::make( $request->all(), [ '...
php
{ "resource": "" }
q29148
BaseUserController.getAdvancedSearchFieldsResults
train
public function getAdvancedSearchFieldsResults(Request $request) { // check if user has permissions to access this link if(!User::hasAccess('User', 'read')) { return $this->noPermission(); } // join parameters for the query // we are left joining the the media tab...
php
{ "resource": "" }
q29149
Security.checkAuthFunction
train
public function checkAuthFunction($params, &$smarty) { $roles = $this->explode($this->getParam($params, 'role')); $resources = $this->explode($this->getParam($params, 'resource')); $modules = $this->explode($this->getParam($params, 'module')); $accesses = $this->explode($this->getPar...
php
{ "resource": "" }
q29150
MigrateCommand.runMigration
train
private function runMigration() { // Confirm connection and migration. $connection = $this->confirmConnectionAndMigration(); // Load the migration class. $migration_class = $this->getMigrationClass(); // Process the migration. $this->processMigration($connection, $m...
php
{ "resource": "" }
q29151
MigrateCommand.confirmConnectionAndMigration
train
private function confirmConnectionAndMigration() { // Verify which connection to use. $connection = $this->verifyConnection(); // Check if the data table exists against this connection. if ($this->checkTableExists($this->argument('dataset'), true, $connection)) { $this->...
php
{ "resource": "" }
q29152
MigrateCommand.getMigrationClass
train
private function getMigrationClass() { // Load the configuration for this dataset. $config = $this->loadConfig($this->argument('dataset')); // Calculate some reference variables. $namespace = $config['namespace']; $class_name = sprintf('CreateData%sTable', studly_case($this-...
php
{ "resource": "" }
q29153
MigrateCommand.processMigration
train
private function processMigration($connection, $class) { // Verbose. $this->info('Migrating...'); $this->line(''); // Migrate the database. $migration = new $class($connection); $migration->up($connection); }
php
{ "resource": "" }
q29154
MigrateCommand.createMigrationFile
train
private function createMigrationFile($connection, $class) { // Interate the database file. $next_interation = $this->getNextInteration(); // Create an extension of this migration script in the database/migrations folder. $alias_file_name = sprintf('%s_%s_create_%s_table', date('Y_m_...
php
{ "resource": "" }
q29155
FileSystem.getNewFilename
train
public static function getNewFilename($dst) { $fileexts = explode('.', $dst); if(count($fileexts) > 1) { $filename = implode('.', array_slice($fileexts, 0, -1)); $ext = $fileexts[count($fileexts)-1]; $dst = $filename.'.'.$ext; } else $filename = $dst; $i=1; while(file_exists($dst)) ...
php
{ "resource": "" }
q29156
FileSystem.write
train
public static function write($dst, $content, $mode=null, $append=false) { if($mode === null) $mode = static::OVERRIDE; if($mode & static::RENAME) $dst = static::getNewFilename($dst); elseif($mode & static::OVERRIDE) static::delete($dst); elseif(file_exists($dst)) return false; static:...
php
{ "resource": "" }
q29157
Zippy.create
train
public function create($path, $files = null, $recursive = true, $type = null, $password = null) { if (null === $type) { $type = $this->guessAdapterExtension($path); } try { $adapter = $this->getAdapterFor($this->sanitizeExtension($type)); ...
php
{ "resource": "" }
q29158
Zippy.open
train
public function open($path, $type = null, $password = null) { if (null === $type) { $type = $this->guessAdapterExtension($path); } try { $adapter = $this->getAdapterFor($this->sanitizeExtension($type)); if (method_exists($adapter, 'setPassword') && $passw...
php
{ "resource": "" }
q29159
Zippy.guessAdapterExtension
train
private function guessAdapterExtension($path) { $path = strtolower(trim($path)); foreach ($this->getStrategies() as $extension => $strategy) { if ($extension === substr($path, (strlen($extension) * -1))) { return $extension; } } return null; ...
php
{ "resource": "" }
q29160
ImageCropper.setWidth
train
public function setWidth($value) { $this->width = intval($value); $this->right = null; return $this; }
php
{ "resource": "" }
q29161
ImageCropper.setHeight
train
public function setHeight($value) { $this->height = intval($value); $this->bottom = null; return $this; }
php
{ "resource": "" }
q29162
User.recover
train
public static function recover($data) { if (!Tilmeld::$config['pw_recovery']) { return [ 'result' => false, 'message' => 'Account recovery is not allowed.' ]; } $user = User::factory($data['username']); if (!isset($user->guid) || !isset($user->recoverSecret) ...
php
{ "resource": "" }
q29163
User.getDescendantGroups
train
public function getDescendantGroups() { if (!isset($this->descendantGroups)) { $this->descendantGroups = []; if (isset($this->group)) { $this->descendantGroups = (array) $this->group->getDescendants(); } foreach ($this->groups as $curGroup) { $this->descendantGroups...
php
{ "resource": "" }
q29164
User.getTimezone
train
public function getTimezone($returnDateTimeZoneObject = false) { if (!empty($this->timezone)) { return $returnDateTimeZoneObject ? new DateTimeZone($this->timezone) : $this->timezone; } if (isset($this->group->guid) && !empty($this->group->timezone)) { return $returnDateTimeZoneO...
php
{ "resource": "" }
q29165
User.gatekeeper
train
public function gatekeeper($ability = null) { if (!isset($ability)) { return self::current(true)->is($this); } // Check the cache to see if we've already checked this user. if ($this->gatekeeperCache) { $abilities =& $this->gatekeeperCache; } else { $abilities = $this->abilities; ...
php
{ "resource": "" }
q29166
User.checkPassword
train
public function checkPassword($password) { switch (Tilmeld::$config['pw_method']) { case 'plain': return ($this->password == $password); case 'digest': return ($this->password == hash('sha256', $password)); case 'salt': default: return ($this->password == hash('sha256...
php
{ "resource": "" }
q29167
User.isDescendant
train
public function isDescendant($group = null) { if (is_numeric($group)) { $group = Group::factory((int) $group); } if (!isset($group->guid)) { return false; } // Check to see if the user is in a descendant group of the given group. if (isset($this->group->guid) && $this->group->isDesce...
php
{ "resource": "" }
q29168
User.changePassword
train
public function changePassword($data) { if (!isset($data['password']) || (string) $data['password'] === '') { return ['result' => false, 'message' => 'Please specify a password.']; } if (!$this->checkPassword($data['oldPassword'])) { return ['result' => false, 'message' => 'Incorrect password.']...
php
{ "resource": "" }
q29169
User.checkUsername
train
public function checkUsername() { if (!Tilmeld::$config['email_usernames']) { if (empty($this->username)) { return ['result' => false, 'message' => 'Please specify a username.']; } if (Tilmeld::$config['max_username_length'] > 0 && strlen($this->username) > Tilmeld::$config['max_...
php
{ "resource": "" }
q29170
User.checkPhone
train
public function checkPhone() { if (empty($this->phone)) { return ['result' => false, 'message' => 'Please specify a phone number.']; } $stripToDigits = preg_replace('/\D/', '', $this->phone); if (!preg_match('/\d{10}/', $stripToDigits)) { return [ 'result' => false, 'message...
php
{ "resource": "" }
q29171
CurlHelper.getRequestHandle
train
public function getRequestHandle(RequestContext $context) { $curlHandle = curl_init(); $defaults = $this->getDefaultSettings($context); $defaults += $this->getCurlTimeoutSettings($context); $defaults += $this->getCurlSslSettings(); $defaults += $this->getProxySettings($co...
php
{ "resource": "" }
q29172
CurlHelper.executeRequestHandle
train
public function executeRequestHandle($curlHandle) { curl_setopt($curlHandle, CURLOPT_VERBOSE, true); $verbose = fopen('php://temp', 'w+'); curl_setopt($curlHandle, CURLOPT_STDERR, $verbose); @list($headers, $response) = explode("\r\n\r\n", curl_exec($curlHandle), 2); $error...
php
{ "resource": "" }
q29173
CurlHelper.getProxySettings
train
private function getProxySettings(RequestContext $context): array { $proxy = []; if (!is_null($context->getProxy())) { $proxy[CURLOPT_PROXY] = $context->getProxy(); } return $proxy; }
php
{ "resource": "" }
q29174
CurlHelper.getCurlTimeoutSettings
train
private function getCurlTimeoutSettings(RequestContext $context): array { $timeoutOptions = []; $timeout = $context->getTimeout(); $timeoutOptions += $this->fillTimeoutOptions($timeout, CURLOPT_TIMEOUT, CURLOPT_TIMEOUT_MS); $connectionTimeout = $context->getConnectionTimeout(); ...
php
{ "resource": "" }
q29175
CurlHelper.getDefaultSettings
train
private function getDefaultSettings(RequestContext $context): array { $defaults = [ CURLOPT_ENCODING => "", CURLOPT_USERAGENT => "php-nano-rest", CURLOPT_HEADER => true, CURLOPT_HTTPHEADER => array_values($context->getRequestHeaders()), CURLOPT_RET...
php
{ "resource": "" }
q29176
CurlHelper.fillTimeoutOptions
train
private function fillTimeoutOptions($timeout, $optionName, $optionNameMs): array { $timeoutOptions = []; if (is_int($timeout)) { $timeoutOptions[$optionName] = $timeout; } elseif (is_float($timeout)) { $timeoutOptions[$optionNameMs] = $timeout * 1000; $ti...
php
{ "resource": "" }
q29177
Property.required
train
public function required() { if(isset($this->params['required'])) return !!$this->params['required']; if(isset($this->params['validation']['required'])) return !!$this->params['validation']['required']; }
php
{ "resource": "" }
q29178
Property.getDefault
train
public function getDefault($entity, $name) { if($this->get('many')) return new ManyCollection($entity, $name); elseif(isset($this->params['default'])) { if(is_callable($this->params['default'])) return $this->params['default'](); else return $this->params['default']; } else return $this->_ge...
php
{ "resource": "" }
q29179
Property.serialize
train
public function serialize($val) { if($this->get('many')) { if(!$val instanceof ManyCollection) return serialize([]); $r = []; foreach($val as $v) { $s = $this->doSerialize($v); if($s !== null) $r[] = $s; } return serialize($r); } else return $this->doSerialize($val); }
php
{ "resource": "" }
q29180
Property.doSerialize
train
protected function doSerialize($val) { if(is_string($val) || is_numeric($val) || is_bool($val) || is_null($val)) return $val; else return serialize($val); }
php
{ "resource": "" }
q29181
Property.unserialize
train
public function unserialize($str, $entity, $name) { if($this->get('many')) { $r = new ManyCollection($entity, $name); $arr = unserialize($str); if(!is_array($arr)) return $r; foreach($arr as $v) $r[] = $this->doUnserialize($v, $entity); return $r; } else return $this->doUnserialize($str,...
php
{ "resource": "" }
q29182
Property.setDecorator
train
public function setDecorator($val, Entity $entity, $name, $silentException=false) { if($this->get('many')) { if($val instanceof ManyCollection) return $val; if(is_array($val)) { $res = new ManyCollection($entity, $name); foreach($val as $v) $res[] = $this->_doSet($v, $entity, $name, $silentExce...
php
{ "resource": "" }
q29183
Property._doSet
train
public function _doSet($val, Entity $entity, $name, $silentException=false) { if($silentException) { try { return $this->doSet($val, $entity, $name); } catch(\Exception $e) { return null; } catch(\Throwable $e) { return null; } } else return $this->doSet($val, $entity, $name); }
php
{ "resource": "" }
q29184
Meta.removeMetaTag
train
public function removeMetaTag($name) { if(isset($this->metaList[$name])) { unset($this->metaList[$name]); } return $this; }
php
{ "resource": "" }
q29185
Meta.setDescription
train
public function setDescription($objectData, $customData = []) { $this->set('description', $customData['description']); // Custom description if(isset($customData['description'])) { $this->set('description', $customData['description']); }else{ // Avoid duplicat...
php
{ "resource": "" }
q29186
Meta.setProfileOG
train
public function setProfileOG($profileObj) { Meta::set("profile:first_name", $profileObj->firstName, "property"); Meta::set("profile:last_name", $profileObj->lastName, "property"); if(isset($profileObj->gender)) { Meta::set("profile:gender", $profileObj->gender, "property"); ...
php
{ "resource": "" }
q29187
Meta.setArticleOG
train
public function setArticleOG($postObj) { Meta::set("article:published_time", $postObj->created_at->format('c'), "propery");// When the article was first published. Meta::set("article:modified_time", $postObj->updated_at->format('c'), "propery");// When the article was last changed. // Autho...
php
{ "resource": "" }
q29188
Meta.setImageOG
train
public function setImageOG($imageObj) { if($imageObj) { Meta::set("og:image", asset($imageObj->url), "property"); Meta::set("og:image:type", $imageObj->type."/".str_replace("jpg", "jpeg", $imageObj->extension), "property"); if($imageObj->description) { Met...
php
{ "resource": "" }
q29189
Meta.printMetaTags
train
public function printMetaTags() { if(!$this->getMetaIsPrinted()) { $this->printTitle(); $this->printMetaTagsList(); $this->printCanonical(); $this->printHrefLang(); $this->setMetaIsPrinted(); } return $this; }
php
{ "resource": "" }
q29190
Meta.printMetaTagsList
train
private function printMetaTagsList() { foreach($this->metaList as $metaName=>$metaData){ if(in_array($metaName, $this->allowedDuplicateMeta)) { foreach($metaData as $duplicateMetaData){ print '<meta '.$duplicateMetaData['type'].'="'.$metaName.'" content="'.$du...
php
{ "resource": "" }
q29191
Meta.parseAttributes
train
public function parseAttributes($attributes) { if($attributes) { $htmlMeta = ' '; foreach ($attributes as $key => $value) { // false async means no async if ($key == 'async' && $value == false) { continue; } ...
php
{ "resource": "" }
q29192
Meta.validateWildCards
train
public function validateWildCards($input, $errorClass = '') { preg_match_all('@\{.*?\}}@', $input, $matches); $notDefined = []; if($matches) { foreach ($matches as $match) { foreach ($match as $wildcard) { if (!array_key_exists($wildcard, $th...
php
{ "resource": "" }
q29193
Meta.setHrefLang
train
public function setHrefLang($url, $hreflang) { if($url && $hreflang) { $this->hreflang[] = [ 'url' => $url, 'lang' => $hreflang ]; } return $this; }
php
{ "resource": "" }
q29194
Meta.setHrefLangData
train
public function setHrefLangData($model, $routeName = '') { foreach(Language::getVisibleList() as $language){ Meta::setHrefLang($model->translate($language->slug)->href($routeName), $language->slug); } return $this; }
php
{ "resource": "" }
q29195
ArrayUtils.get
train
public static function get($arr, $str_path, $default=null) { $path = explode('.', $str_path); return static::array_get($arr, $path, $default); }
php
{ "resource": "" }
q29196
ArrayUtils.set
train
public static function set(&$arr, $str_path, $value) { $path = explode('.', $str_path); static::array_set($arr, $path, $value); }
php
{ "resource": "" }
q29197
ArrayUtils.append
train
public static function append(&$arr, $str_path, $value) { $path = explode('.', $str_path); static::array_append($arr, $path, $value); }
php
{ "resource": "" }
q29198
ArrayUtils.array_append
train
public static function array_append(&$arr, $path, $value) { if(!is_array($path)) $path = [$path]; $lastkey = array_pop($path); foreach($path as $parent) $arr =& $arr[$parent]; $arr[$lastkey][] = $value; }
php
{ "resource": "" }
q29199
ArrayUtils.array_get
train
public static function array_get($arr, $path, $default=null) { if(!is_array($path)) $path = [$path]; foreach($path as $key) { if(!isset($arr[$key])) return $default; else $arr = $arr[$key]; } return $arr; }
php
{ "resource": "" }