sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
protected function initServiceClient() { if ($this->httpClient === null) { $this->initHttpClients(); } $serviceDescription = new Description($this->config->getServiceDescriptionConfig()); $serviceClient = new GuzzleClient($this->getHttpClient(), $serviceDescription); ...
Sets the http client
entailment
public function initHttpClients() { $clientConfig = $this->config->getHttpClientConfig(); $authClient = new HttpClient($clientConfig); $this->setAuthHttpClient($authClient); $clientConfig['handler'] = $this->initHandlerStack(); $client = new HttpClient($clientConfig); ...
Sets the http client
entailment
public function setParent(Category $parent = null): Category { if ($parent === $this) { // Refuse the category to have itself as parent. $this->parent = null; return $this; } $this->parent = $parent; // Ensure bidirectional relation is respected...
@param Category|null $parent @return Category
entailment
public function addChild(Category $category): Category { $this->children->add($category); if ($category->getParent() !== $this) { $category->setParent($this); } return $this; }
@param Category $category @return Category
entailment
public function addPage(Page $page): Category { $this->children->add($page); if ($page->getCategory() !== $this) { $page->setCategory($this); } return $this; }
@param Page $page @return Category
entailment
public function removePage(Page $page): Category { $this->children->removeElement($page); $page->setCategory(null); return $this; }
@param Page $page @return Category
entailment
public function onRemove(LifecycleEventArgs $event) { $em = $event->getEntityManager(); if (count($this->children)) { foreach ($this->children as $child) { $child->setParent(null); $em->persist($child); } } $this->enabled = fals...
@ORM\PreRemove() @param LifecycleEventArgs $event
entailment
public function parse($token) { $parts = explode('.', $token); if (count($parts) !== 3) { throw new InvalidArgumentException('Token is invalid'); } $this->token = $token; $this->header = json_decode(base64_decode($parts[0]), true); $this->payload = json_de...
Parse a Token @param string $token @throws InvalidArgumentException
entailment
public function isValid() { $payload = $this->getPayload(); if (!isset($payload['exp'])) { return false; } $expireDateTime = DateTimeImmutable::createFromFormat('U', $payload['exp']); $now = new DateTime('now'); return ($expireDateTime->getTimestamp() - $...
Checks if the token is valid @return bool
entailment
public function findByCategory(Category $category, $order, $orderBy, $page, $limit): Paginator { $qb = $this->createQueryBuilder('page') ->where('page.category = :category') ->andWhere('page.enabled = :enabled') ->orderBy('page.'.$orderBy, $order) ->setMaxResu...
@param Category $category @param string $order @param string $orderBy @param int $page @param int $limit @return Paginator
entailment
public function findFrontPages(array $slugs = [], $host = null, $locale = null) { $qb = $this->createQueryBuilder('page') ->where('page.enabled = :enabled') ->leftJoin('page.category', 'category') ->andWhere('page.category is null OR category.enabled = :enabled') ...
Will search for pages to show in front depending on the arguments. If slugs are defined, there's no problem in looking for nulled host or locale, because slugs are unique, so it does not. @param array $slugs @param string|null $host @param string|null $locale @return Page[]
entailment
protected function getFinalTreeElement(array $slugs, array $elements) { // Will check that slugs and elements match $slugsElements = array_keys($elements); $sortedSlugs = $slugs; sort($sortedSlugs); sort($slugsElements); if ($sortedSlugs !== $slugsElements || !coun...
Slugs HAVE TO be ordered exactly as in the request. This method will check that, in $elements, we have the same keys as in $slugs, and that the hierarchy is correct. This also prevents things like /children/parent to work, as it should be /parent/children. @param array $slugs @param Page[]|Category[] $elem...
entailment
public function make(array $config): Client { $config = $this->getConfig($config); return $this->getClient($config); }
Make a new gitlab client. @param array $config @return \Gitlab\Client
entailment
protected function getClient(array $config): Client { $client = Client::create($config['url']); $client->authenticate( $config['token'], array_get($config, 'method', Client::AUTH_URL_TOKEN), array_get($config, 'sudo', null) ); return $client; ...
Get the main client. @param array $config @return \Gitlab\Client
entailment
public function findFrontCategories(array $slugs) { $qb = $this->createQueryBuilder('category') ->where('category.enabled = :enabled') ->setParameter('enabled', true) ->andWhere('category.slug IN ( :slugs )') ->setParameter('slugs', $slugs) ; ...
@param array $slugs @return Category[]
entailment
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('orbitale_cms'); $rootNode ->addDefaultsIfNotSet() ->children() ->scalarNode('page_class') ->isRequired() ...
{@inheritdoc}
entailment
public function indexAction(Request $request, string $slugs = '', string $_locale = null): Response { if (preg_match('~/$~', $slugs)) { return $this->redirect($this->generateUrl('orbitale_cms_page', ['slugs' => rtrim($slugs, '/')])); } $this->request = $request; $this->r...
@param Request $request @param string $slugs @param string|null $_locale @return Response
entailment
protected function getPages(array $slugsArray = []) { /** @var Page[] $pages */ $pages = $this->get('orbitale_cms.page_repository') ->findFrontPages($slugsArray, $this->request->getHost(), $this->request->getLocale()) ; if (!count($pages) || (count($slugsArray) && count(...
Retrieves the page list based on slugs. Also checks the hierarchy of the different pages. @param array $slugsArray @return Page[]
entailment
protected function getCurrentPage(array $pages, array $slugsArray): Page { if (count($pages) === count($slugsArray)) { $currentPage = $this->getFinalTreeElement($slugsArray, $pages); } else { $currentPage = current($pages); } return $currentPage; }
Retrieves the current page based on page list and entered slugs. @param Page[] $pages @param array $slugsArray @return Page
entailment
public function fetch($id) { if (!file_exists($this->filename($id))) { return false; } $filedata = file_get_contents($this->filename($id)); $data = json_decode($filedata, true); if ($data['ttl'] !== null) { if (($data['time'] + $data['ttl']) < time())...
Fetches an entry from the cache or returns false if not exists. @param string $id @return string|false
entailment
public function save($id, $data, $ttl = null) { $filedata = [ 'time' => time(), 'ttl' => $ttl, 'data' => $data, ]; return false !== file_put_contents($this->filename($id), json_encode($filedata), LOCK_EX); }
Puts data into the cache. @param string $id @param string $data @param int $ttl @return bool
entailment
private function createWritablePathIfNotExists($path) { if (!is_dir($path)) { // check if parentdir exists, and create this first. $parentdir = dirname($path); if (!is_dir($parentdir)) { $this->createWritablePathIfNotExists($parentdir); } ...
Create path if needed. @param string $path @return bool
entailment
public function append(Response $xResponse) { if(!$this->xResponse) { $this->xResponse = $xResponse; } elseif(get_class($this->xResponse) == get_class($xResponse)) { if($this->xResponse != $xResponse) { $this->xResponse->app...
Append one response object onto the end of another You cannot append a given response onto the end of a response of different type. If no prior response has been appended, this response becomes the main response object to which other response objects will be appended. @param Response $xResponse The ...
entailment
public function printDebug() { if(($this->xResponse)) { foreach($this->aDebugMessages as $sMessage) { $this->xResponse->debug($sMessage); } $this->aDebugMessages = []; } }
Prints the debug messages into the current response object @return void
entailment
public function getValue($row): string { $escape = $this->get('escape', false); $value = $this->attributes['value']($row); if ($value instanceof Renderable) { return $value->render(); } return $escape === true ? e($value) : $value; }
Get value of column. @param mixed $row @return string
entailment
private function getClassOptions($sClassName, array $aDirectoryOptions, array $aDefaultOptions = []) { $aOptions = $aDefaultOptions; if(key_exists('separator', $aDirectoryOptions)) { $aOptions['separator'] = $aDirectoryOptions['separator']; } if(key_exists('protec...
Get a given class options from specified directory options @param string $sClassName The name of the class @param array $aDirectoryOptions The directory options @param array $aDefaultOptions The default options @return array
entailment
private function getOptionsFromClass($sClassName) { if(!key_exists($sClassName, $this->aClassOptions)) { return null; // Class not registered } return $this->aClassOptions[$sClassName]; }
Find a class name is register with Jaxon::CALLABLE_CLASS type @param string $sClassName The class name of the callable object @return array|null
entailment
private function getOptionsFromNamespace($sClassName, $sNamespace = null) { // Find the corresponding namespace if($sNamespace === null) { foreach(array_keys($this->aNamespaceOptions) as $_sNamespace) { if(substr($sClassName, 0, strlen($_sNamespace) + ...
Find a class name is register with Jaxon::CALLABLE_DIR type @param string $sClassName The class name of the callable object @param string|null $sNamespace The namespace @return array|null
entailment
protected function _getCallableObject($sClassName, array $aOptions) { // Make sure the registered class exists if(key_exists('include', $aOptions)) { require_once($aOptions['include']); } if(!class_exists($sClassName)) { return null; } ...
Find a callable object by class name @param string $sClassName The class name of the callable object @param array $aOptions The callable object options @return object
entailment
public function getCallableObject($sClassName) { // Replace all separators ('.' and '_') with antislashes, and remove the antislashes // at the beginning and the end of the class name. $sClassName = trim(str_replace(['.', '_'], ['\\', '\\'], (string)$sClassName), '\\'); if(key_exist...
Find a callable object by class name @param string $sClassName The class name of the callable object @return object
entailment
private function createCallableObjects() { // Create callable objects for registered classes foreach($this->aClassOptions as $sClassName => $aClassOptions) { if(!key_exists($sClassName, $this->aCallableObjects)) { $this->_getCallableObject($sClassName,...
Create callable objects for all registered namespaces @return void
entailment
protected function getRegisteredObject($sClassName) { // Get the corresponding callable object $xCallableObject = $this->getCallableObject($sClassName); return ($xCallableObject) ? $xCallableObject->getRegisteredObject() : null; }
Find a user registered callable object by class name @param string $sClassName The class name of the callable object @return object
entailment
public function generateHash() { $this->createCallableObjects(); $sHash = ''; foreach($this->aNamespaces as $sNamespace => $aOptions) { $sHash .= $sNamespace . $aOptions['separator']; } foreach($this->aCallableObjects as $sClassName => $xCallableObject) ...
Generate a hash for the registered callable objects @return string
entailment
public function getScript() { $this->createCallableObjects(); $sPrefix = $this->getOption('core.prefix.class'); $aJsClasses = []; $sCode = ''; foreach(array_keys($this->aNamespaces) as $sNamespace) { $offset = 0; $sJsNamespace = str_replace('...
Generate client side javascript code for the registered callable objects @return string
entailment
private function _setOptions(array $aOptions, $sPrefix = '', $nDepth = 0) { $sPrefix = trim((string)$sPrefix); $nDepth = intval($nDepth); // Check the max depth if($nDepth < 0 || $nDepth > 9) { throw new \Jaxon\Config\Exception\Data(jaxon_trans('config.errors.data...
Recursively set Jaxon options from a data array @param array $aOptions The options array @param string $sPrefix The prefix for option names @param integer $nDepth The depth from the first call @return void
entailment
public function setOptions(array $aOptions, $sKeys = '') { // Find the config array in the input data $aKeys = explode('.', (string)$sKeys); foreach ($aKeys as $sKey) { if(($sKey)) { if(!array_key_exists($sKey, $aOptions) || !is_array($aOptions...
Set the values of an array of config options @param array $aOptions The options array @param string $sKeys The keys of the options in the array @return void
entailment
public function getOption($sName, $xDefault = null) { return (array_key_exists($sName, $this->aOptions) ? $this->aOptions[$sName] : $xDefault); }
Get the value of a config option @param string $sName The option name @param mixed $xDefault The default value, to be returned if the option is not defined @return mixed The option value, or its default value
entailment
public function getOptionNames($sPrefix) { $sPrefix = trim((string)$sPrefix); $sPrefix = rtrim($sPrefix, '.') . '.'; $sPrefixLen = strlen($sPrefix); $aOptions = []; foreach($this->aOptions as $sName => $xValue) { if(substr($sName, 0, $sPrefixLen) == $sPref...
Get the names of the options matching a given prefix @param string $sPrefix The prefix to match @return array The options matching the prefix
entailment
public function setClassName($sClass) { $this->sPrefix = $this->getOption('core.prefix.function'); $sClass = trim($sClass, '.\\ '); if(!$sClass) { return $this; } if(!($xCallable = $this->xRepository->getCallableObject($sClass))) { //...
Set the name of the class to call @param string|null $sClass The callable class @return Factory
entailment
public function setCallable(CallableObject $xCallable) { $this->sPrefix = $this->getOption('core.prefix.class') . $xCallable->getJsName() . '.'; return $this; }
Set the callable object to call @param CallableObject $xCallable The callable object @return Factory
entailment
public function call($sFunction) { $aArguments = func_get_args(); $sFunction = (string)$sFunction; // Remove the function name from the arguments array. array_shift($aArguments); // Makes legacy code works if(strpos($sFunction, '.') !== false) { /...
Return the javascript call to a Jaxon function or object method @param string $sFunction The function or method (without class) name @param ... $xParams The parameters of the function or method @return Request
entailment
public function func($sFunction) { $aArguments = func_get_args(); $sFunction = (string)$sFunction; // Remove the function name from the arguments array. array_shift($aArguments); // Make the request $xRequest = new Request($sFunction); $xRequest->useSingleQuot...
Return the javascript call to a generic function @param string $sFunction The function or method (with class) name @param ... $xParams The parameters of the function or method @return Request
entailment
public function paginate($nItemsTotal, $nItemsPerPage, $nCurrentPage) { // Get the args list starting from the $sMethod $aArgs = array_slice(func_get_args(), 3); // Make the request $request = call_user_func_array([$this, 'call'], $aArgs); $paginator = jaxon()->paginator($nIt...
Make the pagination links for a registered Jaxon class method @param integer $nItemsTotal The total number of items @param integer $nItemsPerPage The number of items per page page @param integer $nCurrentPage The current page @return string the pagination links
entailment
public function addNamespace($sNamespace, $sDirectory, $sExtension = '') { // The 'jaxon' key cannot be overriden if($sNamespace == 'jaxon') { return; } // Save the namespace $this->aNamespaces[$sNamespace] = [ 'directory' => rtrim(trim($sDirec...
Add a namespace to the template system @param string $sNamespace The namespace name @param string $sDirectory The namespace directory @param string $sExtension The extension to append to template names @return void
entailment
public function render($sTemplate, array $aVars = []) { $sTemplate = trim($sTemplate); // Get the namespace name $sNamespace = ''; $iSeparatorPosition = strrpos($sTemplate, '::'); if($iSeparatorPosition !== false) { $sNamespace = substr($sTemplate, 0, $iSe...
Render a template @param string $sTemplate The name of template to be rendered @param string $aVars The template vars @return string The template content
entailment
public static function make($xValue) { if($xValue instanceof Interfaces\Parameter) { return $xValue; } elseif(is_numeric($xValue)) { return new Parameter(Jaxon::NUMERIC_VALUE, $xValue); } elseif(is_string($xValue)) { ...
Create a Parameter instance using the given value @param mixed $xValue The parameter value @return Parameter
entailment
public function getScript() { $sJsCode = ''; switch($this->sType) { case Jaxon::FORM_VALUES: $sJsCode = $this->getJsCall('getFormValues', $this->xValue); break; case Jaxon::INPUT_VALUE: $sJsCode = $this->getJsCall('$', $this->xValue) . '.va...
Generate the javascript code. @return string
entailment
public static function fromHttpData($sUploadDir, array $aFile) { $xFile = new UploadedFile(); $xFile->sType = $aFile['type']; $xFile->sName = $xFile->slugify($aFile['filename']); $xFile->sFilename = $aFile['name']; $xFile->sExtension = $aFile['extension']; $xFile->sSi...
Create an instance of this class using data from the $_FILES global var. @param string $sUploadDir The directory where to save the uploaded file @param array $aFile The uploaded file data @return UploadedFile
entailment
public function toTempData() { return [ 'type' => $this->sType, 'name' => $this->sName, 'filename' => $this->sFilename, 'extension' => $this->sExtension, 'size' => $this->sSize, 'path' => $this->sPath, ]; }
Convert the UploadedFile instance to array. @return array
entailment
public static function fromTempData(array $aFile) { $xFile = new UploadedFile(); $xFile->sType = $aFile['type']; $xFile->sName = $aFile['name']; $xFile->sFilename = $aFile['filename']; $xFile->sExtension = $aFile['extension']; $xFile->sSize = $aFile['size']; $...
Create an instance of this class using data from an array. @param array $aFile The uploaded file data @return UploadedFile
entailment
public function configure($sName, $sValue) { switch($sName) { case 'class': // The user function is a method in the given class $this->xUserFunction = [$sValue, $this->xUserFunction]; break; case 'alias': $this->sJsFunction = $sValue; b...
Set call options for this instance @param string $sName The name of the configuration option @param string $sValue The value of the configuration option @return void
entailment
public function getScript() { $sPrefix = $this->getOption('core.prefix.function'); $sJsFunction = $this->getName(); return $this->render('jaxon::support/function.js', array( 'sPrefix' => $sPrefix, 'sAlias' => $sJsFunction, 'sFunction' => $sJsFunction, // ...
Generate the javascript function stub that is sent to the browser on initial page load @return string
entailment
public function call($aArgs = []) { if(($this->sInclude)) { require_once $this->sInclude; } // If the function is an alias for a class method, then instanciate the class if(is_array($this->xUserFunction) && is_string($this->xUserFunction[0])) { ...
Call the registered user function, including an external file if needed and passing along the specified arguments @param array $aArgs The function arguments @return void
entailment
public function title(string $title = null): Htmlable { $page = Paginator::resolveCurrentPage(); $data = [ 'site' => ['name' => $this->site], 'page' => ['title' => $title, 'number' => $page], ]; $data['site']['name'] = $this->getHtmlTitleFormatForSite($data)...
Create the title. @param string|null $title @return \Illuminate\Contracts\Support\Htmlable
entailment
protected function getHtmlTitleFormatForSite(array $data) { if ((int) $data['page']['number'] < 2) { return $data['site']['name']; } return Str::replace($this->formats['site'], $data); }
Get HTML::title() format for site. @param array $data @return mixed
entailment
protected function getHtmlTitleFormatForPage(array $data) { if (empty($data['page']['title'])) { return $data['site']['name']; } return Str::replace($this->formats['page'], $data); }
Get HTML::title() format for page. @param array $data @return mixed
entailment
public function create(string $tag = 'div', $value = null, array $attributes = []): Htmlable { if (\is_array($value)) { $attributes = $value; $value = null; } $content = '<'.$tag.$this->attributes($attributes).'>'; if (! \is_null($value)) { $cont...
Generate a HTML element. @param string $tag @param mixed $value @param array $attributes @return \Illuminate\Contracts\Support\Htmlable
entailment
public function attributable(array $attributes, array $defaults = []): string { return $this->attributes($this->decorate($attributes, $defaults)); }
Build a list of HTML attributes from one or two array and generate HTML attributes. @param array $attributes @param array $defaults @return string
entailment
public function addParameters(array $aParameters) { foreach($aParameters as $xParameter) { if($xParameter instanceof JsCall) { $this->addParameter(Jaxon::JS_VALUE, 'function(){' . $xParameter->getScript() . ';}'); } else { ...
Add a set of parameters to this request @param array $aParameters The parameters @return void
entailment
public function checkboxes($name, array $list = [], $checked = null, array $options = [], $separator = '<br>') { $group = []; $name = \str_replace('[]', '', $name); foreach ($list as $id => $label) { $group[] = $this->generateCheckboxByGroup($id, $label, $name, $checked, $option...
Create a checkboxes input field. @param string $name @param array $list @param bool|array $checked @param array $options @param string $separator @return string
entailment
protected function generateCheckboxByGroup($id, $label, $name, $checked, array $options) { $identifier = \sprintf('%s_%s', $name, $id); $key = \sprintf('%s[]', $name); $active = \in_array($id, (array) $checked); $options['id'] = $identifier; $control = $this->checkbox($key,...
Generate checkbox by group. @param string $id @param string $label @param string $name @param bool|array $checked @param array $options @return array
entailment
public function render($sPath, array $aVars = []) { // Make the template vars available as attributes foreach($aVars as $sName => $xValue) { $sName = (string)$sName; $this->$sName = $xValue; } // Render the template ob_start(); include(...
Render a template @param string $sPath The path to the template @param string $aVars The template vars @return string The template content
entailment
public function initiate(array $config): void { foreach ($config as $key => $value) { if (\property_exists($this, $key)) { $this->{$key} = $value; } } $this->header(function () { return []; }); }
Load grid configuration. @param array $config @return void
entailment
public function layout(string $name, array $data = []) { if (\in_array($name, ['horizontal', 'vertical'])) { $this->view = "orchestra/html::table.{$name}"; } else { $this->view = $name; } $this->viewData = $data; return $this; }
Set table layout (view). <code> // use default horizontal layout $table->layout('horizontal'); // use default vertical layout $table->layout('vertical'); // define table using custom view $table->layout('path.to.view'); </code> @param string $name @param array $data @return $this
entailment
public function with($model, bool $paginate = true) { $this->model = $model; $this->paginate = $paginate; return $this; }
Attach Eloquent as row and allow pagination (if required). <code> // add model without pagination $table->with(User::all(), false); // add model with pagination $table->with(User::paginate(30), true); </code> @param mixed $model @param bool $paginate @throws \InvalidArgumentException @return $this
entailment
public function rows($data) { if ($data instanceof Arrayable) { $data = $data->toArray(); } $this->setRowsData($data); return $this; }
Attach rows data instead of assigning a model. <code> // assign a data $table->rows(DB::table('users')->get()); </code> @param array|\Illuminate\Contracts\Support\Arrayable $data @throws \InvalidArgumentException @return $this
entailment
public function data(): array { if (empty($this->data) && ! empty($this->model)) { $this->buildRowsFromModel($this->model); } return $this->data; }
Get raw data. @throws \InvalidArgumentException @return array
entailment
public function header(Closure $callback = null) { if (\is_null($callback)) { return $this->header; } $this->header = $callback; return null; }
Add or append grid header attributes. @param \Closure|null $callback @return \Closure|array|null
entailment
public function column($name, $callback = null) { list($name, $column) = $this->buildColumn($name, $callback); $this->columns[] = $column; $this->keyMap[$name] = \count($this->columns) - 1; return $column; }
Append a new column to the table. <code> // add a new column using just field name $table->column('username'); // add a new column using a label (header title) and field name $table->column('User Name', 'username'); // add a new column by using a field name and closure $table->column('fullname', function ($column) {...
entailment
public function find(string $name): Column { if (! \array_key_exists($name, $this->keyMap)) { throw new InvalidArgumentException("Name [{$name}] is not available."); } return $this->columns[$this->keyMap[$name]]; }
Find definition that match the given id. @param string $name @throws \InvalidArgumentException @return \Orchestra\Contracts\Html\Table\Column
entailment
public function paginate($perPage) { if (\filter_var($perPage, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]) && ! \is_bool($perPage)) { $this->perPage = $perPage; $this->paginate = true; } elseif (\filter_var($perPage, FILTER_VALIDATE_BOOLEAN)) { $this->...
Setup pagination. @param bool|int|null $perPage @return $this
entailment
public function searchable(array $attributes, string $key = 'q'): void { $model = $this->resolveQueryBuilderFromModel($this->model); $request = $this->app->make('request'); $value = $request->input($key); $request->merge(["{$key}" => \rawurlencode($value)]); $this->set('sea...
Execute searchable filter on model instance. @param array $attributes @param string $key @return void
entailment
public function sortable( array $orderColumns = [], string $orderByKey = 'order_by', string $directionKey = 'direction' ): void { $model = $this->resolveQueryBuilderFromModel($this->model); $request = $this->app->make('request'); $orderByValue = $request->input($orde...
Execute sortable query filter on model instance. @param array $orderColumns @param string $orderByKey @param string $directionKey @return void
entailment
protected function buildColumn($name, $callback = null): array { list($label, $name, $callback) = $this->buildFluentAttributes($name, $callback); $value = ''; if (! empty($name)) { $value = function ($row) use ($name) { return \data_get($row, $name); ...
Build control. @param mixed $name @param mixed $callback @return array
entailment
protected function buildModel($model) { try { $query = $this->resolveQueryBuilderFromModel($model); } catch (InvalidArgumentException $e) { $query = $model; } if ($this->paginate === true && \method_exists($query, 'paginate')) { $query = $query->p...
Convert the model to Paginator when available or convert it to a collection. @param mixed $model @return \Illuminate\Contracts\Support\Arrayable|array
entailment
protected function buildRowsFromModel($model): void { $this->model = $model = $this->buildModel($model); if ($model instanceof Paginator) { $this->setRowsData($model->items()); $this->paginate = true; } elseif ($model instanceof Collection) { $this->setRo...
Get rows from model instance. @param object $model @throws \InvalidArgumentException @return void
entailment
protected function resolveQueryBuilderFromModel($model) { if ($this->isEloquentModel($model)) { return $model->newQuery(); } elseif ($this->isEloquentRelationModel($model)) { return $model->getQuery(); } elseif (! $this->isQueryBuilder($model)) { throw new...
Resolve query builder from model instance. @param mixed $model @throws \InvalidArgumentException @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
entailment
protected function isQueryBuilder($model): bool { return $model instanceof \Illuminate\Database\Query\Builder || $model instanceof \Illuminate\Database\Eloquent\Builder; }
Check if given $model is a query builder. @param mixed $model @return bool
entailment
public function getPages() { $pages = []; if($this->numPages <= 1) { return []; } if($this->numPages <= $this->maxPagesToShow) { for($i = 1; $i <= $this->numPages; $i++) { $pages[] = $this->createPage($i, $i == $th...
Get an array of paginated page data. Example: array( array ('num' => 1, 'call' => '/example/page/1', 'isCurrent' => false), array ('num' => '...', 'call' => NULL, 'isCurrent' => false), array ('num' => 3, 'call' => '/example/page/3', 'isCurrent' => false), array ('num' => 4, 'call' => '/exa...
entailment
public function toHtml() { if($this->getNumPages() <= 1) { return ''; } $this->renderer->setPaginator($this); return $this->renderer->render(); }
Render an HTML pagination control. @return string
entailment
private function __convertStringToBool($sValue) { if(strcasecmp($sValue, 'true') == 0) { return true; } if(strcasecmp($sValue, 'false') == 0) { return false; } if(is_numeric($sValue)) { if($sValue == 0) {...
Converts a string to a boolean var @param string $sValue The string to be converted @return boolean
entailment
private function __convertValue($sValue) { $cType = substr($sValue, 0, 1); $sValue = substr($sValue, 1); switch ($cType) { case 'S': $value = ($sValue === false ? '' : $sValue); break; case 'B': $value = $this->_...
Convert an Jaxon request argument to its value Depending of its first char, the Jaxon request argument is converted to a given type. @param string $sValue The keys of the options in the file @return mixed
entailment
private function __argumentDecode(&$sArg) { if($sArg == '') { return ''; } // Arguments are url encoded when uploading files $sType = 'multipart/form-data'; $iLen = strlen($sType); $sContentType = ''; if(key_exists('CONTENT_TYPE', $_SERVER...
Decode and convert an Jaxon request argument from JSON @param string $sArg The Jaxon request argument @return mixed
entailment
private function __argumentDecodeUTF8_iconv(&$mArg) { if(is_array($mArg)) { foreach($mArg as $sKey => &$xArg) { $sNewKey = $sKey; $this->__argumentDecodeUTF8_iconv($sNewKey); if($sNewKey != $sKey) { ...
Decode an Jaxon request argument and convert to UTF8 with iconv @param string|array $mArg The Jaxon request argument @return void
entailment
private function __argumentDecodeUTF8_mb_convert_encoding(&$mArg) { if(is_array($mArg)) { foreach($mArg as $sKey => &$xArg) { $sNewKey = $sKey; $this->__argumentDecodeUTF8_mb_convert_encoding($sNewKey); if($sNewKey != $sKey) ...
Decode an Jaxon request argument and convert to UTF8 with mb_convert_encoding @param string|array $mArg The Jaxon request argument @return void
entailment
private function __argumentDecodeUTF8_utf8_decode(&$mArg) { if(is_array($mArg)) { foreach($mArg as $sKey => &$xArg) { $sNewKey = $sKey; $this->__argumentDecodeUTF8_utf8_decode($sNewKey); if($sNewKey != $sKey) { ...
Decode an Jaxon request argument from UTF8 @param string|array $mArg The Jaxon request argument @return void
entailment
public function processArguments() { if(($this->getOption('core.decode_utf8'))) { $sFunction = ''; if(function_exists('iconv')) { $sFunction = "iconv"; } elseif(function_exists('mb_convert_encoding')) { ...
Return the array of arguments that were extracted and parsed from the GET or POST data @return array
entailment
public function canProcessRequest() { foreach($this->xPluginManager->getRequestPlugins() as $xPlugin) { if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) { return true; } } return false; }
Check if the current request can be processed Calls each of the request plugins and determines if the current request can be processed by one of them. If no processor identifies the current request, then the request must be for the initial page load. @return boolean
entailment
public function processRequest() { foreach($this->xPluginManager->getRequestPlugins() as $xPlugin) { if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) { $xUploadPlugin = $this->xPluginManager->getRequestPlugin(Jaxon::FILE_UPLOAD); ...
Process the current request Calls each of the request plugins to request that they process the current request. If any plugin processes the request, it will return true. @return boolean
entailment
public function register($sType, $sDirectory, $aOptions) { if($sType != $this->getName()) { return false; } if(!is_string($sDirectory) || !is_dir($sDirectory)) { throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); ...
Register a callable class @param string $sType The type of request handler being registered @param string $sDirectory The name of the class being registered @param array|string $aOptions The associated options @return boolean
entailment
public function read($sConfigFile) { $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION); switch($sExt) { case 'php': $aConfigOptions = Php::read($sConfigFile); break; case 'yaml': case 'yml': $aConfigOptions = Yaml::read($sConfigFil...
Read options from a config file @param string $sConfigFile The full path to the config file @return array
entailment
abstract public function __construct(Request $request, Translator $translator, View $view, GridContract $grid); /** * Extend decoration. * * @param callable $callback * * @return $this */ public function extend(callable $callback = null) { // Run the table designer. ...
Create a new Builder instance. @param \Illuminate\Http\Request $request @param \Illuminate\Translation\Translator $translator @param \Illuminate\Contracts\View\Factory $view @param \Orchestra\Contracts\Html\Grid $grid
entailment
public static function detect() { $aURL = []; // Try to get the request URL if(!empty($_SERVER['REQUEST_URI'])) { $_SERVER['REQUEST_URI'] = str_replace(array('"',"'",'<','>'), array('%22','%27','%3C','%3E'), $_SERVER['REQUEST_URI']); $aURL = parse_url($_SERVER...
Detect the URI of the current request @return string The URI
entailment
private function init($sTranslationDir, $sTemplateDir) { /* * Parameters */ // Translation directory $this->coreContainer['jaxon.core.translation_dir'] = $sTranslationDir; // Template directory $this->coreContainer['jaxon.core.template_dir'] = $sTemplateDir;...
Set the parameters and create the objects in the dependency injection container @param string $sTranslationDir The translation directory @param string $sTemplateDir The template directory @return void
entailment
public function get($sClass) { if($this->sentryContainer != null && $this->sentryContainer->has($sClass)) { return $this->sentryContainer->get($sClass); } return $this->coreContainer[$sClass]; }
Get a class instance @return object The class instance
entailment
public function addViewRenderer($sId, $xClosure) { // Return the non-initialiazed view renderer $this->coreContainer['jaxon.sentry.view.base.' . $sId] = $xClosure; // Return the initialized view renderer $this->coreContainer['jaxon.sentry.view.' . $sId] = function ($c) use ($sId) { ...
Add a view renderer @param string $sId The unique identifier of the view renderer @param Closure $xClosure A closure to create the view instance @return void
entailment
public function getViewRenderer($sId = '') { if(!$sId) { // Return the view renderer facade return $this->coreContainer[\Jaxon\Sentry\View\Facade::class]; } // Return the view renderer with the given id return $this->coreContainer['jaxon.sentry.view.' ...
Get the view renderer @param string $sId The unique identifier of the view renderer @return Jaxon\Sentry\Interfaces\View
entailment
public function canExportJavascript() { // Check config options // - The js.app.extern option must be set to true // - The js.app.uri and js.app.dir options must be set to non null values if(!$this->getOption('js.app.extern') || !$this->getOption('js.app.uri') || ...
Check if the javascript code generated by Jaxon can be exported to an external file @return boolean
entailment
private function generateHash() { $sHash = jaxon()->getVersion(); foreach($this->xPluginManager->getRequestPlugins() as $xPlugin) { $sHash .= $xPlugin->generateHash(); } foreach($this->xPluginManager->getResponsePlugins() as $xPlugin) { $sHash ...
Generate a hash for all the javascript code generated by the library @return string
entailment
private function makePluginsCode() { if($this->sCssCode === null || $this->sJsCode === null || $this->sJsReady === null) { $this->sCssCode = ''; $this->sJsCode = ''; $this->sJsReady = ''; foreach($this->xPluginManager->getResponsePlugins() as $xRespons...
Get the HTML tags to include Jaxon javascript files into the page @return string
entailment