sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function up()
{
Schema::create('lfm_categories', function (Blueprint $table) {
$table->integer('id', true);
$table->integer('user_id')->nullable()->unsigned()->default(0);
$table->string('title')->nullable()->default(null);;
$table->longText('title_disc... | Run the migrations.
@return void | entailment |
public function table($table)
{
$processor = $this->getPostProcessor();
$grammar = $this->getQueryGrammar();
$query = new CassandraBuilder($this, $grammar, $processor);
return $query->from($table);
} | @param string $table
@return CassandraBuilder | entailment |
public function select($query, $bindings = [], $useReadPdo = true)
{
$query .= ' ALLOW FILTERING';
return $this->statement($query, $bindings);
} | @param string $query
@param array $bindings
@param bool $useReadPdo
@return mixed | entailment |
public function insert($query, $bindings = [])
{
try {
$this->statement($query, $bindings);
return true;
} catch (\Exception $e) {
throw new InternalServerErrorException('Insert failed. ' . $e->getMessage());
}
} | Run an insert statement against the database.
@param string $query
@param array $bindings
@return bool
@throws InternalServerErrorException | entailment |
public function statement($query, $bindings = [])
{
if (!empty($bindings)) {
return $this->client->runQuery($query, ['arguments' => $bindings]);
} else {
return $this->client->runQuery($query);
}
} | Execute an SQL statement and return the boolean result.
@param string $query
@param array $bindings
@return bool | entailment |
public function validateMoney(MoneyInterface $money)
{
try {
$this->numberValidator->validateNumber($money->getAmount());
} catch (InvalidNumberException $exception) {
throw new InvalidAmountException(
'Invalid amount for money specified: ' . $money->getAmount... | @param MoneyInterface $money
@throws InvalidAmountException
@throws InvalidCurrencyException | entailment |
public function run(
Renamer $renamer,
Scaffolder $scaffolder
) {
$this->drawBanner();
$child = $this->askForChildConfirmation();
$replacements = $this->askForReplacements($child);
if (! $child) {
$preset = $this->askForPreset();
}
if ($... | Run CLI logic.
@param \Tonik\CLI\Command\Shake $shake
@return void | entailment |
public function askForReplacements($child)
{
$replacements = [];
if ($child) {
$this->placeholders = array_merge($this->placeholders, $this->childPlaceholders);
}
foreach ($this->placeholders as $placeholder => $data) {
$input = $this->climate->input($data['... | Asks placeholders and saves answers.
@param boolean child
@return array | entailment |
public function askForPreset()
{
$input = $this->climate->input('<comment>Choose the front-end scaffolding</comment>');
$input->accept($this->presets, true);
return strtolower($input->prompt());
} | Asks for preset name which files will be generated.
@return string | entailment |
public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time)
{
$this->writeWarning($test, $e, $time);
} | @param \PHPUnit_Framework_Test $test
@param \PHPUnit_Framework_Warning $e
@param float $time
@since Method available since Release 4.2.0 | entailment |
protected function writeError(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
$this->writeFailureOrError($test, $e, $time, 'error');
} | @param \PHPUnit_Framework_Test $test
@param \Exception $e
@param float $time
@since Method available since Release 2.17.0 | entailment |
protected function writeFailure(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
$this->writeFailureOrError($test, $e, $time, 'failure');
} | @param \PHPUnit_Framework_Test $test
@param \Exception $e
@param float $time
@since Method available since Release 2.17.0 | entailment |
protected function writeWarning(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
$this->writeFailureOrError($test, $e, $time, 'failure');
} | @param \PHPUnit_Framework_Test $test
@param \Exception $e
@param float $time
@since Method available since Release 4.2.0 | entailment |
public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
if (!$this->colors) {
parent::addError($test, $e, $time);
return;
}
$this->writeProgress(Coloring::magenta('E'));
$this->lastTestFailed = true;
} | An error occurred.
@param \PHPUnit_Framework_Test $test
@param \Exception $e
@param float $time | entailment |
public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time)
{
if (!$this->colors) {
parent::addFailure($test, $e, $time);
return;
}
$this->writeProgress(Coloring::red('F'));
$this->lastTestFailed = true;
} | A failure occurred.
@param \PHPUnit_Framework_Test $test
@param \PHPUnit_Framework_AssertionFailedError $e
@param float $time | entailment |
public function scaffold()
{
$this->updateDependencies([
'foundation-sites' => '^6.4.1',
'what-input' => '^4.1.3',
'motion-ui' => '^1.2.2',
]);
$this->updateConfig([
'foundation' => [
'./resources/assets/js/foundation.js',
... | Scaffold a Foundation boilerplate preset.
@return void | entailment |
public static function findFileAndLineOfFailureOrError(array $testClassSuperTypes, \Exception $e, \ReflectionClass $class)
{
if (in_array($class->getName(), $testClassSuperTypes)) {
return;
}
if ($e->getFile() == $class->getFileName()) {
return array($e->getFile(), $e... | @param array $testClassSuperTypes
@param \Exception $e
@param \ReflectionClass $class
@return array | entailment |
public static function buildFailureTrace(array $backtrace)
{
$failureTrace = '';
for ($i = 0, $count = count($backtrace); $i < $count; ++$i) {
if (!array_key_exists('file', $backtrace[$i])) {
continue;
}
$failureTrace .=
$backtrace... | @param array $backtrace
@return string | entailment |
public function addObject( $contentObject, $commit = true )
{
// Indexing is not implemented in eZ Publish 5 legacy search engine
if ( $this->searchHandler instanceof LegacyHandler )
{
$searchEngine = new eZSearchEngine();
$searchEngine->addObject( $contentObject, $co... | Adds object $contentObject to the search database.
@param \eZContentObject $contentObject Object to add to search engine
@param bool $commit Whether to commit after adding the object
@return bool True if the operation succeeded. | entailment |
public function removeObjectById( $contentObjectId, $commit = null )
{
if ( !isset( $commit ) && ( $this->iniConfig->variable( 'IndexOptions', 'DisableDeleteCommits' ) === 'true' ) )
{
$commit = false;
}
elseif ( !isset( $commit ) )
{
$commit = true;
... | Removes a content object by ID from the search database.
@since 5.0
@param int $contentObjectId The content object to remove by ID
@param bool $commit Whether to commit after removing the object
@return bool True if the operation succeeded | entailment |
public function search( $searchText, $params = array(), $searchTypes = array() )
{
$searchText = trim( $searchText );
if ( empty( $searchText ) )
{
return array(
'SearchResult' => array(),
'SearchCount' => 0,
'StopWordArray' => arr... | Searches $searchText in the search database.
@param string $searchText Search term
@param array $params Search parameters
@param array $searchTypes Search types
@return array | entailment |
public function cleanup()
{
// Indexing is not implemented in eZ Publish 5 legacy search engine
if ( $this->searchHandler instanceof LegacyHandler )
{
$db = eZDB::instance();
$db->begin();
$db->query( "DELETE FROM ezsearch_word" );
$db->query( ... | Purges the index. | entailment |
public function updateNodeSection( $nodeID, $sectionID )
{
$contentObject = eZContentObject::fetchByNodeID( $nodeID );
eZContentOperationCollection::registerSearchObject( $contentObject->attribute( 'id' ) );
} | Update index when a new section is assigned to an object, through a node.
@param int $nodeID
@param int $sectionID | entailment |
public function updateNodeVisibility( $nodeID, $action )
{
$node = eZContentObjectTreeNode::fetch( $nodeID );
eZContentOperationCollection::registerSearchObject( $node->attribute( 'contentobject_id' ) );
$params = array(
'Depth' => 1,
'DepthOperator' => 'eq',
... | Update index when node's visibility is modified.
If the node has children, they will be also re-indexed, but this action is deferred to ezfindexsubtree cronjob.
@param int $nodeID
@param string $action | entailment |
public function swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() )
{
$contentObject1 = eZContentObject::fetchByNodeID( $nodeID );
$contentObject2 = eZContentObject::fetchByNodeID( $selectedNodeID );
eZContentOperationCollection::registerSearchObject( $contentObject1->attribute( 'id... | Update search index when two nodes are swapped
@param int $nodeID
@param int $selectedNodeID
@param array $nodeIdList | entailment |
function isSearchPartIncomplete( $part )
{
if ( $this->searchHandler instanceof LegacyHandler )
{
$searchEngine = new eZSearchEngine();
return $searchEngine->isSearchPartIncomplete( $part );
}
return false;
} | Returns true if the search part is incomplete.
Used only by legacy search engine (eZSearchEngine class).
@param string $part
@return bool | entailment |
public function normalizeText( $text )
{
if ( $this->searchHandler instanceof LegacyHandler )
{
$searchEngine = new eZSearchEngine();
return $searchEngine->normalizeText( $text );
}
return $text;
} | Normalizes the text so that it is easily parsable
Used only by legacy search engine (eZSearchEngine class).
@param string $text
@return string | entailment |
protected function getSSLBuilder($config)
{
if (empty($config)) {
return null;
}
$ssl = \Cassandra::ssl();
$serverCert = array_get($config, 'server_cert_path');
$clientCert = array_get($config, 'client_cert_path');
$privateKey = array_get($config, 'privat... | Creates the SSL connection builder.
@param $config
@return \Cassandra\SSLOptions|null
@throws \DreamFactory\Core\Exceptions\InternalServerErrorException | entailment |
public function listTables()
{
$tables = $this->keyspace->tables();
$out = [];
foreach ($tables as $table) {
$out[] = ['table_name' => $table->name()];
}
return $out;
} | Lists Cassandra table.
@return array | entailment |
public function executeStatement($statement, array $options = [])
{
if (!empty($options)) {
return $this->session->execute($statement, $options);
} else {
return $this->session->execute($statement);
}
} | @param \Cassandra\SimpleStatement $statement
@param array $options
@return \Cassandra\Rows | entailment |
public function runQuery($cql, array $options = [])
{
$pageInfo = $this->extractPaginationInfo($cql);
$statement = $this->prepareStatement($cql);
$rows = $this->executeStatement($statement, $options);
return static::rowsToArray($rows, $pageInfo);
} | @param string $cql
@param array $options
@return array | entailment |
protected function extractPaginationInfo(& $cql)
{
$words = explode(' ', $cql);
$limit = 0;
$offset = 0;
$limitKey = null;
foreach ($words as $key => $word) {
if ('limit' === strtolower($word) && is_numeric($words[$key + 1])) {
$limit = (int)$words... | Extracts pagination info from CQL.
@param $cql
@return array | entailment |
public static function rowsToArray($rows, array $options = [])
{
$limit = array_get($options, 'limit', 0);
$offset = array_get($options, 'offset', 0);
$array = [];
if ($offset > 0) {
if ($limit > 0) {
for ($i = 0; ($i < $limit && $rows->offsetExists($offs... | @param \Cassandra\Rows $rows
@param array $options
@return array | entailment |
public function write($buffer)
{
$result = fwrite($this->fileHandle, $buffer, strlen($buffer));
if ($result === false) {
throw new \UnexpectedValueException(sprintf('Failed to write buffer into the file [ %s ].', $this->file));
}
} | @param string $buffer
@throws \UnexpectedValueException | entailment |
public function resolve($pathOrFile)
{
if (is_dir($pathOrFile)) {
$pathOrFile .= DIRECTORY_SEPARATOR . '.docheader';
}
if (! is_file($pathOrFile)) {
throw DocHeaderFileConfiguration::notFound($pathOrFile);
}
return $pathOrFile;
} | @param string $pathOrFile
@throws DocHeaderFileConfiguration
@return string | entailment |
private static function apply($text, $color)
{
if (!array_key_exists($color, self::$outputFormatterStyles)) {
self::$outputFormatterStyles[$color] = new OutputFormatterStyle($color);
}
return self::$outputFormatterStyles[$color]->apply($text);
} | @param string $text
@param string $color
@return string | entailment |
public static function get($key = null)
{
if ($key === null) {
return self::self()->getContainer()['settings'];
} else {
return self::self()->getContainer()['settings'][$key];
}
} | Get the settings value.
If $key = null, this function returns settings.
@param string|null $key
@return mixed | entailment |
public static function set($key, $value)
{
if (is_array($key)) {
$now = self::self()->getContainer()['settings'];
foreach ($key as $item) {
$now = $now[$item];
}
$now = $value;
} else {
$settings = self::self()->getContainer... | Set the settings value.
When $key is an array, it will be viewed to a list of keys. <br>
For Example:
$key = ['a','b']; <br>
The function will set the value of $container->settions['a']['b'].
@param array|string $key
@param mixed $value | entailment |
protected function handleBootstrap($filename, $syntaxCheck = false)
{
try {
\PHPUnit_Util_Fileloader::checkAndLoad($filename, $syntaxCheck);
} catch (RuntimeException $e) {
\PHPUnit_TextUI_TestRunner::showError($e->getMessage());
}
} | Loads a bootstrap file.
@param string $filename
@param bool $syntaxCheck
@see \PHPUnit_TextUI_Command::handleBootstrap()
@since Method available since Release 2.16.0 | entailment |
protected function earlyConfigure(\PHPUnit_Util_Configuration $configuration)
{
$configuration->handlePHPConfiguration();
$phpunitConfiguration = $configuration->getPHPUnitConfiguration();
if (array_key_exists('bootstrap', $phpunitConfiguration)) {
if (array_key_exists('syntaxCh... | @param \PHPUnit_Util_Configuration $configuration $configuration
@since Method available since Release 2.16.0 | entailment |
public static function invokeWith($level, \Closure $callable)
{
$oldLevel = error_reporting($level);
self::enableErrorToException($level);
try {
call_user_func($callable);
} catch (\Exception $e) {
self::disableErrorToException();
error_reporting(... | @param int $level
@param \Closure $callable
@throws \Exception | entailment |
public static function errorToException($code, $message, $file, $line)
{
if (error_reporting() & $code) {
throw new \ErrorException($message, 0, $code, $file, $line);
}
} | @param int $code
@param string $message
@param string $file
@param int $line
@throws \ErrorException | entailment |
public function validateMoney(MoneyInterface $money)
{
$this->baseValidator->validateMoney($money);
$precision = $this->informationProvider->getDefaultPrecision($money->getCurrency());
if (!$this->math->isEqual($money->getAmount(), $this->math->round($money->getAmount(), $precision))) {
... | @param MoneyInterface $money
@throws InvalidAmountException
@throws InvalidCurrencyException | entailment |
public function send($method, $uri, array $options = [])
{
$this->calls[] = array('send', $method, $uri, $options);
return new Response();
} | /*
{@inheritdoc} | entailment |
public function purgeKey($service, $key, array $options = [])
{
$this->calls[] = array('purgeKey', $service, $key, $options);
return new Response();
} | /*
{@inheritdoc} | entailment |
public function getCall($num)
{
if (array_key_exists($num, $this->calls)) {
return $this->calls[$num];
}
return null;
} | @param $num
@return array|null | entailment |
public function addSeeder(AbstractPopulator $seeder)
{
$seeder->setPopulator($this);
$seeder->setDatabase($this->database);
$seeder->setFaker($this->faker);
$this->seeders[] = $seeder;
} | Add new seeder
@param AbstractPopulator $seeder | entailment |
public function canvasImageScale()
{
$imageOriginalWidth = imagesx($this->oImg);
$imageOriginalHeight = imagesy($this->oImg);
$scale = min($imageOriginalWidth / $this->options ['width'], $imageOriginalHeight / $this->options ['height']);
$this->options ['cropWidth'] = ceil($this->op... | Scale the image before smartcrop analyse
@return \App\Helpers\Classes\SmartClass | entailment |
public function canvasImageResample($width, $height)
{
$oCanvas = imagecreatetruecolor($width, $height);
imagecopyresampled($oCanvas, $this->oImg, 0, 0, 0, 0, $width, $height, imagesx($this->oImg), imagesy($this->oImg));
$this->oImg = $oCanvas;
return $this;
} | Function for scale image
@param integer $width
@param integer $height
@return \App\Helpers\Classes\SmartClass | entailment |
public function analyse()
{
$result = [];
$w = $this->w = imagesx($this->oImg);
$h = $this->h = imagesy($this->oImg);
$this->od = new \SplFixedArray ($h * $w * 3);
$this->aSample = new \SplFixedArray ($h * $w);
for ($y = 0; $y < $h; $y++)
{
for ($... | Analyse the image, find out the optimal crop scheme
@return array | entailment |
public function generateCrops()
{
$w = imagesx($this->oImg);
$h = imagesy($this->oImg);
$results = [];
$minDimension = min($w, $h);
$cropWidth = empty ($this->options ['cropWidth']) ? $minDimension : $this->options ['cropWidth'];
$cropHeight = empty ($this->options ['... | Generate crop schemes
@return array | entailment |
public function score($output, $crop)
{
$result = [
'detail' => 0,
'saturation' => 0,
'skin' => 0,
'boost' => 0,
'total' => 0
];
$downSample = $this->options ['scoreDownSample'];
$invDownSample = 1 / $downSample;
$o... | Score a crop scheme
@param array $output
@param array $crop
@return array | entailment |
public function crop($x, $y, $width, $height)
{
$oCanvas = imagecreatetruecolor($width, $height);
imagecopyresampled($oCanvas, $this->oImg, 0, 0, $x, $y, $width, $height, $width, $height);
$this->oImg = $oCanvas;
return $this;
} | Crop image
@param integer $x
@param integer $y
@param integer $width
@param integer $height
@return \App\Helpers\Classes\SmartClass | entailment |
public function up()
{
Schema::create('lfm_files', function (Blueprint $table) {
$table->increments('id')->unsigned();
$table->integer('user_id')->nullable()->unsigned()->default(0);;
$table->integer('category_id');
$table->integer('file_mime_type_id')->unsign... | Run the migrations.
@return void | entailment |
protected function createJUnitXMLWriter()
{
$streamWriter = $this->createStreamWriter($this->junitXMLFile);
$utf8Converter = extension_loaded('mbstring') ? new UTF8Converter() : new NullUTF8Converter();
return $this->junitXMLRealtime ? new StreamJUnitXMLWriter($streamWriter, $utf8Converter)... | @return \Stagehand\TestRunner\JUnitXMLWriter\JUnitXMLWriter
@since Method available since Release 3.3.0 | entailment |
public function swap(array $replacements)
{
foreach ($replacements as $from => $to) {
$this->replace($from, $this->normalize($to));
}
} | Inits renaming process.
@param array $replacements Values map to replace.
@return void | entailment |
protected function replace($from, $to)
{
if ($this->file->getExtension() === 'json') {
$from = addslashes($from);
}
file_put_contents(
$this->file->getRealPath(),
str_replace($from, $to, $this->file->getContents())
);
} | Replaces strings in file content.
@param string $from
@param string $to
@return void | entailment |
public function boot()
{
// the main router
$this->loadRoutesFrom(__DIR__.'/Routes/private_routes.php');
$this->loadRoutesFrom(__DIR__.'/Routes/public_routes.php');
// the main views folder
$this->loadViewsFrom(__DIR__ . '/Views', 'laravel_file_manager');
// the main migration folder f... | Bootstrap the application services.
@return void | entailment |
public function register()
{
// set the main config file
$this->mergeConfigFrom(
__DIR__ . '/Config/LFM.php', 'laravel_file_manager'
);
// bind the LFMC Facade
$this->app->bind('LFMC', function () {
return new LFMC;
});
$this->app->bind('FileManager', function () {
... | Register the application services.
@return void | entailment |
public function addListener($listener, array $events = array())
{
if (!\is_object($listener))
{
throw new InvalidArgumentException('The given listener is not an object.');
}
// We deal with a closure.
if ($listener instanceof Closure)
{
if (empty($events))
{
throw new InvalidArgumentException... | Add a listener to this dispatcher, only if not already registered to these events.
If no events are specified, it will be registered to all events matching it's methods name.
In the case of a closure, you must specify at least one event name.
@param object|Closure $listener The listener
@param array $e... | entailment |
public function clearListeners($event = null)
{
if ($event)
{
if ($event instanceof EventInterface)
{
$event = $event->getName();
}
if (isset($this->listeners[$event]))
{
unset($this->listeners[$event]);
}
}
else
{
$this->listeners = array();
}
return $this;
} | Clear the listeners in this dispatcher.
If an event is specified, the listeners will be cleared only for that event.
@param EventInterface|string $event The event object or name.
@return Dispatcher This method is chainable.
@since 1.0 | entailment |
public function init() {
//close csrf
Yii::$app->request->enableCsrfValidation = false;
//默认设置
// $this->php_path = dirname(__FILE__) . '/';
$this->php_path = $_SERVER['DOCUMENT_ROOT'] . '/';
$this->php_url = '/';
//根目录路径,可以指定绝对路径,比如 /var/www/attached/
$this->r... | public $save_path; | entailment |
public function handAction() {
//获得action 动作
$action = Yii::$app->request->get('action');
switch ($action) {
case 'fileManagerJson':
$this->fileManagerJsonAction();
break;
case 'uploadJson':
$this->UploadJosnAction();
... | 处理动作 | entailment |
public function cmp_func($a, $b) {
global $order;
if ($a['is_dir'] && !$b['is_dir']) {
return -1;
} else if (!$a['is_dir'] && $b['is_dir']) {
return 1;
} else {
if ($order == 'size') {
if ($a['filesize'] > $b['filesize']) {
... | 排序 | entailment |
public function create($amount, $currency)
{
$result = new Money($amount, $currency);
$this->validator->validateMoney($result);
return $result;
} | @param string $amount
@param string $currency
@return Money
@throws InvalidAmountException
@throws InvalidCurrencyException | entailment |
public function createFromCents($amountInCents, $currency)
{
return $this->create($this->math->div($amountInCents, '100'), $currency);
} | @param int $amountInCents
@param string $currency
@return Money
@throws InvalidAmountException
@throws InvalidCurrencyException | entailment |
public function convert($text)
{
$encoding = mb_detect_encoding($text);
if (!$encoding || $encoding == 'ASCII' || $encoding == 'UTF-8') {
return $text;
}
return mb_convert_encoding($text, 'UTF-8', $encoding);
} | @param string $text
@return string | entailment |
public function send($method, $uri, array $options = [])
{
// Prepend entrypoint if $uri is not absolute
if (0 !== strpos($uri, 'http')) {
$uri = $this->entryPoint . $uri;
}
return $this->adapter->send($method, $uri, $options);
} | /*
{@inheritdoc} | entailment |
public function purgeAll($service, array $options = [])
{
$url = '/service/' . urlencode($service) . '/purge_all';
return $this->send('POST', $url, $options);
} | /*
{@inheritdoc} | entailment |
public function purgeKey($service, $key, array $options = [])
{
$url = '/service/' . urlencode($service) . '/purge/' . $key;
return $this->send('POST', $url, $options);
} | /*
{@inheritdoc} | entailment |
public function update(IRow &$row, $data)
{
$oldValues = [];
if ($row instanceof ActiveRow) {
$oldValues = $row->toArray();
}
$res = $this->getTable()->wherePrimary($row->getPrimary())->update($data);
if (!$res) {
// if MySQL is set to return number o... | Update updates provided record with given $data array and mutates the provided instance. Operation is logged
to audit log.
@param IRow $row
@param array $data values to update
@return bool
@throws \Exception | entailment |
public function delete(IRow &$row)
{
$res = $this->getTable()->wherePrimary($row->getPrimary())->delete();
$oldValues = [];
if ($row instanceof ActiveRow) {
$oldValues = $row->toArray();
}
if (!$res) {
return false;
}
if ($this->audit... | Delete deletes provided record from repository and mutates the provided instance. Operation is logged to audit log.
@param IRow $row
@return bool | entailment |
public function insert($data)
{
$row = $this->getTable()->insert($data);
if (!$row instanceof IRow) {
return $row;
}
if ($this->auditLogRepository) {
$to = $this->filterValues($this->excludeColumns((array)$data));
$data = [
'versi... | Insert inserts data to the repository. If single IRow is returned, it attempts to log audit information.
@param $data
@return bool|int|IRow | entailment |
private function filterValues(array $values)
{
foreach ($values as $i => $field) {
if (is_bool($field)) {
$values[$i] = (int) $field;
} elseif ($field instanceof \DateTime) {
$values[$i] = $field->format('Y-m-d H:i:s');
} elseif (!is_scalar... | filterValues removes non-scalar values from the array and formats any DateTime to DB string representation.
@param array $values
@return array | entailment |
public static function bind_manipulation_capture()
{
$current = DB::get_conn();
if (!$current || !$current->getConnector()->getSelectedDatabase() || @$current->isManipulationLoggingCapture) {
return;
} // If not yet set, or its already captured, just return
$type = get_c... | This will bind a new class dynamically so we can hook into manipulation
and capture it. It creates a new PHP file in the temp folder, then
loads it and sets it as the active DB class.
@deprecated 2.1...3.0 Please use ProxyDBExtension with the tractorcow/silverstripe-proxy-db module instead | entailment |
public function onAfterPublish(&$original)
{
$member = Security::getCurrentUser();
if (!$member || !$member->exists()) {
return false;
}
$effectiveViewerGroups = '';
if ($this->owner->CanViewType === 'OnlyTheseUsers') {
$originalViewerGroups = $origin... | Log a record being published. | entailment |
public function onAfterUnpublish()
{
$member = Security::getCurrentUser();
if (!$member || !$member->exists()) {
return false;
}
$this->getAuditLogger()->info(sprintf(
'"%s" (ID: %s) unpublished %s "%s" (ID: %s)',
$member->Email ?: $member->Title,... | Log a record being unpublished. | entailment |
public function afterMemberLoggedIn()
{
$this->getAuditLogger()->info(sprintf(
'"%s" (ID: %s) successfully logged in',
$this->owner->Email ?: $this->owner->Title,
$this->owner->ID
));
} | Log successful login attempts. | entailment |
public function authenticationFailed($data)
{
// LDAP authentication uses a "Login" POST field instead of Email.
$login = isset($data['Login'])
? $data['Login']
: (isset($data[Email::class]) ? $data[Email::class] : '');
if (empty($login)) {
return $this->... | Log failed login attempts. | entailment |
public function onAfterInit()
{
// Suppress errors if dev/build necessary
if (!Security::database_is_ready()) {
return false;
}
$currentMember = Security::getCurrentUser();
if (!$currentMember || !$currentMember->exists()) {
return false;
}
... | Log permission failures (where the status is set after init of page). | entailment |
public static function convertFormatToFormat($jalaliFormat, $georgianFormat, $timeString, $timezone = null)
{
// Normalize $timezone, take from static::date(...)
$timezone = ($timezone != null) ? $timezone : ((self::$timezone != null) ? self::$timezone : date_default_timezone_get());
if (is_... | Convert a formatted string from Georgian Calendar to Jalali Calendar.
This will be useful to directly convert time strings coming from databases.
Example:
// Suppose this comes from database
$a = '2016-02-14 14:20:38';
$date = \jDateTime::convertFormatToFormat('Y-m-d H:i:s', 'Y-m-d H:i:s', $a);
// $date will now be '۱... | entailment |
public static function date($format, $stamp = false, $convert = null, $jalali = null, $timezone = null)
{
//Timestamp + Timezone
$stamp = ($stamp !== false) ? $stamp : time();
$timezone = ($timezone != null) ? $timezone : ((self::$timezone != null) ? self::$timezone : date_default_timezone_g... | jDateTime::Date
Formats and returns given timestamp just like php's
built in date() function.
e.g:
$obj->date("Y-m-d H:i", time());
$obj->date("Y-m-d", time(), false, false, 'America/New_York');
@author Sallar Kaboli
@param $format string Acceps format string based on: php.net/date
@param $stamp int Unix Timestamp (E... | entailment |
public static function gDate($format, $stamp = false, $timezone = null)
{
return self::date($format, $stamp, false, false, $timezone);
} | jDateTime::gDate
Same as jDateTime::Date method
but this one works as a helper and returns Gregorian Date
in case someone doesn't like to pass all those false arguments
to Date method.
e.g. $obj->gDate("Y-m-d") //Outputs: 2011-05-05
$obj->date("Y-m-d", false, false, false); //Outputs: 2011-05-05
Both return the exact... | entailment |
public static function getdate($timestamp = null)
{
if ($timestamp === null)
{
$timestamp = time();
}
if (is_string($timestamp))
{
if (ctype_digit($timestamp) || ($timestamp{0} == '-' && ctype_digit(substr($timestamp, 1))))
{
... | jDateTime::getdate
Like php built-in function, returns an associative array containing the date information of a timestamp, or the current local time if no timestamp is given. .
@author Meysam Pour Ganji
@param $timestamp int The timestamp that whould convert to date information array, if NULL passed, current timesta... | entailment |
private static function getDayNames($day, $shorten = false, $len = 1, $numeric = false)
{
$days = ['sat' => [1, 'شنبه'], 'sun' => [2, 'یکشنبه'], 'mon' => [3, 'دوشنبه'], 'tue' => [4, 'سه شنبه'], 'wed' => [5, 'چهارشنبه'], 'thu' => [6, 'پنجشنبه'], 'fri' => [7, 'جمعه']];
$day = substr(strtolower($day), ... | Returns correct names for week days | entailment |
private static function getMonthNames($month, $shorten = false, $len = 3)
{
// Convert
$months = ['فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'];
$ret = $months[ $month - 1 ];
// Return
return ($shorten) ? self::substr(... | Returns correct names for months | entailment |
private static function substr($str, $start, $len)
{
if (function_exists('mb_substr'))
{
return mb_substr($str, $start, $len, 'UTF-8');
}
else
{
return substr($str, $start, $len * 2);
}
} | Substring helper | entailment |
public static function toGregorian($j_y, $j_m, $j_d)
{
$g_days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
$j_days_in_month = [31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29];
$jy = $j_y - 979;
$jm = $j_m - 1;
$jd = $j_d - 1;
$j_day_no = 365 * $jy + s... | Jalali to Gregorian Conversion
Copyright (C) 2000 Roozbeh Pournader and Mohammad Toossi | entailment |
public function Gregorian_to_Jalali($gy, $gm, $gd, $mod = '')
{
$g_d_m = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
$jy = ($gy <= 1600) ? 0 : 979;
$gy -= ($gy <= 1600) ? 621 : 1600;
$gy2 = ($gm > 2) ? ($gy + 1) : $gy;
$days = (365 * $gy) + ((int)(($gy2 + 3) / 4)... | *-----------------------------------Begin--------------------------------*// | entailment |
public static function parseFromFormat($format, $date)
{
// reverse engineer date formats
$keys = [
'Y' => ['year', '\d{4}'],
'y' => ['year', '\d{2}'],
'm' => ['month', '\d{2}'],
'n' => ['month', '\d{1,2}'],
'M' => ['month', '[A-Z][a-z]{3}'... | *------------------------------ Date converter --------------------------*// | entailment |
private static function buildHtreeRow($width, callable $hasher)
{
$row = [];
if ($width === 2) {
$row[] = new TwoChildrenNode($hasher);
return $row;
}
if ($width === 3) {
$row[] = new TwoChildrenNode($hasher);
$row[] = new TwoChildrenN... | Returns a tree of ITreeNode objects of width $width
@param int $width
@param callable $hasher
@todo This must be cleaned up, it is pretty terrible as it stands.
@return ITreeNode[]
The return is an array of ITreeNode nodes that represent all of the base
of the tree in order. Additionally, the 0 index on the array will... | entailment |
protected function parseSelect($schema, $extras)
{
$fields = array_get($extras, ApiOptions::FIELDS);
if (empty($fields)) {
// minimally return id fields
$idFields = array_get($extras, ApiOptions::ID_FIELD);
if (empty($idFields)) {
$idFields = $sche... | @param TableSchema $schema
@param array|null $extras
@return array
@throws \DreamFactory\Core\Exceptions\BadRequestException
@throws \Exception | entailment |
protected function addToTransaction(
$record = null,
$id = null,
$extras = null,
$rollback = false,
$continue = false,
$single = false
) {
$dbConn = $this->parent->getConnection();
if ($rollback) {
// sql transaction really only for rollbac... | {@inheritdoc} | entailment |
protected function commitTransaction($extras = null)
{
$dbConn = $this->parent->getConnection();
if (empty($this->batchRecords) && empty($this->batchIds)) {
if (0 < $dbConn->transactionLevel()) {
$dbConn->commit();
}
return null;
}
... | {@inheritdoc} | entailment |
public static function findByPluginID($pluginID)
{
if (is_null(self::$plugins)) {
self::loadAllPlugins();
}
foreach (self::$plugins as $plugin) { /* @var $plugin \Stagehand\TestRunner\Core\Plugin\PluginInterface */
if (strtolower($plugin->getPluginID()) == strtolower... | @param string $pluginID
@return \Stagehand\TestRunner\Core\Plugin\PluginInterface | entailment |
public function replace(array $replacements)
{
foreach ($this->files() as $file) {
(new Replacer($file))->swap($replacements);
}
} | Process renaming in files content.
@param array $answers
@return void | entailment |
public function files()
{
$files = (new Finder)->files();
foreach ($this->ignoredFiles as $name) {
$files->notName($name);
}
foreach ($this->searchedFiles as $name) {
$files->name($name);
}
return $files->exclude($this->ignoredDirectories)->... | Finds files to rename.
@return array | entailment |
protected function findSuiteMethod(\ReflectionClass $testClass)
{
if ($testClass->hasMethod(\PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME)) {
$method = $testClass->getMethod(\PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME);
if ($method->isStatic()) {
return $metho... | @param \ReflectionClass $testClass
@return \ReflectionMethod
@since Method available since Release 3.0.3 | entailment |
public function attachMenuItemToForeignModule(
string $foreignMenuLink,
MenuItem $internalMenuItem,
MenuItem $menuItem
) {
$foreignMenuItem = $this->getMenuItemByLink($foreignMenuLink);
if (!is_null($foreignMenuItem)) {
$foreignMenuItem->addChild($menuItem);
... | Try to attach menu item to:
- foreign module menu (if exists, search is done by link)
- own module menu (if foreign module menu doesn't exist) | entailment |
public function getNamespace()
{
if (isset($this->properties[ 'namespace' ])) {
return $this->properties[ 'namespace' ];
}
$dir = $this->getRealPath();
$dirParts = explode('Widgets' . DIRECTORY_SEPARATOR, $dir);
$namespace = loader()->getDirNamespace(reset($dirPa... | Widget::getNamespace
@return mixed|string | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.