_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q239600
SocialLoginController.auth
train
public function auth(Request $request, $action) { $provider = strtolower($request->attributes->get('provider')); if (! $this->providerExists($provider)) { return $this->createNotFoundResponse(); } $service = $this->getServiceByProvider($provider); $redirectUri ...
php
{ "resource": "" }
q239601
SocialLoginController.callback
train
public function callback(Request $request) { // Check to see if this provider exists and has a callback implemented $provider = strtolower($request->attributes->get('provider')); if (! $this->providerExists($provider)) { return $this->createNotFoundResponse(); } ...
php
{ "resource": "" }
q239602
SocialLoginController.providerExists
train
protected function providerExists($provider) { return ( array_key_exists($provider, $this->serviceMap) || array_key_exists($provider, $this->config) ); }
php
{ "resource": "" }
q239603
SocialLoginController.github
train
protected function github(Oauth2Service\GitHub $github, TokenInterface $token) { $emails = json_decode($github->request('user/emails'), true); $user = json_decode($github->request('user'), true); $loginRequest = new LoginRequest( 'github', $user['id'], ...
php
{ "resource": "" }
q239604
SocialLoginController.google
train
protected function google(Oauth2Service\Google $google, TokenInterface $token) { $user = json_decode($google->request('https://www.googleapis.com/oauth2/v1/userinfo'), true); $loginRequest = new LoginRequest( 'google', $user['id'], $token->getAccessToken(), ...
php
{ "resource": "" }
q239605
SocialLoginController.facebook
train
protected function facebook(Oauth2Service\Facebook $facebook, TokenInterface $token) { $user = json_decode($facebook->request('/me'), true); $loginRequest = new LoginRequest( 'facebook', $user['id'], $token->getAccessToken(), $token->getEndOfLife() > ...
php
{ "resource": "" }
q239606
SocialLoginController.getServiceByProvider
train
public function getServiceByProvider($provider) { $redirect = $this->url($this->config[$provider]['callback_route'], array( 'provider' => $provider, )); $serviceName = $this->serviceMap[$provider]; $storage = new SessionStorage(false); $credentials = new Cons...
php
{ "resource": "" }
q239607
Yaml.dumpToSimpleYaml
train
protected function dumpToSimpleYaml($array) { $parts = []; foreach ($array as $key => $value) { $parts[] = "$key: $value"; } $yaml = implode("\n", $parts); return $yaml; }
php
{ "resource": "" }
q239608
Yaml.parseYaml
train
public static function parseYaml($yaml) { if (self::$yamlParser == null) { self::$yamlParser = new YamlParser; } return self::$yamlParser->parse($yaml); }
php
{ "resource": "" }
q239609
File.deleteAction
train
public function deleteAction($parameter) { try { if(!$this->request->isPost()) { return $this->jsonResult(400, 'Please access via POST method.', 'error_access_post'); } if(!$this->getFile()) { return $this->jsonResult(400, 'No file was uploade...
php
{ "resource": "" }
q239610
File.downloadAction
train
public function downloadAction($parameter) { if(!$this->getFile()) { return 404; } if(count($parameter) > 1) { return 404; } if($parameter && $parameter[0] != $this->filename) { return 404; } return Misc::servefile($this->fil...
php
{ "resource": "" }
q239611
File.uploadAction
train
public function uploadAction($parameter) { try { if(!$files = $this->request->files()) { return $this->jsonResult(400, 'Failed to upload file.', 'error_upload_failed'); } foreach($files as $file) { if($error = $file->getError()) { ...
php
{ "resource": "" }
q239612
Bookability_Availability.find
train
public function find($token, $_params = array()) { return $this->transform($this->master->get('availability/' . $token, $_params)); }
php
{ "resource": "" }
q239613
Bookability_Availability.month
train
public function month($token, $_params = array()) { return $this->transform($this->master->get('availability/' . $token . '/month', $_params), true); }
php
{ "resource": "" }
q239614
Bookability_Availability.date
train
public function date($token, $_params = array()) { return $this->transform($this->master->get('availability/' . $token . '/date', $_params), true); }
php
{ "resource": "" }
q239615
Query.fullQueryString
train
protected function fullQueryString() { $queryParts = []; // Main search can be default search or full text search. if ($this->queryString) { if (!$this->querySwitchFulltext) { $queryParts[] = $this->queryString; } else { $queryParts[] ...
php
{ "resource": "" }
q239616
Query.getPazpar2BaseURL
train
public function getPazpar2BaseURL() { $URL = 'http://' . GeneralUtility::getIndpEnv('HTTP_HOST') . $this->getPazpar2Path(); if ($this->pazpar2BaseURL) { $URL = $this->pazpar2BaseURL; } return $URL; }
php
{ "resource": "" }
q239617
Query.queryIsDone
train
protected function queryIsDone() { $result = false; $statReplyString = $this->fetchURL($this->pazpar2StatURL()); $statReply = GeneralUtility::xml2array($statReplyString); if ($statReply) { // The progress variable is a string representing a number between //...
php
{ "resource": "" }
q239618
Query.fetchResults
train
protected function fetchResults() { $maxResults = 1000; // limit results if (count($this->conf['exportFormats']) > 0) { // limit results even more if we are creating export data $maxResults = $maxResults / (count($this->conf['exportFormats']) + 1); } $recordsT...
php
{ "resource": "" }
q239619
Query.pazpar2ShowURL
train
protected function pazpar2ShowURL($start = 0, $num = 500) { $URL = $this->getPazpar2BaseURL() . '?command=show'; $URL .= '&query=' . urlencode($this->fullQueryString()); $URL .= '&start=' . $start . '&num=' . $num; $URL .= '&sort=' . urlencode($this->sortOrderString()); $URL ...
php
{ "resource": "" }
q239620
Query.sortOrderString
train
protected function sortOrderString() { $sortOrderComponents = []; foreach ($this->getSortOrder() as $sortCriterion) { $sortOrderComponents[] = $sortCriterion['fieldName'] . ':' . (($sortCriterion['direction'] === 'descending') ? '0' : '1'); } $sortOrde...
php
{ "resource": "" }
q239621
Query.yearSort
train
protected function yearSort($a, $b) { $aDates = $this->extractNewestDates($a); $bDates = $this->extractNewestDates($b); if (count($aDates) > 0 && count($bDates) > 0) { return $bDates[0] - $aDates[0]; } elseif (count($aDates) > 0 && count($bDates) === 0) { ret...
php
{ "resource": "" }
q239622
DataProvider.getObjects
train
public function getObjects($query, $object) { $this->statement = $this->db->query($query); if ($this->statement) { $this->statement->setFetchMode(\PDO::FETCH_CLASS, $object); $objects = $this->statement->fetchAll(); if ($objects) { return $objects...
php
{ "resource": "" }
q239623
DataProvider.getObject
train
public function getObject($query, $object) { $this->statement = $this->db->query($query); if ($this->statement) { $this->statement->setFetchMode(\PDO::FETCH_CLASS, $object); return $this->statement->fetch(); } return false; }
php
{ "resource": "" }
q239624
DataProvider.getArrays
train
public function getArrays($query) { $this->statement = $this->db->query($query); if ($this->statement) { $result = $this->statement->fetchAll(\PDO::FETCH_ASSOC); if ($result) { return $result; } } return false; }
php
{ "resource": "" }
q239625
ShardManager.registerShard
train
public function registerShard($shard_name, $parameters) { if (empty($shard_name)) { throw new \Exception("The shard name is not specified!"); } if (!empty($this->shard_table[$shard_name])) { throw new \Exception("The shard '$shard_name' has been already regis...
php
{ "resource": "" }
q239626
ShardManager.dbshard
train
public function dbshard($shard_name) { if (empty($shard_name) || empty($this->shard_table[$shard_name])) { throw new \Exception("The shard '$shard_name' was not found!"); return null; } if (empty($this->shard_table[$shard_name]["dbworker"])) { $th...
php
{ "resource": "" }
q239627
VolumeManager.findByFileId
train
public function findByFileId($fileId) { foreach ($this->volumes as $volume) { try { $file = $volume->findFile($fileId); if ($file) { return $volume; } } catch (\Exception $e) { } } return...
php
{ "resource": "" }
q239628
VolumeManager.findByFolderId
train
public function findByFolderId($folderId) { foreach ($this->volumes as $volume) { if ($volume->findFolder($folderId)) { return $volume; } } return null; }
php
{ "resource": "" }
q239629
EnvironmentVariableStrategy.get
train
public function get() { $result = $this->_environment ? $this->_environment->getenv($this->_name) : getenv($this->_name); return $result !== false ? $result : null; }
php
{ "resource": "" }
q239630
CiiPHPMessageSource.getMessageFile
train
protected function getMessageFile($category,$language) { if(!isset($this->_files[$category][$language])) { if(($pos=strpos($category,'.'))!==false && strpos($category,'ciims') === false) { $extensionClass=substr($category,0,$pos); $extensionCategory=substr($categor...
php
{ "resource": "" }
q239631
Php.parse
train
public function parse(\Pinocchio\Pinocchio $pinocchio, \Pinocchio\Highlighter\HighlighterInterface $highlighter = null) { if (null === $highlighter) { $highlighter = new Pygments(); } $code = ''; // $docBlocks is initialized with an empty element for the '<?php' start o...
php
{ "resource": "" }
q239632
Php.getCommentRegexSet
train
public function getCommentRegexSet() { return array( self::REGEX_COMMENT_SINGLE_LINE, self::REGEX_COMMENT_MULTILINE_START, self::REGEX_COMMENT_MULTILINE_CONT, self::REGEX_COMMENT_MULTILINE_END, self::REGEX_COMMENT_MULTILINE_ONE_LINER, ); ...
php
{ "resource": "" }
q239633
Php.parseDocblocks
train
protected function parseDocblocks($rawDocBlocks) { $parsedDocBlocks = array(); $docBlockParser = new MarkdownParser(); foreach ($rawDocBlocks as $docBlock) { $docBlock = preg_replace(self::REGEX_DOCBLOCK_TYPE, '$1$2 `$4` ', $docBlock); $docBlock = preg_replace(self::...
php
{ "resource": "" }
q239634
LeanRecent.update
train
public function update( $new_instance, $old_instance ) { $post_types = get_post_types(); $selected = isset( $_REQUEST[ $this->get_field_id( 'post_type' ) ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $this->get_field_id( 'post_type' ) ] ) ) : false; if ( in_array( $selected, $post_types, true ) ) { ...
php
{ "resource": "" }
q239635
UserHelper.GetAndStoreUsersInSession
train
public static function GetAndStoreUsersInSession($caller) { $users = array(); if (!$caller->app()->user()->getAttribute(\Puzzlout\Framework\Enums\SessionKeys::AllUsers)) { $manager = $caller->managers()->getDalInstance($caller->module()); $users = $manager->selectAllUsers(); ...
php
{ "resource": "" }
q239636
UserHelper.AddNewUserToSession
train
public static function AddNewUserToSession($caller, $user) { $users = self::GetAndStoreUsersInSession($caller); $users[] = $user; $caller->app()->user->setAttribute( \Puzzlout\Framework\Enums\SessionKeys::AllUsers, $users ); }
php
{ "resource": "" }
q239637
UserHelper.CategorizeUsersList
train
public static function CategorizeUsersList($users) { $list = array(); if (is_array($users) && count($users) > 0) { foreach ($users as $user) { $userType = $user->user_type(); $list[$userType][] = $user; } } return $list; }
php
{ "resource": "" }
q239638
Ip.getProxyString
train
private static function getProxyString(): ?string { $proxyString = null; if (\getenv('HTTP_CLIENT_IP')) { $proxyString = \getenv('HTTP_CLIENT_IP'); } elseif (\getenv('HTTP_X_FORWARDED_FOR')) { $proxyString = \getenv('HTTP_X_FORWARDED_FOR'); } elseif (\getenv('...
php
{ "resource": "" }
q239639
Ip.getFirstIP
train
private static function getFirstIP($proxyString = ''): ?string { \preg_match('/^(([0-9]{1,3}\.){3}[0-9]{1,3})/', $proxyString, $matches); return (\is_array($matches) && isset($matches[1])) ? $matches[1] : null; }
php
{ "resource": "" }
q239640
Ip.getFullIpHost
train
private static function getFullIpHost($clientIpHost = null, $proxyIpHost = null): ?string { $fullIpHost = []; if ($clientIpHost !== null) { $fullIpHost[] = \sprintf('client: %s', $clientIpHost); } if ($proxyIpHost !== null) { $fullIpHost[] = \sprintf('proxy: %...
php
{ "resource": "" }
q239641
Ip.check
train
public static function check(): array { $remoteAddr = \getenv('REMOTE_ADDR') ?: null; $httpVia = \getenv('HTTP_VIA') ?: null; $proxyString = static::getProxyString(); $ipData = static::$ipData; if ($remoteAddr !== null) { if ($proxyString !== null) { ...
php
{ "resource": "" }
q239642
JagilpeEntityListExtension.getAttributesString
train
public function getAttributesString(array $attributes = array()) { $attributesString = ''; foreach ($attributes as $name => $values) { $value = is_array($values) ? implode(' ', $values) : $values; $attributesString .= ' '.$name.'="'.$value.'"'; } return $att...
php
{ "resource": "" }
q239643
SQLAdapterMySQL.update
train
public function update(array $options=array()) { $options += self::$updateDefaults; if( empty($options['table']) ) { throw new Exception('Empty table option'); } if( empty($options['what']) ) { throw new Exception('No field'); } $OPTIONS = ''; $OPTIONS .= (!empty($options['lowpriority'])) ? ' LOW_PR...
php
{ "resource": "" }
q239644
SQLAdapterMySQL.insert
train
public function insert(array $options=array()) { $options += self::$insertDefaults; if( empty($options['table']) ) { throw new Exception('Empty table option'); } if( empty($options['what']) ) { throw new Exception('No field'); } $OPTIONS = ''; $OPTIONS .= (!empty($options['lowpriority'])) ? ' LOW_PR...
php
{ "resource": "" }
q239645
SQLAdapterMySQL.delete
train
public function delete(array $options=array()) { $options += self::$deleteDefaults; if( empty($options['table']) ) { throw new Exception('Empty table option'); } $OPTIONS = ''; $OPTIONS .= (!empty($options['lowpriority'])) ? ' LOW_PRIORITY' : ''; $OPTIONS .= (!empty($options['quick'])) ? ' QUICK' : ''; ...
php
{ "resource": "" }
q239646
Posix.getDimensionsFromTput
train
protected function getDimensionsFromTput() : ?array { if (empty($output = $this->execute('tput cols && tput lines'))) { return null; } // tput will have returned the values on separate lines, so let's just explode. $output = explode("\n", $output); return [ ...
php
{ "resource": "" }
q239647
UserSessionService.recover_session
train
function recover_session($token=''){ //$r = Env::getRequest(); $key = Env::getConfig("jwt")->get('key'); $expiration = Env::getConfig("jwt")->get('token_expiration'); $cookie_key= Env::getConfig("jwt")->get('cookie_key'); if(empty($key) || empty($expiration) || empty($cookie_key)){ throw new Exception(...
php
{ "resource": "" }
q239648
UserSessionService.create_session
train
function create_session($data){ $key = Env::getConfig("jwt")->get('key'); $expiration = Env::getConfig("jwt")->get('token_expiration'); $cookie_key= Env::getConfig("jwt")->get('cookie_key'); $token = array( "iss" => $_SERVER['HTTP_HOST'], "iat" => time(), "nbf" => time(), "exp" => time()+($ex...
php
{ "resource": "" }
q239649
UserSessionService.destroy
train
function destroy(){ $cookie_key= Env::getConfig("jwt")->get('cookie_key'); setcookie($cookie_key,'',time()-10000,'/'); unset($_SESSION[$cookie_key]); session_destroy(); }
php
{ "resource": "" }
q239650
MailMessage.getHtmlMail
train
public static function getHtmlMail($mailView, $params, $to, $from, $subject) { if (file_exists($mailView)) { ob_start(); require_once $mailView; $body = ob_get_contents(); ob_end_clean(); } else { throw new MailViewException($mailView); ...
php
{ "resource": "" }
q239651
MailMessage.getPlainMail
train
public static function getPlainMail($to, $from, $body, $subject) { $mail = new MailMessage($to, $from, $body, $subject); return $mail; }
php
{ "resource": "" }
q239652
Reconstitution.reconstituteFrom
train
public static function reconstituteFrom(CommittedEvents $history) { $instance = static::fromIdentity($history->getIdentity()); $instance->whenAll($history); return $instance; }
php
{ "resource": "" }
q239653
ContainerHasCapableTrait._containerHas
train
protected function _containerHas($container, $key) { $key = $this->_normalizeKey($key); if ($container instanceof BaseContainerInterface) { return $container->has($key); } if ($container instanceof ArrayAccess) { // Catching exceptions thrown by `offsetExist...
php
{ "resource": "" }
q239654
ConfigurationValue.parse
train
public function parse() { $value = $this->getRawValue(); $matches = []; if (is_array($value)) { return $value; } if (preg_match(self::NESTED_CONFIGURATION_REGEX, $value, $matches) === 1) { return $this->parseNestedValue($value, $matches); } else { return $this->parser->parseIn...
php
{ "resource": "" }
q239655
KalmanFilter.value
train
function value($value, $u = 0) { if (null === $this->x) { $this->x = (1 / $this->measurementVector) * $value; $this->cov = (1 / $this->measurementVector) * $this->measurementNoise * (1 / $this->measurementVector); } else { // Compute prediction $predX ...
php
{ "resource": "" }
q239656
FinderTrait.findBy
train
public function findBy(array $wheres, array $options = []) { $query = $this->getSqlObject()->select(); $this->setColumns($query, $options); $wheres = $this->addJoins($query, $wheres, $options); $this->addWheres($query, $wheres, $options); if (Arr::get($options, 'order')) ...
php
{ "resource": "" }
q239657
FinderTrait.findAllBy
train
public function findAllBy(array $wheres, array $options = []) { $query = $this->getSqlObject()->select(); $this->setColumns($query, $options); $wheres = $this->addJoins($query, $wheres, $options); $this->addWheres($query, $wheres, $options); $page = Arr::get($options, 'pa...
php
{ "resource": "" }
q239658
FinderTrait.setOrder
train
protected function setOrder(Select $query, array $order) { // Normalize to [['column', 'direction']] format if only one column if (! is_array(Arr::get($order, 0))) { $order = [$order]; } foreach ($order as $key => $orderValue) { if (is_array($orderValue)) { ...
php
{ "resource": "" }
q239659
FinderTrait.getPaginationData
train
protected function getPaginationData(Select $query, array $options) { // Get pagination options $page = (int) Arr::get($options, 'page'); if ($page < 1) { $page = 1; } $resultsPerPage = Arr::get( $options, 'resultsPerPage', $t...
php
{ "resource": "" }
q239660
FinderTrait.getQueryResultCount
train
protected function getQueryResultCount(Select $query) { $queryString = $this->getSqlObject()->getSqlStringForSqlObject($query, $this->dbAdapter->getPlatform()); $format = 'Select count(*) as `count` from (%s) as `query_count`'; $countQueryString = sprintf($format, $queryString); $...
php
{ "resource": "" }
q239661
FinderTrait.addWheres
train
protected function addWheres(PreparableSqlInterface $query, array $wheres, array $options = []) { foreach ($wheres as $key => $where) { if (is_array($where) && count($where) === 3) { $leftOpRightSyntax = true; $operator = $where[1]; switch ($oper...
php
{ "resource": "" }
q239662
ValidatorAwareTrait._setValidator
train
protected function _setValidator($validator) { if (!is_null($validator) && !($validator instanceof ValidatorInterface)) { throw $this->_createInvalidArgumentException($this->__('Invalid validator'), null, null, $validator); } $this->validator = $validator; }
php
{ "resource": "" }
q239663
PathRoute.getMatchedParameters
train
protected function getMatchedParameters(array $matches): array { $parameters = []; foreach ($matches as $key => $match) { if (is_string($key)) { $parameters[$key] = $match[0]; } } return array_replace_recursive($this->getParameters(), $paramet...
php
{ "resource": "" }
q239664
PathRoute.getPattern
train
protected function getPattern(): string { $path = preg_replace_callback('~:([a-z][a-z0-9\_]+)~i', function ($match) { return sprintf('(?<%s>%s)', $match[1], '[^\/]*'); }, $this->getPath()); return sprintf('~\G(%s)(/|\z)~', $path); }
php
{ "resource": "" }
q239665
SubscribeToList.prepareEmailDataForInsert
train
public function prepareEmailDataForInsert($request) { $data = []; $data['email_type_id'] = 1; // Primary $data['title'] = $request->input('email'); $data['description'] = ""; $data['comments'] = "Created by front-end subscription to an email list"; $data...
php
{ "resource": "" }
q239666
SubscribeToList.prepareList_emailDataForInsert
train
public function prepareList_emailDataForInsert($input) { $data = []; $data['title'] = $input['listID']." ".$input['emailID']; $data['list_id'] = $input['listID']; $data['email_id'] = $input['emailID']; $data['comments'] = ""; $data['enabled'] ...
php
{ "resource": "" }
q239667
SubscribeToList.preparePeoplesDataForInsert
train
public function preparePeoplesDataForInsert($input) { $data = []; $data['user_id'] = null; // Set users up as PEOPLES in the admin $data['title'] = $input['first_name']." ".$input['surname']; $data['salutation'] = ""; $data['first_name'] = $input['first_nam...
php
{ "resource": "" }
q239668
ImportExportController.getValidReturnUri
train
protected function getValidReturnUri( $returnUri, $default = null ) { $match = array(); $returnUri = ltrim( str_replace( '\\', '/', $returnUri ), "\n\r\t\v\e\f" ); if ( ! preg_match( '#^/([^/].*)?$#', $returnUri, $match ) ) { return $default; } ret...
php
{ "resource": "" }
q239669
ImportExportController.exportAction
train
public function exportAction() { $params = $this->params(); $paragraphId = $params->fromRoute( 'paragraphId' ); $serviceLocator = $this->getServiceLocator(); $paragraphModel = $serviceLocator->get( 'Grid\Paragraph\Model\Paragraph\Model' ); $paragraph = $paragr...
php
{ "resource": "" }
q239670
ExternalMemberAuthenticator.authenticateExternalMember
train
protected function authenticateExternalMember($data, ValidationResult &$result = null, Member $member = null) { $result = $result ?: ValidationResult::create(); $ssLoginUserName = Environment::getEnv('SS_DEFAULT_ADMIN_USERNAME'); $email = !empty($data['Email']) ? $data['Email'] : null; ...
php
{ "resource": "" }
q239671
JobRestoreManager.saveReport
train
private function saveReport(JobConfigurationInterface $configuration) { $report = $this->reportManager->create($configuration); $report ->setEndedAt() ->setOutput('Job was dead and restored.') ->setSuccessful(true); $this->reportManager->add($report, true...
php
{ "resource": "" }
q239672
JobRestoreManager.isDead
train
private function isDead(JobConfigurationInterface $configuration) { $report = $this->reportManager->getLastStartedByConfiguration($configuration); return $report && $report->getPid() && (false === $report->isSuccessful()) && !posix_getsid($report->getPid()); }
php
{ "resource": "" }
q239673
ResourceConstantsClassGenerator.WriteContent
train
public function WriteContent() { $output = $this->WriteGetListMethod(); $output .= PhpCodeSnippets::CRLF; fwrite($this->writer, $output); }
php
{ "resource": "" }
q239674
ResourceConstantsClassGenerator.WriteNewArrayAndItsContents
train
public function WriteNewArrayAndItsContents($array, $arrayOpened = false, $tabAmount = 0) { $output = ""; foreach ($array as $key => $value) { if (is_array($value)) { $output .= $this->WriteAssociativeArrayValueAsNewArray($key, $tabAmount); //new array opened ...
php
{ "resource": "" }
q239675
MattermostChatController.ackAction
train
public function ackAction() { $json = array(); $postId = $this->params()->fromQuery('postid', null); $response = $this->mattermost->saveReaction($postId, 'ok'); $json['result'] = $response; return new JsonModel($json); }
php
{ "resource": "" }
q239676
MattermostChatController.isAckAction
train
public function isAckAction() { $json = array(); $postId = $this->params()->fromQuery('postid', null); $myReactions = $this->mattermost->getMyReactions($postId); $ok = array_filter($myReactions, function($v){ return strcmp($v['emoji_name'], 'ok') == 0; }); ...
php
{ "resource": "" }
q239677
EbreEscoolMigrator.migrate
train
public function migrate(array $filters) { $this->filters =$filters; foreach ($this->academicPeriods() as $period) { $this->period = $period->id; $this->setDestinationConnectionByPeriod($this->period); $this->switchToDestinationConnection(); $this->outp...
php
{ "resource": "" }
q239678
EbreEscoolMigrator.migrateTeachers
train
protected function migrateTeachers() { $this->output->info('### Migrating teachers ###'); foreach ($this->teachers() as $teacher) { $this->showMigratingInfo($teacher, 1); $this->output->info(' email: ' . $teacher->email); $this->migrateTeacher($teacher); ...
php
{ "resource": "" }
q239679
EbreEscoolMigrator.migrateTeacher
train
protected function migrateTeacher(Teacher $teacher) { $user = User::firstOrNew([ 'email' => $teacher->email, ]); $user->name = $teacher->name; $user->password = bcrypt('secret'); $user->remember_token = str_random(10); $user->save(); //TODO: migrate te...
php
{ "resource": "" }
q239680
EbreEscoolMigrator.migrateEnrollment
train
protected function migrateEnrollment($enrollment) { $user = $this->migratePerson($enrollment->person); try { $enrollment = ScoolEnrollment::firstOrNew([ 'user_id' => $user->id, 'study_id' => $this->translateStudyId($enrollment->study_id), ...
php
{ "resource": "" }
q239681
EbreEscoolMigrator.migrateLesson
train
protected function migrateLesson($oldLesson) { if ($this->lessonNotExists($oldLesson)) { DB::beginTransaction(); try { $lesson = new ScoolLesson; $lesson->location_id = $this->translateLocationId($oldLesson->location_id); ...
php
{ "resource": "" }
q239682
EbreEscoolMigrator.migrateEnrollmentDetail
train
protected function migrateEnrollmentDetail($enrollmentDetail,$enrollment_id) { try { $enrollment = ScoolEnrollmentSubmodule::firstOrNew([ 'enrollment_id' => $enrollment_id, 'module_id' => $this->translateModuleId($enrollmentDetail->moduleid), '...
php
{ "resource": "" }
q239683
EbreEscoolMigrator.translateLocationId
train
protected function translateLocationId($oldLocationId) { $location = ScoolLocation::where('name',Location::findOrFail($oldLocationId)->name)->first(); if ( $location != null ) { return $location->id; } throw new LocationNotFoundByNameException(); }
php
{ "resource": "" }
q239684
EbreEscoolMigrator.translateTimeslotId
train
protected function translateTimeslotId($oldTimeslotId) { $timeslot = ScoolTimeslot::where('order',Timeslot::findOrFail($oldTimeslotId)->order)->first(); if ( $timeslot != null ) { return $timeslot->id; } throw new TimeslotNotFoundByNameException(); }
php
{ "resource": "" }
q239685
EbreEscoolMigrator.translateModuleId
train
protected function translateModuleId($oldModuleId) { $module = Module::where('name',StudyModule::findOrFail($oldModuleId)->name)->first(); if ( $module != null ) { return $module->id; } throw new ModuleNotFoundByNameException(); }
php
{ "resource": "" }
q239686
EbreEscoolMigrator.translateSubmoduleId
train
protected function translateSubmoduleId($oldSubModuleId) { $submodule = Submodule::where('name',StudySubModule::findOrFail($oldSubModuleId)->name)->first(); if ( $submodule != null ) { return $submodule->id; } throw new SubmoduleNotFoundByNameException(); }
php
{ "resource": "" }
q239687
EbreEscoolMigrator.translateStudyId
train
protected function translateStudyId($oldStudyId) { $study = ScoolStudy::where('name',Study::findOrFail($oldStudyId)->name)->first(); if ( $study != null ) { return $study->id; } throw new StudyNotFoundByNameException(); }
php
{ "resource": "" }
q239688
EbreEscoolMigrator.translateCourseId
train
protected function translateCourseId($oldCourseId) { $course = ScoolCourse::where('name',Course::findOrFail($oldCourseId)->name)->first(); if ( $course != null ) { return $course->id; } throw new CourseNotFoundByNameException(); }
php
{ "resource": "" }
q239689
EbreEscoolMigrator.translateClassroomId
train
protected function translateClassroomId($oldClassroomId) { $classroom = Classroom::where('name',ClassroomGroup::findOrFail($oldClassroomId)->name)->first(); if ( $classroom != null ) { return $classroom->id; } throw new ClassroomNotFoundByNameException(); }
php
{ "resource": "" }
q239690
EbreEscoolMigrator.migratePerson
train
protected function migratePerson($person) { //TODO create person in personal data table $user = User::firstOrNew([ 'email' => $person->email, ]); $user->name = $person->name; $user->password = bcrypt('secret'); $user->remember_token = str_random(10); ...
php
{ "resource": "" }
q239691
EbreEscoolMigrator.migrateClassrooms
train
protected function migrateClassrooms() { $this->output->info('### Migrating classrooms ###'); foreach ($classrooms = $this->classrooms() as $classroom) { $this->showMigratingInfo($classroom, 1); $this->migrateClassroom($classroom); } $this->output->info( ...
php
{ "resource": "" }
q239692
EbreEscoolMigrator.migrateLocations
train
protected function migrateLocations() { $this->output->info('### Migrating locations ###'); foreach ($this->locations() as $location) { $this->showMigratingInfo($location, 1); $this->migrateLocation($location); } $this->output->info( '### END Migra...
php
{ "resource": "" }
q239693
EbreEscoolMigrator.migrateLocation
train
protected function migrateLocation($srcLocation) { $location = ScoolLocation::firstOrNew([ 'name' => $srcLocation->name, ]); $location->save(); $location->shortname = $srcLocation->shortName; $location->description = $srcLocation->description; $location->code ...
php
{ "resource": "" }
q239694
EbreEscoolMigrator.migrateClassroom
train
protected function migrateClassroom($srcClassroom) { $classroom = Classroom::firstOrNew([ 'name' => $srcClassroom->name, ]); $classroom->save(); $this->addCourseToClassroom($classroom, $srcClassroom->course_id); $classroom->shortname = $srcClassroom->shortName; ...
php
{ "resource": "" }
q239695
EbreEscoolMigrator.migrateCurriculum
train
private function migrateCurriculum() { foreach ($this->departments() as $department) { $this->setDepartment($department); $this->showMigratingInfo($department,1); $this->migrateDepartment($department); foreach ($this->studies($department) as $study) { ...
php
{ "resource": "" }
q239696
EbreEscoolMigrator.migrateEnrollments
train
private function migrateEnrollments() { $this->output->info('### Migrating enrollments ###'); foreach ($this->enrollments() as $enrollment) { if ($enrollment->person == null ) { $this->output->error('Skipping enrolmment because no personal data'); continue...
php
{ "resource": "" }
q239697
EbreEscoolMigrator.seedDays
train
protected function seedDays() { $this->output->info('### Seeding days###'); //%u ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday) $timestamp = strtotime('next Monday'); $days = array(); for ($i = 1; $i < 8; $i++) { $days...
php
{ "resource": "" }
q239698
EbreEscoolMigrator.migrateTimeslots
train
protected function migrateTimeslots() { $this->output->info('### Migrating timeslots ###'); foreach ($this->timeslots() as $timeslot) { $timeslot->showMigratingInfo($this->output,1); $this->migrateTimeslot($timeslot); } $this->output->info('### END OF Migratin...
php
{ "resource": "" }
q239699
EbreEscoolMigrator.migrateLessons
train
protected function migrateLessons() { $this->output->info('### Migrating lessons ###'); if ($this->checkLessonsMigrationState()) { foreach ($this->lessons() as $lesson) { $lesson->showMigratingInfo($this->output,1); $this->migrateLesson($lesson); ...
php
{ "resource": "" }