_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q10900
EloquentPeriod.byOrganizationWithYear
train
public function byOrganizationWithYear($id) { // return $this->Period->where('organization_id', '=', $id)->with('year')->get(); -> Evitar los with $periods = $this->DB->connection($this->databaseConnectionName) ->table('ACCT_Period As p') ->join('ACCT_Fiscal_Year AS f', 'f.id', '=', 'p.fiscal_year_id') ->where('p.organization_id', '=', $id) ->get(array('p.id', 'p.month', 'f.year')); return new Collection($periods); }
php
{ "resource": "" }
q10901
EloquentPeriod.lastPeriodbyOrganizationAndByFiscalYear
train
public function lastPeriodbyOrganizationAndByFiscalYear($organizationId, $fiscalYearId) { $Period = $this->Period->selectRaw('id, end_date, max(month) as month') ->where('organization_id', '=', $organizationId) ->where('fiscal_year_id', '=', $fiscalYearId) ->orderBy('month', 'desc') ->groupBy(array('id', 'end_date')) ->first(); return $Period; }
php
{ "resource": "" }
q10902
EloquentPeriod.create
train
public function create(array $data) { $Period = new Period(); $Period->setConnection($this->databaseConnectionName); $Period->fill($data)->save(); return $Period; }
php
{ "resource": "" }
q10903
EloquentPeriod.update
train
public function update(array $data, $Period = null) { if(empty($Period)) { $Period = $this->byId($data['id']); } foreach ($data as $key => $value) { $Period->$key = $value; } return $Period->save(); }
php
{ "resource": "" }
q10904
File.setModificationDate
train
private function setModificationDate(array $ftpInfo) { $modDate = !empty($ftpInfo['modify']) ? DateTimeImmutable::createFromFormat('YmdHis', $ftpInfo['modify']) : false; $this->modify = !empty($modDate) ? $modDate : new DateTimeImmutable(); }
php
{ "resource": "" }
q10905
XmlnukeMediaGallery.addIFrame
train
public function addIFrame($src, $windowWidth, $windowHeight, $thumb="", $title = "", $caption="", $width="", $height="") { $this->addXmlnukeObject(XmlnukeMediaItem::IFrameFactory($src, $windowWidth, $windowHeight, $thumb, $title, $caption, $width, $height)); }
php
{ "resource": "" }
q10906
Render.buildAttrs
train
public function buildAttrs(array $attrs = array()) { $result = ' '; foreach ($attrs as $key => $param) { $param = (array) $param; if ($key === 'data') { $result .= $this->_buildDataAttrs($param); continue; } $value = implode(' ', $param); $value = $this->_cleanValue($value); if ($key !== 'data' && $attr = $this->_buildAttr($key, $value)) { $result .= $attr; } } return trim($result); }
php
{ "resource": "" }
q10907
Render._buildAttr
train
protected function _buildAttr($key, $val) { $return = null; if (!empty($val) || $val === '0' || $key === 'value') { $return = ' ' . $key . '="' . $val . '"'; } return $return; }
php
{ "resource": "" }
q10908
Render._buildDataAttrs
train
protected function _buildDataAttrs(array $param = array()) { $return = ''; foreach ($param as $data => $val) { $dKey = 'data-' . trim($data); if (is_object($val)) { $val = (array) $val; } if (is_array($val)) { $val = str_replace('"', '\'', json_encode($val)); $return .= $this->_buildAttr($dKey, $val); continue; } $return .= $this->_buildAttr($dKey, $val); } return $return; }
php
{ "resource": "" }
q10909
Render._cleanAttrs
train
protected function _cleanAttrs(array $attrs = array()) { foreach ($attrs as $key => $val) { if (Arr::in($key, $this->_disallowAttr)) { unset($attrs[$key]); } } return $attrs; }
php
{ "resource": "" }
q10910
Render._cleanValue
train
protected function _cleanValue($value, $trim = false) { $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); return ($trim) ? trim($value) : $value; }
php
{ "resource": "" }
q10911
Render._mergeAttr
train
protected function _mergeAttr(array $attrs = array(), $val = null, $key = 'class') { if (Arr::key($key, $attrs)) { $attrs[$key] .= ' ' . $val; } else { $attrs[$key] = $val; } return $attrs; }
php
{ "resource": "" }
q10912
MenuContentFactory.createTabsMenu
train
protected function createTabsMenu(ManialinkInterface $manialink, ParentItem $rootItem, $openId) { /** @var Frame $tabsFrame */ $tabsFrame = $manialink->getData('tabs_frame'); $tabsFrame->removeAllChildren(); $this->menuTabsFactory->createTabsMenu($manialink, $tabsFrame, $rootItem, [$this, 'callbackItemClick'], $openId); }
php
{ "resource": "" }
q10913
MenuContentFactory.callbackClose
train
public function callbackClose( ManialinkInterface $manialink, $login, $params, $args ) { $this->destroy($manialink->getUserGroup()); }
php
{ "resource": "" }
q10914
FloatValueHolder.almostEqual
train
public static function almostEqual($a, $b, $epsilon = 0.0000000001) { $diff = abs($a - $b); if ($a === $b) { // just compare values, handles e.g. INF return true; } elseif ($a === 0.0 || $b === 0.0 || $diff < self::FLOAT_MIN) { // a or b is zero or both are extremely close to it // relative error is less meaningful here return $diff < ($epsilon * self::FLOAT_MIN); } else { // use relative error $abs_a = abs($a); $abs_b = abs($b); return $diff / ($abs_a + $abs_b) < $epsilon; } }
php
{ "resource": "" }
q10915
CheckInForm.doCheckIn
train
public function doCheckIn($data, CheckInForm $form) { /** @var CheckInController $controller */ $controller = $form->getController(); $validator = CheckInValidator::create(); $result = $validator->validate($data['TicketCode']); switch ($result['Code']) { case CheckInValidator::MESSAGE_CHECK_OUT_SUCCESS: $validator->getAttendee()->checkOut(); break; case CheckInValidator::MESSAGE_CHECK_IN_SUCCESS: $validator->getAttendee()->checkIn(); break; } $form->sessionMessage($result['Message'], strtolower($result['Type']), false); $this->extend('onAfterCheckIn', $response, $form, $result); return $response ? $response : $controller->redirect($controller->Link()); }
php
{ "resource": "" }
q10916
ExtendQueuedTask.getLengthQueue
train
public function getLengthQueue($jobType = null) { $jobType = (string)$jobType; $queueLength = 0; $pendingStats = $this->getPendingStats(); if (empty($pendingStats)) { return $queueLength; } foreach ($pendingStats as $pendingStatsItem) { if ((!empty($jobType) && (strcmp($pendingStatsItem[$this->alias]['jobtype'], $jobType) !== 0)) || ($pendingStatsItem[$this->alias]['status'] !== 'NOT_STARTED')) { continue; } $queueLength++; } return $queueLength; }
php
{ "resource": "" }
q10917
ExtendQueuedTask.getPendingJob
train
public function getPendingJob($jobType = null, $includeFinished = false, $timestamp = null) { if (empty($jobType)) { return false; } if (empty($timestamp) || (!is_int($timestamp) || !ctype_digit($timestamp))) { $timestamp = strtotime('-15 minute'); } $fetchedTime = date('Y-m-d H:i:s', $timestamp); $fields = [ $this->alias . '.jobtype', $this->alias . '.created', $this->alias . '.status', $this->alias . '.age', $this->alias . '.fetched', $this->alias . '.progress', $this->alias . '.completed', $this->alias . '.reference', $this->alias . '.failed', $this->alias . '.failure_message' ]; $conditions = [ 'OR' => [ [ // NOT_READY $this->alias . '.notbefore > NOW()', ], [ // NOT_STARTED $this->alias . '.fetched' => null, ], [ // IN_PROGRESS 'AND' => [ $this->alias . '.fetched NOT' => null, $this->alias . '.fetched >' => $fetchedTime, $this->alias . '.completed' => null, $this->alias . '.failed' => 0, ], ] ], $this->alias . '.jobtype' => $jobType, ]; if ($includeFinished) { $conditions['OR'][] = [ // FAILED 'AND' => [ $this->alias . '.fetched NOT' => null, $this->alias . '.fetched >' => $fetchedTime, $this->alias . '.completed' => null, $this->alias . '.failed >' => 0, ], ]; $conditions['OR'][] = [ // COMPLETED 'AND' => [ $this->alias . '.fetched NOT' => null, $this->alias . '.fetched >' => $fetchedTime, $this->alias . '.completed NOT' => null, ], ]; } $order = [ 'FIELD(' . $this->alias . '__status' . ', \'NOT_READY\', \'NOT_STARTED\', \'IN_PROGRESS\', \'FAILED\', \'COMPLETED\')' => 'ASC', 'CAST(' . $this->alias . '__age AS SIGNED)' => 'DESC', 'CASE WHEN ' . $this->alias . '__status' . ' IN(\'NOT_READY\', \'NOT_STARTED\', \'IN_PROGRESS\') THEN ' . $this->alias . '.id END ASC', 'CASE WHEN ' . $this->alias . '__status' . ' IN(\'FAILED\', \'COMPLETED\') THEN ' . $this->alias . '.id END DESC', ]; return $this->find('first', compact('fields', 'conditions', 'order')); }
php
{ "resource": "" }
q10918
ExtendQueuedTask.updateMessage
train
public function updateMessage($id = null, $message = null) { if (empty($id) || !$this->exists($id)) { return false; } $message = (string)$message; if (empty($message)) { $message = null; } $this->id = (int)$id; return (bool)$this->saveField('failure_message', $message); }
php
{ "resource": "" }
q10919
ExtendQueuedTask.updateTaskProgress
train
public function updateTaskProgress($id, &$step, $maxStep = 0) { if (empty($id) || !$this->exists($id) || ($maxStep < 1) || ($maxStep < $step)) { return false; } $step++; $progress = $step / $maxStep; return $this->updateProgress($id, $progress); }
php
{ "resource": "" }
q10920
ExtendQueuedTask.updateTaskErrorMessage
train
public function updateTaskErrorMessage($id = null, $errorMessage = null, $keepExistingMessage = false) { if (empty($id) || !$this->exists($id) || empty($errorMessage)) { return false; } if ($keepExistingMessage) { $this->id = $id; $message = $this->field('failure_message'); if (!empty($message)) { $errorMessage = $message . "\n" . $errorMessage; } } return $this->markJobFailed($id, $errorMessage); }
php
{ "resource": "" }
q10921
ExtendQueuedTask.deleteTasks
train
public function deleteTasks($data = null) { if (empty($data) || !is_array($data)) { return false; } $excludeFields = [ 'data', 'failure_message', 'workerkey', ]; $data = array_diff_key($data, array_flip($excludeFields)); $conditions = []; foreach ($data as $field => $value) { $conditions[$this->alias . '.' . $field] = $value; } if (empty($conditions)) { return false; } $countTasks = $this->find('count', compact('conditions')); if (($countTasks == 0) || !$this->deleteAll($conditions)) { return false; } return true; }
php
{ "resource": "" }
q10922
ConnectionManager.findConnection
train
public function findConnection(string $name=null) { if ( empty($name) ) { # Take first available connection $connection = \reset($this->connections); if ($connection === false) return null; } else { # Attempt to find the connection from the pool $connection = ( $this->connections[\strtolower($name)] ?? null); } return $connection; }
php
{ "resource": "" }
q10923
ConnectionManager.addConnection
train
public function addConnection(PdoConnectionInterface $connection) { $this->connections[\strtolower($connection->getName())] = $connection; return $connection; }
php
{ "resource": "" }
q10924
MimeType.register
train
public static function register(string $guesser): void { if (\in_array(MimeTypeGuesserContract::class, \class_implements($guesser), true)) { \array_unshift(self::$guessers, $guesser); } throw new RuntimeException(\sprintf('You guesser [%s] should implement the [\%s].', $guesser, MimeTypeGuesserContract::class)); }
php
{ "resource": "" }
q10925
MimeType.guess
train
public static function guess(string $guess): ?string { $guessers = self::getGuessers(); if (\count($guessers) === 0) { $msg = 'Unable to guess the mime type as no guessers are available'; if (! MimeTypeFileInfoGuesser::isSupported()) { $msg .= ' (Did you enable the php_fileinfo extension?).'; } throw new \LogicException($msg); } $exception = null; foreach ($guessers as $guesser) { try { $mimeType = $guesser::guess($guess); } catch (RuntimeException $e) { $exception = $e; continue; } if ($mimeType !== null) { return $mimeType; } } // Throw the last catched exception. if ($exception !== null) { throw $exception; } return null; }
php
{ "resource": "" }
q10926
MimeType.getGuessers
train
private static function getGuessers(): array { if (! self::$nativeGuessersLoaded) { if (MimeTypeFileExtensionGuesser::isSupported()) { self::$guessers[] = MimeTypeFileExtensionGuesser::class; } if (MimeTypeFileInfoGuesser::isSupported()) { self::$guessers[] = MimeTypeFileInfoGuesser::class; } if (MimeTypeFileBinaryGuesser::isSupported()) { self::$guessers[] = MimeTypeFileBinaryGuesser::class; } self::$nativeGuessersLoaded = true; } return self::$guessers; }
php
{ "resource": "" }
q10927
View.get_block_template
train
public static function get_block_template( $url ) { $template = static::get_template( $url ); $template = str_replace( '<a ', '<span ', $template ); $template = str_replace( '</a>', '</span>', $template ); // @codingStandardsIgnoreStart $template .= sprintf( '<link rel="stylesheet" href="%1$s">', esc_url_raw( get_template_directory_uri() . '/vendor/inc2734/wp-oembed-blog-card/src/assets/css/gutenberg-embed.min.css' ) ); $template .= sprintf( '<link rel="stylesheet" href="%1$s">', esc_url_raw( get_template_directory_uri() . '/vendor/inc2734/wp-oembed-blog-card/src/assets/css/app.min.css' ) ); // @codingStandardsIgnoreEnd return static::_strip_newlines( apply_filters( 'wp_oembed_blog_card_gutenberg_template', $template, $url ) ); }
php
{ "resource": "" }
q10928
View.get_pre_blog_card_template
train
public static function get_pre_blog_card_template( $url ) { if ( ! $url ) { return; } if ( 0 === strpos( $url, home_url() ) ) { $target = '_self'; } else { $target = '_blank'; } return static::_strip_newlines( sprintf( '<div class="js-wp-oembed-blog-card"> <a class="js-wp-oembed-blog-card__link" href="%1$s" target="%2$s">%1$s</a> </div>', esc_url( $url ), esc_attr( $target ) ) ); }
php
{ "resource": "" }
q10929
Path.combine
train
public static function combine($part1, $part2) { if ($part1 && $part2) { return sprintf("%s/%s", rtrim($part1, '/'), ltrim($part2, '/')); } throw new InvalidArgumentException("All parts must be filled"); }
php
{ "resource": "" }
q10930
Path.getRoot
train
public static function getRoot($rootForPath = null, $rootHasDir = 'lib') { if (!$rootForPath) { $includes = get_included_files(); $rootForPath = $includes[0]; } $rootForPath = rtrim($rootForPath, DIRECTORY_SEPARATOR); $rootHasDir = ltrim($rootHasDir, DIRECTORY_SEPARATOR); while (!is_dir($rootForPath . DIRECTORY_SEPARATOR . $rootHasDir)) { $rootForPath = dirname($rootForPath); if ($rootForPath == DIRECTORY_SEPARATOR) { throw new Exception("Cannot determine root path."); } } return $rootForPath; }
php
{ "resource": "" }
q10931
Path.purge
train
public static function purge($path, $fileFilterRegex = null, $dirFilterRegex = null) { Path::validatePath($path); $iterator = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS); $iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST); foreach ((array) $fileFilterRegex as $regex) { $iterator = new FileRegexIterator($iterator, $regex); } foreach ((array) $dirFilterRegex as $regex) { $iterator = new DirectoryRegexIterator($iterator, $regex); } foreach ($iterator as $file) { if ($file->isDir()) { Path::delete($file->getPathName()); continue; } File::delete($file->getPathname()); } }
php
{ "resource": "" }
q10932
ExtendedRequest.getIp
train
public function getIp() { $keys = ['X_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR', 'CLIENT_IP', 'REMOTE_ADDR']; foreach ($keys as $key) { $ip = $this->getServerParam($key); if (!$ip) { continue; } $ip = preg_replace('/,.*$/u', '', $ip); $ip = trim($ip); return $ip; } return null; }
php
{ "resource": "" }
q10933
ExtendedRequest.getRequestTargetWithParams
train
public function getRequestTargetWithParams($params) { $target = $this->getFullPath(); if ($params) { $target .= '?' . http_build_query($params); } return $target; }
php
{ "resource": "" }
q10934
ExtendedRequest.withHost
train
public function withHost($host) { $uri = $this->getUri()->withHost($host); /** @var static $clone */ $clone = $this->withUri($uri); return $clone; }
php
{ "resource": "" }
q10935
Pearify.getTempDir
train
protected static function getTempDir() { $name = tempnam(sys_get_temp_dir(), 'tmp'); unlink($name); mkdir($name, 0777, true); return $name; }
php
{ "resource": "" }
q10936
Player.initRecords
train
public function initRecords($overrideExisting = true) { if (null !== $this->collRecords && !$overrideExisting) { return; } $collectionClassName = RecordTableMap::getTableMap()->getCollectionClassName(); $this->collRecords = new $collectionClassName; $this->collRecords->setModel('\eXpansion\Bundle\LocalRecords\Model\Record'); }
php
{ "resource": "" }
q10937
Player.getRecords
train
public function getRecords(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collRecordsPartial && !$this->isNew(); if (null === $this->collRecords || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRecords) { // return empty collection $this->initRecords(); } else { $collRecords = RecordQuery::create(null, $criteria) ->filterByPlayer($this) ->find($con); if (null !== $criteria) { if (false !== $this->collRecordsPartial && count($collRecords)) { $this->initRecords(false); foreach ($collRecords as $obj) { if (false == $this->collRecords->contains($obj)) { $this->collRecords->append($obj); } } $this->collRecordsPartial = true; } return $collRecords; } if ($partial && $this->collRecords) { foreach ($this->collRecords as $obj) { if ($obj->isNew()) { $collRecords[] = $obj; } } } $this->collRecords = $collRecords; $this->collRecordsPartial = false; } } return $this->collRecords; }
php
{ "resource": "" }
q10938
Player.countRecords
train
public function countRecords(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collRecordsPartial && !$this->isNew(); if (null === $this->collRecords || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRecords) { return 0; } if ($partial && !$criteria) { return count($this->getRecords()); } $query = RecordQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByPlayer($this) ->count($con); } return count($this->collRecords); }
php
{ "resource": "" }
q10939
Player.addRecord
train
public function addRecord(Record $l) { if ($this->collRecords === null) { $this->initRecords(); $this->collRecordsPartial = true; } if (!$this->collRecords->contains($l)) { $this->doAddRecord($l); if ($this->recordsScheduledForDeletion and $this->recordsScheduledForDeletion->contains($l)) { $this->recordsScheduledForDeletion->remove($this->recordsScheduledForDeletion->search($l)); } } return $this; }
php
{ "resource": "" }
q10940
EloquentAccount.byIds
train
public function byIds(array $ids, $databaseConnectionName = null) { if(empty($databaseConnectionName)) { $databaseConnectionName = $this->databaseConnectionName; } return $this->Account->setConnection($databaseConnectionName) ->whereIn('id',$ids) ->get(); }
php
{ "resource": "" }
q10941
EloquentAccount.byOrganizationAndByKey
train
public function byOrganizationAndByKey($organizationId, $key) { if(empty($databaseConnectionName)) { $databaseConnectionName = $this->databaseConnectionName; } return $this->Account->setConnection($databaseConnectionName) ->where('organization_id', '=', $organizationId) ->where('key', '=', $key)->get(); }
php
{ "resource": "" }
q10942
EloquentAccount.byParent
train
public function byParent($id, $databaseConnectionName = null) { if(empty($databaseConnectionName)) { $databaseConnectionName = $this->databaseConnectionName; } return $this->Account->setConnection($databaseConnectionName) ->where('parent_account_id', '=', $id) ->orderBy('key', 'asc') ->get(); }
php
{ "resource": "" }
q10943
PayeeVisitor.beforePayeeBankgiro
train
public function beforePayeeBankgiro(Node $node): void { if (!$this->payeeBg) { $this->payeeBg = (string)$node->getValueFrom('Number'); } if ($node->getValueFrom('Number') != $this->payeeBg) { $this->getErrorObject()->addError( "Non-matching payee bankgiro numbers (expecting: %s, found: %s) on line %s", $this->payeeBg, (string)$node->getValueFrom('Number'), (string)$node->getLineNr() ); } }
php
{ "resource": "" }
q10944
PayeeVisitor.beforePayeeBgcNumber
train
public function beforePayeeBgcNumber(Node $node): void { if (!$this->payeeBgcNr) { $this->payeeBgcNr = (string)$node->getValue(); } if ($node->getValue() != $this->payeeBgcNr) { $this->getErrorObject()->addError( "Non-matching payee BGC customer numbers (expecting: %s, found: %s) on line %s", $this->payeeBgcNr, (string)$node->getValue(), (string)$node->getLineNr() ); } }
php
{ "resource": "" }
q10945
Transactions.all
train
public static function all(array $arg_params) { //validate params $data = self::getParams($arg_params); $url = '/ecommerce/transactions'; $filters = ''; if(!empty($data['page'])&&ctype_digit($data['page'])){ $filters .= 'page='.$data['page']; } if(!empty($filters))$filters='?'.$filters; //submit to api $transactions_data = APIRequests::request( $url.$filters, APIRequests::METHOD_GET ); //return response return self::toListObj($transactions_data['body']); }
php
{ "resource": "" }
q10946
ModuleFactory.httpDigestParse
train
private static function httpDigestParse($txt) { // protect against missing data $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1); $data = array(); $keys = implode('|', array_keys($needed_parts)); preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); foreach ($matches as $m) { $data[$m[1]] = $m[3] ? $m[3] : $m[4]; unset($needed_parts[$m[1]]); } return $needed_parts ? false : $data; }
php
{ "resource": "" }
q10947
Series.setOption
train
public function setOption( $name, $value ) { $this->jsWriter->setSeriesOption( $this->getTitle(), $name, $value ); return $this; }
php
{ "resource": "" }
q10948
Series.setLineWidth
train
public function setLineWidth( $val ) { if ( $this->jsWriter instanceof \Altamira\JsWriter\Ability\Lineable ) { $this->jsWriter->setSeriesLineWidth( $this->getTitle(), $val ); } return $this; }
php
{ "resource": "" }
q10949
SummaryField.Field
train
public function Field($properties = array()) { $context = $this; $properties['Editable'] = $this->editable; $properties['Reservation'] = $this->getReservation(); $properties['Attendees'] = $this->editable ? $this->getEditableAttendees() : $this->getReservation()->Attendees(); if (count($properties)) { $context = $context->customise($properties); } $this->extend('onBeforeRender', $context); $result = $context->renderWith($this->getTemplates()); if (is_string($result)) { $result = trim($result); } else { if ($result instanceof DBField) { $result->setValue(trim($result->getValue())); } } return $result; }
php
{ "resource": "" }
q10950
TcPdfFactory.create
train
public function create(array $options = array()) { $reflClass = $this->getReflectionClass($options); $options = array_merge(array( 'orientation' => 'P', 'unit' => 'mm', 'format' => 'USLETTER', 'unicode' => true, 'encoding' => 'UTF-8', 'diskcache' => true, 'pdfa' => false, 'printHeader' => false, 'printFooter' => false, 'margins' => array(15, 27, 15), 'autoPageBreak' => array(true, 25), ), $options); $pdf = $reflClass->newInstanceArgs($this->getConstructorOptions($options)); foreach ($options as $option => $arguments) { if (is_callable(array($pdf, 'set' . $option))) { if (!is_array($arguments)) { if (null === $arguments) { $arguments = array(); } else { $arguments = array($arguments); } } call_user_func_array(array($pdf, 'set' . $option), $arguments); } } return new TcPdf($pdf); }
php
{ "resource": "" }
q10951
TcPdfFactory.getConstructorOptions
train
protected function getConstructorOptions(array &$options) { $ctorOptions = array( 'orientation' => isset($options['orientation']) ? $options['orientation'] : 'P', 'unit' => isset($options['unit']) ? $options['unit'] : 'mm', 'format' => isset($options['format']) ? $options['format'] : 'A4', 'unicode' => isset($options['unicode']) ? $options['unicode'] : true, 'encoding' => isset($options['encoding']) ? $options['encoding'] : 'UTF-8', // Diskcache actually defaults to false, but caching is a good thing, so we will default to true 'diskcache' => isset($options['diskcache']) ? $options['diskcache'] : true, 'pdfa' => isset($options['pdfa']) ? $options['pdfa'] : false ); unset( $options['orientation'], $options['unit'], $options['format'], $options['unicode'], $options['encoding'], $options['diskcache'], $options['pdfa'] ); return array_values($ctorOptions); }
php
{ "resource": "" }
q10952
ReservationSession.start
train
public static function start(CalendarEvent $event) { $reservation = Reservation::create(); $reservation->EventID = $event->ID; $reservation->write(); self::set($reservation); return $reservation; }
php
{ "resource": "" }
q10953
ReservationSession.end
train
public static function end() { // If the session is ended while in cart or pending state, remove the reservation. // The session is only ended in these states when iffy business is going on. if (in_array(self::get()->Status, array('CART', 'PENDING'))) { self::get()->delete(); } Session::set(self::KEY, null); Session::clear(self::KEY); }
php
{ "resource": "" }
q10954
Record.setPlayer
train
public function setPlayer(Player $v = null) { if ($v === null) { $this->setPlayerId(NULL); } else { $this->setPlayerId($v->getId()); } $this->aPlayer = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Player object, it will not be re-added. if ($v !== null) { $v->addRecord($this); } return $this; }
php
{ "resource": "" }
q10955
Record.getPlayer
train
public function getPlayer(ConnectionInterface $con = null) { if ($this->aPlayer === null && ($this->player_id !== null)) { $this->aPlayer = PlayerQuery::create()->findPk($this->player_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aPlayer->addRecords($this); */ } return $this->aPlayer; }
php
{ "resource": "" }
q10956
TicketExtension.createDefaultFields
train
public function createDefaultFields() { $fields = Attendee::config()->get('default_fields'); if (!$this->owner->Fields()->exists()) { foreach ($fields as $fieldName => $config) { $field = UserField::createDefaultField($fieldName, $config); $this->owner->Fields()->add($field); } } }
php
{ "resource": "" }
q10957
TicketExtension.updateCMSActions
train
public function updateCMSActions(FieldList $actions) { $checkInButton = new LiteralField('StartCheckIn', "<a class='action ss-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only' id='Edit_StartCheckIn' role='button' href='{$this->owner->Link('checkin')}' target='_blank'> Start check in </a>" ); if ($this->owner->Attendees()->exists()) { $actions->push($checkInButton); } }
php
{ "resource": "" }
q10958
TicketExtension.getTicketSaleStartDate
train
public function getTicketSaleStartDate() { $saleStart = null; if (($tickets = $this->owner->Tickets())) { /** @var Ticket $ticket */ foreach ($tickets as $ticket) { if (($date = $ticket->getAvailableFrom()) && strtotime($date) < strtotime($saleStart) || $saleStart === null) { $saleStart = $date; } } } return $saleStart; }
php
{ "resource": "" }
q10959
TicketExtension.getEventExpired
train
public function getEventExpired() { $expired = false; if (($tickets = $this->owner->Tickets()) && $expired = $tickets->exists()) { /** @var Ticket $ticket */ foreach ($tickets as $ticket) { $expired = (!$ticket->validateDate() && $expired); } } return $expired; }
php
{ "resource": "" }
q10960
TicketExtension.getGuestList
train
public function getGuestList() { $reservationClass = Reservation::singleton()->getClassName(); $attendeeClass = Attendee::singleton()->getClassName(); return Attendee::get() ->leftJoin($reservationClass, "`$attendeeClass`.`ReservationID` = `$reservationClass`.`ID`") ->filter(array( 'EventID' => $this->owner->ID )) ->filterAny(array( 'ReservationID' => 0, 'Status' => Reservation::STATUS_PAID )); }
php
{ "resource": "" }
q10961
TicketExtension.getSuccessContent
train
public function getSuccessContent() { if (!empty($this->owner->SuccessMessage)) { return $this->owner->dbObject('SuccessMessage'); } else { return SiteConfig::current_site_config()->dbObject('SuccessMessage'); } }
php
{ "resource": "" }
q10962
TicketExtension.getMailContent
train
public function getMailContent() { if (!empty($this->owner->SuccessMessageMail)) { return $this->owner->dbObject('SuccessMessageMail'); } else { return SiteConfig::current_site_config()->dbObject('SuccessMessageMail'); } }
php
{ "resource": "" }
q10963
TicketExtension.canCreateTickets
train
public function canCreateTickets() { $currentDate = $this->owner->getController()->CurrentDate(); if ($currentDate && $currentDate->exists()) { return $currentDate->dbObject('StartDate')->InFuture(); } return false; }
php
{ "resource": "" }
q10964
TicketExtension.getController
train
public function getController() { return $this->controller ? $this->controller : $this->controller = CalendarEvent_Controller::create($this->owner); }
php
{ "resource": "" }
q10965
CachedObjectHandler.getDataCacheKey
train
public static function getDataCacheKey($data, Context $context) { $group = $context->hasAttribute('groups') ? $context->getAttribute('groups') : '*'; $version = $context->hasAttribute('version') ? $context->getAttribute('version') : '*'; $dataArray = [ 'data' => $data, 'serializationFormat' => $context->getFormat(), 'serializationGroups' => $group, 'serializationVersion' => $version, ]; try { return \sha1(\serialize($dataArray)); } catch (\Exception $e) { return; } }
php
{ "resource": "" }
q10966
MapQuery.filterByFilename
train
public function filterByFilename($filename = null, $comparison = null) { if (null === $comparison) { if (is_array($filename)) { $comparison = Criteria::IN; } } return $this->addUsingAlias(MapTableMap::COL_FILENAME, $filename, $comparison); }
php
{ "resource": "" }
q10967
MapQuery.filterByEnvironment
train
public function filterByEnvironment($environment = null, $comparison = null) { if (null === $comparison) { if (is_array($environment)) { $comparison = Criteria::IN; } } return $this->addUsingAlias(MapTableMap::COL_ENVIRONMENT, $environment, $comparison); }
php
{ "resource": "" }
q10968
MapQuery.filterByMood
train
public function filterByMood($mood = null, $comparison = null) { if (null === $comparison) { if (is_array($mood)) { $comparison = Criteria::IN; } } return $this->addUsingAlias(MapTableMap::COL_MOOD, $mood, $comparison); }
php
{ "resource": "" }
q10969
MapQuery.filterByBronzetime
train
public function filterByBronzetime($bronzetime = null, $comparison = null) { if (is_array($bronzetime)) { $useMinMax = false; if (isset($bronzetime['min'])) { $this->addUsingAlias(MapTableMap::COL_BRONZETIME, $bronzetime['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($bronzetime['max'])) { $this->addUsingAlias(MapTableMap::COL_BRONZETIME, $bronzetime['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(MapTableMap::COL_BRONZETIME, $bronzetime, $comparison); }
php
{ "resource": "" }
q10970
MapQuery.filterBySilvertime
train
public function filterBySilvertime($silvertime = null, $comparison = null) { if (is_array($silvertime)) { $useMinMax = false; if (isset($silvertime['min'])) { $this->addUsingAlias(MapTableMap::COL_SILVERTIME, $silvertime['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($silvertime['max'])) { $this->addUsingAlias(MapTableMap::COL_SILVERTIME, $silvertime['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(MapTableMap::COL_SILVERTIME, $silvertime, $comparison); }
php
{ "resource": "" }
q10971
MapQuery.filterByGoldtime
train
public function filterByGoldtime($goldtime = null, $comparison = null) { if (is_array($goldtime)) { $useMinMax = false; if (isset($goldtime['min'])) { $this->addUsingAlias(MapTableMap::COL_GOLDTIME, $goldtime['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($goldtime['max'])) { $this->addUsingAlias(MapTableMap::COL_GOLDTIME, $goldtime['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(MapTableMap::COL_GOLDTIME, $goldtime, $comparison); }
php
{ "resource": "" }
q10972
MapQuery.filterByAuthortime
train
public function filterByAuthortime($authortime = null, $comparison = null) { if (is_array($authortime)) { $useMinMax = false; if (isset($authortime['min'])) { $this->addUsingAlias(MapTableMap::COL_AUTHORTIME, $authortime['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($authortime['max'])) { $this->addUsingAlias(MapTableMap::COL_AUTHORTIME, $authortime['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(MapTableMap::COL_AUTHORTIME, $authortime, $comparison); }
php
{ "resource": "" }
q10973
MapQuery.filterByCopperprice
train
public function filterByCopperprice($copperprice = null, $comparison = null) { if (is_array($copperprice)) { $useMinMax = false; if (isset($copperprice['min'])) { $this->addUsingAlias(MapTableMap::COL_COPPERPRICE, $copperprice['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($copperprice['max'])) { $this->addUsingAlias(MapTableMap::COL_COPPERPRICE, $copperprice['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(MapTableMap::COL_COPPERPRICE, $copperprice, $comparison); }
php
{ "resource": "" }
q10974
MapQuery.filterByLaprace
train
public function filterByLaprace($laprace = null, $comparison = null) { if (is_string($laprace)) { $laprace = in_array(strtolower($laprace), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; } return $this->addUsingAlias(MapTableMap::COL_LAPRACE, $laprace, $comparison); }
php
{ "resource": "" }
q10975
MapQuery.filterByNblaps
train
public function filterByNblaps($nblaps = null, $comparison = null) { if (is_array($nblaps)) { $useMinMax = false; if (isset($nblaps['min'])) { $this->addUsingAlias(MapTableMap::COL_NBLAPS, $nblaps['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($nblaps['max'])) { $this->addUsingAlias(MapTableMap::COL_NBLAPS, $nblaps['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(MapTableMap::COL_NBLAPS, $nblaps, $comparison); }
php
{ "resource": "" }
q10976
MapQuery.filterByNpcheckpoints
train
public function filterByNpcheckpoints($npcheckpoints = null, $comparison = null) { if (is_array($npcheckpoints)) { $useMinMax = false; if (isset($npcheckpoints['min'])) { $this->addUsingAlias(MapTableMap::COL_NPCHECKPOINTS, $npcheckpoints['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($npcheckpoints['max'])) { $this->addUsingAlias(MapTableMap::COL_NPCHECKPOINTS, $npcheckpoints['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(MapTableMap::COL_NPCHECKPOINTS, $npcheckpoints, $comparison); }
php
{ "resource": "" }
q10977
MapQuery.filterByMapstyle
train
public function filterByMapstyle($mapstyle = null, $comparison = null) { if (null === $comparison) { if (is_array($mapstyle)) { $comparison = Criteria::IN; } } return $this->addUsingAlias(MapTableMap::COL_MAPSTYLE, $mapstyle, $comparison); }
php
{ "resource": "" }
q10978
MapQuery.filterByMxmap
train
public function filterByMxmap($mxmap, $comparison = null) { if ($mxmap instanceof \eXpansion\Bundle\Maps\Model\Mxmap) { return $this ->addUsingAlias(MapTableMap::COL_MAPUID, $mxmap->getTrackuid(), $comparison); } elseif ($mxmap instanceof ObjectCollection) { return $this ->useMxmapQuery() ->filterByPrimaryKeys($mxmap->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByMxmap() only accepts arguments of type \eXpansion\Bundle\Maps\Model\Mxmap or Collection'); } }
php
{ "resource": "" }
q10979
MapQuery.useMxmapQuery
train
public function useMxmapQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinMxmap($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Mxmap', '\eXpansion\Bundle\Maps\Model\MxmapQuery'); }
php
{ "resource": "" }
q10980
CommandHandlerResolver.resolveHandlingMethod
train
protected function resolveHandlingMethod($commandType) { // Remove namespace $pos = strrpos($commandType, '\\'); if ($pos !== false) { $commandType = substr($commandType, $pos + 1); } // Remove "Command" suffix if (substr($commandType, -7) === 'Command') { $commandType = substr($commandType, 0, -7); } return lcfirst($commandType); }
php
{ "resource": "" }
q10981
LogWrapper.getLogger
train
public static function getLogger($logName = 'default') { $filename = new LogConfigFilenameProcessor('log4php'); if (!$filename->Exists()) throw new NotFoundException('Log4php config file not found.'); else \Logger::configure($filename->FullQualifiedNameAndPath()); return \Logger::getLogger($logName); }
php
{ "resource": "" }
q10982
ChartDatumAbstract.offsetGet
train
public function offsetGet ($offset) { return isset($this->datumData[$offset]) ? $this->datumData[$offset] : false; }
php
{ "resource": "" }
q10983
AccessCheckFactory.create
train
public function create(array $data = array()) { if (!isset($data["configPathPrefix"])) { $data["configPathPrefix"] = $this->configPathPrefix; } return $this->_objectManager->create($this->_instanceName, $data); }
php
{ "resource": "" }
q10984
GameDataStorage.getServerOs
train
public function getServerOs() { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { return self::OS_WINDOWS; } else { if (strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') { return self::OS_MAC; } else { return self::OS_LINUX; } } }
php
{ "resource": "" }
q10985
SummaryController.SummaryForm
train
public function SummaryForm() { $summary = new SummaryForm($this, 'SummaryForm', ReservationSession::get()); $summary->setNextStep(CheckoutSteps::nextStep($this->step)); return $summary; }
php
{ "resource": "" }
q10986
Collection.offsetExists
train
public function offsetExists($offset) { if (!is_int($offset) && !is_string($offset)) { throw new RuntimeException('Invalid array offset type: '. gettype($offset)); } return array_key_exists($offset, $this->items); }
php
{ "resource": "" }
q10987
Collection.getItems
train
public function getItems(array $keys = []) { $items = []; foreach ($keys as $key) { $items[] = $this->offsetGet($key); } if (empty($keys)) { $items = $this->items; } return $items; }
php
{ "resource": "" }
q10988
Collection.removeItem
train
public function removeItem($item) { $key = $this->getKey($item); if ($key !== false) { $this->offsetUnset($key); } }
php
{ "resource": "" }
q10989
Collection.addListener
train
public function addListener(ListenerInterface $listener) { if (!in_array($listener, $this->collection_listeners, true)) { $this->collection_listeners[] = $listener; } }
php
{ "resource": "" }
q10990
Collection.removeListener
train
public function removeListener(ListenerInterface $listener) { if (false !== ($pos = array_search($listener, $this->collection_listeners, true))) { array_splice($this->collection_listeners, $pos, 1); } }
php
{ "resource": "" }
q10991
Collection.toArray
train
public function toArray() { $data = []; foreach ($this->items as $key => $value) { if ($value instanceof BaseObjectInterface) { $value = $value->toArray(); } $data[$key] = $value; } return $data; }
php
{ "resource": "" }
q10992
Collection.propagateCollectionChangedEvent
train
protected function propagateCollectionChangedEvent(CollectionChangedEvent $event) { foreach ($this->collection_listeners as $listener) { $listener->onCollectionChanged($event); } }
php
{ "resource": "" }
q10993
EloquentJournalVoucherGridRepository.numToLetter
train
protected function numToLetter($num, $uppercase = FALSE) { $num -= 1; $letter = chr(($num % 26) + 97); $letter .= (floor($num/26) > 0) ? str_repeat($letter, floor($num/26)) : ''; return ($uppercase ? strtoupper($letter) : $letter); }
php
{ "resource": "" }
q10994
EloquentJournalVoucherGridRepository.utf8ize
train
protected function utf8ize($mixed) { if (is_array($mixed)) { foreach ($mixed as $key => $value) { $mixed[$key] = self::utf8ize($value); } } else if (is_string ($mixed)) { return utf8_encode($mixed); } return $mixed; }
php
{ "resource": "" }
q10995
OAuthClient20.handle
train
public function handle() { // Get Var Elements $accessToken = $this->getAccessToken(); $state = $this->getVar("state"); // Initiate OAuth Client with Specific server configuration $to = new $this->_className(); // Try to Handle the Authentication Process if ($accessToken == "") { $code = $this->_context->get("code"); // If not received the "Code" Parameter, initiate the autorization request if ($code == "") { $state = md5(uniqid(rand(), TRUE)); //CSRF protection $this->setVar("state", $state); $params = array( "client_id" => $this->_client_id, "redirect_uri" => $this->_redirect_uri, "state" => $state, "scope" => $this->_scope ); if (count($this->_extraArgs) > 0) { $params = array_merge($params, $this->_extraArgs); } $req = new WebRequest($to->authorizationURL()); $req->redirect($params, $this->_window_top); } // Request the Access Token if ($this->_context->get("state") == $this->getVar("state")) { $params = array( "client_id" => $this->_client_id, "redirect_uri" => $this->_redirect_uri, "client_secret" => $this->_client_secret, "code" => $code, "grant_type" => "authorization_code" ); $req = new WebRequest($to->accessTokenURL()); $result = $req->post($params); $accessToken = $to->decodeAccessToken($result); $this->setVar("access_token", $accessToken); $to->setAccessToken($accessToken); $this->saveAccessToken(); if ($this->_app_uri != "") { $req = new WebRequest($this->_app_uri); $response = $req->redirect(); } } } else { $to->setAccessToken($this->getVar('access_token')); } return $to; }
php
{ "resource": "" }
q10996
ChatCommands.registerPlugin
train
public function registerPlugin($pluginId, ChatCommandPluginInterface $pluginService) { $commands = $pluginService->getChatCommands(); foreach ($commands as $command) { $this->addCommand($pluginId, $command->getCommand(), $command); foreach ($command->getAliases() as $alias) { $this->addCommand($pluginId, $alias, $command); } } }
php
{ "resource": "" }
q10997
ChatCommands.deletePlugin
train
public function deletePlugin($pluginId) { if (!isset($this->commandPlugin[$pluginId])) { return; } foreach ($this->commandPlugin[$pluginId] as $cmdTxt => $command) { unset($this->commands[$cmdTxt]); } unset($this->commandPlugin[$pluginId]); }
php
{ "resource": "" }
q10998
ChatCommands.getChatCommands
train
public function getChatCommands() { $chatCommands = []; foreach ($this->commands as $chatCommand => $data) { $chatCommands[$data->getCommand()] = clone $data; } return $chatCommands; }
php
{ "resource": "" }
q10999
ChatCommands.findChatCommand
train
protected function findChatCommand($cmdAndArgs, $depth, $orig = null) { if ($depth == 0) { return [null, []]; } if ($orig == null) { $orig = $cmdAndArgs; } $cmdAndArgs = array_splice($cmdAndArgs, 0, $depth); $parameters = array_diff($orig, $cmdAndArgs); $command = implode(' ', $cmdAndArgs); return isset($this->commands[$command]) ? [$this->commands[$command], $parameters] : $this->findChatCommand($cmdAndArgs, $depth - 1, $orig); }
php
{ "resource": "" }