_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q18000 | Form.getRequest | train | protected function getRequest()
{
// Check if current request handler has a request object
$controller = $this->getController();
if ($controller && !($controller->getRequest() instanceof NullHTTPRequest)) {
return $controller->getRequest();
}
// Fall back | php | {
"resource": ""
} |
q18001 | Form.getSessionValidationResult | train | public function getSessionValidationResult()
{
$resultData = $this->getSession()->get("FormInfo.{$this->FormName()}.result");
| php | {
"resource": ""
} |
q18002 | Form.setSessionValidationResult | train | public function setSessionValidationResult(ValidationResult $result, $combineWithExisting = false)
{
// Combine with existing result
if ($combineWithExisting) {
$existingResult = $this->getSessionValidationResult();
if ($existingResult) {
if ($result) {
... | php | {
"resource": ""
} |
q18003 | Form.setFieldMessage | train | public function setFieldMessage(
$fieldName,
$message,
$messageType = ValidationResult::TYPE_ERROR,
$messageCast = ValidationResult::CAST_TEXT
) {
$field = $this->fields->dataFieldByName($fieldName);
| php | {
"resource": ""
} |
q18004 | Form.setupDefaultClasses | train | protected function setupDefaultClasses()
{
$defaultClasses = self::config()->get('default_classes');
if ($defaultClasses) {
| php | {
"resource": ""
} |
q18005 | Form.actionIsValidationExempt | train | public function actionIsValidationExempt($action)
{
// Non-actions don't bypass validation
if (!$action) {
return false;
}
if ($action->getValidationExempt()) {
return true;
| php | {
"resource": ""
} |
q18006 | Form.Fields | train | public function Fields()
{
foreach ($this->getExtraFields() as $field) {
if (!$this->fields->fieldByName($field->getName())) { | php | {
"resource": ""
} |
q18007 | Form.getAttributesHTML | train | public function getAttributesHTML($attrs = null)
{
$exclude = (is_string($attrs)) ? func_get_args() : null;
$attrs = $this->getAttributes();
// Remove empty
$attrs = array_filter((array)$attrs, function ($value) {
return ($value || $value === 0);
});
//... | php | {
"resource": ""
} |
q18008 | Form.getEncType | train | public function getEncType()
{
if ($this->encType) {
return $this->encType;
}
if ($fields = $this->fields->dataFields()) {
foreach ($fields as $field) {
if ($field | php | {
"resource": ""
} |
q18009 | Form.sessionMessage | train | public function sessionMessage($message, $type = ValidationResult::TYPE_ERROR, $cast = ValidationResult::CAST_TEXT)
{
$this->setMessage($message, $type, $cast);
$result = $this->getSessionValidationResult() ?: ValidationResult::create();
| php | {
"resource": ""
} |
q18010 | Form.sessionError | train | public function sessionError($message, $type = ValidationResult::TYPE_ERROR, $cast = ValidationResult::CAST_TEXT)
{
$this->setMessage($message, $type, $cast);
$result = $this->getSessionValidationResult() ?: ValidationResult::create();
| php | {
"resource": ""
} |
q18011 | Form.forTemplate | train | public function forTemplate()
{
if (!$this->canBeCached()) {
HTTPCacheControlMiddleware::singleton()->disableCache();
| php | {
"resource": ""
} |
q18012 | Form.canBeCached | train | protected function canBeCached()
{
if ($this->getSecurityToken()->isEnabled()) {
return false;
}
if ($this->FormMethod() !== 'GET') {
return false;
}
// Don't cache if there are required fields, or some other complex validator
$validator = $th... | php | {
"resource": ""
} |
q18013 | MySQLiConnector.prepareStatement | train | public function prepareStatement($sql, &$success)
{
// Record last statement for error reporting
| php | {
"resource": ""
} |
q18014 | MySQLiConnector.parsePreparedParameters | train | public function parsePreparedParameters($parameters, &$blobs)
{
$types = '';
$values = array();
$blobs = array();
$parametersCount = count($parameters);
for ($index = 0; $index < $parametersCount; $index++) {
$value = $parameters[$index];
$phpType = ge... | php | {
"resource": ""
} |
q18015 | MySQLiConnector.bindParameters | train | public function bindParameters(mysqli_stmt $statement, array $parameters)
{
// Because mysqli_stmt::bind_param arguments must be passed by reference
// we need to do a bit of hackery
$boundNames = [];
$parametersCount = count($parameters);
for ($i = 0; $i < $parametersCount; ... | php | {
"resource": ""
} |
q18016 | DBTime.Short | train | public function Short()
{
if (!$this->value) {
return null;
}
| php | {
"resource": ""
} |
q18017 | DBTime.Format | train | public function Format($format)
{
if (!$this->value) {
return null;
}
$formatter = $this->getFormatter();
| php | {
"resource": ""
} |
q18018 | DBTime.FormatFromSettings | train | public function FormatFromSettings($member = null)
{
if (!$member) {
$member = Security::getCurrentUser();
}
// Fall back to nice
if (!$member) {
return | php | {
"resource": ""
} |
q18019 | DB.get_conn | train | public static function get_conn($name = 'default')
{
if (isset(self::$connections[$name])) {
return self::$connections[$name];
}
// lazy connect
$config = static::getConfig($name);
| php | {
"resource": ""
} |
q18020 | DB.get_schema | train | public static function get_schema($name = 'default')
{
$connection = self::get_conn($name);
if ($connection) {
| php | {
"resource": ""
} |
q18021 | DB.get_connector | train | public static function get_connector($name = 'default')
{
$connection = self::get_conn($name);
if ($connection) {
| php | {
"resource": ""
} |
q18022 | DB.set_alternative_database_name | train | public static function set_alternative_database_name($name = null)
{
// Ignore if disabled
if (!Config::inst()->get(static::class, 'alternative_database_enabled')) {
return;
}
// Skip if CLI
if (Director::is_cli()) {
return;
}
// Valida... | php | {
"resource": ""
} |
q18023 | DB.get_alternative_database_name | train | public static function get_alternative_database_name()
{
// Ignore if disabled
if (!Config::inst()->get(static::class, 'alternative_database_enabled')) {
return false;
}
// Skip if CLI
if (Director::is_cli()) {
return false;
}
// Skip i... | php | {
"resource": ""
} |
q18024 | DB.valid_alternative_database_name | train | public static function valid_alternative_database_name($name)
{
if (Director::isLive() || empty($name)) {
return false;
| php | {
"resource": ""
} |
q18025 | DB.connect | train | public static function connect($databaseConfig, $label = 'default')
{
// This is used by the "testsession" module to test up a test session using an alternative name
if ($name = self::get_alternative_database_name()) {
$databaseConfig['database'] = $name;
}
if (!isset($d... | php | {
"resource": ""
} |
q18026 | DB.create_field | train | public static function create_field($table, $field, $spec)
{
| php | {
"resource": ""
} |
q18027 | Query.column | train | public function column($column = null)
{
$result = array();
while ($record = $this->next()) {
if ($column) {
$result[] = $record[$column];
} | php | {
"resource": ""
} |
q18028 | Query.keyedColumn | train | public function keyedColumn()
{
$column = array();
foreach ($this as $record) {
$val = $record[key($record)];
| php | {
"resource": ""
} |
q18029 | Query.map | train | public function map()
{
$column = array();
foreach ($this as $record) {
| php | {
"resource": ""
} |
q18030 | Query.table | train | public function table()
{
$first = true;
$result = "<table>\n";
foreach ($this as $record) {
if ($first) {
$result .= "<tr>";
foreach ($record as $k => $v) {
$result .= "<th>" . Convert::raw2xml($k) . "</th> ";
... | php | {
"resource": ""
} |
q18031 | InheritedPermissions.flushMemberCache | train | public function flushMemberCache($memberIDs = null)
{
if (!$this->cacheService) {
return;
}
// Hard flush, e.g. flush=1
if (!$memberIDs) {
$this->cacheService->clear();
}
if ($memberIDs && is_array($memberIDs)) {
foreach ([self::V... | php | {
"resource": ""
} |
q18032 | InheritedPermissions.prePopulatePermissionCache | train | public function prePopulatePermissionCache($permission = 'edit', $ids = [])
{
switch ($permission) {
case self::EDIT:
$this->canEditMultiple($ids, Security::getCurrentUser(), false);
break;
case self::VIEW:
| php | {
"resource": ""
} |
q18033 | InheritedPermissions.checkDefaultPermissions | train | protected function checkDefaultPermissions($type, Member $member = null)
{
$defaultPermissions = $this->getDefaultPermissions();
if (!$defaultPermissions) {
return false;
}
switch ($type) {
| php | {
"resource": ""
} |
q18034 | InheritedPermissions.isVersioned | train | protected function isVersioned()
{
if (!class_exists(Versioned::class)) {
return false;
}
/** @var Versioned|DataObject $singleton */
| php | {
"resource": ""
} |
q18035 | InheritedPermissions.getCachePermissions | train | protected function getCachePermissions($cacheKey)
{
// Check local cache
if (isset($this->cachePermissions[$cacheKey])) {
return $this->cachePermissions[$cacheKey];
}
// Check persistent cache
if ($this->cacheService) {
$result = $this->cacheService->... | php | {
"resource": ""
} |
q18036 | ManyManyThroughQueryManipulator.extractInheritableQueryParameters | train | public function extractInheritableQueryParameters(DataQuery $query)
{
$params = $query->getQueryParams();
// Remove `Foreign.` query parameters for created objects,
// as this would interfere with relations on those objects.
foreach (array_keys($params) as $key) {
if (st... | php | {
"resource": ""
} |
q18037 | MySQLStatement.bind | train | protected function bind()
{
$variables = array();
// Bind each field
while ($field = $this->metadata->fetch_field()) {
$this->columns[] = $field->name;
$this->types[$field->name] = $field->type;
// Note that while boundValues isn't initialised at this poi... | php | {
"resource": ""
} |
q18038 | SearchFilter.addRelation | train | protected function addRelation($name)
{
if (strstr($name, '.')) {
$parts = explode('.', $name);
$this->name = array_pop($parts);
| php | {
"resource": ""
} |
q18039 | SearchFilter.setModifiers | train | public function setModifiers(array $modifiers)
{
$modifiers = array_map('strtolower', $modifiers);
// Validate modifiers are supported
$allowed = $this->getSupportedModifiers();
$unsupported = array_diff($modifiers, $allowed);
if ($unsupported) {
throw | php | {
"resource": ""
} |
q18040 | SearchFilter.getDbName | train | public function getDbName()
{
// Special handler for "NULL" relations
if ($this->name === "NULL") {
return $this->name;
}
// Ensure that we're dealing with a DataObject.
if (!is_subclass_of($this->model, DataObject::class)) {
throw new InvalidArgument... | php | {
"resource": ""
} |
q18041 | SearchFilter.getDbFormattedValue | train | public function getDbFormattedValue()
{
// SRM: This code finds the table where the field named $this->name lives
// Todo: move to somewhere more appropriate, such as DataMapper, the magical class-to-be?
if ($this->aggregate) {
return intval($this->value);
| php | {
"resource": ""
} |
q18042 | SearchFilter.applyAggregate | train | public function applyAggregate(DataQuery $query, $having)
{
$schema = DataObject::getSchema();
| php | {
"resource": ""
} |
q18043 | SearchFilter.exclude | train | public function exclude(DataQuery $query)
{
if (($key = array_search('not', $this->modifiers)) !== false) {
unset($this->modifiers[$key]);
return $this->apply($query);
}
if (is_array($this->value)) {
| php | {
"resource": ""
} |
q18044 | DBConnector.databaseError | train | protected function databaseError($msg, $errorLevel = E_USER_ERROR, $sql = null, $parameters = array())
{
// Prevent errors when error checking is set at zero level
if (empty($errorLevel)) {
return;
}
// Format query if given
if (!empty($sql)) {
$forma... | php | {
"resource": ""
} |
q18045 | DBConnector.isQueryDDL | train | public function isQueryDDL($sql)
{
$operations = Config::inst()->get(static::class, | php | {
"resource": ""
} |
q18046 | DBConnector.isQueryType | train | protected function isQueryType($sql, $type)
{
if (!preg_match('/^(?<operation>\w+)\b/', $sql, $matches)) {
return false;
}
$operation = $matches['operation'];
if (is_array($type)) {
| php | {
"resource": ""
} |
q18047 | DBConnector.parameterValues | train | protected function parameterValues($parameters)
{
$values = array();
foreach ($parameters as $value) {
$values[] = | php | {
"resource": ""
} |
q18048 | SecurityToken.getSession | train | protected function getSession()
{
$injector = Injector::inst();
if ($injector->has(HTTPRequest::class)) {
return $injector->get(HTTPRequest::class)->getSession();
} elseif (Controller::has_curr()) {
| php | {
"resource": ""
} |
q18049 | SecurityToken.getRequestToken | train | protected function getRequestToken($request)
{
$name = $this->getName();
$header = 'X-' . ucwords(strtolower($name));
if ($token = $request->getHeader($header)) {
| php | {
"resource": ""
} |
q18050 | DBString.setOptions | train | public function setOptions(array $options = [])
{
parent::setOptions($options);
if (array_key_exists('nullifyEmpty', $options)) {
$this->options['nullifyEmpty'] = (bool) $options['nullifyEmpty'];
| php | {
"resource": ""
} |
q18051 | DBString.LimitCharactersToClosestWord | train | public function LimitCharactersToClosestWord($limit = 20, $add = '...')
{
// Safely convert to plain text
$value = $this->Plain();
// Determine if value exceeds limit before limiting characters
if (mb_strlen($value) <= $limit) {
| php | {
"resource": ""
} |
q18052 | DBString.LimitWordCount | train | public function LimitWordCount($numWords = 26, $add = '...')
{
$value = $this->Plain();
$words = explode(' ', $value);
if (count($words) <= $numWords) {
return $value;
} | php | {
"resource": ""
} |
q18053 | SSViewer_Scope.locally | train | public function locally()
{
list(
$this->item,
$this->itemIterator,
$this->itemIteratorTotal,
$this->popIndex,
$this->upIndex,
$this->currentIndex
) = $this->itemStack[$this->localIndex];
// Remember any un-completed (... | php | {
"resource": ""
} |
q18054 | SSViewer_Scope.resetLocalScope | train | public function resetLocalScope()
{
// Restore previous un-completed lookup chain if set
$previousLocalState = $this->localStack ? array_pop($this->localStack) : null;
array_splice($this->itemStack, $this->localIndex + 1, count($this->itemStack), $previousLocalState);
list(
... | php | {
"resource": ""
} |
q18055 | SSViewer_Scope.self | train | public function self()
{
$result = $this->itemIterator ? $this->itemIterator->current() : $this->item;
| php | {
"resource": ""
} |
q18056 | SSViewer_Scope.next | train | public function next()
{
if (!$this->item) {
return false;
}
if (!$this->itemIterator) {
if (is_array($this->item)) {
$this->itemIterator = new ArrayIterator($this->item);
} else {
$this->itemIterator = $this->item->getIter... | php | {
"resource": ""
} |
q18057 | TempDatabase.isDBTemp | train | protected function isDBTemp($name)
{
$prefix = Environment::getEnv('SS_DATABASE_PREFIX') ?: 'ss_';
$result = preg_match(
| php | {
"resource": ""
} |
q18058 | TempDatabase.rollbackTransaction | train | public function rollbackTransaction()
{
// Ensure a rollback can be performed
$success = static::getConn()->supportsTransactions()
&& static::getConn()->transactionDepth();
if (!$success) {
| php | {
"resource": ""
} |
q18059 | TempDatabase.kill | train | public function kill()
{
// Nothing to kill
if (!$this->isUsed()) {
return;
}
// Rollback any transactions (note: Success ignored)
$this->rollbackTransaction();
// Check the database actually exists
$dbConn = $this->getConn();
$dbName = $... | php | {
"resource": ""
} |
q18060 | TempDatabase.clearAllData | train | public function clearAllData()
{
if (!$this->isUsed()) {
return;
}
$this->getConn()->clearAllData();
// Some DataExtensions keep a static cache of information that needs to
// be reset whenever the database is cleaned out
$classes = array_merge(
... | php | {
"resource": ""
} |
q18061 | TempDatabase.build | train | public function build()
{
// Disable PHPUnit error handling
$oldErrorHandler = set_error_handler(null);
// Create a temporary database, and force the connection to use UTC for time
$dbConn = $this->getConn();
$prefix = Environment::getEnv('SS_DATABASE_PREFIX') ?: 'ss_';
... | php | {
"resource": ""
} |
q18062 | TempDatabase.rebuildTables | train | protected function rebuildTables($extraDataObjects = [])
{
DataObject::reset();
// clear singletons, they're caching old extension info which is used in DatabaseAdmin->doBuild()
Injector::inst()->unregisterObjects(DataObject::class);
$dataClasses = ClassInfo::subclassesFor(DataObje... | php | {
"resource": ""
} |
q18063 | TempDatabase.deleteAll | train | public function deleteAll()
{
$schema = $this->getConn()->getSchemaManager();
foreach ($schema->databaseList() as $dbName) {
if ($this->isDBTemp($dbName)) {
$schema->dropDatabase($dbName);
| php | {
"resource": ""
} |
q18064 | TempDatabase.resetDBSchema | train | public function resetDBSchema(array $extraDataObjects = [])
{
// Skip if no DB
if (!$this->isUsed()) {
return;
}
try {
$this->rebuildTables($extraDataObjects);
} catch (DatabaseException $ex) {
// In case of error during build force a hard... | php | {
"resource": ""
} |
q18065 | AllowedHostsMiddleware.setAllowedHosts | train | public function setAllowedHosts($allowedHosts)
{
if (is_string($allowedHosts)) {
$allowedHosts = preg_split('/ *, */', $allowedHosts);
| php | {
"resource": ""
} |
q18066 | Debug.caller | train | public static function caller()
{
$bt = debug_backtrace();
$caller = isset($bt[2]) ? $bt[2] : array();
$caller['line'] = $bt[1]['line'];
$caller['file'] = $bt[1]['file'];
if (!isset($caller['class'])) {
$caller['class'] = '';
}
| php | {
"resource": ""
} |
q18067 | Debug.endshow | train | public static function endshow($val, $showHeader = true, HTTPRequest $request = null)
{
// Don't show on live
if (Director::isLive()) | php | {
"resource": ""
} |
q18068 | Debug.message | train | public static function message($message, $showHeader = true, HTTPRequest $request = null)
{
// Don't show on live
if (Director::isLive()) {
return;
}
| php | {
"resource": ""
} |
q18069 | Debug.create_debug_view | train | public static function create_debug_view(HTTPRequest $request = null)
{
$service = static::supportsHTML($request)
? DebugView::class
| php | {
"resource": ""
} |
q18070 | Debug.supportsHTML | train | protected static function supportsHTML(HTTPRequest $request = null)
{
// No HTML output in CLI
if (Director::is_cli()) {
return false;
}
// Get current request if registered
if (!$request && Injector::inst()->has(HTTPRequest::class)) {
$request = Inje... | php | {
"resource": ""
} |
q18071 | Debug.require_developer_login | train | public static function require_developer_login()
{
// Don't require login for dev mode
if (Director::isDev()) {
return;
}
if (isset($_SESSION['loggedInAs'])) {
// We have to do some raw SQL here, because this method is called in Object::defineMethods().
... | php | {
"resource": ""
} |
q18072 | Requirements_Backend.javascript | train | public function javascript($file, $options = array())
{
$file = ModuleResourceLoader::singleton()->resolvePath($file);
// Get type
$type = null;
if (isset($this->javascript[$file]['type'])) {
$type = $this->javascript[$file]['type'];
}
if (isset($options[... | php | {
"resource": ""
} |
q18073 | Requirements_Backend.customScript | train | public function customScript($script, $uniquenessID = null)
{
if ($uniquenessID) {
$this->customScript[$uniquenessID] = $script;
| php | {
"resource": ""
} |
q18074 | Requirements_Backend.customCSS | train | public function customCSS($script, $uniquenessID = null)
{
if ($uniquenessID) {
$this->customCSS[$uniquenessID] = $script;
| php | {
"resource": ""
} |
q18075 | Requirements_Backend.css | train | public function css($file, $media = null)
{
$file = ModuleResourceLoader::singleton()->resolvePath($file);
| php | {
"resource": ""
} |
q18076 | Requirements_Backend.clear | train | public function clear($fileOrID = null)
{
$types = [
'javascript',
'css',
'customScript',
'customCSS',
'customHeadTags',
'combinedFiles',
];
foreach ($types as $type) {
if ($fileOrID) {
if (is... | php | {
"resource": ""
} |
q18077 | Requirements_Backend.block | train | public function block($fileOrID)
{
if (is_string($fileOrID)) {
$fileOrID | php | {
"resource": ""
} |
q18078 | Requirements_Backend.includeInResponse | train | public function includeInResponse(HTTPResponse $response)
{
$this->processCombinedFiles();
$jsRequirements = array();
$cssRequirements = array();
foreach ($this->getJavascript() as $file => $attributes) {
$path = $this->pathForFile($file);
if ($path) {
... | php | {
"resource": ""
} |
q18079 | Requirements_Backend.pathForFile | train | protected function pathForFile($fileOrUrl)
{
// Since combined urls could be root relative, treat them as urls here.
if (preg_match('{^(//)|(http[s]?:)}', $fileOrUrl) || Director::is_root_relative_url($fileOrUrl)) {
return $fileOrUrl; | php | {
"resource": ""
} |
q18080 | Requirements_Backend.parseCombinedFile | train | protected function parseCombinedFile($file)
{
// Array with path and type keys
if (is_array($file) && isset($file['path']) && isset($file['type'])) {
return array($file['path'], $file['type']);
}
// Extract value from indexed array
if (is_array($file)) {
... | php | {
"resource": ""
} |
q18081 | Requirements_Backend.processCombinedFiles | train | public function processCombinedFiles()
{
// Check if combining is enabled
if (!$this->getCombinedFilesEnabled()) {
return;
}
// Before scripts are modified, detect files that are provided by preceding ones
$providedScripts = $this->getProvidedScripts();
... | php | {
"resource": ""
} |
q18082 | Requirements_Backend.hashedCombinedFilename | train | protected function hashedCombinedFilename($combinedFile, $fileList)
{
$name = pathinfo($combinedFile, PATHINFO_FILENAME);
$hash = $this->hashOfFiles($fileList);
| php | {
"resource": ""
} |
q18083 | Requirements_Backend.getCombinedFilesEnabled | train | public function getCombinedFilesEnabled()
{
if (isset($this->combinedFilesEnabled)) {
return $this->combinedFilesEnabled;
}
// Non-dev sites are always combined
if (!Director::isDev()) {
| php | {
"resource": ""
} |
q18084 | Requirements_Backend.hashOfFiles | train | protected function hashOfFiles($fileList)
{
// Get hash based on hash of each file
$hash = '';
foreach ($fileList as $file) {
$absolutePath = Director::getAbsFile($file);
if (file_exists($absolutePath)) {
$hash .= sha1_file($absolutePath);
| php | {
"resource": ""
} |
q18085 | Requirements_Backend.themedCSS | train | public function themedCSS($name, $media = null)
{
$path = ThemeResourceLoader::inst()->findThemedCSS($name, SSViewer::get_themes());
if ($path) {
$this->css($path, $media);
} else {
throw new InvalidArgumentException(
| php | {
"resource": ""
} |
q18086 | Requirements_Backend.themedJavascript | train | public function themedJavascript($name, $type = null)
{
$path = ThemeResourceLoader::inst()->findThemedJavascript($name, SSViewer::get_themes());
if ($path) {
$opts = [];
if ($type) {
$opts['type'] = $type;
}
$this->javascript($path, $o... | php | {
"resource": ""
} |
q18087 | Requirements_Backend.debug | train | public function debug()
{
Debug::show($this->javascript);
Debug::show($this->css);
Debug::show($this->customCSS);
Debug::show($this->customScript);
| php | {
"resource": ""
} |
q18088 | InstallConfig.getDatabaseConfig | train | public function getDatabaseConfig($request, $databaseClasses, $realPassword = true)
{
// Get config from request
if (isset($request['db']['type'])) {
$type = $request['db']['type'];
if (isset($request['db'][$type])) {
$config = $request['db'][$type];
... | php | {
"resource": ""
} |
q18089 | InstallConfig.getAdminConfig | train | public function getAdminConfig($request, $realPassword = true)
{
if (isset($request['admin'])) {
$config = $request['admin'];
if (isset($config['password']) && $config['password'] === Installer::PASSWORD_PLACEHOLDER) {
$config['password'] = Environment::getEnv('SS_DEF... | php | {
"resource": ""
} |
q18090 | InstallConfig.alreadyInstalled | train | public function alreadyInstalled()
{
if (file_exists($this->getEnvPath())) {
return true;
}
if (!file_exists($this->getConfigPath())) {
return false;
| php | {
"resource": ""
} |
q18091 | InstallConfig.getDatabaseClass | train | protected function getDatabaseClass($databaseClasses)
{
$envDatabase = Environment::getEnv('SS_DATABASE_CLASS');
if ($envDatabase) {
return $envDatabase;
}
// Check supported versions
foreach ($this->preferredDatabases as $candidate) {
| php | {
"resource": ""
} |
q18092 | InstallConfig.getFrameworkVersion | train | public function getFrameworkVersion()
{
$composerLockPath = BASE_PATH . '/composer.lock';
if (!file_exists($composerLockPath)) {
return 'unknown';
}
$lockData = json_decode(file_get_contents($composerLockPath), true);
if (json_last_error() || empty($lockData['pack... | php | {
"resource": ""
} |
q18093 | AbstractConfirmationToken.prepare_tokens | train | public static function prepare_tokens($keys, HTTPRequest $request)
{
$target = null;
foreach ($keys as $key) {
$token = new static($key, $request);
| php | {
"resource": ""
} |
q18094 | AbstractConfirmationToken.genToken | train | protected function genToken()
{
// Generate a new random token (as random as possible)
$rg = new RandomGenerator();
$token = $rg->randomToken('md5');
// Store a file in the session | php | {
"resource": ""
} |
q18095 | AbstractConfirmationToken.reloadWithToken | train | public function reloadWithToken()
{
$location = $this->redirectURL();
$locationJS = Convert::raw2js($location);
$locationATT = Convert::raw2att($location);
$body = <<<HTML
<script>location.href='$locationJS';</script>
<noscript><meta | php | {
"resource": ""
} |
q18096 | RequestHandler.handleAction | train | protected function handleAction($request, $action)
{
$classMessage = Director::isLive() ? 'on this handler' : 'on class ' . static::class;
if (!$this->hasMethod($action)) {
return new HTTPResponse("Action '$action' isn't available $classMessage.", 404);
| php | {
"resource": ""
} |
q18097 | RequestHandler.allowedActions | train | public function allowedActions($limitToClass = null)
{
if ($limitToClass) {
$actions = Config::forClass($limitToClass)->get('allowed_actions', true);
} else {
$actions = $this->config()->get('allowed_actions');
}
if (is_array($actions)) {
if (arra... | php | {
"resource": ""
} |
q18098 | RequestHandler.hasAction | train | public function hasAction($action)
{
if ($action == 'index') {
return true;
}
// Don't allow access to any non-public methods (inspect instance plus all extensions)
$insts = array_merge([$this], (array) $this->getExtensionInstances());
foreach ($insts as $inst) {... | php | {
"resource": ""
} |
q18099 | RequestHandler.definingClassForAction | train | protected function definingClassForAction($actionOrigCasing)
{
$action = strtolower($actionOrigCasing);
$definingClass = null;
$insts = array_merge([$this], (array) $this->getExtensionInstances());
foreach ($insts as $inst) {
if (!method_exists($inst, $action)) {
... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.