sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function toArray(): array { return [ 'name' => $this->name, 'method' => $this->method, 'url' => $this->url, 'model' => $this->model, 'view' => $this->view, 'controller' => $this->controller, 'action' => $this->action,...
Return route array. @return array
entailment
private function protect(Authentication $authentication, int $httpResponseCode = 403): void { if (($this->authentication = $authentication->isLogged()) === false) { \http_response_code($httpResponseCode); throw new AuthenticationException(''); } }
Allow access to controller class or methods only if logged. Return a status code, useful with AJAX requests. @param Authentication $authentication @param int $httpResponseCode @return void @throws AuthenticationException if not authenticated.
entailment
private function protectWithRedirect(Authentication $authentication, string $location): void { if (($this->authentication = $authentication->isLogged()) === false) { \header('Location: '.$location); throw new AuthenticationException(''); } }
Allow access to controller class or methods only if logged and do a redirection. @param Authentication $authentication @param string $location @return void @throws AuthenticationException
entailment
public function bootstrapFormButtonDefaultFunction(array $args = []) { $cancelButton = $this->bootstrapFormButtonCancelFunction(["href" => ArrayHelper::get($args, "cancel_href")]); $submitButton = $this->bootstrapFormButtonSubmitFunction(); // Return the HTML. return implode(" ", [$can...
Displays a Bootstrap form buttons "default". @param array $args The arguments. @return string Returns the Bootstrap form button "Default".
entailment
public function bootstrapFormButtonSubmitFunction() { $txt = $this->getTranslator()->trans("label.submit", [], "WBWBootstrapBundle"); $but = $this->getButtonTwigExtension()->bootstrapButtonPrimaryFunction(["content" => $txt, "title" => $txt, "icon" => "g:ok"]); return $this->getButtonTwigExten...
Displays a Bootstrap form button "submit". @return string Returns the Bootstrap form button "Submit".
entailment
public function getMultiple(array $keys, $default = null): array { $arrayResult = []; foreach ($keys as $key) { $arrayResult[$key] = $this->get($key, $default); } return $arrayResult; }
Obtains multiple cache items by their unique keys. @param array $keys A list of keys that can obtained in a single operation. @param mixed $default Default value to return for keys that do not exist. @return array A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.
entailment
public function validate(string $requestUri, string $requestMethod): bool { $route = $this->findRoute($this->filterUri($requestUri), $requestMethod); if ($route instanceof Route) { $this->buildValidRoute($route); return true; } $this->buildErrorRoute(); ...
Evaluate request uri. @param string $requestUri @param string $requestMethod @return bool
entailment
private function findRoute(string $uri, string $method): RouteInterface { $matches = []; $route = new NullRoute(); foreach ($this->routes as $value) { $urlMatch = \preg_match('`^'.\preg_replace($this->matchTypes, $this->types, $value->url).'/?$`', $uri, $matches); $m...
Find if provided route match with one of registered routes. @param string $uri @param string $method @return RouteInterface
entailment
private function buildValidRoute(Route $route): void { //add to route array the passed uri for param check when call $matches = $this->routeMatches; //route match and there is a subpattern with action if (\count($matches) > 1) { //assume that subpattern rapresent action ...
Build a valid route. @param Route $route @return void
entailment
private function buildParam(Route $route): array { $param = []; $url = \explode('/', $route->url); $matches = \explode('/', $this->routeMatches[0]); $rawParam = \array_diff($matches, $url); foreach ($rawParam as $key => $value) { $paramName = \strtr($url[$key],...
Try to find parameters in a valid route and return it. @param Route $route @return array
entailment
private function buildErrorRoute(): void { //check if there is a declared route for errors, if no exit with false if (($key = \array_search($this->badRoute, \array_column($this->routes->getArrayCopy(), 'name'), true)) === false) { $this->route = new NullRoute(); return; ...
Actions for error route. @return void
entailment
private function filterUri(string $passedUri): string { //sanitize url $url = \filter_var($passedUri, FILTER_SANITIZE_URL); //check for rewrite mode $url = \str_replace($this->rewriteModeOffRouter, '', $url); //remove basepath $url = \substr($url, \strlen($this->bas...
Analize current uri, sanitize and return it. @param string $passedUri @return string
entailment
public function transform(ApiRequest $request, ApiResponse $response, array $context = []): ApiResponse { if (isset($context['exception'])) { // Convert exception to json $content = Json::encode($this->extractException($request, $response, $context)); if ($context['exception'] instanceof ClientErrorExceptio...
Encode given data for response @param mixed[] $context
entailment
public function start(): void { if (\session_status() !== PHP_SESSION_ACTIVE) { //prepare the session start \session_name($this->name); //start session \session_start([ 'cookie_path' => $this->cookiePath, 'cookie_domain' ...
Start session. @return void
entailment
private function refresh(): void { $time = \time(); if (isset($this->data['time']) && $this->data['time'] <= ($time - $this->expire)) { //delete session data $this->data = []; //regenerate session $this->regenerate(); } $this->setSe...
Refresh session. @return void
entailment
private function setSessionData(int $time): void { $this->id = \session_id(); $this->data['time'] = $time; $this->data['expire'] = $this->expire; $this->status = \session_status(); }
Set Session Data. @param int $time @return void
entailment
public function destroy(): void { //delete session data $this->data = []; $this->id = ''; //destroy cookie \setcookie($this->name, 'NothingToSeeHere.', \time()); //call session destroy \session_destroy(); //update status $this->status = \ses...
Destroy session. @return void
entailment
protected function notifyDanger($content) { $notification = NotificationFactory::newDangerNotification($content); return $this->notify(NotificationEvents::NOTIFICATION_DANGER, $notification); }
Notify "danger". @param string $content The content. @return Event Returns the event.
entailment
protected function notifyInfo($content) { $notification = NotificationFactory::newInfoNotification($content); return $this->notify(NotificationEvents::NOTIFICATION_INFO, $notification); }
Notify "info". @param string $content The content. @return Event Returns the event.
entailment
protected function notifySuccess($content) { $notification = NotificationFactory::newSuccessNotification($content); return $this->notify(NotificationEvents::NOTIFICATION_SUCCESS, $notification); }
Notify "success". @param string $content The content. @return Event Returns the event.
entailment
protected function notifyWarning($content) { $notification = NotificationFactory::newWarningNotification($content); return $this->notify(NotificationEvents::NOTIFICATION_WARNING, $notification); }
Notify "warning". @param string $content The content. @return Event Returns the event.
entailment
public static function getGlyphiconBreadcrumbNodes() { $breadcrumbNodes = []; $breadcrumbNodes[] = new BreadcrumbNode("label.edit_profile", "g:user", "fos_user_profile_edit", NavigationInterface::NAVIGATION_MATCHER_ROUTER); $breadcrumbNodes[] = new BreadcrumbNode("label.show_profile", "g:user"...
Get a FOSUser breadcrumb node with Glyphicon icons. @return BreadcrumbNode[] Returns the FOSUser breadcrumb node.
entailment
public function setPosition($position) { if (in_array($position, [self::ADDON_LEFT, self::ADDON_RIGHT])) { $this->position = $position; } return $this; }
AddOn::setPosition @param $position @return static
entailment
public function render() { if ($this->hasChildNodes()) { if ($this->childNodes->first() instanceof Button) { $this->attributes->removeAttributeClass('input-group-text'); } } return parent::render(); }
AddOn::render @return string
entailment
public static function renderIcon(Environment $twigEnvironment, $name, $style = null) { // Determines the handler. $handler = explode(":", $name); if (1 === count($handler)) { array_unshift($handler, "g"); } if (2 !== count($handler)) { return ""; ...
Render an icon. @param Environment $twigEnvironment The twig environment. @param string $name The icon name. @param string $style The icon style. @return string Returns a rendered icon.
entailment
protected function bootstrapGlyphicon($name, $style) { $attributes = []; $attributes["class"][] = "glyphicon"; $attributes["class"][] = null !== $name ? "glyphicon-" . $name : null; $attributes["aria-hidden"] = "true"; $attributes["style"] = $style; retur...
Displays a Bootstrap glyphicon. @param string $name The name. @return string Returns the Bootstrap glyphicon.
entailment
public function showPrivacyCookieBanner( Twig_Environment $twigEnvironment, $policyPageUrl = null, array $options = array() ) { $options['policyPageUrl'] = $policyPageUrl; return $twigEnvironment->render( 'EzSystemsPrivacyCookieBundle::privacycookie.html.twig', ...
Renders cookie privacy banner snippet code. This helper should be included at the end of template before the body ending tag. @param \Twig_Environment $twigEnvironment @param string $policyPageUrl cookie policy page address (not required, no policy link will be shown) @param array $options override default options @r...
entailment
public function loadFile($filename, $subDir = null) { if (is_file($filename)) { $this->javascripts->append($filename); } else { $extension = pathinfo($filename, PATHINFO_EXTENSION); if (empty($extension)) { if (input()->env('DEBUG_STAGE') === 'PRO...
Body::loadFile @param string $filename @param string|null $subDir @return void
entailment
protected function bootstrapButton(ButtonInterface $button, $icon) { $attributes = []; $attributes["class"] = ["btn", ButtonRenderer::renderType($button)]; $attributes["class"][] = ButtonRenderer::renderBlock($button); $attributes["class"][] = ButtonRenderer::ren...
Displays a Bootstrap button. @param ButtonInterface $button The button. @param string $icon The icon. @return string Returns the Bootstrap button.
entailment
public function register(Application $app) { $app[Service::PASSWORD_HASH] = $app->share(function () use ($app) { return new Service\DefaultPasswordHashService(); }); }
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 stream_close() { if ($this->data == null) { return; } $this->stream_flush(); $this->data = null; $this->path = null; $this->save = false; $this->dirty = null; $this->metadata = array(); }
Close the stream
entailment
protected function bootstrapNavs(array $items, $class, $stacked) { $attributes = []; $attributes["class"][] = "nav"; $attributes["class"][] = $class; $attributes["class"][] = true === $stacked ? "nav-stacked" : null; $innerHTML = []; foreach ($items as $current) { ...
Displays a Bootstrap navs. @param array $items The items. @param string $class The class. @param bool $stacked Stacked ? @return string Returns the Bootstrap nav.
entailment
public function setObject($property, $content) { $property = $this->namespace . ':' . $property; $element = new Element('meta'); $element->attributes[ 'name' ] = $property; $element->attributes[ 'content' ] = (is_array($content) ? implode(', ', $content) : trim($content)); ...
AbstractNamespace::setObject @param string $property @param string $content @return static
entailment
public function createGroup($label) { $group = new Select\Group(); $group->textContent->push($label); $this->childNodes->push($group); return $this->childNodes->last(); }
Select::createGroup @param string $label @return Select\Group
entailment
public function setTitle($text, $tagName = 'h5', array $attributes = []) { $this->dialog->content->header->tagName = $tagName; $this->dialog->content->header->textContent->push($text); if (count($this->attributes)) { foreach ($attributes as $name => $value) { $th...
Modal::setTitle @param string $text @param string $tagName @param array $attributes @return static
entailment
public function register(Application $app) { $app[Validator::LOGIN] = $app->share(function () use ($app) { return new Validator\SymfonyLoginValidator($app['validator']); }); $app[Validator::REGISTRATION] = $app->share(function () use ($app) { return new Validator\Symf...
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 createImage($src, $alt = null) { return $this->image = new Card\Image($src, $alt); }
Card::createImage @param string $src @param string|null $alt @return \O2System\Framework\Libraries\Ui\Components\Card\Image
entailment
public function createRibbon( $ribbon, $contextualClass = Card\Ribbon::DEFAULT_CONTEXT, $position = Card\Ribbon::LEFT_RIBBON ) { if ($ribbon instanceof Card\Ribbon) { $ribbon->position = $position; } elseif (is_string($ribbon)) { $ribbon = new Card\Rib...
Card::createRibbon @param Card\Ribbon|string $ribbon @param string $contextualClass @param int $position @return Card\Ribbon
entailment
public function createHeader() { $this->childNodes->prepend(new Card\Header()); return $this->header = $this->childNodes->first(); }
Card::createHeader @return Card\Header
entailment
public function createBody() { $this->childNodes->push(new Card\Body()); return $this->body = $this->childNodes->last(); }
Card::createBody @return Card\Body
entailment
public function createFooter() { $this->childNodes->push(new Card\Footer()); return $this->footer = $this->childNodes->last(); }
Card::createFooter @return Card\Footer
entailment
public function render() { $output[] = $this->open(); // Render header and image if ($this->header->hasTextContent() || $this->header->hasChildNodes()) { $output[] = $this->header; if ($this->image instanceof Card\Image || $this->image instanceof Card...
Card::render @return string
entailment
public function getResource(): object { return new ExtendedPDO( $this->options['dsn'], $this->options['user'], $this->options['password'], $this->options['options'] ); }
Get Resource. @return object
entailment
private function askForCreateSP(string $spType, string $tableName): void { $question = sprintf('Create SP for <dbo>%s</dbo> ? (default Yes): ', $spType); $question = new ConfirmationQuestion($question, true); if ($this->helper->ask($this->input, $this->output, $question)) { $defaultSpName = strt...
Asking function for create or not stored procedure. @param string $spType Stored procedure type {insert|update|delete|select}. @param string $tableName The table name.
entailment
private function generateSP(string $tableName, string $spType, string $spName): string { switch ($spType) { case 'UPDATE': $routine = new UpdateRoutine($this->input, $this->output, $this->helper, ...
Generate code for stored routine. @param string $tableName The table name. @param string $spType Stored routine type {insert|update|delete|select}. @param string $spName Stored routine name. @return string
entailment
private function printAllTables(array $tableList): void { if ($this->input->getOption('tables')) { $tableData = array_chunk($tableList, 4); $array = []; foreach ($tableData as $parts) { $partsArray = []; foreach ($parts as $part) { $partsArray[] = ...
Check option -t for show all tables. @param array[] $tableList All existing tables from data schema.
entailment
private function startAsking(array $tableList): void { $question = new Question('Please enter <note>TABLE NAME</note>: '); $tableName = $this->helper->ask($this->input, $this->output, $question); $key = StaticDataLayer::searchInRowSet('table_name', $tableName, $tableList); if (!isset($key)) { ...
Main function for asking. @param array[] $tableList All existing tables from data schema.
entailment
public function image($large, $small = null) { $this->image = [ 'smallImageUrl' => $small ?? $large, 'largeImageUrl' => $large, ]; return $this; }
Set the card image. @param $large @param null $small @return $this
entailment
public static function createNewScope( int $id, string $name, string $description = null, bool $isDefault = false ): Scope { $scope = new static(); $scope->id = $id; $scope->name = $name; $scope->description = $description; $scope->isDefault =...
Create a new Scope
entailment
public function login(string $userName, string $password, string $storedUserName = '', string $storedPassword = '', int $storedId): bool { if ($userName === $storedUserName && $this->password->verify($password, $storedPassword)) { //write valid login on session $this->session->loginT...
Try to attemp login with the informations passed by param. <pre><code class="php">$user = ''; //user from login page form $password = ''; //password from login page form $storedUser = ''; //user from stored informations $storedPassword = ''; //password hash from stored informations $storedId = ''; //user id from stor...
entailment
public function logout(): bool { //remove login data from session unset($this->session->login, $this->session->loginTime); //regenerate session id $this->session->regenerate(); $this->logged = false; return true; }
Do logout and delete login information from session. <pre><code class="php">$auth = new Authentication($session, $password); $auth->logout(); </code></pre> @return bool True if logout is done.
entailment
private function refresh(): bool { //check for login data on in current session if (empty($this->session->login)) { return false; } //take time $time = \time(); //check if login expired if (($this->session->loginTime + $this->session->expire) < $...
Check if user is logged, get login data from session and update it. @return bool True if refresh is done false if no.
entailment
public function register(Application $app) { $app[Repository::USER] = $app->share(function () use ($app) { return new Repository\DBALUserRepository($app['db']); }); $app[Repository::CITY] = $app->share(function()use($app){ return new MockCityRepository(); }); ...
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 callPoolOffset($method, array $args = []) { $poolOffset = $this->poolOffset; if ( ! $this->exists($poolOffset)) { $poolOffset = 'default'; } $itemPool = $this->getItemPool($poolOffset); if ($itemPool instanceof AbstractItemPool) { if...
Cache::callPoolOffset @param string $method @param array $args @return bool|mixed
entailment
public function get($key, $default = null) { if ($this->hasItem($key)) { $item = $this->getItem($key); return $item->get(); } return $default; }
Cache::get 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. @throws \Psr\SimpleCache\InvalidArgumentExcepti...
entailment
public function getItem($key) { if (false !== ($cacheItem = $this->callPoolOffset('getItem', [$key]))) { return $cacheItem; } return new Item(null, null); }
Cache::getItem Returns a Cache Item representing the specified key. This method must always return a CacheItemInterface object, even in case of a cache miss. It MUST NOT return null. @param string $key The key for which to return the corresponding Cache Item. @throws InvalidArgumentException @throws \Exception If t...
entailment
public function set($key, $value, $ttl = null) { return $this->save(new Item($key, $value, $ttl)); }
Cache::set 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 null|int|\DateInterval $ttl Optional. The TTL...
entailment
public function registerClient(string $name, array $redirectUris): array { do { $client = Client::createNewClient($name, $redirectUris); } while ($this->clientRepository->idExists($client->getId())); $secret = $client->generateSecret(); $client = $this->clientRepository-...
Register a new client and generate a strong secret Please note that the secret must be really kept secret, as it is used for some grant type to authorize the client. It is returned as a result of this method, as it's already encrypted in the client object @param string $name @param array $redirectUris @return array ...
entailment
public function sendError($code, $message = null) { if ($this->ajaxOnly === false) { output()->setContentType('application/json'); } if (is_array($code)) { if (is_numeric(key($code))) { $message = reset($code); $code = key($code); ...
------------------------------------------------------------------------
entailment
public function sendPayload($data, $longPooling = false) { if ($longPooling === false) { if ($this->ajaxOnly) { if (is_ajax()) { output()->send($data); } else { output()->sendError(403); } } else ...
Restful::sendPayload @param mixed $data The payload data to-be send. @param bool $longPooling Long pooling flag mode. @throws \Exception
entailment
public function setConfig(array $config) { $this->config = array_merge($this->config, $config); if ($this->config[ 'responsive' ]) { $this->responsive(); } return $this; }
Table::setConfig Set table configuration. @param array $config @return static
entailment
public function setColumns(array $columns) { $defaultColumn = [ 'field' => 'label', 'label' => 'Label', 'attr' => [ 'name' => '', 'id' => '', 'class' => '', 'width' => '', 'style' =...
Table::setColumns @param array $columns @return static
entailment
protected function setPrependColumns() { $prependColumns = [ 'numbering' => [ 'field' => 'numbering', 'label' => '#', 'attr' => [ 'width' => '5%', ], 'format' => 'number', ...
Table::setPrependColumns
entailment
protected function setAppendColumns() { $appendColumns = [ 'ordering' => [ 'field' => 'ordering', 'label' => '', 'attr' => [ 'class' => 'width-fit', 'width' => '1%', ], ...
Table::setAppendColumns
entailment
public function render() { if ($this->config[ 'ordering' ]) { $this->attributes->addAttributeClass('table-ordering'); } // Render header $tr = $this->header->createRow(); foreach ($this->columns as $key => $column) { $th = $tr->createColumn('th'); ...
Table::render @return string
entailment
protected function renderBodyColumn($td, array $column, Result\Row $row) { switch ($column[ 'format' ]) { default: if (is_callable($column[ 'format' ])) { if (is_array($column[ 'field' ])) { foreach ($column[ 'field' ] as $field) { ...
Table::renderBodyColumn @param Element $td @param array $column @param \O2System\Database\DataObjects\Result\Row $row
entailment
public function &__get($property) { $get[ $property ] = false; if (services()->has($property)) { $get[ $property ] = services()->get($property); } elseif (array_key_exists($property, $this->validSubModels)) { $get[ $property ] = $this->loadSubModel($property); ...
------------------------------------------------------------------------
entailment
final protected function loadSubModel($model) { if (is_file($this->validSubModels[ $model ])) { $className = '\\' . get_called_class() . '\\' . ucfirst($model); $className = str_replace('\Base\\Model', '\Models', $className); if (class_exists($className)) { ...
------------------------------------------------------------------------
entailment
public function setClass($className) { $this->attributes->removeAttributeClass($this->iconPrefixClass . '-*'); $this->attributes->addAttributeClass($this->iconPrefixClass . '-' . $className); return $this; }
AbstractIcon::setClass @param string $className @return static
entailment
public function setHeading($text, $level = 3) { $this->heading = new Heading($text, $level); $this->heading->entity->setEntityName($text); return $this; }
HeadingSetterTrait::setHeading @param string $text @param int $level @return static
entailment
public function languages() { $languages = []; foreach ($this->language->getRegistry() as $language) { $languages[ $language->getParameter() ] = $language->getProperties()->name; } return $languages; }
Options::languages @return array
entailment
public function load() { if ($this->getPresets()->offsetExists('assets')) { presenter()->assets->autoload($this->getPresets()->offsetGet('assets')); } presenter()->assets->loadCss('theme'); presenter()->assets->loadJs('theme'); // Autoload default theme layout ...
Theme::load @return static
entailment
public function hasLayout($layout) { $extensions = ['.php', '.phtml', '.html', '.tpl']; if (isset($this->presets[ 'extensions' ])) { array_unshift($partialsExtensions, $this->presets[ 'extension' ]); } elseif (isset($this->presets[ 'extension' ])) { array_unshift($ex...
Theme::hasLayout @return bool
entailment
public function setLayout($layout) { $extensions = ['.php', '.phtml', '.html', '.tpl']; if (isset($this->presets[ 'extensions' ])) { array_unshift($partialsExtensions, $this->presets[ 'extension' ]); } elseif (isset($this->presets[ 'extension' ])) { array_unshift($ex...
Theme::setLayout @param string $layout @return static
entailment
protected function loadLayout() { if ($this->layout instanceof Theme\Layout) { // add theme layout public directory loader()->addPublicDir($this->layout->getPath() . 'assets'); presenter()->assets->autoload( [ 'css' => ['layout'], ...
Theme::loadLayout @return static
entailment
protected function bootstrapImage($src, $alt, $width, $height, $class, $usemap) { $template = "<img %attributes%/>"; $attributes = []; $attributes["src"] = $src; $attributes["alt"] = $alt; $attributes["width"] = $width; $attributes["height"] = $height; $...
Displays a Bootstrap image. @param string $src The source @param string $alt The alternative text. @param string $width The width. @param string $height The height. @param string $class The class. @param string $usemap The usemap. @return string Returns the Bootstrap image.
entailment
public function createOptions(array $options, $selected = null) { foreach ($options as $label => $value) { $option = $this->createOption($label, $value); if (is_array($selected) && in_array($value, $selected)) { $option->selected(); } elseif ($selected ==...
OptionCreateTrait::createOptions @param array $options @param string|null $selected @return static
entailment
public function createOption($label, $value = null, $selected = false) { $option = new Option(); $option->textContent->push($label); if (isset($value)) { $option->attributes->addAttribute('value', $value); } if ($selected) { $option->selected(); ...
OptionCreateTrait::createOption @param string $label @param string|null $value @param bool $selected @return Option
entailment
public function render() { if ( ! $this->footer->hasChildNodes() && ! $this->footer->hasTextContent() && ! $this->footer->hasButtons()) { $this->childNodes->pop(); } return parent::render(); }
Content::render @return string
entailment
public function register() { parent::register(); $this->registerConfig(); $this->singleton(Contracts\Http\JsonResponse::class, Http\JsonResponder::class); }
Register the service provider.
entailment
public function bootstrapNavsPills(array $args = []) { return $this->bootstrapNavs(ArrayHelper::get($args, "items", []), "nav-pills", ArrayHelper::get($args, "stacked", false)); }
Displays a Bootstrap navs "Pills". @param array $args The arguments. @return string Returns the Bootstrap nav "Pills".
entailment
public function getFilterOptions(array $options = array()) { $options['types'] = $this->comment->getType(); $options['subtypes'] = array($this->comment->getSubtype(), 'hjcomment'); $options['container_guids'] = $this->comment->container_guid; if (!isset($options['order_by'])) { $options['order_by'] = 'e.guid...
Get options for {@link elgg_get_entities()} @param array $options Default options array @return array
entailment
public function getOffset($limit = self::LIMIT, $order = 'desc') { if ($limit === 0) { return 0; } if ($order == 'asc' || $order == 'time_created::asc') { $before = $this->getCommentsBefore(array('count' => true, 'offset' => 0)); } else { $before = $this->getCommentsAfter(array('count' => true, 'offset...
Calculate a page offset to the given comment @param int $limit Items per page @param int $order Ordering @return int
entailment
public function delete($recursive = true) { $success = 0; $count = $this->getCount(); $comments = $this->getAll()->setIncrementOffset(false); foreach ($comments as $comment) { if ($comment->delete($recursive)) { $success++; } } return ($success == $count); }
Delete all comments in a thread @param bool $recursive Delete recursively @return bool
entailment
public function getAll($getter = 'elgg_get_entities_from_metadata', $options = array()) { $options['limit'] = 0; $options = $this->getFilterOptions($options); return new ElggBatch($getter, $options); }
Get all comments as batch @param string $getter Callable getter @param array $options Getter options @return ElggBatch
entailment
public function getCommentsBefore(array $options = array()) { $options['wheres'][] = " e.time_created < {$this->comment->time_created} "; $options['order_by'] = 'e.time_created ASC'; $comments = elgg_get_entities_from_metadata($this->getFilterOptions($options)); if (is_array($comments)) { return array_r...
Get preceding comments @param array $options Additional options @return mixed
entailment
public function setImage($src, $alt = null) { $this->image = new Element('img'); if (strpos($src, 'holder.js') !== false) { $parts = explode('/', $src); $size = end($parts); $this->image->attributes->addAttribute('data-src', $src); $alt = empty($alt)...
ImageSetterTrait::setImage @param string $src @param string|null $alt @return static
entailment
public function transform(ApiRequest $request, ApiResponse $response, array $context = []): ApiResponse { if (isset($context['exception'])) { return $this->transformException($context['exception'], $request, $response); } return $this->transformResponse($request, $response); }
Encode given data for response @param mixed[] $context
entailment
public function authenticate($username, $password) { if ($user = $this->find($username)) { if ($user->account) { if ($this->passwordVerify($password, $user->account->password)) { if ($this->passwordRehash($password)) { $user->account->u...
User::authenticate @param string $username @param string $password @return bool
entailment
public function find($username) { $column = 'username'; if (is_numeric($username)) { $column = 'id'; } elseif (filter_var($username, FILTER_VALIDATE_EMAIL)) { $column = 'email'; } elseif (preg_match($this->config[ 'msisdnRegex' ], $username)) { $co...
User::find @param string $username @return bool|mixed|\O2System\Database\DataObjects\Result|\O2System\Framework\Models\Sql\DataObjects\Result
entailment
public function loggedIn() { if (parent::loggedIn()) { $account = new Account($_SESSION[ 'account' ]); if ($user = models('users')->findWhere(['username' => $account->username], 1)) { // Store Account Profile if ($profile = $user->profile) { ...
User::loggedIn @return bool @throws \Psr\Cache\InvalidArgumentException
entailment
public function forceLogin($username, $column = 'username') { if (is_numeric($username)) { $column = 'id'; } elseif (filter_var($username, FILTER_VALIDATE_EMAIL)) { $column = 'email'; } elseif (preg_match($this->config[ 'msisdnRegex' ], $username)) { $colu...
User::forceLogin @param string $username @param string $column @return bool
entailment
public function authorize(ServerRequest $request) { if (isset($GLOBALS[ 'account' ][ 'role' ])) { $uriSegments = $request->getUri()->getSegments()->getString(); $role = $GLOBALS[ 'account' ][ 'role' ]; if (in_array($role->code, ['DEVELOPER', 'ADMINISTRATOR'])) { ...
User::authorize @param \O2System\Framework\Http\Message\ServerRequest $request @return bool
entailment
public function render() { if ($this->title instanceof Element) { $this->title->attributes->addAttributeClass('card-title'); $this->childNodes->push($this->title); } if ($this->subTitle instanceof Element) { $this->subTitle->attributes->addAttributeClass(...
Body::render @return string
entailment
public function setNamespace(Opengraph\Abstracts\AbstractNamespace $namespace) { $this->prefix = 'http://ogp.me/ns# ' . $namespace->namespace . ": http://ogp.me/ns/$namespace->namespace#"; $this->offsetSet('type', $namespace->namespace); foreach ($namespace->getArrayCopy() as $property => $...
Opengraph::setNamespace @param \O2System\Framework\Http\Presenter\Meta\Opengraph\Abstracts\AbstractNamespace $namespace @return static
entailment
public function setAppId($appId) { $element = new Element('meta'); $element->attributes[ 'name' ] = 'fb:app_id'; $element->attributes[ 'content' ] = $appId; parent::offsetSet('fb:app_id', $element); return $this; }
Opengraph::setAppId @param string $appId @return static
entailment
public function setObject($property, $content) { $property = 'og:' . $property; $element = new Element('meta'); $element->attributes[ 'name' ] = $property; $element->attributes[ 'content' ] = (is_array($content) ? implode(', ', $content) : trim($content)); parent::offsetSet...
Opengraph::setObject @param string $property @param string $content @return static
entailment
public function setImage($image) { if (getimagesize($image)) { if (strpos($image, 'http') === false) { loader()->loadHelper('url'); $image = images_url($image); } $this->setObject('image', $image); } return $this; }
Opengraph::setImage @param $image @return static
entailment
public function setLocale($lang, $territory = null) { $lang = strtolower($lang); $this->setObject( 'locale', (isset($territory) ? $lang . '_' . strtoupper($territory) : $lang) ); return $this; }
Opengraph::setLocale @param string $lang @param string|null $territory @return static
entailment
public function setMap($latitude, $longitude) { $this->setObject('latitude', $latitude); $this->setObject('longitude', $longitude); return $this; }
Opengraph::setMap @param float $latitude @param float $longitude @return static
entailment