sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
protected function registerServiceProvider($properties)
{
$namespace = $this->resolveNamespace($properties);
$name = Str::studly(
isset($properties['type']) ? $properties['type'] : 'package'
);
// The main service provider from a package should be named like:
//... | Register the Package Service Provider.
@param array $properties
@return void
@throws \Nova\Packages\FileMissingException | entailment |
public function dispatch($command)
{
if (! is_null($this->queueResolver) && $this->commandShouldBeQueued($command)) {
return $this->dispatchToQueue($command);
} else {
return $this->dispatchNow($command);
}
} | Dispatch a command to its appropriate handler.
@param mixed $command
@return mixed | entailment |
public function dispatchNow($command, $handler = null)
{
if (! is_null($handler) || ! is_null($handler = $this->getCommandHandler($command))) {
$callback = function ($command) use ($handler)
{
return $handler->handle($command);
};
}
// The... | Dispatch a command to its appropriate handler in the current process.
@param mixed $command
@param mixed $handler
@return mixed | entailment |
public function getCommandHandler($command)
{
$key = get_class($command);
if (array_key_exists($key, $this->handlers)) {
$handler = $this->handlers[$key];
return $this->container->make($handler);
}
} | Retrieve the handler for a command.
@param mixed $command
@return bool|mixed | entailment |
protected function detectWebEnvironment($environments)
{
// If the given environment is just a Closure, we will defer the environment check
// to the Closure the developer has provided, which allows them to totally swap
// the webs environment detection logic with their own custom Closure's ... | Set the application environment for a web request.
@param array|string $environments
@return string | entailment |
public function handle()
{
$type = $this->option('type');
if (! in_array($type, array('module', 'theme', 'package'))) {
return $this->error('Invalid package type specified.');
}
$name = $this->argument('name');
if (strpos($name, '/') > 0) {
list ($v... | Execute the console command.
@return mixed | entailment |
private function stepOne($type)
{
$input = $this->ask('Please enter the name of the Package:', $this->data['name']);
if (Str::length($input) > 3) {
$name = Str::studly($input);
} else {
$name = Str::upper($input);
}
$this->data['name'] = $name;
... | Step 1: Configure Package.
@param string $type
@return mixed | entailment |
protected function generate($type)
{
$slug = $this->data['slug'];
if ($type == 'module') {
$path = $this->getModulePath($slug);
} else if ($type == 'theme') {
$path = $this->getThemePath($slug);
} else {
$path = $this->getPackagePath($slug);
... | Generate the Package. | entailment |
protected function generateFolders($type)
{
$slug = $this->data['slug'];
if ($type == 'module') {
$path = $this->packages->getModulesPath();
$packagePath = $this->getModulePath($slug);
$mode = 'module';
} else if ($type == 'theme') {
$path =... | Generate defined Package folders.
@param string $type
@return void | entailment |
protected function generateFiles($type)
{
if ($type == 'module') {
$mode = 'module';
$this->data['type'] = 'Module';
$this->data['lower_type'] = 'module';
} else if ($type == 'theme') {
$mode = 'theme';
$this->data['type'] = '... | Generate defined Package files.
@param string $type
@return void | entailment |
protected function generateGitkeep($type)
{
$slug = $this->data['slug'];
if ($type == 'module') {
$packagePath = $this->getModulePath($slug);
$mode = 'module';
} else if ($type == 'theme') {
$packagePath = $this->getThemePath($slug);
$mode =... | Generate .gitkeep files within generated folders.
@param string $type
@return void | entailment |
protected function updateComposerJson($type)
{
// If the generated package is a Module.
if ($type == 'module') {
$namespace = 'Modules\\';
$directory = 'modules/';
}
// If the generated package is a Theme.
else if ($type == 'theme') {
$na... | Update the composer.json and run the Composer.
@param string $type
@return void | entailment |
protected function getPackagePath($slug = null)
{
if (! is_null($slug)) {
return $this->packages->getPackagePath($slug);
}
return $this->packages->getPackagesPath();
} | Get the path to the Package.
@param string $slug
@return string | entailment |
protected function getModulePath($slug = null)
{
if (! is_null($slug)) {
return $this->packages->getModulePath($slug);
}
return $this->packages->getModulesPath();
} | Get the path to the Package.
@param string $slug
@return string | entailment |
protected function getThemePath($slug = null)
{
if (! is_null($slug)) {
return $this->packages->getThemePath($slug);
}
return $this->packages->getThemesPath();
} | Get the path to the Package.
@param string $slug
@return string | entailment |
protected function getDestinationFile($file, $packagePath)
{
$slug = $this->data['slug'];
return $packagePath .$this->formatContent($file);
} | Get destination file.
@param string $file
@param string $packagePath
@return string | entailment |
protected function getStubContent($key, $mode)
{
$packageStubs = $this->packageStubs[$mode];
//
$stub = $packageStubs[$key];
$path = __DIR__ .DS .'stubs' .DS .$stub .'.stub';
$content = $this->files->get($path);
return $this->formatContent($content);
} | Get stub content by key.
@param int $key
@param bool $mode
@return string | entailment |
public function dispatch(...$params): ResponseInterface
{
/**
* @var RequestInterface $request
* @var ResponseInterface $response
*/
list($request, $response) = $params;
try {
// before dispatcher
$this->beforeDispatch($request, $response);... | Do dispatcher
@param array ...$params
@return \Psr\Http\Message\ResponseInterface
@throws \InvalidArgumentException | entailment |
protected function beforeDispatch(RequestInterface $request, ResponseInterface $response)
{
RequestContext::setRequest($request);
RequestContext::setResponse($response);
// Trigger 'Before Request' event
App::trigger(HttpServerEvent::BEFORE_REQUEST);
} | before dispatcher
@param RequestInterface $request
@param ResponseInterface $response
@throws \InvalidArgumentException | entailment |
protected function afterDispatch($response)
{
if (!$response instanceof Response) {
$response = RequestContext::getResponse()->auto($response);
}
// Handle Response
$response->send();
// Release system resources
App::trigger(AppEvent::RESOURCE_RELEASE);
... | If $response is not an instance of Response,
usually return by Action of Controller,
then the auto() method will format the result
and return a suitable response
@param mixed $response
@throws \InvalidArgumentException | entailment |
public function getHeader($name)
{
$key = strtolower($name);
if (isset($this->responseHeader[$key])) {
if (!isset($this->responseHeader[$key]['name']) &&
is_array($this->responseHeader[$key])) {
$values = array();
foreach ($this->respons... | Recupera o valor um campo de cabeçalho da resposta HTTP.
@param string $name Nome do campo de cabeçalho.
@return string O valor do campo ou NULL se não estiver existir. | entailment |
public function getHeaderDate($name)
{
$date = $this->getHeader($name);
if (!is_null($date) && !empty($date)) {
return strtotime($date);
}
} | Recupera um valor como unix timestamp de um campo de cabeçalho da resposta HTTP.
@param string $name Nome do campo de cabeçalho.
@return int UNIX Timestamp ou NULL se não estiver definido. | entailment |
public function setRawResponse($response)
{
$parts = explode("\r\n\r\n", $response);
if (count($parts) == 2) {
$matches = array();
$this->responseBody = $parts[1];
if (preg_match_all(
'/(HTTP\/[1-9]\.[0-9]\s+(?<statusCode>\d+)\s+(?<statusMessage>... | Define a resposta da requisição HTTP.
@param string $response Toda a resposta da requisição
@param \Moip\Http\CookieManager | entailment |
public function pop($queue = null)
{
$original = $queue ?: $this->default;
$queue = $this->getQueue($queue);
if ( ! is_null($this->expire)) {
$this->migrateAllExpiredJobs($queue);
}
$job = $this->getConnection()->lpop($queue);
if ( ! is_null($job)) {
... | Pop the next job off of the queue.
@param string $queue
@return \Nova\Queue\Jobs\Job|null | entailment |
public function deleteReserved($queue, $job)
{
$this->getConnection()->zrem($this->getQueue($queue).':reserved', $job);
} | Delete a reserved job from the queue.
@param string $queue
@param string $job
@return void | entailment |
public function migrateExpiredJobs($from, $to)
{
$options = ['cas' => true, 'watch' => $from, 'retry' => 10];
$this->getConnection()->transaction($options, function ($transaction) use ($from, $to)
{
// First we need to get all of jobs that have expired based on the current time
... | Migrate the delayed jobs that are ready to the regular queue.
@param string $from
@param string $to
@return void | entailment |
protected function removeExpiredJobs($transaction, $from, $time)
{
$transaction->multi();
$transaction->zremrangebyscore($from, '-inf', $time);
} | Remove the expired jobs from a given queue.
@param \Predis\Transaction\MultiExec $transaction
@param string $from
@param int $time
@return void | entailment |
public function get($name)
{
try {
return \strpos($name, '.') === false
? parent::get($name)
: $this->getRecursive($name);
} catch (NotFoundException $exception) {
throw new ContainerValueNotFoundException(
\sprintf('No entry or... | Returns an entry of the container by its name.
@see \DI\Container::get
@param string $name
@throws ContainerValueNotFoundException
@throws ContainerException
@return mixed | entailment |
public function has($name)
{
if (\strpos($name, '.') === false) {
return parent::has($name);
}
try {
$this->getRecursive($name);
} catch (\Throwable $exception) {
return false;
}
return true;
} | Test if the container can provide something for the given name.
@see \DI\Container::has
@param string $name
@throws \InvalidArgumentException
@return mixed | entailment |
private function getRecursive(string $key, array $parent = null)
{
if ($parent !== null ? \array_key_exists($key, $parent) : parent::has($key)) {
return $parent !== null ? $parent[$key] : parent::get($key);
}
$keySegments = \explode('.', $key);
$keyParts = [];
w... | @param string $key
@param array|null $parent
@throws NotFoundException
@return mixed | entailment |
public function showAction(Request $request, $slug)
{
$query = trim(strtolower(strip_tags($request->get('query', ''))));
$search = null;
// if we have a slug - there was a search before
if ($slug) {
/** @var \Genj\FaqBundle\Entity\Search $search */
$search =... | shows search results for previous queries
@param Request $request
@param string $slug
@return \Symfony\Component\HttpFoundation\Response | entailment |
public function listMostPopularAction($max = 3)
{
$queries = $this->getSearchRepository()->retrieveMostPopular($max);
return $this->render(
'GenjFaqBundle:Search:list_most_popular.html.twig',
array(
'queries' => $queries,
'max' => $max
... | list most popular search queries based on searchCount
@param int $max
@return \Symfony\Component\HttpFoundation\Response | entailment |
public function handle()
{
$type = $this->option('type');
if (! is_null($type) && ! in_array($type, array('package', 'module', 'theme'))) {
return $this->error("Invalid Packages type [$type].");
}
$packages = $this->getPackages($type);
if (empty($packages)) {
... | Execute the console command.
@return mixed | entailment |
protected function getPackages($type)
{
$packages = $this->packages->all();
if (! is_null($type)) {
$packages = $packages->where('type', $type);
}
$results = array();
foreach ($packages->sortBy('basename') as $package) {
$results[] = $this->getPacka... | Get all Packages.
@return array | entailment |
protected function getPackageInformation($package)
{
$location = ($package['location'] === 'local') ? 'Local' : 'Vendor';
$type = Str::title($package['type']);
if ($this->packages->isEnabled($package['slug'])) {
$status = 'Enabled';
} else {
$status = 'Disab... | Returns Package manifest information.
@param string $package
@return array | entailment |
protected function resolveByPath($filePath)
{
$this->data['filename'] = $this->makeFileName($filePath);
$this->data['namespace'] = $this->getNamespace($filePath);
$this->data['path'] = $this->getBaseNamespace();
$this->data['className'] = basename($filePath);
//
$... | Resolve Container after getting file path.
@param string $filePath
@return array | entailment |
public function driver($driver = null)
{
$driver = $driver ?: $this->getDefaultDriver();
if (! isset($this->drivers[$driver])) {
$this->drivers[$driver] = $this->createDriver($driver);
}
return $this->drivers[$driver];
} | Get a driver instance.
@param string $driver
@return mixed | entailment |
protected function compileEchos($value)
{
$difference = strlen($this->contentTags[0]) - strlen($this->escapedTags[0]);
if ($difference > 0) {
return $this->compileEscapedEchos($this->compileRegularEchos($value));
}
return $this->compileRegularEchos($this->compileEscaped... | Compile Template echos into valid PHP.
@param string $value
@return string | entailment |
protected function compileStatements($value)
{
$callback = function($match)
{
if (method_exists($this, $method = 'compile' .ucfirst($match[1]))) {
$match[0] = call_user_func(array($this, $method), Arr::get($match, 3));
}
return isset($match[3]) ? ... | Compile Template Statements that start with "@"
@param string $value
@return mixed | entailment |
protected function compileRegularEchos($value)
{
$pattern = sprintf('/(@)?%s\s*(.+?)\s*%s(\r?\n)?/s', $this->contentTags[0], $this->contentTags[1]);
$callback = function($matches)
{
$whitespace = empty($matches[3]) ? '' : $matches[3] .$matches[3];
return $matches[1]... | Compile the "regular" echo statements.
@param string $value
@return string | entailment |
protected function compileExtends($expression)
{
$expression = $this->stripParentheses($expression);
$data = "<?php echo \$__env->make($expression, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
$this->footer[] = $data;
return '';
} | Compile the extends statements into valid PHP.
@param string $expression
@return string | entailment |
public function stripParentheses($expression)
{
if (Str::startsWith($expression, '(') && Str::endsWith($expression, ')')) {
$expression = substr($expression, 1, -1);
}
return $expression;
} | Strip the parentheses from the given expression.
@param string $expression
@return string | entailment |
public function getOptions(array $config)
{
$options = array_get($config, 'options', array());
return array_diff_key($this->options, $options) + $options;
} | Get the PDO options based on the configuration.
@param array $config
@return array | entailment |
public function createConnection($dsn, array $config, array $options)
{
$username = array_get($config, 'username');
$password = array_get($config, 'password');
return new PDO($dsn, $username, $password, $options);
} | Create a new PDO connection.
@param string $dsn
@param array $config
@param array $options
@return PDO | entailment |
public function push($filename, LoggerInterface $logger)
{
$destination = $this->createPath($filename);
$logger->info(sprintf('Uploading %s to: %s', $filename, $destination));
$process = ProcessBuilder::create($this->options)
->setPrefix(array('s3cmd', 'put'))
->add... | {@inheritdoc} | entailment |
public function get($key)
{
$destination = $this->createPath($key);
$process = ProcessBuilder::create($this->options)
->setPrefix(array('s3cmd', 'info'))
->add($destination)
->setTimeout($this->timeout)
->getProcess();
$process->run();
... | {@inheritdoc} | entailment |
public function all()
{
$process = ProcessBuilder::create($this->options)
->setPrefix(array('s3cmd', 'ls'))
->add(trim($this->bucket, '/').'/')
->setTimeout($this->timeout)
->getProcess();
$process->run();
if (!$process->isSuccessful()) {
... | {@inheritdoc} | entailment |
private function parseS3CmdListOutput($output)
{
$backups = array();
if (null === $output) {
return $backups;
}
foreach (explode("\n", $output) as $row) {
if ('' === $row) {
continue;
}
$backups[] = $this->parseS3CmdL... | @param string $output
@return Backup[] | entailment |
private function parseS3CmdListRow($row)
{
$columns = explode(' ', preg_replace('/\s+/', ' ', $row));
if (4 !== count($columns)) {
throw new \RuntimeException(sprintf('Error processing result: %s', $row));
}
return new Backup($columns[3], $columns[2], new \DateTime(spri... | @param string
@return Backup | entailment |
public function findMany($ids, $columns = array('*'))
{
if (empty($ids)) {
return $this->model->newCollection();
}
$keyName = $this->model->getQualifiedKeyName();
$this->query->whereIn($keyName, $ids);
return $this->get($columns);
} | Find a model by its primary key.
@param array $ids
@param array $columns
@return \Nova\Database\ORM\Model|Collection|static | entailment |
public function get($columns = array('*'))
{
$models = $this->getModels($columns);
if (count($models) > 0) {
$models = $this->eagerLoadRelations($models);
}
return $this->model->newCollection($models);
} | Execute the query as a "select" statement.
@param array $columns
@return \Nova\Database\ORM\Collection|static[] | entailment |
public function paginate($perPage = null, $columns = array('*'), $pageName = 'page', $page = null)
{
if (is_null($page)) {
$page = Paginator::resolveCurrentPage($pageName);
}
$path = Paginator::resolveCurrentPath($pageName);
if (is_null($perPage)) {
$perPage... | Paginate the given query.
@param int $perPage
@param array $columns
@param string $pageName
@param int|null $page
@return \Nova\Pagination\Paginator
@throws \InvalidArgumentException | entailment |
public function simplePaginate($perPage = null, $columns = array('*'), $pageName = 'page', $page = null)
{
if (is_null($page)) {
$page = Paginator::resolveCurrentPage($pageName);
}
$path = Paginator::resolveCurrentPath($pageName);
if (is_null($perPage)) {
$p... | Paginate the given query into a simple paginator.
@param int $perPage
@param array $columns
@param string $pageName
@param int|null $page
@return \Nova\Pagination\SimplePaginator | entailment |
public function increment($column, $amount = 1, array $extra = array())
{
$extra = $this->addUpdatedAtColumn($extra);
return $this->query->increment($column, $amount, $extra);
} | Increment a column's value by a given amount.
@param string $column
@param int $amount
@param array $extra
@return int | entailment |
public function decrement($column, $amount = 1, array $extra = array())
{
$extra = $this->addUpdatedAtColumn($extra);
return $this->query->decrement($column, $amount, $extra);
} | Decrement a column's value by a given amount.
@param string $column
@param int $amount
@param array $extra
@return int | entailment |
protected function addUpdatedAtColumn(array $values)
{
if (! $this->model->usesTimestamps()) return $values;
$column = $this->model->getUpdatedAtColumn();
return array_add($values, $column, $this->model->freshTimestampString());
} | Add the "updated at" column to an array of values.
@param array $values
@return array | entailment |
public function delete()
{
if (isset($this->onDelete)) {
return call_user_func($this->onDelete, $this);
}
return $this->query->delete();
} | Delete a record from the database.
@return mixed | entailment |
protected function loadRelation(array $models, $name, Closure $constraints)
{
$relation = $this->getRelation($name);
$relation->addEagerConstraints($models);
call_user_func($constraints, $relation);
$models = $relation->initRelation($models, $name);
$results = $relation->... | Eagerly load the relationship on a set of models.
@param array $models
@param string $name
@param \Closure $constraints
@return array | entailment |
public function getRelation($relation)
{
$query = Relation::noConstraints(function() use ($relation)
{
return $this->getModel()->$relation();
});
$nested = $this->nestedRelations($relation);
if (count($nested) > 0) {
$query->getQuery()->with($nested)... | Get the relation instance for the given relation name.
@param string $relation
@return \Nova\Database\ORM\Relations\Relation | entailment |
protected function isNested($name, $relation)
{
$dots = str_contains($name, '.');
return $dots && Str::startsWith($name, $relation.'.');
} | Determine if the relationship is nested.
@param string $name
@param string $relation
@return bool | entailment |
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null)
{
if (strpos($relation, '.') !== false) {
return $this->hasNested($relation, $operator, $count, $boolean, $callback);
}
$relation = $this->getHasRelationQuery($relation);
... | Add a relationship count condition to the query.
@param string $relation
@param string $operator
@param int $count
@param string $boolean
@param \Closure|null $callback
@return \Nova\Database\ORM\Builder|static | entailment |
protected function mergeWheresToHas(Builder $hasQuery, Relation $relation)
{
$relationQuery = $relation->getBaseQuery();
$hasQuery = $hasQuery->getModel()->removeGlobalScopes($hasQuery);
$hasQuery->mergeWheres(
$relationQuery->wheres, $relationQuery->getBindings()
);
... | Merge the "wheres" from a relation query to a has query.
@param \Nova\Database\ORM\Builder $hasQuery
@param \Nova\Database\ORM\Relations\Relation $relation
@return void | entailment |
public function withCount($relations)
{
if (is_string($relations)) $relations = func_get_args();
// If no columns are set, add the default * columns.
if (is_null($this->query->columns)) {
$this->query->select($this->query->from .'.*');
}
$relations = $this->pars... | Add subselect queries to count the relations.
@param mixed $relations
@return $this | entailment |
protected function callScope($scope, $parameters)
{
array_unshift($parameters, $this);
return call_user_func_array(array($this->model, $scope), $parameters) ?: $this;
} | Call the given model scope on the underlying model.
@param string $scope
@param array $parameters
@return \Nova\Database\Query\Builder | entailment |
protected function transform($messages, $format, $key)
{
return array_map(function ($message) use ($format, $key)
{
return str_replace(array(':message', ':key'), array($message, $key), $format);
}, (array) $messages);
} | Format an array of messages.
@param array $messages
@param string $format
@param string $messageKey
@return array | entailment |
public function handle()
{
try{
$dbname = $this->argument('dbname');
$connection = $this->hasArgument('connection') && $this->argument('connection') ? $this->argument('connection') : config('database.default');
$hasDb = \DB::connection($connection)->select("SELECT SCHEMA... | Execute the console command.
@return mixed | entailment |
public function increment($key, $value = 1)
{
$raw = $this->getPayload($key);
$int = ((int) $raw['data']) + $value;
$this->put($key, $int, (int) $raw['time']);
return $int;
} | Increment the value of an item in the cache.
@param string $key
@param mixed $value
@return int | entailment |
public function retrieveActiveBySlug($slug)
{
$query = $this->createQueryBuilder('c')
->where('c.isActive = :isActive')
->andWhere('c.slug = :slug')
->orderBy('c.rank', 'ASC')
->setMaxResults(1)
->getQuery();
$query->setParameter('isActive... | @param string $slug
@return mixed | entailment |
public function handle()
{
$fullPath = $this->createBaseMigration();
$this->files->put($fullPath, $this->files->get(__DIR__ .DS .'stubs' .DS .'database.stub'));
$this->info('Migration created successfully!');
$this->call('optimize');
} | Execute the console command.
@return void | entailment |
protected function createBaseMigration()
{
$name = 'create_session_table';
$path = $this->container['path'] .DS .'Database' .DS .'Migrations';
return $this->container['migration.creator']->create($name, $path);
} | Create a base migration file for the session.
@return string | entailment |
protected function createLogger()
{
$log = new Writer(
new Monolog('nova'), $this->app['events']
);
$this->configureHandler($log);
return $log;
} | Create the logger.
@return \Nova\Log\Writer | entailment |
protected function configureHandler(Writer $log)
{
$driver = $this->app['config']['app.log'];
$method = 'configure' .ucfirst($driver) .'Handler';
call_user_func(array($this, $method), $log);
} | Configure the Monolog handlers for the application.
@param \Nova\Foundation\Application $app
@param \Nova\Log\Writer $log
@return void | entailment |
protected function configureDailyHandler(Writer $log)
{
$log->useDailyFiles(
$this->app['path.storage'] .DS .'logs' .DS .'framework.log',
$this->app['config']->get('app.log_max_files', 5)
);
} | Configure the Monolog handlers for the application.
@param \Nova\Log\Writer $log
@return void | entailment |
public function delete($id)
{
$db = new DatabaseManager();
$connection = $db->getDbh();
$sql = 'DELETE from :table WHERE id=:id';
$sql = str_replace(':table', $this->tableName, $sql);
$statement = $connection->prepare($sql);
// $statement->bindParam(':table', $this-... | delete record for given ID - return true/false depending on delete success
@param $id
@return bool | entailment |
public function create($object)
{
$db = new DatabaseManager();
$connection = $db->getDbh();
$objectAsArrayForSqlInsert = DatatbaseUtility::objectToArrayLessId($object);
$fields = array_keys($objectAsArrayForSqlInsert);
$insertFieldList = DatatbaseUtility::fieldListToInsertSt... | insert new record into the DB table
returns new record ID if insertion was successful, otherwise -1
@param Object $object
@return integer | entailment |
public function update($object)
{
$id = $object->getId();
$db = new DatabaseManager();
$connection = $db->getDbh();
$objectAsArrayForSqlInsert = DatatbaseUtility::objectToArrayLessId($object);
$fields = array_keys($objectAsArrayForSqlInsert);
$updateFieldList = Data... | insert new record into the DB table
returns new record ID if insertion was successful, otherwise -1
@param $object
@return bool | entailment |
public function hit($key, $decayMinutes = 1)
{
$this->cache->add($key, 1, $decayMinutes);
return (int) $this->cache->increment($key);
} | Increment the counter for a given key for a given decay time.
@param string $key
@param int $decayMinutes
@return int | entailment |
public function retriesLeft($key, $maxAttempts)
{
$attempts = $this->attempts($key);
return ($attempts === 0) ? $maxAttempts : $maxAttempts - $attempts + 1;
} | Get the number of retries left for the given key.
@param string $key
@param int $maxAttempts
@return int | entailment |
public function clear($key)
{
$this->cache->forget($key);
$this->cache->forget($key .':lockout');
} | Clear the hits and lockout for the given key.
@param string $key
@return void | entailment |
public function evaluate($method, $arguments)
{
$this->authenticator->authenticate($method, $arguments);
return $this->evaluator->evaluate($method, $arguments);
} | Authenticate request and (if successful) map method name to callable
and run it with the given arguments.
@param string $method Method name
@param array $arguments Positional or associative argument array
@return mixed Return value of the callable
@throws Exception\MissingAuth If the no credentials are given
@throws E... | entailment |
public function resource($name, $controller, array $options = array())
{
$registrar = $this->getRegistrar();
$registrar->register($name, $controller, $options);
} | Route a resource to a controller.
@param string $name
@param string $controller
@param array $options
@return void | entailment |
protected function updateGroupStack(array $attributes)
{
if (! empty($this->groupStack)) {
$old = last($this->groupStack);
$attributes = static::mergeGroup($attributes, $old);
}
$this->groupStack[] = $attributes;
} | Update the group stack with the given attributes.
@param array $attributes
@return void | entailment |
public static function mergeGroup($new, $old)
{
$new['namespace'] = static::formatUsesPrefix($new, $old);
$new['prefix'] = static::formatGroupPrefix($new, $old);
if (isset($new['domain'])) {
unset($old['domain']);
}
$new['where'] = array_merge(
isse... | Merge the given group attributes.
@param array $new
@param array $old
@return array | entailment |
protected static function formatGroupPrefix($new, $old)
{
$prefix = isset($old['prefix']) ? $old['prefix'] : null;
if (isset($new['prefix'])) {
return trim($prefix, '/') .'/' .trim($new['prefix'], '/');
}
return $prefix;
} | Format the prefix for the new group attributes.
@param array $new
@param array $old
@return string | entailment |
public function getLastGroupPrefix()
{
if (! empty($this->groupStack)) {
$last = end($this->groupStack);
return isset($last['prefix']) ? $last['prefix'] : '';
}
return '';
} | Get the prefix from the last group on the stack.
@return string | entailment |
protected function createRoute($methods, $uri, $action)
{
if (is_callable($action)) {
$action = array('uses' => $action);
}
// If the route is routing to a controller we will parse the route action into
// an acceptable array format before registering it and creating thi... | Create a new route instance.
@param array|string $methods
@param string $uri
@param mixed $action
@return \Nova\Routing\Route | entailment |
protected function findActionClosure(array $action)
{
return Arr::first($action, function ($key, $value)
{
return is_callable($value) && is_numeric($key);
});
} | Find the Closure in an action array.
@param array $action
@return \Closure | entailment |
protected function newRoute($methods, $uri, $action)
{
return with(new Route($methods, $uri, $action))
->setRouter($this)
->setContainer($this->container);
} | Create a new Route object.
@param array|string $methods
@param string $uri
@param mixed $action
@return \Nova\Routing\Route | entailment |
protected function addWhereClausesToRoute($route)
{
$route->where(
array_merge($this->patterns, Arr::get($route->getAction(), 'where', array()))
);
return $route;
} | Add the necessary where clauses to the route based on its initial registration.
@param \Nova\Routing\Route $route
@return \Nova\Routing\Route | entailment |
protected function mergeGroupAttributesIntoRoute($route)
{
$action = $this->mergeWithLastGroup($route->getAction());
$route->setAction($action);
} | Merge the group stack with the controller action.
@param \Nova\Routing\Route $route
@return void | entailment |
public function dispatchToRoute(Request $request)
{
// First we will find a route that matches this request. We will also set the
// route resolver on the request so middlewares assigned to the route will
// receive access to this route instance for checking of the parameters.
$route... | Dispatch the request to a route and return the response.
@param \Nova\Http\Request $request
@return mixed | entailment |
protected function runRouteWithinStack(Route $route, Request $request)
{
$skipMiddleware = $this->container->bound('middleware.disable') &&
($this->container->make('middleware.disable') === true);
// Create a Pipeline instance.
$pipeline = new Pipeline(
... | Run the given route within a Stack "onion" instance.
@param \Nova\Routing\Route $route
@param \Nova\Http\Request $request
@return mixed | entailment |
public function gatherRouteMiddleware(Route $route)
{
$middleware = array_map(function ($name)
{
return $this->resolveMiddleware($name);
}, $route->gatherMiddleware());
return Arr::flatten($middleware);
} | Gather the middleware for the given route.
@param \Mini\Routing\Route $route
@return array | entailment |
public function resolveMiddleware($name)
{
if (isset($this->middlewareGroups[$name])) {
return $this->parseMiddlewareGroup($name);
}
return $this->parseMiddleware($name);
} | Resolve the middleware name to class name preserving passed parameters.
@param string $name
@return array | entailment |
protected function parseMiddleware($name)
{
list($name, $parameters) = array_pad(explode(':', $name, 2), 2, null);
//
$callable = isset($this->middleware[$name]) ? $this->middleware[$name] : $name;
if (is_null($parameters)) {
return $callable;
}
// When... | Parse the middleware and format it for usage.
@param string $name
@return array | entailment |
protected function parseMiddlewareGroup($name)
{
$results = array();
foreach ($this->middlewareGroups[$name] as $middleware) {
if (! isset($this->middlewareGroups[$middleware])) {
$results[] = $this->parseMiddleware($middleware);
continue;
}
... | Parse the middleware group and format it for usage.
@param string $name
@return array | entailment |
protected function performBinding($key, $value, $route)
{
$callback = $this->binders[$key];
return call_user_func($callback, $value, $route);
} | Call the binding callback for the given key.
@param string $key
@param string $value
@param \Nova\Routing\Route $route
@return mixed | entailment |
public function pushMiddlewareToGroup($group, $middleware)
{
if (! array_key_exists($group, $this->middlewareGroups)) {
$this->middlewareGroups[$group] = array();
}
if (! in_array($middleware, $this->middlewareGroups[$group])) {
$this->middlewareGroups[$group][] = $m... | Add a middleware to the end of a middleware group.
If the middleware is already in the group, it will not be added again.
@param string $group
@param string $middleware
@return $this | entailment |
public function createClassBinding($binding)
{
return function ($value, $route) use ($binding)
{
// If the binding has an @ sign, we will assume it's being used to delimit
// the class name from the bind method name. This allows for bindings
// to run multiple bin... | Create a class based binding using the IoC container.
@param string $binding
@return \Closure | entailment |
public function prepareResponse($request, $response)
{
if (! $response instanceof SymfonyResponse) {
$response = new Response($response);
}
return $response->prepare($request);
} | Create a response instance from the given value.
@param \Symfony\Component\HttpFoundation\Request $request
@param mixed $response
@return \Nova\Http\Response | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.