_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q900 | FileOutputPrinter.setOutputPath | train | public function setOutputPath($path)
{
if (!file_exists($path)) {
if (!mkdir($path, 0755, true)) {
throw new BadOutputPathException(
sprintf(
'Output path %s does not exist and could not be created!',
$path
... | php | {
"resource": ""
} |
q901 | FoxyStripeController.processFoxyRequest | train | protected function processFoxyRequest(HTTPRequest $request)
{
$encryptedData = $request->postVar('FoxyData')
? urldecode($request->postVar('FoxyData'))
: urldecode($request->postVar('FoxySubscriptionData'));
$decryptedData = $this->decryptFeedData($encryptedData);
$t... | php | {
"resource": ""
} |
q902 | FoxyStripeController.parseFeedData | train | private function parseFeedData($encryptedData, $decryptedData)
{
$orders = new \SimpleXMLElement($decryptedData);
// loop over each transaction to find FoxyCart Order ID
foreach ($orders->transactions->transaction as $transaction) {
$this->processTransaction($transaction, $encry... | php | {
"resource": ""
} |
q903 | FoxyStripeController.sso | train | public function sso()
{
// GET variables from FoxyCart Request
$fcsid = $this->request->getVar('fcsid');
$timestampNew = strtotime('+30 days');
// get current member if logged in. If not, create a 'fake' user with Customer_ID = 0
// fake user will redirect to FC checkout, as... | php | {
"resource": ""
} |
q904 | Cluster.terminate | train | private static function terminate(): Promise
{
if (self::$onClose === null) {
return Promise\any([]);
}
if (self::$signalWatchers) {
foreach (self::$signalWatchers as $watcher) {
Loop::cancel($watcher);
}
}
$onClose = self... | php | {
"resource": ""
} |
q905 | Cluster.onReceivedMessage | train | private static function onReceivedMessage(string $event, $data)
{
foreach (self::$onMessage[$event] ?? [] as $callback) {
asyncCall($callback, $data);
}
} | php | {
"resource": ""
} |
q906 | Cluster.createLogHandler | train | public static function createLogHandler(string $logLevel = LogLevel::DEBUG, bool $bubble = false): HandlerInterface
{
if (!self::isWorker()) {
throw new \Error(__FUNCTION__ . " should only be called when running as a worker. " .
"Create your own log handler when not running as pa... | php | {
"resource": ""
} |
q907 | Util.prepareOptions | train | public static function prepareOptions($value, $defaults = [])
{
if (is_string($value)) {
$value = json_decode($value, true);
}
return is_array($value) ? array_merge($defaults, $value) : $defaults;
} | php | {
"resource": ""
} |
q908 | EzRSSAggregator.process | train | public function process(DOMElement $node, Item $item)
{
foreach ($this->keys as $key) {
$item->setExtra($key, $this->getValue($node, $key));
}
} | php | {
"resource": ""
} |
q909 | CustomerExtension.onAfterWrite | train | public function onAfterWrite()
{
parent::onAfterWrite();
if ($this->owner->PasswordEncryption != Security::config()->get('password_encryption_algorithm')) {
$this->resetPasswordEncryption();
}
} | php | {
"resource": ""
} |
q910 | CustomerExtension.setDataFromTransaction | train | public function setDataFromTransaction($transaction)
{
foreach ($this->owner->config()->get('customer_map') as $type => $map) {
switch ($type) {
case 'int':
foreach ($map as $foxyField => $foxyStripeField) {
if ((int)$transaction->{$fox... | php | {
"resource": ""
} |
q911 | CustomerExtension.resetPasswordEncryption | train | private function resetPasswordEncryption()
{
$defaultEncryption = Security::config()->get('password_encryption_algorithm');
if ($this->owner->PasswordEncryption != $defaultEncryption) {
DB::prepared_query(
'UPDATE "Member" SET "PasswordEncryption" = ? WHERE ID = ?',
... | php | {
"resource": ""
} |
q912 | ExtraFormBuilder.buildConstraint | train | protected function buildConstraint(array $constraint)
{
$extraFormConstraint = $this
->constraintRegistry
->getConstraint($constraint['extra_form_constraint'])
;
$className = $extraFormConstraint->getClassName();
$options = isset($constraint['options']) ? $co... | php | {
"resource": ""
} |
q913 | ExtraFormBuilder.buildFormOptions | train | protected function buildFormOptions($name, array $field, $data = null)
{
// Allow sub options structure (collection case)
if (isset($field['options']['constraints'])) {
$field['options']['options'] = $this->buildFormOptions('', $field['options']);
}
$constraints = array(... | php | {
"resource": ""
} |
q914 | DonationProductController.updatevalue | train | public function updatevalue(\SilverStripe\Control\HTTPRequest $request)
{
if ($request->getVar('Price') && FoxyStripeSetting::current_foxystripe_setting()->CartValidation) {
$vars = $request->getVars();
$signedPrice = FoxyCart_Helper::fc_hash_value($this->Code, 'price', $vars['Price'... | php | {
"resource": ""
} |
q915 | FastFeed.addFeed | train | public function addFeed($channel, $feed)
{
if (!filter_var($feed, FILTER_VALIDATE_URL)) {
throw new LogicException('You tried to add a invalid url.');
}
$this->feeds[$channel][] = $feed;
} | php | {
"resource": ""
} |
q916 | FastFeed.getFeed | train | public function getFeed($channel)
{
if (!isset($this->feeds[$channel])) {
throw new LogicException('You tried to get a not existent channel');
}
return $this->feeds[$channel];
} | php | {
"resource": ""
} |
q917 | FastFeed.setFeed | train | public function setFeed($channel, $feed)
{
if (!is_string($channel)) {
throw new LogicException('You tried to add a invalid channel.');
}
$this->feeds[$channel] = array();
$this->addFeed($channel, $feed);
} | php | {
"resource": ""
} |
q918 | FastFeed.get | train | protected function get($url)
{
$request = $this->http->get(
$url,
array('User-Agent' => self::USER_AGENT.' v.'.self::VERSION)
);
$response = $request->send();
if (!$response->isSuccessful()) {
$this->log('fail with '.$response->getStatusCode().' ... | php | {
"resource": ""
} |
q919 | Permutation.getPermutations | train | public function getPermutations(array $sourceDataSet, $subsetSize = null)
{
$combinationMap = $this->_combination->getCombinations($sourceDataSet, $subsetSize);
$permutationsMap = [];
foreach ($combinationMap as $combination) {
$permutationsMap = array_merge(
... | php | {
"resource": ""
} |
q920 | Permutation._findPermutations | train | private function _findPermutations($combination)
{
// If the combination only has 1 element, then the permutation is the same as the combination
if (count($combination) <= 1) {
return [$combination];
}
$permutationList = [];
$startKey = $this->_processSubPermuta... | php | {
"resource": ""
} |
q921 | ContentElement.generate | train | public function generate()
{
// Get the content element object
$this->objElement = \ElementsModel::findPublishedByAlias($this->type);
if ($this->objElement === null)
{
return;
}
// Register the custom template
if (!array_key_exists($this->objElement->template, TemplateLoader::getFiles()))
{
T... | php | {
"resource": ""
} |
q922 | ContentElement.compile | train | protected function compile()
{
// Get the pattern model collection
$colPattern = \PatternModel::findVisibleByPid($this->objElement->id);
if ($colPattern === null)
{
return;
}
// Get correct content element id (included content element) see #37
$intPid = ($this->origId) ? $this->origId : $this->i... | php | {
"resource": ""
} |
q923 | RequestHandler.setPath | train | protected static function setPath($path = null)
{
if (!static::$pathStack) {
$requestURI = parse_url($_SERVER['REQUEST_URI']);
static::$pathStack = static::$requestPath = explode('/', ltrim($requestURI['path'], '/'));
}
static::$_path = isset($path) ? $path : sta... | php | {
"resource": ""
} |
q924 | IbanToArrayTransformer.reverseTransform | train | public function reverseTransform($out)
{
if (null !== $out && is_array($out)) {
return strtoupper(
sprintf(
'%s%s%s%s%s%s%s%s',
$out['c1'],
$out['c2'],
$out['c3'],
$out['c4'],
... | php | {
"resource": ""
} |
q925 | tl_elements.setDefaultType | train | public function setDefaultType ($value, DataContainer $dc)
{
$db = Database::getInstance();
if ($value)
{
// There can only be one default element
$db->prepare("UPDATE tl_elements SET defaultType='' WHERE NOT id=? AND pid=?")
->execute($dc->activeRecord->id, $dc->activeRecord->pid);
}
retur... | php | {
"resource": ""
} |
q926 | tl_elements.checkTitle | train | public function checkTitle ($value, DataContainer $dc)
{
$db = Database::getInstance();
$objTitle = $db->prepare("SELECT id FROM tl_elements WHERE NOT id=? AND pid=? AND title=?")
->execute($dc->activeRecord->id, $dc->activeRecord->pid, $value);
if ($objTitle->numRows > 0)
{
throw new Exception(sp... | php | {
"resource": ""
} |
q927 | tl_elements.generateAlias | train | public function generateAlias (DataContainer $dc)
{
$db = Database::getInstance();
// Generate alias from theme name and title
$alias = \StringUtil::generateAlias(\ThemeModel::findById($dc->activeRecord->pid)->name . '-' . $dc->activeRecord->title);
if ($alias != $dc->activeRecord->alias)
{
// Save al... | php | {
"resource": ""
} |
q928 | tl_elements.getContentElementTemplates | train | public function getContentElementTemplates(DataContainer $dc)
{
$arrTemplates = array();
// Get the default templates
foreach (\TemplateLoader::getPrefixedFiles('ce_') as $strTemplate)
{
$arrTemplates[$strTemplate][] = 'root';
}
$arrCustomized = glob(TL_ROOT . '/templates/ce_*');
// Add the customi... | php | {
"resource": ""
} |
q929 | tl_elements.editButton | train | public function editButton($row, $href, $label, $title, $icon, $attributes)
{
switch ($row['type'])
{
case 'group':
return \Image::getHtml(str_replace('.', '_.', $icon), $label) . ' ';
case 'element':
return '<a href="'.$this->addToUrl($href.'&id='.$row['id']).'" title="'.\StringUtil::special... | php | {
"resource": ""
} |
q930 | ConfiguredTypeRepository.findByTags | train | public function findByTags(array $tags)
{
$qb = $this->createQueryBuilder('c');
foreach ($tags as $key => $tag) {
$operator = substr($tag, 0, 1);
if ($operator === '+' || $operator === '-') {
$tag = substr($tag, 1);
}
$literalExpr = ... | php | {
"resource": ""
} |
q931 | ConfiguredTypeRepository.getAllTags | train | public function getAllTags()
{
$qb = $this->createQueryBuilder('c');
$qb
->select('c.tags')
->where($qb->expr()->isNotNull('c.tags'))
->distinct()
;
$tagStrings = array_map('current', $qb->getQuery()->getScalarResult());
$distinctTags = a... | php | {
"resource": ""
} |
q932 | UserEndpoint.find | train | public function find($username)
{
$parameters['username'] = $username;
return $this->apiClient->callEndpoint(self::ENDPOINT, $parameters);
} | php | {
"resource": ""
} |
q933 | UserEndpoint.update | train | public function update($username, $parameters = array())
{
$parameters['username'] = $username;
return $this->apiClient->callEndpoint(
self::ENDPOINT,
$parameters,
null,
HttpMethod::REQUEST_PUT
);
} | php | {
"resource": ""
} |
q934 | UserEndpoint.add | train | public function add($username, $parameters = array())
{
$parameters['username'] = $username;
return $this->apiClient->callEndpoint(
self::ENDPOINT,
$parameters,
null,
HttpMethod::REQUEST_POST
);
} | php | {
"resource": ""
} |
q935 | UserEndpoint.findAvatars | train | public function findAvatars($username)
{
$parameters['username'] = $username;
return $this->apiClient->callEndpoint(sprintf('%s/avatars', self::ENDPOINT), $parameters);
} | php | {
"resource": ""
} |
q936 | UserEndpoint.updatePassword | train | public function updatePassword($username, $password)
{
$parameters['username'] = $username;
$parameters['password'] = $password;
return $this->apiClient->callEndpoint(
sprintf('%s/avatars', self::ENDPOINT),
$parameters,
null,
HttpMethod::REQUES... | php | {
"resource": ""
} |
q937 | UserEndpoint.picker | train | public function picker($query, $maxResults = null, $showAvatar = null, $exclude = null)
{
$parameters = array(
'query' => $query,
'maxResults' => $maxResults,
'showAvatar' => $showAvatar,
'exclude' => $exclude
);
return $this->apiClient->callEn... | php | {
"resource": ""
} |
q938 | UserEndpoint.search | train | public function search($username, $startAt = null, $maxResults = null, $includeActive = null, $includeInactive = null)
{
$parameters = array(
'username' => $username,
'startAt' => $startAt,
'maxResults' => $maxResults,
'includeActive' => $includeActive,
... | php | {
"resource": ""
} |
q939 | Versioning.getRevisionRecords | train | public static function getRevisionRecords($options = [])
{
$options = Util::prepareOptions($options, [
'indexField' => false,
'conditions' => [],
'order' => false,
'limit' => false,
'offset' => 0,
]);
$query = 'SELECT * FROM `%s` W... | php | {
"resource": ""
} |
q940 | Versioning.beforeVersionedSave | train | public function beforeVersionedSave()
{
$this->wasDirty = false;
if ($this->isDirty && static::$createRevisionOnSave) {
// update creation time
$this->Created = time();
$this->wasDirty = true;
}
} | php | {
"resource": ""
} |
q941 | Versioning.afterVersionedSave | train | public function afterVersionedSave()
{
if ($this->wasDirty && static::$createRevisionOnSave) {
// save a copy to history table
$recordValues = $this->_prepareRecordValues();
$set = static::_mapValuesToSet($recordValues);
DB::nonQuery(
'INSERT I... | php | {
"resource": ""
} |
q942 | AuthenticationEndpoint.authentication | train | public function authentication($username, $password)
{
$endpoint = sprintf('authentication?username=%s', urlencode($username));
$parameters['value'] = $password;
return $this->apiClient->callEndpoint(
$endpoint,
$parameters,
null,
HttpMethod::R... | php | {
"resource": ""
} |
q943 | ConfiguredType.getExtraFormConstraints | train | public function getExtraFormConstraints()
{
if (null === $this->extraFormType) {
return null;
}
$configurationArray = json_decode($this->configuration, true);
return $configurationArray['extra_form_constraints'];
} | php | {
"resource": ""
} |
q944 | CaptchaTheme._theme | train | protected function _theme($theme_name = NULL, $options = array())
{
if ( count($options) > 0 ) {
// Avoid invalid options passed via array
foreach ($options as $opt => $value) {
if ( !array_key_exists($opt, $this->_recaptchaOptions) ) {
unset($options[$opt]);
}
}
}
// Avoid empty values... | php | {
"resource": ""
} |
q945 | CaptchaTheme.i18n | train | protected function i18n($key = NULL, $path = NULL)
{
static $RECAPTCHA_LANG;
if ( $RECAPTCHA_LANG ) {
return isset($key) ? $RECAPTCHA_LANG[$key] : $RECAPTCHA_LANG;
}
if ( !isset($this->_recaptchaOptions['lang']) ) {
$language = $this->clientLang();
} else {
$language = $this->_recaptchaOptions['la... | php | {
"resource": ""
} |
q946 | CaptchaTheme.clientLang | train | public function clientLang()
{
if ( isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) {
$language = explode(',', preg_replace('/(;\s?q=[0-9\.]+)|\s/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE']))));
return strtolower($language[0]);
}
return;
} | php | {
"resource": ""
} |
q947 | ReCaptchaType.isEnabled | train | private function isEnabled()
{
if (!$this->enabled) {
return false;
}
if ($this->authorizationChecker) {
foreach ($this->trustedRoles as $trustedRole) {
if ($this->authorizationChecker->isGranted($trustedRole)) {
return false;
... | php | {
"resource": ""
} |
q948 | ActiveRecord.init | train | public static function init()
{
$className = get_called_class();
if (empty(static::$_fieldsDefined[$className])) {
static::_defineFields();
static::_initFields();
static::$_fieldsDefined[$className] = true;
}
if (empty(static::$_relationshipsDefin... | php | {
"resource": ""
} |
q949 | ActiveRecord.setValue | train | public function setValue($name, $value)
{
// handle field
if (static::fieldExists($name)) {
$this->_setFieldValue($name, $value);
}
// undefined
else {
return false;
}
} | php | {
"resource": ""
} |
q950 | ActiveRecord.create | train | public static function create($values = [], $save = false)
{
$className = get_called_class();
// create class
$ActiveRecord = new $className();
$ActiveRecord->setFields($values);
if ($save) {
$ActiveRecord->save();
}
return $ActiveRecord;
} | php | {
"resource": ""
} |
q951 | ActiveRecord.changeClass | train | public function changeClass($className = false, $fieldValues = false)
{
if (!$className) {
return $this;
}
$this->_record[static::_cn('Class')] = $className;
$ActiveRecord = new $className($this->_record, true, $this->isPhantom);
if ($fieldValues) {
... | php | {
"resource": ""
} |
q952 | ActiveRecord.setFields | train | public function setFields($values)
{
foreach ($values as $field => $value) {
$this->_setFieldValue($field, $value);
}
} | php | {
"resource": ""
} |
q953 | ActiveRecord.getData | train | public function getData()
{
$data = [];
foreach (static::$_classFields[get_called_class()] as $field => $options) {
$data[$field] = $this->_getFieldValue($field);
}
if ($this->validationErrors) {
$data['validationErrors'] = $this->validationErrors;
}... | php | {
"resource": ""
} |
q954 | ActiveRecord.save | train | public function save($deep = true)
{
// run before save
$this->beforeSave();
if (static::isVersioned()) {
$this->beforeVersionedSave();
}
// set created
if (static::fieldExists('Created') && (!$this->Created || ($this->Created == 'CURRENT_TIMESTAMP'))) {... | php | {
"resource": ""
} |
q955 | ActiveRecord.destroy | train | public function destroy()
{
if (static::isVersioned()) {
if (static::$createRevisionOnDestroy) {
// save a copy to history table
if ($this->fieldExists('Created')) {
$this->Created = time();
}
$recordValues = $t... | php | {
"resource": ""
} |
q956 | ActiveRecord.delete | train | public static function delete($id)
{
DB::nonQuery('DELETE FROM `%s` WHERE `%s` = %u', [
static::$tableName,
static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'),
$id,
], [static::class,'handleError']);
return DB::affectedRows() > 0;
} | php | {
"resource": ""
} |
q957 | ActiveRecord.getByID | train | public static function getByID($id)
{
$record = static::getRecordByField(static::$primaryKey ? static::$primaryKey : 'ID', $id, true);
return static::instantiateRecord($record);
} | php | {
"resource": ""
} |
q958 | ActiveRecord.getByField | train | public static function getByField($field, $value, $cacheIndex = false)
{
$record = static::getRecordByField($field, $value, $cacheIndex);
return static::instantiateRecord($record);
} | php | {
"resource": ""
} |
q959 | ActiveRecord.getRecordByField | train | public static function getRecordByField($field, $value, $cacheIndex = false)
{
$query = 'SELECT * FROM `%s` WHERE `%s` = "%s" LIMIT 1';
$params = [
static::$tableName,
static::_cn($field),
DB::escape($value),
];
if ($cacheIndex) {
$key... | php | {
"resource": ""
} |
q960 | ActiveRecord.getRecordByWhere | train | public static function getRecordByWhere($conditions, $options = [])
{
if (!is_array($conditions)) {
$conditions = [$conditions];
}
$options = Util::prepareOptions($options, [
'order' => false,
]);
// initialize conditions and order
$condition... | php | {
"resource": ""
} |
q961 | ActiveRecord.getAllByContextObject | train | public static function getAllByContextObject(ActiveRecord $Record, $options = [])
{
return static::getAllByContext($Record::$rootClass, $Record->getPrimaryKeyValue(), $options);
} | php | {
"resource": ""
} |
q962 | ActiveRecord.buildExtraColumns | train | public static function buildExtraColumns($columns)
{
if (!empty($columns)) {
if (is_array($columns)) {
foreach ($columns as $key => $value) {
return ', '.$value.' AS '.$key;
}
} else {
return ', ' . $columns;
... | php | {
"resource": ""
} |
q963 | ActiveRecord.buildHaving | train | public static function buildHaving($having)
{
if (!empty($having)) {
return ' HAVING (' . (is_array($having) ? join(') AND (', static::_mapConditions($having)) : $having) . ')';
}
} | php | {
"resource": ""
} |
q964 | ActiveRecord.getAllRecordsByWhere | train | public static function getAllRecordsByWhere($conditions = [], $options = [])
{
$className = get_called_class();
$options = Util::prepareOptions($options, [
'indexField' => false,
'order' => false,
'limit' => false,
'offset' => 0,
'calcFoun... | php | {
"resource": ""
} |
q965 | ActiveRecord.getAllRecords | train | public static function getAllRecords($options = [])
{
$options = Util::prepareOptions($options, [
'indexField' => false,
'order' => false,
'limit' => false,
'calcFoundRows' => false,
'offset' => 0,
]);
$query = 'SELECT '.($options[... | php | {
"resource": ""
} |
q966 | ActiveRecord.instantiateRecords | train | public static function instantiateRecords($records)
{
foreach ($records as &$record) {
$className = static::_getRecordClass($record);
$record = new $className($record);
}
return $records;
} | php | {
"resource": ""
} |
q967 | ActiveRecord.getFieldOptions | train | public static function getFieldOptions($field, $optionKey = false)
{
if ($optionKey) {
return static::$_classFields[get_called_class()][$field][$optionKey];
} else {
return static::$_classFields[get_called_class()][$field];
}
} | php | {
"resource": ""
} |
q968 | ActiveRecord.getColumnName | train | public static function getColumnName($field)
{
static::init();
if (!static::fieldExists($field)) {
throw new Exception('getColumnName called on nonexisting column: ' . get_called_class().'->'.$field);
}
return static::$_classFields[get_called_class()][$field]['columnName... | php | {
"resource": ""
} |
q969 | ActiveRecord.getValidationError | train | public function getValidationError($field)
{
// break apart path
$crumbs = explode('.', $field);
// resolve path recursively
$cur = &$this->_validationErrors;
while ($crumb = array_shift($crumbs)) {
if (array_key_exists($crumb, $cur)) {
$cur = &$c... | php | {
"resource": ""
} |
q970 | ActiveRecord._getRecordClass | train | protected static function _getRecordClass($record)
{
$static = get_called_class();
if (!static::fieldExists('Class')) {
return $static;
}
$columnName = static::_cn('Class');
if (!empty($record[$columnName]) && is_subclass_of($record[$columnName], $static)) {
... | php | {
"resource": ""
} |
q971 | ActiveRecord._getFieldValue | train | protected function _getFieldValue($field, $useDefault = true)
{
$fieldOptions = static::$_classFields[get_called_class()][$field];
if (isset($this->_record[$fieldOptions['columnName']])) {
$value = $this->_record[$fieldOptions['columnName']];
// apply type-dependent transfo... | php | {
"resource": ""
} |
q972 | ActiveRecord._setFieldValue | train | protected function _setFieldValue($field, $value)
{
// ignore setting versioning fields
if (static::isVersioned()) {
if (array_key_exists($field, static::$versioningFields)) {
return false;
}
}
if (!static::fieldExists($field)) {
r... | php | {
"resource": ""
} |
q973 | ElementsModel.findPublishedByAlias | train | public function findPublishedByAlias($strAlias, array $arrOptions=array())
{
$t = static::$strTable;
$arrColumns = array("$t.alias=? AND $t.invisible=''");
return static::findOneBy($arrColumns, $strAlias, $arrOptions);
} | php | {
"resource": ""
} |
q974 | CollectionEventSubscriber.preSubmitData | train | public function preSubmitData(FormEvent $event)
{
$form = $event->getForm();
$data = $event->getData();
if (null === $data || '' === $data) {
$data = array();
}
foreach ($form as $name => $child) {
if (!isset($data[$name])) {
$form->r... | php | {
"resource": ""
} |
q975 | CollectionEventSubscriber.buildCollection | train | public function buildCollection(FormEvent $event, $eventName)
{
$form = $event->getForm();
for ($i = 0; $i < $this->options['max_items']; ++$i) {
$required = $i < $this->options['min_items'] ? true : false;
$displayed = $i < $this->options['min_items'] || $this->isDisplayabl... | php | {
"resource": ""
} |
q976 | CollectionEventSubscriber.changeData | train | public function changeData(FormEvent $event)
{
$data = $event->getData();
if (null === $data) {
$data = array();
}
if ($data instanceof \Doctrine\Common\Collections\Collection) {
$event->setData($data->getValues());
} else {
$event->setDa... | php | {
"resource": ""
} |
q977 | CollectionEventSubscriber.onSubmit | train | public function onSubmit(FormEvent $event)
{
$form = $event->getForm();
$data = $event->getData();
if (null === $data) {
$data = array();
}
if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
throw new Unexpec... | php | {
"resource": ""
} |
q978 | CollectionEventSubscriber.isDisplayable | train | protected function isDisplayable(FormEvent $event, $i, $eventName)
{
$form = $event->getForm();
$data = $event->getData();
if (!isset($data[$i])) {
return false;
}
$item = is_object($data[$i]) ? (array) $data[$i] : $data[$i];
if (!is_array($item)) {
... | php | {
"resource": ""
} |
q979 | SQL.getCreateTable | train | public static function getCreateTable($recordClass, $historyVariant = false)
{
$indexes = $historyVariant ? [] : $recordClass::$indexes;
$fulltextColumns = [];
$queryString = [];
// history table revisionID field
if ($historyVariant) {
$queryString[] = '`Revisio... | php | {
"resource": ""
} |
q980 | Watcher.stop | train | public function stop()
{
if (!$this->running) {
return;
}
$this->running = false;
$promise = call(function () {
$promises = [];
foreach (clone $this->workers as $worker) {
\assert($worker instanceof Internal\IpcParent);
... | php | {
"resource": ""
} |
q981 | MySQL.escape | train | public static function escape($data)
{
if (is_string($data)) {
$data = static::getConnection()->quote($data);
$data = substr($data, 1, strlen($data)-2);
return $data;
} elseif (is_array($data)) {
foreach ($data as $key=>$string) {
if (i... | php | {
"resource": ""
} |
q982 | MySQL.allRecords | train | public static function allRecords($query, $parameters = [], $errorHandler = null)
{
// execute query
$result = static::query($query, $parameters, $errorHandler);
$records = [];
while ($record = $result->fetch(PDO::FETCH_ASSOC)) {
$records[] = $record;
}
... | php | {
"resource": ""
} |
q983 | MySQL.allValues | train | public static function allValues($valueKey, $query, $parameters = [], $errorHandler = null)
{
// execute query
$result = static::query($query, $parameters, $errorHandler);
$records = [];
while ($record = $result->fetch(PDO::FETCH_ASSOC)) {
$records[] = $record[$valueKey]... | php | {
"resource": ""
} |
q984 | MySQL.oneRecordCached | train | public static function oneRecordCached($cacheKey, $query, $parameters = [], $errorHandler = null)
{
// check for cached record
if (array_key_exists($cacheKey, static::$_record_cache)) {
// return cache hit
return static::$_record_cache[$cacheKey];
}
// prepr... | php | {
"resource": ""
} |
q985 | MySQL.oneRecord | train | public static function oneRecord($query, $parameters = [], $errorHandler = null)
{
// preprocess and execute query
$result = static::query($query, $parameters, $errorHandler);
// get record
$record = $result->fetch(PDO::FETCH_ASSOC);
// return record
return $record;... | php | {
"resource": ""
} |
q986 | MySQL.oneValue | train | public static function oneValue($query, $parameters = [], $errorHandler = null)
{
// get the first record
$record = static::oneRecord($query, $parameters, $errorHandler);
if ($record) {
// return first value of the record
return array_shift($record);
} else {... | php | {
"resource": ""
} |
q987 | MySQL.handleError | train | public static function handleError($query = '', $queryLog = false, $errorHandler = null)
{
if (is_callable($errorHandler, false, $callable)) {
return call_user_func($errorHandler, $query, $queryLog);
}
// save queryLog
if ($queryLog) {
$error = static::getCon... | php | {
"resource": ""
} |
q988 | MySQL.preprocessQuery | train | protected static function preprocessQuery($query, $parameters = [])
{
if (is_array($parameters) && count($parameters)) {
return vsprintf($query, $parameters);
} else {
if (isset($parameters)) {
return sprintf($query, $parameters);
} else {
... | php | {
"resource": ""
} |
q989 | MySQL.finishQueryLog | train | protected static function finishQueryLog(&$queryLog, $result = false)
{
if ($queryLog == false) {
return false;
}
// save finish time and number of affected rows
$queryLog['time_finish'] = sprintf('%f', microtime(true));
$queryLog['time_duration_ms'] = ($queryLog... | php | {
"resource": ""
} |
q990 | RequestSerializer.serialize | train | public static function serialize(RequestInterface $request): string
{
return self::requestLine($request).self::headers($request).$request->getBody();
} | php | {
"resource": ""
} |
q991 | BelongsTo.getContent | train | public function getContent()
{
return strtr($this->getRelationStubContent(), [
'{{name}}' => $this->name,
'{{relatedTable}}' => $this->relatedModel->getTable(),
'{{relatedModel}}' => $this->relatedModel->getClass(),
'{{foreignKey}}' => $this->foreign... | php | {
"resource": ""
} |
q992 | ThrottlingMiddleware.safeHandle | train | protected function safeHandle(Request $request, Closure $next, int $limit, $decay, bool $global, bool $headers)
{
if ($this->shouldPassThrough($request)) {
return $next($request);
}
$key = $global ? sha1($request->ip()) : $request->fingerprint();
if ($this->limiter->too... | php | {
"resource": ""
} |
q993 | RecordsRequestHandler.handleRequest | train | public static function handleRequest()
{
// save static class
static::$calledClass = get_called_class();
// handle JSON requests
if (static::peekPath() == 'json') {
// check access for API response modes
static::$responseMode = static::shiftPath();
... | php | {
"resource": ""
} |
q994 | Controller.addContentElementsCSS | train | public function addContentElementsCSS ($strBuffer='', $objTemplate=null)
{
foreach (array('CSS', 'SCSS' , 'LESS') as $strType)
{
if ($GLOBALS['TL_CTB_' . $strType] == '')
{
continue;
}
$strKey = substr(md5($strType . $GLOBALS['TL_CTB_CSS'] . $GLOBALS['TL_CTB_SCSS'] . $GLOBALS['TL_CTB_LESS']), 0, 1... | php | {
"resource": ""
} |
q995 | Controller.addContentElementsJS | train | public function addContentElementsJS ($strBuffer='', $objTemplate=null)
{
if ($GLOBALS['TL_CTB_JS'] == '')
{
return $strBuffer;
}
$strKey = substr(md5('js' . $GLOBALS['TL_CTB_JS']), 0, 12);
$strPath = 'assets/js/' . $strKey . '.js';
// Write to a temporary file in the assets folder
if (!file_exist... | php | {
"resource": ""
} |
q996 | Controller.registerBlockElements | train | public function registerBlockElements ()
{
// Don´t register twice
if (isset($GLOBALS['TL_CTE']['CTE']))
{
return;
}
$db = \Database::getInstance();
if ($db->tableExists("tl_elements"))
{
$arrElements = $db->prepare("SELECT * FROM tl_elements ORDER BY sorting ASC")
->execute()
... | php | {
"resource": ""
} |
q997 | Controller.getRootPageId | train | public static function getRootPageId ($strTable, $intId)
{
if ($strTable == 'tl_article')
{
$objArticle = \ArticleModel::findById($intId);
if ($objArticle === null)
{
return null;
}
$objPage = \PageModel::findWithDetails($objArticle->pid);
if ($objPage === null)
{
return null;
... | php | {
"resource": ""
} |
q998 | Controller.addBackendCSS | train | private static function addBackendCSS($objLayout)
{
$arrCSS = \StringUtil::deserialize($objLayout->backendCSS);
if (!empty($arrCSS) && is_array($arrCSS))
{
// Consider the sorting order (see #5038)
if ($objLayout->orderBackendCSS != '')
{
$tmp = \StringUtil::deserialize($objLayout->orderBackendCS... | php | {
"resource": ""
} |
q999 | Controller.addBackendJS | train | private static function addBackendJS($objLayout)
{
$arrJS = \StringUtil::deserialize($objLayout->backendJS);
if (!empty($arrJS) && is_array($arrJS))
{
// Consider the sorting order (see #5038)
if ($objLayout->orderBackendJS != '')
{
$tmp = \StringUtil::deserialize($objLayout->orderBackendJS);
... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.