_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q17900
Hierarchy.showingCMSTree
train
public function showingCMSTree() { if (!Controller::has_curr() || !class_exists(LeftAndMain::class)) { return false;
php
{ "resource": "" }
q17901
Hierarchy.stageChildren
train
public function stageChildren($showAll = false, $skipParentIDFilter = false) { $hideFromHierarchy = $this->owner->config()->hide_from_hierarchy; $hideFromCMSTree = $this->owner->config()->hide_from_cms_tree; $baseClass = $this->owner->baseClass(); $baseTable = $this->owner->baseTable...
php
{ "resource": "" }
q17902
Hierarchy.liveChildren
train
public function liveChildren($showAll = false, $onlyDeletedFromStage = false) { /** @var Versioned|DataObject|Hierarchy $owner */ $owner = $this->owner; if (!$owner->hasExtension(Versioned::class) || !$owner->hasStages()) { throw new Exception('Hierarchy->liveChildren() only work...
php
{ "resource": "" }
q17903
Hierarchy.getParent
train
public function getParent($filter = null) { $parentID = $this->owner->ParentID; if (empty($parentID)) { return null; }
php
{ "resource": "" }
q17904
Hierarchy.getAncestors
train
public function getAncestors($includeSelf = false) { $ancestors = new ArrayList(); $object = $this->owner; if ($includeSelf) { $ancestors->push($object); } while ($object
php
{ "resource": "" }
q17905
Installer.writeConfigEnv
train
protected function writeConfigEnv($config) { if (!$config['usingEnv']) { return; } $path = $this->getBaseDir() . '.env'; $vars = []; // Retain existing vars $env = new EnvironmentLoader(); if (file_exists($path)) { $vars = $env->loadF...
php
{ "resource": "" }
q17906
Installer.writeToFile
train
public function writeToFile($filename, $content, $absolute = false) { // Get absolute / relative paths by either combining or removing base from path list($absolutePath, $relativePath) = $absolute ? [ $filename, substr($filename, strlen($this->getBaseDir()...
php
{ "resource": "" }
q17907
Installer.createHtaccess
train
public function createHtaccess() { $start = "### SILVERSTRIPE START ###\n"; $end = "\n### SILVERSTRIPE END ###"; $base = dirname($_SERVER['SCRIPT_NAME']); $base = Convert::slashes($base, '/'); if ($base != '.') { $baseClause = "RewriteBase '$base'\n"; } ...
php
{ "resource": "" }
q17908
Installer.createWebConfig
train
public function createWebConfig() { $content = <<<TEXT <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <security> <requestFiltering> <hiddenSegments applyToWebDAV="false"> <add segment="silverstripe-cache" /> ...
php
{ "resource": "" }
q17909
GenericTemplateGlobalProvider.ModulePath
train
public static function ModulePath($name) { // BC for a couple fo the key modules in the old syntax. Reduces merge brittleness but can // be removed before 4.0 stable $legacyMapping = [ 'framework' => 'silverstripe/framework', 'frameworkadmin' => 'silverstripe/admin', ...
php
{ "resource": "" }
q17910
SSViewer_BasicIteratorSupport.FirstLast
train
public function FirstLast() { if ($this->First() && $this->Last()) { return 'first last'; } if ($this->First()) { return 'first';
php
{ "resource": "" }
q17911
Module.getShortName
train
public function getShortName() { // If installed in the root directory we need to infer from composer if ($this->path === $this->basePath && $this->composerData) { // Sometimes we customise installer name if (isset($this->composerData['extra']['installer-name'])) { ...
php
{ "resource": "" }
q17912
Module.getResource
train
public function getResource($path) { $path = Path::normalise($path, true); if (empty($path)) { throw new InvalidArgumentException('$path is required');
php
{ "resource": "" }
q17913
Database.setSchemaManager
train
public function setSchemaManager(DBSchemaManager $schemaManager) { $this->schemaManager =
php
{ "resource": "" }
q17914
Database.previewWrite
train
protected function previewWrite($sql) { // Only preview if previewWrite is set, we are in dev mode, and // the query is mutable if (isset($_REQUEST['previewwrite']) && Director::isDev() && $this->connector->isQueryMutable($sql)
php
{ "resource": "" }
q17915
Database.benchmarkQuery
train
protected function benchmarkQuery($sql, $callback, $parameters = array()) { if (isset($_REQUEST['showqueries']) && Director::isDev()) { $this->queryCount++; $starttime = microtime(true); $result = $callback($sql); $endtime = round(microtime(true) - $starttime,...
php
{ "resource": "" }
q17916
Database.escapeColumnKeys
train
protected function escapeColumnKeys($fieldValues) { $out = array(); foreach ($fieldValues as $field => $value) {
php
{ "resource": "" }
q17917
Database.clearAllData
train
public function clearAllData() { $tables = $this->getSchemaManager()->tableList(); foreach
php
{ "resource": "" }
q17918
Database.connect
train
public function connect($parameters) { // Ensure that driver is available (required by PDO) if (empty($parameters['driver'])) { $parameters['driver'] = $this->getDatabaseServer(); } // Notify connector of parameters $this->connector->connect($parameters); ...
php
{ "resource": "" }
q17919
Database.selectDatabase
train
public function selectDatabase($name, $create = false, $errorLevel = E_USER_ERROR) { // In case our live environment is locked down, we can bypass a SHOW DATABASE check $canConnect = Config::inst()->get(static::class, 'optimistic_connect') || $this->schemaManager->databaseExists($name); ...
php
{ "resource": "" }
q17920
Database.dropSelectedDatabase
train
public function dropSelectedDatabase() { $databaseName = $this->connector->getSelectedDatabase(); if ($databaseName) {
php
{ "resource": "" }
q17921
CanonicalURLMiddleware.getRedirect
train
protected function getRedirect(HTTPRequest $request) { // Check global disable if (!$this->isEnabled()) { return null; } // Get properties of current request $host = $request->getHost(); $scheme = $request->getScheme(); // Check https if ...
php
{ "resource": "" }
q17922
CanonicalURLMiddleware.throwRedirectIfNeeded
train
public function throwRedirectIfNeeded(HTTPRequest $request = null) { $request = $this->getOrValidateRequest($request); if (!$request) { return; }
php
{ "resource": "" }
q17923
CanonicalURLMiddleware.getOrValidateRequest
train
protected function getOrValidateRequest(HTTPRequest $request = null) { if ($request instanceof HTTPRequest) {
php
{ "resource": "" }
q17924
CanonicalURLMiddleware.requiresSSL
train
protected function requiresSSL(HTTPRequest $request) { // Check if force SSL is enabled if (!$this->getForceSSL()) { return false; } // Already on SSL if ($request->getScheme() === 'https') { return false; } // Veto if any existing pa...
php
{ "resource": "" }
q17925
CanonicalURLMiddleware.isEnabled
train
protected function isEnabled() { // At least one redirect must be enabled if (!$this->getForceWWW() && !$this->getForceSSL()) { return false; } // Filter by env vars $enabledEnvs = $this->getEnabledEnvs(); if (is_bool($enabledEnvs)) { return $...
php
{ "resource": "" }
q17926
CanonicalURLMiddleware.hasBasicAuthPrompt
train
protected function hasBasicAuthPrompt(HTTPResponse $response = null) { if (!$response) {
php
{ "resource": "" }
q17927
CanonicalURLMiddleware.redirectToScheme
train
protected function redirectToScheme(HTTPRequest $request, $scheme, $host = null) { if (!$host) { $host = $request->getHost(); } $url = Controller::join_links("{$scheme}://{$host}", Director::baseURL(), $request->getURL(true)); // Force redirect
php
{ "resource": "" }
q17928
HTMLEditorSanitiser.getRuleForElement
train
protected function getRuleForElement($tag) { if (isset($this->elements[$tag])) { return $this->elements[$tag];
php
{ "resource": "" }
q17929
HTMLEditorSanitiser.getRuleForAttribute
train
protected function getRuleForAttribute($elementRule, $name) { if (isset($elementRule->attributes[$name])) { return $elementRule->attributes[$name];
php
{ "resource": "" }
q17930
HTMLEditorSanitiser.elementMatchesRule
train
protected function elementMatchesRule($element, $rule = null) { // If the rule doesn't exist at all, the element isn't allowed if (!$rule) { return false; } // If the rule has attributes required, check them to see if this element has at least one if ($rule->attr...
php
{ "resource": "" }
q17931
HTMLEditorSanitiser.attributeMatchesRule
train
protected function attributeMatchesRule($attr, $rule = null) { // If the rule doesn't exist at all, the attribute isn't allowed if (!$rule) { return false; } // If the rule has a set of valid values, check them to see if this attribute is one if (isset($rule->val...
php
{ "resource": "" }
q17932
ModuleResource.getRelativePath
train
public function getRelativePath() { // Root module $parent = $this->module->getRelativePath(); if (!$parent) {
php
{ "resource": "" }
q17933
CookieJar.get
train
public function get($name, $includeUnsent = true) { $cookies = $includeUnsent ? $this->current : $this->existing; if (isset($cookies[$name])) { return $cookies[$name]; } //Normalise cookie names by replacing '.' with '_'
php
{ "resource": "" }
q17934
CookieJar.forceExpiry
train
public function forceExpiry($name, $path = null, $domain = null, $secure = false,
php
{ "resource": "" }
q17935
CookieJar.outputCookie
train
protected function outputCookie( $name, $value, $expiry = 90, $path = null, $domain = null, $secure = false, $httpOnly = true ) { // if headers aren't sent, we can set the cookie if (!headers_sent($file, $line)) { return setcookie($...
php
{ "resource": "" }
q17936
CurrencyField_Disabled.Field
train
public function Field($properties = array()) { if ($this->value) { $val = Convert::raw2xml($this->value); $val = DBCurrency::config()->get('currency_symbol') . number_format(preg_replace('/[^0-9.-]/', '', $val), 2); $valforInput = Convert::raw2att($val); ...
php
{ "resource": "" }
q17937
Diff.cleanHTML
train
public static function cleanHTML($content, $cleaner = null) { if (!$cleaner) { if (self::$html_cleaner_class && class_exists(self::$html_cleaner_class)) { $cleaner = Injector::inst()->create(self::$html_cleaner_class); } else { //load cleaner if the de...
php
{ "resource": "" }
q17938
SQLInsert.addRow
train
public function addRow($data = null) { // Clear existing empty row if (($current = $this->currentRow()) && $current->isEmpty()) { array_pop($this->rows); } // Append data if ($data instanceof SQLAssignmentRow) {
php
{ "resource": "" }
q17939
SQLInsert.getColumns
train
public function getColumns() { $columns = array(); foreach ($this->getRows() as $row) { $columns = array_merge($columns,
php
{ "resource": "" }
q17940
SQLInsert.currentRow
train
public function currentRow($create = false) { $current = end($this->rows); if ($create && !$current) {
php
{ "resource": "" }
q17941
DateField.getDateFormat
train
public function getDateFormat() { // Browsers expect ISO 8601 dates, localisation is handled on the client if ($this->getHTML5()) { return DBDate::ISO_DATE; } if ($this->dateFormat) {
php
{ "resource": "" }
q17942
TreeDropdownField.setFilterFunction
train
public function setFilterFunction($callback) { if (!is_callable($callback, true)) { throw new InvalidArgumentException('TreeDropdownField->setFilterCallback(): not passed a valid
php
{ "resource": "" }
q17943
TreeDropdownField.setDisableFunction
train
public function setDisableFunction($callback) { if (!is_callable($callback, true)) { throw new InvalidArgumentException('TreeDropdownField->setDisableFunction(): not passed a valid
php
{ "resource": "" }
q17944
TreeDropdownField.setSearchFunction
train
public function setSearchFunction($callback) { if (!is_callable($callback, true)) { throw new InvalidArgumentException('TreeDropdownField->setSearchFunction(): not passed a valid
php
{ "resource": "" }
q17945
TreeDropdownField.filterMarking
train
public function filterMarking($node) { $callback = $this->getFilterFunction(); if ($callback && !call_user_func($callback, $node)) { return false; } if ($this->search)
php
{ "resource": "" }
q17946
TreeDropdownField.flattenChildrenArray
train
protected function flattenChildrenArray($children, $parentTitles = []) { $output = []; foreach ($children as $child) { $childTitles = array_merge($parentTitles, [$child['title']]); $grandChildren = $child['children']; $contextString = implode('/', $parentTitles);...
php
{ "resource": "" }
q17947
TreeDropdownField.getSearchResults
train
protected function getSearchResults() { $callback = $this->getSearchFunction(); if ($callback) { return call_user_func($callback, $this->getSourceObject(), $this->getLabelField(), $this->search); } $sourceObject = $this->getSourceObject(); $filters = array(); ...
php
{ "resource": "" }
q17948
TreeDropdownField.getCacheKey
train
protected function getCacheKey() { $target = $this->getSourceObject(); if (!isset(self::$cacheKeyCache[$target])) {
php
{ "resource": "" }
q17949
DBComposite.writeToManipulation
train
public function writeToManipulation(&$manipulation) { foreach ($this->compositeDatabaseFields() as $field => $spec) {
php
{ "resource": "" }
q17950
DBComposite.isChanged
train
public function isChanged() { // When unbound, use the local changed flag if (! ($this->record instanceof DataObject)) { return $this->isChanged; } // Defer to parent record foreach ($this->compositeDatabaseFields() as $field => $spec) {
php
{ "resource": "" }
q17951
DBComposite.exists
train
public function exists() { // By default all fields foreach ($this->compositeDatabaseFields() as $field => $spec) { $fieldObject = $this->dbObject($field);
php
{ "resource": "" }
q17952
DBComposite.getField
train
public function getField($field) { // Skip invalid fields $fields = $this->compositeDatabaseFields(); if (!isset($fields[$field])) { return null; } // Check bound object if ($this->record instanceof DataObject) { $key = $this->getName() . $fie...
php
{ "resource": "" }
q17953
DBComposite.setField
train
public function setField($field, $value, $markChanged = true) { $this->objCacheClear(); // Non-db fields get assigned as normal properties if (!$this->hasField($field)) { parent::setField($field, $value); return $this; } // Set changed if ($...
php
{ "resource": "" }
q17954
DBComposite.dbObject
train
public function dbObject($field) { $fields = $this->compositeDatabaseFields(); if (!isset($fields[$field])) { return null; } // Build nested field $key = $this->getName() . $field; $spec = $fields[$field]; /** @var DBField $fieldObject
php
{ "resource": "" }
q17955
GridFieldDetailForm.getItemRequestHandler
train
protected function getItemRequestHandler($gridField, $record, $requestHandler) { $class = $this->getItemRequestClass(); $assignedClass = $this->itemRequestClass; $this->extend('updateItemRequestClass', $class, $gridField, $record, $requestHandler, $assignedClass); /** @var GridFieldD...
php
{ "resource": "" }
q17956
DataObject.duplicate
train
public function duplicate($doWrite = true, $relations = null) { // Handle legacy behaviour if (is_string($relations) || $relations === true) { if ($relations === true) { $relations = 'many_many'; } Deprecation::notice('5.0', 'Use cascade_duplicates...
php
{ "resource": "" }
q17957
DataObject.duplicateRelations
train
protected function duplicateRelations($sourceObject, $destinationObject, $relations) { // Get list of duplicable relation types $manyMany = $sourceObject->manyMany(); $hasMany = $sourceObject->hasMany(); $hasOne = $sourceObject->hasOne(); $belongsTo = $sourceObject->belongsTo...
php
{ "resource": "" }
q17958
DataObject.duplicateManyManyRelations
train
protected function duplicateManyManyRelations($sourceObject, $destinationObject, $filter) { Deprecation::notice('5.0', 'Use duplicateRelations() instead'); // Get list of relations to duplicate if ($filter === 'many_many' || $filter === 'belongs_many_many') {
php
{ "resource": "" }
q17959
DataObject.update
train
public function update($data) { foreach ($data as $key => $value) { // Implement dot syntax for updates if (strpos($key, '.') !== false) { $relations = explode('.', $key); $fieldName = array_pop($relations); /** @var static $relObj */ ...
php
{ "resource": "" }
q17960
DataObject.merge
train
public function merge($rightObj, $priority = 'right', $includeRelations = true, $overwriteWithEmpty = false) { $leftObj = $this; if ($leftObj->ClassName != $rightObj->ClassName) { // we can't merge similiar subclasses because they might have additional relations user_error("...
php
{ "resource": "" }
q17961
DataObject.forceChange
train
public function forceChange() { // Ensure lazy fields loaded $this->loadLazyFields(); // Populate the null values in record so that they actually get written foreach (array_keys(static::getSchema()->fieldSpecs(static::class)) as $fieldName) {
php
{ "resource": "" }
q17962
DataObject.validateWrite
train
protected function validateWrite() { if ($this->ObsoleteClassName) { return new ValidationException( "Object is of class '{$this->ObsoleteClassName}' which doesn't exist - " . "you need to change the ClassName before you can write it" ); } ...
php
{ "resource": "" }
q17963
DataObject.preWrite
train
protected function preWrite() { // Validate this object if ($writeException = $this->validateWrite()) { // Used by DODs to clean up after themselves, eg, Versioned $this->invokeWithExtensions('onAfterSkippedWrite');
php
{ "resource": "" }
q17964
DataObject.updateChanges
train
protected function updateChanges($forceChanges = false) { if ($forceChanges) { // Force changes, but only for loaded fields foreach ($this->record as $field => $value) { $this->changed[$field]
php
{ "resource": "" }
q17965
DataObject.prepareManipulationTable
train
protected function prepareManipulationTable($baseTable, $now, $isNewRecord, &$manipulation, $class) { $schema = $this->getSchema(); $table = $schema->tableName($class); $manipulation[$table] = array(); $changed = $this->getChangedFields(); // Extract records for this table ...
php
{ "resource": "" }
q17966
DataObject.writeBaseRecord
train
protected function writeBaseRecord($baseTable, $now) { // Generate new ID if not specified if ($this->isInDB()) { return; } // Perform an insert on the base table
php
{ "resource": "" }
q17967
DataObject.writeManipulation
train
protected function writeManipulation($baseTable, $now, $isNewRecord) { // Generate database manipulations for each class $manipulation = array(); foreach (ClassInfo::ancestry(static::class, true) as $class) { $this->prepareManipulationTable($baseTable, $now, $isNewRecord, $manipu...
php
{ "resource": "" }
q17968
DataObject.writeRelations
train
public function writeRelations() { if (!$this->isInDB()) { return; } // If there's any relations that couldn't be saved before, save them now (we
php
{ "resource": "" }
q17969
DataObject.writeComponents
train
public function writeComponents($recursive = false) { foreach ($this->components as $component) { $component->write(false, false, false, $recursive); }
php
{ "resource": "" }
q17970
DataObject.delete_by_id
train
public static function delete_by_id($className, $id) { $obj = DataObject::get_by_id($className, $id); if ($obj) { $obj->delete(); } else {
php
{ "resource": "" }
q17971
DataObject.getComponent
train
public function getComponent($componentName) { if (isset($this->components[$componentName])) { return $this->components[$componentName]; } $schema = static::getSchema(); if ($class = $schema->hasOneComponent(static::class, $componentName)) { $joinField = $com...
php
{ "resource": "" }
q17972
DataObject.setComponent
train
public function setComponent($componentName, $item) { // Validate component $schema = static::getSchema(); if ($class = $schema->hasOneComponent(static::class, $componentName)) { // Force item to be written if not by this point // @todo This could be lazy-written in a...
php
{ "resource": "" }
q17973
DataObject.getComponents
train
public function getComponents($componentName, $id = null) { if (!isset($id)) { $id = $this->ID; } $result = null; $schema = $this->getSchema(); $componentClass = $schema->hasManyComponent(static::class, $componentName); if (!$componentClass) { ...
php
{ "resource": "" }
q17974
DataObject.getRelationClass
train
public function getRelationClass($relationName) { // Parse many_many $manyManyComponent = $this->getSchema()->manyManyComponent(static::class, $relationName); if ($manyManyComponent) { return $manyManyComponent['childClass']; } // Go through all relationship conf...
php
{ "resource": "" }
q17975
DataObject.getRelationType
train
public function getRelationType($component) { $types = array('has_one', 'has_many', 'many_many', 'belongs_many_many', 'belongs_to'); $config = $this->config(); foreach ($types as $type) { $relations = $config->get($type);
php
{ "resource": "" }
q17976
DataObject.inferReciprocalComponent
train
public function inferReciprocalComponent($remoteClass, $remoteRelation) { $remote = DataObject::singleton($remoteClass); $class = $remote->getRelationClass($remoteRelation); $schema = static::getSchema(); // Validate arguments if (!$this->isInDB()) { throw new Ba...
php
{ "resource": "" }
q17977
DataObject.getManyManyComponents
train
public function getManyManyComponents($componentName, $id = null) { if (!isset($id)) { $id = $this->ID; } $schema = static::getSchema(); $manyManyComponent = $schema->manyManyComponent(static::class, $componentName); if (!$manyManyComponent) { throw ne...
php
{ "resource": "" }
q17978
DataObject.belongsTo
train
public function belongsTo($classOnly = true) { $belongsTo = (array)$this->config()->get('belongs_to'); if ($belongsTo && $classOnly) { return
php
{ "resource": "" }
q17979
DataObject.loadLazyFields
train
protected function loadLazyFields($class = null) { if (!$this->isInDB() || !is_numeric($this->ID)) { return false; } if (!$class) { $loaded = array(); foreach ($this->record as $key => $value) { if (strlen($key) > 5 && substr($key, -5) ==...
php
{ "resource": "" }
q17980
DataObject.getChangedFields
train
public function getChangedFields($databaseFieldsOnly = false, $changeLevel = self::CHANGE_STRICT) { $changedFields = array(); // Update the changed array with references to changed obj-fields foreach ($this->record as $k => $v) { // Prevents DBComposite infinite looping on isCha...
php
{ "resource": "" }
q17981
DataObject.hasDatabaseField
train
public function hasDatabaseField($field) { $spec = static::getSchema()->fieldSpec(static::class,
php
{ "resource": "" }
q17982
DataObject.relObject
train
public function relObject($fieldPath) { $object = null; $component = $this; // Parse all relations foreach (explode('.', $fieldPath) as $relation) { if (!$component) { return null; } // Inspect relation type if (ClassI...
php
{ "resource": "" }
q17983
DataObject.getReverseAssociation
train
public function getReverseAssociation($className) { if (is_array($this->manyMany())) { $many_many = array_flip($this->manyMany()); if (array_key_exists($className, $many_many)) { return $many_many[$className]; } } if (is_array($this->hasMan...
php
{ "resource": "" }
q17984
DataObject.get
train
public static function get( $callerClass = null, $filter = "", $sort = "", $join = "", $limit = null, $containerClass = DataList::class ) { // Validate arguments if ($callerClass == null) { $callerClass = get_called_class(); if ...
php
{ "resource": "" }
q17985
DataObject.flush_and_destroy_cache
train
public static function flush_and_destroy_cache() { if (self::$_cache_get_one) { foreach (self::$_cache_get_one as $class => $items) { if (is_array($items)) { foreach ($items as $item) { if ($item) {
php
{ "resource": "" }
q17986
DataObject.reset
train
public static function reset() { // @todo Decouple these DBEnum::flushCache(); ClassInfo::reset_db_cache(); static::getSchema()->reset();
php
{ "resource": "" }
q17987
DataObject.get_by_id
train
public static function get_by_id($classOrID, $idOrCache = null, $cache = true) { // Shift arguments if passing id in first or second argument list ($class, $id, $cached) = is_numeric($classOrID) ? [get_called_class(), $classOrID, isset($idOrCache) ? $idOrCache : $cache] : [$c...
php
{ "resource": "" }
q17988
DataObject.fieldLabels
train
public function fieldLabels($includerelations = true) { $cacheKey = static::class . '_' . $includerelations; if (!isset(self::$_cache_field_labels[$cacheKey])) { $customLabels = $this->config()->get('field_labels'); $autoLabels = array(); // get all translated s...
php
{ "resource": "" }
q17989
DataObject.summaryFields
train
public function summaryFields() { $rawFields = $this->config()->get('summary_fields'); // Merge associative / numeric keys $fields = []; foreach ($rawFields as $key => $value) { if (is_int($key)) { $key = $value; } $fields[$key] = ...
php
{ "resource": "" }
q17990
DataObject.defaultSearchFilters
train
public function defaultSearchFilters() { $filters = array(); foreach ($this->searchableFields() as $name => $spec) { if (empty($spec['filter'])) { /** @skipUpgrade */ $filters[$name] = 'PartialMatchFilter'; } elseif ($spec['filter'] instanceof...
php
{ "resource": "" }
q17991
DataObject.setJoin
train
public function setJoin(DataObject $object, $alias = null) { $this->joinRecord = $object; if ($alias) { if (static::getSchema()->fieldSpec(static::class, $alias)) { throw new InvalidArgumentException(
php
{ "resource": "" }
q17992
DataObject.findRelatedObjects
train
public function findRelatedObjects($source, $recursive = true, $list = null) { if (!$list) { $list = new ArrayList(); } // Skip search for unsaved records if (!$this->isInDB()) { return $list; } $relationships = $this->config()->get($source) ...
php
{ "resource": "" }
q17993
DataObject.mergeRelatedObject
train
protected function mergeRelatedObject($list, $added, $item) { // Identify item $itemKey = get_class($item) . '/' . $item->ID; // Write if saved, versioned, and not already added if ($item->isInDB() && !isset($list[$itemKey])) { $list[$itemKey] = $item; $added...
php
{ "resource": "" }
q17994
GridFieldPrintButton.handleAction
train
public function handleAction(GridField $gridField, $actionName, $arguments, $data) { if ($actionName == 'print') {
php
{ "resource": "" }
q17995
GridFieldPrintButton.handlePrint
train
public function handlePrint($gridField, $request = null) { set_time_limit(60); Requirements::clear(); $data = $this->generatePrintData($gridField); $this->extend('updatePrintData', $data); if ($data) { return
php
{ "resource": "" }
q17996
GridFieldPrintButton.getPrintColumnsForGridField
train
protected function getPrintColumnsForGridField(GridField $gridField) { if ($this->printColumns) { return $this->printColumns; } /** @var GridFieldDataColumns $dataCols */ $dataCols = $gridField->getConfig()->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDa...
php
{ "resource": "" }
q17997
GridFieldPrintButton.getTitle
train
public function getTitle(GridField $gridField) { $form = $gridField->getForm(); $currentController = $gridField->getForm()->getController(); $title = ''; if (method_exists($currentController, 'Title')) { $title = $currentController->Title(); } else { ...
php
{ "resource": "" }
q17998
GridFieldPrintButton.generatePrintData
train
public function generatePrintData(GridField $gridField) { $printColumns = $this->getPrintColumnsForGridField($gridField); $header = null; if ($this->printHasHeader) { $header = new ArrayList(); foreach ($printColumns as $field => $label) { $header->...
php
{ "resource": "" }
q17999
Form.restoreFormState
train
public function restoreFormState() { // Restore messages $result = $this->getSessionValidationResult(); if (isset($result)) { $this->loadMessagesFrom($result); } // load data in from previous submission upon error $data
php
{ "resource": "" }