sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
private function getColumnTypes(): void
{
$rows = DataLayer::getAllTableColumns();
foreach ($rows as $row)
{
$key = '@'.$row['table_name'].'.'.$row['column_name'].'%type@';
$key = strtoupper($key);
$value = $row['column_type'];
if (isset($row['character_set_name'])) $value .= ' ch... | Selects schema, table, column names and the column type from MySQL and saves them as replace pairs. | entailment |
private function getConstants(): void
{
// If myTargetConfigFilename is not set return immediately.
if (!isset($this->constantClassName)) return;
$reflection = new \ReflectionClass($this->constantClassName);
$constants = $reflection->getConstants();
foreach ($constants as $name => $value)
{
... | Reads constants set the PHP configuration file and adds them to the replace pairs. | entailment |
private function getDuplicates(): array
{
// First pass make lookup table by method_name.
$lookup = [];
foreach ($this->sources as $source)
{
if (isset($source['method_name']))
{
if (!isset($lookup[$source['method_name']]))
{
$lookup[$source['method_name']] = [];
... | Returns all elements in {@link $sources} with duplicate method names.
@return array[] | entailment |
private function getOldStoredRoutinesInfo(): void
{
$this->rdbmsOldMetadata = [];
$routines = DataLayer::getRoutines();
foreach ($routines as $routine)
{
$this->rdbmsOldMetadata[$routine['routine_name']] = $routine;
}
} | Retrieves information about all stored routines in the current schema. | entailment |
private function loadAll(): void
{
$this->findSourceFiles();
$this->detectNameConflicts();
$this->getColumnTypes();
$this->readStoredRoutineMetadata();
$this->getConstants();
$this->getOldStoredRoutinesInfo();
$this->getCorrectSqlMode();
$this->loadStoredRoutines();
// Drop obsol... | Loads all stored routines into MySQL. | entailment |
private function loadList(array $fileNames): void
{
$this->findSourceFilesFromList($fileNames);
$this->detectNameConflicts();
$this->getColumnTypes();
$this->readStoredRoutineMetadata();
$this->getConstants();
$this->getOldStoredRoutinesInfo();
$this->getCorrectSqlMode();
$this->loadS... | Loads all stored routines in a list into MySQL.
@param string[] $fileNames The list of files to be loaded. | entailment |
private function loadStoredRoutines(): void
{
// Log an empty line.
$this->io->writeln('');
// Sort the sources by routine name.
usort($this->sources, function ($a, $b) {
return strcmp($a['routine_name'], $b['routine_name']);
});
// Process all sources.
foreach ($this->sources as $... | Loads all stored routines. | entailment |
private function logOverviewErrors(): void
{
if (!empty($this->errorFilenames))
{
$this->io->warning('Routines in the files below are not loaded:');
$this->io->listing($this->errorFilenames);
}
} | Logs the source files that were not successfully loaded into MySQL. | entailment |
private function methodName(string $routineName): ?string
{
if ($this->nameMangler!==null)
{
/** @var NameMangler $mangler */
$mangler = $this->nameMangler;
return $mangler::getMethodName($routineName);
}
return null;
} | Returns the method name in the wrapper for a stored routine. Returns null when name mangler is not set.
@param string $routineName The name of the routine.
@return null|string | entailment |
private function readStoredRoutineMetadata(): void
{
if (file_exists($this->phpStratumMetadataFilename))
{
$this->phpStratumMetadata = (array)json_decode(file_get_contents($this->phpStratumMetadataFilename), true);
if (json_last_error()!=JSON_ERROR_NONE)
{
throw new RuntimeException(... | Reads the metadata of stored routines from the metadata file. | entailment |
private function removeObsoleteMetadata(): void
{
// 1 pass through $mySources make new array with routine_name is key.
$clean = [];
foreach ($this->sources as $source)
{
$routine_name = $source['routine_name'];
if (isset($this->phpStratumMetadata[$routine_name]))
{
$clean[$r... | Removes obsolete entries from the metadata of all stored routines. | entailment |
private function writeStoredRoutineMetadata(): void
{
$json_data = json_encode($this->phpStratumMetadata, JSON_PRETTY_PRINT);
if (json_last_error()!=JSON_ERROR_NONE)
{
throw new RuntimeException("Error of encoding to JSON: '%s'.", json_last_error_msg());
}
// Save the metadata.
$this->w... | Writes the metadata of all stored routines to the metadata file. | entailment |
public function offsetGet($offset)
{
if (isset($this->data[$offset])) {
return $this->data[$offset];
}
return false;
} | Get.
@param string $offset
@return mixed | entailment |
public static function canComment($hook, $type, $permission, $params) {
$entity = elgg_extract('entity', $params);
if (!$entity instanceof Comment) {
return $permission;
}
if ($entity->getDepthToOriginalContainer() >= (int) elgg_get_plugin_setting('max_comment_depth', 'hypeInteractions')) {
return fals... | Disallows commenting on comments once a certain depth has been reached
@param string $hook "permissions_check:comment"
@param string $type "object"
@param bool $permission Current permission
@param array $params Hook params
@param bool | entailment |
public static function canEditAnnotation($hook, $type, $permission, $params) {
$annotation = elgg_extract('annotation', $params);
$user = elgg_extract('user', $params);
if ($annotation instanceof ElggAnnotation && $annotation->name == 'likes') {
// only owners of original annotation (or users who can edit th... | Fixes editing permissions on likes
@param string $hook "permissions_check"
@param string $type "annotation"
@param bool $permission Current permission
@param array $params Hook params
@return boolean | entailment |
public function disabled()
{
$this->attributes->addAttributeClass('disabled');
if ($this->childNodes->first() instanceof Item) {
$this->childNodes->first()->disabled();
}
} | Item::disabled | entailment |
public function render()
{
$output[] = $this->open();
if ( ! empty($this->heading)) {
$output[] = $this->heading . PHP_EOL;
}
if ( ! empty($this->paragraph)) {
if ($this->textContent->count()) {
foreach ($this->textContent as $textContent) {... | Item::render
@return string | entailment |
public function store($offset, $value)
{
$element = new Element('meta');
if ($offset === 'http-equiv') {
$element->attributes[ 'http-equiv' ] = $value[ 'property' ];
$element->attributes[ 'content' ] = $value[ 'content' ];
parent::store(camelcase('http_equiv_' . ... | Meta::store
@param string $offset
@param mixed $value | entailment |
public function transform()
{
$object = $this->resource;
$data = $object instanceof Collection || $object instanceof AbstractPaginator
? $object->map([$this, 'transformResource'])->toArray()
: $this->transformResource($object);
if ($object instanceof AbstractPaginat... | Get a displayable API output for the given object.
@return array | entailment |
public function toResponse($status = 200, array $headers = [], $options = 0)
{
return new JsonResponse($this->transform(), $status, $headers, $options);
} | Get the instance as a json response object.
@param int $status
@param array $headers
@param int $options
@return \Illuminate\Http\JsonResponse | entailment |
public static function riverMenuSetup($hook, $type, $return, $params) {
if (!elgg_is_logged_in()) {
return $return;
}
$remove = array('comment');
foreach ($return as $key => $item) {
if ($item instanceof ElggMenuItem&& in_array($item->getName(), $remove)) {
unset($return[$key]);
}
}
return $... | Filters river menu
@param string $hook "register"
@param string $type "menu:river"
@param array $return Menu items
@param array $params Hook params
@return array | entailment |
public static function interactionsMenuSetup($hook, $type, $menu, $params) {
$entity = elgg_extract('entity', $params, false);
/* @var ElggEntity $entity */
if (!elgg_instanceof($entity)) {
return $menu;
}
$active_tab = elgg_extract('active_tab', $params);
// Commenting
$comments_count = $entity->c... | Setups entity interactions menu
@param string $hook "register"
@param string $type "menu:interactions"
@param array $menu Menu
@param array $params Hook parameters
@uses $params['entity'] An entity that we are interacting with
@uses $params['active_tab'] Currently active tab, default to 'comments'
@return arra... | entailment |
public static function entityMenuSetup($hook, $type, $menu, $params) {
$entity = elgg_extract('entity', $params);
if (!$entity instanceof Comment) {
return;
}
if ($entity->canEdit()) {
$menu[] = ElggMenuItem::factory(array(
'name' => 'edit',
'text' => elgg_echo('edit'),
'href' => "stream/ed... | Setups comment menu
@param string $hook "register"
@param string $type "menu:interactions"
@param array $menu Menu
@param array $params Hook parameters
@return array | entailment |
public function register(Application $app)
{
$app[Controller::INDEX] = $app->share(function () use ($app) {
return new Controller\IndexController($app[UseCase::LOGIN]);
});
$app[Controller::ACCOUNT] = $app->share(function () use ($app) {
return new Controller\AccountC... | Registers services on the given app.
This method should only be used to configure services and parameters.
It should not get services.
@param Application $app An Application instance | entailment |
public function write($session_id, $session_data)
{
return $this->memcached->set($session_id, $session_data, $this->expire);
} | Write session data to storage.
http://php.net/manual/en/sessionhandler.write.php.
@param string $session_id
@param string $session_data
@return bool | entailment |
public function destroy($session_id)
{
if ($this->memcached->delete($session_id)) {
return true;
}
if ($this->memcached->getResultCode() === 16) {
return true;
}
return false;
} | Destroy session data.
http://php.net/manual/en/sessionhandler.destroy.php.
@param string $session_id
@return bool | entailment |
public function add(array $item)
{
$item = array_merge([
'id' => null,
'sku' => null,
'quantity' => 1,
'price' => 0,
'discount' => 0,
'name' => null,
'options' => [],
], $item);
// set sku... | Cart::add
@param array $item | entailment |
public function update($sku, array $item)
{
if ($this->offsetExists($sku)) {
$item = array_merge($this->offsetGet($sku), $item);
// update sub-total
$item[ 'subTotal' ][ 'price' ] = $item[ 'price' ] * $item[ 'quantity' ];
$item[ 'subTotal' ][ 'weight' ] = $it... | Cart::update
@param string $sku
@param array $item
@return bool | entailment |
public function getTotalWeight()
{
$totalWeight = 0;
if ($this->count()) {
foreach ($this->storage as $id => $item) {
if (isset($item[ 'subTotal' ][ 'weight' ])) {
$totalWeight += (int)$item[ 'weight' ];
}
}
}
... | Cart::getTotalWeight
@return int | entailment |
public function getTotalPrice()
{
$totalPrice = 0;
if ($this->count()) {
foreach ($this->storage as $id => $item) {
if (isset($item[ 'subTotal' ][ 'price' ])) {
$totalPrice += (int)$item[ 'price' ];
}
}
}
r... | Cart::getTotalPrice
@return int | entailment |
public function contextOutline()
{
$this->attributes->replaceAttributeClass($this->contextualClassPrefix . '-',
$this->contextualClassPrefix . '-outline-');
$this->setContextualClassPrefix($this->contextualClassPrefix . '-outline');
return $this;
} | ContextualClassSetterTrait::contextOutline
@return static | entailment |
public function setContextualClassSuffix($suffix)
{
$this->attributes->removeAttributeClass([
$this->contextualClassPrefix . '-' . 'default',
$this->contextualClassPrefix . '-' . 'primary',
$this->contextualClassPrefix . '-' . 'secondary',
$this->contextualCla... | ContextualClassSetterTrait::setContextualClassSuffix
@param string $suffix
@return static | entailment |
protected function generateBody(array $params, array $columns): void
{
$uniqueColumns = $this->checkUniqueKeys($columns);
$limit = ($uniqueColumns==null);
$this->codeStore->append(sprintf('delete from %s', $this->tableName));
$this->codeStore->append('where');
$first = true;
foreach ... | Generate body part.
@param array[] $columns Columns from table.
@param array[] $params Params for where block. | entailment |
public function createHelp($text = null, $tagName = 'span')
{
$help = new Group\Help($tagName);
if (isset($text)) {
$help->textContent->push($text);
}
$this->childNodes->push($help);
return $this->help = $this->childNodes->last();
} | Group::createHelp
@param string|null $text
@param string $tagName
@return \O2System\Framework\Libraries\Ui\Components\Form\Group\Help | entailment |
public function render()
{
if ($this->help instanceof Group\Help) {
foreach ($this->childNodes as $childNode) {
if ($childNode instanceof Elements\Input or
$childNode instanceof Elements\Checkbox or
$childNode instanceof Elements\Select or
... | Group::render
@return string | entailment |
public function createTokenResponse(
ServerRequestInterface $request,
Client $client = null,
TokenOwnerInterface $owner = null
): ResponseInterface {
$postParams = $request->getParsedBody();
$refreshToken = $postParams['refresh_token'] ?? null;
if (null === $refresh... | {@inheritdoc} | entailment |
protected function connect(array $settings): void
{
$host = $this->getSetting($settings, true, 'database', 'host');
$user = $this->getSetting($settings, true, 'database', 'user');
$password = $this->getSetting($settings, true, 'database', 'password');
$database = $this->getSetting($settings, t... | Connects to a MySQL instance.
@param array $settings The settings from the configuration file. | entailment |
public static function createNewAccessToken(
int $ttl,
TokenOwnerInterface $owner = null,
Client $client = null,
$scopes = null
): AccessToken {
return static::createNew($ttl, $owner, $client, $scopes);
} | Create a new AccessToken
@param string|string[]|Scope[]|null $scopes | entailment |
public function createCard($contextualClass = Card::DEFAULT_CONTEXT, $inverse = false)
{
$card = new Card($contextualClass, $inverse);
$this->childNodes->push($card);
return $this->childNodes->last();
} | Group::createCard
@param string $contextualClass
@param bool $inverse
@return Card | entailment |
public function createInput(array $attributes = [])
{
$field = new Form\Elements\Input();
if (count($attributes)) {
foreach ($attributes as $name => $value) {
$field->attributes->addAttribute($name, $value);
if ($name === 'name') {
$t... | Group::createInput
@param array $attributes
@return \O2System\Framework\Libraries\Ui\Components\Form\Elements\Input | entailment |
public function createSelect(array $options = [], $selected = null, array $attributes = [])
{
$field = new Form\Elements\Select();
if (count($options)) {
$field->createOptions($options, $selected);
}
if (count($attributes)) {
foreach ($attributes as $name =>... | Group::createSelect
@param array $options
@param string|null $selected
@param array $attributes
@return \O2System\Framework\Libraries\Ui\Components\Form\Elements\Select | entailment |
public function createAddon($node = null, $position = Group\AddOn::ADDON_LEFT)
{
$addOn = new Group\AddOn($position);
if (isset($node)) {
if ($node instanceof Element) {
$addOn->childNodes->push($node);
} else {
$addOn->textContent->push($node... | Group::createAddon
@param Element|string|null $node
@param int $position
@return mixed | entailment |
public function render()
{
$addOnsLeft = [];
$addOnsRight = [];
if ($this->addOns->count()) {
foreach ($this->addOns as $addOn) {
if ($addOn->position === Group\AddOn::ADDON_LEFT) {
$addOnsLeft[] = $addOn;
} else {
... | Group::render
@return string | entailment |
public function floatLeft($size = null)
{
if (empty($size)) {
$this->attributes->addAttributeClass('float-left');
} elseif (in_array($size, ['xs', 'sm', 'md', 'lg', 'xl'])) {
$this->attributes->addAttributeClass('float-' . $size . '-left');
}
return $this;
... | FloatUtilitiesTrait::floatLeft
@param string|null $size
@return static | entailment |
public function floatRight($size = null)
{
if (empty($size)) {
$this->attributes->addAttributeClass('float-right');
} elseif (in_array($size, ['xs', 'sm', 'md', 'lg', 'xl'])) {
$this->attributes->addAttributeClass('float-' . $size . '-right');
}
return $this;... | FloatUtilitiesTrait::floatRight
@param string|null $size
@return static | entailment |
public function floatNone($size = null)
{
if (empty($size)) {
$this->attributes->addAttributeClass('float-none');
} elseif (in_array($size, ['xs', 'sm', 'md', 'lg', 'xl'])) {
$this->attributes->addAttributeClass('float-' . $size . '-none');
}
return $this;
... | FloatUtilitiesTrait::floatNone
@param string|null $size
@return static | entailment |
public function createHeader($text, $tagName = 'h6')
{
$header = new Element($tagName);
$header->attributes->addAttributeClass('dropdown-header');
$header->textContent->push($text);
$this->childNodes->push($header);
return $this->childNodes->last();
} | Menu::createHeader
@param string $text
@param string $tagName
@return Element | entailment |
public function createItem($label = null, $href = null)
{
$link = new Link($label, $href);
$link->attributes->addAttributeClass('dropdown-item');
$this->childNodes->push($link);
return $this->childNodes->last();
} | Menu::createItem
@param string|null $label
@param string|null $href
@return Link | entailment |
public function createDivider()
{
$element = new Element('div');
$element->attributes->addAttributeClass('dropdown-divider');
$this->childNodes->push($element);
return $this->childNodes->last();
} | Menu::createDivider
@return Element | entailment |
public function map(array $options, Banner $banner)
{
$bannerOptions = get_object_vars($banner);
$validatedOptions = array();
foreach ($bannerOptions as $name => $value) {
$validatedOptions[$name] = empty($options[$name]) ? $value : $options[$name];
}
return $va... | Map additional options used by Banner object.
@param array $options
@param \EzSystems\PrivacyCookieBundle\Banner\Banner $banner
@return array | entailment |
private function registerApiMiddleware()
{
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $this->app['config'];
foreach ($config->get('api-helper.middleware', []) as $name => $class) {
$this->aliasMiddleware($name, $class);
};
} | Register the API route Middleware. | entailment |
public function &__get($property)
{
$get[ $property ] = false;
// CodeIgniter property aliasing
if ($property === 'load') {
$property = 'loader';
}
if (services()->has($property)) {
return services()->get($property);
} elseif (o2system()->__i... | Commander::__get
@param string $property
@return mixed|\O2System\Framework\Containers\Models|\O2System\Framework\Models\NoSql\Model|\O2System\Framework\Models\Sql\Model | entailment |
public function getResult()
{
if ($this->map->currentModel->row instanceof Sql\DataObjects\Result\Row) {
$criteria = $this->map->currentModel->row->offsetGet($this->map->currentForeignKey);
$field = $this->map->referenceTable . '.' . $this->map->referencePrimaryKey;
if (... | BelongsTo::getResult
@return array|bool|\O2System\Framework\Models\Sql\DataObjects\Result\Row | entailment |
protected function prepareTokenResponse(
AccessToken $accessToken,
RefreshToken $refreshToken = null,
bool $useRefreshTokenScopes = false
): ResponseInterface {
$owner = $accessToken->getOwner();
$scopes = $useRefreshTokenScopes ? $refreshToken->getScopes() : $accessToken->ge... | Prepare the actual HttpResponse for the token | entailment |
protected static function parseButton(ButtonInterface $button, array $args) {
$button->setActive(ArrayHelper::get($args, "active", false));
$button->setBlock(ArrayHelper::get($args, "block", false));
$button->setContent(ArrayHelper::get($args, "content"));
$button->setDisabled(ArrayHelp... | Parses a button.
@param ButtonInterface $button The button.
@param array $args The arguments.
@return ButtonInterface Returns the button. | entailment |
public function setName($name)
{
$xName = explode(' ', $name);
$firstName = $xName[ 0 ];
array_shift($xName);
$lastName = implode(' ', $xName);
$this->setObject('first_name', $firstName);
$this->setObject('last_name', $lastName);
return $this;
} | Profile::setName
@param string $name
@return static | entailment |
public function setGender($gender)
{
$gender = strtolower($gender);
if (in_array($gender, ['male', 'female'])) {
$this->setObject('gender', $gender);
}
return $this;
} | Profile::setGender
@param string $gender
@return static | entailment |
public function execute()
{
parent::execute();
if (empty($this->optionFilename)) {
output()->write(
(new Format())
->setContextualClass(Format::DANGER)
->setString(language()->getLine('CLI_MAKE_WIDGET_E_NAME'))
... | Widget::execute | entailment |
final protected function fetchSubModels()
{
$reflection = new \ReflectionClass(get_called_class());
// Define called model class filepath
$filePath = $reflection->getFileName();
// Define filename for used as subdirectory name
$filename = pathinfo($filePath, PATHINFO_FILENA... | AbstractModel::fetchSubModels
@access protected
@final this method cannot be overwritten.
@return void
@throws \ReflectionException | entailment |
final protected function hasSubModel($model)
{
if (array_key_exists($model, $this->validSubModels)) {
return (bool)is_file($this->validSubModels[ $model ]);
}
return false;
} | ------------------------------------------------------------------------ | entailment |
public function createInput(array $attributes = [])
{
$field = new Components\Form\Elements\Input();
if (count($attributes)) {
foreach ($attributes as $name => $value) {
$field->attributes->addAttribute($name, $value);
if ($name === 'name') {
... | Form::createInput
@param array $attributes
@return Components\Form\Elements\Input | entailment |
public function createButton($label, array $attributes = [])
{
$button = new Components\Form\Elements\Button($label);
if ( ! array_key_exists('class', $attributes)) {
$button->attributes->addAttributeClass(['btn', 'my-2', 'my-sm-0']);
}
if (count($attributes)) {
... | From::createButton
@param string $label
@param array $attributes
@return Components\Form\Elements\Button | entailment |
protected function getSyntaxHighlighterConfig() {
$provider = $this->get(SyntaxHighlighterStringsProvider::SERVICE_NAME);
$config = new SyntaxHighlighterConfig();
$config->setStrings($provider->getSyntaxHighlighterStrings());
return $config;
} | Get the Syntax Highlighter config.
@return SyntaxHighlighterConfig Returns the SyntaxHighlighter config. | entailment |
public static function renderType(ButtonInterface $button) {
return null !== $button->getType() ? $button->getPrefix() . $button->getType() : null;
} | Render a type.
@param ButtonInterface $button The button.
@return string|null Returns the rendered type. | entailment |
public static function setup_theme() {
global $pagenow;
if ( ( is_admin() && 'themes.php' == $pagenow ) || ! self::can_switch_themes() ) {
return;
}
self::check_reset();
self::load_cookie();
if ( empty( self::$theme ) ) {
return;
}
add_filter( 'pre_option_template', array( self::$theme, 'get_... | Loads cookie and sets up theme filters. | entailment |
public static function check_reset() {
if ( ! empty( filter_input( INPUT_GET, 'tts_reset' ) ) ) {
setcookie( self::get_cookie_name(), '', 1 );
nocache_headers();
wp_safe_redirect( home_url() );
die;
}
} | Clear theme choice if reset variable is present in request. | entailment |
public static function load_cookie() {
$theme_name = filter_input( INPUT_COOKIE, self::get_cookie_name() );
if ( ! $theme_name ) {
return;
}
$theme = wp_get_theme( $theme_name );
if (
$theme->exists()
&& $theme->get( 'Name' ) !== get_option( 'current_theme' )
&& $theme->is_allowed()
) {
... | Sets if cookie is defined to non-default theme. | entailment |
public static function get_allowed_themes() {
static $themes;
if ( isset( $themes ) ) {
return $themes;
}
$wp_themes = wp_get_themes( array( 'allowed' => true ) );
/** @var WP_Theme $theme */
foreach ( $wp_themes as $theme ) {
// Make keys names (rather than slugs) for backwards compat.
$theme... | Retrieves allowed themes.
@return WP_Theme[] | entailment |
public static function init() {
if ( self::can_switch_themes() ) {
add_action( 'admin_bar_menu', array( __CLASS__, 'admin_bar_menu' ), 90 );
add_action( 'wp_ajax_tts_set_theme', array( __CLASS__, 'set_theme' ) );
}
load_plugin_textdomain( 'toolbar-theme-switcher', false, dirname( dirname( plugin_basename(... | Sets up hooks that doesn't need to happen early. | entailment |
public static function admin_bar_menu( $wp_admin_bar ) {
$themes = self::get_allowed_themes();
$current = empty( self::$theme ) ? wp_get_theme() : self::$theme;
unset( $themes[ $current->get( 'Name' ) ] );
uksort( $themes, array( __CLASS__, 'sort_core_themes' ) );
$title = apply_filters( 'tts_root_title', s... | Creates menu in toolbar.
@param WP_Admin_Bar $wp_admin_bar Admin bar instance. | entailment |
public static function sort_core_themes( $theme_a, $theme_b ) {
static $twenties = array(
'Twenty Ten',
'Twenty Eleven',
'Twenty Twelve',
'Twenty Thirteen',
'Twenty Fourteen',
'Twenty Fifteen',
'Twenty Sixteen',
'Twenty Seventeen',
'Twenty Eighteen',
'Twenty Nineteen',
'Twenty Twenty... | Callback to sort theme array with core themes in numerical order by year.
@param string $theme_a First theme name.
@param string $theme_b Second theme name.
@return int | entailment |
public static function set_theme() {
$stylesheet = filter_input( INPUT_GET, 'theme' );
$theme = wp_get_theme( $stylesheet );
if ( $theme->exists() && $theme->is_allowed() ) {
setcookie( self::get_cookie_name(), $theme->get_stylesheet(), strtotime( '+1 year' ), COOKIEPATH );
}
wp_safe_redirect( wp_g... | Saves selected theme in cookie if valid. | entailment |
public static function get_theme_field( $field_name, $default = false ) {
if ( ! empty( self::$theme ) ) {
return self::$theme->get( $field_name );
}
return $default;
} | Returns field from theme data if cookie is set to valid theme.
@param string $field_name
@param mixed $default
@deprecated :2.0
@return mixed | entailment |
public function render()
{
if ($this->attributes->hasAttribute('class') === false) {
$this->attributes->addAttributeClass('col');
}
return parent::render();
} | Column::render
@return string | entailment |
public function getGrant(string $grantType): GrantInterface
{
if ($this->hasGrant($grantType)) {
return $this->grants[$grantType];
}
// If we reach here... then no grant was found. Not good!
throw OAuth2Exception::unsupportedGrantType(sprintf(
'Grant type "%s... | Get the grant by its name
@throws OAuth2Exception (unsupported_grant_type) When grant type is not registered | entailment |
public function getResponseType(string $responseType): GrantInterface
{
if ($this->hasResponseType($responseType)) {
return $this->responseTypes[$responseType];
}
// If we reach here... then no grant was found. Not good!
throw OAuth2Exception::unsupportedResponseType(spr... | Get the response type by its name
@throws OAuth2Exception (unsupported_grant_type) When response type is not registered | entailment |
private function getClient(ServerRequestInterface $request, bool $allowPublicClients)
{
list($id, $secret) = $this->extractClientCredentials($request);
// If the grant type we are issuing does not allow public clients, and that the secret is
// missing, then we have an error...
if (... | Get the client (after authenticating it)
According to the spec (http://tools.ietf.org/html/rfc6749#section-2.3), for public clients we do
not need to authenticate them
@return Client|null
@throws OAuth2Exception (invalid_client) When a client secret is missing or client authentication failed | entailment |
private function createResponseFromOAuthException(OAuth2Exception $exception): ResponseInterface
{
$payload = [
'error' => $exception->getCode(),
'error_description' => $exception->getMessage(),
];
return new Response\JsonResponse($payload, 400);
} | Create a response from the exception, using the format of the spec
@link http://tools.ietf.org/html/rfc6749#section-5.2 | entailment |
private function extractClientCredentials(ServerRequestInterface $request): array
{
// We first try to get the Authorization header, as this is the recommended way according to the spec
if ($request->hasHeader('Authorization')) {
// The value is "Basic xxx", we are interested in the last... | Extract the client credentials from Authorization header or POST data | entailment |
public function createToken($owner, $client, array $scopes = []): AccessToken
{
if (empty($scopes)) {
$scopes = $this->scopeService->getDefaultScopes();
} else {
$this->validateTokenScopes($scopes);
}
do {
$token = AccessToken::createNewAccessToke... | Create a new token (and generate the token)
@param TokenOwnerInterface $owner
@param Client $client
@param string[]|Scope[] $scopes
@return AccessToken
@throws OAuth2Exception | entailment |
protected function bootstrapGrid($lg, $md, $sm, $xs, $recopy, $prefix) {
$found = null;
$values = [&$lg, &$md, &$sm, &$xs];
foreach ($values as &$current) {
if (1 <= $current && $current <= 12) {
$found = $current;
}
if (null === $current &&... | Displays a Bootstrap grid.
@param string $lg The large column size.
@param string $md The medium column size.
@param string $sm The small column size.
@param string $xs The extra-small column size.
@param string $recopy Recopy ?
@param string $prefix The column prefix.
@return string Returns the Bootstrap grid. | entailment |
public function execute()
{
$options = input()->get();
if (empty($options)) {
$_GET[ 'host' ] = 'localhost';
$_GET[ 'port' ] = 8000;
}
parent::execute();
output()->write(
(new Format())
->setContextualClass(Format::SUCCES... | Serve::execute | entailment |
public function getDigitalOcean($file = self::DEFAULT_CREDENTIALS_FILE)
{
if (!file_exists($file)) {
throw new \RuntimeException(sprintf('Impossible to get credentials informations in %s', $file));
}
$credentials = Yaml::parse($file);
return new DigitalOcean(new Credent... | Returns an instance of DigitalOcean
@param string $file The file with credentials.
@return DigitalOcean An instance of DigitalOcean
@throws \RuntimeException | entailment |
private static function getLeadingDir(string $pattern): string
{
$dir = $pattern;
$pos = strpos($dir, '*');
if ($pos!==false) $dir = substr($dir, 0, $pos);
$pos = strpos($dir, '?');
if ($pos!==false) $dir = substr($dir, 0, $pos);
$pos = strrpos($dir, '/');
if ($pos!==false)
{
... | Returns the leading directory without wild cards of a pattern.
@param string $pattern The pattern.
@return string | entailment |
public function findSources(string $sources): array
{
$patterns = $this->sourcesToPatterns($sources);
$sources = [];
foreach ($patterns as $pattern)
{
$tmp = $this->findSourcesInPattern($pattern);
$sources = array_merge($sources, $tmp);
}
$sources = array_unique($sources);
... | Finds sources of stored routines.
@param string $sources The value of the sources parameter.
@return string[] | entailment |
private function findSourcesInPattern(string $pattern): array
{
$sources = [];
$directory = new RecursiveDirectoryIterator(self::getLeadingDir($pattern));
$directory->setFlags(RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
$files = new RecursiveIteratorIterator($directory);
foreach ($files as $ful... | Finds sources of stored routines in a pattern.
@param string $pattern The pattern of the sources.
@return string[] | entailment |
private function readPatterns(string $filename): array
{
$path = $this->basedir.'/'.$filename;
$lines = explode(PHP_EOL, file_get_contents($path));
$patterns = [];
foreach ($lines as $line)
{
$line = trim($line);
if ($line<>'')
{
$patterns[] = $line;
}
}
... | Reads a list of patterns from a file.
@param string $filename The name of the file with a list of patterns.
@return string[] | entailment |
private function sourcesToPatterns(string $sources): array
{
if (substr($sources, 0, 5)=='file:')
{
$patterns = $this->readPatterns(substr($sources, 5));
}
else
{
$patterns = [$sources];
}
return $patterns;
} | Converts the sources parameter to a list a patterns.
@param string $sources The value of the sources parameter.
@return string[] | entailment |
protected function bootstrapButtonGroup($class, $role, array $buttons) {
$attributes = [];
$attributes["class"] = $class;
$attributes["role"] = $role;
$innerHTML = "\n" . implode("\n", $buttons) . "\n";
return static::coreHTMLElement("div", $innerHTML, $attributes);
} | Displays a Bootstrap button group.
@param string $class The class.
@param string $role The role.
@param array $buttons The buttons.
@return string Returns the Bootstrap button group. | entailment |
public static function createNewAuthorizationCode(
int $ttl,
string $redirectUri = null,
TokenOwnerInterface $owner = null,
Client $client = null,
$scopes = null
): AuthorizationCode {
$token = static::createNew($ttl, $owner, $client, $scopes);
$token->redire... | Create a new AuthorizationCode
@param int $ttl
@param string $redirectUri
@param TokenOwnerInterface $owner
@param Client $client
@param string|string[]|Scope[]|null $scopes
@return AuthorizationCode | entailment |
public function &__get($property)
{
$get[ $property ] = false;
if (property_exists($this, $property)) {
return $this->{$property};
}
return $get[ $property ];
} | View::__get
@param string $property
@return bool Returns FALSE when property is not set. | entailment |
public function with($vars, $value = null)
{
if (is_string($vars)) {
$vars = [$vars => $value];
}
presenter()->merge($vars);
return $this;
} | View::with
@param mixed $vars
@param mixed $value
@return static | entailment |
public function modal($filename, array $vars = [])
{
if (presenter()->theme->hasLayout('modal')) {
if (presenter()->theme->hasLayout('modal')) {
presenter()->theme->setLayout('modal');
echo $this->load($filename, $vars, true);
exit(EXIT_SUCCESS);
... | View::modal
@param string $filename
@param array $vars | entailment |
public function load($filename, array $vars = [], $return = false)
{
if ($filename instanceof \SplFileInfo) {
return $this->page($filename->getRealPath(), array_merge($vars, $filename->getVars()));
}
if (strpos($filename, 'Pages') !== false) {
return $this->page($fil... | View::load
@param string $filename
@param array $vars
@param bool $return
@return false|string | entailment |
public function page($filename, array $vars = [], $return = false)
{
if ( ! is_file($filename)) {
$pageDirectories = modules()->getResourcesDirs('pages');
foreach ($pageDirectories as $pageDirectory) {
if (is_file($pageFilePath = $pageDirectory . $filename . '.phtml')... | View::page
@param string $filename
@param array $vars
@param bool $return
@return bool|string Returns FALSE if failed. | entailment |
public function getFilePath($filename)
{
$filename = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $filename);
if (is_file($filename)) {
return realpath($filename);
} else {
$viewsDirectories = array_merge([
PATH_KERNEL . 'Views' . DIRECTORY_SEPARATOR... | View::getFilePath
@param string $filename
@return bool|string | entailment |
public function render(array $options = [])
{
if (profiler() !== false) {
profiler()->watch('Starting View Rendering');
}
parser()->loadVars(presenter()->getArrayCopy());
if (presenter()->page->file instanceof \SplFileInfo) {
if (false === ($pagePresets = p... | View::render
@param array $options
@return string | entailment |
public static function getCSSClassname($size, $value, $suffix, $min = 1, $max = 12) {
if ($value < $min || $max < $value) {
return null;
}
$sizes = ["lg", "md", "sm", "xs"];
$suffixes = ["offset", "pull", "push", ""];
if (false === in_array($size, $sizes) || fal... | Get a CSS classname.
@param string $size The size.
@param int $value The value.
@param string $suffix The suffix.
@param int $min The min value.
@param int $max The max value.
@return string|null Returns the CSS classname. | entailment |
public static function getInstance() {
if (is_null(self::$_instance)) {
$id_cache = is_memcache_available() ? new Memcache() : new FileCache();
self::$_instance = new self($id_cache);
}
return self::$_instance;
} | Returns a singleton
@return self | entailment |
public function getGuidFromRiverId($river_id = 0) {
$river_id = (int) $river_id;
$guid = $this->id_cache->get($river_id);
if ($guid) {
return $guid;
}
$objects = elgg_get_entities_from_metadata([
'types' => RiverObject::TYPE,
'subtypes' => [RiverObject::SUBTYPE, 'hjstream'],
'metadata_name_valu... | Return value of the entity guid that corresponds to river_id
@param int $river_id River item ID
@return int|false | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.