sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function transfert($imageId, array $parameters) { if (!array_key_exists('region_id', $parameters) || !is_int($parameters['region_id'])) { throw new \InvalidArgumentException('You need to provide an integer "region_id".'); } return $this->processQuery($this->buildQuery($im...
Transferts a specific image to a specified region. The region_id key is required. @param integer $imageId The id of the image. @param array $parameters An array of parameters. @return StdClass @throws \InvalidArgumentException
entailment
public function route() { $segments = server_request()->getUri()->getSegments()->getParts(); array_shift($segments); $download = false; if (false !== ($key = array_search('download', $segments))) { $download = true; unset($segments[ $key ]); $segm...
Resources::route
entailment
public function createTitle($title) { $item = $this->list->createList($title); $item->attributes->addAttributeClass('menu-title'); return $item; }
Menu::createTitle @param string $title @return \O2System\Framework\Libraries\Ui\Contents\Lists\Item
entailment
protected function whenLoaded($relationship) { return $this->resource->relationLoaded($relationship) ? $this->resource->{$relationship} : new MissingValue; }
Retrieve a relationship if it has been loaded. @param string $relationship @return \Illuminate\Http\Resources\MissingValue|mixed
entailment
protected function whenPivotLoaded($table, $value, $default = null) { if (func_num_args() === 2) $default = new MissingValue; return $this->when( $this->pivot && ($this->pivot instanceof $table || $this->pivot->getTable() === $table), ...[$value, $default] ...
Execute a callback if the given pivot table has been loaded. @param string $table @param mixed $value @param mixed $default @return \Illuminate\Http\Resources\MissingValue|mixed
entailment
public function resolve($request = null) { $request = $request ?: Container::getInstance()->make('request'); if ($this->resource instanceof Collection) $data = $this->resolveCollection($this->resource, $request); elseif ($this->resource instanceof AbstractPaginator) ...
Resolve the resource to an array. @param \Illuminate\Http\Request|null $request @return array
entailment
protected function resolveNestedRelations($data, $request) { foreach ($data as $key => $value) { if (is_array($value)) { $data[$key] = $this->resolveNestedRelations($value, $request); } elseif ($value instanceof static) { $data[$key] = $val...
Resolve the nested resources to an array. @param array $data @param \Illuminate\Http\Request $request @return array
entailment
public function resolveCollection($collection, $request = null) { return $collection->map(function ($item) use ($request) { return (new static($item))->toArray($request); })->all(); }
Resolve the resource to an array. @param \Illuminate\Support\Collection $collection @param \Illuminate\Http\Request|null $request @return array
entailment
public function toResponse($request) { return ( $this->resource instanceof AbstractPaginator ? new PaginatedResourceResponse($this) : new ResourceResponse($this) )->toResponse($request); }
Create an HTTP response that represents the object. @param \Illuminate\Http\Request $request @return \Illuminate\Http\Response|mixed
entailment
protected function when($condition, $value, $default = null) { return $condition ? value($value) : (func_num_args() === 3 ? value($default) : new MissingValue); }
Retrieve a value based on a given condition. @param bool $condition @param mixed $value @param mixed $default @return \Illuminate\Http\Resources\MissingValue|mixed
entailment
protected function filter($data) { $index = -1; foreach ($data as $key => $value) { $index++; if (is_array($value)) { $data[$key] = $this->filter($value); continue; } if (is_numeric($key) && $value instanceof MergeVa...
Filter the given data, removing any optional values. @param array $data @return array
entailment
protected function merge($data, $index, $merge) { if (array_values($data) === $data) { return array_merge( array_merge(array_slice($data, 0, $index, true), $merge), $this->filter(array_slice($data, $index + 1, null, true)) ); } return ...
Merge the given data in at the given index. @param array $data @param int $index @param array $merge @return array
entailment
public function autoload($assets) { foreach ($assets as $position => $collections) { if (property_exists($this, $position)) { if ($collections instanceof \ArrayObject) { $collections = $collections->getArrayCopy(); } $this->{$...
Assets::autoload @param array $assets @return void
entailment
public function loadPackages($packages) { foreach ($packages as $package => $files) { if (is_string($files)) { $this->loadPackage($files); } elseif (is_array($files)) { $this->loadPackage($package, $files); } elseif (is_object($files)) { ...
Assets::loadPackages @param array $packages @return void
entailment
public function loadPackage($package, $subPackages = []) { $packageDir = implode(DIRECTORY_SEPARATOR, [ 'packages', $package, ]) . DIRECTORY_SEPARATOR; if (count($subPackages)) { if (array_key_exists('libraries', $subPackages)) { ...
Assets::loadPackage @param string $package @param array $subPackages @return void
entailment
public function loadCss($files) { $files = is_string($files) ? [$files] : $files; $this->head->loadCollections(['css' => $files]); }
Assets::loadCss @param string|array $files @return void
entailment
public function loadJs($files, $position = 'body') { $files = is_string($files) ? [$files] : $files; $this->{$position}->loadCollections(['js' => $files]); }
Assets::loadJs @param string|array $files @param string $position @return void
entailment
public function loadFiles($assets) { foreach ($assets as $type => $item) { $addMethod = 'load' . ucfirst($type); if (method_exists($this, $addMethod)) { call_user_func_array([&$this, $addMethod], [$item]); } } }
Assets::loadFiles @param array $assets @return void
entailment
public function theme($path) { $path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path); if (is_file($filePath = PATH_THEME . $path)) { return path_to_url($filePath); } }
Assets::theme @param string $path @return string
entailment
public function file($file) { $filePaths = loader()->getPublicDirs(true); foreach ($filePaths as $filePath) { if (is_file($filePath . $file)) { return path_to_url($filePath . $file); break; } } }
Assets::file @param string $file @return string
entailment
public function image($image) { $filePaths = loader()->getPublicDirs(true); $image = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $image); foreach ($filePaths as $filePath) { $filePath .= 'img' . DIRECTORY_SEPARATOR; if (is_file($filePath . $image)) { ...
Assets::image @param string $image @return string
entailment
public function media($media) { $filePaths = loader()->getPublicDirs(true); $media = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $media); foreach ($filePaths as $filePath) { $filePath .= 'media' . DIRECTORY_SEPARATOR; if (is_file($filePath . $media)) { ...
Assets::media @param string $media @return string
entailment
public function parseSourceCode($sourceCode) { $sourceCode = str_replace( [ '"../assets/', "'../assets/", "(../assets/", ], [ '"' . base_url() . '/assets/', "'" . base_url() . '/assets/', ...
Assets::parseSourceCode @param string $sourceCode @return string
entailment
public function load($model, $offset = null) { if (is_string($model)) { if (class_exists($model)) { $service = new SplServiceRegistry($model); } } elseif ($model instanceof SplServiceRegistry) { $service = $model; } if (isset($serv...
Models::load @param object|string $model @param string|null $offset
entailment
public function register(SplServiceRegistry $service, $offset = null) { if ($service instanceof SplServiceRegistry) { $offset = isset($offset) ? $offset : camelcase($service->getParameter()); if ($service->isSubclassOf('O2System\Framework\Models\Sql\M...
Models::register @param SplServiceRegistry $service @param string|null $offset
entailment
public function add($model, $offset = null) { if (is_object($model)) { if ( ! $model instanceof SplServiceRegistry) { $model = new SplServiceRegistry($model); } } if (profiler() !== false) { profiler()->watch('Add New Model: ' . $model->ge...
Models::add @param \O2System\Framework\Models\Sql\Model|\O2System\Framework\Models\NoSql\Model|\O2System\Framework\Models\Files\Model $model @param null $offset
entailment
public function autoload($model, $offset = null) { if (isset($offset)) { if ($this->has($offset)) { return $this->get($offset); } // Try to load if (is_string($model)) { if ($this->has($model)) { return $thi...
Models::autoload @param string $model @param string|null $offset @return mixed
entailment
public function onPostBind(FormEvent $event) { $form = $event->getForm(); $request = $this->container->get('request'); if (!$request->request->has(Autocomplete::KEY_PATH)) { return; } $name = $request->request->get(Autocomplete::KEY_PATH); $parts = $this...
Executed on event FormEvents::POST_BIND @param FormEvent $event @throws UnexpectedResponseException to force data to be send to client
entailment
public function createLists(array $lists) { if (count($lists)) { foreach ($lists as $list) { $this->createList($list); } } return $this; }
AbstractList::createLists @param array $lists @return static
entailment
public function createList($list = null) { $node = new Item(); if ($list instanceof Item) { $node = $list; } elseif ($list instanceof Element) { $node->entity->setEntityName($list->entity->getEntityName()); $node->childNodes->push($list); } else {...
AbstractList @param Item|Element|int|string|null $list @return Item
entailment
protected function pushChildNode(Element $node) { if ($node->hasChildNodes()) { if ($node->childNodes->first() instanceof Link) { $parseUrl = parse_url($node->childNodes->first()->getAttributeHref()); $parseUrlQuery = []; if (isset($parseUrl[ 'qu...
AbstractList::pushChildNode @param \O2System\Framework\Libraries\Ui\Element $node
entailment
public function render() { $output[] = $this->open(); if ($this->hasChildNodes()) { if ($this->inline) { $this->attributes->addAttributeClass('list-inline'); } foreach ($this->childNodes as $childNode) { if ($this->inline) { ...
AbstractList::render @return string
entailment
public function items() { return [ 'home' => [ 'title' => trans('dashboard::menus.principal.home'), 'url' => '#home', 'data-scroll' => true ], 'about' => [ 'title' => trans('dashboard::menus.principal.abo...
Specify Items Menu @return string
entailment
public function createTokenResponse( ServerRequestInterface $request, Client $client = null, TokenOwnerInterface $owner = null ): ResponseInterface { $postParams = $request->getParsedBody(); // Everything is okey, we can start tokens generation! $scope = $postParams[...
{@inheritdoc}
entailment
public function register(Application $app) { $app['validator'] = $app->share(function ($app) { if (isset($app['translator'])) { $r = new \ReflectionClass('Symfony\Component\Validator\Validator'); $file = dirname($r->getFilename()).'/Resources/translations/validato...
Registers services on the given app. This method should only be used to configure services and parameters. It should not get services.
entailment
public function getDisplayName() { $name = $this->title; if (!$name) { $owner = $this->getOwnerEntity(); $name = elgg_echo('interactions:comment:subject', array($owner->name)); } return $name; }
{@inheritdoc}
entailment
public function getOriginalContainer() { $container = $this; while ($container instanceof Comment) { $container = $container->getContainerEntity(); } return ($container instanceof Comment) ? $this->getOwnerEntity() : $container; }
Get entity that the original comment was made on in a comment thread @return ElggEntity
entailment
public function getDepthToOriginalContainer() { $depth = 0; $ancestry = $this->getAncestry(); foreach ($ancestry as $a) { $ancestor = get_entity($a); if ($ancestor instanceof self) { $depth++; } } return $depth; }
Get nesting level of this comment @return int
entailment
public function getAncestry() { $ancestry = array(); $container = $this; while ($container instanceof ElggEntity) { array_unshift($ancestry, $container->guid); $container = $container->getContainerEntity(); } return $ancestry; }
Get ancestry @return int[]
entailment
public function getSubscriberFilterOptions(array $options = array()) { $defaults = array( 'type' => 'user', 'relationship' => 'subscribed', 'relationship_guid' => $this->getOriginalContainer()->guid, 'inverse_relationship' => true, ); return array_merge($defaults, $options); }
Returns getter options for comment subscribers @param array $options Additional options @return array
entailment
public function save($update_last_action = true) { $result = false; if (elgg_trigger_before_event('create', 'object', $this)) { $result = parent::save($update_last_action); if ($result) { elgg_trigger_after_event('create', 'object', $this); } } return $result; }
{@inheritdoc}
entailment
public function createBrand($label) { $brand = new Link(); $brand->attributes->addAttributeClass('navbar-brand'); $brand->setAttributeHref(base_url()); if (is_object($label)) { $brand->childNodes->push($label); } else { $brand->textContent->push($labe...
Navbar::createBrand @param string $label @return \O2System\Framework\Libraries\Ui\Contents\Link
entailment
public function createForm() { $this->collapse->childNodes->push(new Navbar\Form()); return $this->form = $this->collapse->childNodes->last(); }
Navbar::createForm @return \O2System\Framework\Libraries\Ui\Components\Navbar\Form
entailment
public function render() { if ($this->nav->childNodes->count() || $this->textContent->count()) { return parent::render(); } return ''; }
Navbar::render @return string
entailment
public function loadRegistry() { if (empty($this->registry)) { $cacheItemPool = cache()->getItemPool('default'); if (cache()->hasItemPool('registry')) { $cacheItemPool = cache()->getItemPool('registry'); } if ($cacheItemPool instanceof CacheI...
Language::loadRegistry Load language registry. @return void @throws \Psr\Cache\InvalidArgumentException
entailment
public function fetchRegistry() { $registry = []; $directory = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator(PATH_ROOT) ); $packagesIterator = new \RegexIterator($directory, '/^.+\.json$/i', \RecursiveRegexIterator::GET_MATCH); foreach ($packag...
Language::fetchRegistry Fetch language registry. @return array
entailment
public function getRegistry($package = null) { if (isset($package)) { if ($this->registered($package)) { return $this->registry[ $package ]; } return false; } return $this->registry; }
Language::getRegistry Gets language registries. @return array
entailment
public function updateRegistry() { if (is_cli()) { output()->verbose( (new Format()) ->setContextualClass(Format::WARNING) ->setString(language()->getLine('CLI_REGISTRY_LANGUAGE_VERB_UPDATE_START')) ->setNewLinesBefore(1...
Language::updateRegistry Update language registry. @return void @throws \Exception
entailment
public function flushRegistry() { $cacheItemPool = cache()->getItemPool('default'); if (cache()->exists('registry')) { $cacheItemPool = cache()->getItemPool('registry'); } if ($cacheItemPool instanceof CacheItemPoolInterface) { $cacheItemPool->deleteItem('o2...
Language::flushRegistry Flush language registry. @return void @throws \Psr\Cache\InvalidArgumentException
entailment
public function setSrc($src) { if (strpos($src, 'holder.js') !== false) { $parts = explode('/', $src); $size = end($parts); $this->attributes->addAttribute('data-src', $src); if ( ! $this->attributes->hasAttribute('alt')) { $this->setAlt($size...
Image::setSrc @param string $src @return static
entailment
public function getResult() { if ($this->map->currentModel->row instanceof Sql\DataObjects\Result\Row) { $criteria = $this->map->currentModel->row->offsetGet($this->map->currentPrimaryKey); $field = $this->map->currentTable . '.' . $this->map->currentPrimaryKey; $this->m...
BelongsToManyThrough::getResult @return array|bool|\O2System\Framework\Models\Sql\DataObjects\Result\Row
entailment
public function bootstrapBreadcrumbsFunction(array $args = [], NavigationTree $tree, Request $request) { NavigationTreeHelper::activeTree($tree, $request); return $this->bootstrapBreadcrumbs($tree); }
Displays a Bootstrap breadcrumbs. @param array $args The arguments. @param NavigationTree $tree The tree. @param Request $request The request. @return string Returns the Bootstrap breadcrumbs.
entailment
public function parseRequest(KernelMessageUri $uri = null) { $this->uri = is_null($uri) ? new KernelMessageUri() : $uri; $uriSegments = $this->uri->getSegments()->getParts(); $uriString = $this->uri->getSegments()->getString(); if ($this->uri->getSegments()->getTotalParts()) { ...
Router::parseRequest @param KernelMessageUri|null $uri @return bool @throws \ReflectionException
entailment
final protected function getPagesControllerClassName() { $modules = modules()->getArrayCopy(); foreach($modules as $module) { $controllerClassName = $module->getNamespace() . 'Controllers\Pages'; if ($module->getNamespace() === 'O2System\Framework\\') { $cont...
Router::getPagesControllerClassName @return bool|string
entailment
final public function registerModule(FrameworkModuleDataStructure $module) { // Push Subdomain App Module modules()->push($module); // Add Config FilePath config()->addFilePath($module->getRealPath()); // Reload Config config()->reload(); // Load modular ad...
Router::registerModule @param FrameworkModuleDataStructure $module
entailment
protected function parseAction(KernelActionDataStructure $action, array $uriSegments = []) { ob_start(); $closure = $action->getClosure(); if (empty($closure)) { $closure = ob_get_contents(); } ob_end_clean(); if ($closure instanceof Controller) { ...
Router::parseAction @param KernelActionDataStructure $action @param array $uriSegments @throws \ReflectionException
entailment
public function bootstrapDropdownButtonFunction(array $args = []) { return $this->bootstrapDropdownButton(ArrayHelper::get($args, "content"), ArrayHelper::get($args, "id"), ArrayHelper::get($args, "expanded", true), ArrayHelper::get($args, "class", "default")); }
Displays a Bootstrap dropdown "Button". @param array $args The arguments. @return string Returns the Bootstrap dropdown "Button".
entailment
public function getProgressBar() : ProgressBar { if (!$this->progressBar) { $this->progressBar = new ProgressBar($this->getOutput(), $this->numRecords); $this->progressBar->setFormat('debug'); $this->progressBar->setBarWidth((int) exec('tput cols')); } re...
Allows to modify the progress bar instance @return ProgressBar
entailment
public function setAuthor($name, $href = null) { $this->author = new Element('small', 'author'); if (isset($href)) { $this->author->childNodes->push(new Link($name, $href)); } else { $this->author->textContent->push($name); } return $this; }
Blockquote::setAuthor @param string $name @param string|null $href @return static
entailment
public function setSource($name, $href = null) { $this->source = new Element('cite', 'source'); if (isset($href)) { $this->source->childNodes->push(new Link($name, $href)); } else { $this->source->textContent->push($name); } return $this; }
Blockquote::setSource @param string $name @param string|null $href @return static
entailment
public function render() { if ($this->paragraph instanceof Element) { $this->childNodes->push($this->paragraph); } $footer = new Element('div', 'footer'); $footer->attributes->addAttributeClass('blockquote-footer'); if ($this->author instanceof Element) { ...
Blockquote::render @return string
entailment
public function createToken($redirectUri, $owner, $client, array $scopes = []): AuthorizationCode { if (empty($scopes)) { $scopes = $this->scopeService->getDefaultScopes(); } else { $this->validateTokenScopes($scopes); } do { $token = Authorizatio...
Create a new token (and generate the token) @param string $redirectUri @param TokenOwnerInterface $owner @param Client $client @param string[]|Scope[] $scopes @return AuthorizationCode @throws OAuth2Exception
entailment
public function hash(string $password): string { $hash = \password_hash($password, $this->algo, $this->options[$this->algo]); return $hash; }
Create password hash from the given string and return it. <pre><code class="php">$password = new Password(); $hash = $password->hash('FooPassword'); //var_dump result //$2y$11$cq3ZWO18l68X7pGs9Y1fveTGcNJ/iyehrDZ10BAvbY8LaBXNvnyk6 var_dump($hash) </code></pre> @param string $password @return string Hashed password.
entailment
public function needsRehash(string $hash): bool { return \password_needs_rehash($hash, $this->algo, $this->options[$this->algo]); }
Checks if the given hash matches the algorithm and the options provided. <pre><code class="php">$password = new Password(); $hash = '$2y$11$cq3ZWO18l68X7pGs9Y1fveTGcNJ/iyehrDZ10BAvbY8LaBXNvnyk6'; //true if rehash is needed, false if no $rehashCheck = $password->needsRehash($hash); </code></pre> @param string $hash ...
entailment
public static function columnTypeToPhpTypeHinting(array $dataTypeInfo): string { switch ($dataTypeInfo['data_type']) { case 'tinyint': case 'smallint': case 'mediumint': case 'int': case 'bigint': case 'year': $phpType = 'int'; break; case 'decimal': ...
Returns the corresponding PHP type hinting of a MySQL column type. @param string[] $dataTypeInfo Metadata of the MySQL data type. @return string
entailment
public static function deriveFieldLength(array $dataTypeInfo): ?int { switch ($dataTypeInfo['data_type']) { case 'tinyint': case 'smallint': case 'mediumint': case 'int': case 'bigint': case 'float': case 'double': $ret = $dataTypeInfo['numeric_precision']; ...
Returns the widths of a field based on a MySQL data type. @param array $dataTypeInfo Metadata of the column on which the field is based. @return int|null
entailment
public static function escapePhpExpression(array $dataTypeInfo, string $expression, bool $lobAsString): string { switch ($dataTypeInfo['data_type']) { case 'tinyint': case 'smallint': case 'mediumint': case 'int': case 'bigint': case 'year': $ret = "'.self::quoteInt...
Returns PHP code escaping the value of a PHP expression that can be safely used when concatenating a SQL statement. @param array $dataTypeInfo Metadata of the column on which the field is based. @param string $expression The PHP expression. @param bool $lobAsString A flag indication LOBs must be treated as strin...
entailment
public static function getBindVariableType(array $dataTypeInfo, bool $lobAsString): string { $ret = ''; switch ($dataTypeInfo['data_type']) { case 'tinyint': case 'smallint': case 'mediumint': case 'int': case 'bigint': case 'year': $ret = 'i'; break; ...
Returns the type of a bind variable. @see http://php.net/manual/en/mysqli-stmt.bind-param.php @param array $dataTypeInfo Metadata of the column on which the field is based. @param bool $lobAsString A flag indication LOBs must be treated as strings. @return string
entailment
public static function isBlobParameter(string $dataType): bool { switch ($dataType) { case 'tinytext': case 'text': case 'mediumtext': case 'longtext': case 'tinyblob': case 'blob': case 'mediumblob': case 'longblob': $isBlob = true; break; ...
Returns true if one if a MySQL column type is a BLOB or a CLOB. @param string $dataType Metadata of the MySQL data type. @return bool
entailment
public static function phpTypeHintingToPhpTypeDeclaration(string $phpTypeHint): string { $phpType = ''; switch ($phpTypeHint) { case 'array': case 'array[]': case 'bool': case 'float': case 'int': case 'string': case 'void': $phpType = $phpTypeHint; ...
Returns the corresponding PHP type declaration of a MySQL column type. @param string $phpTypeHint The PHP type hinting. @return string
entailment
public function handle(ServerRequestInterface $request) { if (cache()->hasItem('maintenance')) { $maintenanceInfo = cache()->getItem('maintenance')->get(); echo view()->load('maintenance', $maintenanceInfo, true); exit(EXIT_SUCCESS); } }
Maintenance::handle Handles a request and produces a response May call other collaborating code to generate the response. @param \O2System\Psr\Http\Message\ServerRequestInterface $request
entailment
private function match(string $path, string $suffix): bool { return substr($path, -strlen($suffix)) === $suffix; }
Match transformer for the suffix? (.json?)
entailment
public function render() { $output[] = $this->open(); if ($this->hasChildNodes()) { $output[] = implode(PHP_EOL, $this->childNodes->getArrayCopy()); } return implode(PHP_EOL, $output); }
Image::render @return string
entailment
public function getFilePath($filename) { if (modules()) { $filePaths = modules()->getDirs('Views'); } else { $filePaths = array_reverse($this->filePaths); } foreach ($filePaths as $filePath) { if (is_file($filePath . $filename . '.phtml')) { ...
Output::getFilePath @param string $filename @return string
entailment
public function errorHandler($errorSeverity, $errorMessage, $errorFile, $errorLine, $errorContext = []) { $isFatalError = (((E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $errorSeverity) === $errorSeverity); if (strpos($errorFile, 'parser') !== false) { if (function_exists(...
Output::errorHandler Kernel defined error handler function. @param int $errorSeverity The first parameter, errno, contains the level of the error raised, as an integer. @param string $errorMessage The second parameter, errstr, contains the error message, as a string. @param string $errorFile The third paramet...
entailment
public function sendError($code = 204, $vars = null, $headers = []) { $languageKey = $code . '_' . error_code_string($code); $error = [ 'code' => $code, 'title' => language()->getLine($languageKey . '_TITLE'), 'message' => language()->getLine($languageKey . ...
Output::sendError @param int $code @param null|array|string $vars @param array $headers
entailment
public function createToken($owner, $client, array $scopes = []): RefreshToken { if (empty($scopes)) { $scopes = $this->scopeService->getDefaultScopes(); } else { $this->validateTokenScopes($scopes); } do { $token = RefreshToken::createNewRefreshT...
Create a new token (and generate the token) @param TokenOwnerInterface $owner @param Client $client @param string[]|Scope[] $scopes @return RefreshToken @throws OAuth2Exception
entailment
public function handle($request, \Closure $next) { if ($request->expectsJson()) { return $next($request); } return json_response()->error([ 'message' => 'Invalid AJAX Request', ], $this->code); }
Handle an incoming request. @param \Illuminate\Http\Request $request @param \Closure $next @return mixed
entailment
private function base64Encode($uri) { if (null === $uri) { return null; } $splFileObject = new SplFileObject($uri); if (30100 < Kernel::VERSION_ID) { return (new DataUriNormalizer())->normalize($splFileObject); } $data = ""; while (fals...
Encode an URI into base 64. @param string $uri The URI. @return string Returns the URI encoded into base 64. @throws ExceptionInterface Throws an exception if an error occurs
entailment
public function bootstrapImageBase64Function(array $args = []) { $src = $this->base64Encode(ArrayHelper::get($args, "src")); return $this->bootstrapImage($src, ArrayHelper::get($args, "alt"), ArrayHelper::get($args, "width"), ArrayHelper::get($args, "height"), ArrayHelper::get($args, "class"), ArrayHe...
Displays a Bootstrap image "Base 64". @param array $args The arguments. @return string Returns the Bootstrap base 64 image. @throws ExceptionInterface Throws an exception if an error occurs
entailment
public function handle(ServerRequestInterface $request) { if (null !== ($ssid = input()->get('ssid')) && services()->has('user')) { if (services()->get('user')->validate($ssid)) { set_cookie('ssid', $ssid); echo services()->get('user')->getIframeScript(); ...
Environment::handle Handles a request and produces a response May call other collaborating code to generate the response. @param \O2System\Psr\Http\Message\ServerRequestInterface $request
entailment
public static function begin(): void { $ret = self::$mysqli->autocommit(false); if (!$ret) self::mySqlError('mysqli::autocommit'); }
Starts a transaction. Wrapper around [mysqli::autocommit](http://php.net/manual/mysqli.autocommit.php), however on failure an exception is thrown. @since 1.0.0 @api
entailment
public static function connect(string $host, string $user, string $password, string $database, int $port = 3306): void { self::$mysqli = new \mysqli($host, $user, $password, $database, $port); if (self::$mysqli->connect_errno) { $message = 'MySQL Error no: '.self::$mysqli->connect_errno."\n"; ...
Connects to a MySQL instance. Wrapper around [mysqli::__construct](http://php.net/manual/mysqli.construct.php), however on failure an exception is thrown. @param string $host The hostname. @param string $user The MySQL user name. @param string $password The password. @param string $database The default databa...
entailment
public static function disconnect(): void { if (self::$mysqli!==null) { self::$mysqli->close(); self::$mysqli = null; } }
Closes the connection to the MySQL instance, if connected. @since 1.0.0 @api
entailment
public static function executeBulk(BulkHandler $bulkHandler, string $query): void { self::realQuery($query); $bulkHandler->start(); $result = self::$mysqli->use_result(); while (($row = $result->fetch_assoc())) { $bulkHandler->row($row); } $result->free(); $bulkHandler->stop()...
Executes a query using a bulk handler. @param BulkHandler $bulkHandler The bulk handler. @param string $query The SQL statement. @since 1.0.0 @api
entailment
public static function executeMulti(string $queries): array { $ret = []; self::multiQuery($queries); do { $result = self::$mysqli->store_result(); if (self::$mysqli->errno) self::mySqlError('mysqli::store_result'); if ($result) { if (self::$haveFetchAll) { ...
Executes multiple queries and returns an array with the "result" of each query, i.e. the length of the returned array equals the number of queries. For SELECT, SHOW, DESCRIBE or EXPLAIN queries the "result" is the selected rows (i.e. an array of arrays), for other queries the "result" is the number of effected rows. @...
entailment
public static function executeNone(string $query): int { self::realQuery($query); $n = self::$mysqli->affected_rows; if (self::$mysqli->more_results()) self::$mysqli->next_result(); return $n; }
Executes a query that does not select any rows. @param string $query The SQL statement. @return int The number of affected rows (if any). @since 1.0.0 @api
entailment
public static function executeSingleton0(string $query) { $result = self::query($query); $row = $result->fetch_array(MYSQLI_NUM); $n = $result->num_rows; $result->free(); if (self::$mysqli->more_results()) self::$mysqli->next_result(); if (!($n==0 || $n==1)) { throw new Res...
Executes a query that returns 0 or 1 row with one column. Throws an exception if the query selects 2 or more rows. @param string $query The SQL statement. @return mixed The selected value. @since 1.0.0 @api
entailment
public static function getMaxAllowedPacket(): int { if (!isset(self::$maxAllowedPacket)) { $query = "show variables like 'max_allowed_packet'"; $max_allowed_packet = self::executeRow1($query); self::$maxAllowedPacket = $max_allowed_packet['Value']; // Note: When setting ...
Returns the value of the MySQL variable max_allowed_packet. @return int
entailment
public static function quoteBit(?string $bits): string { if ($bits===null || $bits==='') { return 'null'; } return "b'".self::$mysqli->real_escape_string($bits)."'"; }
Returns a literal for a bit value that can be safely used in SQL statements. @param string|null $bits The bit value. @return string
entailment
public static function quoteDecimal($value): string { if ($value===null || $value==='') return 'null'; if (is_int($value) || is_float($value)) return (string)$value; return "'".self::$mysqli->real_escape_string($value)."'"; }
Returns a literal for a decimal value that can be safely used in SQL statements. @param float|int|string|null $value The value. @return string
entailment
public static function quoteString(?string $value): string { if ($value===null || $value==='') return 'null'; return "'".self::$mysqli->real_escape_string($value)."'"; }
Returns a literal for a string value that can be safely used in SQL statements. @param string|null $value The value. @return string
entailment
protected static function multiQuery(string $queries): void { if (self::$logQueries) { $time0 = microtime(true); $tmp = self::$mysqli->multi_query($queries); if ($tmp===false) { throw new DataLayerException(self::$mysqli->errno, self::$mysqli->error, $queries); } ...
Executes multiple SQL statements. Wrapper around [multi_mysqli::query](http://php.net/manual/mysqli.multi-query.php), however on failure an exception is thrown. @param string $queries The SQL statements. @return void
entailment
protected static function realQuery(string $query): void { if (self::$logQueries) { $time0 = microtime(true); $tmp = self::$mysqli->real_query($query); if ($tmp===false) { throw new DataLayerException(self::$mysqli->errno, self::$mysqli->error, $query); } self::$q...
Execute a query without a result set. Wrapper around [mysqli::real_query](http://php.net/manual/en/mysqli.real-query.php), however on failure an exception is thrown. For SELECT, SHOW, DESCRIBE or EXPLAIN queries, see @query. @param string $query The SQL statement.
entailment
private static function executeTableShowTableColumn(array $column, $value): void { $spaces = str_repeat(' ', $column['length'] - mb_strlen((string)$value)); switch ($column['type']) { case 1: // tinyint case 2: // smallint case 3: // int case 4: // float case 5: // double ...
Helper method for method executeTable. Shows table cell with data. @param array $column The metadata of the column. @param mixed $value The value of the table cell.
entailment
public function setTextContent($textContent) { $this->entity->setEntityName('ribbon-' . $textContent); $this->textContent->push($textContent); return $this; }
Ribbon::setTextContent @param string $textContent @return static
entailment
public function insert(array $sets) { if (count($sets)) { if (method_exists($this, 'insertRecordSets')) { $this->insertRecordSets($sets); } if (method_exists($this, 'beforeInsert')) { $this->beforeInsert($sets); } ...
ModifierTrait::insert @param array $sets @return bool
entailment
public function insertOrUpdate(array $sets) { if ($result = $this->qb->from($this->table)->getWhere($sets)) { return $this->update($sets); } else { return $this->insert($sets); } return false; }
ModifierTrait::insertOrUpdate @param array $sets @return bool
entailment
public function insertMany(array $sets) { if (count($sets)) { if (method_exists($this, 'insertRecordSets')) { foreach ($sets as $set) { $this->insertRecordSets($set); if ($this->recordOrdering === true && empty($sets[ 'record_ordering' ])) ...
ModifierTrait::insertMany @param array $sets @return bool|int
entailment
public function insertIfNotExists(array $sets, array $conditions = []) { if (count($sets)) { if ($result = $this->qb->from($this->table)->getWhere($conditions)) { if ($result->count() == 0) { return $this->insert($sets); } } ...
ModifierTrait::insertIfNotExists @param array $sets @param array $conditions @return bool
entailment