_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q1000
Formatter.onAfterExercise
train
public function onAfterExercise(TestworkEvent\AfterExerciseCompleted $event) { $this->timer->stop(); $this->renderer->render(); $this->printer->write($this->renderer->getResult()); }
php
{ "resource": "" }
q1001
JqlEndpoint.search
train
public function search($jql, $startAt = null, $maxResults = null, $validateQuery = null, $fields = null, $expand = null) { $parameters = array( 'jql' => $jql, 'startAt' => $startAt, 'maxResults' => $maxResults, 'validateQuery' => $validateQuery, 'fields' => $fields, 'expand' => $expand ); return $this->apiClient->callEndpoint('search', $parameters); }
php
{ "resource": "" }
q1002
Step.getProcessedResult
train
public function getProcessedResult() { $status = StepResult::SKIPPED; if (!empty(static::$resultLabels[$this->getResultCode()])) { $status = static::$resultLabels[$this->getResultCode()]; } return [ 'status' => $status, 'error_message' => $this->getException(), 'duration' => $this->getDuration() * 1000 * 1000000, ]; }
php
{ "resource": "" }
q1003
ConfigurationFetcherRegistry.getFetcher
train
public function getFetcher($alias) { if (!is_string($alias)) { throw new UnexpectedTypeException($alias, 'string'); } if (!isset($this->fetchers[$alias])) { throw new \InvalidArgumentException(sprintf('Could not load configuration fetcher "%s"', $alias)); } return $this->fetchers[$alias]; }
php
{ "resource": "" }
q1004
Date.seeDateIsInDays
train
public function seeDateIsInDays($date, $days) { \PHPUnit_Framework_Assert::assertEquals($days, $this->_GetNow()->diffInDays($this->_ParseDate($date), false)); }
php
{ "resource": "" }
q1005
Date.dontSeeDateIsInDays
train
public function dontSeeDateIsInDays($date, $days) { \PHPUnit_Framework_Assert::assertNotEquals($days, $this->_GetNow()->diffInDays($this->_ParseDate($date), false)); }
php
{ "resource": "" }
q1006
Date.seeDateIsInMonths
train
public function seeDateIsInMonths($date, $months) { \PHPUnit_Framework_Assert::assertEquals($months, $this->_GetNow()->diffInMonths($this->_ParseDate($date), false)); }
php
{ "resource": "" }
q1007
Date.dontSeeDateIsInMonths
train
public function dontSeeDateIsInMonths($date, $months) { \PHPUnit_Framework_Assert::assertNotEquals($months, $this->_GetNow()->diffInMonths($this->_ParseDate($date), false)); }
php
{ "resource": "" }
q1008
Date.seeDateIsInYears
train
public function seeDateIsInYears($date, $years) { \PHPUnit_Framework_Assert::assertEquals($years, $this->_GetNow()->diffInYears($this->_ParseDate($date), false)); }
php
{ "resource": "" }
q1009
Date.dontSeeDateIsInYears
train
public function dontSeeDateIsInYears($date, $years) { \PHPUnit_Framework_Assert::assertNotEquals($years, $this->_GetNow()->diffInYears($this->_ParseDate($date), false)); }
php
{ "resource": "" }
q1010
Date.seeDateIsMonday
train
public function seeDateIsMonday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::MONDAY); }
php
{ "resource": "" }
q1011
Date.dontSeeDateIsMonday
train
public function dontSeeDateIsMonday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::MONDAY); }
php
{ "resource": "" }
q1012
Date.seeDateIsTuesday
train
public function seeDateIsTuesday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::TUESDAY); }
php
{ "resource": "" }
q1013
Date.dontSeeDateIsTuesday
train
public function dontSeeDateIsTuesday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::TUESDAY); }
php
{ "resource": "" }
q1014
Date.seeDateIsWednesday
train
public function seeDateIsWednesday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::WEDNESDAY); }
php
{ "resource": "" }
q1015
Date.dontSeeDateIsWednesday
train
public function dontSeeDateIsWednesday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::WEDNESDAY); }
php
{ "resource": "" }
q1016
Date.seeDateIsThursday
train
public function seeDateIsThursday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::THURSDAY); }
php
{ "resource": "" }
q1017
Date.dontSeeDateIsThursday
train
public function dontSeeDateIsThursday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::THURSDAY); }
php
{ "resource": "" }
q1018
Date.seeDateIsFriday
train
public function seeDateIsFriday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::FRIDAY); }
php
{ "resource": "" }
q1019
Date.dontSeeDateIsFriday
train
public function dontSeeDateIsFriday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::FRIDAY); }
php
{ "resource": "" }
q1020
Date.seeDateIsSaturday
train
public function seeDateIsSaturday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::SATURDAY); }
php
{ "resource": "" }
q1021
Date.dontSeeDateIsSaturday
train
public function dontSeeDateIsSaturday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::SATURDAY); }
php
{ "resource": "" }
q1022
Date.seeDateIsSunday
train
public function seeDateIsSunday($date) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::SUNDAY); }
php
{ "resource": "" }
q1023
Date.dontSeeDateIsSunday
train
public function dontSeeDateIsSunday($date) { \PHPUnit_Framework_Assert::assertFalse($this->_ParseDate($date)->dayOfWeek == Carbon::SUNDAY); }
php
{ "resource": "" }
q1024
Date.seeDateMatches
train
public function seeDateMatches($d1, $d2) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($d1)->eq($this->_ParseDate($d2))); }
php
{ "resource": "" }
q1025
Date.dontSeeDateMatches
train
public function dontSeeDateMatches($d1, $d2) { \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($d1)->ne($this->_ParseDate($d2))); }
php
{ "resource": "" }
q1026
Date.seeDateInQuarter
train
public function seeDateInQuarter($date, $quarter) { \PHPUnit_Framework_Assert::assertEquals($quarter, $this->_ParseDate($date)->quarter); }
php
{ "resource": "" }
q1027
Date.dontSeeDateInQuarter
train
public function dontSeeDateInQuarter($date, $quarter) { \PHPUnit_Framework_Assert::assertNotEquals($quarter, $this->_ParseDate($date)->quarter); }
php
{ "resource": "" }
q1028
Date.seeDayInWeek
train
public function seeDayInWeek($date, $day) { \PHPUnit_Framework_Assert::assertEquals($day, $this->_ParseDate($date)->dayOfWeek); }
php
{ "resource": "" }
q1029
Date.dontSeeDayInWeek
train
public function dontSeeDayInWeek($date, $day) { \PHPUnit_Framework_Assert::assertNotEquals($day, $this->_ParseDate($date)->dayOfWeek); }
php
{ "resource": "" }
q1030
Date.seeDayInMonth
train
public function seeDayInMonth($date, $day) { \PHPUnit_Framework_Assert::assertEquals($day, $this->_ParseDate($date)->day); }
php
{ "resource": "" }
q1031
Date.dontSeeDayInMonth
train
public function dontSeeDayInMonth($date, $day) { \PHPUnit_Framework_Assert::assertNotEquals($day, $this->_ParseDate($date)->day); }
php
{ "resource": "" }
q1032
Date.seeDayInYear
train
public function seeDayInYear($date, $day) { \PHPUnit_Framework_Assert::assertEquals($day, $this->_ParseDate($date)->dayOfYear); }
php
{ "resource": "" }
q1033
Date.dontSeeDayInYear
train
public function dontSeeDayInYear($date, $day) { \PHPUnit_Framework_Assert::assertNotEquals($day, $this->_ParseDate($date)->dayOfYear); }
php
{ "resource": "" }
q1034
Date.seeWeekInYear
train
public function seeWeekInYear($date, $week) { \PHPUnit_Framework_Assert::assertEquals($week, $this->_ParseDate($date)->weekOfYear); }
php
{ "resource": "" }
q1035
Date.dontSeeWeekInYear
train
public function dontSeeWeekInYear($date, $week) { \PHPUnit_Framework_Assert::assertNotEquals($week, $this->_ParseDate($date)->weekOfYear); }
php
{ "resource": "" }
q1036
Date.seeMonthInYear
train
public function seeMonthInYear($date, $month) { \PHPUnit_Framework_Assert::assertEquals($month, $this->_ParseDate($date)->month); }
php
{ "resource": "" }
q1037
Date.dontSeeMonthInYear
train
public function dontSeeMonthInYear($date, $month) { \PHPUnit_Framework_Assert::assertNotEquals($month, $this->_ParseDate($date)->month); }
php
{ "resource": "" }
q1038
Comment.getSubject
train
public function getSubject() { if (!$this->isNewRecord && $this->subject === null) { $this->subject = call_user_func([$this->model_class, 'findOne'], $this->foreign_pk); if ($this->subject === null) { $msg = Yii::t('app', 'Could not find model for attachment `{attachment}`', [ 'attachment'=>$this->id ]); throw new ErrorException($msg); } } return $this->subject; }
php
{ "resource": "" }
q1039
Comment.setSubject
train
public function setSubject($subject) { self::validateSubject($subject, true); $this->model_class = $subject->className(); $this->foreign_pk = $subject->getPrimaryKey(true); $this->subject = $subject; }
php
{ "resource": "" }
q1040
Comment.validateSubject
train
public static function validateSubject($subject, $throwException = true) { if (!ComponentConfig::isActiveRecord($subject, $throwException)) return false; if (!ComponentConfig::hasBehavior($subject, CommentsBehavior::className(), $throwException)) return false; if (empty($subject->primaryKey) || (is_array($subject->primaryKey) && count($subject->primaryKey) === 0)) { if (!$throwException) return false; $msg = Yii::t('app', 'The model needs a valid primary key'); throw new InvalidParamException($msg); } if ($subject->isNewRecord) { if (!$throwException) return false; $msg = Yii::t('app', 'Commenting is not possible on unsaved models'); throw new InvalidParamException($msg); } return true; }
php
{ "resource": "" }
q1041
TemplateMigration.update
train
public function update() { $t = new Template; $t->name = $this->getTemplateName(); $fg = new Fieldgroup; $fg->name = $this->getTemplateName(); foreach($this->fields as $field) { // add global fields if(!($field->flags & Field::flagGlobal)) continue; $fg->add($field); } $fg->save(); $t->fieldgroup = $fg; $t->fieldgroup->save(); $t->save(); $this->templateSetup($t); $t->fieldgroup->save(); $t->save(); return $t; }
php
{ "resource": "" }
q1042
TemplateMigration.downgrade
train
public function downgrade() { $template = $this->getTemplate($this->getTemplateName()); $fieldgroup = $template->fieldgroup; $fg = $this->wire('fieldgroups')->get($template->name); $minNumberToError = $fg->id == $fieldgroup->id ? 2 : 1; if($fg->numTemplates() >= $minNumberToError) throw new WireException("Cannot delete $template->name, because it's fieldgroup is used by at least one other template."); // Remove all pages of that template $selector = "template=$template, include=all, check_access=0"; $this->eachPageUncache($selector, function($p) { $this->pages->delete($p, true); }); // Delete fieldgroup and template $this->templates->delete($template); $this->fieldgroups->delete($fieldgroup); }
php
{ "resource": "" }
q1043
ProductHolder.loadDescendantProductGroupIDListInto
train
public function loadDescendantProductGroupIDListInto(&$idList) { if ($children = $this->AllChildren()) { foreach ($children as $child) { if (in_array($child->ID, $idList)) { continue; } if ($child instanceof self) { $idList[] = $child->ID; $child->loadDescendantProductGroupIDListInto($idList); } } } }
php
{ "resource": "" }
q1044
Customers.modify
train
public function modify( $customerId, $username, $name, $company, $address, $city, $state, $country, $zipCode, $phoneCC, $phone, $lang ) { return $this->post( 'modify', [ 'customer-id' => $customerId, 'username' => $username, 'name' => $name, 'company' => $company, 'address-line-1' => $address, 'city' => $city, 'state' => $state, 'country' => $country, 'zipcode' => $zipCode, 'phone-cc' => $phoneCC, 'phone' => $phone, 'lang-pref' => $lang, ] ); }
php
{ "resource": "" }
q1045
Customers.signup
train
public function signup( $username, $passwd, $name, $company, $address, $city, $state, $country, $zipCode, $phoneCC, $phone, $lang ) { return $this->post( 'signup', [ 'username' => $username, 'passwd' => $passwd, 'name' => $name, 'company' => $company, 'address-line-1' => $address, 'city' => $city, 'state' => $state, 'country' => $country, 'zipcode' => $zipCode, 'phone-cc' => $phoneCC, 'phone' => $phone, 'lang-pref' => $lang, ] ); }
php
{ "resource": "" }
q1046
Captcha.setConfig
train
public function setConfig($config_location = NULL) { static $CAPTCHA_CONFIG = array(); $path = ( NULL === $config_location ) ? __DIR__ . DIRECTORY_SEPARATOR . 'captcha_config.php' : realpath($config_location); if ( false === $path ) { throw new CaptchaException( sprintf("Config File not found in: %s ", $config_location) ); } if ( $path ) { include_once $path; foreach (get_class_vars(get_class($this)) as $key => $value) { $config = preg_replace('/^[\_A-Z]/', '\\1', $key); if ( array_key_exists($config, $CAPTCHA_CONFIG) ) { $this->$key = $CAPTCHA_CONFIG[$config]; } } } }
php
{ "resource": "" }
q1047
Captcha.displayHTML
train
public function displayHTML($theme_name = NULL, $options = array()) { if ( strlen($this->_publicKey == 0) ) { throw new CaptchaException('To use reCAPTCHA you must get a Public API key from https://www.google.com/recaptcha/admin'); } // append a Theme $captcha_snippet = $this->_theme($theme_name, $options); $captcha_snippet .= '<script type="text/javascript" src="'. $this->_buildServerURI() . '"></script> <noscript> <iframe src="' . $this->_buildServerURI('noscript') . '" height="300" width="500" frameborder="0"></iframe><br> <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"> </noscript>'; return $captcha_snippet; }
php
{ "resource": "" }
q1048
Captcha.isValid
train
public function isValid() { // Skip without submission if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST') { return FALSE; } else { $captchaChallenge = isset($_POST['recaptcha_challenge_field']) ? $this->_sanitizeField($_POST['recaptcha_challenge_field']) : NULL; $captchaResponse = isset($_POST['recaptcha_response_field']) ? $this->_sanitizeField($_POST['recaptcha_response_field']) : NULL; // Skip empty submission if ( strlen($captchaChallenge) == 0 || strlen($captchaResponse) == 0 ) { $this->setError('incorrect-captcha-sol'); return FALSE; } $data = array( 'privatekey' => $this->_privateKey, 'remoteip' => $this->_remoteIp(), 'challenge' => $captchaChallenge, 'response' => $captchaResponse ); $result = $this->_postHttpChallenge($data); if ( $result['isvalid'] === "true") { return TRUE; } else { $this->setError($result['error']); } return FALSE; } }
php
{ "resource": "" }
q1049
Captcha._postHttpChallenge
train
protected function _postHttpChallenge(array $data) { if ( strlen($this->_privateKey) == 0 ) { throw new CaptchaException( 'To use reCAPTCHA you must get a Private API key from https://www.google.com/recaptcha/admin' ); } $responseHeader = ''; $result = array('isvalid'=>'false', 'error'=>''); $remote_url = parse_url(self::RECAPTCHA_VERIFY_SERVER); $httpQuery = http_build_query($data); $requestHeader = sprintf( self::RECAPTCHA_HEADER, $remote_url['path'], $remote_url['host'], strlen($httpQuery), $httpQuery); if ( function_exists('fsockopen') ) { $handler = @fsockopen($remote_url['host'], 80, $errno, $errstr, $this->timeout); if( false == ( $handler ) ) { throw new CaptchaException( sprintf('Could not open sock to check reCAPTCHA at %s.', self::RECAPTCHA_VERIFY_SERVER) ); } stream_set_timeout($handler, $this->timeout); fwrite($handler, $requestHeader); $remote_response = stream_get_line($handler, 32, "\n"); if (strpos($remote_response, '200 OK') !== false) { while (!feof($handler)) { $responseHeader .= stream_get_line($handler, 356); } fclose($handler); $responseHeader = str_replace("\r\n", "\n", $responseHeader); $responseHeader = explode("\n\n", $responseHeader); array_shift($responseHeader); $responseHeader = explode("\n", implode("\n\n", $responseHeader)); } // Fallback to CURL if fsockopen is not enabled } elseif ( extension_loaded('curl') ) { $ch = curl_init(self::RECAPTCHA_VERIFY_SERVER); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout); curl_setopt($ch, CURLOPT_USERAGENT, 'reCAPTCHA/PHP'); curl_setopt($ch, CURLOPT_HTTPHEADER, explode("\r\n", $requestHeader) ); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $httpQuery); $responseHeader = curl_exec($ch); curl_close($ch); if ($responseHeader !== false) { $responseHeader = explode("\n\n", $responseHeader); $responseHeader = explode("\n", implode("\n\n", $responseHeader)); } } else { throw new CaptchaException( sprintf('Can\'t connect to the server %s. Try again.', self::RECAPTCHA_VERIFY_SERVER ) ); } $result = ( count($responseHeader) == 2 ) ? array_combine(array_keys($result), $responseHeader) : $result; return $result; }
php
{ "resource": "" }
q1050
Captcha._buildServerURI
train
private function _buildServerURI($path = 'challenge') { // Scheme $uri = ( TRUE === $this->_ssl ) ? 'https://' : 'http://'; // Host $uri .= self::RECAPTCHA_API_SERVER; // Path $uri .= ($path !== 'challenge') ? 'noscript' : $path; // Query $uri .= '?k=' . $this->_publicKey; $uri .= ($this->_error) ? '&error=' . $this->_error : NULL; $uri .= ( isset($this->_recaptchaOptions['lang']) ) ? '&hl=' . $this->_recaptchaOptions['lang'] : '&hl=' .$this->clientLang(); return $uri; }
php
{ "resource": "" }
q1051
RSSParser.getNodes
train
public function getNodes($content) { $items = array(); $document = $this->createDocumentFromXML($content); $nodes = $document->getElementsByTagName('item'); if ($nodes->length) { foreach ($nodes as $node) { try { $item = $this->create($node); $items[] = $item; } catch (\Exception $e) { throw new RuntimeException($e->getMessage()); } } } return $items; }
php
{ "resource": "" }
q1052
Relations._defineRelationships
train
protected static function _defineRelationships() { $className = get_called_class(); $classes = class_parents($className); array_unshift($classes, $className); static::$_classRelationships[$className] = []; while ($class = array_pop($classes)) { if (!empty($class::$relationships)) { static::$_classRelationships[$className] = array_merge(static::$_classRelationships[$className], $class::$relationships); } if (static::isVersioned() && !empty($class::$versioningRelationships)) { static::$_classRelationships[$className] = array_merge(static::$_classRelationships[$className], $class::$versioningRelationships); } } }
php
{ "resource": "" }
q1053
Relations._initRelationships
train
protected static function _initRelationships() { $className = get_called_class(); if (!empty(static::$_classRelationships[$className])) { $relationships = []; foreach (static::$_classRelationships[$className] as $relationship => $options) { if (is_array($options)) { $relationships[$relationship] = static::_initRelationship($relationship, $options); } } static::$_classRelationships[$className] = $relationships; } }
php
{ "resource": "" }
q1054
RecordValidator.resolveValue
train
protected function resolveValue($field) { $cur = &$this->_record; if (array_key_exists($field, $cur)) { $cur = &$cur[$field]; } else { return null; } return $cur; }
php
{ "resource": "" }
q1055
CommentsBehavior.getComments
train
public function getComments($newestFirst=true, $limit=null, $offset=null) { $query = Comment::find()->subject($this->owner); $query->orderNewestFirst($newestFirst); if ($limit !== null) $query->limit($limit); if ($offset !== null) $query->offset($offset); return $query->all(); }
php
{ "resource": "" }
q1056
PatternFileTree.getImageSizeList
train
protected function getImageSizeList() { $arrSizes = \System::getContainer()->get('contao.image.image_sizes')->getAllOptions(); if (is_array($arrList = \StringUtil::deserialize($this->sizeList))) { $arrSizes['image_sizes'] = array_intersect_key($arrSizes['image_sizes'], array_flip($arrList)); } else { $arrSizes['image_sizes'] = array(); } if ($this->canEnterSize) { return $arrSizes; } return $arrSizes['image_sizes']; }
php
{ "resource": "" }
q1057
Migration.eachPageUncache
train
protected function eachPageUncache($selector, callable $callback) { $num = 0; $id = 0; while (true) { $p = $this->pages->get("{$selector}, id>$id"); if(!$id = $p->id) break; $callback($p); $this->pages->uncacheAll($p); $num++; } return $num; }
php
{ "resource": "" }
q1058
Migration.insertIntoTemplate
train
protected function insertIntoTemplate ($template, $field, $reference = null, $after = true) { $template = $this->getTemplate($template); $fieldgroup = $template->fieldgroup; $method = $after ? 'insertAfter' : 'insertBefore'; $field = $this->getField($field); // Get reference if supplied if($reference instanceof Field) $reference = $fieldgroup->get($reference->name); else if(is_string($reference)) $reference = $fieldgroup->get($reference); // Insert field or append if($reference instanceof Field) $fieldgroup->$method($field, $reference); else $fieldgroup->append($field); $fieldgroup->save(); }
php
{ "resource": "" }
q1059
Migration.removeFromTemplate
train
protected function removeFromTemplate($template, $field) { $t = $this->getTemplate($template); $f = $this->getField($field); $success = $t->fieldgroup->remove($f); $t->fieldgroup->save(); return $success; }
php
{ "resource": "" }
q1060
Migration.editInTemplateContext
train
protected function editInTemplateContext ($template, $field, callable $callback) { $template = $this->getTemplate($template); $fieldgroup = $template->fieldgroup; $field = $this->getField($field); $context = $fieldgroup->getField($field->name, true); $callback($context, $template); $this->fields->saveFieldgroupContext($context, $fieldgroup); }
php
{ "resource": "" }
q1061
tl_pattern.setPickerOptions
train
public function setPickerOptions($value, $dc) { $db = Database::getInstance(); switch ($value) { case 'datetime': if (!in_array($dc->activeRecord->rgxp, array('date', 'time', 'datim'))) { // Change rgxp in database $db->prepare("UPDATE " . $this->table . " SET rgxp=? WHERE id=?") ->execute('date', $dc->activeRecord->id); } if ($dc->activeRecord->multiple) { // Reset multiple in database $db->prepare("UPDATE " . $this->table . " SET multiple=? WHERE id=?") ->execute('', $dc->activeRecord->id); } break; case 'color': if (!in_array($dc->activeRecord->rgxp, array('alnum', 'extnd'))) { // Change rgxp in database $db->prepare("UPDATE " . $this->table . " SET rgxp=? WHERE id=?") ->execute('', $dc->activeRecord->id); } break; case 'link': if ($dc->activeRecord->rgxp != 'url') { // Change rgxp in database $db->prepare("UPDATE " . $this->table . " SET rgxp=? WHERE id=?") ->execute('url', $dc->activeRecord->id); } if ($dc->activeRecord->multiple) { // Reset multiple in database $db->prepare("UPDATE " . $this->table . " SET multiple=? WHERE id=?") ->execute('', $dc->activeRecord->id); } break; case 'unit': if ($dc->activeRecord->maxLength > 200) { // Change maxLength in database $db->prepare("UPDATE " . $this->table . " SET maxLength=? WHERE id=?") ->execute(200, $dc->activeRecord->id); } if ($dc->activeRecord->multiple) { // Change multiple in database $db->prepare("UPDATE " . $this->table . " SET multiple=? WHERE id=?") ->execute('', $dc->activeRecord->id); } break; } return $value; }
php
{ "resource": "" }
q1062
tl_pattern.setMultipleOption
train
public function setMultipleOption($value, $dc) { $db = Database::getInstance(); if ($value > 3 && $dc->activeRecord->maxLength > 200) { // change maxLegth in database $db->prepare("UPDATE " . $this->table . " SET maxLength=? WHERE id=?") ->execute(200, $dc->activeRecord->id); } return $value; }
php
{ "resource": "" }
q1063
tl_pattern.setSourceOptions
train
public function setSourceOptions($value, $dc) { $db = Database::getInstance(); if ($value == 'video' || $value == 'audio') { if (!$dc->activeRecord->multiSource) { // Change multiSource in database $db->prepare("UPDATE " . $this->table . " SET multiSource=? WHERE id=?") ->execute(1, $dc->activeRecord->id); } if ($dc->activeRecord->sortBy != 'html5media') { // Change sortBy in database $db->prepare("UPDATE " . $this->table . " SET sortBy=? WHERE id=?") ->execute('html5media', $dc->activeRecord->id); } if ($dc->activeRecord->canChangeSortBy) { // Change canChangeSortBy in database $db->prepare("UPDATE " . $this->table . " SET canChangeSortBy=? WHERE id=?") ->execute(0, $dc->activeRecord->id); } } return $value; }
php
{ "resource": "" }
q1064
tl_pattern.getPattern
train
public function getPattern($dc) { $pattern = array(); foreach ($GLOBALS['TL_CTP'] as $k=>$v) { foreach ($v as $kk=>$vv) { if (!$vv['unique']) { $pattern[$k][] = $kk; } elseif (\PatternModel::countByPidAndType($dc->activeRecord->pid, $kk) < 1 || $dc->activeRecord->type == $kk) { $pattern[$k][] = $kk; } } } return $pattern; }
php
{ "resource": "" }
q1065
tl_pattern.saveGroups
train
public function saveGroups ($dc) { $db = Database::getInstance(); // Change predefined groups if ($dc->activeRecord->type == 'protection' && !$dc->activeRecord->canChangeGroups) { // Serialize array if not $groups = is_array($dc->activeRecord->groups) ? serialize($dc->activeRecord->groups) : $dc->activeRecord->groups; // Save alias to database $db->prepare("UPDATE tl_content SET groups=? WHERE type=(SELECT alias FROM tl_elements WHERE id=?)") ->execute($groups, $dc->activeRecord->pid); } }
php
{ "resource": "" }
q1066
tl_pattern.getForms
train
public function getForms() { $arrForms = array(); $objForms = $this->Database->execute("SELECT id, title FROM tl_form ORDER BY title"); while ($objForms->next()) { $arrForms[$objForms->id] = $objForms->title . ' (ID ' . $objForms->id . ')'; } return $arrForms; }
php
{ "resource": "" }
q1067
Theme.exportTables
train
public function exportTables ($xml, $objArchive, $objThemeId) { // Find tables node $tables = $xml->getElementsByTagName('tables')[0]; // Add the table (elements) $table = $xml->createElement('table'); $table->setAttribute('name', 'tl_elements'); $table = $tables->appendChild($table); // Load the DCA $this->loadDataContainer('tl_elements'); // Get the order fields $objDcaExtractor = \DcaExtractor::getInstance('tl_elements'); $arrOrder = $objDcaExtractor->getOrderFields(); // Get all content blocks $objContentBlocks = $this->Database->prepare("SELECT * FROM tl_elements WHERE pid=?") ->execute($objThemeId); // Add the rows while ($objContentBlocks->next()) { $this->addDataRow($xml, $table, $objContentBlocks->row(), $arrOrder); } $objContentBlocks->reset(); // Add the child table (pattern) $table = $xml->createElement('table'); $table->setAttribute('name', 'tl_pattern'); $table = $tables->appendChild($table); // Load the DCA $this->loadDataContainer('tl_pattern'); // Get the order fields $objDcaExtractor = \DcaExtractor::getInstance('tl_pattern'); $arrOrder = $objDcaExtractor->getOrderFields(); // Add pattern recursively while ($objContentBlocks->next()) { $this->addPatternData($xml, $table, $arrOrder, $objContentBlocks->id); } }
php
{ "resource": "" }
q1068
Theme.addPatternData
train
protected function addPatternData ($xml, $table, $arrOrder, $intParentID) { // Get all content patterns $objContentPattern = $this->Database->prepare("SELECT * FROM tl_pattern WHERE pid=?") ->execute($intParentID); // Add the rows while ($objContentPattern->next()) { $this->addDataRow($xml, $table, $objContentPattern->row(), $arrOrder); if (in_array($objContentPattern->type, $GLOBALS['TL_CTP_SUB'])) { $this->addPatternData($xml, $table, $arrOrder, $objContentPattern->id); } } }
php
{ "resource": "" }
q1069
Combination.getCombinations
train
public function getCombinations(array $sourceDataSet, $subsetSize = null) { // If the subset size is supplied, then just return the combinations that match such size if (isset($subsetSize)) { return $this->_getCombinationSubset($sourceDataSet, $subsetSize); } // Otherwise, we return all possible combinations $masterCombinationSet = []; // Calculate the combinations for all the possible lengths and add them to the master set $sourceDataSetLength = count($sourceDataSet); for ($i = 1; $i <= $sourceDataSetLength; $i++) { $combinationSubset = $this->_getCombinationSubset($sourceDataSet, $i); $masterCombinationSet = array_merge($masterCombinationSet, $combinationSubset); } return $masterCombinationSet; }
php
{ "resource": "" }
q1070
Combination._getCombinationSubset
train
protected function _getCombinationSubset(array $sourceDataSet, $subsetSize) { if (!isset($subsetSize) || $subsetSize < 0) { throw new \InvalidArgumentException('Subset size cannot be empty or less than 0'); } $sourceSetSize = count($sourceDataSet); if ($subsetSize >= $sourceSetSize) { return [$sourceDataSet]; } else if ($subsetSize == 1) { return array_chunk($sourceDataSet, 1, true); } else if ($subsetSize == 0) { return []; } $combinations = []; $setKeys = array_keys($sourceDataSet); $pointer = new Pointer($sourceDataSet, $subsetSize); do { $combinations[] = $this->_getCombination($sourceDataSet, $setKeys, $pointer); } while ($pointer->advance()); return $combinations; }
php
{ "resource": "" }
q1071
Combination._getCombination
train
private function _getCombination($sourceDataSet, $setKeyList, Pointer $pointer) { $combination = array(); $indexPointerList = $pointer->getPointerList(); foreach ($indexPointerList as $indexPointer) { $namedKey = $setKeyList[$indexPointer]; $combination[$namedKey] = $sourceDataSet[$namedKey]; } return $combination; }
php
{ "resource": "" }
q1072
Pattern.generateDCA
train
public function generateDCA($strFieldName, $arrFieldDCA=array(), $bolVisble=true, $bolCallbacks=true) { $strVirtualField = $this->virtualFieldName($strFieldName); // Add to palette if ($bolVisble) { /* Using the subpalette system of the DC_TABLE not possible because of direct database check (see https://github.com/contao/core-bundle/blob/2a85914f4ba858780ffbac38a468acb7028772c7/src/Resources/contao/drivers/DC_Table.php#L3191) if (!empty($this->parent)) { if (isset($GLOBALS['TL_DCA']['tl_content']['subpalettes'][$this->parent])) { $GLOBALS['TL_DCA']['tl_content']['subpalettes'][$this->parent] .= ',' . $strVirtualField; } else { $GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'][] = $this->parent; $GLOBALS['TL_DCA']['tl_content']['subpalettes'][$this->parent] = $strVirtualField; } } else { $GLOBALS['TL_DCA']['tl_content']['palettes'][$this->alias] .= ',' . $strVirtualField; } */ $GLOBALS['TL_DCA']['tl_content']['palettes'][$this->element] .= ',' . $strVirtualField; } // Add necessary virtual field callbacks if ($bolCallbacks) { $arrFieldDCA['eval']['doNotSaveEmpty'] = true; $arrFieldDCA['load_callback'] = is_array($arrFieldDCA['load_callback']) ? $arrFieldDCA['load_callback'] : array(); $arrFieldDCA['save_callback'] = is_array($arrFieldDCA['save_callback']) ? $arrFieldDCA['save_callback'] : array(); // load default value if ($arrFieldDCA['default']) { array_unshift($arrFieldDCA['load_callback'], array('tl_content_elements', 'defaultValue')); } // load/save database values first/last array_unshift($arrFieldDCA['load_callback'], array('tl_content_elements', 'loadFieldValue')); array_push($arrFieldDCA['save_callback'], array('tl_content_elements', 'saveFieldAndClear')); } // Virtual field data $arrFieldDCA = array_merge($arrFieldDCA, array ( 'id' => (isset($this->data->id)) ? $this->data->id : null, 'pattern' => $this->pattern, 'parent' => (isset($this->parent)) ? $this->parent : 0, 'column' => $strFieldName, 'data' => (isset($this->data->$strFieldName)) ? $this->data->$strFieldName : null )); // Add field informations $GLOBALS['TL_DCA']['tl_content']['fields'][$strVirtualField] = $arrFieldDCA; }
php
{ "resource": "" }
q1073
Pattern.virtualFieldName
train
protected function virtualFieldName($strFieldName) { $strVirtualField = $this->pattern . '-' . $strFieldName; if ($this->data !== null) { $strVirtualField .= '-' . $this->data->id; } return $strVirtualField; }
php
{ "resource": "" }
q1074
Pattern.writeToTemplate
train
public function writeToTemplate($value) { if (is_array($this->arrMapper)) { $arrValue[$this->arrMapper[0]] = $this->Template->{$this->arrMapper[0]}; $map =& $arrValue; foreach ($this->arrMapper as $key) { if (!is_array($map[$key])) { $map[$key] = array(); } $map =& $map[$key]; } $map[$this->alias] = $value; $this->Template->{$this->arrMapper[0]} = $arrValue[$this->arrMapper[0]]; return; } $this->Template->{$this->alias} = $value; }
php
{ "resource": "" }
q1075
Pattern.hasData
train
public static function hasData($strName) { foreach ($GLOBALS['TL_CTP'] as $v) { foreach ($v as $kk=>$vv) { if ($kk == $strName) { return ($vv['data']) ?:false; } } } return null; }
php
{ "resource": "" }
q1076
rc4crypt.encrypt
train
static function encrypt ($pwd, $data, $ispwdHex = 0) { if ($ispwdHex) $pwd = @pack('H*', $pwd); // valid input, please! $key[] = ''; $box[] = ''; $cipher = ''; $pwd_length = strlen($pwd); $data_length = strlen($data); for ($i = 0; $i < 256; $i++) { $key[$i] = ord($pwd[$i % $pwd_length]); $box[$i] = $i; } for ($j = $i = 0; $i < 256; $i++) { $j = ($j + $box[$i] + $key[$i]) % 256; $tmp = $box[$i]; $box[$i] = $box[$j]; $box[$j] = $tmp; } for ($a = $j = $i = 0; $i < $data_length; $i++) { $a = ($a + 1) % 256; $j = ($j + $box[$a]) % 256; $tmp = $box[$a]; $box[$a] = $box[$j]; $box[$j] = $tmp; $k = $box[(($box[$a] + $box[$j]) % 256)]; $cipher .= chr(ord($data[$i]) ^ $k); } return $cipher; }
php
{ "resource": "" }
q1077
OrderHistoryPage.getOrders
train
public function getOrders($limit = 10) { if ($Member = Security::getCurrentUser()) { $Orders = $Member->Orders()->sort('TransactionDate', 'DESC'); $list = new PaginatedList($Orders, Controller::curr()->getRequest()); $list->setPageLength($limit); return $list; } return false; }
php
{ "resource": "" }
q1078
CommentQuery.subject
train
public function subject($model) { Comment::validateSubject($model, true); $this->modelClass($model::className()); $this->andWhere(['foreign_pk'=>$this->createPrimaryKeyJson($model)]); return $this; }
php
{ "resource": "" }
q1079
tl_content_elements.addCteType
train
public function addCteType($arrRow) { $return = \tl_content::addCteType($arrRow); if (($objElement = $objElement = \ElementsModel::findOneByAlias($arrRow['type'])) === null && !array_key_exists($arrRow['type'], $GLOBALS['TL_DCA']['tl_content']['palettes'])) { $tag = '<span style="color: #222;">' . $GLOBALS['TL_LANG']['CTE']['deleted'] . '</span>'; } else if ($objElement->invisible) { $tag = ' <span style="color: #c6c6c6;">(' . $GLOBALS['TL_LANG']['CTE']['invisible'] . ')</span>'; } return ($tag) ? substr_replace($return, $tag . '</div>', strpos($return, '</div>')) : $return; }
php
{ "resource": "" }
q1080
tl_content_elements.addTypeHelpWizard
train
public function addTypeHelpWizard ($dc) { return ' <a href="contao/help.php?table='.$dc->table.'&amp;field='.$dc->field.'&amp;ptable='.$dc->parentTable.'&amp;pid='.$dc->activeRecord->pid.'" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['helpWizard']) . '" onclick="Backend.openModalIframe({\'width\':735,\'title\':\''.\StringUtil::specialchars(str_replace("'", "\\'", $arrData['label'][0])).'\',\'url\':this.href});return false">'.\Image::getHtml('about.svg', $GLOBALS['TL_LANG']['MSC']['helpWizard'], 'style="vertical-align:text-bottom"').'</a>'; }
php
{ "resource": "" }
q1081
tl_content_elements.getElements
train
public function getElements ($dc) { if ($dc->activeRecord !== null) { $ptable = $dc->activeRecord->ptable; $pid = $dc->activeRecord->pid; } else { // If no activeRecord try to use get parameters (submitted by the custom help wizard) $ptable = \Input::get('ptable'); $pid = \Input::get('pid'); } // Try to find content block elements for the theme $objLayout = \LayoutModel::findById(\Agoat\CustomContentElementsBundle\Contao\Controller::getLayoutId($ptable, $pid)); $colElements = \ElementsModel::findPublishedByPid($objLayout->pid); $arrElements = array(); $strGroup = 'cte'; if ($colElements !== null) { foreach ($colElements as $objElement) { if ($objElement->type == 'group') { $strGroup = $objElement->alias; } else { $arrElements[$strGroup][] = $objElement->alias; } } } // Add standard content elements if (!\Config::get('hideLegacyCTE')) { unset($GLOBALS['TL_CTE']['CTE']); foreach ($GLOBALS['TL_CTE'] as $k=>$v) { foreach (array_keys($v) as $kk) { $arrElements[$k][] = $kk; } } } // Legacy support if ($dc->value != '' && !in_array($dc->value, array_reduce($arrElements, 'array_merge', array()))) { if (($objLegacy = \ElementsModel::findOneByAlias($dc->value)) === null && !array_key_exists($dc->value, $GLOBALS['TL_DCA']['tl_content']['palettes'])) { $arrLegacy = array('deleted' => array ($dc->value)); } else if ($objLegacy->invisible) { $arrLegacy = array('invisible' => array ($dc->value)); } else { $arrLegacy = array('legacy' => array ($dc->value)); } // Add current at top of the list $arrElements = array_merge($arrLegacy, $arrElements); } return $arrElements; }
php
{ "resource": "" }
q1082
tl_content_elements.setDefaultType
train
public function setDefaultType($value, $dc) { if (!$value) { if ($dc->activeRecord !== null) { $ptable = $dc->activeRecord->ptable; $pid = $dc->activeRecord->pid; } else { return $value; } // Try to find content block elements for the theme $objLayout = \LayoutModel::findById(\Agoat\CustomContentElementsBundle\Contao\Controller::getLayoutId($ptable, $pid)); $objDefault = \ElementsModel::findDefaultPublishedElementByPid($objLayout->pid); // if no default content element is found if ($objDefault === null) { if (\Config::get('hideLegacyCTE')) { $objDefault = \ElementsModel::findFirstPublishedElementByPid($objLayout->pid); } if ($objDefault === null) { $objDefault = new \stdClass(); $objDefault->alias = 'text'; } } $objContent = \ContentModel::findByPk($dc->id); $objContent->type = $objDefault->alias; $objContent->save(); $this->redirect(\Environment::get('request')); } return $value; }
php
{ "resource": "" }
q1083
tl_content_elements.buildPaletteAndFields
train
public function buildPaletteAndFields ($dc) { // Build the content block elements palette and fields only when editing a content element (see #5) if (\Input::get('act') != 'edit' && \Input::get('act') != 'show' && !isset($_GET['target'])) { return; } $intId = (isset($_GET['target'])) ? explode('.', \Input::get('target'))[2] : $dc->id; $objContent = \ContentModel::findByPk($intId); if ($objContent === null) { return; } // Get block element $objElement = \ElementsModel::findOneByAlias($objContent->type); if ($objElement === null) { return; } // Add default palette (for type selection) $GLOBALS['TL_DCA']['tl_content']['palettes'][$objElement->alias] = '{type_legend},type'; // Add pattern to palette $colPattern = \PatternModel::findVisibleByPid($objElement->id); if ($colPattern === null) { return; } $arrData = array(); $colData = \DataModel::findByPid($intId); if ($colData !== null) { foreach ($colData as $objData) { $arrData[$objData->pattern] = $objData; } } foreach($colPattern as $objPattern) { // Construct dca for pattern $strClass = Agoat\CustomContentElementsBundle\Contao\Pattern::findClass($objPattern->type); $bolData = Agoat\CustomContentElementsBundle\Contao\Pattern::hasData($objPattern->type); if (!class_exists($strClass)) { \System::log('Pattern element class "'.$strClass.'" (pattern element "'.$objPattern->type.'") does not exist', __METHOD__, TL_ERROR); } else { if ($bolData && !isset($arrData[$objPattern->alias])) { $arrData[$objPattern->alias] = new \DataModel(); $arrData[$objPattern->alias]->pid = $objContent->id; $arrData[$objPattern->alias]->pattern = $objPattern->alias; $arrData[$objPattern->alias]->save(); } $objPatternClass = new $strClass($objPattern); $objPatternClass->pid = $objContent->id; $objPatternClass->pattern = $objPattern->alias; $objPatternClass->element = $objElement->alias; $objPatternClass->data = $arrData[$objPattern->alias]; // Save data to the DCA $objPatternClass->create(); } } }
php
{ "resource": "" }
q1084
tl_content_elements.loadFieldValue
train
public function loadFieldValue ($value, $dc) { if (!empty($value)) { return $value; } if (!empty($GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['data'])) { return $GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['data']; } return null; }
php
{ "resource": "" }
q1085
tl_content_elements.saveData
train
public function saveData (&$dc) { // Save all modified values foreach ($this->arrModifiedData as $field => $value) { // Get virtual field attributes from DCA $id = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['id']; $pattern = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['pattern']; $parent = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['parent']; $column = $GLOBALS['TL_DCA']['tl_content']['fields'][$field]['column']; if ($id !== null) { $objData = \DataModel::findByPK($id); } else { $objData = \DataModel::findByPidAndPatternAndParent($dc->activeRecord->id, $pattern, $parent); } if ($objData === null) { // if no dataset exist make a new one $objData = new \DataModel(); $objData->tstamp = time(); } $objData->pid = $dc->activeRecord->id; $objData->pattern = $pattern; $objData->parent = $parent; if ($objData->$column != $value) { $dc->blnCreateNewVersion = true; $objData->$column = $value; $objData->tstamp = time(); } $objData->save(); } }
php
{ "resource": "" }
q1086
tl_content_elements.prepareOrderValue
train
public function prepareOrderValue ($value, $dc) { $orderField = $GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['eval']['orderField']; $orderData = \StringUtil::deserialize($GLOBALS['TL_DCA']['tl_content']['fields'][$orderField]['data']); $GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['eval'][$orderField] = (is_array($orderData)) ? $orderData : array(); return $value; }
php
{ "resource": "" }
q1087
tl_content_elements.saveOrderValue
train
public function saveOrderValue ($value, $dc) { $orderField = $GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['eval']['orderField']; $orderData = \Input::post($orderField); if ($orderData) { // Convert UUID to binary data for file sources if ($GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['inputType'] == 'fileTree') { $this->arrModifiedData[$orderField] = array_map('\StringUtil::uuidToBin', explode(',', $orderData)); } else { $this->arrModifiedData[$orderField] = explode(',', $orderData); } } else { $this->arrModifiedData[$orderField] = NULL; } return $value; }
php
{ "resource": "" }
q1088
tl_content_elements.setAceCodeHighlighting
train
public function setAceCodeHighlighting($value, $dc) { $pattern = $GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['pattern']; $highlight = $GLOBALS['TL_DCA']['tl_content']['fields'][$pattern . '-highlight']['data']; if (!empty($highlight)) { $GLOBALS['TL_DCA']['tl_content']['fields'][$dc->field]['eval']['rte'] = 'ace|' . strtolower($highlight); } return $value; }
php
{ "resource": "" }
q1089
tl_content_elements.createDataVersion
train
public function createDataVersion ($strTable, $intPid, $intVersion) { $db = Database::getInstance(); $objData = $db->prepare("SELECT * FROM tl_data WHERE pid=?") ->execute($intPid); if ($objData === null) { return; } $db->prepare("INSERT INTO tl_version (pid, tstamp, version, fromTable, data) VALUES (?, ?, ?, ?, ?)") ->execute($intPid, time(), $intVersion, 'tl_data', serialize($objData->fetchAllAssoc())); }
php
{ "resource": "" }
q1090
tl_content_elements.restoreDataVersion
train
public function restoreDataVersion ($strTable, $intPid, $intVersion) { $db = Database::getInstance(); $objData = $db->prepare("SELECT * FROM tl_version WHERE fromTable=? AND pid=? AND version=?") ->execute('tl_data', $intPid, $intVersion); if ($objData->numRows < 1) { return; } $data = \StringUtil::deserialize($objData->data); if (!is_array($data)) { return; } // Get the currently available fields $arrFields = array_flip($this->Database->getFieldnames('tl_data')); $objStmt = $db->prepare("DELETE FROM tl_data WHERE pid=?") ->execute($intPid); foreach ($data as $row) { // Unset fields that do not exist (see #5219) $row = array_intersect_key($row, $arrFields); // Reset fields added after storing the version to their default value (see #7755) foreach (array_diff_key($arrFields, $row) as $k=>$v) { $row[$k] = \Widget::getEmptyValueByFieldType($GLOBALS['TL_DCA']['tl_data']['fields'][$k]['sql']); } $db->prepare("INSERT INTO tl_data %s") ->set($row) ->execute($row['id']); } }
php
{ "resource": "" }
q1091
ProjectEndpoint.convertAvatar
train
public function convertAvatar($projectId, $cropperWidth, $cropperOffsetX, $cropperOffsetY, $needsCropping) { return $this->apiClient->callEndpoint( sprintf('%s/%s/avatar', self::ENDPOINT, $projectId), array( "cropperWidth" => $cropperWidth, "cropperOffsetX" => $cropperOffsetX, "cropperOffsetY" => $cropperOffsetY, "needsCropping" => $needsCropping ), HttpMethod::REQUEST_POST ); }
php
{ "resource": "" }
q1092
ProjectEndpoint.findProperty
train
public function findProperty($projectId, $propertyKey) { return $this->apiClient->callEndpoint(sprintf('%s/%s/properties/%s', self::ENDPOINT, $projectId, $propertyKey)); }
php
{ "resource": "" }
q1093
ProjectEndpoint.findRole
train
public function findRole($projectId, $roleId) { return $this->apiClient->callEndpoint(sprintf('%s/%s/role/%s', self::ENDPOINT, $projectId, $roleId)); }
php
{ "resource": "" }
q1094
ProjectEndpoint.updateRole
train
public function updateRole($projectId, $roleId, $user = null, $group = null) { $parameters = []; if ((is_null($user) && is_null($group)) || (!is_null($user) && !is_null($group))) { throw new EndpointParameterException('User or group should be given'); } elseif (!is_null($user)) { $parameters['user'] = $user; } else { $parameters['group'] = $group; } return $this->apiClient->callEndpoint( sprintf('%s/%s/role/%s', self::ENDPOINT, $projectId, $roleId), $parameters, null, HttpMethod::REQUEST_PUT ); }
php
{ "resource": "" }
q1095
ProjectEndpoint.addRole
train
public function addRole($projectId, $roleId, $user = null, $group = null) { $parameters = []; if ((is_null($user) && is_null($group)) || (!is_null($user) && !is_null($group))) { throw new EndpointParameterException('User or group should be given'); } elseif (!is_null($user)) { $parameters['user'] = $user; } else { $parameters['group'] = $group; } return $this->apiClient->callEndpoint( sprintf('%s/%s/role/%s', self::ENDPOINT, $projectId, $roleId), $parameters, null, HttpMethod::REQUEST_POST ); }
php
{ "resource": "" }
q1096
ProjectEndpoint.deleteRole
train
public function deleteRole($projectId, $roleId) { return $this->apiClient->callEndpoint( sprintf('%s/%s/role/%s', self::ENDPOINT, $projectId, $roleId), array(), null, HttpMethod::REQUEST_DELETE ); }
php
{ "resource": "" }
q1097
Time.dontSeeTimeIsInSecs
train
public function dontSeeTimeIsInSecs($time, $seconds) { \PHPUnit_Framework_Assert::assertNotEquals($seconds, $this->_GetNow()->diffInSeconds($this->_ParseDate($time), false)); }
php
{ "resource": "" }
q1098
Time.seeTimeWasInSecs
train
public function seeTimeWasInSecs($time, $seconds) { \PHPUnit_Framework_Assert::assertEquals($seconds, $this->_ParseDate($time)->diffInSeconds($this->_GetNow(), false)); }
php
{ "resource": "" }
q1099
Time.seeTimeIsInMins
train
public function seeTimeIsInMins($time, $minutes) { \PHPUnit_Framework_Assert::assertEquals($minutes, $this->_GetNow()->diffInMinutes($this->_ParseDate($time), false)); }
php
{ "resource": "" }