sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function getInstalledPackages() { $packages = []; $content = $this->getFileContents('composer.lock'); foreach (['packages', 'packages-dev'] as $key) { if (!isset($content[$key])) { continue; } foreach ($content[$key] as $package) ...
Get installed package versions. @throws \LogicException @return array
entailment
public function getRequiredPackages() { $packages = []; $content = $this->getFileContents('composer.json'); foreach (['require', 'require-dev'] as $key) { if (!isset($content[$key])) { continue; } foreach ($content[$key] as $name => $ver...
Get required package versions. @throws \LogicException @return array
entailment
protected function getFileContents($file) { $filePath = $this->directory.'/'.$file; if (!file_exists($filePath)) { throw new InvalidArgumentException("The file [$filePath] does not exist."); } return json_decode(file_get_contents($filePath), true); }
Get file content. @param string $file @throws \InvalidArgumentException @return array
entailment
protected function getVariables() { foreach ($this->fields as $field) { $field->fill($this->data); } return [ 'fields' => $this->fields, 'attributes' => $this->formatAttribute(), 'method' => $this->attributes['method'], ]; }
Get variables for render form. @return array
entailment
public function versionDiff($current, $latest) { $needle = 0; while ($needle < strlen($current) && $needle < strlen($latest)) { if ($current[$needle] !== $latest[$needle]) { break; } $needle++; } return substr($latest, 0, $needle...
Get the diff between the current and latest version. @param string $current @param string $latest @return string
entailment
protected function getComposerPathFromInput(InputInterface $input) { if ($input->getOption('directory')) { return $input->getOption('directory'); } if ($input->getOption('global')) { return getenv('HOME').'/.composer'; } }
Get composer path based on user input. @param \Symfony\Component\Console\Input\InputInterface $input @return null|string
entailment
public function getNewRegistrationIds() { if ($this->getNewRegistrationIdsCount() == 0) { return array(); } $filteredResults = array_filter( $this->results, function ($result) { return isset($result['registration_id']); } ...
Return an array of expired registration ids linked to new id All old registration ids must be updated to new ones in DB @return array oldRegistrationId => newRegistrationId
entailment
public function getUnavailableRegistrationIds() { if ($this->getFailureCount() == 0) { return array(); } $filteredResults = array_filter( $this->results, function ($result) { return ( isset($result['error']) ...
Returns an array of registration ids for which you must resend a message (?), cause devices aren't available now. @TODO: check if it be auto sent later @return array
entailment
public function register_control( \WP_Customize_Manager $wp_customize ) { $this->args['type'] = 'upload'; $wp_customize->add_control( new \WP_Customize_Upload_Control( $wp_customize, $this->get_id(), $this->_generate_register_control_args() ) ); }
Add control @param WP_Customize_Manager $wp_customize @see https://developer.wordpress.org/reference/classes/wp_customize_manager/add_control/ @see https://developer.wordpress.org/reference/classes/wp_customize_manager/add_setting/
entailment
public function chunk($callback, $count = 100) { if ($this->usePaginate) { return $this->buildData(false)->chunk($count)->each($callback); } $this->setSort(); $this->queries->reject(function ($query) { return 'paginate' === $query['method']; })->each...
@param callable $callback @param int $count @return bool
entailment
protected function resolvePerPage($paginate) { if ($perPage = app('request')->input($this->perPageName)) { if (is_array($paginate)) { $paginate['arguments'][0] = (int) $perPage; return $paginate['arguments']; } $this->perPage = (int) $per...
Resolve perPage for pagination. @param array|null $paginate @return array
entailment
protected function setSort() { $this->sort = Input::get($this->sortName, []); if (!is_array($this->sort)) { return; } if (empty($this->sort['column']) || empty($this->sort['type'])) { return; } if (str_contains($this->sort['column'], '.')) { ...
Set the grid sort.
entailment
protected function setRelationSort($column) { list($relationName, $relationColumn) = explode('.', $column); if ($this->queries->contains(function ($query) use ($relationName) { return 'with' === $query['method'] && in_array($relationName, $query['arguments'], true); })) { ...
Set relation sort. @param string $column
entailment
protected function joinParameters(Relation $relation) { $relatedTable = $relation->getRelated()->getTable(); if ($relation instanceof BelongsTo) { return [ $relatedTable, $relation->getForeignKey(), '=', $relatedTable.'.'.$...
Build join parameters for related model. `HasOne` and `BelongsTo` relation has different join parameters. @param Relation $relation @throws \Exception @return array
entailment
public function _amp_post_template_css() { ob_start(); $this->_print_front_styles(); $css = ob_get_clean(); $css = str_replace( '!important', '', $css ); // @codingStandardsIgnoreStart echo $css; // @codingStandardsIgnoreEnd }
Styles for AMP @return void
entailment
public function _tiny_mce_before_init( $mce_init ) { $styles = WP_Customizer_Framework\Style::get_registerd_styles(); if ( ! isset( $mce_init['content_style'] ) ) { $mce_init['content_style'] = ''; } foreach ( $styles as $style ) { foreach ( $style['selectors'] as $i => $selector ) { $selector = tri...
Styles for TinyMCE @param array $mce_init @return array
entailment
public function _print_gutenberg_styles() { $styles = WP_Customizer_Framework\Style::get_registerd_styles(); $new_styles = []; foreach ( $styles as $styles_index => $style ) { foreach ( $style['selectors'] as $selectors_index => $selector ) { $selector = trim( $selector ); $style['selectors'][ $select...
Print styles for Gutenberg @return void
entailment
protected function _print_styles( $styles ) { foreach ( $styles as $style ) { $selectors = implode( ',', $style['selectors'] ); $properties = implode( ';', $style['properties'] ); if ( ! $style['media_query'] ) { printf( '%1$s { %2$s }', // @todo // @codingStandardsIgnoreStart strip...
Print styles in head @param array $styles @return void
entailment
public function getResults() { if(!$this->statManager->checkStatus()){ $this->runValidation($this->options); } return $this->statManager->getStatus(); }
Returns results @return array
entailment
public function edit($channelId, $typeId, $type, $allow = null, $deny = null) { $current = $this->show($channelId, $typeId, $type); if (is_null($current)) { return $this->create($channelId, $typeId, $type, $allow, $deny); } if (is_null($allow)) { $allow = $cur...
Edit channel permissions. @param string $channelId @param string $typeId @param string $type @param null $allow @param null $deny @return array
entailment
public function setEmailsDomains(BagHelper $emailBag) { $domainBag = new BagHelper(); foreach ($emailBag as $key => $emails) { foreach ($emails as $email) { $mail = new Email($email); list($user, $domain) = $mail->parse(); $domainBag->set($...
Sets the email addresses that should be validated. @param BagHelper $emailBag @return BagHelper $domainBag
entailment
public function setSender($email) { $mail = new Email($email); $parts = $mail->parse(); $this->fromUser = $parts[0]; $this->fromDomain = $parts[1]; }
Sets the email address to use as the sender/validator. @param string $email @return void
entailment
public function register( $selectors, $properties, $media_query = null ) { Style::register( $selectors, $properties, $media_query ); }
Registers style setting @param string|array $selectors @param string|array $properties @param string $media_query @return void
entailment
protected function _color_luminance( $hex, $percent ) { $hex = $this->_hex_normalization( $hex ); $hue = $this->_get_hue( $hex ); $saturation = $this->_get_saturation( $hex ); $luminance = $this->_get_luminance( $hex ); // Add luminance. $luminance += $percent * 100; $luminance = ( 100 < ...
Change brightness @param hex $hex @param int $percent @return hex
entailment
protected function _hex_normalization( $hex ) { $hex = preg_replace( '/[^0-9a-f]/i', '', ltrim( $hex, '#' ) ); if ( strlen( $hex ) < 6 ) { $hex = $hex[0] + $hex[0] + $hex[1] + $hex[1] + $hex[2] + $hex[2]; } return $hex; }
Normalize hex .e.g #000000 -> 000000 .e.g #000 -> 000000 @param hex $hex @return hex
entailment
private function _get_hue( $hex ) { $red = hexdec( substr( $hex, 0, 2 ) ); $green = hexdec( substr( $hex, 2, 2 ) ); $blue = hexdec( substr( $hex, 4, 2 ) ); $max_rgb = max( $red, $green, $blue ); $min_rgb = min( $red, $green, $blue ); if ( $red === $green && $red === $blue ) { return 0; } $diff_m...
Return hue from hex @SuppressWarnings(PHPMD.CyclomaticComplexity) @param hex $hex @return hue
entailment
private function _convert_hsl_to_hex( $hue, $saturation, $luminance ) { if ( 49 >= $luminance ) { $max_hsl = 2.55 * ( $luminance + $luminance * ( $saturation / 100 ) ); $min_hsl = 2.55 * ( $luminance - $luminance * ( $saturation / 100 ) ); } else { $max_hsl = 2.55 * ( $luminance + ( 100 - $luminance ) * ( ...
Convert hsl to hex @param hue $hue @param saturation $saturation @param luminance $luminance @return hex
entailment
public function bulkSet($registrationIds = array(), $data = null, $collapseKey = null) { $this->setRegistrationIds($registrationIds); $this->setData($data); $this->setCollapseKey($collapseKey); }
Set multiple fields at once. @param string[] $registrationIds @param array|null $data @param string|null $collapseKey
entailment
public function getIssuers() { $issuers = array(); if (isset($this->data->directory)) { foreach ($this->data->directory->issuer as $issuer) { $issuers[] = new Issuer((string) $issuer->issuerid, (string) $issuer->issuername); } } return $issue...
{@inheritdoc}
entailment
private function isTokenInRequest(Request $request) { return $request->query->has($this->tokenParam) || $request->attributes->has($this->tokenParam) || $request->request->has($this->tokenParam); }
Check the ParameterBags consulted by Request::get() for the token. @param Request $request @return boolean
entailment
public function connect($host,$domain) { $remoteSocket = $host . ':' . $this->config['port']; $this->domain = $domain; $errnum = 0; $errstr = ''; $this->host = $remoteSocket; // open connection $this->socket = @stream_socket_client( ...
Tries to connect to the specified host on the pre-configured port. @param string $host The host to connect to @return String weather a error string or success string @throws Exception\ExceptionNoConnection @throws Exception\ExceptionNoTimeout
entailment
public function acceptsAnyRecipient(Domain $domain) { $test = 'catch-all-test-' . time(); $accepted = $this->rcpt($test . '@' . $domain->getDomain()); if ($accepted) { $domain->addDescription(array('catchall' => 1)); // success on a non-existing address is a "catc...
@param Domain $domain @return bool
entailment
public function helo() { // don't try if it was already done if ($this->state['helo']) { return true; } try { $this->expect( $this->config['responseCodes']['SMTP_CONNECT_SUCCESS'], $this->config['commandTimeouts']['helo'] ...
Sends a HELO/EHLO sequence @todo Implement TLS, add logs @return bool True if successful, false otherwise
entailment
protected function ehlo() { try { // modern, timeout 5 minutes $this->send('EHLO ' . $this->options['fromDomain']); $this->expect($this->config['responseCodes']['SMTP_GENERIC_SUCCESS'], $this->config['commandTimeouts']['ehlo']); } catch (Exception\ExceptionUnexpe...
Send EHLO or HELO, depending on what's supported by the remote host. @return void
entailment
public function mail($from) { if (!$this->state['helo']) { throw new Exception\ExceptionNoHelo('Need HELO before MAIL FROM'); } try { // issue MAIL FROM, 5 minute timeout $this->send('MAIL FROM:<' . $from . '>'); $this->expect($this->config['re...
Sends a MAIL FROM command to indicate the sender. @param string $from The "From:" address @return bool If MAIL FROM command was accepted or not @throws Exception\ExceptionNoHelo
entailment
public function rcpt($to) { // need to have issued MAIL FROM first if (!$this->state['mail']) { $this->statusManager->setStatus($this->users,new Domain($this->domain),0,'Need MAIL FROM before RCPT TO'); throw new Exception\ExceptionNoMailFrom('Need MAIL FROM before RCPT TO')...
Sends a RCPT TO command to indicate a recipient. @param string $to Recipient's email address @return bool Is the recipient accepted @throws Exception\ExceptionNoMailFrom
entailment
public function rset() { $this->send('RSET'); // MS ESMTP doesn't follow RFC according to ZF tracker, see [ZF-1377] $expected = array( $this->config['responseCodes']['SMTP_GENERIC_SUCCESS'], $this->config['responseCodes']['SMTP_CONNECT_SUCCESS'], // hotmai...
Sends a RSET command and resets our internal state. @return void
entailment
public function quit() { // although RFC says QUIT can be issued at any time, we won't if ($this->state['helo']) { try { $this->send('QUIT'); $this->expect($this->config['responseCodes']['SMTP_QUIT_SUCCESS'], $this->config['commandTimeouts']['quit']); ...
Sends a QUIT command. @return void
entailment
public function send($cmd) { // must be connected if (!$this->isConnect()) { $this->statusManager->setStatus($this->users,new Domain($this->domain),0,'No connection'); return false; } $result = false; // write the cmd to the connection stream ...
Sends a command to the remote host. @param string $cmd The cmd to send @return int|bool Number of bytes written to the stream @throws Exception\ExceptionNoConnection @throws Exception\ExceptionSendFailed
entailment
public function recv($timeout = null) { // timeout specified? if ($timeout !== null) { stream_set_timeout($this->socket, $timeout); } // retrieve response $line = fgets($this->socket, 1024); if ($this->validationOptions['debug'] === true) { $t...
Receives a response line from the remote host. @param int $timeout Timeout in seconds @return string @throws Exception\ExceptionNoConnection @throws Exception\ExceptionTimeout @throws Exception\ExceptionNoResponse
entailment
public function expect($codes, $timeout = null) { if (!is_array($codes)) { $codes = (array)$codes; } $code = null; $text = $line = ''; try { $text = $line = $this->recv($timeout); while (preg_match("/^[0-9]+-/", $line)) { $...
Receives lines from the remote host and looks for expected response codes. @param string|array $codes A list of one or more expected response codes @param int $timeout The timeout for this individual command, if any @return string The last text message received @throws Exception\ExceptionUnexpec...
entailment
public function disconnect($quit = true) { if ($quit) { $this->quit(); } if ($this->isConnect()) { fclose($this->socket); } $this->host = null; $this->resetState(); }
Disconnects the currently connected MTA. @param bool $quit Issue QUIT before closing the socket on our end. @return void
entailment
private function resetState() { $this->state['helo'] = false; $this->state['mail'] = false; $this->state['rcpt'] = false; }
Resets internal state flags to defaults
entailment
protected function buildOptions(): array { if (is_string($this->options)) { $this->loadRemoteOptions($this->options); } if ($this->options instanceof \Closure) { $this->options = $this->options->call($this->filter, $this->filter->getValue()); } if ($...
Build options. @return array
entailment
public function render() { $this->script = "$('{$this->getElementClassSelector()}').iCheck({radioClass:'iradio_minimal-blue'});"; return parent::render()->with(['options' => $this->options, 'inline' => $this->inline]); }
{@inheritdoc}
entailment
private function memberMentions($message) { $filteredMessage = $message['content']; foreach ($message['mentions'] as $mention) { $filteredMessage = str_replace('<@'.$mention['id'].'>', '@'.$mention['username'], $filteredMessage); } return $filteredMessage; }
/* Thanks @Vinlock
entailment
public function sendData($data) { $endpoint = $this->endpoint; if ($this->getTestMode()) { $endpoint .= '?test=true'; } $httpResponse = $this->httpClient->request('GET', $endpoint); return $this->response = new FetchIssuersResponse($this, $this->parseXmlResponse...
{@inheritdoc}
entailment
public function removeIDFilterIfNeeded() { if (!$this->useIdFilter && !$this->idFilterRemoved) { array_shift($this->filters); $this->idFilterRemoved = true; } }
Remove ID filter if needed.
entailment
public function chunk(callable $callback, $count = 100) { return $this->model->addConditions($this->conditions())->chunk($callback, $count); }
@param callable $callback @param int $count @return bool
entailment
protected function urlWithoutFilters() { $columns = []; /** @var Filter\AbstractFilter $filter * */ foreach ($this->filters as $filter) { $columns[] = $filter->getColumn(); } /** @var \Illuminate\Http\Request $request * */ $request = Request::instance();...
Get url without filter queryString. @return string
entailment
public function parse() { $parts = explode('@', $this->getEmail()); $domain = array_pop($parts); $user = implode('@', $parts); return array($user, $domain); }
Parses an email string into respective user and domain parts and returns those as an array. @return array ['user', 'domain']
entailment
public function add($title, BatchAction $abstract) { $id = $this->actions->count(); $abstract->setId($id); $this->actions->push(compact('id', 'title', 'abstract')); return $this; }
Add a batch action. @param string $title @param BatchAction $abstract @return $this
entailment
protected function setUpScripts() { Admin::script($this->script()); foreach ($this->actions as $action) { $abstract = $action['abstract']; $abstract->setResource($this->grid->resource()); Admin::script($abstract->script()); } }
Setup scripts of batch actions.
entailment
public function edit($guildId, $options = []) { $image = new Image(); $guild = $this->show($guildId); $json['name'] = isset($options['name']) ? $options['name'] : $guild['name']; $json['region'] = isset($options['region']) ? $options['region'] : $guild['region']; $json['icon'...
/* Edit a guild. @param string $guildId Required @param array $options [ @property string $name @property string $region @property file|url $icon @property string $afk_channel_id ] @return array
entailment
public function getOutdatedPackages(array $excluded = []) { // Get all installed and required packages. $installed = $this->composer->getInstalledPackages(); $required = $this->composer->getRequiredPackages(); $outdated = []; // Get the installed version number of the requi...
Get outdated packages with their current and latest version. @param array $excluded @return array
entailment
public function getValidator(array $input) { if (!array_key_exists($this->column, $input)) { return false; } $input = array_only($input, $this->column); $form = $this->buildNestedForm($this->column, $this->builder); $rules = $attributes = []; /* @var F...
Get validator for this field. @param array $input @return bool|Validator
entailment
protected function resetInputKey(array &$input, array $column) { /** * flip the column name array set. * * for example, for the DateRange, the column like as below * * ["start" => "created_at", "end" => "updated_at"] * * to: * ...
Reset input key for validation. @param array $input @param array $column $column is the column name array set
entailment
protected function buildNestedForm($column, \Closure $builder, $key = null) { $form = new Form\NestedForm($column, $key); $form->setForm($this->form); call_user_func($builder, $form); $form->hidden($this->getKeyName()); $form->hidden(NestedForm::REMOVE_FLAG_NAME)->default...
Build a Nested form. @param string $column @param \Closure $builder @param null $key @return NestedForm
entailment
public function render() { // specify a view to render. $this->view = $this->views[$this->viewMode]; list($template, $script) = $this->buildNestedForm($this->column, $this->builder) ->getTemplateHtmlAndScript(); $this->setupScript($script); return parent::rende...
Render the `HasMany` field. @throws \Exception @return \Illuminate\View\View
entailment
public static function add( $panel_id, $args ) { $panel = static::_panel( $panel_id, $args ); static::$panels[ $panel->get_id() ] = $panel; return $panel; }
Add Panel @param string $panel_id @param array $args @return Panel
entailment
protected function validate(array $data) { $validator = Validator::make($data, $this->rules); if ($validator->fails()) { throw new FormValidationException(trans('dashboard::dashboard.errors.form.validation'), $validator); } }
Validate the form submission. @param array $data @throws FormValidationException
entailment
public function render(string $view, array $data = [], $layout = null): string { $output = $this->fetch($view, $data); // False - will disable use layout file if ($layout === false) { return $output; } return $this->renderContent($output, $data, $layout); }
Render a view, if layout file is setting, will use it. throws RuntimeException if view file does not exist @param string $view @param array $data extract data to view, cannot contain view as a key @param string|null|false $layout Override default layout file @return string @throws \Throwable
entailment
public function handle(Request $request, \Closure $next, ...$args) { if (!Admin::user() || !empty($args)) { return $next($request); } if ($this->checkRoutePermission($request)) { return $next($request); } if (!Admin::user()->allPermissions()->first(f...
Handle an incoming request. @param \Illuminate\Http\Request $request @param \Closure $next @param array $args @return mixed
entailment
protected function collectFields(\Closure $content) { call_user_func($content, $this->form); $all = $this->form->builder()->fields(); $fields = $all->slice($this->offset); $this->offset = $all->count(); return $fields; }
Collect fields under current tab. @param \Closure $content @return Collection
entailment
public function render_content() { ?> <?php if ( ! empty( $this->label ) ) : ?> <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> <?php endif; ?> <?php if ( ! empty( $this->description ) ) : ?> <span class="description customize-control-description"><?php echo esc_html(...
Render the control's content @return void
entailment
protected function getOptions(array $options): array { $options['format'] = array_get($options, 'format', $this->format); $options['locale'] = array_get($options, 'locale', config('app.locale')); return $options; }
@param array $options @return mixed
entailment
public function execute(InputInterface $input, OutputInterface $output) { $excluded = []; if ($input->getOption('exclude')) { $excluded = explode(',', $input->getOption('exclude')); } $io = new OutputStyle($input, $output); $composerPath = $this->getComposerPat...
Execute the command. @param \Symfony\Component\Console\Input\InputInterface $input @param \Symfony\Component\Console\Output\OutputInterface $output @return int
entailment
public function connect() { $this->log->debug("connect"); $host = $this->ipv4_address_for_host($this->host, $this->port); if(!$host) { return FALSE; } // NOTE: This timeout doesn't apply to DNS, but does apply to the actual connecting $this->socket...
TODO: Make private functions private
entailment
public function select($options = []) { $source = []; foreach ($options as $key => $value) { $source[] = [ 'value' => $key, 'text' => $value, ]; } $this->addOptions(['source' => $source]); }
Select type editable. @param array $options
entailment
public function data($data) { if ($data instanceof Arrayable) { $data = $data->toArray(); } $this->data = $data; }
@param $data @deprecated
entailment
public function display($callback = null) { if ($callback instanceof \Closure) { $callback->call($this, $this); } $actions = $this->prepends; if ($this->allowEdit) { array_push($actions, $this->editAction()); } if ($this->allowDelete) { ...
{@inheritdoc}
entailment
public function fill($data) { $this->value = array_get($data, $this->column); if (is_string($this->value)) { $this->value = explode(',', $this->value); } $this->value = array_filter((array) $this->value); }
{@inheritdoc}
entailment
public function prepare($value) { if (is_array($value) && !Arr::isAssoc($value)) { $value = implode(',', array_filter($value)); } return $value; }
{@inheritdoc}
entailment
public function value($value = null) { if (is_null($value)) { return empty($this->value) ? ($this->getDefault() ?? []) : $this->value; } $this->value = $value; return $this; }
Get or set value for this field. @param mixed $value @return $this|array|mixed
entailment
public function sendMessage() { $message = new \CodeMonkeysRu\GCM\Message(); call_user_func_array(array($message, 'bulkSet'), func_get_args()); return $this->send($message); }
Send message to GCM without explicitly created message @param string[] $registrationIds @param array|null $data @param string|null $collapseKey @throws \CodeMonkeysRu\GCM\Exception @return \CodeMonkeysRu\GCM\Response
entailment
public function send(Message $message) { if (!$this->serverApiKey) { throw new Exception("Server API Key not set", Exception::ILLEGAL_API_KEY); } //GCM response: Number of messages on bulk (1001) exceeds maximum allowed (1000) if (count($message->getRegistrationIds()) >...
Send message to GCM @param \CodeMonkeysRu\GCM\Message $message @throws \CodeMonkeysRu\GCM\Exception @return \CodeMonkeysRu\GCM\Response
entailment
private function formMessageData(Message $message) { $data = array( 'registration_ids' => $message->getRegistrationIds(), ); $dataFields = array( 'registration_ids' => 'getRegistrationIds', 'collapse_key' => 'getCollapseKey', 'data' => 'getDat...
Form raw message data for sending to GCM @param \CodeMonkeysRu\GCM\Message $message @return array
entailment
private function validatePayloadSize(array $rawData, $fieldName, $maxSize) { if (!isset($rawData[$fieldName])) { return; } if (strlen(json_encode($rawData[$fieldName])) > $maxSize) { throw new Exception( ucfirst($fieldName)." payload is to big (max {$m...
Validate size of json representation of passed payload @param array $rawData @param string $fieldName @param int $maxSize @throws \CodeMonkeysRu\GCM\Exception @return void
entailment
public function add(array $emails) { if(!empty ($emails) ){ foreach ($emails as $key => $values) { $this->set($key, $values); } } }
Adds new container the current container set. @param array $emails An array of container
entailment
public function get($key, $default = null, $first = true) { if(!is_string($key) && !is_int($key)){ throw new \InvalidArgumentException('$key expected to be string or integer, got: '.gettype($key)); } if (!array_key_exists($key, $this->container)) { if (null === $defa...
Returns a email value by name. @param string $key The email name @param mixed $default The default value @param Boolean $first Whether to return the first value or all email values @return string|array The first email value if $first is true, an array of values otherwise
entailment
public function set($key, $values, $replace = true) { if(!is_string($key) && !is_int($key)){ throw new \InvalidArgumentException('$key expected to be string, got:'.gettype($key)); } if( !is_string($values) && !is_array($values) ){ throw new \InvalidArgumentException(...
Sets a email values. @param string|int $key The key @param string|array $values The value or an array of values @param Boolean $replace Whether to replace the actual value or not (true by default)
entailment
public function getValidator(array $input) { if (!array_key_exists($this->column, $input)) { return false; } $input = array_only($input, $this->column); $rules = $attributes = []; /** @var Field $field */ foreach ($this->buildEmbeddedForm()->fields() as...
{@inheritdoc}
entailment
public function resetInputKey(array &$input, array $column) { $column = array_flip($column); foreach ($input[$this->column] as $key => $value) { if (!array_key_exists($key, $column)) { continue; } $newKey = $key.$column[$key]; /* ...
Reset input key for validation. @param array $input @param array $column $column is the column name array set
entailment
public function getEntries($domain) { $hosts = array(); $weight = array(); getmxrr($domain, $hosts, $weight); // sort MX priorities foreach ($hosts as $k => $host) { $this->mxs[$host] = $weight[$k]; } asort($this->mxs); // add the hos...
Queries the DNS server for domain MX entries @param string $domain The domain MX entries @return array MX hosts and their weights
entailment
public function edit($channelId, $name = null, $position = null, $topic = null) { $channel = $this->show($channelId); $json['name'] = is_null($name) ? $channel['name'] : $name; $json['position'] = is_null($position) ? $channel['position'] : $position; $json['topic'] = is_null($topic)...
Edit a channel. @param string $channelId Required @param string $name Required @param int $position @param string $topic @return array
entailment
public function handle(Request $request, Closure $next, $roles) { $accessDenied = true; if (!$user = $this->auth->getActiveUser()) { Flash::error(trans('dashboard::dashboard.flash.access_denied')); return redirect()->route('auth.login'); } if (!is_array($ro...
Check if user belongs to the specified role. @param Request $request @param Closure $next @param string|array $roles @return \Illuminate\Http\RedirectResponse
entailment
public function handle(Request $request, Closure $next, $permissions) { $accessDenied = true; if (!$user = $this->auth->getActiveUser()) { Flash::error(trans('dashboard::dashboard.flash.access_denied')); return redirect()->back(); } if (!is_array($permissio...
Check if user has permission. @param Request $request @param Closure $next @param string|array $permissions @return \Illuminate\Http\RedirectResponse
entailment
public function render() { if (!$this->grid->allowExport()) { return ''; } $this->setUpScripts(); $export = trans('admin.export'); $all = trans('admin.all'); $currentPage = trans('admin.current_page'); $selectedRows = trans('admin.selected_rows')...
Render Export button. @return string
entailment
public function condition($inputs) { $value = array_get($inputs, $this->column); if (is_array($value)) { $value = array_filter($value); } if (is_null($value) || empty($value)) { return; } $this->value = $value; return $this->buildCo...
Get condition of this filter. @param array $inputs @return array|mixed|void
entailment
public function setOriginal($data, $relatedKeyName) { if (empty($data)) { return $this; } foreach ($data as $value) { /* * like $this->original[30] = [ id = 30, .....] */ $this->original[$value[$relatedKeyName]] = $value; ...
Set original values for fields. @param array $data @param string $relatedKeyName @return $this
entailment
public function options($options = []) { // remote options if (is_string($options)) { return $this->loadRemoteOptions(...func_get_args()); } if ($options instanceof Arrayable) { $options = $options->toArray(); } if (is_callable($options)) { ...
Set options. @param array|callable|string $options @return $this|mixed
entailment
protected function loadRemoteOptions($url, $parameters = [], $options = []) { $ajaxOptions = [ 'url' => $url.'?'.http_build_query($parameters), ]; $ajaxOptions = json_encode(array_merge($ajaxOptions, $options)); $this->script = <<<EOT $.ajax($ajaxOptions).done(function...
Load options from remote. @param string $url @param array $parameters @param array $options @return $this
entailment
protected function databaseSetup() { $this->output->writeln(<<<STEP <fg=yellow> *-----------------------------------------------* | | | Configure Database | | This package uses MySQL Only | | ...
Setup the database credentials. @return void
entailment
protected function databaseSetupPassword() { $pass = $this->secret('Please enter the database password'); $passConfirm = $this->secret('Please confirm the database password'); if ($pass != $passConfirm) { $this->error('[ERROR] Database passwords do not match. Please retry...
Setup the database credentials password. @return string
entailment
protected function userSetup() { $this->output->writeln(<<<STEP <fg=yellow> *-----------------------------------------------* | | | Configure Default User | | | *-------------------------------...
Setup the user credentials. @return void
entailment
protected function userSetupPassword() { $pass = $this->secret('Please enter the user password'); $passConfirm = $this->secret('Please confirm the user password'); if ($pass != $passConfirm) { $this->error('[ERROR] Passwords do not match.'); $this->userSetupPa...
Setup the user credentials password. @return string
entailment
protected function setupEnvFile() { $env = __DIR__ . '/stubs/env.stub'; $config = $this->database; // Update the env stub file with actual credentials. $contents = str_replace( array_map(function ($key) { return '{{' . $key . '}}'; }, array_keys(...
Setup ENV file with database credentials. @return void
entailment
protected function triggerPublish() { $this->info('Starting publishing vendor assets.'); $this->call('vendor:publish'); $this->info('Publishing vendor assets finished.'); // Reload config $this->laravel['Illuminate\Foundation\Bootstrap\LoadConfiguration']->bootstrap($this->l...
Run vendor:publish to publish vendor assets. @return void
entailment
protected function createDefaultUser() { // Get the user configuration data. $config = $this->user; // Create default permission. $this->permissionRepository->create([ 'name' => 'Administrator (Full Access)', 'slug' => 'admin', ], false); // Crea...
Create default Group and User @return void
entailment
protected function setupSeedStubs() { // Get the user configuration data. $config = $this->user; $user = __DIR__ . '/stubs/UserTableSeeder.stub'; $role = __DIR__ . '/stubs/RoleTableSeeder.stub'; $permission = __DIR__ . '/stubs/PermissionTableSeeder.stub'; ...
Setup stub files for seeders. @return void
entailment