sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function resolveCommands($commands) { $commands = is_array($commands) ? $commands : func_get_args(); foreach ($commands as $command) { $this->resolve($command); } }
Resolve an array of commands through the application. @param array|mixed $commands @return void
entailment
public function command($signature, Closure $callback) { $command = new ClosureCommand($signature, $callback); return $this->add($command); }
Register a Closure based command with the application. @param string $signature @param Closure $callback @return \Nova\Console\ClosureCommand
entailment
public function fetch($scratchDir, LoggerInterface $logger) { $logger->info(sprintf('Syncing files from: %s', $this->source)); $process = ProcessBuilder::create($this->options) ->setTimeout($this->timeout) ->setPrefix('rsync') ->add($this->source) ->a...
{@inheritdoc}
entailment
protected function createPdoStatement($query, $pdo = null) { if (is_null($pdo)) { $pdo = $this->getPdo(); } $grammar = $this->getQueryGrammar(); $query = preg_replace_callback('#\{(.*?)\}#', function ($matches) use ($grammar) { $value = $matches[1]; ...
Parse and wrap the variables from query, then return a propared PDO Statement instance. @param string $query @param \PDO $pdo @return \PDOStatement
entailment
public function statement($query, $bindings = array()) { return $this->run($query, $bindings, function ($me, $query, $bindings) { if ($me->pretending()) return true; $bindings = $me->prepareBindings($bindings); // $statement = $me->createPdoStatement...
Execute an SQL statement and return the boolean result. @param string $query @param array $bindings @return bool
entailment
public function affectingStatement($query, $bindings = array()) { return $this->run($query, $bindings, function ($me, $query, $bindings) { if ($me->pretending()) return 0; $bindings = $me->prepareBindings($bindings); // $statement = $me->createPdoSta...
Run an SQL statement and get the number of rows affected. @param string $query @param array $bindings @return int
entailment
public function beginTransaction() { ++$this->transactions; if ($this->transactions == 1) { $this->pdo->beginTransaction(); } $this->fireConnectionEvent('beganTransaction'); }
Start a new database transaction. @return void
entailment
public function commit() { if ($this->transactions == 1) $this->pdo->commit(); --$this->transactions; $this->fireConnectionEvent('committed'); }
Commit the active database transaction. @return void
entailment
protected function run($query, $bindings, Closure $callback) { $this->reconnectIfMissingConnection(); $start = microtime(true); try { $result = $this->runQueryCallback($query, $bindings, $callback); } catch (QueryException $e) { $result = $this->tryA...
Run a SQL statement and log its execution context. @param string $query @param array $bindings @param \Closure $callback @return mixed @throws \Database\QueryException
entailment
public function logQuery($query, $bindings, $time = null) { if (isset($this->events)) { $this->events->dispatch('nova.query', array($query, $bindings, $time, $this->getName())); } if (! $this->loggingQueries) return; $this->queryLog[] = compact('query', 'bindings', 'tim...
Log a query in the connection's query log. @param string $query @param array $bindings @param float|null $time @return void
entailment
protected function fireConnectionEvent($event) { if (isset($this->events)) { $this->events->dispatch('connection.'.$this->getName().'.'.$event, $this); } }
Fire an event for this connection. @param string $event @return void
entailment
public function getDoctrineConnection() { $driver = $this->getDoctrineDriver(); $data = array('pdo' => $this->pdo, 'dbname' => $this->getConfig('database')); return new DoctrineConnection($data, $driver); }
Get the Doctrine DBAL database connection instance. @return \Doctrine\DBAL\Connection
entailment
public function getCacheManager() { if ($this->cache instanceof Closure) { $this->cache = call_user_func($this->cache); } return $this->cache; }
Get the cache manager instance. @return \Nova\Cache\CacheManager
entailment
protected function buildJsonAttributes(array $map): array { $result = []; foreach ($map as $jsonKey => $value) { if ($value !== null) { $result[$jsonKey] = $value; } } return $result; }
@param array $map @return array
entailment
public function register() { $this->registerPresenceVerifier(); $this->app->bindShared('validator', function($app) { $config = $app['config']; // Get a Validation Factory instance. $validator = new Factory($config); if (isset($app['validatio...
Register the Service Provider. @return void
entailment
protected function recreateJob($delay) { $payload = json_decode($this->job->body, true); array_set($payload, 'attempts', array_get($payload, 'attempts', 1) + 1); $this->iron->recreate(json_encode($payload), $this->getQueue(), $delay); }
Release a pushed job back onto the queue. @param int $delay @return void
entailment
public function handle() { $this->info('Gathering Information of Roles'); $permissions = app(Role::class)->pluck(config('artify.permissions_column'))->collapse(); if (!count($permissions)) { return $this->error('Roles are not set yet, or maybe they are not an array.'); } ...
Execute the console command. @return mixed
entailment
public function boot() { Filesystem::macro('getFileName', function ($name) { return array_last(explode('\\', $name)); }); Filesystem::macro('getNamespaceFromLocation', function ($location) { return ucfirst(str_replace('/', '\\', $location)); }); Filesystem::macro('transformNamespaceToLocation', function...
Bootstrap services. @return void
entailment
public function register() { if ($this->app->runningInConsole()) { $this->registerConsoleCommands(); $this->app->singleton(DatabaseMigrationCommand::class, function ($app) { return new DatabaseMigrationCommand($app->make('migrator'), $app->make(DatabaseManager::class)); }); $this->app->singleton(Datab...
Register services. @return void
entailment
public function handle(Job $job, array $data) { $event = unserialize($data['event']); if (method_exists($event, 'broadcastAs')) { $name = $event->broadcastAs(); } else { $name = get_class($event); } if (! is_array($channels = $event->broadcastOn())) ...
Handle the queued job. @param \Nova\Queue\Job $job @param array $data @return void
entailment
protected function getPayloadFromEvent($event) { if (method_exists($event, 'broadcastWith')) { return $event->broadcastWith(); } $payload = array(); // $reflection = new ReflectionClass($event); foreach ($reflection->getProperties(ReflectionProperty::IS...
Get the payload for the given event. @param mixed $event @return array
entailment
public function share(Closure $closure) { return function($container) use ($closure) { // We'll simply declare a static variable within the Closures and if it has // not been set we will execute the given Closures to resolve this value // and return it back to the...
Wrap a Closure such that it is shared. @param \Closure $closure @return \Closure
entailment
public function extend($abstract, Closure $closure) { if (! isset($this->bindings[$abstract])) { throw new \InvalidArgumentException("Type {$abstract} is not bound."); } if (isset($this->instances[$abstract])) { $this->instances[$abstract] = $closure($this->instances...
"Extend" an abstract type in the container. @param string $abstract @param \Closure $closure @return void @throws \InvalidArgumentException
entailment
protected function getExtender($abstract, Closure $closure) { // To "extend" a binding, we will grab the old "resolver" Closure and pass it // into a new one. The old resolver will be called first and the result is // handed off to the "new" resolver, along with this container instance. ...
Get an extender Closure for resolving a type. @param string $abstract @param \Closure $closure @return \Closure
entailment
public function wrap(Closure $callback, array $parameters = array()) { return function () use ($callback, $parameters) { return $this->call($callback, $parameters); }; }
Wrap the given closure such that its dependencies will be injected when executed. @param \Closure $callback @param array $parameters @return \Closure
entailment
public function call($callback, array $parameters = array(), $defaultMethod = null) { if ($this->isCallableWithAtSign($callback) || $defaultMethod) { return $this->callClass($callback, $parameters, $defaultMethod); } $dependencies = $this->getMethodDependencies($callback, $param...
Call the given Closure / class@method and inject its dependencies. @param callable|string $callback @param array $parameters @param string|null $defaultMethod @return mixed
entailment
public function afterResolving($abstract, Closure $callback = null) { if ($abstract instanceof Closure && $callback === null) { $this->afterResolvingCallback($abstract); } else { $this->afterResolvingCallbacks[$abstract][] = $callback; } }
Register a new after resolving callback for all types. @param string $abstract @param \Closure|null $callback @return void
entailment
protected function resolvingCallback(Closure $callback) { $abstract = $this->getFunctionHint($callback); if ($abstract) { $this->resolvingCallbacks[$abstract][] = $callback; } else { $this->globalResolvingCallbacks[] = $callback; } }
Register a new resolving callback by type of its first argument. @param \Closure $callback @return void
entailment
protected function afterResolvingCallback(Closure $callback) { $abstract = $this->getFunctionHint($callback); if ($abstract) { $this->afterResolvingCallbacks[$abstract][] = $callback; } else { $this->globalAfterResolvingCallbacks[] = $callback; } }
Register a new after resolving callback by type of its first argument. @param \Closure $callback @return void
entailment
protected function getFunctionHint(Closure $callback) { $function = new ReflectionFunction($callback); if ($function->getNumberOfParameters() == 0) { return; } $expected = $function->getParameters()[0]; if (! $expected->getClass()) { return; ...
Get the type hint for this closure's first argument. @param \Closure $callback @return mixed
entailment
protected function fireResolvingCallbacks($abstract, $object) { if (isset($this->resolvingCallbacks[$abstract])) { $this->fireCallbackArray($object, $this->resolvingCallbacks[$abstract]); } $this->fireCallbackArray($object, $this->globalResolvingCallbacks); }
Fire all of the resolving callbacks. @param string $abstract @param mixed $object @return void
entailment
protected function fireCallbackArray($object, array $callbacks) { foreach ($callbacks as $callback) { call_user_func($callback, $object, $this); } }
Fire an array of callbacks with an object. @param mixed $object @param array $callbacks
entailment
public function isShared($abstract) { if (isset($this->bindings[$abstract]['shared'])) { $shared = $this->bindings[$abstract]['shared']; } else { $shared = false; } return isset($this->instances[$abstract]) || $shared === true; }
Determine if a given type is shared. @param string $abstract @return bool
entailment
public function getParams(): array { $params = [ 'chat_id' => $this->chatId, 'phone_number' => $this->phoneNumber, 'first_name' => $this->firstName, ]; if ($this->lastName) { $params['last_name'] = $this->lastName; } if ($this...
Get parameters for HTTP query. @return mixed
entailment
public function getParams(): array { $params = [ 'chat_id' => $this->chatId, 'from_chat_id' => $this->fromChatId, 'message_id' => $this->messageId ]; if ($this->disableNotification) { $params['disable_notification'] = (int)$this->disableNotifi...
Get parameters for HTTP query. @return mixed
entailment
public function get($name) { if (!isset($this->profiles[$name])) { throw new \InvalidArgumentException(sprintf('Profile "%s" is not registered.', $name)); } return $this->profiles[$name]; }
@param string $name @return Profile
entailment
public static function plural($value, $count = 2) { if (($count === 1) || static::uncountable($value)) { return $value; } $plural = Inflector::pluralize($value); return static::matchCase($plural, $value); }
Get the plural form of an English word. @param string $value @param int $count @return string
entailment
public function addConstraints() { $parentTable = $this->parent->getTable(); $this->setJoin(); if (static::$constraints) { $this->query->where($parentTable.'.'.$this->firstKey, '=', $this->farParent->getKey()); } }
Set the base constraints on the relation query. @return void
entailment
protected function setJoin(Builder $query = null) { $query = $query ?: $this->query; $foreignKey = $this->related->getTable().'.'.$this->secondKey; $query->join($this->parent->getTable(), $this->getQualifiedParentKeyName(), '=', $foreignKey); }
Set the join clause on the query. @param \Nova\Database\ORM\Builder|null $query @return void
entailment
public function handleException($exception) { if (! $exception instanceof Exception) { $exception = new FatalThrowableError($exception); } $this->getExceptionHandler()->report($exception); if ($this->app->runningInConsole()) { $this->renderForConsole($except...
Handle an exception for the application. @param \Exception $exception @return \Symfony\Component\HttpFoundation\Response
entailment
protected function renderForConsole($e, ConsoleOutput $output = null) { if (is_null($output)) { $output = new ConsoleOutput(); } $this->getExceptionHandler()->renderForConsole($output, $e); }
Render an exception to the console. @param \Exception $e @return void
entailment
protected function parseNamespacedSegments($key) { list($namespace, $item) = explode('::', $key); // If the namespace is registered as a package, we will just assume the group // is equal to the namespace since all packages cascade in this way having // a single file per package, ot...
Parse an array of namespaced segments. @param string $key @return array
entailment
public function handle() { $table = $this->container['config']['queue.connections.database.table']; $tableClassName = Str::studly($table); $fullPath = $this->createBaseMigration($table); $stubPath = __DIR__ .DS . 'stubs' .DS .'jobs.stub'; $stub = str_replace( ...
Execute the console command. @return void
entailment
public function create($type, $options = array(), $content = array(), $segment_opts = array(), $type_opts = array()) { if (!in_array($type, array("regular", "plaintext", "absplit", "rss", "auto"))) { throw new \Exception('the Campaign Type has to be one of "regular", "plaintext", "absplit", "rss", "...
Create a new draft campaign to send. You can not have more than 32,000 campaigns in your account. @link http://apidocs.mailchimp.com/api/2.0/campaigns/create.php @param string $type the Campaign Type has to be one of "regular", "plaintext", "absplit", "rss", "auto" @param array $options @param array $content @param ar...
entailment
public function content($options = array()) { $payload = array( 'cid' => $this->cid, 'options' => $options ); $apiCall = 'campaigns/content'; $data = $this->requestMonkey($apiCall, $payload); $data = json_decode($data, true); if (isset($data['error...
Get the content (both html and text) for a campaign either as it would appear in the campaign archive or as the raw, original content @link http://apidocs.mailchimp.com/api/2.0/campaigns/content.php @param array $options @return array Campaign content @throws MailchimpAPIException
entailment
public function get($filters = array(), $start = 0, $limit = 25, $sort_field = 'create_time', $sort_dir = "DESC") { if (!in_array(strtolower($sort_field), array("create_time", "send_time", "title", "subject"))) throw new \Exception('sort_field has to be one of "create_time", "send_time", "title", "...
Get the list of campaigns and their details matching the specified filters @link http://apidocs.mailchimp.com/api/2.0/campaigns/list.php @param array $filters @param int $start start page @param int $limit limit @param string $sort_field @param string $sort_dir @return array @throws \Exception @throws MailchimpAPIExce...
entailment
public function del() { $payload = array( 'cid' => $this->cid ); $apiCall = 'campaigns/delete'; $data = $this->requestMonkey($apiCall, $payload); $data = json_decode($data, true); if (isset($data['error'])) throw new MailchimpAPIException($data); ...
Delete a campaign. Seriously, "poof, gone!" - be careful! Seriously, no one can undelete these. @link http://apidocs.mailchimp.com/api/2.0/campaigns/delete.php @return boolean @throws MailchimpAPIException
entailment
public function templateContent() { $payload = array( 'cid' => $this->cid ); $apiCall = 'campaigns/template-content'; $data = $this->requestMonkey($apiCall, $payload); $data = json_decode($data, true); if (isset($data['error'])) throw new Mailchimp...
Get the HTML template content sections for a campaign. Note that this will return very jagged, non-standard results based on the template a campaign is using. You only want to use this if you want to allow editing template sections in your application. @link http://apidocs.mailchimp.com/api/2.0/campaigns/template-cont...
entailment
public function schedule($schedule_time, $schedule_time_b = null) { $payload = array( 'cid' => $this->cid, 'schedule_time' => $schedule_time, 'schedule_time_b' => $schedule_time_b ); $apiCall = 'campaigns/schedule'; $data = $this->requestMonkey($apiCal...
Schedule a campaign to be sent in the future @link http://apidocs.mailchimp.com/api/2.0/campaigns/schedule.php @param string $schedule_time @param string $schedule_time_b @return boolean true on success @throws MailchimpAPIException
entailment
public function scheduleBatch($schedule_time, $num_batches = 2, $stagger_mins = 5) { $payload = array( 'cid' => $this->cid, 'schedule_time' => $schedule_time, 'num_batches' => $num_batches, 'stagger_mins' => $stagger_mins ); $apiCall = 'campaigns/s...
Schedule a campaign to be sent in batches sometime in the future. Only valid for "regular" campaigns @link http://apidocs.mailchimp.com/api/2.0/campaigns/schedule-batch.php @param string $schedule_time @param int $num_batches @param int $stagger_mins @return boolean true on success @throws MailchimpAPIException
entailment
public function update($name, $value) { $payload = array( 'cid' => $this->cid, 'name' => $name, 'value' => $value ); $apiCall = 'campaigns/update'; $data = $this->requestMonkey($apiCall, $payload); $data = json_decode($data, true); if (...
Update just about any setting besides type for a campaign that has not been sent @link http://apidocs.mailchimp.com/api/2.0/campaigns/update.php @param string $id the Campaign Id to update @param string $name parameter name @param string $value parameter value @return boolean true on success @throws MailchimpAPIExcept...
entailment
public function hasTable($table) { $sql = $this->grammar->compileTableExists(); $table = $this->connection->getTablePrefix().$table; return count($this->connection->select($sql, array($table))) > 0; }
Determine if the given table exists. @param string $table @return bool
entailment
public function hasColumn($table, $column) { $column = strtolower($column); return in_array($column, array_map('strtolower', $this->getColumnListing($table))); }
Determine if the given table has a given column. @param string $table @param string $column @return bool
entailment
public function getColumnListing($table) { $table = $this->connection->getTablePrefix().$table; $results = $this->connection->select($this->grammar->compileColumnExists($table)); return $this->connection->getPostProcessor()->processColumnListing($results); }
Get the column listing for a given table. @param string $table @return array
entailment
public function drop($table) { $blueprint = $this->createBlueprint($table); $blueprint->drop(); $this->build($blueprint); }
Drop a table from the schema. @param string $table @return \Nova\Database\Schema\Blueprint
entailment
public function dropIfExists($table) { $blueprint = $this->createBlueprint($table); $blueprint->dropIfExists(); $this->build($blueprint); }
Drop a table from the schema if it exists. @param string $table @return \Nova\Database\Schema\Blueprint
entailment
protected function createBlueprint($table, Closure $callback = null) { if (isset($this->resolver)) { return call_user_func($this->resolver, $table, $callback); } return new Blueprint($table, $callback); }
Create a new command set with a Closure. @param string $table @param \Closure $callback @return \Nova\Database\Schema\Blueprint
entailment
protected function execute(InputInterface $input, OutputInterface $output) { $registry = $this->getBackupHelper()->getProfileRegistry(); if (!$profile = $input->getArgument('profile')) { $this->listProfiles($output, $registry); return; } $this->doExecute($r...
{@inheritdoc}
entailment
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $httpHandler = $request->getAttribute(AttributeEnum::ROUTER_ATTRIBUTE); /* @var HandlerAdapter $handlerAdapter */ $handlerAdapter = App::getBean('httpHandlerAdapter'); re...
execute action @param \Psr\Http\Message\ServerRequestInterface $request @param \Psr\Http\Server\RequestHandlerInterface $handler @return \Psr\Http\Message\ResponseInterface @throws \Swoft\Exception\InvalidArgumentException @throws \Swoft\Http\Server\Exception\RouteNotFoundException @throws \Swoft\Http\Server\Exceptio...
entailment
public function compileCreate(Blueprint $blueprint, Fluent $command) { $columns = implode(', ', $this->getColumns($blueprint)); $sql = 'create table '.$this->wrapTable($blueprint)." ($columns"; // SQLite forces primary keys to be added when the table is initially created // so we w...
Compile a create table command. @param \Nova\Database\Schema\Blueprint $blueprint @param \Nova\Support\Fluent $command @return string
entailment
protected function addForeignKeys(Blueprint $blueprint) { $sql = ''; $foreigns = $this->getCommandsByName($blueprint, 'foreign'); // Once we have all the foreign key commands for the table creation statement // we'll loop through each of them and add them to the create table SQL we...
Get the foreign key syntax for a table creation statement. @param \Nova\Database\Schema\Blueprint $blueprint @return string|null
entailment
protected function getForeignKey($foreign) { $on = $this->wrapTable($foreign->on); // We need to columnize the columns that the foreign key is being defined for // so that it is a properly formatted list. Once we have done this, we can // return the foreign key SQL declaration to th...
Get the SQL for the foreign key. @param \Nova\Support\Fluent $foreign @return string
entailment
protected function addPrimaryKeys(Blueprint $blueprint) { $primary = $this->getCommandByName($blueprint, 'primary'); if (! is_null($primary)) { $columns = $this->columnize($primary->columns); return ", primary key ({$columns})"; } }
Get the primary key syntax for a table creation statement. @param \Nova\Database\Schema\Blueprint $blueprint @return string|null
entailment
public function handle() { $daemon = $this->option('daemon'); if ($this->downForMaintenance() && ! $daemon) { return; } // We'll listen to the processed and failed events so we can write information // to the console as jobs are processed, which will let the dev...
Execute the console command. @return void
entailment
protected function listenForEvents() { $events = $this->container['events']; $events->listen('nova.queue.processing', function ($connection, $job) { $this->writeOutput($job, 'starting'); }); $events->listen('nova.queue.processed', function ($connection, $job) ...
Listen for the queue events in order to update the console output. @return void
entailment
protected function runWorker($connection, $queue, $delay, $memory, $daemon = false) { $this->worker->setDaemonExceptionHandler( $this->container['Nova\Foundation\Exceptions\HandlerInterface'] ); $sleep = $this->option('sleep'); $tries = $this->option('tries'); i...
Run the worker instance. @param string $connection @param string $queue @param int $delay @param int $memory @param bool $daemon @return array
entailment
protected function writeStatus(Job $job, $status, $type) { $date = Carbon::now()->format('Y-m-d H:i:s'); $message = sprintf("<{$type}>[%s] %s</{$type}> %s", $date, str_pad("{$status}:", 11), $job->resolveName()); $this->output->writeln($message); }
Format the status output for the queue worker. @param \Illuminate\Contracts\Queue\Job $job @param string $status @param string $type @return void
entailment
public function provideSymfonyService($name, $symfonyName = null) { if (null === $symfonyName) { $symfonyName = $name; } if (parent::offsetExists($name)) { throw new \LogicException(sprintf('Service %s has already been defined.', $name)); } $this->de...
Provide a symfony service in this container. @param string $name The name of the service. @param null|string $symfonyName The name of the service in the symfony container (if not equal). @return void @throws \LogicException When the service being set is already contained in the DIC.
entailment
public function offsetSet($id, $value) { if (isset($this->delegates[$id])) { throw new \LogicException(sprintf('Service %s has been delegated to symfony, cannot set.', $id)); } // @codingStandardsIgnoreStart @trigger_error( 'get service: The pimple based DIC i...
Sets a parameter or an object. Objects must be defined as Closures. Allowing any PHP callable leads to difficult to debug problems as function names (strings) are callable (creating a function with the same a name as an existing parameter would break your container). @param string $id The unique identifier for th...
entailment
public function offsetGet($id) { if (isset($this->delegates[$id])) { // @codingStandardsIgnoreStart @trigger_error( sprintf( 'getting service "%1$s" via pimple based DIC is deprecated, use the symfony service "%2$s"', $id, ...
Gets a parameter or an object. @param string $id The unique identifier for the parameter or object. @return mixed The value of the parameter or an object. @throws \InvalidArgumentException If the identifier is not defined. @SuppressWarnings(PHPMD.ShortVariableName)
entailment
public function offsetExists($id) { if (isset($this->delegates[$id])) { return true; } // @codingStandardsIgnoreStart @trigger_error( 'isset service: The pimple based DIC is deprecated, use the symfony DIC in new projects.', E_USER_DEPRECATED ...
Checks if a parameter or an object is set. @param string $id The unique identifier for the parameter or object. @return bool @SuppressWarnings(PHPMD.ShortVariableName)
entailment
public function offsetUnset($id) { if (isset($this->delegates[$id])) { throw new \LogicException(sprintf('Service %s has been delegated to symfony, cannot unset.', $id)); } // @codingStandardsIgnoreStart @trigger_error( 'unset service: The pimple based DIC is ...
Unset a parameter or an object. @param string $id The unique identifier for the parameter or object. @return void @throws \LogicException When the service being unset is delegated to the symfony DIC. @SuppressWarnings(PHPMD.ShortVariableName)
entailment
public function process(ActionInterface $action, EntryCollection $collection) { $users = $this->getUsers(); foreach ($users as $user) { $collection->add(new EntryUnaware(\get_class($user[0]), $user[0]->getId()), 'SONATA_ADMIN'); } }
{@inheritdoc}
entailment
protected function getUsers() { $qb = $this->registry->getManager()->createQueryBuilder(); $qb ->select('u') ->from($this->userClass, 'u') ->where($qb->expr()->like('u.roles', ':roles')) ->setParameter('roles', '%"ROLE_SUPER_ADMIN"%'); return...
Returns corresponding users. @return \Doctrine\ORM\Internal\Hydration\IterableResult
entailment
public function handle() { $pattern = storage_path('logs') .DS .'*.log'; $files = $this->files->glob($pattern); foreach ($files as $file) { $this->files->delete($file); } $this->info('Log files cleared successfully!'); }
Execute the console command. @author Sang Nguyen
entailment
public function getParams(): array { $params = [ 'chat_id' => $this->chatId, 'voice' => $this->voice, ]; $params = array_merge($params, $this->buildJsonAttributes([ 'duration' => $this->duration, 'disable_notification' => $this->disableNotific...
Get parameters for HTTP query. @return mixed
entailment
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { /* @var \Swoft\Http\Server\Parser\RequestParserInterface $requestParser */ $requestParser = App::getBean('requestParser'); $request = $requestParser->parse($request); ...
do process @param \Psr\Http\Message\ServerRequestInterface $request @param \Psr\Http\Server\RequestHandlerInterface $handler @return \Psr\Http\Message\ResponseInterface
entailment
public function registerPolicies(GateContract $gate) { foreach ($this->policies as $key => $value) { $gate->policy($key, $value); } }
Register the application's policies. @param \Nova\Contracts\Auth\Access\Gate $gate @return void
entailment
protected function registerRepository() { $this->app->bindShared('migration.repository', function($app) { $table = $app['config']['database.migrations']; return new DatabaseMigrationRepository($app['db'], $table); }); }
Register the migration repository service. @return void
entailment
protected function registerMakeCommand() { $this->app->bindShared('migration.creator', function($app) { return new MigrationCreator($app['files']); }); $this->app->bindShared('command.migrate.make', function($app) { $creator = $app['migration.creator'...
Register the "install" migration command. @return void
entailment
public function up() { Schema::create(config('actionlog.action_logs_table'), function (Blueprint $table) { $table->engine = "InnoDB COMMENT='用户操作记录表'"; $table->increments('id'); $table->integer(config('actionlog.user_foreign_key')) ->unsigned() ...
Run the migrations. @return void
entailment
protected function registerPackageAssets($package, $namespace, $path) { $assets = $path .DS .'Assets'; if ($this->app['files']->isDirectory($assets)) { $namespace = 'modules/' .str_replace('_', '-', $namespace); $this->app['assets.dispatcher']->package($package, $assets, $n...
Register the package's assets. @param string $package @param string $namespace @param string $path @return void
entailment
public function boot() { $events = $this->app->make(Dispatcher::class); $this->registerEventListeners($events); if ($this->app->bound(Kernel::class)) { $kernel = $this->app->make(Kernel::class); $router = $this->app->make(Router::class); $this->registerR...
{@inheritdoc}
entailment
public function format($change = false) { // lower case values only $change = strtolower($change); // if set, attempt to change format if ($change){ switch($change){ // allowed formats, change to new format case "xml": case "json": $this->format = $change; break; // other form...
Return or change the output format (returned by VATSIM) @param string $change json|xml @return string current format or bool false (unable to set format)
entailment
public function signature($signature, $private_key = false) { $signature = strtoupper($signature); // RSA-SHA1 public key/private key encryption if ($signature == 'RSA' || $signature == 'RSA-SHA1') { // private key must be provided if (!$private_key){ return false; } // signature met...
Set the signing method to be used to encrypt request signature. @param string $signature Signature encryption method: RSA|HMAC @param string $private_key openssl RSA private key (only needed if using RSA) @return boolean true if able to use this signing type
entailment
public function requestToken($return_url=false, $allow_sus=false, $allow_ina=false) { // signature method must have been set if (!$this->signature){ return false; } // if the return URL isn't specified, assume this file (though don't consider GET data) if (!$return_url){ // using https or http? ...
Request a login token from VATSIM (required to send someone for an SSO login) @param string $return_url URL for VATSIM to return memers to after login @param boolean $allow_sus true to allow suspended VATSIM accounts to log in @param boolean $allow_ina true to allow inactive VATSIM accounts to log...
entailment
public function sendToVatsim() { // a token must have been returned to redirect this user if (!$this->token){ return false; } // redirect to the SSO login location, appending the token return $this->base . $this->loc_login . $this->token->key; }
Redirect the user to VATSIM to log in/confirm login @return boolean false if failed
entailment
public function checkLogin($tokenKey, $tokenSecret, $tokenVerifier) { $this->token = new Consumer($tokenKey, $tokenSecret); // the location to send a cURL request to to obtain this user's details $returnUrl = $this->base.$this->loc_api.$this->loc_return.$this->format.'/'; // generate a token request ca...
Obtains a user's login details from a token key and secret @param string $tokenKey The token key provided by VATSIM @param secret $tokenSecret The secret associated with the token @return object|false false if error, otherwise returns user details
entailment
private function curlRequest($url, $requestString) { // using cURL to post the request to VATSIM $ch = curl_init(); // configure the post request to VATSIM curl_setopt_array($ch, array( CURLOPT_URL => $url, // the url to make the request to CURLOPT_RETURNTRANSFER => 1, // do not output the returned ...
Perform a (post) cURL request @param type $url Destination of request @param type $requestString Query string of data to be posted @return boolean true if able to make request
entailment
public function createDuplicateType($new_id = NULL) { $duplicate = parent::createDuplicate(); if (!empty($new_id)) { $duplicate->id = $new_id; $duplicate->label = "Duplicate. " . $duplicate->label; } return $duplicate; }
{@inheritdoc}
entailment
public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); if ($update) { // Clear the cached field definitions as some settings affect the field // definitions. $this->entityManager()->clearCachedFieldDefinitions(); } }
{@inheritdoc}
entailment
public static function postDelete(EntityStorageInterface $storage, array $entities) { parent::postDelete($storage, $entities); // Clear the site_commerce type cache to reflect the removal. $storage->resetCache(array_keys($entities)); }
{@inheritdoc}
entailment
public function register() { $this->app['vatsimoauth'] = $this->app->share(function($app) { return new SSO( $app['config']->get('sso::base'), // base $app['config']->get('sso::key'), // key $app['config']->get('sso::secret'), // secret $app['config']->get('sso::method'), // method $...
Register the service provider. @return void
entailment
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element = []; $element['visible'] = array( '#type' => 'select', '#title' => $this->t('Display field'), '#options' => array('0' => $this->t('Disallow'), '1' => $t...
{@inheritdoc}
entailment
public function edit(Listener $listener) { $eloquent = Auth::user(); $form = $this->presenter->password($eloquent); return $listener->showPasswordChanger(['eloquent' => $eloquent, 'form' => $form]); }
Get password information. @param \Orchestra\Contracts\Foundation\Listener\Account\PasswordUpdater $listener @return mixed
entailment
public function update(Listener $listener, array $input) { $user = Auth::user(); if (! $this->validateCurrentUser($user, $input)) { return $listener->abortWhenUserMismatched(); } $validation = $this->validator->on('changePassword')->with($input); if ($validatio...
Update password information. @param \Orchestra\Contracts\Foundation\Listener\Account\PasswordUpdater $listener @param array $input @return mixed
entailment
public function create(Listener $listener) { $eloquent = Foundation::make('orchestra.user'); $form = $this->presenter->profile($eloquent, 'orchestra::register'); $form->extend(function ($form) { $form->submit = 'orchestra/foundation::title.register'; }); $this->...
View registration page. @param \Orchestra\Contracts\Foundation\Listener\Account\ProfileCreator $listener @return mixed
entailment
public function store(Listener $listener, array $input) { $temporaryPassword = null; $password = $input['password'] ?? null; if (empty($password)) { $password = $temporaryPassword = \resolve(GenerateRandomPassword::class)(); } $validation = $this->validator->on(...
Create a new user. @param \Orchestra\Contracts\Foundation\Listener\Account\ProfileCreator $listener @param array $input @return mixed
entailment
protected function notifyCreatedUser(Listener $listener, Eloquent $user, ?string $temporaryPassword) { try { $user->sendWelcomeNotification($temporaryPassword); } catch (Exception $e) { return $listener->profileCreatedWithoutNotification(); } return $listener...
Send new registration e-mail to user. @param \Orchestra\Contracts\Foundation\Listener\Account\ProfileCreator $listener @param \Orchestra\Model\User $user @param string|null $temporaryPassword @return mixed
entailment
protected function saving(Eloquent $user, array $input, $password) { $user->setAttribute('email', $input['email']); $user->setAttribute('fullname', $input['fullname']); $user->setAttribute('password', $password); $this->fireEvent('creating', [$user]); $this->fireEvent('savin...
Saving new user. @param \Orchestra\Model\User $user @param array $input @param string $password @return void
entailment