sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function writeDouble($double) {
$bin = pack("d",$double);
$testEndian = unpack("C*",pack("S*",256));
$bigEndian = !$testEndian[1]==1;
if ($bigEndian) $bin = strrev($bin);
$this->rawData.=$bin;
} | writeDouble
@param float $double
@return void | entailment |
public function send($recipient, $body, $originator = '')
{
if (null === $this->username || null === $this->password || null === $this->accountRef) {
throw new Exception\InvalidCredentialsException('No API credentials provided');
}
$params = $this->getParameters(array(
... | {@inheritDoc} | entailment |
public function getStatus($messageId)
{
if (null === $this->username || null === $this->password || null === $this->accountRef) {
throw new Exception\InvalidCredentialsException('No API credentials provided');
}
$params = $this->getParameters(array(
'messageID' => $m... | Retrieves the status of a message
@param string $messageId The message Id.
@return array | entailment |
public function getParameters(array $additionnal_parameters = array())
{
return array_merge(array(
'username' => $this->username,
'password' => $this->password,
'account' => $this->accountRef,
'plainText' => '1',
), $additionnal_parameters);
} | Builds the parameters list to send to the API.
@return array
@author Kevin Gomez <contact@kevingomez.fr> | entailment |
protected function parseResults($result, array $extra_result_data = array())
{
// the data sent by the API looks like this
// Result=OK
// MessageIDs=3c13bbba-a9c2-460c-961b-4d6772960af0
$data = array();
// split the lines
$result_lines = explode("\n", $result);
... | Parse the data returned by the API.
@param string $result The raw result string.
@return array | entailment |
public function count()
{
$count = 0;
foreach ($this->_indices as $index) {
$count += $this->_indices->count();
}
return $count;
} | Returns the total number of documents in this index (including deleted documents).
@return integer | entailment |
public function numDocs()
{
$docs = 0;
foreach ($this->_indices as $index) {
$docs += $this->_indices->numDocs();
}
return $docs;
} | Returns the total number of non-deleted documents in this index.
@return integer | entailment |
public static function getDefaultSearchField()
{
if (count($this->_indices) == 0) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices list is empty');
}
$defaultSearchField = reset($this->_indices)->getDefaultSearchField... | Get default search field.
Null means, that search is performed through all fields by default
@return string
@throws Zend_Search_Lucene_Exception | entailment |
public static function getResultSetLimit()
{
if (count($this->_indices) == 0) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices list is empty');
}
$defaultResultSetLimit = reset($this->_indices)->getResultSetLimit();
... | Set result set limit.
0 means no limit
@return integer
@throws Zend_Search_Lucene_Exception | entailment |
public function getMaxBufferedDocs()
{
if (count($this->_indices) == 0) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices list is empty');
}
$maxBufferedDocs = reset($this->_indices)->getMaxBufferedDocs();
for... | Retrieve index maxBufferedDocs option
maxBufferedDocs is a minimal number of documents required before
the buffered in-memory documents are written into a new Segment
Default value is 10
@return integer
@throws Zend_Search_Lucene_Exception | entailment |
public function getMaxMergeDocs()
{
if (count($this->_indices) == 0) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices list is empty');
}
$maxMergeDocs = reset($this->_indices)->getMaxMergeDocs();
foreach ($th... | Retrieve index maxMergeDocs option
maxMergeDocs is a largest number of documents ever merged by addDocument().
Small values (e.g., less than 10,000) are best for interactive indexing,
as this limits the length of pauses while indexing to a few seconds.
Larger values are best for batched indexing and speedier searches.... | entailment |
public function getMergeFactor()
{
if (count($this->_indices) == 0) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices list is empty');
}
$mergeFactor = reset($this->_indices)->getMergeFactor();
foreach ($this-... | Retrieve index mergeFactor option
mergeFactor determines how often segment indices are merged by addDocument().
With smaller values, less RAM is used while indexing,
and searches on unoptimized indices are faster,
but indexing speed is slower.
With larger values, more RAM is used during indexing,
and while searches on... | entailment |
public function find($query)
{
if (count($this->_indices) == 0) {
return array();
}
$hitsList = array();
$indexShift = 0;
foreach ($this->_indices as $index) {
$hits = $index->find($query);
if ($indexShift != 0) {
foreach... | Performs a query against the index and returns an array
of Zend_Search_Lucene_Search_QueryHit objects.
Input is a string or Zend_Search_Lucene_Search_Query.
@param mixed $query
@return array Zend_Search_Lucene_Search_QueryHit
@throws Zend_Search_Lucene_Exception | entailment |
public function getFieldNames($indexed = false)
{
$fieldNamesList = array();
foreach ($this->_indices as $index) {
$fieldNamesList[] = $index->getFieldNames($indexed);
}
return array_unique(call_user_func_array('array_merge', $fieldNamesList));
} | Returns a list of all unique field names that exist in this index.
@param boolean $indexed
@return array | entailment |
public function getDocument($id)
{
if ($id instanceof Zend_Search_Lucene_Search_QueryHit) {
/* @var $id Zend_Search_Lucene_Search_QueryHit */
$id = $id->id;
}
foreach ($this->_indices as $index) {
$indexCount = $index->count();
if ($indexCoun... | Returns a Zend_Search_Lucene_Document object for the document
number $id in this index.
@param integer|Zend_Search_Lucene_Search_QueryHit $id
@return Zend_Search_Lucene_Document
@throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range | entailment |
public function hasTerm(Zend_Search_Lucene_Index_Term $term)
{
foreach ($this->_indices as $index) {
if ($index->hasTerm($term)) {
return true;
}
}
return false;
} | Returns true if index contain documents with specified term.
Is used for query optimization.
@param Zend_Search_Lucene_Index_Term $term
@return boolean | entailment |
public function termDocs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
{
if ($docsFilter != null) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Document filters could not used with multi-searcher');
}
$docsList ... | Returns IDs of all the documents containing term.
@param Zend_Search_Lucene_Index_Term $term
@param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
@return array
@throws Zend_Search_Lucene_Exception | entailment |
public function termFreqs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
{
if ($docsFilter != null) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Document filters could not used with multi-searcher');
}
$freqsLis... | Returns an array of all term freqs.
Return array structure: array( docId => freq, ...)
@param Zend_Search_Lucene_Index_Term $term
@param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
@return integer
@throws Zend_Search_Lucene_Exception | entailment |
public function termPositions(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
{
if ($docsFilter != null) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Document filters could not used with multi-searcher');
}
$term... | Returns an array of all term positions in the documents.
Return array structure: array( docId => array( pos1, pos2, ...), ...)
@param Zend_Search_Lucene_Index_Term $term
@param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
@return array
@throws Zend_Search_Lucene_Exception | entailment |
public function docFreq(Zend_Search_Lucene_Index_Term $term)
{
$docFreq = 0;
foreach ($this->_indices as $index) {
$docFreq += $index->docFreq($term);
}
return $docFreq;
} | Returns the number of documents in this index containing the $term.
@param Zend_Search_Lucene_Index_Term $term
@return integer | entailment |
public function getSimilarity()
{
if (count($this->_indices) == 0) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Indices list is empty');
}
$similarity = reset($this->_indices)->getSimilarity();
foreach ($this->_i... | Retrive similarity used by index reader
@return Zend_Search_Lucene_Search_Similarity
@throws Zend_Search_Lucene_Exception | entailment |
public function norm($id, $fieldName)
{
foreach ($this->_indices as $index) {
$indexCount = $index->count();
if ($indexCount > $id) {
return $index->norm($id, $fieldName);
}
$id -= $indexCount;
}
return null;
} | Returns a normalization factor for "field, document" pair.
@param integer $id
@param string $fieldName
@return float | entailment |
public function delete($id)
{
foreach ($this->_indices as $index) {
$indexCount = $index->count();
if ($indexCount > $id) {
$index->delete($id);
return;
}
$id -= $indexCount;
}
include_once 'Zend/Search/Lucene... | Deletes a document from the index.
$id is an internal document id
@param integer|Zend_Search_Lucene_Search_QueryHit $id
@throws Zend_Search_Lucene_Exception | entailment |
public function setDocumentDistributorCallback($callback)
{
if ($callback !== null && !is_callable($callback)) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('$callback parameter must be a valid callback.');
}
$this->_docu... | Set callback for choosing target index.
@param callback $callback
@throws Zend_Search_Lucene_Exception | entailment |
public function addDocument(Zend_Search_Lucene_Document $document)
{
if ($this->_documentDistributorCallBack !== null) {
$index = call_user_func($this->_documentDistributorCallBack, $document, $this->_indices);
} else {
$index = $this->_indices[array_rand($this->_indices)];
... | Adds a document to this index.
@param Zend_Search_Lucene_Document $document
@throws Zend_Search_Lucene_Exception | entailment |
public function terms()
{
$termsList = array();
foreach ($this->_indices as $index) {
$termsList[] = $index->terms();
}
return array_unique(call_user_func_array('array_merge', $termsList));
} | Returns an array of all terms in this index.
@return array | entailment |
public function resetTermsStream()
{
if ($this->_termsStream === null) {
/**
* Zend_Search_Lucene_TermStreamsPriorityQueue
*/
include_once 'Zend/Search/Lucene/TermStreamsPriorityQueue.php';
$this->_termsStream = new Zend_Search_Lucene_TermStreamsPriorityQueue($this->_i... | Reset terms stream. | entailment |
public function getDataRegexMatch(string $regex, $group = null, int $fill_size = 0)
{
$is_matched = preg_match($regex, $this->stringDataIsWaitingToBeParsed, $matches);
if ($group !== null && $group >= 0) {
if ($is_matched) {
return $matches[$group] ?? '';
} e... | @param string $regex
@param int|string $group
@param int $fill_size Fill the array to the fixed size
@return array|string | entailment |
public static function getTypes()
{
return array( self::TT_WORD,
self::TT_PHRASE,
self::TT_FIELD,
self::TT_FIELD_INDICATOR,
self::TT_REQUIRED,
self::TT_PROHIBITED,
... | Returns all possible lexeme types.
It's used for syntax analyzer state machine initialization
@return array | entailment |
public static function loadDocxFile($fileName, $storeContent = false)
{
if (!is_readable($fileName)) {
include_once 'Zend/Search/Lucene/Document/Exception.php';
throw new Zend_Search_Lucene_Document_Exception('Provided file \'' . $fileName . '\' is not readable.');
}
... | Load Docx document from a file
@param string $fileName
@param boolean $storeContent
@return Zend_Search_Lucene_Document_Docx
@throws Zend_Search_Lucene_Document_Exception | entailment |
public function send($recipient, $body, $originator = '')
{
if (empty($originator)) {
throw new InvalidArgumentException('The originator parameter is required for this provider.');
}
$internationalOriginator = $this->localNumberToInternational($originator, $this->international_p... | {@inheritDoc} | entailment |
private function executeQuery($url, array $data = array(), array $extra_result_data = array())
{
$request = array(
'outboundSMSMessageRequest' => array(
'address' => array(sprintf('tel:%s', $data['to'])),
'senderAddress' => sprintf('tel:%s'... | do the query | entailment |
public function setNextEntrySign($sign)
{
if ($this->_mode === self::GM_BOOLEAN) {
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('It\'s not allowed to mix boolean and signs styles in the same subquery.');
... | Set sign for next entry
@param integer $sign
@throws Zend_Search_Lucene_Exception | entailment |
public function addEntry(Zend_Search_Lucene_Search_QueryEntry $entry)
{
if ($this->_mode !== self::GM_BOOLEAN) {
$this->_signs[] = $this->_nextEntrySign;
}
$this->_entries[] = $entry;
$this->_nextEntryField = null;
$this->_nextEntrySign = null;
} | Add entry to a query
@param Zend_Search_Lucene_Search_QueryEntry $entry | entailment |
public function processFuzzyProximityModifier($parameter = null)
{
// Check, that modifier has came just after word or phrase
if ($this->_nextEntryField !== null || $this->_nextEntrySign !== null) {
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw ne... | Process fuzzy search or proximity search modifier
@throws Zend_Search_Lucene_Search_QueryParserException | entailment |
public function boost($boostFactor)
{
// Check, that modifier has came just after word or phrase
if ($this->_nextEntryField !== null || $this->_nextEntrySign !== null) {
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_Q... | Set boost factor to the entry
@param float $boostFactor | entailment |
public function addLogicalOperator($operator)
{
if ($this->_mode === self::GM_SIGNS) {
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('It\'s not allowed to mix boolean and signs styles in the same subquery.'... | Process logical operator
@param integer $operator | entailment |
public function _signStyleExpressionQuery()
{
include_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
$query = new Zend_Search_Lucene_Search_Query_Boolean();
include_once 'Zend/Search/Lucene/Search/QueryParser.php';
if (Zend_Search_Lucene_Search_QueryParser::getDefaultOperator()... | Generate 'signs style' query from the context
'+term1 term2 -term3 +(<subquery1>) ...'
@return Zend_Search_Lucene_Search_Query | entailment |
private function _booleanExpressionQuery()
{
/**
* We treat each level of an expression as a boolean expression in
* a Disjunctive Normal Form
*
* AND operator has higher precedence than OR
*
* Thus logical query is a disjunction of one or more conjuncti... | Generate 'boolean style' query from the context
'term1 and term2 or term3 and (<subquery1>) and not (<subquery2>)'
@return Zend_Search_Lucene_Search_Query
@throws Zend_Search_Lucene | entailment |
public function readInt()
{
$str = $this->_fread(4);
return ord($str[0]) << 24 |
ord($str[1]) << 16 |
ord($str[2]) << 8 |
ord($str[3]);
} | Reads an integer from the current position in the file
and advances the file pointer.
@return integer | entailment |
public function writeInt($value)
{
settype($value, 'integer');
$this->_fwrite(
chr($value>>24 & 0xFF) .
chr($value>>16 & 0xFF) .
chr($value>>8 & 0xFF) .
chr($value & 0xFF), 4
);
} | Writes an integer to the end of file.
@param integer $value | entailment |
public function readLong()
{
/**
* Check, that we work in 64-bit mode.
* fseek() uses long for offset. Thus, largest index segment file size in 32bit mode is 2Gb
*/
if (PHP_INT_SIZE > 4) {
$str = $this->_fread(8);
return ord($str[0]) << 56 |
... | Returns a long integer from the current position in the file
and advances the file pointer.
@return integer|float
@throws Zend_Search_Lucene_Exception | entailment |
public function writeLong($value)
{
/**
* Check, that we work in 64-bit mode.
* fseek() and ftell() use long for offset. Thus, largest index segment file size in 32bit mode is 2Gb
*/
if (PHP_INT_SIZE > 4) {
settype($value, 'integer');
$this->_fwrite... | Writes long integer to the end of file
@param integer $value
@throws Zend_Search_Lucene_Exception | entailment |
public function readLong32Bit()
{
$wordHigh = $this->readInt();
$wordLow = $this->readInt();
if ($wordHigh & (int)0x80000000) {
// It's a negative value since the highest bit is set
if ($wordHigh == (int)0xFFFFFFFF && ($wordLow & (int)0x80000000)) {
... | Returns a long integer from the current position in the file,
advances the file pointer and return it as float (for 32-bit platforms).
@return integer|float
@throws Zend_Search_Lucene_Exception | entailment |
public function writeLong32Bit($value)
{
if ($value < (int)0x80000000) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Long integers lower than -2147483648 (0x80000000) are not supported on 32-bit platforms.');
}
if ($value ... | Writes long integer to the end of file (32-bit platforms implementation)
@param integer|float $value
@throws Zend_Search_Lucene_Exception | entailment |
public function readVInt()
{
$nextByte = ord($this->_fread(1));
$val = $nextByte & 0x7F;
for ($shift=7; ($nextByte & 0x80) != 0; $shift += 7) {
$nextByte = ord($this->_fread(1));
$val |= ($nextByte & 0x7F) << $shift;
}
return $val;
} | Returns a variable-length integer from the current
position in the file and advances the file pointer.
@return integer | entailment |
public function writeVInt($value)
{
settype($value, 'integer');
while ($value > 0x7F) {
$this->_fwrite(chr(($value & 0x7F)|0x80));
$value >>= 7;
}
$this->_fwrite(chr($value));
} | Writes a variable-length integer to the end of file.
@param integer $value | entailment |
public function readString()
{
$strlen = $this->readVInt();
if ($strlen == 0) {
return '';
} else {
/**
* This implementation supports only Basic Multilingual Plane
* (BMP) characters (from 0x0000 to 0xFFFF) and doesn't support
*... | Reads a string from the current position in the file
and advances the file pointer.
@return string | entailment |
public function writeString($str)
{
/**
* This implementation supports only Basic Multilingual Plane
* (BMP) characters (from 0x0000 to 0xFFFF) and doesn't support
* "supplementary characters" (characters whose code points are
* greater than 0xFFFF)
* Java 2 repr... | Writes a string to the end of file.
@param string $str
@throws Zend_Search_Lucene_Exception | entailment |
protected function mayCache($item) {
return (
isset($item) &&
is_object($item) &&
isset($item->headers) &&
is_string($item->headers->etag) &&
!empty($item->headers->etag) &&
isset($item->body) &&
is_object($item->body)
);
} | Returns whether or not the item may be cached. It has to be a stdClass
that Sag would return, with a valid E-Tag, and no cache headers that tell
us to not cache.
@param The item that we're trying to cache - it should be a response as a
stdClass.
@return bool | entailment |
public function beginTransaction()
{
if ($this->disableTransactionHandling) {
return;
}
if (null !== $this->session) {
throw new \RuntimeException('Transaction already started');
}
$this->session = $this->mongoClient->startSession();
$this->se... | Begin transaction
@return void | entailment |
public function commit()
{
if ($this->disableTransactionHandling) {
return;
}
if (null === $this->session) {
throw new RuntimeAdapterException('Transaction not started');
}
$this->session->commitTransaction();
$this->session->endSession();
... | Commit transaction
@return void | entailment |
public function rollback()
{
if ($this->disableTransactionHandling) {
return;
}
if (null === $this->session) {
throw new RuntimeAdapterException('Transaction not started');
}
$this->session->abortTransaction();
$this->session->endSession();
... | Rollback transaction
@return void | entailment |
private function getCollection(StreamName $streamName): Collection
{
$collection = $this->mongoClient->selectCollection($this->dbName, $this->getCollectionName($streamName));
return $collection;
} | Get mongo db stream collection
@param StreamName $streamName
@return Collection | entailment |
public function performSearch()
{
try {
$index = Zend_Search_Lucene::open(self::get_index_location());
Zend_Search_Lucene::setResultSetLimit(100);
$query = new Zend_Search_Lucene_Search_Query_Boolean();
$term = Zend_Search_Lucene_Search_QueryPars... | Perform a search query on the index | entailment |
private function buildQueryUrl($params)
{
$url = parse_url($_SERVER['REQUEST_URI']);
if (! array_key_exists('query', $url)) {
$url['query'] = '';
}
parse_str($url['query'], $url['query']);
if (! is_array($url['query'])) {
$url['query'] = array();
... | Build a nice query string for the results
@return string | entailment |
public static function set_meta_data($data)
{
if (is_array($data)) {
foreach ($data as $key => $value) {
self::$meta_data[strtolower($key)] = $value;
}
} else {
user_error("set_meta_data must be passed an array", E_USER_ERROR);
}
} | OpenSearch MetaData fields. For a list of fields consult
{@link self::get_meta_data()}
@param array | entailment |
public static function get_meta_data()
{
$data = self::$meta_data;
$defaults = array(
'Description' => _t('DocumentationViewer.OPENSEARCHDESC', 'Search the documentation'),
'Tags' => _t('DocumentationViewer.OPENSEARCHTAGS', 'documentation'),
'Contact' => ... | Returns the meta data needed by opensearch.
@return array | entailment |
public function renderResults()
{
if (!$this->results && $this->query) {
$this->performSearch();
}
if (!$this->outputController) {
return user_error('Call renderResults() on a DocumentationViewer instance.', E_USER_ERROR);
}
$request = $this-... | Renders the search results into a template. Either the search results
template or the Atom feed. | entailment |
public function merge()
{
if ($this->_mergeDone) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('Merge is already done.');
}
if (count($this->_segmentInfos) < 1) {
include_once 'Zend/Search/Lucene/Exception.php';... | Do merge.
Returns number of documents in newly created segment
@return Zend_Search_Lucene_Index_SegmentInfo
@throws Zend_Search_Lucene_Exception | entailment |
private function _mergeFields()
{
foreach ($this->_segmentInfos as $segName => $segmentInfo) {
foreach ($segmentInfo->getFieldInfos() as $fieldInfo) {
$this->_fieldsMap[$segName][$fieldInfo->number] = $this->_writer->addFieldInfo($fieldInfo);
}
}
} | Merge fields information | entailment |
private function _mergeNorms()
{
foreach ($this->_writer->getFieldInfos() as $fieldInfo) {
if ($fieldInfo->isIndexed) {
foreach ($this->_segmentInfos as $segName => $segmentInfo) {
if ($segmentInfo->hasDeletions()) {
$srcNorm = $segment... | Merge field's normalization factors | entailment |
private function _mergeStoredFields()
{
$this->_docCount = 0;
foreach ($this->_segmentInfos as $segName => $segmentInfo) {
$fdtFile = $segmentInfo->openCompoundFile('.fdt');
for ($count = 0; $count < $segmentInfo->count(); $count++) {
$fieldCount = $fdtFile-... | Merge fields information | entailment |
private function _mergeTerms()
{
/**
* Zend_Search_Lucene_Index_TermsPriorityQueue
*/
include_once 'Zend/Search/Lucene/Index/TermsPriorityQueue.php';
$segmentInfoQueue = new Zend_Search_Lucene_Index_TermsPriorityQueue();
$segmentStartId = 0;
foreach ($this->_segmentInfos ... | Merge fields information | entailment |
public function fromArray(array $data = array())
{
if (!empty($data['id'])) {
$this->id = (string) $data['id'];
}
if (isset($data['recipient'])) {
$this->recipient = (string) $data['recipient'];
}
if (isset($data['body'])) {
$this->body =... | {@inheritDoc} | entailment |
public function toArray()
{
return array(
'id' => $this->id,
'recipient' => $this->recipient,
'body' => $this->body,
'originator' => $this->originator,
'status' => $this->status,
'sent' => $this->isSent(),
... | {@inheritDoc} | entailment |
public function offsetGet($offset)
{
$offset = strtolower($offset);
return $this->offsetExists($offset) ? $this->$offset : null;
} | {@inheritDoc} | entailment |
public function offsetSet($offset, $value)
{
$offset = strtolower($offset);
if ($this->offsetExists($offset)) {
$this->$offset = $value;
}
} | {@inheritDoc} | entailment |
public function offsetUnset($offset)
{
$offset = strtolower($offset);
if ($this->offsetExists($offset)) {
$this->$offset = null;
}
} | {@inheritDoc} | entailment |
public function canView()
{
return (Director::isDev() || Director::is_cli() ||
!$this->config()->get('check_permission') ||
Permission::check($this->config()->get('check_permission'))
);
} | Can the user view this documentation. Hides all functionality for private
wikis.
@return bool | entailment |
public function handleAction($request, $action)
{
// if we submitted a form, let that pass
if (!$request->isGET() && !$request->isHEAD()) {
return parent::handleAction($request, $action);
}
$url = $request->getURL();
//
// If the current request has an e... | Overloaded to avoid "action doesn't exist" errors - all URL parts in
this controller are virtual and handled through handleRequest(), not
controller methods.
@param $request
@param $action
@return SS_HTTPResponse | entailment |
public function httpError($status, $message = null)
{
$this->init();
$class = get_class($this);
$body = $this->customise(
new ArrayData(
array(
'Message' => $message
)
)
)->renderWith(array("{$class}_error", $cl... | @param int $status
@param string $message
@return SS_HTTPResponse | entailment |
public function getMenu()
{
$entities = $this->getManifest()->getEntities();
$output = new ArrayList();
$record = $this->getPage();
$current = $this->getEntity();
foreach ($entities as $entity) {
$checkLang = $entity->getLanguage();
$checkVers = $enti... | Generate a list of {@link Documentation } which have been registered and which can
be documented.
@return DataObject | entailment |
public function getContent()
{
$page = $this->getPage();
$html = $page->getHTML();
$html = $this->replaceChildrenCalls($html);
return $html;
} | Return the content for the page. If its an actual documentation page then
display the content from the page, otherwise display the contents from
the index.md file if its a folder
@return HTMLText | entailment |
public function includeChildren($args)
{
if (isset($args['Folder'])) {
$children = $this->getManifest()->getChildrenFor(
Controller::join_links(dirname($this->record->getPath()), $args['Folder'])
);
} else {
$children = $this->getManifest()->getChi... | Short code parser | entailment |
public function getBreadcrumbs()
{
if ($this->record) {
return $this->getManifest()->generateBreadcrumbs(
$this->record,
$this->record->getEntity()
);
}
} | Generate a list of breadcrumbs for the user.
@return ArrayList | entailment |
public function Link($action = '')
{
$link = Controller::join_links(
Director::baseURL(),
Config::inst()->get('DocumentationViewer', 'link_base'),
$this->getLanguage(),
$action,
'/'
);
return $link;
} | Return the base link to this documentation location.
@return string | entailment |
public function AllPages($version = null)
{
$pages = $this->getManifest()->getPages();
$output = new ArrayList();
$baseLink = $this->getDocumentationBaseHref();
foreach ($pages as $url => $page) {
// Option to skip Pages that do not belong to the current version
... | Generate a list of all the pages in the documentation grouped by the
first letter of the page.
@param string|int|null $version
@return GroupedList | entailment |
public function getEditLink()
{
$editLink = false;
$entity = null;
$page = $this->getPage();
if ($page) {
$entity = $page->getEntity();
if ($entity && isset(self::$edit_links[strtolower($entity->title)])) {
// build the edit link, using the ... | Returns an edit link to the current page (optional).
@return string|false | entailment |
public function getNextPage()
{
return ($this->record)
? $this->getManifest()->getNextPage(
$this->record->getPath(),
$this->getEntity()->getPath()
)
: null;
} | Returns the next page. Either retrieves the sibling of the current page
or return the next sibling of the parent page.
@return DocumentationPage|null | entailment |
public function getPreviousPage()
{
return ($this->record)
? $this->getManifest()->getPreviousPage(
$this->record->getPath(),
$this->getEntity()->getPath()
)
: null;
} | Returns the previous page. Either returns the previous sibling or the
parent of this page
@return DocumentationPage|null | entailment |
private function handleCommandMessage(SabreAMF_AMF3_CommandMessage $request) {
switch($request->operation) {
case SabreAMF_AMF3_CommandMessage::CLIENT_PING_OPERATION :
$response = new SabreAMF_AMF3_AcknowledgeMessage($request);
break;
... | handleCommandMessage
@param SabreAMF_AMF3_CommandMessage $request
@return Sabre_AMF3_AbstractMessage | entailment |
protected function authenticate($username,$password) {
if (is_callable($this->onAuthenticate)) {
call_user_func($this->onAuthenticate,$username,$password);
}
} | authenticate
@param string $username
@param string $password
@return void | entailment |
protected function invokeService($service,$method,$data) {
if (is_callable($this->onInvokeService)) {
return call_user_func_array($this->onInvokeService,array($service,$method,$data));
} else {
throw new Exception('onInvokeService is not defined or not callable')... | invokeService
@param string $service
@param string $method
@param array $data
@return mixed | entailment |
public function exec() {
// First we'll be looping through the headers to see if there's anything we reconize
foreach($this->getRequestHeaders() as $header) {
switch($header['name']) {
// We found a credentials headers, calling the authenticate method
... | exec
@return void | entailment |
public function getMsgBody()
{
$body = null;
if (!empty($this->_parts)) {
if (count($this->_parts) > 1) {
foreach ($this->_parts as $part) {
if ($part->contentType != Content::CT_TEXT_PLAIN && $this->getHeaders()->getMessageContentType() == Content::C... | Текст письма
@return string|null | entailment |
public function getMsgAlternativeBody()
{
if (
!empty($this->_parts)
&& (
$this->getHeaders()->getMessageContentType() == Content::CT_MULTIPART_ALTERNATIVE
|| $this->getHeaders()->getMessageContentType() == Content::CT_MULTIPART_MIXED
)
... | Альтернативный текст письма
@return string|null | entailment |
protected function parserContent($boundary, $content)
{
if ($boundary) {
$parts = preg_split('#--'.$boundary.'(--)?\s*#si', $content, -1, PREG_SPLIT_NO_EMPTY);
foreach ($parts as $part) {
$part = trim($part);
if (empty($part)) {
con... | Разбор тела сообщения
@param string $boundary
@param string $content | entailment |
public function toUtf8($string)
{
$encode = mb_detect_encoding(
$string, [
'UTF-8',
'Windows-1251'
]
);
if ($encode && $encode !== 'UTF-8') {
$string = mb_convert_encoding($string, 'UTF-8', $encode);
}
if (!... | Конвертация в utf-8
@param $string
@return false|string|string[]|null | entailment |
protected function decodeFileName($data)
{
array_shift($data);
if (count($data) == 1) {
$name = preg_replace('#.*name\s*\=\s*[\'"]([^\'"]+).*#si', '$1', $data[0]);
} elseif (count($data) > 1) {
foreach ($data as $value) {
if (preg_match(self::FILE_PATT... | @param array $data
@return string | entailment |
public function getCustomAttribute($blockThis, $block, $attributeCode)
{
if($this->isEditForm($blockThis)){
$attribute = $block->getCustomer()->getCustomAttribute($attributeCode);
$value = $attribute ? $attribute->getValue() : null;
return $value;
} e... | /*
Return the attribute value for customer,
or Form Data Attribute
@param $blockThis
@param $block
@param $attributeCode
@return string | entailment |
protected function configure()
{
$this
->setName('atoum')
->setDescription('Launch atoum tests.')
->setHelp(<<<EOF
Launch tests of AcmeFooBundle:
<comment>./app/console atoum AcmeFooBundle</comment>
Launch tests of many bundles:
<comment>./app/console atoum... | {@inheritdoc} | entailment |
protected function execute(InputInterface $input, OutputInterface $output)
{
$runner = new Runner('atoum');
$bundles = $input->getArgument('bundles');
if (count($bundles) > 0) {
foreach ($bundles as $k => $bundleName) {
$bundles[$k] = $this->extractBundleConfigur... | {@inheritdoc} | entailment |
protected function getAtoumArguments()
{
$inlinedArguments = array();
foreach ($this->atoumArguments as $name => $values) {
$inlinedArguments[] = $name;
if (null !== $values) {
$inlinedArguments[] = $values;
}
}
return $inlinedArg... | Return inlined atoum cli arguments
@return array | entailment |
public function extractBundleConfigurationFromKernel($name)
{
$kernelBundles = $this->getContainer()->get('kernel')->getBundles();
$bundle = null;
if (preg_match('/Bundle$/', $name)) {
if (!isset($kernelBundles[$name])) {
throw new \LogicException(sprintf('Bundle... | @param string $name name
@throws \LogicException
@return BundleConfiguration | entailment |
public function getContent($url, $method = 'GET', array $headers = array(), $data = array())
{
if (is_array($data)) {
$data = $this->encodePostData($data);
}
try {
$response = $this->browser->call($url, $method, $headers, $data);
} catch (\Exception $e) {
... | {@inheritDoc} | entailment |
public function getResponseObject(string $class, string $json)
{
$object = $this->deserialize($class, $json);
$this->assertValid($object, ValidationException::RESPONSE);
return $object;
} | @param string $class
@param string $json
@throws ValidationException
@throws ParseException
@return mixed | entailment |
public function getRequestString($object): string
{
$this->assertValid($object, ValidationException::RESPONSE);
return $this->serializeBodyObject($object);
} | @param mixed $object
@throws ValidationException
@throws ParseException
@return string | entailment |
private function deserialize(string $class, string $json)
{
try {
return $this->serializer->deserialize($json, $class, 'atol_client');
} catch (\RuntimeException $exception) {
throw ParseException::becauseOfRuntimeException($exception, ParseException::RESPONSE);
}
... | @param string $class
@param string $json
@throws ParseException
@return mixed | entailment |
private function assertValid($object, int $code = 0)
{
$errors = $this->validator->validate($object);
if (count($errors)) {
throw ValidationException::becauseOfValidationErrors($errors, $code);
}
} | Assert that object is valid.
@param mixed $object
@param int $code
@throws ValidationException | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.