sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public static function relation($local, $foreign)
{
$relations = Config::table($local)->relations();
if (isset($relations->{$foreign}))
{
return true;
}
throw new dbException('Relation "' . $local . '" to "' . $foreign . '" doesn\'t exist');
} | Checking that relation between tables exists
@param string $local local table
@param string $foreign related table
@return bool relation exists
@throws dbException | entailment |
public function render()
{
// Set the request arguments as GET parameters
$_GET = $this->getRequestArguments();
// Instantiate a frontend controller
$typoScript = TypoScriptUtility::extractTypoScriptKeyForPidAndType(
$this->page,
$this->typeNum,
$... | Render this component
@return string Rendered component (HTML) | entailment |
protected function exportInternal()
{
// Read the linked TypoScript
if ($this->config !== null) {
$typoScript = TypoScriptUtility::extractTypoScriptKeyForPidAndType(
$this->page,
$this->typeNum,
$this->config
);
... | Return component specific properties
@return array Component specific properties | entailment |
public function Field($properties=array()) {
$obj=($properties ? $this->customise($properties):$this);
Requirements::css(CB_DIR.'/javascript/external/syntaxhighlighter/themes/shCore.css');
Requirements::css(CB_DIR.'/javascript/external/syntaxhighlighter/themes/shCore'.$thi... | Returns the form field - used by templates. Although FieldHolder is generally what is inserted into templates, all of the field holder templates make use of $Field. It's expected that FieldHolder will give you the "complete" representation of the field on the form, whereas Field will give you the core editing widget, ... | entailment |
public function parse($resource) {
$result = array();
$fieldcnt = mysqli_num_fields($resource);
$fields_transform = array();
for($i=0;$i<$fieldcnt;$i++) {
$finfo = mysqli_fetch_field_direct($resource, $i);
if(isset(self::$mysqli_type[$finfo->type])) {
... | Parse resource into array
@param resource $resource
@return array | entailment |
public function doSnippetSearch($keywords, $languageID=false, $folderID=false) {
$searchIndex=singleton('CodeBankSolrIndex');
$searchQuery=new SearchQuery();
$searchQuery->classes=array(
array(
'class'=>'Snippet',
... | Performs the search against the snippets in the system
@param {string} $keywords Keywords to search for
@param {int} $languageID Language to filter to
@param {int} $folderID Folder to filter to
@return {DataList} Data list pointing to the snippets in the results | entailment |
public function send($url, $method, $body, $headers = [], $options = [])
{
//Create a new Request Object
$request = new Request($method, $url, $headers, $body);
try {
//Send the Request
$rawResponse = $this->client->send($request, $options);
} catch (RequestE... | Send request to the server and fetch the raw response
@param string $url URL/Endpoint to send the request to
@param string $method Request Method
@param string|resource|StreamInterface $body Request Body
@param array $headers Request Headers
@param array $options Additional Options
@return BoxRawResponse ... | entailment |
public function renderAction($component)
{
// Register common stylesheets & scripts
FluidTemplate::addCommonStylesheets($this->settings['stylesheets']);
FluidTemplate::addCommonHeaderScripts($this->settings['headerScripts']);
FluidTemplate::addCommonFooterScripts($this->settings['foo... | Render a component
@param string $component Component class
@return string Rendered component | entailment |
public function graphAction($component = null)
{
$graphvizService = GeneralUtility::makeInstanceService('graphviz', 'svg');
if ($graphvizService instanceof GraphvizService) {
$graph = new Graph(Scanner::discoverAll());
return $graphvizService->createGraph($graph($component))... | Graph action
@param string $component Component class
@return string SVG component graph
@todo Add a dummy graph telling that GraphViz isn't available | entailment |
protected function populateLanguageIDs() {
$this->_cache_language_ids=array();
if($snippetLanguages=$this->snippetLanguagesIncluded()) {
// And keep a record of parents we don't need to get
// parents of themselves, as well as IDs to mark
foreach($snippetLanguages as ... | Populate the IDs of the snippet languages returned by snippetLanguagesIncluded() | entailment |
protected function populateSnippetIDs() {
$this->_cache_snippet_ids=array();
if($snippets=$this->snippetsIncluded()) {
// And keep a record of parents we don't need to get
// parents of themselves, as well as IDs to mark
foreach($snippets as $snippetId) {
... | Populate the IDs of the snippets returned by snippetsIncluded() | entailment |
protected function populateFolderIDs() {
$this->_cache_language_ids=array();
if($snippetFolders=$this->snippetFoldersIncluded()) {
// And keep a record of parents we don't need to get
// parents of themselves, as well as IDs to mark
foreach($snippetFolders as $folderI... | Populate the IDs of the snippet languages returned by snippetLanguagesIncluded() | entailment |
public function isSnippetLanguageIncluded($obj) {
if($obj instanceof SnippetLanguage) {
if($this->_cache_language_ids===null) {
$this->populateLanguageIDs();
}
return (isset($this->_cache_language_ids[$obj->ID]) && $this->_cache_language_ids[$obj-... | Returns TRUE if the given snippet or language should be included in the tree.
@param {SnippetLanguage|Snippet|SnippetFolder} $obj Object to be checked
@return {bool} Returns boolean true if the snippet or language or folder should be included in the tree false otherwise | entailment |
public function init() {
parent::init();
Requirements::css(CB_DIR.'/css/CodeBank.css');
Requirements::add_i18n_javascript(CB_DIR.'/javascript/lang');
Requirements::customScript("var CB_DIR='".CB_DIR."';", 'cb_dir');
Requirements::javascript(CB_DIR.'/javascript/C... | Initializes the code bank admin | entailment |
public function Link($action=null) {
$link = Controller::join_links(
$this->stat('url_base', true),
$this->stat('url_segment', true), // in case we want to change the segment
'/', // trailing slash needed if $action is null!
"$action"
);
$... | Override {@link LeftAndMain} Link to allow blank URL segment for CMSMain.
@param {string} $action Action to be used
@return {string} Resulting link | entailment |
protected function LinkWithSearch($link) {
// Whitelist to avoid side effects
$params=array(
'q'=>(array)$this->request->getVar('q'),
'tag'=>$this->request->getVar('tag'),
'creator'=>$this->request->getVar('creator'),
'Paren... | Generates the link with search params
@param {string} Link to
@return {string} Link with search params | entailment |
public function getLinkMain() {
if($this->currentPageID()!=0 && $this->class=='CodeBankEditSnippet') {
return $this->LinkWithSearch(Controller::join_links($this->Link('show'), $this->currentPageID()));
}else if($this->currentPageID()!=0 && $this->class=='CodeBank') {
$otherID=nul... | Gets the main tab link
@return {string} URL to the main tab | entailment |
public function getEditForm($id=null, $fields=null) {
if(!$id) {
$id=$this->currentPageID();
}
$form=parent::getEditForm($id);
$record=$this->getRecord($id);
if($record && !$record->canView()) {
return Security::permissi... | Gets the form used for viewing snippets
@param {int} $id ID of the record to fetch
@param {FieldList} $fields Fields to use
@return {Form} Form to be used | entailment |
public function getsubtree($request) {
if(strpos($request->getVar('ID'), 'folder-')!==false) {
$folderID=(strpos($request->getVar('ID'), 'folder-')!==false ? intval(str_replace('folder-', '', $request->getVar('ID'))):null);
$html=$this->getSiteTreeFor('SnippetFolder', $folderID, 'Childre... | Get a subtree underneath the request param 'ID'.
If ID = 0, then get the whole tree. | entailment |
public function updatetreenodes($request) {
$data=array();
$ids=explode(',', $request->getVar('ids'));
foreach($ids as $id) {
if($id==Session::get('CodeBank.deletedSnippetID')) {
Session::clear('CodeBank.deletedSnippetID');
$this->response->addHeader('... | Allows requesting a view update on specific tree nodes.
Similar to {@link getsubtree()}, but doesn't enforce loading
all children with the node. Useful to refresh views after
state modifications, e.g. saving a form.
@return String JSON | entailment |
public function TreeIsFiltered() {
return ($this->request->getVar('q') || $this->request->getVar('tag') || $this->request->getVar('creator'));
} | Checks to see if the tree should be filtered or not
@return {bool} | entailment |
public function SiteTreeAsUL() {
$html=$this->getSiteTreeFor($this->stat('tree_class'), null, 'Children', null);
$this->extend('updateSiteTreeAsUL', $html);
return $html;
} | Gets the snippet language tree as an unordered list
@return {string} XHTML forming the tree of languages to snippets | entailment |
public function getSiteTreeFor($className, $rootID=null, $childrenMethod=null, $numChildrenMethod=null, $filterFunction=null, $minNodeCount=30) {
// Filter criteria
$params=$this->request->getVar('q');
$tag=$this->request->getVar('tag');
$creator=$this->request->getVar('creator');
... | Get a site tree HTML listing which displays the nodes under the given criteria.
@param $className The class of the root object
@param $rootID The ID of the root object. If this is null then a complete tree will be shown
@param $childrenMethod The method to call to get the children of the tree. For example, Children, A... | entailment |
public function getRecord($id) {
$className='Snippet';
if($className && $id instanceof $className) {
return $id;
}else if($id=='root') {
return singleton($className);
}else if(is_numeric($id)) {
return DataObject::get_by_id($className, $id);
}e... | Gets the snippet for editing/viewing
@param {int} $id ID of the snippet to fetch
@return {DataObject} DataObject to use | entailment |
public function getEditLink() {
if(!empty($this->urlParams['OtherID']) && is_numeric($this->urlParams['OtherID'])) {
return $this->LinkWithSearch('admin/codeBank/show/'.$this->currentPageID().'/'.intval($this->urlParams['OtherID']));
}
return $this->LinkWithSearch('admin/cod... | Returns the link to view/edit snippets
@return {string} Link to view/edit snippets | entailment |
public function SearchForm() {
$languages=SnippetLanguage::get()
->leftJoin('Snippet', '"Snippet"."LanguageID"="SnippetLanguage"."ID"')
->where('"SnippetLanguage"."Hidden"=0 OR "Snippet"."ID" IS NOT NULL')
... | Generates the search form
@return {Form} Form used for searching | entailment |
public function compare() {
$compareContent=false;
//Get the Main Revision
$snippet1=Snippet::get()->byID(intval($this->urlParams['ID']));
if(empty($snippet1) || $snippet1===false || $snippet1->ID==0) {
$snippet1=false;
}
if($snippet... | Handles rendering of the compare view
@return {string} HTML to be sent to the browser | entailment |
public function getTreeHints() {
$json = '';
$classes = array('Snippet', 'SnippetLanguage', 'SnippetFolder');
$cacheCanCreate = array();
foreach($classes as $class) $cacheCanCreate[$class] = singleton($class)->canCreate();
// Generate basic cache key. Too complex to encompa... | Create serialized JSON string with tree hints data to be injected into 'data-hints' attribute of root node of jsTree.
@return {string} Serialized JSON | entailment |
public function addSnippet(SS_HTTPRequest $request) {
if($request->getVar('Type')=='SnippetFolder') {
return $this->redirect(Controller::join_links($this->Link('addFolder'), '?FolderID='.str_replace('folder-', '', $request->getVar('ID'))));
}else {
return $this->redirect(Control... | Handles requests to add a snippet or folder to a language
@param {SS_HTTPRequest} $request HTTP Request | entailment |
public function moveSnippet(SS_HTTPRequest $request) {
$snippet=Snippet::get()->byID(intval($request->getVar('ID')));
if(empty($snippet) || $snippet===false || $snippet->ID==0) {
$this->response->setStatusCode(403, _t('CodeBank.SNIPPIT_NOT_EXIST', '_Snippit does not exist'));
... | Handles moving of a snippet when the tree is reordered
@param {SS_HTTPRequest} $request HTTP Request | entailment |
public function AddFolderForm() {
$fields=new FieldList(
new TabSet('Root',
new Tab('Main', 'Main',
new TextField('Name', _t('SnippetFolder.NAME', '_Name'), null, 150)
... | Form used for adding a folder
@return {Form} Form to be used for adding a folder | entailment |
public function doAddFolder($data, Form $form) {
//Existing Check
$existingCheck=SnippetFolder::get()->filter('Name:nocase', Convert::raw2sql($data['Name']))->filter('LanguageID', intval($data['LanguageID']));
if(array_key_exists('FolderID', $data)) {
$existingCheck=$existin... | Handles actually adding a folder to the databsae
@param {array} $data Submitted data
@param {Form} $form Submitting form
@return {string} HTML to be rendered | entailment |
public function RenameFolderForm() {
$folder=SnippetFolder::get()->byID(intval(str_replace('folder-', '', $this->request->getVar('ID'))));
if(!empty($folder) && $folder!==false && $folder->ID!=0) {
$fields=new FieldList(
new TabSet('Root',
... | Form used for renaming a folder
@return {Form} Form to be used for renaming a folder | entailment |
public function doRenameFolder($data, Form $form) {
$folder=SnippetFolder::get()->byID(intval($data['ID']));
if(empty($folder) || $folder===false || $folder->ID==0) {
$form->sessionMessage(_t('CodeBank.FOLDER_NOT_FOUND', '_Folder could not be found'), 'bad');
return $this->redire... | Performs the rename of the folder
@param {array} $data Submitted data
@param {Form} $form Submitting form
@return {string} HTML to be rendered | entailment |
public function deleteFolder() {
$folder=SnippetFolder::get()->byID(intval(str_replace('folder-', '', $this->request->getVar('ID'))));
if(empty($folder) || $folder===false || $folder->ID==0) {
$this->response->setStatusCode(404, _t('CodeBank.FOLDER_NOT_FOUND', '_Folder could not be found'));... | Deletes a folder node | entailment |
public function printSnippet() {
$record=$this->getRecord($this->currentPageID());
if(!empty($record) && $record!==false && $record->ID>0) {
$version=false;
if(!empty($this->urlParams['OtherID']) && is_numeric($this->urlParams['OtherID'])) {
$version=$record->Vers... | Handles requests to print the current snippet
@return {string} Rendered template | entailment |
protected function hasOldTables() {
if(!file_exists(ASSETS_PATH.'/.codeBankMigrated')) {
$tables=DB::tableList();
if(array_key_exists('snippits', $tables) && array_key_exists('snippit_search', $tables)) {
return true;
}else {
touch(ASSETS_PATH.... | Tests to see if the old tables exist
@return {bool} Returns boolean true if the old tables are detected and the migration file is not detected | entailment |
public function forTemplate() {
$obj=$this->obj;
if($this->obj instanceof SnippetLanguage) {
$liAttrib='id="language-'.$obj->ID.'" data-id="language-'.$obj->ID.'"';
}else if($this->obj instanceof SnippetFolder) {
$liAttrib='id="folder-'.$obj->ID.'" data-id="folder-'.$obj-... | Returns template, for further processing by {@link Hierarchy->getChildrenAsUL()}. Does not include closing tag to allow this method to inject its own children.
@return {string} HTML to be used | entailment |
public function each(Callable $f) : void {
foreach ($this->items as $i) {
$f($i);
}
} | run a function against each item in the collection
@param callable $f | entailment |
public function equals(Collection $that) : bool {
return
get_class($this) == get_class($that) &&
$this->items === $that->items;
} | compare one collection against another. collections are
considered equal if both collection classes are of the same
type and both item arrays are considered equal with strict
comparison.
@param Collection $that
@return bool | entailment |
public function reduce(Callable $f, $initial = null) {
return array_reduce($this->items, $f, $initial);
} | return a single value reduced from the collection by the
provided function.
@param callable $f
@param null $initial
@return mixed | entailment |
public function setExtbaseConfiguration($pluginName, $controllerClass, $actionName, $extensionName = null)
{
// Validate the extension name
if (!empty($extensionName)) {
$extensionName = GeneralUtility::camelCaseToLowerCaseUnderscored(trim($extensionName));
if (!in_array($ext... | Set the extbase configuration
@param string $pluginName Plugin name
@param string $controllerClass Controller name
@param string $actionName Action name
@param string|null $extensionName Extension name | entailment |
public function setControllerActionArgument($name, $value)
{
// Validate the argument name
$name = trim($name);
if (empty($name)) {
throw new \RuntimeException('Invalid extbase controller argument name', 1481708515);
}
$this->request->setArgument($name, $value);
... | Set a controller action argument
@param string $name Argument name
@param mixed $value Argument value | entailment |
public function setControllerSettings(array $settings, $override = false)
{
$this->controllerSettings = $override ? $settings : array_replace($this->controllerSettings, $settings);
} | Set the controller settings
@param array $settings Controller settings
@param bool $override Override current settings (instead of amending them) | entailment |
public function render()
{
// Set the request arguments as GET parameters
$_GET = $this->getRequestArguments();
try {
/** @var \TYPO3\CMS\Extbase\Mvc\Web\Response $response */
$response = $this->objectManager->get(Response::class);
$this->request->setOrig... | Render this component
@return string Rendered component (HTML) | entailment |
protected function getControllerInstance()
{
// One-time instantiation of an extended controller object
if ($this->controllerInstance === null) {
$extendedControllerClassName = $this->extbaseController.'ComponentController_'.md5(
$this->extbaseControllerClass
... | Return an extend Extbase controller instance
@return ActionController|ComponentControllerInterface Extended Extbase controller instance | entailment |
protected function exportInternal()
{
// Compose a configuration string
if ($this->extbaseExtensionName && $this->extbasePlugin && $this->extbaseController && $this->extbaseAction) {
$this->config = [
'extension' => $this->extbaseExtensionName,
'plugin' ... | Return component specific properties
@return array Component specific properties | entailment |
public function writeTypeMarker(&$data, $markerType = null, $dataByVal = false)
{
// Workaround for PHP5 with E_STRICT enabled complaining about "Only
// variables should be passed by reference"
if ((null === $data) && ($dataByVal !== false)) {
$data = &$dataByVal;
}
... | Serialize PHP types to AMF3 and write to stream
Checks to see if the type was declared and then either
auto negotiates the type or use the user defined markerType to
serialize the data from php back to AMF3
@param mixed $data
@param int $markerType
@param mixed $dataByVal
@return void | entailment |
public function writeInteger($int)
{
if (($int & 0xffffff80) == 0) {
$this->_stream->writeByte($int & 0x7f);
return $this;
}
if (($int & 0xffffc000) == 0 ) {
$this->_stream->writeByte(($int >> 7 ) | 0x80);
$this->_stream->writeByte($int & 0x7f... | Write an AMF3 integer
@param int|float $data
@return Zend_Amf_Parse_Amf3_Serializer | entailment |
protected function writeBinaryString(&$string){
$ref = strlen($string) << 1 | 0x01;
$this->writeInteger($ref);
$this->_stream->writeBytes($string);
return $this;
} | Send string to output stream, without trying to reference it.
The string is prepended with strlen($string) << 1 | 0x01
@param string $string
@return Zend_Amf_Parse_Amf3_Serializer | entailment |
public function writeString(&$string)
{
$len = strlen($string);
if(!$len){
$this->writeInteger(0x01);
return $this;
}
$ref = array_key_exists($string, $this->_referenceStrings)
? $this->_referenceStrings[$string]
: false;
i... | Send string to output stream
@param string $string
@return Zend_Amf_Parse_Amf3_Serializer | entailment |
public function writeByteArray(&$data)
{
if ($this->writeObjectReference($data)) {
return $this;
}
if (is_string($data)) {
//nothing to do
} else if ($data instanceof Zend_Amf_Value_ByteArray) {
$data = $data->getData();
} else {
... | Send ByteArray to output stream
@param string|Zend_Amf_Value_ByteArray $data
@return Zend_Amf_Parse_Amf3_Serializer | entailment |
public function writeXml($xml)
{
if ($this->writeObjectReference($xml)) {
return $this;
}
if(is_string($xml)) {
//nothing to do
} else if ($xml instanceof DOMDocument) {
$xml = $xml->saveXml();
} else if ($xml instanceof SimpleXMLElement) ... | Send xml to output stream
@param DOMDocument|SimpleXMLElement $xml
@return Zend_Amf_Parse_Amf3_Serializer | entailment |
public function writeDate($date)
{
if ($this->writeObjectReference($date)) {
return $this;
}
if ($date instanceof DateTime) {
$dateString = $date->format('U') * 1000;
} elseif ($date instanceof Zend_Date) {
$dateString = $date->toString('U') * 100... | Convert DateTime/Zend_Date to AMF date
@param DateTime|Zend_Date $date
@return Zend_Amf_Parse_Amf3_Serializer | entailment |
public function writeArray(&$array)
{
// arrays aren't reference here but still counted
$this->_referenceObjects[] = $array;
// have to seperate mixed from numberic keys.
$numeric = array();
$string = array();
foreach ($array as $key => &$value) {
if (is... | Write a PHP array back to the amf output stream
@param array $array
@return Zend_Amf_Parse_Amf3_Serializer | entailment |
protected function writeObjectReference(&$object, $objectByVal = false)
{
// Workaround for PHP5 with E_STRICT enabled complaining about "Only
// variables should be passed by reference"
if ((null === $object) && ($objectByVal !== false)) {
$object = &$objectByVal;
}
... | Check if the given object is in the reference table, write the reference if it exists,
otherwise add the object to the reference table
@param mixed $object object reference to check for reference
@param mixed $objectByVal object to check for reference
@return Boolean true, if the reference was written, false otherwise | entailment |
public function writeObject($object)
{
if($this->writeObjectReference($object)){
return $this;
}
$className = '';
//Check to see if the object is a typed object and we need to change
switch (true) {
// the return class mapped name back to actionscri... | Write object to ouput stream
@param mixed $data
@return Zend_Amf_Parse_Amf3_Serializer | entailment |
public function login($data) {
$response=CodeBank_ClientAPI::responseBase();
$response['login']=true;
//Try to login
$member=MemberAuthenticator::authenticate(array(
'Email'=>$data->user,
... | Attempt to login
@param {stdClass} $data Data passed from ActionScript
@return {array} Returns a standard response array | entailment |
public function logout() {
$response=CodeBank_ClientAPI::responseBase();
//Session now expired
$response['session']='expired';
$member=Member::currentUser();
if($member) {
$member->logOut();
}
return $response;
} | Closes the users session
@return {array} Default response base | entailment |
public function lostPassword($data) {
$response=CodeBank_ClientAPI::responseBase();
$response['login']=true;
$SQL_email=Convert::raw2sql($data->user);
$member=Member::get_one('Member', "\"Email\"='{$SQL_email}'");
// Allow vetoing forgot password requests
$sng=new MemberLoginF... | Method for allowing a user to reset their password
@param {stdClass} $data Data passed from ActionScript
@return {array} Returns a standard response array | entailment |
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
) {
$content = trim($renderChildrenClosure());
return preg_match('%^https?\:\/\/%', $content) ?
htmlspecialchars($content) : '{{ pa... | Render a resource URL for Fractal, possibly treated with the `path` view helper
@param array $arguments
@param \Closure $renderChildrenClosure
@param RenderingContextInterface $renderingContext
@return string | entailment |
protected function _addTree(Zend_Server_Reflection_Node $parent, $level = 0)
{
if ($level >= $this->_sigParamsDepth) {
return;
}
foreach ($this->_sigParams[$level] as $value) {
$node = new Zend_Server_Reflection_Node($value, $parent);
if ((null !== $value... | Create signature node tree
Recursive method to build the signature node tree. Increments through
each array in {@link $_sigParams}, adding every value of the next level
to the current value (unless the current value is null).
@param Zend_Server_Reflection_Node $parent
@param int $level
@return void | entailment |
protected function _buildTree()
{
$returnTree = array();
foreach ((array) $this->_return as $value) {
$node = new Zend_Server_Reflection_Node($value);
$this->_addTree($node);
$returnTree[] = $node;
}
return $returnTree;
} | Build the signature tree
Builds a signature tree starting at the return values and descending
through each method argument. Returns an array of
{@link Zend_Server_Reflection_Node}s.
@return array | entailment |
protected function _buildSignatures($return, $returnDesc, $paramTypes, $paramDesc)
{
$this->_return = $return;
$this->_returnDesc = $returnDesc;
$this->_paramDesc = $paramDesc;
$this->_sigParams = $paramTypes;
$this->_sigParamsDepth = count($paramTypes);... | Build method signatures
Builds method signatures using the array of return types and the array of
parameters types
@param array $return Array of return types
@param string $returnDesc Return value description
@param array $params Array of arguments (each an array of types)
@param array $paramDesc Array of parameter d... | entailment |
protected function _reflect()
{
$function = $this->_reflection;
$helpText = '';
$signatures = array();
$returnDesc = '';
$paramCount = $function->getNumberOfParameters();
$paramCountRequired = $function->getNumberOfRequiredP... | Use code reflection to create method signatures
Determines the method help/description text from the function DocBlock
comment. Determines method signatures using a combination of
ReflectionFunction and parsing of DocBlock @param and @return values.
@param ReflectionFunction $function
@return array | entailment |
static public function createWithSafeMessage($safeMessage = "", array $messageData = array(), $code = 0, \Exception $previous = null)
{
$exception = new static($safeMessage, $code, $previous);
$exception->setSafeMessage($safeMessage, $messageData);
return $exception;
} | Helper method to create this exception and set the safe message
that will be shown to the user.
@param string $safeMessage
@param array $messageData
@param int $code
@param \Exception $previous
@return CustomAuthenticationException | entailment |
public function unserialize($str)
{
list($this->messageKey, $this->messageData, $parentData) = unserialize($str);
parent::unserialize($parentData);
} | {@inheritdoc} | entailment |
public function validate(ValidationResult $validationResult) {
if (!$this->owner->ID) return; // The object is new, won't be looping.
if (!$this->owner->LanguageID) return; // The object has no parent, won't be looping.
if (!$this->owner->isChanged('LanguageID')) return; // The parent has not ch... | Validate the owner object - check for existence of infinite loops. | entailment |
public function parentStack() {
$p=$this->owner;
while($p) {
$stack[]=$p;
if($p->FolderID && $p->FolderID>0) {
$folder=$p->Folder();
if(!empty($folder) && $folder!==false && $folder->ID!=0) {
$p=$folder;
... | Return an array of this page and its ancestors, ordered item -> root.
@return array | entailment |
public function getAncestors() {
$ancestors=new ArrayList();
$object =$this->owner;
while($object=$object->Language()) {
$ancestors->push($object);
}
return $ancestors;
} | Return all the parents of this class in a set ordered from the lowest to highest parent.
@return SS_List | entailment |
public function naturalNext( $className=null, $root=0, $afterNode=null ) {
// If this node is not the node we are searching from, then we can possibly return this
// node as a solution
if($afterNode && $afterNode->ID != $this->owner->ID) {
if(!$className || ($className && $this->owne... | Get the next node in the tree of the type. If there is no instance of the className descended from this node,
then search the parents.
@param string $className Class name of the node to find.
@param string|int $root ID/ClassName of the node to limit the search to
@param DataObject afterNode Used for recursive calls to ... | entailment |
public function markPartialTree($minNodeCount=30, $context=null, $childrenMethod="AllChildrenIncludingDeleted", $numChildrenMethod="numChildren") {
if(!is_numeric($minNodeCount)) $minNodeCount=30;
$this->markedNodes=array($this->owner->ClassName.'_'.$this->owner->ID=>$this->owner);
$this->owner... | Mark a segment of the tree, by calling mark().
The method performs a breadth-first traversal until the number of nodes is more than minCount.
This is used to get a limited number of tree nodes to show in the CMS initially.
This method returns the number of nodes marked. After this method is called other methods
can c... | entailment |
public function markChildren($node, $context=null, $childrenMethod='AllChildrenIncludingDeleted', $numChildrenMethod='numChildren') {
if($node->hasMethod($childrenMethod)) {
$children=$node->$childrenMethod($context);
}else {
user_error(sprintf("Can't find the method '%s' on clas... | Mark all children of the given node that match the marking filter.
@param DataObject $node Parent node. | entailment |
public function markById($id, $open=false, $className=null) {
if(isset($this->markedNodes[$className.'_'.$id])) {
$this->markChildren($this->markedNodes[$className.'_'.$id]);
if($open) {
$this->markedNodes[$className.'_'.$id]->markOpened();
}
... | Mark the children of the DataObject with the given ID.
@param int $id ID of parent node.
@param boolean $open If this is true, mark the parent node as opened. | entailment |
public function markToExpose($childObj) {
if(is_object($childObj)){
$stack=array_reverse($childObj->parentStack());
foreach($stack as $stackItem) {
$this->markById($stackItem->ID, true, $stackItem->ClassName);
}
}
} | Expose the given object in the tree, by marking this page and all it ancestors.
@param DataObject $childObj | entailment |
public function numChildren($cache=true) {
// Build the cache for this class if it doesn't exist.
if(!$cache || !is_numeric($this->_cache_numChildren)) {
if($this->owner instanceof SnippetLanguage) {
$this->_cache_numChildren=(int)$this->owner->Snippets()->filter('FolderID', ... | Return the number of direct children.
By default, values are cached after the first invocation.
Can be augumented by {@link augmentNumChildrenCountQuery()}.
@param Boolean $cache
@return int | entailment |
public function getChildrenAsUL($attributes="", $titleEval='"<li>" . $child->Title', $extraArg=null, $limitToMarked=false, $childrenMethod="AllChildrenIncludingDeleted", $numChildrenMethod="numChildren", $rootCall=true, $minNodeCount=30) {
if($limitToMarked && $rootCall) {
$this->markingFinished($nu... | Returns the children of this DataObject as an XHTML UL. This will be called recursively on each child,
so if they have children they will be displayed as a UL inside a LI.
@param string $attributes Attributes to add to the UL.
@param string|callable $titleEval PHP code to evaluate to start each child - this should incl... | entailment |
public function markingFilterMatches($node) {
if(!$this->markingFilter) {
return true;
}
if(isset($this->markingFilter['parameter']) && $parameterName=$this->markingFilter['parameter']) {
if(is_array($this->markingFilter['value'])){
$ret=false;
... | Returns true if the marking filter matches on the given node.
@param DataObject $node Node to check.
@return boolean | entailment |
protected function markingFinished($numChildrenMethod="numChildren") {
// Mark childless nodes as expanded.
if($this->markedNodes) {
foreach($this->markedNodes as $id => $node) {
if(!$node->isExpanded() && !$node->$numChildrenMethod()) {
$node->markExpande... | Ensure marked nodes that have children are also marked expanded.
Call this after marking but before iterating over the tree. | entailment |
public function markingClasses() {
$classes='';
if(!$this->isExpanded()) {
$classes .= " unexpanded jstree-closed";
}
if($this->isTreeOpened()) {
if($this->numChildren() > 0) $classes .= " jstree-open";
} else {
$classes .= " closed";
}... | Return CSS classes of 'unexpanded', 'closed', both, or neither, depending on
the marking of this DataObject. | entailment |
public function markExpanded() {
self::$marked[ClassInfo::baseDataClass($this->owner->class)][$this->owner->ID]=true;
self::$expanded[ClassInfo::baseDataClass($this->owner->class)][$this->owner->ID]=true;
} | Mark this DataObject as expanded. | entailment |
public function markUnexpanded() {
self::$marked[ClassInfo::baseDataClass($this->owner->class)][$this->owner->ID]=true;
self::$expanded[ClassInfo::baseDataClass($this->owner->class)][$this->owner->ID]=false;
} | Mark this DataObject as unexpanded. | entailment |
public function markOpened() {
self::$marked[ClassInfo::baseDataClass($this->owner->class)][$this->owner->ID]=true;
self::$treeOpened[ClassInfo::baseDataClass($this->owner->class)][$this->owner->ID]=true;
} | Mark this DataObject's tree as opened. | entailment |
public function isMarked() {
$baseClass=ClassInfo::baseDataClass($this->owner->class);
$id=$this->owner->ID;
return isset(self::$marked[$baseClass][$id]) ? self::$marked[$baseClass][$id] : false;
} | Check if this DataObject is marked.
@return boolean | entailment |
public function isExpanded() {
$baseClass=ClassInfo::baseDataClass($this->owner->class);
$id=$this->owner->ID;
return isset(self::$expanded[$baseClass][$id]) ? self::$expanded[$baseClass][$id] : false;
} | Check if this DataObject is expanded.
@return boolean | entailment |
public function isTreeOpened() {
$baseClass=ClassInfo::baseDataClass($this->owner->class);
$id=$this->owner->ID;
return isset(self::$treeOpened[$baseClass][$id]) ? self::$treeOpened[$baseClass][$id] : false;
} | Check if this DataObject's tree is opened. | entailment |
public function partialTreeAsUL($minCount=50) {
$children=$this->owner->AllChildren();
if($children) {
if($attributes) $attributes=" $attributes";
$output="<ul$attributes>\n";
foreach($children as $child) {
$output .= eval("return $titleEval;") . ... | Return a partial tree as an HTML UL. | entailment |
public function loadDescendantIDListInto(&$idList) {
if($children=$this->AllChildren()) {
foreach($children as $child) {
if(in_array($child->ID, $idList)) {
continue;
}
$idList[]=$child->ID;
$ext=$child->getExtension... | Get a list of this DataObject's and all it's descendants ID, and put it in $idList.
@var array $idList Array to put results in. | entailment |
public function Children() {
if(!(isset($this->_cache_children) && $this->_cache_children)) {
$result=$this->owner->stageChildren(false);
if(isset($result)) {
$this->_cache_children=new ArrayList();
foreach($result as $child) {
if($chil... | Get the children for this DataObject.
@return SS_List | entailment |
public function doAllChildrenIncludingDeleted($context=null) {
if(!$this->owner) user_error('Hierarchy::doAllChildrenIncludingDeleted() called without $this->owner');
$idxStageChildren=array();
$idxLiveChildren=array();
$baseClass=ClassInfo::baseDataClass($this->owner->class);
... | @see AllChildrenIncludingDeleted
@param unknown_type $context
@return SS_List | entailment |
public function stageChildren($showAll=false) {
$baseClass=ClassInfo::baseDataClass($this->owner->class);
if($baseClass=='SnippetPackage') {
if($this->owner->ID==0) {
$staged=SnippetPackage::get();
}
}else if($baseClass=='SnippetLanguage') {
... | Return children from the stage site
@param showAll Inlcude all of the elements, even those not shown in the menus.
(only applicable when extension is applied to {@link SiteTree}).
@return SS_List | entailment |
public function getBreadcrumbs($separator=' » ') {
$crumbs=array();
$ancestors=array_reverse($this->owner->getAncestors()->toArray());
foreach($ancestors as $ancestor) $crumbs[]=$ancestor->Title;
$crumbs[]=$this->owner->Title;
return implode($separator, $crumbs);
} | Returns a human-readable, flattened representation of the path to the object,
using its {@link Title()} attribute.
@param String
@return String | entailment |
public function authenticate(TokenInterface $token)
{
if (!$this->supports($token)) {
throw new \InvalidArgumentException('GuardAuthenticationProvider only supports GuardTokenInterface.');
}
if (!$token instanceof PreAuthenticationGuardToken) {
/*
* The ... | Finds the correct authenticator for the token and calls it.
@param GuardTokenInterface $token
@return TokenInterface | entailment |
public function requireDefaultRecords() {
parent::requireDefaultRecords();
$codeVersion=singleton('CodeBank')->getVersion();
if(!CodeBankConfig::get()->first()) {
$conf=new CodeBankConfig();
$conf->Version=$codeVersion;
$conf->write(... | Creates the default code bank config | entailment |
public static function CurrentConfig() {
if(empty(self::$_currentConfig)) {
self::$_currentConfig=CodeBankConfig::get()->first();
}
return self::$_currentConfig;
} | Gets the current config
@return {CodeBankConfig} Code Bank Config Data | entailment |
public function getCMSFields() {
$langGridConfig=GridFieldConfig_RecordEditor::create(30);
$langGridConfig->getComponentByType('GridFieldDetailForm')->setItemRequestClass('CodeBankGridField_ItemRequest');
$langGridConfig->getComponentByType('GridFieldDataColumns')->setFieldCasting(array(
... | Gets fields used in the cms
@return {FieldList} Fields to be used | entailment |
function setup() {
$dataStore = new PersonalDataStoreStub();
$this->eventStore = new TestEventStoreSpy();
$this->container = new ContainerStub();
$this->container->set(EventStore::class, $this->eventStore);
$this->classMap = new DomainEventClassMap();
$this->commandBus... | setup() is the initialization function that will
define our dependencies. call it from the objectbehavior's
let() function
```php
function let() {
$this->setup();
}
``` | entailment |
public function given(StreamId $id, DomainEvent ...$domainEvents) {
$version = StreamVersion::zero();
$this->environment = StreamEvents::make(
array_map(function (DomainEvent $event) use ($id, &$version) {
$streamEvent = new StreamEvent($id, $version, $event);
... | given() is the method to use to set up an environment
that consists of a single event stream.
the environment is the collection of events that need to
already exist within the event store in order to test that
the command results in the generation of the correct outcome
the first argument is the stream id, the rest o... | entailment |
public function givenStreams(StreamEvents ...$streamEvents) {
$arraysOfEvents[] = array_map(function (StreamEvents $streamEvents) {
return $streamEvents->toArray();
}, $streamEvents);
$this->environment = StreamEvents::make(array_merge(...$arraysOfEvents));
return $this;
... | givenStreams() is the method to use to set up an environment
that consists of multiple event streams.
the environment is the collection of events that need to
already exist within the event store in order to test that
the command results in the generation of the correct outcome
the argument is a variadic list of Stre... | entailment |
public function then(DomainEvent ...$events) {
if ( ! $this->commandBus) {
throw new FailureException('Cannot execute specification without calling beInitializedWith().');
}
$this->commandBus->execute($this->commandToExecute);
$this->eventsShouldExistInStore(...$events);
... | then() is the method that triggers the execution of the
command and then validates that the Domain Events passed
as the argument exist within the environment.
```php
$this->given(
// ...
)->when(
// ...
)->then(
new ExampleEvent(1),
new ExampleEvent(1)
);
```
@param DomainEvent ...$events
@throws \Exception | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.