sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function thenFail(\Exception $expected) { try { $this->commandBus->execute($this->commandToExecute); $expectedType = get_class($expected); throw new FailureException("Expected exception {$expectedType} but it was not thrown."); } catch (\Exception $caught) { ...
thenFail() is the method to use when you want to verify that given the existing environment, the command will result in an exception. ```php $this->given( // ... )->when( // ... )->thenFail( new SomethingWentWrong(...) ); ``` @param \Exception $expected @throws FailureException
entailment
private function eventsShouldExistInStore(DomainEvent ...$events) { $expected = array_map(function (DomainEvent $event) { return $this->serializer->serialize($event); }, $events); $existing = $this->eventStore->getEvents()->map(function(DomainEvent $event) { return $this...
internal method that throws an exception should the expected events not exist within the event store @param DomainEvent ...$events @throws FailureException
entailment
public function parse($resource) { $result = array(); $fieldcnt = mysql_num_fields($resource); $fields_transform = array(); for($i=0;$i<$fieldcnt;$i++) { $type = mysql_field_type($resource, $i); if(isset(self::$fieldTypes[$type])) { $fields_transfo...
Parse resource into array @param resource $resource @return array
entailment
public function render() { // Set the request arguments as GET parameters $_GET = $this->getRequestArguments(); try { // Instantiate a TypoScript parser $configurationManager = $this->objectManager->get(ConfigurationManager::class); $typoScriptParser ...
Render this component @return string Rendered component (HTML)
entailment
protected function loadJsonParameters() { $reflectionObject = new \ReflectionObject($this); $componentFile = $reflectionObject->getFileName(); $parameterFile = dirname($componentFile).DIRECTORY_SEPARATOR.pathinfo( $componentFile, PATHINFO_FILENAME ...
Load parameters provided from an external JSON file
entailment
protected function setParameter($param, $value) { $param = trim($param); if (!strlen($param)) { throw new \RuntimeException(sprintf('Invalid fluid template parameter "%s"', $param), 1481551574); } $this->parameters[$param] = $value; }
Set a rendering parameter @param string $param Parameter name @param mixed $value Parameter value @throws \RuntimeException If the parameter name is invalid
entailment
protected function exportInternal() { // Read the linked TypoScript if ($this->template !== null) { $this->config = [ 'template' => $this->template, 'section' => $this->section, ]; $templateFile = GeneralUtility::getFileAbsFileName...
Return component specific properties @return array Component specific properties
entailment
protected function _setDbAdapter(Zend_Db_Adapter_Abstract $zendDb = null) { $this->_zendDb = $zendDb; /** * If no adapter is specified, fetch default database adapter. */ if(null === $this->_zendDb) { require_once 'Zend/Db/Table/Abstract.php'; $this...
_setDbAdapter() - set the database adapter to be used for quering @param Zend_Db_Adapter_Abstract @throws Zend_Auth_Adapter_Exception @return Zend_Auth_Adapter_DbTable
entailment
public function setAmbiguityIdentity($flag) { if (is_integer($flag)) { $this->_ambiguityIdentity = (1 === $flag ? true : false); } elseif (is_bool($flag)) { $this->_ambiguityIdentity = $flag; } return $this; }
setAmbiguityIdentity() - sets a flag for usage of identical identities with unique credentials. It accepts integers (0, 1) or boolean (true, false) parameters. Default is false. @param int|bool $flag @return Zend_Auth_Adapter_DbTable
entailment
public function getDbSelect() { if ($this->_dbSelect == null) { $this->_dbSelect = $this->_zendDb->select(); } return $this->_dbSelect; }
getDbSelect() - Return the preauthentication Db Select object for userland select query modification @return Zend_Db_Select
entailment
public function authenticate() { $this->_authenticateSetup(); $dbSelect = $this->_authenticateCreateSelect(); $resultIdentities = $this->_authenticateQuerySelect($dbSelect); if ( ($authResult = $this->_authenticateValidateResultSet($resultIdentities)) instanceof Zend_Auth_Result) { ...
authenticate() - defined by Zend_Auth_Adapter_Interface. This method is called to attempt an authentication. Previous to this call, this adapter would have already been configured with all necessary information to successfully connect to a database table and attempt to find a record matching the provided identity. @...
entailment
protected function _authenticateSetup() { $exception = null; if ($this->_tableName == '') { $exception = 'A table must be supplied for the Zend_Auth_Adapter_DbTable authentication adapter.'; } elseif ($this->_identityColumn == '') { $exception = 'An identity column m...
_authenticateSetup() - This method abstracts the steps involved with making sure that this adapter was indeed setup properly with all required pieces of information. @throws Zend_Auth_Adapter_Exception - in the event that setup was not done properly @return true
entailment
protected function _authenticateCreateSelect() { // build credential expression if (empty($this->_credentialTreatment) || (strpos($this->_credentialTreatment, '?') === false)) { $this->_credentialTreatment = '?'; } $credentialExpression = new Zend_Db_Expr( '(...
_authenticateCreateSelect() - This method creates a Zend_Db_Select object that is completely configured to be queried against the database. @return Zend_Db_Select
entailment
protected function _authenticateQuerySelect(Zend_Db_Select $dbSelect) { try { if ($this->_zendDb->getFetchMode() != Zend_DB::FETCH_ASSOC) { $origDbFetchMode = $this->_zendDb->getFetchMode(); $this->_zendDb->setFetchMode(Zend_DB::FETCH_ASSOC); } ...
_authenticateQuerySelect() - This method accepts a Zend_Db_Select object and performs a query against the database with that object. @param Zend_Db_Select $dbSelect @throws Zend_Auth_Adapter_Exception - when an invalid select object is encountered @return array
entailment
protected function _authenticateValidateResult($resultIdentity) { $zendAuthCredentialMatchColumn = $this->_zendDb->foldCase('zend_auth_credential_match'); if ($resultIdentity[$zendAuthCredentialMatchColumn] != '1') { $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CRE...
_authenticateValidateResult() - This method attempts to validate that the record in the resultset is indeed a record that matched the identity provided to this adapter. @param array $resultIdentity @return Zend_Auth_Result
entailment
public function addCertificatePair($private_key_file, $public_key_file, $type = Zend_InfoCard_Cipher::ENC_RSA_OAEP_MGF1P, $password = null) { return $this->_infoCard->addCertificatePair($private_key_file, $public_key_file, $type, $password); }
Add a Certificate Pair to the list of certificates searched by the component @param string $private_key_file The path to the private key file for the pair @param string $public_key_file The path to the certificate / public key for the pair @param string $type (optional) The URI for the type of...
entailment
public function authenticate() { try { $claims = $this->_infoCard->process($this->getXmlToken()); } catch(Exception $e) { return new Zend_Auth_Result(Zend_Auth_Result::FAILURE , null, array('Exception Thrown', ...
Authenticates the XML token @return Zend_Auth_Result The result of the authentication
entailment
public function updateAction(ServerRequest $request, Response $response) { $script = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extParams']['tw_componentlibrary']['script']; $descriptorspec = array( 0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pi...
Update the fractal component library @param ServerRequest $request @param Response $response @return bool
entailment
public static function save($filename, Zend_Server_Interface $server) { if (!is_string($filename) || (!file_exists($filename) && !is_writable(dirname($filename)))) { return false; } $methods = $server->getFunctions(); if ($methods instanceof Zend_Ser...
Cache a file containing the dispatch list. Serializes the server definition stores the information in $filename. Returns false on any error (typically, inability to write to file), true on success. @param string $filename @param Zend_Server_Interface $server @return bool
entailment
public static function get($filename, Zend_Server_Interface $server) { if (!is_string($filename) || !file_exists($filename) || !is_readable($filename)) { return false; } if (false === ($dispatch = @file_get_contents($filename))) { ret...
Load server definition from a file Unserializes a stored server definition from $filename. Returns false if it fails in any way, true on success. Useful to prevent needing to build the server definition on each request. Sample usage: <code> if (!Zend_Server_Cache::get($filename, $server)) { require_once 'Some/Servic...
entailment
public static function delete($filename) { if (is_string($filename) && file_exists($filename)) { unlink($filename); return true; } return false; }
Remove a cache file @param string $filename @return boolean
entailment
public function requireTable() { //Init the search engine $searchEngine=Config::inst()->get('CodeBank', 'snippet_search_engine'); if($searchEngine && class_exists($searchEngine) && in_array('ICodeBankSearchEngine', class_implements($searchEngine))) { $searchEngine::requireTable(); ...
Check the database schema and update it as necessary.
entailment
public function getCMSFields() { $fields=new FieldList( new TabSet('Root', new Tab('Main', _t('Snippet.MAIN', '_Main'), DropdownField::create('LanguageID', _t('Snippet.LANGUAGE', '_Language'), SnippetLanguage::get()-...
Gets fields used in the cms @return {FieldList} Fields to be used
entailment
protected function onBeforeWrite() { parent::onBeforeWrite(); if($this->ID==0) { $this->CreatorID=Member::currentUserID(); }else { $this->LastEditorID=Member::currentUserID(); //If the language is changing reset the folder id ...
Sets the creator id for new snippets and sets the last editor id for existing snippets
entailment
protected function onAfterWrite() { parent::onAfterWrite(); //Write the snippet version record if(!empty($this->Text)) { $version=new SnippetVersion(); $version->Text=$this->Text; $version->ParentID=$this->ID; $version->write(); } ...
Creates the snippet version record after writing
entailment
public function equals(self $that): bool { if (get_class($this) !== get_class($that)) { throw new CannotCompareDifferentIds; } return $this->id === $that->id; }
compare two Id instances for equality Ids are considered equal if they are of the same type and contain the same underlying string representations @param self $that @return bool @throws CannotCompareDifferentIds
entailment
protected function onBeforeDelete() { parent::onBeforeDelete(); //Remove all Snippets from this folder DB::query('UPDATE "Snippet" SET "FolderID"='.$this->ParentID.' WHERE "FolderID"='.$this->ID); //Remove all Snippet Folders from this folder DB::query('UPDATE "...
Removes all snippets from the folder before deleting
entailment
public function positiveMatch(string $name, $subject, array $arguments): ?\PhpSpec\Wrapper\DelayedCall { $argumentCount = count($arguments); if ($argumentCount == 1) { $this->compare($subject, $arguments[0]); } else { for ($i = 0; $i < $argumentCount; $i++) { ...
Evaluates positive match. @param string $name @param mixed $subject @param array $arguments
entailment
public function negativeMatch(string $name, $subject, array $arguments): ?\PhpSpec\Wrapper\DelayedCall { if ($subject->equals($arguments[0])) { throw new FailureException('<label>' . get_class($subject) . "</label> <value>{$subject->toString()}</value> should not equal <value>{$arguments[0]->toS...
Evaluates negative match. @param string $name @param mixed $subject @param array $arguments
entailment
public function authenticate() { if (empty($this->_username) || empty($this->_password)) { /** * @see Zend_Auth_Adapter_Exception */ require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('Username/passw...
Perform authentication @throws Zend_Auth_Adapter_Exception @return Zend_Auth_Result @see Zend_Auth_Adapter_Interface#authenticate()
entailment
public function setWebPath() { $folder_array = explode(self::DS, $this->getUploadPath()); $this->web_path = array_pop($folder_array); }
Set the correct web path
entailment
public function setDirPaths($dir_path) { if (is_null($dir_path)) { $this->setDir($this->getUploadPath()); $this->setDirPath(""); } else { $this->setDirPath($this->DirTrim($dir_path)); $this->setDir($this->getUploadPath() . self::DS . $dir_path); ...
Set the dir paths @param null|string $dir_path
entailment
public function DirTrim($path, $file = null, $rTrim = false) { if ($rTrim) { $result = rtrim($path, self::DS); } else { $result = trim($path, self::DS); } if (!is_null($file)) { $file_result = trim($file, self::DS); } else { $f...
Trim the directory separators from the file(path) @param string $path @param string $file @param bool $rTrim @return string
entailment
public function checkPath($path = null) { if (is_null($path)) { $path = $this->getDir(); } $real_path = realpath($path); if (!$real_path) { $real_path = realpath(dirname($path)); } $upload_path = realpath($this->getUploadPath()); if (...
Check if the path is in the upload directory @param string $path default is the file dir @throws \Exception when directory is not in the upload path @return bool
entailment
public function resolveRequest(Request $request, $action = null) { $this->setDirPath($request->get('dir_path')); $this->setCurrentFile($this->getPath($this->getDirPath(), $request->get('filename'), true)); if ($action === self::FILE_RENAME && !$this->getCurrentFile()->isDir()) { ...
Set the required request parameters to the object @param Request $request @param int|null $action
entailment
public function getPath($dir_path = null, $filename = null, $full_path = false) { if ($full_path) { $path = $this->upload_path; } else { $path = $this->web_path; } if (!is_null($dir_path)) { $path = self::DS . $this->DirTrim($path, $dir_path); ...
Get the path of the file @param null|string $dir_path @param null|string $filename @param bool $full_path @return string
entailment
public function extractZip() { $this->event(YouweFileManagerEvents::BEFORE_FILE_EXTRACTED); $this->getDriver()->extractZip($this->getCurrentFile()); $this->event(YouweFileManagerEvents::AFTER_FILE_EXTRACTED); }
Extract the zip
entailment
public function pasteFile($type) { $this->event(YouweFileManagerEvents::BEFORE_FILE_PASTED); $this->resolveImage(); $this->getDriver()->pasteFile($this->getCurrentFile(), $type); $this->event(YouweFileManagerEvents::AFTER_FILE_PASTED); }
Paste the file @param string $type
entailment
public function resolveImage() { if ($this->FilterImages() && $this->getCurrentFile()->isImage()) { try { $imageCacheManager = $this->getCacheManager(); } catch (\Exception $e) { $exception = 'Cannot resolve the image. Please make sure that LiipImagine...
Remove the image of the current file @throws \Exception if Liip Imagine Bundle is not installed
entailment
public function moveFile() { $this->event(YouweFileManagerEvents::BEFORE_FILE_MOVED); $target_full_path = $this->getTargetFile()->getFilepath(true); $this->getDriver()->moveFile($this->getCurrentFile(), $target_full_path); $this->resolveImage(); $this->getCurrentFile()->updat...
Move the file
entailment
public function deleteFile() { $this->event(YouweFileManagerEvents::BEFORE_FILE_DELETED); $this->resolveImage(); $this->getDriver()->deleteFile($this->getCurrentFile()); $this->event(YouweFileManagerEvents::AFTER_FILE_DELETED); }
Delete the file
entailment
public function renameFile() { $this->event(YouweFileManagerEvents::BEFORE_FILE_RENAMED); $target_full_path = $this->getTargetFile()->getFilepath(true); $this->getDriver()->renameFile($this->getCurrentFile(), $target_full_path); $this->resolveImage(); $this->getCurrentFile()-...
Rename the file
entailment
public function newDirectory() { $target_full_path = $this->getTargetFile()->getFilepath(true); $this->event(YouweFileManagerEvents::BEFORE_FILE_DIR_CREATED); $this->getDriver()->makeDir($target_full_path); $this->getCurrentFile()->updateFilepath($target_full_path); $this->ev...
Create a new directory
entailment
public function throwError($string, $code = 500, $e = null) { if (!$this->isFullException() || is_null($e)) { throw new \Exception($string, $code); } else { throw new \Exception($string . ": " . $e->getMessage(), $code); } }
Throw the error based on the full exception config @param string $string the displayed exception @param int $code the displayed code @param null|\Exception $e the actual exception @throws \Exception the exception that is given
entailment
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $default_mimetypes = array( 'image/png', 'image/jpg', 'image/jpeg', 'image/gif', 'application/pdf', 'application/ogg', 'video/mp4', ...
{@inheritDoc}
entailment
public function FieldHolder($properties=array()) { Requirements::css(CB_DIR.'/css/PackageSelectionField.css'); Requirements::javascript(CB_DIR.'/javascript/PackageSelectionField.js'); return parent::FieldHolder($properties); }
Returns a "field holder" for this field - used by templates. @param {array} $properties Key value pairs of template variables @return {string}
entailment
public function AddPackageForm() { $sng=singleton('SnippetPackage'); $fields=new FieldList( new TabSet('Root', new Tab('Main', _t('PackageSelectionField.MAIN', '_Main'), new TextField('Ti...
Generates the form for adding packages @return {Form} Form to be used
entailment
public function doAddPackage($data, Form $form) { $record=new SnippetPackage(); if($record->canEdit()) { $form->saveInto($record); $record->write(); Requirements::customScript("window.parent.jQuery('#".$this->getName()."').entwine('ss').handl...
Handles adding of the package @param {array} $data Submitted data @param {Form} $form Submitting form @return {mixed}
entailment
public function readTypeMarker($typeMarker = null) { if(null === $typeMarker) { $typeMarker = $this->_stream->readByte(); } switch($typeMarker) { case Zend_Amf_Constants::AMF3_UNDEFINED: return null; case Zend_Amf_Constants::AMF3_NULL: ...
Read AMF markers and dispatch for deserialization Checks for AMF marker types and calls the appropriate methods for deserializing those marker types. markers are the data type of the following value. @param integer $typeMarker @return mixed Whatever the corresponding PHP data type is @throws Zend_Amf_Exception for u...
entailment
public function readInteger() { $count = 1; $intReference = $this->_stream->readByte(); $result = 0; while ((($intReference & 0x80) != 0) && $count < 4) { $result <<= 7; $result |= ($intReference & 0x7f); $intReference =...
Read and deserialize an integer AMF 3 represents smaller integers with fewer bytes using the most significant bit of each byte. The worst case uses 32-bits to represent a 29-bit number, which is what we would have done with no compression. - 0x00000000 - 0x0000007F : 0xxxxxxx - 0x00000080 - 0x00003FFF : 1xxxxxxx 0xxxx...
entailment
public function readString() { $stringReference = $this->readInteger(); //Check if this is a reference string if (($stringReference & 0x01) == 0) { // reference string $stringReference = $stringReference >> 1; if ($stringReference >= count($this->_referen...
Read and deserialize a string Strings can be sent as a reference to a previously occurring String by using an index to the implicit string reference table. Strings are encoding using UTF-8 - however the header may either describe a string literal or a string reference. - string = 0x06 string-data - string-data = inte...
entailment
public function readDate() { $dateReference = $this->readInteger(); if (($dateReference & 0x01) == 0) { $dateReference = $dateReference >> 1; if ($dateReference>=count($this->_referenceObjects)) { require_once 'Zend/Amf/Exception.php'; throw ne...
Read and deserialize a date Data is the number of milliseconds elapsed since the epoch of midnight, 1st Jan 1970 in the UTC time zone. Local time zone information is not sent to flash. - date = 0x08 integer-data [ number-data ] @return Zend_Date
entailment
public function readArray() { $arrayReference = $this->readInteger(); if (($arrayReference & 0x01)==0){ $arrayReference = $arrayReference >> 1; if ($arrayReference>=count($this->_referenceObjects)) { require_once 'Zend/Amf/Exception.php'; throw...
Read amf array to PHP array - array = 0x09 integer-data ( [ 1OCTET *amf3-data ] | [OCTET *amf3-data 1] | [ OCTET *amf-data ] ) @return array
entailment
public function readObject() { $traitsInfo = $this->readInteger(); $storedObject = ($traitsInfo & 0x01)==0; $traitsInfo = $traitsInfo >> 1; // Check if the Object is in the stored Objects reference table if ($storedObject) { $ref = $traitsInfo; if...
Read an object from the AMF stream and convert it into a PHP object @todo Rather than using an array of traitsInfo create Zend_Amf_Value_TraitsInfo @return object|array
entailment
public function readXmlString() { $xmlReference = $this->readInteger(); $length = $xmlReference >> 1; $string = $this->_stream->readBytes($length); return simplexml_load_string($string); }
Convert XML to SimpleXml If user wants DomDocument they can use dom_import_simplexml @return SimpleXml Object
entailment
public function guessMimeType($filepath) { $magic_file = $this->getFileManager()->getMagicFile(); $mimetype = finfo_file(finfo_open(FILEINFO_MIME_TYPE, $magic_file), $filepath); $extension = pathinfo($filepath, PATHINFO_EXTENSION); $match_extension = $this->matchMimetypeExtension($m...
Try to guess the mimetypes first with a custom magic file. This fix the problems with wrong mime type detection. @param string $filepath @return mixed
entailment
public function matchMimetypeExtension($mimetype, $extension) { $mime_extensions = self::$mimetypes_extensions; if (isset($mime_extensions[$extension]) && $mime_extensions[$extension] == $mimetype) { return true; } return false; }
Check if the mimetype match with the extension @param string $mimetype @param string $extension @return bool
entailment
public function setFileclass($mimetype) { switch ($mimetype) { case 'directory': $fileclass = "dir"; $this->is_dir = true; break; case 'application/pdf': $fileclass = "pdf"; break; case 'appli...
Set the file class Javascript uses the fileclass to check which actions the file should have. CSS uses the file class to check which icon belongs to the file. @param string $mimetype
entailment
public function getFilepath($include_filename = false) { $filepath = $this->filepath; if ($include_filename) { $filepath .= FileManager::DS . $this->getFilename(); } return $filepath; }
Returns the full path to the file @param bool $include_filename @return string
entailment
public function setUsages(FileManager $file_manager) { $usages = array(); $usage_class = $file_manager->getUsagesClass(); if ($usage_class != false) { /** @var mixed $usage_object */ $usage_object = new $usage_class; $usages_result = $usage_object->returnU...
Set the locations where the file is used in an array. This function requires a class that is set in the config with the function returnUsages. @param FileManager $file_manager
entailment
public function getWebPath($trim = false) { if ($trim) { return trim($this->web_path, FileManager::DS); } else { return $this->web_path; } }
Returns the web path of the file @param bool $trim @return string
entailment
public function manipulateCacheActions(&$cacheActions, &$optionValues) { $extensionConfiguration = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extParams']['tw_componentlibrary']; if ($GLOBALS['BE_USER']->isAdmin() && !empty($extensionConfiguration['componentlibrary'])) { $componentLibrary = $ext...
Add an entry to the CacheMenuItems array @param array $cacheActions Array of CacheMenuItems @param array $optionValues Array of AccessConfigurations-identifiers (typically used by userTS with options.clearCache.identifier)
entailment
public function get(string $name): Projection { return $this->projections->filter(function (Projection $projection) use ($name) { return $projection->name() === $name; })->first(); }
retrieve a projection based on its string name @param string $name @return Projection
entailment
public function handle(DomainEvent $event) : void { $this->projections->each(function (Projection $projection) use ($event) { $projection->handle($event); }); }
receive a domain event and hand it off to every projection @param DomainEvent $event
entailment
public function createFileManager(array $parameters, $driver, $dir_path = null) { $file_manager = new FileManager($parameters, $driver, $this->container); $this->file_manager = $file_manager; $file_manager->setDirPaths($dir_path); $this->setDisplayType(); return $file_manager...
Create the file manager object @param array $parameters @param string $dir_path @param mixed $driver @return FileManager
entailment
public function getFilePath(FileManager $file_manager) { $current_file = $file_manager->getCurrentFile(); $target_file = $file_manager->getTargetFile(); if (($current_file->getFilename() == "" && !is_null($target_file->getFilename()))) { throw new \Exception("Filename cannot be ...
Get and check the current file path @param FileManager $file_manager @throws \Exception when the file name is empty while there is a target file or when the file is invalid @return bool|string
entailment
public function checkToken($request_token) { $token_manager = $this->container->get('security.csrf.token_manager'); $token = new CsrfToken('file_manager', $request_token); $valid = $token_manager->isTokenValid($token); if (!$valid) { throw new InvalidCsrfTokenException()...
Check if the form token is valid @param string $request_token @throws InvalidCsrfTokenException when the token is not valid
entailment
public function handleUploadFiles($files) { $dir = $this->getFileManager()->getDir(); /** @var FileManagerDriver $driver */ $driver = $this->container->get('youwe.file_manager.driver'); $this->getFileManager()->event(YouweFileManagerEvents::BEFORE_FILE_UPLOADED); /...
Handle the uploaded file(s) @param array $files @return bool
entailment
public function getRenderOptions(Form $form) { $file_manager = $this->getFileManager(); $dir_files = scandir($file_manager->getDir()); $root_dirs = scandir($file_manager->getUploadPath()); $is_popup = $this->container->get('request')->get('popup') ? true : false; $options['f...
Returns an array with all the rendered options Current options are: files - All files in the current directory file_body_display - The display type of the filemanager (block or list) dirs - The directories in the upload directory isPopup - Boolean that is true when the window is a po...
entailment
public function getFiles(array $dir_files, $files = array()) { foreach ($dir_files as $file) { $filepath = $this->getFileManager()->DirTrim($this->getFileManager()->getDir(), $file, true); //Only show non-hidden files if ($file[0] != ".") { $files[] = new...
Returns all files in the current directory @param array $dir_files @param array $files @return array
entailment
public function setDisplayType() { $file_manager = $this->getFileManager(); /** @var Session $session */ $session = $this->container->get('session'); $display_type = $session->get(self::DISPLAY_TYPE_SESSION); if ($this->container->get('request')->get('display_type') != null...
Set the display type @return string
entailment
public function getDirectoryTree($dir_files, $dir, $dir_path, $dirs = array()) { foreach ($dir_files as $file) { $filepath = $this->getFileManager()->DirTrim($dir, $file, true); if ($file[0] != ".") { if (is_dir($filepath)) { $new_dir_files = scand...
Returns the directory tree of the given path. This will loop itself until it has all directories @param array $dir_files files in the directory @param string $dir current directory @param string $dir_path current directory path @param array $dirs directories @return array|null
entailment
public function handleAction(FileManager $fileManager, Request $request, $action) { $response = new Response(); try{ $dir = $this->getFilePath($fileManager); $fileManager->setDir($dir); $fileManager->checkPath(); if($request->getMethod() === 'POST') { ...
Validates the request and handles the action @param FileManager $fileManager @param Request $request @param string $action @return Response
entailment
public function pasteFile() { /** @var Session $session */ $session = $this->container->get('session'); $sources = $session->get('copy'); $type = $sources['type']; $this->getFileManager()->pasteFile($type); $session->remove('copy'); }
Paste the file
entailment
public function getEditForm($id=null, $fields=null) { if(!$id) { $id=$this->currentPageID(); } $record=$this->getRecord($id); if($record && !$record->canView()) { return Security::permissionFailure($this); } ...
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 doSave($data, Form $form) { $record=$this->currentPage(); if($record->canEdit()) { $form->saveInto($record); $record->write(); $this->response->addHeader('X-Status', rawurlencode(_t('CodeBank.SNIPPET_SAVED', '_Snippet has b...
Saves the snippet to the database @param {array} $data Data submitted by the user @param {Form} $form Submitting form @return {SS_HTTPResponse} Response
entailment
public function doDelete($data, Form $form) { $record=$this->currentPage(); if($record->canDelete()) { Session::set('CodeBank.deletedSnippetID', $record->ID); $record->delete(); $this->response->addHeader('X-Status', rawurlencode(_t('CodeBank.SNIPPET_...
Deletes the snippet from the database @param {array} $data Data submitted by the user @param {Form} $form Submitting form @return {SS_HTTPResponse} Response
entailment
public function writeMessage(Zend_Amf_Parse_OutputStream $stream) { $objectEncoding = $this->_objectEncoding; //Write encoding to start of stream. Preamble byte is written of two byte Unsigned Short $stream->writeByte(0x00); $stream->writeByte($objectEncoding); // Loop thro...
Serialize the PHP data types back into Actionscript and create and AMF stream. @param Zend_Amf_Parse_OutputStream $stream @return Zend_Amf_Response
entailment
function Text_Diff_Renderer($params = array()) { foreach ($params as $param => $value) { $v = '_' . $param; if (isset($this->$v)) { $this->$v = $value; } } }
Constructor.
entailment
public function setPassword($password) { if ($this->username === null) { throw new InvalidConfigException('用户名不能为空'); } $this->password = md5($password . $this->username); }
设置密码 @param string $password @throws InvalidConfigException
entailment
public function setCallback($callback) { if (is_array($callback)) { require_once 'Zend/Server/Method/Callback.php'; $callback = new Zend_Server_Method_Callback($callback); } elseif (!$callback instanceof Zend_Server_Method_Callback) { require_once 'Zend/Server/Exc...
Set method callback @param array|Zend_Server_Method_Callback $callback @return Zend_Server_Method_Definition
entailment
public function addPrototype($prototype) { if (is_array($prototype)) { require_once 'Zend/Server/Method/Prototype.php'; $prototype = new Zend_Server_Method_Prototype($prototype); } elseif (!$prototype instanceof Zend_Server_Method_Prototype) { require_once 'Zend/S...
Add prototype to method definition @param array|Zend_Server_Method_Prototype $prototype @return Zend_Server_Method_Definition
entailment
public function setObject($object) { if (!is_object($object) && (null !== $object)) { require_once 'Zend/Server/Exception.php'; throw new Zend_Server_Exception('Invalid object passed to ' . __CLASS__ . '::' . __METHOD__); } $this->_object = $object; return $th...
Set object to use with method calls @param object $object @return Zend_Server_Method_Definition
entailment
public function toArray() { $prototypes = $this->getPrototypes(); $signatures = array(); foreach ($prototypes as $prototype) { $signatures[] = $prototype->toArray(); } return array( 'name' => $this->getName(), 'callback' ...
Serialize to array @return array
entailment
public function authenticate() { $optionsRequired = array('filename', 'realm', 'username', 'password'); foreach ($optionsRequired as $optionRequired) { if (null === $this->{"_$optionRequired"}) { /** * @see Zend_Auth_Adapter_Exception */ ...
Defined by Zend_Auth_Adapter_Interface @throws Zend_Auth_Adapter_Exception @return Zend_Auth_Result
entailment
protected function _secureStringCompare($a, $b) { if (strlen($a) !== strlen($b)) { return false; } $result = 0; for ($i = 0; $i < strlen($a); $i++) { $result |= ord($a[$i]) ^ ord($b[$i]); } return $result == 0; }
Securely compare two strings for equality while avoided C level memcmp() optimisations capable of leaking timing information useful to an attacker attempting to iteratively guess the unknown string (e.g. password) being compared against. @param string $a @param string $b @return bool
entailment
public static function parse($arguments, $content=null, $parser=null) { //Ensure ID is pressent in the arguments if(!array_key_exists('id', $arguments)) { return '<p><b><i>'._t('CodeBankShortCode.MISSING_ID_ATTRIBUTE', '_Short Code missing the id attribute').'</i></b></p>'; } ...
Parses the snippet short code @example [snippet id=123] @example [snippet id=123 version=456]
entailment
protected function _setupPrimaryAssignment() { if ($this->_primaryAssignment === null) { $this->_primaryAssignment = array(1 => self::PRIMARY_ASSIGNMENT_SESSION_ID); } else if (!is_array($this->_primaryAssignment)) { $this->_primaryAssignment = array(1 => (string) $this->_pri...
Initialize session table primary key value assignment @return void @throws Zend_Session_SaveHandler_Exception
entailment
public function render() { // Set the request arguments as GET parameters $_GET = $this->getRequestArguments(); try { $this->controllerContext->getRequest()->setOriginalRequestMappingResults($this->validationErrors); // Render the content element $result...
Render this component @return string Rendered component (HTML)
entailment
protected function exportInternal() { // Read the TypoScript rendering configuration for the given content record if ($this->config !== null) { $this->template = '10 = RECORDS'.PHP_EOL.TypoScriptUtility::serialize('', [10 => $this->config]); } return parent::exportIntern...
Return component specific properties @return array Component specific properties
entailment
public function toDomainEvents(): DomainEvents { return DomainEvents::make($this->map(function (StreamEvent $streamEvent) { return $streamEvent->event(); })->toArray()); }
return a DomainEvents collection containing the domain events from within this stream events collection @return DomainEvents
entailment
protected static function _namespaceIsset($namespace, $name = null) { if (self::$_readable === false) { /** * @see Zend_Session_Exception */ require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception(self::_THROW_NOT_READABLE_MSG...
namespaceIsset() - check to see if a namespace or a variable within a namespace is set @param string $namespace @param string $name @return bool
entailment
protected static function _namespaceUnset($namespace, $name = null) { if (self::$_writable === false) { /** * @see Zend_Session_Exception */ require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception(self::_THROW_NOT_WRITABLE_MSG...
namespaceUnset() - unset a namespace or a variable within a namespace @param string $namespace @param string $name @throws Zend_Session_Exception @return void
entailment
protected static function & _namespaceGet($namespace, $name = null) { if (self::$_readable === false) { /** * @see Zend_Session_Exception */ require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception(self::_THROW_NOT_READABLE_MSG...
namespaceGet() - Get $name variable from $namespace, returning by reference. @param string $namespace @param string $name @return mixed
entailment
public function scopeWithRelations(Builder $builder, $relations = null) { $with = []; foreach ($this->getWithRelationsList($relations) as $relation) { list($relation, $scope) = $this->_parseRelation($relation); if ($this->isWithableRelation($builder, $relation)) { ...
Add eager loaded relations. @param Builder $builder query builder @param array $relations list of relations to be loaded
entailment
protected function _parseRelation($relation) { $scope = null; if (strpos($relation, ':') !== false) { list($relation, $scope) = explode(':', $relation); } return [$relation, $scope]; }
Parse relation string to extract relation name and optional scope @param $relation @return array [relation name, scope name]
entailment
public function handle(GetResponseEvent $event) { $request = $event->getRequest(); if (!$this->keyExtractor->hasKey($request)) { $response = new Response(); $response->setStatusCode(401); $event->setResponse($response); return ; } $ap...
This interface must be implemented by firewall listeners. @param GetResponseEvent $event
entailment
public static function getMappedClassName($className) { $mappedName = array_search($className, self::$classMap); if ($mappedName) { return $mappedName; } $mappedName = array_search($className, array_flip(self::$classMap)); if ($mappedName) { return ...
Looks up the supplied call name to its mapped class name @param string $className @return string
entailment
public static function addResourceDirectory($prefix, $dir) { if(self::$_resourceLoader) { self::$_resourceLoader->addPrefixPath($prefix, $dir); } }
Add directory to the list of places where to look for resource handlers @param string $prefix @param string $dir
entailment
public static function getResourceParser($resource) { if(self::$_resourceLoader) { $type = preg_replace("/[^A-Za-z0-9_]/", " ", get_resource_type($resource)); $type = str_replace(" ","", ucwords($type)); return self::$_resourceLoader->load($type); } return...
Get plugin class that handles this resource @param resource $resource Resource type @return string Class name
entailment