repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
silverstripe/silverstripe-framework
src/ORM/Connect/Database.php
Database.previewWrite
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) ) { // output previe...
php
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) ) { // output previe...
[ "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", ...
Determines if the query should be previewed, and thus interrupted silently. If so, this function also displays the query via the debuging system. Subclasess should respect the results of this call for each query, and not execute any queries that generate a true response. @param string $sql The query to be executed @re...
[ "Determines", "if", "the", "query", "should", "be", "previewed", "and", "thus", "interrupted", "silently", ".", "If", "so", "this", "function", "also", "displays", "the", "query", "via", "the", "debuging", "system", ".", "Subclasess", "should", "respect", "the...
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Connect/Database.php#L184-L198
train
silverstripe/silverstripe-framework
src/ORM/Connect/Database.php
Database.benchmarkQuery
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
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,...
[ "protected", "function", "benchmarkQuery", "(", "$", "sql", ",", "$", "callback", ",", "$", "parameters", "=", "array", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "_REQUEST", "[", "'showqueries'", "]", ")", "&&", "Director", "::", "isDev", "(", ...
Allows the display and benchmarking of queries as they are being run @param string $sql Query to run, and single parameter to callback @param callable $callback Callback to execute code @param array $parameters Parameters for any parameterised query @return mixed Result of query
[ "Allows", "the", "display", "and", "benchmarking", "of", "queries", "as", "they", "are", "being", "run" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Connect/Database.php#L208-L230
train
silverstripe/silverstripe-framework
src/ORM/Connect/Database.php
Database.escapeColumnKeys
protected function escapeColumnKeys($fieldValues) { $out = array(); foreach ($fieldValues as $field => $value) { $out[$this->escapeIdentifier($field)] = $value; } return $out; }
php
protected function escapeColumnKeys($fieldValues) { $out = array(); foreach ($fieldValues as $field => $value) { $out[$this->escapeIdentifier($field)] = $value; } return $out; }
[ "protected", "function", "escapeColumnKeys", "(", "$", "fieldValues", ")", "{", "$", "out", "=", "array", "(", ")", ";", "foreach", "(", "$", "fieldValues", "as", "$", "field", "=>", "$", "value", ")", "{", "$", "out", "[", "$", "this", "->", "escape...
Escapes unquoted columns keys in an associative array @param array $fieldValues @return array List of field values with the keys as escaped column names
[ "Escapes", "unquoted", "columns", "keys", "in", "an", "associative", "array" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Connect/Database.php#L303-L310
train
silverstripe/silverstripe-framework
src/ORM/Connect/Database.php
Database.clearAllData
public function clearAllData() { $tables = $this->getSchemaManager()->tableList(); foreach ($tables as $table) { $this->clearTable($table); } }
php
public function clearAllData() { $tables = $this->getSchemaManager()->tableList(); foreach ($tables as $table) { $this->clearTable($table); } }
[ "public", "function", "clearAllData", "(", ")", "{", "$", "tables", "=", "$", "this", "->", "getSchemaManager", "(", ")", "->", "tableList", "(", ")", ";", "foreach", "(", "$", "tables", "as", "$", "table", ")", "{", "$", "this", "->", "clearTable", ...
Clear all data out of the database
[ "Clear", "all", "data", "out", "of", "the", "database" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Connect/Database.php#L391-L397
train
silverstripe/silverstripe-framework
src/ORM/Connect/Database.php
Database.connect
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
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); ...
[ "public", "function", "connect", "(", "$", "parameters", ")", "{", "// Ensure that driver is available (required by PDO)", "if", "(", "empty", "(", "$", "parameters", "[", "'driver'", "]", ")", ")", "{", "$", "parameters", "[", "'driver'", "]", "=", "$", "this...
Instruct the database to generate a live connection @param array $parameters An map of parameters, which should include: - server: The server, eg, localhost - username: The username to log on with - password: The password to log on with - database: The database to connect to - charset: The character set to use. Defaul...
[ "Instruct", "the", "database", "to", "generate", "a", "live", "connection" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Connect/Database.php#L772-L788
train
silverstripe/silverstripe-framework
src/ORM/Connect/Database.php
Database.selectDatabase
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
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); ...
[ "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", ":...
Change the connection to the specified database, optionally creating the database if it doesn't exist in the current schema. @param string $name Name of the database @param bool $create Flag indicating whether the database should be created if it doesn't exist. If $create is false and the database doesn't exist then a...
[ "Change", "the", "connection", "to", "the", "specified", "database", "optionally", "creating", "the", "database", "if", "it", "doesn", "t", "exist", "in", "the", "current", "schema", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Connect/Database.php#L823-L843
train
silverstripe/silverstripe-framework
src/ORM/Connect/Database.php
Database.dropSelectedDatabase
public function dropSelectedDatabase() { $databaseName = $this->connector->getSelectedDatabase(); if ($databaseName) { $this->connector->unloadDatabase(); $this->schemaManager->dropDatabase($databaseName); } }
php
public function dropSelectedDatabase() { $databaseName = $this->connector->getSelectedDatabase(); if ($databaseName) { $this->connector->unloadDatabase(); $this->schemaManager->dropDatabase($databaseName); } }
[ "public", "function", "dropSelectedDatabase", "(", ")", "{", "$", "databaseName", "=", "$", "this", "->", "connector", "->", "getSelectedDatabase", "(", ")", ";", "if", "(", "$", "databaseName", ")", "{", "$", "this", "->", "connector", "->", "unloadDatabase...
Drop the database that this object is currently connected to. Use with caution.
[ "Drop", "the", "database", "that", "this", "object", "is", "currently", "connected", "to", ".", "Use", "with", "caution", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Connect/Database.php#L849-L856
train
silverstripe/silverstripe-framework
src/Control/Middleware/CanonicalURLMiddleware.php
CanonicalURLMiddleware.getRedirect
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
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 ...
[ "protected", "function", "getRedirect", "(", "HTTPRequest", "$", "request", ")", "{", "// Check global disable", "if", "(", "!", "$", "this", "->", "isEnabled", "(", ")", ")", "{", "return", "null", ";", "}", "// Get properties of current request", "$", "host", ...
Given request object determine if we should redirect. @param HTTPRequest $request Pre-validated request object @return HTTPResponse|null If a redirect is needed return the response
[ "Given", "request", "object", "determine", "if", "we", "should", "redirect", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/CanonicalURLMiddleware.php#L205-L235
train
silverstripe/silverstripe-framework
src/Control/Middleware/CanonicalURLMiddleware.php
CanonicalURLMiddleware.throwRedirectIfNeeded
public function throwRedirectIfNeeded(HTTPRequest $request = null) { $request = $this->getOrValidateRequest($request); if (!$request) { return; } $response = $this->getRedirect($request); if ($response) { throw new HTTPResponse_Exception($response); ...
php
public function throwRedirectIfNeeded(HTTPRequest $request = null) { $request = $this->getOrValidateRequest($request); if (!$request) { return; } $response = $this->getRedirect($request); if ($response) { throw new HTTPResponse_Exception($response); ...
[ "public", "function", "throwRedirectIfNeeded", "(", "HTTPRequest", "$", "request", "=", "null", ")", "{", "$", "request", "=", "$", "this", "->", "getOrValidateRequest", "(", "$", "request", ")", ";", "if", "(", "!", "$", "request", ")", "{", "return", "...
Handles redirection to canonical urls outside of the main middleware chain using HTTPResponseException. Will not do anything if a current HTTPRequest isn't available @param HTTPRequest|null $request Allow HTTPRequest to be used for the base comparison @throws HTTPResponse_Exception
[ "Handles", "redirection", "to", "canonical", "urls", "outside", "of", "the", "main", "middleware", "chain", "using", "HTTPResponseException", ".", "Will", "not", "do", "anything", "if", "a", "current", "HTTPRequest", "isn", "t", "available" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/CanonicalURLMiddleware.php#L245-L255
train
silverstripe/silverstripe-framework
src/Control/Middleware/CanonicalURLMiddleware.php
CanonicalURLMiddleware.getOrValidateRequest
protected function getOrValidateRequest(HTTPRequest $request = null) { if ($request instanceof HTTPRequest) { return $request; } if (Injector::inst()->has(HTTPRequest::class)) { return Injector::inst()->get(HTTPRequest::class); } return null; }
php
protected function getOrValidateRequest(HTTPRequest $request = null) { if ($request instanceof HTTPRequest) { return $request; } if (Injector::inst()->has(HTTPRequest::class)) { return Injector::inst()->get(HTTPRequest::class); } return null; }
[ "protected", "function", "getOrValidateRequest", "(", "HTTPRequest", "$", "request", "=", "null", ")", "{", "if", "(", "$", "request", "instanceof", "HTTPRequest", ")", "{", "return", "$", "request", ";", "}", "if", "(", "Injector", "::", "inst", "(", ")",...
Return a valid request, if one is available, or null if none is available @param HTTPRequest $request @return HTTPRequest|null
[ "Return", "a", "valid", "request", "if", "one", "is", "available", "or", "null", "if", "none", "is", "available" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/CanonicalURLMiddleware.php#L263-L272
train
silverstripe/silverstripe-framework
src/Control/Middleware/CanonicalURLMiddleware.php
CanonicalURLMiddleware.requiresSSL
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
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...
[ "protected", "function", "requiresSSL", "(", "HTTPRequest", "$", "request", ")", "{", "// Check if force SSL is enabled", "if", "(", "!", "$", "this", "->", "getForceSSL", "(", ")", ")", "{", "return", "false", ";", "}", "// Already on SSL", "if", "(", "$", ...
Check if a redirect for SSL is necessary @param HTTPRequest $request @return bool
[ "Check", "if", "a", "redirect", "for", "SSL", "is", "necessary" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/CanonicalURLMiddleware.php#L280-L308
train
silverstripe/silverstripe-framework
src/Control/Middleware/CanonicalURLMiddleware.php
CanonicalURLMiddleware.isEnabled
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
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 $...
[ "protected", "function", "isEnabled", "(", ")", "{", "// At least one redirect must be enabled", "if", "(", "!", "$", "this", "->", "getForceWWW", "(", ")", "&&", "!", "$", "this", "->", "getForceSSL", "(", ")", ")", "{", "return", "false", ";", "}", "// F...
Ensure this middleware is enabled
[ "Ensure", "this", "middleware", "is", "enabled" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/CanonicalURLMiddleware.php#L355-L375
train
silverstripe/silverstripe-framework
src/Control/Middleware/CanonicalURLMiddleware.php
CanonicalURLMiddleware.hasBasicAuthPrompt
protected function hasBasicAuthPrompt(HTTPResponse $response = null) { if (!$response) { return false; } return ($response->getStatusCode() === 401 && $response->getHeader('WWW-Authenticate')); }
php
protected function hasBasicAuthPrompt(HTTPResponse $response = null) { if (!$response) { return false; } return ($response->getStatusCode() === 401 && $response->getHeader('WWW-Authenticate')); }
[ "protected", "function", "hasBasicAuthPrompt", "(", "HTTPResponse", "$", "response", "=", "null", ")", "{", "if", "(", "!", "$", "response", ")", "{", "return", "false", ";", "}", "return", "(", "$", "response", "->", "getStatusCode", "(", ")", "===", "4...
Determine whether the executed middlewares have added a basic authentication prompt @param HTTPResponse $response @return bool
[ "Determine", "whether", "the", "executed", "middlewares", "have", "added", "a", "basic", "authentication", "prompt" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/CanonicalURLMiddleware.php#L383-L389
train
silverstripe/silverstripe-framework
src/Control/Middleware/CanonicalURLMiddleware.php
CanonicalURLMiddleware.redirectToScheme
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 $response = HTTPR...
php
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 $response = HTTPR...
[ "protected", "function", "redirectToScheme", "(", "HTTPRequest", "$", "request", ",", "$", "scheme", ",", "$", "host", "=", "null", ")", "{", "if", "(", "!", "$", "host", ")", "{", "$", "host", "=", "$", "request", "->", "getHost", "(", ")", ";", "...
Redirect the current URL to the specified HTTP scheme @param HTTPRequest $request @param string $scheme @param string $host @return HTTPResponse
[ "Redirect", "the", "current", "URL", "to", "the", "specified", "HTTP", "scheme" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/Middleware/CanonicalURLMiddleware.php#L399-L412
train
silverstripe/silverstripe-framework
src/Forms/HTMLEditor/HTMLEditorSanitiser.php
HTMLEditorSanitiser.getRuleForElement
protected function getRuleForElement($tag) { if (isset($this->elements[$tag])) { return $this->elements[$tag]; } foreach ($this->elementPatterns as $element) { if (preg_match($element->pattern, $tag)) { return $element; } } ...
php
protected function getRuleForElement($tag) { if (isset($this->elements[$tag])) { return $this->elements[$tag]; } foreach ($this->elementPatterns as $element) { if (preg_match($element->pattern, $tag)) { return $element; } } ...
[ "protected", "function", "getRuleForElement", "(", "$", "tag", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "elements", "[", "$", "tag", "]", ")", ")", "{", "return", "$", "this", "->", "elements", "[", "$", "tag", "]", ";", "}", "foreach"...
Given an element tag, return the rule structure for that element @param string $tag The element tag @return stdClass The element rule
[ "Given", "an", "element", "tag", "return", "the", "rule", "structure", "for", "that", "element" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/HTMLEditor/HTMLEditorSanitiser.php#L175-L186
train
silverstripe/silverstripe-framework
src/Forms/HTMLEditor/HTMLEditorSanitiser.php
HTMLEditorSanitiser.getRuleForAttribute
protected function getRuleForAttribute($elementRule, $name) { if (isset($elementRule->attributes[$name])) { return $elementRule->attributes[$name]; } foreach ($elementRule->attributePatterns as $attribute) { if (preg_match($attribute->pattern, $name)) { ...
php
protected function getRuleForAttribute($elementRule, $name) { if (isset($elementRule->attributes[$name])) { return $elementRule->attributes[$name]; } foreach ($elementRule->attributePatterns as $attribute) { if (preg_match($attribute->pattern, $name)) { ...
[ "protected", "function", "getRuleForAttribute", "(", "$", "elementRule", ",", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "elementRule", "->", "attributes", "[", "$", "name", "]", ")", ")", "{", "return", "$", "elementRule", "->", "attributes", ...
Given an attribute name, return the rule structure for that attribute @param object $elementRule @param string $name The attribute name @return stdClass The attribute rule
[ "Given", "an", "attribute", "name", "return", "the", "rule", "structure", "for", "that", "attribute" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/HTMLEditor/HTMLEditorSanitiser.php#L195-L206
train
silverstripe/silverstripe-framework
src/Forms/HTMLEditor/HTMLEditorSanitiser.php
HTMLEditorSanitiser.elementMatchesRule
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
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...
[ "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 att...
Given a DOMElement and an element rule, check if that element passes the rule @param DOMElement $element The element to check @param stdClass $rule The rule to check against @return bool True if the element passes (and so can be kept), false if it fails (and so needs stripping)
[ "Given", "a", "DOMElement", "and", "an", "element", "rule", "check", "if", "that", "element", "passes", "the", "rule" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/HTMLEditor/HTMLEditorSanitiser.php#L214-L244
train
silverstripe/silverstripe-framework
src/Forms/HTMLEditor/HTMLEditorSanitiser.php
HTMLEditorSanitiser.attributeMatchesRule
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
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...
[ "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 ...
Given a DOMAttr and an attribute rule, check if that attribute passes the rule @param DOMAttr $attr - the attribute to check @param stdClass $rule - the rule to check against @return bool - true if the attribute passes (and so can be kept), false if it fails (and so needs stripping)
[ "Given", "a", "DOMAttr", "and", "an", "attribute", "rule", "check", "if", "that", "attribute", "passes", "the", "rule" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/HTMLEditor/HTMLEditorSanitiser.php#L252-L266
train
silverstripe/silverstripe-framework
src/Core/Manifest/ModuleResource.php
ModuleResource.getRelativePath
public function getRelativePath() { // Root module $parent = $this->module->getRelativePath(); if (!$parent) { return $this->relativePath; } return Path::join($parent, $this->relativePath); }
php
public function getRelativePath() { // Root module $parent = $this->module->getRelativePath(); if (!$parent) { return $this->relativePath; } return Path::join($parent, $this->relativePath); }
[ "public", "function", "getRelativePath", "(", ")", "{", "// Root module", "$", "parent", "=", "$", "this", "->", "module", "->", "getRelativePath", "(", ")", ";", "if", "(", "!", "$", "parent", ")", "{", "return", "$", "this", "->", "relativePath", ";", ...
Get the path of this resource relative to the base path. Note: In the case that this resource is mapped to the `_resources` folder, this will return the original rather than the copy / symlink. @return string Relative path (no leading /)
[ "Get", "the", "path", "of", "this", "resource", "relative", "to", "the", "base", "path", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Core/Manifest/ModuleResource.php#L70-L78
train
silverstripe/silverstripe-framework
src/Control/CookieJar.php
CookieJar.get
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 '_' $safeName = str_replace('.', '_', $name); ...
php
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 '_' $safeName = str_replace('.', '_', $name); ...
[ "public", "function", "get", "(", "$", "name", ",", "$", "includeUnsent", "=", "true", ")", "{", "$", "cookies", "=", "$", "includeUnsent", "?", "$", "this", "->", "current", ":", "$", "this", "->", "existing", ";", "if", "(", "isset", "(", "$", "c...
Get the cookie value by name Cookie names are normalised to work around PHP's behaviour of replacing incoming variable name . with _ @param string $name The name of the cookie to get @param boolean $includeUnsent Include cookies we've yet to send when fetching values @return string|null The cookie value or null if u...
[ "Get", "the", "cookie", "value", "by", "name" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/CookieJar.php#L108-L121
train
silverstripe/silverstripe-framework
src/Control/CookieJar.php
CookieJar.forceExpiry
public function forceExpiry($name, $path = null, $domain = null, $secure = false, $httpOnly = true) { $this->set($name, false, -1, $path, $domain, $secure, $httpOnly); }
php
public function forceExpiry($name, $path = null, $domain = null, $secure = false, $httpOnly = true) { $this->set($name, false, -1, $path, $domain, $secure, $httpOnly); }
[ "public", "function", "forceExpiry", "(", "$", "name", ",", "$", "path", "=", "null", ",", "$", "domain", "=", "null", ",", "$", "secure", "=", "false", ",", "$", "httpOnly", "=", "true", ")", "{", "$", "this", "->", "set", "(", "$", "name", ",",...
Force the expiry of a cookie by name @param string $name The name of the cookie to expire @param string $path The path to save the cookie on (falls back to site base) @param string $domain The domain to make the cookie available on @param boolean $secure Can the cookie only be sent over SSL? @param boolean $httpOnly P...
[ "Force", "the", "expiry", "of", "a", "cookie", "by", "name" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/CookieJar.php#L143-L146
train
silverstripe/silverstripe-framework
src/Control/CookieJar.php
CookieJar.outputCookie
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
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($...
[ "protected", "function", "outputCookie", "(", "$", "name", ",", "$", "value", ",", "$", "expiry", "=", "90", ",", "$", "path", "=", "null", ",", "$", "domain", "=", "null", ",", "$", "secure", "=", "false", ",", "$", "httpOnly", "=", "true", ")", ...
The function that actually sets the cookie using PHP @see http://uk3.php.net/manual/en/function.setcookie.php @param string $name The name of the cookie @param string|array $value The value for the cookie to hold @param int $expiry The number of days until expiry @param string $path The path to save the cookie on (fa...
[ "The", "function", "that", "actually", "sets", "the", "cookie", "using", "PHP" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Control/CookieJar.php#L162-L182
train
silverstripe/silverstripe-framework
src/Forms/CurrencyField_Disabled.php
CurrencyField_Disabled.Field
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
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); ...
[ "public", "function", "Field", "(", "$", "properties", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "value", ")", "{", "$", "val", "=", "Convert", "::", "raw2xml", "(", "$", "this", "->", "value", ")", ";", "$", "val", "=", "...
Overloaded to display the correctly formatted value for this data type @param array $properties @return string
[ "Overloaded", "to", "display", "the", "correctly", "formatted", "value", "for", "this", "data", "type" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/CurrencyField_Disabled.php#L22-L34
train
silverstripe/silverstripe-framework
src/View/Parsers/Diff.php
Diff.cleanHTML
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
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...
[ "public", "static", "function", "cleanHTML", "(", "$", "content", ",", "$", "cleaner", "=", "null", ")", "{", "if", "(", "!", "$", "cleaner", ")", "{", "if", "(", "self", "::", "$", "html_cleaner_class", "&&", "class_exists", "(", "self", "::", "$", ...
Attempt to clean invalid HTML, which messes up diffs. This cleans code if possible, using an instance of HTMLCleaner NB: By default, only extremely simple tidying is performed, by passing through DomDocument::loadHTML and saveXML @param string $content HTML content @param HTMLCleaner $cleaner Optional instance of a H...
[ "Attempt", "to", "clean", "invalid", "HTML", "which", "messes", "up", "diffs", ".", "This", "cleans", "code", "if", "possible", "using", "an", "instance", "of", "HTMLCleaner" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/View/Parsers/Diff.php#L30-L53
train
silverstripe/silverstripe-framework
src/ORM/Queries/SQLInsert.php
SQLInsert.addRow
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) { $this->rows[] = $data; } else {...
php
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) { $this->rows[] = $data; } else {...
[ "public", "function", "addRow", "(", "$", "data", "=", "null", ")", "{", "// Clear existing empty row", "if", "(", "(", "$", "current", "=", "$", "this", "->", "currentRow", "(", ")", ")", "&&", "$", "current", "->", "isEmpty", "(", ")", ")", "{", "a...
Appends a new row to insert @param array|SQLAssignmentRow $data A list of data to include for this row @return $this The self reference to this query
[ "Appends", "a", "new", "row", "to", "insert" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Queries/SQLInsert.php#L87-L101
train
silverstripe/silverstripe-framework
src/ORM/Queries/SQLInsert.php
SQLInsert.getColumns
public function getColumns() { $columns = array(); foreach ($this->getRows() as $row) { $columns = array_merge($columns, $row->getColumns()); } return array_unique($columns); }
php
public function getColumns() { $columns = array(); foreach ($this->getRows() as $row) { $columns = array_merge($columns, $row->getColumns()); } return array_unique($columns); }
[ "public", "function", "getColumns", "(", ")", "{", "$", "columns", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getRows", "(", ")", "as", "$", "row", ")", "{", "$", "columns", "=", "array_merge", "(", "$", "columns", ",", "$", ...
Returns the list of distinct column names used in this insert @return array
[ "Returns", "the", "list", "of", "distinct", "column", "names", "used", "in", "this", "insert" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Queries/SQLInsert.php#L118-L125
train
silverstripe/silverstripe-framework
src/ORM/Queries/SQLInsert.php
SQLInsert.currentRow
public function currentRow($create = false) { $current = end($this->rows); if ($create && !$current) { $this->rows[] = $current = new SQLAssignmentRow(); } return $current; }
php
public function currentRow($create = false) { $current = end($this->rows); if ($create && !$current) { $this->rows[] = $current = new SQLAssignmentRow(); } return $current; }
[ "public", "function", "currentRow", "(", "$", "create", "=", "false", ")", "{", "$", "current", "=", "end", "(", "$", "this", "->", "rows", ")", ";", "if", "(", "$", "create", "&&", "!", "$", "current", ")", "{", "$", "this", "->", "rows", "[", ...
Returns the currently set row @param boolean $create Flag to indicate if a row should be created if none exists @return SQLAssignmentRow|false The row, or false if none exists
[ "Returns", "the", "currently", "set", "row" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Queries/SQLInsert.php#L158-L165
train
silverstripe/silverstripe-framework
src/Forms/DateField.php
DateField.getDateFormat
public function getDateFormat() { // Browsers expect ISO 8601 dates, localisation is handled on the client if ($this->getHTML5()) { return DBDate::ISO_DATE; } if ($this->dateFormat) { return $this->dateFormat; } // Get from locale ret...
php
public function getDateFormat() { // Browsers expect ISO 8601 dates, localisation is handled on the client if ($this->getHTML5()) { return DBDate::ISO_DATE; } if ($this->dateFormat) { return $this->dateFormat; } // Get from locale ret...
[ "public", "function", "getDateFormat", "(", ")", "{", "// Browsers expect ISO 8601 dates, localisation is handled on the client", "if", "(", "$", "this", "->", "getHTML5", "(", ")", ")", "{", "return", "DBDate", "::", "ISO_DATE", ";", "}", "if", "(", "$", "this", ...
Get date format in CLDR standard format This can be set explicitly. If not, this will be generated from the current locale with the current date length. @see http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Field-Symbol-Table
[ "Get", "date", "format", "in", "CLDR", "standard", "format" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/DateField.php#L174-L187
train
silverstripe/silverstripe-framework
src/Forms/TreeDropdownField.php
TreeDropdownField.setFilterFunction
public function setFilterFunction($callback) { if (!is_callable($callback, true)) { throw new InvalidArgumentException('TreeDropdownField->setFilterCallback(): not passed a valid callback'); } $this->filterCallback = $callback; return $this; }
php
public function setFilterFunction($callback) { if (!is_callable($callback, true)) { throw new InvalidArgumentException('TreeDropdownField->setFilterCallback(): not passed a valid callback'); } $this->filterCallback = $callback; return $this; }
[ "public", "function", "setFilterFunction", "(", "$", "callback", ")", "{", "if", "(", "!", "is_callable", "(", "$", "callback", ",", "true", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'TreeDropdownField->setFilterCallback(): not passed a valid ca...
Set a callback used to filter the values of the tree before displaying to the user. @param callable $callback @return $this
[ "Set", "a", "callback", "used", "to", "filter", "the", "values", "of", "the", "tree", "before", "displaying", "to", "the", "user", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/TreeDropdownField.php#L295-L303
train
silverstripe/silverstripe-framework
src/Forms/TreeDropdownField.php
TreeDropdownField.setDisableFunction
public function setDisableFunction($callback) { if (!is_callable($callback, true)) { throw new InvalidArgumentException('TreeDropdownField->setDisableFunction(): not passed a valid callback'); } $this->disableCallback = $callback; return $this; }
php
public function setDisableFunction($callback) { if (!is_callable($callback, true)) { throw new InvalidArgumentException('TreeDropdownField->setDisableFunction(): not passed a valid callback'); } $this->disableCallback = $callback; return $this; }
[ "public", "function", "setDisableFunction", "(", "$", "callback", ")", "{", "if", "(", "!", "is_callable", "(", "$", "callback", ",", "true", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'TreeDropdownField->setDisableFunction(): not passed a valid ...
Set a callback used to disable checkboxes for some items in the tree @param callable $callback @return $this
[ "Set", "a", "callback", "used", "to", "disable", "checkboxes", "for", "some", "items", "in", "the", "tree" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/TreeDropdownField.php#L321-L329
train
silverstripe/silverstripe-framework
src/Forms/TreeDropdownField.php
TreeDropdownField.setSearchFunction
public function setSearchFunction($callback) { if (!is_callable($callback, true)) { throw new InvalidArgumentException('TreeDropdownField->setSearchFunction(): not passed a valid callback'); } $this->searchCallback = $callback; return $this; }
php
public function setSearchFunction($callback) { if (!is_callable($callback, true)) { throw new InvalidArgumentException('TreeDropdownField->setSearchFunction(): not passed a valid callback'); } $this->searchCallback = $callback; return $this; }
[ "public", "function", "setSearchFunction", "(", "$", "callback", ")", "{", "if", "(", "!", "is_callable", "(", "$", "callback", ",", "true", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'TreeDropdownField->setSearchFunction(): not passed a valid ca...
Set a callback used to search the hierarchy globally, even before applying the filter. @param callable $callback @return $this
[ "Set", "a", "callback", "used", "to", "search", "the", "hierarchy", "globally", "even", "before", "applying", "the", "filter", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/TreeDropdownField.php#L349-L357
train
silverstripe/silverstripe-framework
src/Forms/TreeDropdownField.php
TreeDropdownField.filterMarking
public function filterMarking($node) { $callback = $this->getFilterFunction(); if ($callback && !call_user_func($callback, $node)) { return false; } if ($this->search) { return isset($this->searchIds[$node->ID]) && $this->searchIds[$node->ID] ? true : false; ...
php
public function filterMarking($node) { $callback = $this->getFilterFunction(); if ($callback && !call_user_func($callback, $node)) { return false; } if ($this->search) { return isset($this->searchIds[$node->ID]) && $this->searchIds[$node->ID] ? true : false; ...
[ "public", "function", "filterMarking", "(", "$", "node", ")", "{", "$", "callback", "=", "$", "this", "->", "getFilterFunction", "(", ")", ";", "if", "(", "$", "callback", "&&", "!", "call_user_func", "(", "$", "callback", ",", "$", "node", ")", ")", ...
Marking public function for the tree, which combines different filters sensibly. If a filter function has been set, that will be called. And if search text is set, filter on that too. Return true if all applicable conditions are true, false otherwise. @param DataObject $node @return bool
[ "Marking", "public", "function", "for", "the", "tree", "which", "combines", "different", "filters", "sensibly", ".", "If", "a", "filter", "function", "has", "been", "set", "that", "will", "be", "called", ".", "And", "if", "search", "text", "is", "set", "fi...
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/TreeDropdownField.php#L574-L586
train
silverstripe/silverstripe-framework
src/Forms/TreeDropdownField.php
TreeDropdownField.flattenChildrenArray
protected function flattenChildrenArray($children, $parentTitles = []) { $output = []; foreach ($children as $child) { $childTitles = array_merge($parentTitles, [$child['title']]); $grandChildren = $child['children']; $contextString = implode('/', $parentTitles);...
php
protected function flattenChildrenArray($children, $parentTitles = []) { $output = []; foreach ($children as $child) { $childTitles = array_merge($parentTitles, [$child['title']]); $grandChildren = $child['children']; $contextString = implode('/', $parentTitles);...
[ "protected", "function", "flattenChildrenArray", "(", "$", "children", ",", "$", "parentTitles", "=", "[", "]", ")", "{", "$", "output", "=", "[", "]", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "childTitles", "=", "array_...
Flattens a given list of children array items, so the data is no longer structured in a hierarchy NOTE: uses {@link TreeDropdownField::$realSearchIds} to filter items by if there is a search @param array $children - the list of children, which could contain their own children @param array $parentTitles - a list of pa...
[ "Flattens", "a", "given", "list", "of", "children", "array", "items", "so", "the", "data", "is", "no", "longer", "structured", "in", "a", "hierarchy" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/TreeDropdownField.php#L713-L732
train
silverstripe/silverstripe-framework
src/Forms/TreeDropdownField.php
TreeDropdownField.getSearchResults
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
protected function getSearchResults() { $callback = $this->getSearchFunction(); if ($callback) { return call_user_func($callback, $this->getSourceObject(), $this->getLabelField(), $this->search); } $sourceObject = $this->getSourceObject(); $filters = array(); ...
[ "protected", "function", "getSearchResults", "(", ")", "{", "$", "callback", "=", "$", "this", "->", "getSearchFunction", "(", ")", ";", "if", "(", "$", "callback", ")", "{", "return", "call_user_func", "(", "$", "callback", ",", "$", "this", "->", "getS...
Get the DataObjects that matches the searched parameter. @return DataList
[ "Get", "the", "DataObjects", "that", "matches", "the", "searched", "parameter", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/TreeDropdownField.php#L779-L809
train
silverstripe/silverstripe-framework
src/Forms/TreeDropdownField.php
TreeDropdownField.getCacheKey
protected function getCacheKey() { $target = $this->getSourceObject(); if (!isset(self::$cacheKeyCache[$target])) { self::$cacheKeyCache[$target] = DataList::create($target)->max('LastEdited'); } return self::$cacheKeyCache[$target]; }
php
protected function getCacheKey() { $target = $this->getSourceObject(); if (!isset(self::$cacheKeyCache[$target])) { self::$cacheKeyCache[$target] = DataList::create($target)->max('LastEdited'); } return self::$cacheKeyCache[$target]; }
[ "protected", "function", "getCacheKey", "(", ")", "{", "$", "target", "=", "$", "this", "->", "getSourceObject", "(", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "cacheKeyCache", "[", "$", "target", "]", ")", ")", "{", "self", "::", ...
Ensure cache is keyed by last modified datetime of the underlying list. Caches the key for the respective underlying list types, since it doesn't need to query again. @return DBDatetime
[ "Ensure", "cache", "is", "keyed", "by", "last", "modified", "datetime", "of", "the", "underlying", "list", ".", "Caches", "the", "key", "for", "the", "respective", "underlying", "list", "types", "since", "it", "doesn", "t", "need", "to", "query", "again", ...
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/TreeDropdownField.php#L889-L896
train
silverstripe/silverstripe-framework
src/ORM/FieldType/DBComposite.php
DBComposite.writeToManipulation
public function writeToManipulation(&$manipulation) { foreach ($this->compositeDatabaseFields() as $field => $spec) { // Write sub-manipulation $fieldObject = $this->dbObject($field); $fieldObject->writeToManipulation($manipulation); } }
php
public function writeToManipulation(&$manipulation) { foreach ($this->compositeDatabaseFields() as $field => $spec) { // Write sub-manipulation $fieldObject = $this->dbObject($field); $fieldObject->writeToManipulation($manipulation); } }
[ "public", "function", "writeToManipulation", "(", "&", "$", "manipulation", ")", "{", "foreach", "(", "$", "this", "->", "compositeDatabaseFields", "(", ")", "as", "$", "field", "=>", "$", "spec", ")", "{", "// Write sub-manipulation", "$", "fieldObject", "=",...
Write all nested fields into a manipulation @param array $manipulation
[ "Write", "all", "nested", "fields", "into", "a", "manipulation" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/FieldType/DBComposite.php#L78-L85
train
silverstripe/silverstripe-framework
src/ORM/FieldType/DBComposite.php
DBComposite.isChanged
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) { $key = $this-...
php
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) { $key = $this-...
[ "public", "function", "isChanged", "(", ")", "{", "// When unbound, use the local changed flag", "if", "(", "!", "(", "$", "this", "->", "record", "instanceof", "DataObject", ")", ")", "{", "return", "$", "this", "->", "isChanged", ";", "}", "// Defer to parent ...
Returns true if this composite field has changed. For fields bound to a DataObject, this will be cleared when the DataObject is written.
[ "Returns", "true", "if", "this", "composite", "field", "has", "changed", ".", "For", "fields", "bound", "to", "a", "DataObject", "this", "will", "be", "cleared", "when", "the", "DataObject", "is", "written", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/FieldType/DBComposite.php#L126-L141
train
silverstripe/silverstripe-framework
src/ORM/FieldType/DBComposite.php
DBComposite.exists
public function exists() { // By default all fields foreach ($this->compositeDatabaseFields() as $field => $spec) { $fieldObject = $this->dbObject($field); if (!$fieldObject->exists()) { return false; } } return true; }
php
public function exists() { // By default all fields foreach ($this->compositeDatabaseFields() as $field => $spec) { $fieldObject = $this->dbObject($field); if (!$fieldObject->exists()) { return false; } } return true; }
[ "public", "function", "exists", "(", ")", "{", "// By default all fields", "foreach", "(", "$", "this", "->", "compositeDatabaseFields", "(", ")", "as", "$", "field", "=>", "$", "spec", ")", "{", "$", "fieldObject", "=", "$", "this", "->", "dbObject", "(",...
Composite field defaults to exists only if all fields have values @return boolean
[ "Composite", "field", "defaults", "to", "exists", "only", "if", "all", "fields", "have", "values" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/FieldType/DBComposite.php#L148-L158
train
silverstripe/silverstripe-framework
src/ORM/FieldType/DBComposite.php
DBComposite.getField
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
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...
[ "public", "function", "getField", "(", "$", "field", ")", "{", "// Skip invalid fields", "$", "fields", "=", "$", "this", "->", "compositeDatabaseFields", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "fields", "[", "$", "field", "]", ")", ")", "{"...
get value of a single composite field @param string $field @return mixed
[ "get", "value", "of", "a", "single", "composite", "field" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/FieldType/DBComposite.php#L234-L253
train
silverstripe/silverstripe-framework
src/ORM/FieldType/DBComposite.php
DBComposite.setField
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
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 ($...
[ "public", "function", "setField", "(", "$", "field", ",", "$", "value", ",", "$", "markChanged", "=", "true", ")", "{", "$", "this", "->", "objCacheClear", "(", ")", ";", "// Non-db fields get assigned as normal properties", "if", "(", "!", "$", "this", "->"...
Set value of a single composite field @param string $field @param mixed $value @param bool $markChanged @return $this
[ "Set", "value", "of", "a", "single", "composite", "field" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/FieldType/DBComposite.php#L269-L295
train
silverstripe/silverstripe-framework
src/ORM/FieldType/DBComposite.php
DBComposite.dbObject
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
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 */ ...
[ "public", "function", "dbObject", "(", "$", "field", ")", "{", "$", "fields", "=", "$", "this", "->", "compositeDatabaseFields", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "fields", "[", "$", "field", "]", ")", ")", "{", "return", "null", ";...
Get a db object for the named field @param string $field Field name @return DBField|null
[ "Get", "a", "db", "object", "for", "the", "named", "field" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/FieldType/DBComposite.php#L303-L317
train
silverstripe/silverstripe-framework
src/Forms/GridField/GridFieldDetailForm.php
GridFieldDetailForm.getItemRequestHandler
protected function getItemRequestHandler($gridField, $record, $requestHandler) { $class = $this->getItemRequestClass(); $assignedClass = $this->itemRequestClass; $this->extend('updateItemRequestClass', $class, $gridField, $record, $requestHandler, $assignedClass); /** @var GridFieldD...
php
protected function getItemRequestHandler($gridField, $record, $requestHandler) { $class = $this->getItemRequestClass(); $assignedClass = $this->itemRequestClass; $this->extend('updateItemRequestClass', $class, $gridField, $record, $requestHandler, $assignedClass); /** @var GridFieldD...
[ "protected", "function", "getItemRequestHandler", "(", "$", "gridField", ",", "$", "record", ",", "$", "requestHandler", ")", "{", "$", "class", "=", "$", "this", "->", "getItemRequestClass", "(", ")", ";", "$", "assignedClass", "=", "$", "this", "->", "it...
Build a request handler for the given record @param GridField $gridField @param DataObject $record @param RequestHandler $requestHandler @return GridFieldDetailForm_ItemRequest
[ "Build", "a", "request", "handler", "for", "the", "given", "record" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridFieldDetailForm.php#L146-L161
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.duplicate
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
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...
[ "public", "function", "duplicate", "(", "$", "doWrite", "=", "true", ",", "$", "relations", "=", "null", ")", "{", "// Handle legacy behaviour", "if", "(", "is_string", "(", "$", "relations", ")", "||", "$", "relations", "===", "true", ")", "{", "if", "(...
Create a duplicate of this node. Can duplicate many_many relations @param bool $doWrite Perform a write() operation before returning the object. If this is true, it will create the duplicate in the database. @param array|null|false $relations List of relations to duplicate. Will default to `cascade_duplicates` if null...
[ "Create", "a", "duplicate", "of", "this", "node", ".", "Can", "duplicate", "many_many", "relations" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L425-L463
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.duplicateRelations
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
protected function duplicateRelations($sourceObject, $destinationObject, $relations) { // Get list of duplicable relation types $manyMany = $sourceObject->manyMany(); $hasMany = $sourceObject->hasMany(); $hasOne = $sourceObject->hasOne(); $belongsTo = $sourceObject->belongsTo...
[ "protected", "function", "duplicateRelations", "(", "$", "sourceObject", ",", "$", "destinationObject", ",", "$", "relations", ")", "{", "// Get list of duplicable relation types", "$", "manyMany", "=", "$", "sourceObject", "->", "manyMany", "(", ")", ";", "$", "h...
Copies the given relations from this object to the destination @param DataObject $sourceObject the source object to duplicate from @param DataObject $destinationObject the destination object to populate with the duplicated relations @param array $relations List of relations
[ "Copies", "the", "given", "relations", "from", "this", "object", "to", "the", "destination" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L472-L507
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.duplicateManyManyRelations
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') { $relations = $sourc...
php
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') { $relations = $sourc...
[ "protected", "function", "duplicateManyManyRelations", "(", "$", "sourceObject", ",", "$", "destinationObject", ",", "$", "filter", ")", "{", "Deprecation", "::", "notice", "(", "'5.0'", ",", "'Use duplicateRelations() instead'", ")", ";", "// Get list of relations to d...
Copies the many_many and belongs_many_many relations from one object to another instance of the name of object. @deprecated 4.1.0:5.0.0 Use duplicateRelations() instead @param DataObject $sourceObject the source object to duplicate from @param DataObject $destinationObject the destination object to populate with the d...
[ "Copies", "the", "many_many", "and", "belongs_many_many", "relations", "from", "one", "object", "to", "another", "instance", "of", "the", "name", "of", "object", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L517-L532
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.update
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
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 */ ...
[ "public", "function", "update", "(", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "// Implement dot syntax for updates", "if", "(", "strpos", "(", "$", "key", ",", "'.'", ")", "!==", "false", ")", ...
Update a number of fields on this object, given a map of the desired changes. The field names can be simple names, or you can use a dot syntax to access $has_one relations. For example, array("Author.FirstName" => "Jim") will set $this->Author()->FirstName to "Jim". Doesn't write the main object, but if you use the d...
[ "Update", "a", "number", "of", "fields", "on", "this", "object", "given", "a", "map", "of", "the", "desired", "changes", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L959-L1009
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.merge
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
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("...
[ "public", "function", "merge", "(", "$", "rightObj", ",", "$", "priority", "=", "'right'", ",", "$", "includeRelations", "=", "true", ",", "$", "overwriteWithEmpty", "=", "false", ")", "{", "$", "leftObj", "=", "$", "this", ";", "if", "(", "$", "leftOb...
Merges data and relations from another object of same class, without conflict resolution. Allows to specify which dataset takes priority in case its not empty. has_one-relations are just transferred with priority 'right'. has_many and many_many-relations are added regardless of priority. Caution: has_many/many_many re...
[ "Merges", "data", "and", "relations", "from", "another", "object", "of", "same", "class", "without", "conflict", "resolution", ".", "Allows", "to", "specify", "which", "dataset", "takes", "priority", "in", "case", "its", "not", "empty", ".", "has_one", "-", ...
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1049-L1120
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.forceChange
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) { if (!isset($this->record[$fi...
php
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) { if (!isset($this->record[$fi...
[ "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",...
Forces the record to think that all its data has changed. Doesn't write to the database. Force-change preseved until next write. Existing CHANGE_VALUE or CHANGE_STRICT values are preserved. @return $this
[ "Forces", "the", "record", "to", "think", "that", "all", "its", "data", "has", "changed", ".", "Doesn", "t", "write", "to", "the", "database", ".", "Force", "-", "change", "preseved", "until", "next", "write", ".", "Existing", "CHANGE_VALUE", "or", "CHANGE...
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1130-L1145
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.validateWrite
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
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" ); } ...
[ "protected", "function", "validateWrite", "(", ")", "{", "if", "(", "$", "this", "->", "ObsoleteClassName", ")", "{", "return", "new", "ValidationException", "(", "\"Object is of class '{$this->ObsoleteClassName}' which doesn't exist - \"", ".", "\"you need to change the Clas...
Determine validation of this object prior to write @return ValidationException Exception generated by this write, or null if valid
[ "Determine", "validation", "of", "this", "object", "prior", "to", "write" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1305-L1322
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.preWrite
protected function preWrite() { // Validate this object if ($writeException = $this->validateWrite()) { // Used by DODs to clean up after themselves, eg, Versioned $this->invokeWithExtensions('onAfterSkippedWrite'); throw $writeException; } // Che...
php
protected function preWrite() { // Validate this object if ($writeException = $this->validateWrite()) { // Used by DODs to clean up after themselves, eg, Versioned $this->invokeWithExtensions('onAfterSkippedWrite'); throw $writeException; } // Che...
[ "protected", "function", "preWrite", "(", ")", "{", "// Validate this object", "if", "(", "$", "writeException", "=", "$", "this", "->", "validateWrite", "(", ")", ")", "{", "// Used by DODs to clean up after themselves, eg, Versioned", "$", "this", "->", "invokeWithE...
Prepare an object prior to write @throws ValidationException
[ "Prepare", "an", "object", "prior", "to", "write" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1329-L1345
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.updateChanges
protected function updateChanges($forceChanges = false) { if ($forceChanges) { // Force changes, but only for loaded fields foreach ($this->record as $field => $value) { $this->changed[$field] = static::CHANGE_VALUE; } return true; } ...
php
protected function updateChanges($forceChanges = false) { if ($forceChanges) { // Force changes, but only for loaded fields foreach ($this->record as $field => $value) { $this->changed[$field] = static::CHANGE_VALUE; } return true; } ...
[ "protected", "function", "updateChanges", "(", "$", "forceChanges", "=", "false", ")", "{", "if", "(", "$", "forceChanges", ")", "{", "// Force changes, but only for loaded fields", "foreach", "(", "$", "this", "->", "record", "as", "$", "field", "=>", "$", "v...
Detects and updates all changes made to this object @param bool $forceChanges If set to true, force all fields to be treated as changed @return bool True if any changes are detected
[ "Detects", "and", "updates", "all", "changes", "made", "to", "this", "object" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1353-L1363
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.prepareManipulationTable
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
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 ...
[ "protected", "function", "prepareManipulationTable", "(", "$", "baseTable", ",", "$", "now", ",", "$", "isNewRecord", ",", "&", "$", "manipulation", ",", "$", "class", ")", "{", "$", "schema", "=", "$", "this", "->", "getSchema", "(", ")", ";", "$", "t...
Writes a subset of changes for a specific table to the given manipulation @param string $baseTable Base table @param string $now Timestamp to use for the current time @param bool $isNewRecord Whether this should be treated as a new record write @param array $manipulation Manipulation to write to @param string $class C...
[ "Writes", "a", "subset", "of", "changes", "for", "a", "specific", "table", "to", "the", "given", "manipulation" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1374-L1428
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.writeBaseRecord
protected function writeBaseRecord($baseTable, $now) { // Generate new ID if not specified if ($this->isInDB()) { return; } // Perform an insert on the base table $manipulation = []; $this->prepareManipulationTable($baseTable, $now, true, $manipulation, $...
php
protected function writeBaseRecord($baseTable, $now) { // Generate new ID if not specified if ($this->isInDB()) { return; } // Perform an insert on the base table $manipulation = []; $this->prepareManipulationTable($baseTable, $now, true, $manipulation, $...
[ "protected", "function", "writeBaseRecord", "(", "$", "baseTable", ",", "$", "now", ")", "{", "// Generate new ID if not specified", "if", "(", "$", "this", "->", "isInDB", "(", ")", ")", "{", "return", ";", "}", "// Perform an insert on the base table", "$", "m...
Ensures that a blank base record exists with the basic fixed fields for this dataobject Does nothing if an ID is already assigned for this record @param string $baseTable Base table @param string $now Timestamp to use for the current time
[ "Ensures", "that", "a", "blank", "base", "record", "exists", "with", "the", "basic", "fixed", "fields", "for", "this", "dataobject" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1438-L1452
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.writeManipulation
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
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...
[ "protected", "function", "writeManipulation", "(", "$", "baseTable", ",", "$", "now", ",", "$", "isNewRecord", ")", "{", "// Generate database manipulations for each class", "$", "manipulation", "=", "array", "(", ")", ";", "foreach", "(", "ClassInfo", "::", "ance...
Generate and write the database manipulation for all changed fields @param string $baseTable Base table @param string $now Timestamp to use for the current time @param bool $isNewRecord If this is a new record @throws InvalidArgumentException
[ "Generate", "and", "write", "the", "database", "manipulation", "for", "all", "changed", "fields" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1462-L1499
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.writeRelations
public function writeRelations() { if (!$this->isInDB()) { return; } // If there's any relations that couldn't be saved before, save them now (we have an ID here) if ($this->unsavedRelations) { foreach ($this->unsavedRelations as $name => $list) { ...
php
public function writeRelations() { if (!$this->isInDB()) { return; } // If there's any relations that couldn't be saved before, save them now (we have an ID here) if ($this->unsavedRelations) { foreach ($this->unsavedRelations as $name => $list) { ...
[ "public", "function", "writeRelations", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isInDB", "(", ")", ")", "{", "return", ";", "}", "// If there's any relations that couldn't be saved before, save them now (we have an ID here)", "if", "(", "$", "this", "->",...
Writes cached relation lists to the database, if possible
[ "Writes", "cached", "relation", "lists", "to", "the", "database", "if", "possible" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1578-L1591
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.writeComponents
public function writeComponents($recursive = false) { foreach ($this->components as $component) { $component->write(false, false, false, $recursive); } if ($join = $this->getJoin()) { $join->write(false, false, false, $recursive); } return $this; ...
php
public function writeComponents($recursive = false) { foreach ($this->components as $component) { $component->write(false, false, false, $recursive); } if ($join = $this->getJoin()) { $join->write(false, false, false, $recursive); } return $this; ...
[ "public", "function", "writeComponents", "(", "$", "recursive", "=", "false", ")", "{", "foreach", "(", "$", "this", "->", "components", "as", "$", "component", ")", "{", "$", "component", "->", "write", "(", "false", ",", "false", ",", "false", ",", "...
Write the cached components to the database. Cached components could refer to two different instances of the same record. @param bool $recursive Recursively write components @return DataObject $this
[ "Write", "the", "cached", "components", "to", "the", "database", ".", "Cached", "components", "could", "refer", "to", "two", "different", "instances", "of", "the", "same", "record", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1600-L1611
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.delete_by_id
public static function delete_by_id($className, $id) { $obj = DataObject::get_by_id($className, $id); if ($obj) { $obj->delete(); } else { user_error("$className object #$id wasn't found when calling DataObject::delete_by_id", E_USER_WARNING); } }
php
public static function delete_by_id($className, $id) { $obj = DataObject::get_by_id($className, $id); if ($obj) { $obj->delete(); } else { user_error("$className object #$id wasn't found when calling DataObject::delete_by_id", E_USER_WARNING); } }
[ "public", "static", "function", "delete_by_id", "(", "$", "className", ",", "$", "id", ")", "{", "$", "obj", "=", "DataObject", "::", "get_by_id", "(", "$", "className", ",", "$", "id", ")", ";", "if", "(", "$", "obj", ")", "{", "$", "obj", "->", ...
Delete the record with the given ID. @param string $className The class name of the record to be deleted @param int $id ID of record to be deleted
[ "Delete", "the", "record", "with", "the", "given", "ID", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1663-L1671
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.getComponent
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
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...
[ "public", "function", "getComponent", "(", "$", "componentName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "components", "[", "$", "componentName", "]", ")", ")", "{", "return", "$", "this", "->", "components", "[", "$", "componentName", "]",...
Return a unary component object from a one to one relationship, as a DataObject. If no component is available, an 'empty component' will be returned for non-polymorphic relations, or for polymorphic relations with a class set. @param string $componentName Name of the component @return DataObject The component object. ...
[ "Return", "a", "unary", "component", "object", "from", "a", "one", "to", "one", "relationship", "as", "a", "DataObject", ".", "If", "no", "component", "is", "available", "an", "empty", "component", "will", "be", "returned", "for", "non", "-", "polymorphic", ...
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1695-L1766
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.setComponent
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
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...
[ "public", "function", "setComponent", "(", "$", "componentName", ",", "$", "item", ")", "{", "// Validate component", "$", "schema", "=", "static", "::", "getSchema", "(", ")", ";", "if", "(", "$", "class", "=", "$", "schema", "->", "hasOneComponent", "(",...
Assign an item to the given component @param string $componentName @param DataObject|null $item @return $this
[ "Assign", "an", "item", "to", "the", "given", "component" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1775-L1812
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.getComponents
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
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) { ...
[ "public", "function", "getComponents", "(", "$", "componentName", ",", "$", "id", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "id", ")", ")", "{", "$", "id", "=", "$", "this", "->", "ID", ";", "}", "$", "result", "=", "null", ";",...
Returns a one-to-many relation as a HasManyList @param string $componentName Name of the component @param int|array $id Optional ID(s) for parent of this relation, if not the current record @return HasManyList|UnsavedRelationList The components of the one-to-many relationship.
[ "Returns", "a", "one", "-", "to", "-", "many", "relation", "as", "a", "HasManyList" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1821-L1859
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.getRelationClass
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
public function getRelationClass($relationName) { // Parse many_many $manyManyComponent = $this->getSchema()->manyManyComponent(static::class, $relationName); if ($manyManyComponent) { return $manyManyComponent['childClass']; } // Go through all relationship conf...
[ "public", "function", "getRelationClass", "(", "$", "relationName", ")", "{", "// Parse many_many", "$", "manyManyComponent", "=", "$", "this", "->", "getSchema", "(", ")", "->", "manyManyComponent", "(", "static", "::", "class", ",", "$", "relationName", ")", ...
Find the foreign class of a relation on this DataObject, regardless of the relation type. @param string $relationName Relation name. @return string Class name, or null if not found.
[ "Find", "the", "foreign", "class", "of", "a", "relation", "on", "this", "DataObject", "regardless", "of", "the", "relation", "type", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1867-L1896
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.getRelationType
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); if ($relations && isset($relations[$component]...
php
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); if ($relations && isset($relations[$component]...
[ "public", "function", "getRelationType", "(", "$", "component", ")", "{", "$", "types", "=", "array", "(", "'has_one'", ",", "'has_many'", ",", "'many_many'", ",", "'belongs_many_many'", ",", "'belongs_to'", ")", ";", "$", "config", "=", "$", "this", "->", ...
Given a relation name, determine the relation type @param string $component Name of component @return string has_one, has_many, many_many, belongs_many_many or belongs_to
[ "Given", "a", "relation", "name", "determine", "the", "relation", "type" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1904-L1915
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.inferReciprocalComponent
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
public function inferReciprocalComponent($remoteClass, $remoteRelation) { $remote = DataObject::singleton($remoteClass); $class = $remote->getRelationClass($remoteRelation); $schema = static::getSchema(); // Validate arguments if (!$this->isInDB()) { throw new Ba...
[ "public", "function", "inferReciprocalComponent", "(", "$", "remoteClass", ",", "$", "remoteRelation", ")", "{", "$", "remote", "=", "DataObject", "::", "singleton", "(", "$", "remoteClass", ")", ";", "$", "class", "=", "$", "remote", "->", "getRelationClass",...
Given a relation declared on a remote class, generate a substitute component for the opposite side of the relation. Notes on behaviour: - This can still be used on components that are defined on both sides, but do not need to be. - All has_ones on remote class will be treated as local has_many, even if they are belong...
[ "Given", "a", "relation", "declared", "on", "a", "remote", "class", "generate", "a", "substitute", "component", "for", "the", "opposite", "side", "of", "the", "relation", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L1934-L2030
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.getManyManyComponents
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
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...
[ "public", "function", "getManyManyComponents", "(", "$", "componentName", ",", "$", "id", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "id", ")", ")", "{", "$", "id", "=", "$", "this", "->", "ID", ";", "}", "$", "schema", "=", "stati...
Returns a many-to-many component, as a ManyManyList. @param string $componentName Name of the many-many component @param int|array $id Optional ID for parent of this relation, if not the current record @return ManyManyList|UnsavedRelationList The set of components
[ "Returns", "a", "many", "-", "to", "-", "many", "component", "as", "a", "ManyManyList", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L2038-L2098
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.belongsTo
public function belongsTo($classOnly = true) { $belongsTo = (array)$this->config()->get('belongs_to'); if ($belongsTo && $classOnly) { return preg_replace('/(.+)?\..+/', '$1', $belongsTo); } else { return $belongsTo ? $belongsTo : array(); } }
php
public function belongsTo($classOnly = true) { $belongsTo = (array)$this->config()->get('belongs_to'); if ($belongsTo && $classOnly) { return preg_replace('/(.+)?\..+/', '$1', $belongsTo); } else { return $belongsTo ? $belongsTo : array(); } }
[ "public", "function", "belongsTo", "(", "$", "classOnly", "=", "true", ")", "{", "$", "belongsTo", "=", "(", "array", ")", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'belongs_to'", ")", ";", "if", "(", "$", "belongsTo", "&&", "$", "c...
Returns the class of a remote belongs_to relationship. If no component is specified a map of all components and their class name will be returned. @param bool $classOnly If this is TRUE, than any has_many relationships in the form "ClassName.Field" will have the field data stripped off. It defaults to TRUE. @return st...
[ "Returns", "the", "class", "of", "a", "remote", "belongs_to", "relationship", ".", "If", "no", "component", "is", "specified", "a", "map", "of", "all", "components", "and", "their", "class", "name", "will", "be", "returned", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L2120-L2128
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.loadLazyFields
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
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) ==...
[ "protected", "function", "loadLazyFields", "(", "$", "class", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "isInDB", "(", ")", "||", "!", "is_numeric", "(", "$", "this", "->", "ID", ")", ")", "{", "return", "false", ";", "}", "if", "...
Loads all the stub fields that an initial lazy load didn't load fully. @param string $class Class to load the values from. Others are joined as required. Not specifying a tableClass will load all lazy fields from all tables. @return bool Flag if lazy loading succeeded
[ "Loads", "all", "the", "stub", "fields", "that", "an", "initial", "lazy", "load", "didn", "t", "load", "fully", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L2451-L2526
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.getChangedFields
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
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...
[ "public", "function", "getChangedFields", "(", "$", "databaseFieldsOnly", "=", "false", ",", "$", "changeLevel", "=", "self", "::", "CHANGE_STRICT", ")", "{", "$", "changedFields", "=", "array", "(", ")", ";", "// Update the changed array with references to changed ob...
Return the fields that have changed since the last write. The change level affects what the functions defines as "changed": - Level CHANGE_STRICT (integer 1) will return strict changes, even !== ones. - Level CHANGE_VALUE (integer 2) is more lenient, it will only return real data changes, for example a change from 0 t...
[ "Return", "the", "fields", "that", "have", "changed", "since", "the", "last", "write", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L2548-L2606
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.hasDatabaseField
public function hasDatabaseField($field) { $spec = static::getSchema()->fieldSpec(static::class, $field, DataObjectSchema::DB_ONLY); return !empty($spec); }
php
public function hasDatabaseField($field) { $spec = static::getSchema()->fieldSpec(static::class, $field, DataObjectSchema::DB_ONLY); return !empty($spec); }
[ "public", "function", "hasDatabaseField", "(", "$", "field", ")", "{", "$", "spec", "=", "static", "::", "getSchema", "(", ")", "->", "fieldSpec", "(", "static", "::", "class", ",", "$", "field", ",", "DataObjectSchema", "::", "DB_ONLY", ")", ";", "retur...
Returns true if the given field exists as a database column @param string $field Name of the field @return boolean
[ "Returns", "true", "if", "the", "given", "field", "exists", "as", "a", "database", "column" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L2793-L2797
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.relObject
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
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...
[ "public", "function", "relObject", "(", "$", "fieldPath", ")", "{", "$", "object", "=", "null", ";", "$", "component", "=", "$", "this", ";", "// Parse all relations", "foreach", "(", "explode", "(", "'.'", ",", "$", "fieldPath", ")", "as", "$", "relatio...
Traverses to a DBField referenced by relationships between data objects. The path to the related field is specified with dot separated syntax (eg: Parent.Child.Child.FieldName). If a relation is blank, this will return null instead. If a relation name is invalid (e.g. non-relation on a parent) this can throw a LogicE...
[ "Traverses", "to", "a", "DBField", "referenced", "by", "relationships", "between", "data", "objects", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L3001-L3030
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.getReverseAssociation
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
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...
[ "public", "function", "getReverseAssociation", "(", "$", "className", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "manyMany", "(", ")", ")", ")", "{", "$", "many_many", "=", "array_flip", "(", "$", "this", "->", "manyMany", "(", ")", ")", ...
Temporary hack to return an association name, based on class, to get around the mangle of having to deal with reverse lookup of relationships to determine autogenerated foreign keys. @param string $className @return string
[ "Temporary", "hack", "to", "return", "an", "association", "name", "based", "on", "class", "to", "get", "around", "the", "mangle", "of", "having", "to", "deal", "with", "reverse", "lookup", "of", "relationships", "to", "determine", "autogenerated", "foreign", "...
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L3066-L3088
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.get
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
public static function get( $callerClass = null, $filter = "", $sort = "", $join = "", $limit = null, $containerClass = DataList::class ) { // Validate arguments if ($callerClass == null) { $callerClass = get_called_class(); if ...
[ "public", "static", "function", "get", "(", "$", "callerClass", "=", "null", ",", "$", "filter", "=", "\"\"", ",", "$", "sort", "=", "\"\"", ",", "$", "join", "=", "\"\"", ",", "$", "limit", "=", "null", ",", "$", "containerClass", "=", "DataList", ...
Return all objects matching the filter sub-classes are automatically selected and included @param string $callerClass The class of objects to be returned @param string|array $filter A filter to be inserted into the WHERE clause. Supports parameterised queries. See SQLSelect::addWhere() for syntax examples. @param stri...
[ "Return", "all", "objects", "matching", "the", "filter", "sub", "-", "classes", "are", "automatically", "selected", "and", "included" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L3107-L3150
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.flush_and_destroy_cache
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) { $item->de...
php
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) { $item->de...
[ "public", "static", "function", "flush_and_destroy_cache", "(", ")", "{", "if", "(", "self", "::", "$", "_cache_get_one", ")", "{", "foreach", "(", "self", "::", "$", "_cache_get_one", "as", "$", "class", "=>", "$", "items", ")", "{", "if", "(", "is_arra...
Flush the get_one global cache and destroy associated objects.
[ "Flush", "the", "get_one", "global", "cache", "and", "destroy", "associated", "objects", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L3228-L3242
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.reset
public static function reset() { // @todo Decouple these DBEnum::flushCache(); ClassInfo::reset_db_cache(); static::getSchema()->reset(); self::$_cache_get_one = array(); self::$_cache_field_labels = array(); }
php
public static function reset() { // @todo Decouple these DBEnum::flushCache(); ClassInfo::reset_db_cache(); static::getSchema()->reset(); self::$_cache_get_one = array(); self::$_cache_field_labels = array(); }
[ "public", "static", "function", "reset", "(", ")", "{", "// @todo Decouple these", "DBEnum", "::", "flushCache", "(", ")", ";", "ClassInfo", "::", "reset_db_cache", "(", ")", ";", "static", "::", "getSchema", "(", ")", "->", "reset", "(", ")", ";", "self",...
Reset all global caches associated with DataObject.
[ "Reset", "all", "global", "caches", "associated", "with", "DataObject", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L3247-L3255
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.get_by_id
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
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...
[ "public", "static", "function", "get_by_id", "(", "$", "classOrID", ",", "$", "idOrCache", "=", "null", ",", "$", "cache", "=", "true", ")", "{", "// Shift arguments if passing id in first or second argument", "list", "(", "$", "class", ",", "$", "id", ",", "$...
Return the given element, searching by ID. This can be called either via `DataObject::get_by_id(MyClass::class, $id)` or `MyClass::get_by_id($id)` @param string|int $classOrID The class of the object to be returned, or id if called on target class @param int|bool $idOrCache The id of the element, or cache if called o...
[ "Return", "the", "given", "element", "searching", "by", "ID", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L3269-L3284
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.fieldLabels
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
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...
[ "public", "function", "fieldLabels", "(", "$", "includerelations", "=", "true", ")", "{", "$", "cacheKey", "=", "static", "::", "class", ".", "'_'", ".", "$", "includerelations", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "_cache_field_labels", ...
Get any user defined searchable fields labels that exist. Allows overriding of default field names in the form interface actually presented to the user. The reason for keeping this separate from searchable_fields, which would be a logical place for this functionality, is to avoid bloating and complicating the configur...
[ "Get", "any", "user", "defined", "searchable", "fields", "labels", "that", "exist", ".", "Allows", "overriding", "of", "default", "field", "names", "in", "the", "form", "interface", "actually", "presented", "to", "the", "user", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L3582-L3636
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.summaryFields
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
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] = ...
[ "public", "function", "summaryFields", "(", ")", "{", "$", "rawFields", "=", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'summary_fields'", ")", ";", "// Merge associative / numeric keys", "$", "fields", "=", "[", "]", ";", "foreach", "(", "$...
Get the default summary fields for this object. @todo use the translation apparatus to return a default field selection for the language @return array
[ "Get", "the", "default", "summary", "fields", "for", "this", "object", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L3661-L3707
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.defaultSearchFilters
public function defaultSearchFilters() { $filters = array(); foreach ($this->searchableFields() as $name => $spec) { if (empty($spec['filter'])) { /** @skipUpgrade */ $filters[$name] = 'PartialMatchFilter'; } elseif ($spec['filter'] instanceof...
php
public function defaultSearchFilters() { $filters = array(); foreach ($this->searchableFields() as $name => $spec) { if (empty($spec['filter'])) { /** @skipUpgrade */ $filters[$name] = 'PartialMatchFilter'; } elseif ($spec['filter'] instanceof...
[ "public", "function", "defaultSearchFilters", "(", ")", "{", "$", "filters", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "searchableFields", "(", ")", "as", "$", "name", "=>", "$", "spec", ")", "{", "if", "(", "empty", "(", "$", ...
Defines a default list of filters for the search context. If a filter class mapping is defined on the data object, it is constructed here. Otherwise, the default filter specified in {@link DBField} is used. @todo error handling/type checking for valid FormField and SearchFilter subclasses? @return array
[ "Defines", "a", "default", "list", "of", "filters", "for", "the", "search", "context", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L3720-L3736
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.setJoin
public function setJoin(DataObject $object, $alias = null) { $this->joinRecord = $object; if ($alias) { if (static::getSchema()->fieldSpec(static::class, $alias)) { throw new InvalidArgumentException( "Joined record $alias cannot also be a db field" ...
php
public function setJoin(DataObject $object, $alias = null) { $this->joinRecord = $object; if ($alias) { if (static::getSchema()->fieldSpec(static::class, $alias)) { throw new InvalidArgumentException( "Joined record $alias cannot also be a db field" ...
[ "public", "function", "setJoin", "(", "DataObject", "$", "object", ",", "$", "alias", "=", "null", ")", "{", "$", "this", "->", "joinRecord", "=", "$", "object", ";", "if", "(", "$", "alias", ")", "{", "if", "(", "static", "::", "getSchema", "(", "...
Set joining object @param DataObject $object @param string $alias Alias @return $this
[ "Set", "joining", "object" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L4035-L4047
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.findRelatedObjects
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
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) ...
[ "public", "function", "findRelatedObjects", "(", "$", "source", ",", "$", "recursive", "=", "true", ",", "$", "list", "=", "null", ")", "{", "if", "(", "!", "$", "list", ")", "{", "$", "list", "=", "new", "ArrayList", "(", ")", ";", "}", "// Skip s...
Find objects in the given relationships, merging them into the given list @param string $source Config property to extract relationships from @param bool $recursive True if recursive @param ArrayList $list If specified, items will be added to this list. If not, a new instance of ArrayList will be constructed and retur...
[ "Find", "objects", "in", "the", "given", "relationships", "merging", "them", "into", "the", "given", "list" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L4058-L4097
train
silverstripe/silverstripe-framework
src/ORM/DataObject.php
DataObject.mergeRelatedObject
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
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...
[ "protected", "function", "mergeRelatedObject", "(", "$", "list", ",", "$", "added", ",", "$", "item", ")", "{", "// Identify item", "$", "itemKey", "=", "get_class", "(", "$", "item", ")", ".", "'/'", ".", "$", "item", "->", "ID", ";", "// Write if saved...
Merge single object into a list, but ensures that existing objects are not re-added. @param ArrayList $list Global list @param ArrayList $added Additional list to insert into @param DataObject $item Item to add
[ "Merge", "single", "object", "into", "a", "list", "but", "ensures", "that", "existing", "objects", "are", "not", "re", "-", "added", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/DataObject.php#L4132-L4148
train
silverstripe/silverstripe-framework
src/Forms/GridField/GridFieldPrintButton.php
GridFieldPrintButton.handleAction
public function handleAction(GridField $gridField, $actionName, $arguments, $data) { if ($actionName == 'print') { return $this->handlePrint($gridField); } }
php
public function handleAction(GridField $gridField, $actionName, $arguments, $data) { if ($actionName == 'print') { return $this->handlePrint($gridField); } }
[ "public", "function", "handleAction", "(", "GridField", "$", "gridField", ",", "$", "actionName", ",", "$", "arguments", ",", "$", "data", ")", "{", "if", "(", "$", "actionName", "==", "'print'", ")", "{", "return", "$", "this", "->", "handlePrint", "(",...
Handle the print action. @param GridField $gridField @param string $actionName @param array $arguments @param array $data @return DBHTMLText
[ "Handle", "the", "print", "action", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridFieldPrintButton.php#L99-L104
train
silverstripe/silverstripe-framework
src/Forms/GridField/GridFieldPrintButton.php
GridFieldPrintButton.handlePrint
public function handlePrint($gridField, $request = null) { set_time_limit(60); Requirements::clear(); $data = $this->generatePrintData($gridField); $this->extend('updatePrintData', $data); if ($data) { return $data->renderWith([ get_class($gridF...
php
public function handlePrint($gridField, $request = null) { set_time_limit(60); Requirements::clear(); $data = $this->generatePrintData($gridField); $this->extend('updatePrintData', $data); if ($data) { return $data->renderWith([ get_class($gridF...
[ "public", "function", "handlePrint", "(", "$", "gridField", ",", "$", "request", "=", "null", ")", "{", "set_time_limit", "(", "60", ")", ";", "Requirements", "::", "clear", "(", ")", ";", "$", "data", "=", "$", "this", "->", "generatePrintData", "(", ...
Handle the print, for both the action button and the URL @param GridField $gridField @param HTTPRequest $request @return DBHTMLText
[ "Handle", "the", "print", "for", "both", "the", "action", "button", "and", "the", "URL" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridFieldPrintButton.php#L126-L143
train
silverstripe/silverstripe-framework
src/Forms/GridField/GridFieldPrintButton.php
GridFieldPrintButton.getPrintColumnsForGridField
protected function getPrintColumnsForGridField(GridField $gridField) { if ($this->printColumns) { return $this->printColumns; } /** @var GridFieldDataColumns $dataCols */ $dataCols = $gridField->getConfig()->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDa...
php
protected function getPrintColumnsForGridField(GridField $gridField) { if ($this->printColumns) { return $this->printColumns; } /** @var GridFieldDataColumns $dataCols */ $dataCols = $gridField->getConfig()->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDa...
[ "protected", "function", "getPrintColumnsForGridField", "(", "GridField", "$", "gridField", ")", "{", "if", "(", "$", "this", "->", "printColumns", ")", "{", "return", "$", "this", "->", "printColumns", ";", "}", "/** @var GridFieldDataColumns $dataCols */", "$", ...
Return the columns to print @param GridField @return array
[ "Return", "the", "columns", "to", "print" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridFieldPrintButton.php#L152-L165
train
silverstripe/silverstripe-framework
src/Forms/GridField/GridFieldPrintButton.php
GridFieldPrintButton.getTitle
public function getTitle(GridField $gridField) { $form = $gridField->getForm(); $currentController = $gridField->getForm()->getController(); $title = ''; if (method_exists($currentController, 'Title')) { $title = $currentController->Title(); } else { ...
php
public function getTitle(GridField $gridField) { $form = $gridField->getForm(); $currentController = $gridField->getForm()->getController(); $title = ''; if (method_exists($currentController, 'Title')) { $title = $currentController->Title(); } else { ...
[ "public", "function", "getTitle", "(", "GridField", "$", "gridField", ")", "{", "$", "form", "=", "$", "gridField", "->", "getForm", "(", ")", ";", "$", "currentController", "=", "$", "gridField", "->", "getForm", "(", ")", "->", "getController", "(", ")...
Return the title of the printed page @param GridField @return array
[ "Return", "the", "title", "of", "the", "printed", "page" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridFieldPrintButton.php#L174-L199
train
silverstripe/silverstripe-framework
src/Forms/GridField/GridFieldPrintButton.php
GridFieldPrintButton.generatePrintData
public function generatePrintData(GridField $gridField) { $printColumns = $this->getPrintColumnsForGridField($gridField); $header = null; if ($this->printHasHeader) { $header = new ArrayList(); foreach ($printColumns as $field => $label) { $header->...
php
public function generatePrintData(GridField $gridField) { $printColumns = $this->getPrintColumnsForGridField($gridField); $header = null; if ($this->printHasHeader) { $header = new ArrayList(); foreach ($printColumns as $field => $label) { $header->...
[ "public", "function", "generatePrintData", "(", "GridField", "$", "gridField", ")", "{", "$", "printColumns", "=", "$", "this", "->", "getPrintColumnsForGridField", "(", "$", "gridField", ")", ";", "$", "header", "=", "null", ";", "if", "(", "$", "this", "...
Export core. @param GridField $gridField @return ArrayData
[ "Export", "core", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/GridField/GridFieldPrintButton.php#L207-L255
train
silverstripe/silverstripe-framework
src/Forms/Form.php
Form.restoreFormState
public function restoreFormState() { // Restore messages $result = $this->getSessionValidationResult(); if (isset($result)) { $this->loadMessagesFrom($result); } // load data in from previous submission upon error $data = $this->getSessionData(); ...
php
public function restoreFormState() { // Restore messages $result = $this->getSessionValidationResult(); if (isset($result)) { $this->loadMessagesFrom($result); } // load data in from previous submission upon error $data = $this->getSessionData(); ...
[ "public", "function", "restoreFormState", "(", ")", "{", "// Restore messages", "$", "result", "=", "$", "this", "->", "getSessionValidationResult", "(", ")", ";", "if", "(", "isset", "(", "$", "result", ")", ")", "{", "$", "this", "->", "loadMessagesFrom", ...
Load form state from session state @return $this
[ "Load", "form", "state", "from", "session", "state" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/Form.php#L341-L355
train
silverstripe/silverstripe-framework
src/Forms/Form.php
Form.getRequest
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 to curre...
php
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 to curre...
[ "protected", "function", "getRequest", "(", ")", "{", "// Check if current request handler has a request object", "$", "controller", "=", "$", "this", "->", "getController", "(", ")", ";", "if", "(", "$", "controller", "&&", "!", "(", "$", "controller", "->", "g...
Helper to get current request for this form @return HTTPRequest
[ "Helper", "to", "get", "current", "request", "for", "this", "form" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/Form.php#L376-L388
train
silverstripe/silverstripe-framework
src/Forms/Form.php
Form.getSessionValidationResult
public function getSessionValidationResult() { $resultData = $this->getSession()->get("FormInfo.{$this->FormName()}.result"); if (isset($resultData)) { return unserialize($resultData); } return null; }
php
public function getSessionValidationResult() { $resultData = $this->getSession()->get("FormInfo.{$this->FormName()}.result"); if (isset($resultData)) { return unserialize($resultData); } return null; }
[ "public", "function", "getSessionValidationResult", "(", ")", "{", "$", "resultData", "=", "$", "this", "->", "getSession", "(", ")", "->", "get", "(", "\"FormInfo.{$this->FormName()}.result\"", ")", ";", "if", "(", "isset", "(", "$", "resultData", ")", ")", ...
Return any ValidationResult instance stored for this object @return ValidationResult The ValidationResult object stored in the session
[ "Return", "any", "ValidationResult", "instance", "stored", "for", "this", "object" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/Form.php#L431-L438
train
silverstripe/silverstripe-framework
src/Forms/Form.php
Form.setSessionValidationResult
public function setSessionValidationResult(ValidationResult $result, $combineWithExisting = false) { // Combine with existing result if ($combineWithExisting) { $existingResult = $this->getSessionValidationResult(); if ($existingResult) { if ($result) { ...
php
public function setSessionValidationResult(ValidationResult $result, $combineWithExisting = false) { // Combine with existing result if ($combineWithExisting) { $existingResult = $this->getSessionValidationResult(); if ($existingResult) { if ($result) { ...
[ "public", "function", "setSessionValidationResult", "(", "ValidationResult", "$", "result", ",", "$", "combineWithExisting", "=", "false", ")", "{", "// Combine with existing result", "if", "(", "$", "combineWithExisting", ")", "{", "$", "existingResult", "=", "$", ...
Sets the ValidationResult in the session to be used with the next view of this form. @param ValidationResult $result The result to save @param bool $combineWithExisting If true, then this will be added to the existing result. @return $this
[ "Sets", "the", "ValidationResult", "in", "the", "session", "to", "be", "used", "with", "the", "next", "view", "of", "this", "form", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/Form.php#L446-L464
train
silverstripe/silverstripe-framework
src/Forms/Form.php
Form.setFieldMessage
public function setFieldMessage( $fieldName, $message, $messageType = ValidationResult::TYPE_ERROR, $messageCast = ValidationResult::CAST_TEXT ) { $field = $this->fields->dataFieldByName($fieldName); if ($field) { $field->setMessage($message, $messageType,...
php
public function setFieldMessage( $fieldName, $message, $messageType = ValidationResult::TYPE_ERROR, $messageCast = ValidationResult::CAST_TEXT ) { $field = $this->fields->dataFieldByName($fieldName); if ($field) { $field->setMessage($message, $messageType,...
[ "public", "function", "setFieldMessage", "(", "$", "fieldName", ",", "$", "message", ",", "$", "messageType", "=", "ValidationResult", "::", "TYPE_ERROR", ",", "$", "messageCast", "=", "ValidationResult", "::", "CAST_TEXT", ")", "{", "$", "field", "=", "$", ...
Set message on a given field name. This message will not persist via redirect. @param string $fieldName @param string $message @param string $messageType @param string $messageCast @return $this
[ "Set", "message", "on", "a", "given", "field", "name", ".", "This", "message", "will", "not", "persist", "via", "redirect", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/Form.php#L511-L522
train
silverstripe/silverstripe-framework
src/Forms/Form.php
Form.setupDefaultClasses
protected function setupDefaultClasses() { $defaultClasses = self::config()->get('default_classes'); if ($defaultClasses) { foreach ($defaultClasses as $class) { $this->addExtraClass($class); } } }
php
protected function setupDefaultClasses() { $defaultClasses = self::config()->get('default_classes'); if ($defaultClasses) { foreach ($defaultClasses as $class) { $this->addExtraClass($class); } } }
[ "protected", "function", "setupDefaultClasses", "(", ")", "{", "$", "defaultClasses", "=", "self", "::", "config", "(", ")", "->", "get", "(", "'default_classes'", ")", ";", "if", "(", "$", "defaultClasses", ")", "{", "foreach", "(", "$", "defaultClasses", ...
set up the default classes for the form. This is done on construct so that the default classes can be removed after instantiation
[ "set", "up", "the", "default", "classes", "for", "the", "form", ".", "This", "is", "done", "on", "construct", "so", "that", "the", "default", "classes", "can", "be", "removed", "after", "instantiation" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/Form.php#L537-L545
train
silverstripe/silverstripe-framework
src/Forms/Form.php
Form.actionIsValidationExempt
public function actionIsValidationExempt($action) { // Non-actions don't bypass validation if (!$action) { return false; } if ($action->getValidationExempt()) { return true; } if (in_array($action->actionName(), $this->getValidationExemptAction...
php
public function actionIsValidationExempt($action) { // Non-actions don't bypass validation if (!$action) { return false; } if ($action->getValidationExempt()) { return true; } if (in_array($action->actionName(), $this->getValidationExemptAction...
[ "public", "function", "actionIsValidationExempt", "(", "$", "action", ")", "{", "// Non-actions don't bypass validation", "if", "(", "!", "$", "action", ")", "{", "return", "false", ";", "}", "if", "(", "$", "action", "->", "getValidationExempt", "(", ")", ")"...
Passed a FormAction, returns true if that action is exempt from Form validation @param FormAction $action @return bool
[ "Passed", "a", "FormAction", "returns", "true", "if", "that", "action", "is", "exempt", "from", "Form", "validation" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/Form.php#L692-L705
train
silverstripe/silverstripe-framework
src/Forms/Form.php
Form.Fields
public function Fields() { foreach ($this->getExtraFields() as $field) { if (!$this->fields->fieldByName($field->getName())) { $this->fields->push($field); } } return $this->fields; }
php
public function Fields() { foreach ($this->getExtraFields() as $field) { if (!$this->fields->fieldByName($field->getName())) { $this->fields->push($field); } } return $this->fields; }
[ "public", "function", "Fields", "(", ")", "{", "foreach", "(", "$", "this", "->", "getExtraFields", "(", ")", "as", "$", "field", ")", "{", "if", "(", "!", "$", "this", "->", "fields", "->", "fieldByName", "(", "$", "field", "->", "getName", "(", "...
Return the form's fields - used by the templates @return FieldList The form fields
[ "Return", "the", "form", "s", "fields", "-", "used", "by", "the", "templates" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/Form.php#L740-L749
train
silverstripe/silverstripe-framework
src/Forms/Form.php
Form.getAttributesHTML
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
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); }); //...
[ "public", "function", "getAttributesHTML", "(", "$", "attrs", "=", "null", ")", "{", "$", "exclude", "=", "(", "is_string", "(", "$", "attrs", ")", ")", "?", "func_get_args", "(", ")", ":", "null", ";", "$", "attrs", "=", "$", "this", "->", "getAttri...
Return the attributes of the form tag - used by the templates. @param array $attrs Custom attributes to process. Falls back to {@link getAttributes()}. If at least one argument is passed as a string, all arguments act as excludes by name. @return string HTML attributes, ready for insertion into an HTML tag
[ "Return", "the", "attributes", "of", "the", "form", "tag", "-", "used", "by", "the", "templates", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/Form.php#L876-L904
train
silverstripe/silverstripe-framework
src/Forms/Form.php
Form.getEncType
public function getEncType() { if ($this->encType) { return $this->encType; } if ($fields = $this->fields->dataFields()) { foreach ($fields as $field) { if ($field instanceof FileField) { return self::ENC_TYPE_MULTIPART; ...
php
public function getEncType() { if ($this->encType) { return $this->encType; } if ($fields = $this->fields->dataFields()) { foreach ($fields as $field) { if ($field instanceof FileField) { return self::ENC_TYPE_MULTIPART; ...
[ "public", "function", "getEncType", "(", ")", "{", "if", "(", "$", "this", "->", "encType", ")", "{", "return", "$", "this", "->", "encType", ";", "}", "if", "(", "$", "fields", "=", "$", "this", "->", "fields", "->", "dataFields", "(", ")", ")", ...
Returns the encoding type for the form. By default this will be URL encoded, unless there is a file field present in which case multipart is used. You can also set the enc type using {@link setEncType}.
[ "Returns", "the", "encoding", "type", "for", "the", "form", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/Form.php#L1014-L1029
train
silverstripe/silverstripe-framework
src/Forms/Form.php
Form.sessionMessage
public function sessionMessage($message, $type = ValidationResult::TYPE_ERROR, $cast = ValidationResult::CAST_TEXT) { $this->setMessage($message, $type, $cast); $result = $this->getSessionValidationResult() ?: ValidationResult::create(); $result->addMessage($message, $type, null, $cast); ...
php
public function sessionMessage($message, $type = ValidationResult::TYPE_ERROR, $cast = ValidationResult::CAST_TEXT) { $this->setMessage($message, $type, $cast); $result = $this->getSessionValidationResult() ?: ValidationResult::create(); $result->addMessage($message, $type, null, $cast); ...
[ "public", "function", "sessionMessage", "(", "$", "message", ",", "$", "type", "=", "ValidationResult", "::", "TYPE_ERROR", ",", "$", "cast", "=", "ValidationResult", "::", "CAST_TEXT", ")", "{", "$", "this", "->", "setMessage", "(", "$", "message", ",", "...
Set a message to the session, for display next time this form is shown. @param string $message the text of the message @param string $type Should be set to good, bad, or warning. @param string|bool $cast Cast type; One of the CAST_ constant definitions. Bool values will be treated as plain text flag.
[ "Set", "a", "message", "to", "the", "session", "for", "display", "next", "time", "this", "form", "is", "shown", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/Form.php#L1249-L1255
train
silverstripe/silverstripe-framework
src/Forms/Form.php
Form.sessionError
public function sessionError($message, $type = ValidationResult::TYPE_ERROR, $cast = ValidationResult::CAST_TEXT) { $this->setMessage($message, $type, $cast); $result = $this->getSessionValidationResult() ?: ValidationResult::create(); $result->addError($message, $type, null, $cast); ...
php
public function sessionError($message, $type = ValidationResult::TYPE_ERROR, $cast = ValidationResult::CAST_TEXT) { $this->setMessage($message, $type, $cast); $result = $this->getSessionValidationResult() ?: ValidationResult::create(); $result->addError($message, $type, null, $cast); ...
[ "public", "function", "sessionError", "(", "$", "message", ",", "$", "type", "=", "ValidationResult", "::", "TYPE_ERROR", ",", "$", "cast", "=", "ValidationResult", "::", "CAST_TEXT", ")", "{", "$", "this", "->", "setMessage", "(", "$", "message", ",", "$"...
Set an error to the session, for display next time this form is shown. @param string $message the text of the message @param string $type Should be set to good, bad, or warning. @param string|bool $cast Cast type; One of the CAST_ constant definitions. Bool values will be treated as plain text flag.
[ "Set", "an", "error", "to", "the", "session", "for", "display", "next", "time", "this", "form", "is", "shown", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/Form.php#L1265-L1271
train
silverstripe/silverstripe-framework
src/Forms/Form.php
Form.forTemplate
public function forTemplate() { if (!$this->canBeCached()) { HTTPCacheControlMiddleware::singleton()->disableCache(); } $return = $this->renderWith($this->getTemplates()); // Now that we're rendered, clear message $this->clearMessage(); return $return; ...
php
public function forTemplate() { if (!$this->canBeCached()) { HTTPCacheControlMiddleware::singleton()->disableCache(); } $return = $this->renderWith($this->getTemplates()); // Now that we're rendered, clear message $this->clearMessage(); return $return; ...
[ "public", "function", "forTemplate", "(", ")", "{", "if", "(", "!", "$", "this", "->", "canBeCached", "(", ")", ")", "{", "HTTPCacheControlMiddleware", "::", "singleton", "(", ")", "->", "disableCache", "(", ")", ";", "}", "$", "return", "=", "$", "thi...
Return a rendered version of this form. This is returned when you access a form as $FormObject rather than <% with FormObject %> @return DBHTMLText
[ "Return", "a", "rendered", "version", "of", "this", "form", "." ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/Form.php#L1576-L1588
train
silverstripe/silverstripe-framework
src/Forms/Form.php
Form.canBeCached
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
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...
[ "protected", "function", "canBeCached", "(", ")", "{", "if", "(", "$", "this", "->", "getSecurityToken", "(", ")", "->", "isEnabled", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "FormMethod", "(", ")", "!==", "'GET'...
Can the body of this form be cached? @return bool
[ "Can", "the", "body", "of", "this", "form", "be", "cached?" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/Forms/Form.php#L1843-L1862
train
silverstripe/silverstripe-framework
src/ORM/Connect/MySQLiConnector.php
MySQLiConnector.prepareStatement
public function prepareStatement($sql, &$success) { // Record last statement for error reporting $statement = $this->dbConn->stmt_init(); $this->setLastStatement($statement); $success = $statement->prepare($sql); return $statement; }
php
public function prepareStatement($sql, &$success) { // Record last statement for error reporting $statement = $this->dbConn->stmt_init(); $this->setLastStatement($statement); $success = $statement->prepare($sql); return $statement; }
[ "public", "function", "prepareStatement", "(", "$", "sql", ",", "&", "$", "success", ")", "{", "// Record last statement for error reporting", "$", "statement", "=", "$", "this", "->", "dbConn", "->", "stmt_init", "(", ")", ";", "$", "this", "->", "setLastStat...
Retrieve a prepared statement for a given SQL string @param string $sql @param boolean &$success @return mysqli_stmt
[ "Retrieve", "a", "prepared", "statement", "for", "a", "given", "SQL", "string" ]
ed7aaff7da61eefa172fe213ec25e35d2568bc20
https://github.com/silverstripe/silverstripe-framework/blob/ed7aaff7da61eefa172fe213ec25e35d2568bc20/src/ORM/Connect/MySQLiConnector.php#L61-L68
train