sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function rename($dropletId, array $parameters)
{
if (!array_key_exists('name', $parameters) || !is_string($parameters['name'])) {
throw new \InvalidArgumentException('You need to provide a string "name".');
}
return $this->processQuery($this->buildQuery($dropletId, Drople... | Renames a specific droplet to a different name.
The name key is required.
@param integer $dropletId The id of the droplet.
@param array $parameters An array of parameters.
@return StdClass
@throws \InvalidArgumentException | entailment |
public function queryWithParam(string $query, array $param): PDOStatement
{
$statement = $this->prepare($query);
foreach ($param as $value) {
$this->checkValue($value);
//reassign as reference
//because bindParam need it as reference
$ref = $value;
... | Executes an SQL statement with parameters,
returning a result set as a PDOStatement object
@param string $query SQL statement
@param array $param Parameter as array as PDOStatement::bindParam
@return PDOStatement | entailment |
public function pagination()
{
$rows = $this->info->getTotal()->rows;
$rows = empty($rows) ? 0 : $rows;
$limit = input()->get('limit');
$limit = empty($limit) ? $this->info->limit : $limit;
return new Pagination($rows, $limit);
} | Result::pagination
@return \O2System\Framework\Libraries\Ui\Components\Pagination | entailment |
public function all($fields = null)
{
if (isset($fields)) {
$this->db->select($fields);
}
$result = $this->db->from($this->collection)->get();
if ($result->count() > 0) {
$this->result = new DataObjects\Result($result, $this);
return $this->resu... | FinderTrait::all
Find single or many record base on criteria by specific field
@param array|null $fields
@return DataObjects\Result|bool Returns FALSE if failed. | entailment |
public function find($criteria, $field = null, $limit = null)
{
if (is_array($criteria)) {
return $this->findIn($criteria, $field);
}
$field = isset($field) ? $field : $this->primaryKey;
$result = $this->db
->from($this->collection)
->getWhere([$... | FinderTrait::find
Find single or many record base on criteria by specific field
@param string $criteria Criteria value
@param string|null $field Table column field name | set to primary key by default
@return DataObjects\Result|bool Returns FALSE if failed. | entailment |
public function findIn(array $inCriteria, $field = null)
{
$field = isset($field) ? $field : $this->primaryKey;
$result = $this->db
->from($this->collection)
->whereIn($field, $inCriteria)
->get();
if ($result->count() > 0) {
$this->result = ... | FinderTrait::findIn
Find many records within criteria on specific field
@param array $inCriteria List of criteria
@param string $field Table column field name | set to primary key by default
@return DataObjects\Result|bool Returns FALSE if failed. | entailment |
public function findWhere(array $conditions, $limit = null)
{
$result = $this->db
->from($this->collection)
->getWhere($conditions, $limit);
if ($result->count() > 0) {
$this->result = new DataObjects\Result($result, $this);
if ($limit == 1) {
... | FinderTrait::findWhere
Find single record based on certain conditions
@param array $conditions List of conditions with criteria
@access protected
@return DataObjects\Result|bool Returns FALSE if failed. | entailment |
public function findNotIn(array $notInCriteria, $field = null)
{
$field = isset($field) ? $field : $this->primaryKey;
$result = $this->db
->from($this->collection)
->whereNotIn($field, $notInCriteria)
->get();
if ($result->count() > 0) {
$thi... | FinderTrait::findNotIn
Find many records not within criteria on specific field
@param array $notInCriteria List of criteria
@param string $field Table column field name | set to primary key by default
@return DataObjects\Result|bool Returns FALSE if failed. | entailment |
public function createColumns(array $columns, $tagName = 'td')
{
foreach ($columns as $column) {
if ($column instanceof Column) {
$column->tagName = $tagName;
$this->childNodes->push($column);
} else {
$columnElement = $this->createColu... | Row::createColumns
@param array $columns
@param string $tagName
@return static | entailment |
public function createColumn($tagName = 'td')
{
$column = new Element($tagName);
$this->childNodes->push($column);
return $this->childNodes->last();
} | Row::createColumn
@param string $tagName
@return Element | entailment |
private function check(string $uuid): void
{
$uuid32 = \str_replace('-', '', $uuid);
if (\preg_match('/^[0-9a-f]{8}[0-9a-f]{4}[4][0-9a-f]{3}[89ab][0-9a-f]{3}[0-9a-f]{12}$/i', $uuid32) !== 1) {
throw new InvalidArgumentException('Invalid UUID version 4 provided.');
}
$th... | Check UUID.
@param string $uuid
@return void | entailment |
private function generate(): void
{
$this->hexUUID = \sprintf(
'%s-%s-%s-%s-%s',
// 8 hex characters
\bin2hex(\random_bytes(4)),
// 4 hex characters
\bin2hex(\random_bytes(2)),
// "4" for the UUID version + 3 hex characters
... | Generate a random UUID v4 in hex format.
@codeCoverageIgnore
@return string | entailment |
public function jsonResponseSuccess(array $data = [], $status = 200, $code = 'success', array $headers = [], $options = 0)
{
return $this->jsonResponse()->success($data, $status, $code, $headers, $options);
} | Respond with a success response.
@param array $data
@param int $status
@param string $code
@param array $headers
@param int $options
@return \Illuminate\Http\JsonResponse | entailment |
public function jsonResponseError(array $data = [], $status = 400, $code = 'error', array $headers = [], $options = 0)
{
return $this->jsonResponse()->error($data, $status, $code, $headers, $options);
} | Respond with an error response.
@param array $data
@param int $status
@param string $code
@param array $headers
@param int $options
@return \Illuminate\Http\JsonResponse | entailment |
public function canById(int $permissionId): bool
{
if (isset($this->permission[$permissionId])) {
return true;
}
return false;
} | Check if a Permission is owned, use permission Id.
@param int $permissionId
@return bool | entailment |
public function canByName(string $permissionName): bool
{
if (\in_array($permissionName, \array_column($this->permission, 'name'), true)) {
return true;
}
return false;
} | Check if a Permission is owned, use permission name.
@param string $permissionName
@return bool | entailment |
public function offsetGet($offset)
{
if ($this->offsetExists($offset)) {
return parent::offsetGet($offset);
} elseif (null !== ($result = $this->__call($offset))) {
return $result;
}
return null;
} | Row::offsetGet
@param string $offset
@return bool|\O2System\Framework\Models\Sql\DataObjects\Result|\O2System\Framework\Models\Sql\DataObjects\Result\Row|null | entailment |
public function loadFile($filename, $subDir = null)
{
if (is_file($filename)) {
if (strpos($filename, 'font') !== false) {
$this->fonts->append($filename);
} else {
$type = pathinfo($filename, PATHINFO_EXTENSION);
switch ($type) {
... | Head::loadFile
@param string $filename
@param string|null $subDir
@return void | entailment |
protected static function createNew(
int $ttl,
TokenOwnerInterface $owner = null,
Client $client = null,
array $scopes = null
): self {
if (is_array($scopes)) {
$scopes = array_map(function ($scope) {
return (string) $scope;
}, $scopes)... | Create a new AbstractToken
@param int $ttl
@param TokenOwnerInterface $owner
@param Client $client
@param string[]|Scope[]|null $scopes
@return AbstractToken | entailment |
public function matchScopes($scopes): bool
{
$scopes = is_string($scopes) ? explode(' ', $scopes) : $scopes;
$diff = array_diff($scopes, $this->scopes);
return empty($diff);
} | Match the scopes of the token with the one provided in the parameter
@param array|string $scopes | entailment |
public function isValid($scopes): bool
{
if ($this->isExpired()) {
return false;
}
if (! empty($scopes) && ! $this->matchScopes($scopes)) {
return false;
}
return true;
} | Check if the token is valid, according to the given scope(s) and expiration dates
@param array|string $scopes | entailment |
public function get(string $key, $default = null)
{
//create file name
$file = $this->dir.'/'.\sha1($key).'.php';
if ($this->doesFileChecksFailed($file)) {
return $default;
}
$cacheValue = include $file;
return \unserialize($cacheValue['value']);
} | Fetches a value from the cache.
@param string $key The unique key of this item in the cache.
@param mixed $default Default value to return if the key does not exist.
@return mixed The value of the item from the cache, or $default in case of cache miss. | entailment |
private function doesFileChecksFailed(string $file): bool
{
//check if file exist
if (!\file_exists($file)) {
return true;
}
//take cache from file
$cacheValue = include $file;
//check if cache is expired and delete file from storage
if ($cacheVa... | Checks for cache file.
@param string $file
@return bool | entailment |
public function set(string $key, $value, int $ttl = 0): bool
{
//create cache array
$cache = [
'key' => $key,
'value' => \serialize($value),
'expires' => $this->calculateTtl($ttl),
];
//export
// HHVM fails at __set_state, so just us... | Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
@param string $key The key of the item to store.
@param mixed $value The value of the item to store, must be serializable.
@param int $ttl Optional. The TTL (time to live) value in seconds of this item.
If no value i... | entailment |
public function delete(string $key): bool
{
//create file name
$file = $this->dir.'/'.\sha1($key).'.php';
//chek if file exist and delete
if (\file_exists($file)) {
\unlink($file);
return true;
}
return false;
} | Delete an item from the cache by its unique key.
@param string $key The unique cache key of the item to delete.
@return bool True if the item was successfully removed. False if there was an error. | entailment |
public function has(string $key): bool
{
return !$this->doesFileChecksFailed($this->dir.'/'.\sha1($key).'.php');
} | Determines whether an item is present in the cache.
NOTE: It is recommended that has() is only to be used for cache warming type purposes
and not to be used within your live applications operations for get/set, as this method
is subject to a race condition where your has() will return true and immediately after,
anoth... | entailment |
protected function loadAgentFile()
{
if (($found = is_file(PATH_FRAMEWORK . 'Config/UserAgents.php'))) {
include(PATH_FRAMEWORK . 'Config/UserAgents.php');
}
if ($found !== true) {
return false;
}
$return = false;
if (isset($platforms)) {
... | UserAgent::loadAgentFile
Compile the User Agent Data
@return bool | entailment |
protected function setPlatform()
{
if (is_array(static::$platforms) && count(static::$platforms) > 0) {
foreach (static::$platforms as $key => $val) {
if (preg_match('|' . preg_quote($key) . '|i', $this->string)) {
$this->platform = $val;
... | UserAgent::setPlatform
Set the Platform
@return bool | entailment |
public function isBrowser($key = null)
{
if ( ! $this->isBrowser) {
return false;
}
// No need to be specific, it's a browser
if ($key === null) {
return true;
}
// Check for a specific browser
return (isset(static::$browsers[ $key ])... | UserAgent::isBrowser
Is Browser
@param string|null $key
@return bool | entailment |
public function isRobot($key = null)
{
if ( ! $this->isRobot) {
return false;
}
// No need to be specific, it's a robot
if ($key === null) {
return true;
}
// Check for a specific robot
return (isset(static::$robots[ $key ]) && $this-... | Is Robot
@param string $key
@return bool | entailment |
public function isMobile($key = null)
{
if ( ! $this->isMobile) {
return false;
}
// No need to be specific, it's a mobile
if ($key === null) {
return true;
}
// Check for a specific robot
return (isset(static::$mobiles[ $key ]) && $t... | UserAgent::isMobile
Is Mobile
@param string $key
@return bool | entailment |
public function isReferral()
{
if ( ! isset($this->referer)) {
if (empty($_SERVER[ 'HTTP_REFERER' ])) {
$this->referer = false;
} else {
$referer_host = @parse_url($_SERVER[ 'HTTP_REFERER' ], PHP_URL_HOST);
$own_host = parse_url(base_ur... | UserAgent::isReferral
Is this a referral from another site?
@return bool | entailment |
protected function setLanguages()
{
if ((count($this->languages) === 0) && ! empty($_SERVER[ 'HTTP_ACCEPT_LANGUAGE' ])) {
$this->languages = explode(
',',
preg_replace(
'/(;\s?q=[0-9\.]+)|\s/i',
'',
strto... | UserAgent::setLanguages
Sets the accepted languages.
@return void | entailment |
protected function setCharsets()
{
if ((count($this->charsets) === 0) && ! empty($_SERVER[ 'HTTP_ACCEPT_CHARSET' ])) {
$this->charsets = explode(
',',
preg_replace(
'/(;\s?q=.+)|\s/i',
'',
strtolower(trim... | UserAgent::setCharsets
Sets the accepted character sets
@return void | entailment |
public function parse($string)
{
// Reset values
$this->isBrowser = false;
$this->isRobot = false;
$this->isMobile = false;
$this->browser = '';
$this->browserVersion = '';
$this->mobile = '';
$this->robot = '';
// Set the new user-agent strin... | UserAgent::parse
Parse a custom user-agent string
@param string $string
@return void | entailment |
protected function setBrowser()
{
if (is_array(static::$browsers) && count(static::$browsers) > 0) {
foreach (static::$browsers as $key => $val) {
if (preg_match('|' . $key . '.*?([0-9\.]+)|i', $this->string, $match)) {
$this->isBrowser = true;
... | UserAgent::setBrowser
Sets the user agent browser.
@return bool | entailment |
protected function setMobile()
{
if (is_array(static::$mobiles) && count(static::$mobiles) > 0) {
foreach (static::$mobiles as $key => $val) {
if (false !== (stripos($this->string, $key))) {
$this->isMobile = true;
$this->mobile = $val;
... | UserAgent::setMobile
Sets the user agent mobile device.
@return bool | entailment |
protected function setRobot()
{
if (is_array(static::$robots) && count(static::$robots) > 0) {
foreach (static::$robots as $key => $val) {
if (preg_match('|' . preg_quote($key) . '|i', $this->string)) {
$this->isRobot = true;
$this->robot =... | UserAgent::setRobot
Sets the user agent robot.
@return bool | entailment |
public function run()
{
if ($this->count()) {
$request = server_request();
foreach ($this->registry as $offset => $handler) {
$this->process($request, $handler);
}
}
} | Middleware::run
@return void | entailment |
public function isUserInRoleById(int $userId): bool
{
if (isset($this->users[$userId])) {
return true;
}
return false;
} | Check if an user is in role, use the user Id.
@param int $userId
@return bool | entailment |
public function isUserInRoleByName(string $userName): bool
{
if (\in_array($userName, \array_column($this->users, 'name'), true)) {
return true;
}
return false;
} | Check if an user is in role, use the user name.
@param string $userName
@return bool | entailment |
public function createLabel($textContent = null, array $attributes = [])
{
$label = new Form\Elements\Label($attributes);
$label->attributes->addAttributeClass('col-form-label');
if (isset($textContent)) {
$label->textContent->push($textContent);
}
$this->childN... | Group::createLabel
@param array $attributes
@return \O2System\Framework\Libraries\Ui\Components\Form\Elements\Label | entailment |
public function createInput(array $attributes = [])
{
if (isset($attributes[ 'type' ])) {
switch ($attributes[ 'type' ]) {
default:
$input = new Form\Elements\Input($attributes);
break;
case 'checkbox':
$... | Group::createInput
@param array $attributes
@return \O2System\Framework\Libraries\Ui\Components\Form\Elements\Input | entailment |
public function createTextarea(array $attributes = [])
{
$this->childNodes->push(new Form\Elements\Textarea($attributes));
return $this->childNodes->last();
} | Group::createTextarea
@param array $attributes
@return \O2System\Framework\Libraries\Ui\Components\Form\Elements\Textarea | entailment |
public function createSelect(array $options = [], $selected = null, array $attributes = [])
{
$select = new Form\Elements\Select($attributes);
if (count($options)) {
$select->createOptions($options, $selected);
}
$this->childNodes->push($select);
return $this->... | Group::createSelect
@param array $options
@param null $selected
@param array $attributes
@return \O2System\Framework\Libraries\Ui\Components\Form\Elements\Select | entailment |
public function createInputGroup(array $attributes = [])
{
$inputGroup = new Form\Input\Group();
if (count($attributes)) {
$inputGroup->createInput($attributes);
}
$this->childNodes->push($inputGroup);
return $this->input = $this->childNodes->last();
} | @param array $attributes
@return \O2System\Framework\Libraries\Ui\Components\Form\Input\Group | entailment |
public function add(MapEntity $map)
{
$mapId = $map->getMapId();
$this->maps[$mapId] = $map;
parent::markAdded($mapId);
} | {@inheritDoc} | entailment |
public function sync()
{
foreach (parent::getDeleted() as $id) {
if (isset($this->maps[$id])) {
$this->connection->delete('maps', array('map_id' => $id));
unset($this->maps[$id]);
parent::reassign($id);
}
}
foreach (par... | {@inheritDoc} | entailment |
public function getUniqueId()
{
$result = $this->connection->prepare("SELECT MAX(map_id) FROM maps");
$result->execute();
$row = $result->fetchColumn();
return (int)($row + 1);
} | {@inheritDoc} | entailment |
public function findOneByName($name)
{
foreach ($this->maps as $map) {
if ($map->getName() === $name) {
return $map;
}
}
$queryBuilder = $this->connection->createQueryBuilder();
$queryBuilder->select('map_id', 'name', 'width', 'height')->from(... | {@inheritDoc} | entailment |
public function shouldSnapshot(EventSourcedAggregateRoot $aggregateRoot)
{
$clonedAggregateRoot = clone $aggregateRoot;
foreach ($clonedAggregateRoot->getUncommittedEvents() as $domainMessage) {
if (($domainMessage->getPlayhead() + 1) % $this->eventCount === 0) {
return ... | {@inheritdoc} | entailment |
private function enhanceColumns(): void
{
foreach ($this->oldColumns as $table)
{
foreach ($table as $column)
{
$table_name = $column['table_name'];
$column_name = $column['column_name'];
if ($column['constant_name']=='*')
{
$constant_name ... | Enhances $oldColumns as follows:
If the constant name is *, is is replaced with the column name prefixed by $this->myPrefix in uppercase.
Otherwise the constant name is set to uppercase. | entailment |
private function executeColumnWidths(): void
{
$this->loadOldColumns();
$this->loadColumns();
$this->enhanceColumns();
$this->mergeColumns();
$this->writeColumns();
} | Gathers constants based on column widths. | entailment |
private function executeEnabled(): void
{
if ($this->constantsFilename!==null)
{
$this->executeColumnWidths();
}
if ($this->className!==null)
{
$this->executeCreateConstants();
}
$this->logNumberOfConstants();
} | Executes the enabled functionalities. | entailment |
private function extractLines(string $source): array
{
$tokens = token_get_all($source);
$line1 = null;
$line2 = null;
$line3 = null;
// Find annotation @constants
$step = 1;
foreach ($tokens as $token)
{
switch ($step)
{
case 1:
// Step 1: Find doc comm... | Searches for 3 lines in the source code of the class for constants. The lines are:
* The first line of the doc block with the annotation '@setbased.stratum.constants'.
* The last line of this doc block.
* The last line of continuous constant declarations directly after the doc block.
If one of these line can not be fou... | entailment |
private function fillConstants(): void
{
foreach ($this->columns as $table_name => $table)
{
foreach ($table as $column_name => $column)
{
if (isset($this->columns[$table_name][$column_name]['constant_name']))
{
$this->constants[$column['constant_name']] = $column['length... | Merges $columns and $labels (i.e. all known constants) into $constants. | entailment |
private function loadColumns(): void
{
$rows = DataLayer::getAllTableColumns();
foreach ($rows as $row)
{
$row['length'] = DataTypeHelper::deriveFieldLength($row);
$this->columns[$row['table_name']][$row['column_name']] = $row;
}
} | Loads the width of all columns in the MySQL schema into $columns. | entailment |
private function loadLabels(): void
{
$tables = DataLayer::getLabelTables();
foreach ($tables as $table)
{
$rows = DataLayer::getLabelsFromTable($table['table_name'], $table['id'], $table['label']);
foreach ($rows as $row)
{
$this->labels[$row['label']] = $row['id'];
}
... | Loads all primary key labels from the MySQL database. | entailment |
private function loadOldColumns(): void
{
if (file_exists($this->constantsFilename))
{
$handle = fopen($this->constantsFilename, 'r');
$line_number = 0;
while (($line = fgets($handle)))
{
$line_number++;
if ($line!="\n")
{
$n = preg_match('/^\s*(([a-z... | Loads from file $constantsFilename the previous table and column names, the width of the column,
and the constant name (if assigned) and stores this data in $oldColumns. | entailment |
private function logNumberOfConstants(): void
{
$n_id = sizeof($this->labels);
$n_len = sizeof($this->constants) - $n_id;
$this->io->writeln('');
$this->io->text(sprintf('Number of constants based on column widths: %d', $n_len));
$this->io->text(sprintf('Number of constants based on database IDs... | Logs the number of constants generated. | entailment |
private function makeConstantStatements(): array
{
$width1 = 0;
$width2 = 0;
$constants = [];
foreach ($this->constants as $constant => $value)
{
$width1 = max(mb_strlen($constant), $width1);
$width2 = max(mb_strlen((string)$value), $width2);
}
$line_format = sprintf(' ... | Generates PHP code with constant declarations.
@return array The generated PHP code, lines are stored as rows in the array. | entailment |
private function mergeColumns(): void
{
foreach ($this->oldColumns as $table_name => $table)
{
foreach ($table as $column_name => $column)
{
if (isset($this->columns[$table_name][$column_name]))
{
$this->columns[$table_name][$column_name]['constant_name'] = $column['const... | Preserves relevant data in $oldColumns into $columns. | entailment |
private function readConfigFile(string $configFilename): array
{
$settings = parse_ini_file($configFilename, true);
$this->constantsFilename = self::getSetting($settings, false, 'constants', 'columns');
$this->className = self::getSetting($settings, false, 'constants', 'class');
return $sett... | Reads configuration parameters from the configuration file.
@param string $configFilename
@return array | entailment |
private function writeColumns(): void
{
$content = '';
foreach ($this->columns as $table)
{
$width1 = 0;
$width2 = 0;
foreach ($table as $column)
{
$width1 = max(mb_strlen($column['column_name']), $width1);
$width2 = max(mb_strlen((string)$column['length']), $width2... | Writes table and column names, the width of the column, and the constant name (if assigned) to
$constantsFilename. | entailment |
private function writeConstantClass(): void
{
// Get the class loader.
/** @var \Composer\Autoload\ClassLoader $loader */
$loader = spl_autoload_functions()[0][0];
// Find the source file of the constant class.
$file_name = $loader->findFile($this->className);
if ($file_name===false)
{
... | Inserts new and replace old (if any) constant declaration statements in a PHP source file. | entailment |
public function execute()
{
parent::execute();
if (empty($this->optionFilename)) {
output()->write(
(new Format())
->setContextualClass(Format::DANGER)
->setString(language()->getLine('CLI_MAKE_HELPER_E_FILENAME'))
... | Helper::execute | entailment |
public function createLegend($text, array $attributes = [])
{
$node = new Fieldset\Legend($attributes);
$node->entity->setEntityName('legend');
$node->attributes->addAttribute('for', dash($text));
$node->textContent->push($text);
$this->childNodes->prepend($node);
... | Fieldset::createLegend
@param string $text
@param array $attributes
@return mixed | entailment |
private static function extractColumnsFromTableDescription(array $description): array
{
$ret = [];
foreach ($description as $column)
{
preg_match('/^(\w+)(.*)?$/', $column['Type'], $parts1);
$tmp = ['column_name' => $column['Field'],
'data_type' => $parts1[1],
... | Extract column metadata from the rows returend by the SQL statement 'describe table'.
@param array $description The description of the table.
@return array | entailment |
public function loadStoredRoutine(): array
{
$this->routineName = pathinfo($this->sourceFilename, PATHINFO_FILENAME);
$this->phpStratumOldMetadata = $this->phpStratumMetadata;
$this->filemtime = filemtime($this->sourceFilename);
$load = $this->mustLoadStoredRoutine();
if ($l... | Loads the stored routine into the instance of MySQL and returns the metadata of the stored routine.
@return array | entailment |
private function dropRoutine(): void
{
if (isset($this->rdbmsOldRoutineMetadata))
{
MetaDataLayer::dropRoutine($this->rdbmsOldRoutineMetadata['routine_type'], $this->routineName);
}
} | Drops the stored routine if it exists. | entailment |
private function extractBulkInsertTableColumnsInfo(): void
{
// Return immediately if designation type is not appropriate for this method.
if ($this->designationType!='bulk_insert') return;
// Check if table is a temporary table or a non-temporary table.
$table_is_non_temporary = MetaDataLayer::check... | Extracts the column names and column types of the current table for bulk insert. | entailment |
private function extractDesignationType(): void
{
$found = true;
$key = array_search('begin', $this->routineSourceCodeLines);
if ($key!==false)
{
for ($i = 1; $i<$key; $i++)
{
$n = preg_match('/^\s*--\s+type:\s*(\w+)\s*(.+)?\s*$/',
$this->routineSourceCod... | Extracts the designation type of the stored routine. | entailment |
private function extractDocBlockPartsSource(): void
{
// Get the DocBlock for the source.
$tmp = PHP_EOL;
foreach ($this->routineSourceCodeLines as $line)
{
$n = preg_match('/create\\s+(procedure|function)\\s+([a-zA-Z0-9_]+)/i', $line);
if ($n) break;
$tmp .= $line;
$tmp .= PH... | Extracts the DocBlock (in parts) from the source of the stored routine. | entailment |
private function extractDocBlockPartsWrapper(): void
{
// Get the DocBlock parts from the source of the stored routine.
$this->extractDocBlockPartsSource();
// Generate the parameters parts of the DocBlock to be used by the wrapper.
$parameters = [];
foreach ($this->parameters as $parameter_info)... | Extracts DocBlock parts to be used by the wrapper generator. | entailment |
private function extractExtendedParametersInfo(): void
{
$key = array_search('begin', $this->routineSourceCodeLines);
if ($key!==false)
{
for ($i = 1; $i<$key; $i++)
{
$k = preg_match('/^\s*--\s+param:(?:\s*(\w+)\s+(\w+)(?:(?:\s+([^\s-])\s+([^\s-])\s+([^\s-])\s*$)|(?:\s*$)))?/',
... | Extracts extended info of the routine parameters. | entailment |
private function extractPlaceholders(): void
{
$unknown = [];
preg_match_all('(@[A-Za-z0-9\_\.]+(\%type)?@)', $this->routineSourceCode, $matches);
if (!empty($matches[0]))
{
foreach ($matches[0] as $placeholder)
{
if (isset($this->replacePairs[strtoupper($placeholder)]))
{... | Extracts the placeholders from the stored routine source. | entailment |
private function extractReturnType(): void
{
// Return immediately if designation type is not appropriate for this method.
if (!in_array($this->designationType, ['function', 'singleton0', 'singleton1'])) return;
$key = array_search('begin', $this->routineSourceCodeLines);
if ($key!==false)
{
... | Extracts the return type of the stored routine. | entailment |
private function extractRoutineParametersInfo(): void
{
$routine_parameters = MetaDataLayer::getRoutineParameters($this->routineName);
foreach ($routine_parameters as $key => $routine_parameter)
{
if ($routine_parameter['parameter_name'])
{
$data_type_descriptor = $routine_parameter['d... | Extracts info about the parameters of the stored routine. | entailment |
private function extractRoutineTypeAndName(): void
{
$n = preg_match('/create\\s+(procedure|function)\\s+([a-zA-Z0-9_]+)/i', $this->routineSourceCode, $matches);
if ($n==1)
{
$this->routineType = strtolower($matches[1]);
if ($this->routineName!=$matches[2])
{
throw new RoutineLo... | Extracts the name of the stored routine and the stored routine type (i.e. procedure or function) source. | entailment |
private function getParameterDocDescription(string $name): ?string
{
if (isset($this->docBlockPartsSource['parameters']))
{
foreach ($this->docBlockPartsSource['parameters'] as $parameter_doc_info)
{
if ($parameter_doc_info['name']===$name) return $parameter_doc_info['description'];
... | Gets description by name of the parameter as found in the DocBlock of the stored routine.
@param string $name Name of the parameter.
@return string|null | entailment |
private function loadRoutineFile(): void
{
// Set magic constants specific for this stored routine.
$this->setMagicConstants();
// Replace all place holders with their values.
$lines = explode("\n", $this->routineSourceCode);
$routine_source = [];
foreach ($lines as $i => &$line)
... | Loads the stored routine into the database. | entailment |
private function logUnknownPlaceholders(array $unknown): void
{
// Return immediately if there are no unknown placeholders.
if (empty($unknown)) return;
sort($unknown);
$this->io->text('Unknown placeholder(s):');
$this->io->listing($unknown);
$replace = [];
foreach ($unknown as $placehol... | Logs the unknown placeholder (if any).
@param array $unknown The unknown placeholders. | entailment |
private function mustLoadStoredRoutine(): bool
{
// If this is the first time we see the source file it must be loaded.
if (!isset($this->phpStratumOldMetadata)) return true;
// If the source file has changed the source file must be loaded.
if ($this->phpStratumOldMetadata['timestamp']!=$this->filemt... | Returns true if the source file must be load or reloaded. Otherwise returns false.
@return bool | entailment |
private function readSourceCode(): void
{
$this->routineSourceCode = file_get_contents($this->sourceFilename);
$this->routineSourceCodeLines = explode("\n", $this->routineSourceCode);
if ($this->routineSourceCodeLines===false)
{
throw new RoutineLoaderException('Source file is empty');
... | Reads the source code of the stored routine. | entailment |
private function setMagicConstants(): void
{
$real_path = realpath($this->sourceFilename);
$this->replace['__FILE__'] = "'".MetaDataLayer::realEscapeString($real_path)."'";
$this->replace['__ROUTINE__'] = "'".$this->routineName."'";
$this->replace['__DIR__'] = "'".MetaDataLayer::realEscapeStri... | Adds magic constants to replace list. | entailment |
private function unsetMagicConstants(): void
{
unset($this->replace['__FILE__']);
unset($this->replace['__ROUTINE__']);
unset($this->replace['__DIR__']);
unset($this->replace['__LINE__']);
} | Removes magic constants from current replace list. | entailment |
private function updateMetadata(): void
{
$this->phpStratumMetadata['routine_name'] = $this->routineName;
$this->phpStratumMetadata['designation'] = $this->designationType;
$this->phpStratumMetadata['return'] = $this->returnType;
$this->phpStratumMetadata['paramete... | Updates the metadata for the stored routine. | entailment |
private function updateParametersInfo(): void
{
if (!empty($this->extendedParameters))
{
foreach ($this->extendedParameters as $spec_param_name => $spec_param_info)
{
$param_not_exist = true;
foreach ($this->parameters as $key => $param_info)
{
if ($param_info['pa... | Update information about specific parameters of stored routine. | entailment |
private function validateParameterLists(): void
{
// Make list with names of parameters used in database.
$database_parameters_names = [];
foreach ($this->parameters as $parameter_info)
{
$database_parameters_names[] = $parameter_info['parameter_name'];
}
// Make list with names of para... | Validates the parameters found the DocBlock in the source of the stored routine against the parameters from the
metadata of MySQL and reports missing and unknown parameters names. | entailment |
private function validateReturnType(): void
{
// Return immediately if designation type is not appropriate for this method.
if (!in_array($this->designationType, ['function', 'singleton0', 'singleton1'])) return;
$types = explode('|', $this->returnType);
$diff = array_diff($types, ['string', 'int', ... | Validates the specified return type of the stored routine. | entailment |
public function setImageBackground($src)
{
$this->attributes->addAttributeClass('jumbotron-bg');
if (is_file($src)) {
$src = path_to_url($src);
}
$this->attributes->addAttribute('style', 'background-image: url(\'' . $src . '\');');
return $this;
} | Jumbotron::setImageBackground
@param string $src
@return static | entailment |
public function setVideoBackground($src, $poster = null)
{
$this->attributes->addAttributeClass('jumbotron-video');
$video = new Element('video', 'jumbotron-video');
if (isset($poster)) {
$video->attributes->addAttribute('poster', $poster);
}
$video->attributes... | Jumbotron::setVideoBackground
@param string $src
@param string|null $poster
@return static | entailment |
public function setCarousel(Carousel $carousel)
{
$this->attributes->addAttributeClass('jumbotron-carousel');
$this->childNodes->prepend($carousel);
return $this;
} | Jumbotron::setCarousel
@param \O2System\Framework\Libraries\Ui\Components\Carousel $carousel
@return static | entailment |
public function createHeader($text, $tagName = 'h1', array $attributes = ['class' => 'display-3'])
{
$header = new Element($tagName, 'header-' . dash($text));
$header->textContent->push($text);
if (count($attributes)) {
foreach ($attributes as $name => $value) {
... | Jumbotron::createHeader
@param string $text
@param string $tagName
@param array $attributes
@return Element | entailment |
public function createHorizontalRule(array $attributes = [])
{
$hr = new Element('hr');
if (count($attributes)) {
foreach ($attributes as $name => $value) {
$hr->attributes->addAttribute($name, $value);
}
}
$this->childNodes->push($hr);
... | Jumbotron::createHorizontalRule
@param array $attributes
@return Element | entailment |
public function createParagraph($text = null, array $attributes = [])
{
$paragraph = new Paragraph();
if (count($attributes)) {
foreach ($attributes as $name => $value) {
$paragraph->attributes->addAttribute($name, $value);
}
}
if ($text inst... | Jumbotron::createParagraph
@param string|null $text
@param array $attributes
@return Paragraph | entailment |
public function render()
{
if ($this->attributes->hasAttributeClass('jumbotron-fluid')) {
$output[] = $this->open();
$container = new Element('div', 'container');
$container->attributes->addAttributeClass('container-fluid');
if ($this->hasChildNodes()) {
... | Jumbotron::render
@return string | entailment |
public static function format($hook, $type, $notification, $params) {
$event = elgg_extract('event', $params);
$comment = $event->getObject();
$recipient = elgg_extract('recipient', $params);
$language = elgg_extract('language', $params);
if (!$comment instanceof Comment) {
return;
}
$entity = $comm... | Prepare a notification for when comment is created
@param string $hook Equals 'prepare'
@param string $type Equals ''notification:create:object:comment'
@param Notification $notification Notification object
@param array $params Additional params
@return Notification | entailment |
public static function getSubscriptions($hook, $type, $return, $params) {
$event = elgg_extract('event', $params);
if (!$event instanceof SubscriptionNotificationEvent) {
return;
}
$object = $event->getObject();
if (!$object instanceof Comment) {
return;
}
$subscriptions = [];
$actor_subscripti... | Subscribe users to comments based on original entity
@param string $hook "get"
@param string $type "subscriptions"
@param array $return Subscriptions
@param array $params Hook params
@return array | entailment |
public static function subscribe($event, $type, $entity) {
if (!$entity instanceof Comment) {
return;
}
$original_container = $entity->getOriginalContainer();
if (!$original_container instanceof \ElggObject) {
// Let core subscriptions deal with it
return;
}
if (check_entity_relationship($entity... | Subscribe users to notifications about the thread
@param string $event "create"
@param string $type "object"
@param \ElggEntity $entity Object
@return void | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.