code
stringlengths 15
9.96M
| docstring
stringlengths 1
10.1k
| func_name
stringlengths 1
124
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 6
186
| url
stringlengths 50
236
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public function updateDispute($params=null)
{
$requestor = new Stripe_ApiRequestor($this->_apiKey);
$url = $this->instanceUrl() . '/dispute';
list($response, $apiKey) = $requestor->request('post', $url, $params);
$this->refreshFrom(array('dispute' => $response), $apiKey, true);
return $this->dispute;
} | @param array|null $params
@return array The updated dispute. | updateDispute | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Charge.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Charge.php | Apache-2.0 |
public function closeDispute()
{
$requestor = new Stripe_ApiRequestor($this->_apiKey);
$url = $this->instanceUrl() . '/dispute/close';
list($response, $apiKey) = $requestor->request('post', $url);
$this->refreshFrom($response, $apiKey);
return $this;
} | @return Stripe_Charge The updated charge. | closeDispute | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Charge.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Charge.php | Apache-2.0 |
public static function retrieve($apiKey=null)
{
$class = get_class();
return self::_scopedSingletonRetrieve($class, $apiKey);
} | @param string|null $apiKey
@return Stripe_Account | retrieve | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Account.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Account.php | Apache-2.0 |
public static function classUrl($class)
{
$base = self::className($class);
return "/v1/${base}";
} | @param Stripe_SingletonApiResource $class
@return string The endpoint associated with this singleton class. | classUrl | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/SingletonApiResource.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/SingletonApiResource.php | Apache-2.0 |
public function instanceUrl()
{
$class = get_class($this);
$base = self::classUrl($class);
return "$base";
} | @return string The endpoint associated with this singleton API resource. | instanceUrl | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/SingletonApiResource.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/SingletonApiResource.php | Apache-2.0 |
public static function retrieve($id, $apiKey=null)
{
$class = get_class();
return self::_scopedRetrieve($class, $id, $apiKey);
} | @param string $id The ID of the recipient to retrieve.
@param string|null $apiKey
@return Stripe_Recipient | retrieve | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Recipient.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Recipient.php | Apache-2.0 |
public static function all($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedAll($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return array An array of Stripe_Recipients. | all | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Recipient.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Recipient.php | Apache-2.0 |
public static function create($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedCreate($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return Stripe_Recipient The created recipient. | create | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Recipient.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Recipient.php | Apache-2.0 |
public function save()
{
$class = get_class();
return self::_scopedSave($class);
} | @return Stripe_Recipient The saved recipient. | save | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Recipient.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Recipient.php | Apache-2.0 |
public function delete($params=null)
{
$class = get_class();
return self::_scopedDelete($class, $params);
} | @param array|null $params
@return Stripe_Recipient The deleted recipient. | delete | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Recipient.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Recipient.php | Apache-2.0 |
public function transfers($params=null)
{
if (!$params)
$params = array();
$params['recipient'] = $this->id;
$transfers = Stripe_Transfer::all($params, $this->_apiKey);
return $transfers;
} | @param array|null $params
@return array An array of the recipient's Stripe_Transfers. | transfers | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Recipient.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Recipient.php | Apache-2.0 |
public static function retrieve($id, $apiKey=null)
{
$class = get_class();
return self::_scopedRetrieve($class, $id, $apiKey);
} | @param string $id The ID of the plan to retrieve.
@param string|null $apiKey
@return Stripe_Plan | retrieve | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Plan.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Plan.php | Apache-2.0 |
public static function create($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedCreate($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return Stripe_Plan The created plan. | create | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Plan.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Plan.php | Apache-2.0 |
public function delete($params=null)
{
$class = get_class();
return self::_scopedDelete($class, $params);
} | @param array|null $params
@return Stripe_Plan The deleted plan. | delete | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Plan.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Plan.php | Apache-2.0 |
public function save()
{
$class = get_class();
return self::_scopedSave($class);
} | @return Stripe_Plan The saved plan. | save | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Plan.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Plan.php | Apache-2.0 |
public static function all($params=null, $apiKey=null)
{
$class = get_class();
return self::_scopedAll($class, $params, $apiKey);
} | @param array|null $params
@param string|null $apiKey
@return array An array of Stripe_Plans. | all | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Plan.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Plan.php | Apache-2.0 |
public function replaceWith($properties)
{
$removed = array_diff(array_keys($this->_values), array_keys($properties));
// Don't unset, but rather set to null so we send up '' for deletion.
foreach ($removed as $k) {
$this->$k = null;
}
foreach ($properties as $k => $v) {
$this->$k = $v;
}
} | Updates this object.
@param array $properties A mapping of properties to update on this object. | replaceWith | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/AttachedObject.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/AttachedObject.php | Apache-2.0 |
public static function getApiKey()
{
return self::$apiKey;
} | @return string The API key used for requests. | getApiKey | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Stripe.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Stripe.php | Apache-2.0 |
public static function setApiKey($apiKey)
{
self::$apiKey = $apiKey;
} | Sets the API key to be used for requests.
@param string $apiKey | setApiKey | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Stripe.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Stripe.php | Apache-2.0 |
public static function getApiVersion()
{
return self::$apiVersion;
} | @return string The API version used for requests. null if we're using the
latest version. | getApiVersion | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Stripe.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Stripe.php | Apache-2.0 |
public static function setApiVersion($apiVersion)
{
self::$apiVersion = $apiVersion;
} | @param string $apiVersion The API version to use for requests. | setApiVersion | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Stripe.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Stripe.php | Apache-2.0 |
public static function getVerifySslCerts()
{
return self::$verifySslCerts;
} | @return boolean | getVerifySslCerts | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Stripe.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Stripe.php | Apache-2.0 |
public static function setVerifySslCerts($verify)
{
self::$verifySslCerts = $verify;
} | @param boolean $verify | setVerifySslCerts | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Stripe.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Stripe.php | Apache-2.0 |
public function instanceUrl()
{
$id = $this['id'];
if (!$id) {
$class = get_class($this);
$msg = "Could not determine which URL to request: $class instance "
. "has invalid ID: $id";
throw new Stripe_InvalidRequestError($msg, null);
}
if (isset($this['customer'])) {
$parent = $this['customer'];
$base = self::classUrl('Stripe_Customer');
} else if (isset($this['recipient'])) {
$parent = $this['recipient'];
$base = self::classUrl('Stripe_Recipient');
} else {
return null;
}
$parent = Stripe_ApiRequestor::utf8($parent);
$id = Stripe_ApiRequestor::utf8($id);
$parentExtn = urlencode($parent);
$extn = urlencode($id);
return "$base/$parentExtn/cards/$extn";
} | @return string The instance URL for this resource. It needs to be special
cased because it doesn't fit into the standard resource pattern. | instanceUrl | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Card.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Card.php | Apache-2.0 |
public function delete($params=null)
{
$class = get_class();
return self::_scopedDelete($class, $params);
} | @param array|null $params
@return Stripe_Card The deleted card. | delete | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Card.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Card.php | Apache-2.0 |
public function save()
{
$class = get_class();
return self::_scopedSave($class);
} | @return Stripe_Card The saved card. | save | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Card.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Card.php | Apache-2.0 |
public static function retrieve($apiKey=null)
{
$class = get_class();
return self::_scopedSingletonRetrieve($class, $apiKey);
} | @param string|null $apiKey
@return Stripe_Balance | retrieve | php | phorgeit/phorge | externals/stripe-php/lib/Stripe/Balance.php | https://github.com/phorgeit/phorge/blob/master/externals/stripe-php/lib/Stripe/Balance.php | Apache-2.0 |
public static function getStartTime() {
return self::$startTime;
} | @task info | getStartTime | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function getMicrosecondsSinceStart() {
// This is the same as "phutil_microseconds_since()", but we may not have
// loaded libraries yet.
return (int)(1000000 * (microtime(true) - self::getStartTime()));
} | @task info | getMicrosecondsSinceStart | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function setAccessLog($access_log) {
self::$accessLog = $access_log;
} | @task info | setAccessLog | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function getRawInput() {
if (self::$rawInput === null) {
$stream = new AphrontRequestStream();
if (isset($_SERVER['HTTP_CONTENT_ENCODING'])) {
$encoding = trim($_SERVER['HTTP_CONTENT_ENCODING']);
$stream->setEncoding($encoding);
}
$input = '';
do {
$bytes = $stream->readData();
if ($bytes === null) {
break;
}
$input .= $bytes;
} while (true);
self::$rawInput = $input;
}
return self::$rawInput;
} | @task info | getRawInput | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function didStartup($start_time) {
self::$startTime = $start_time;
self::$phases = array();
self::$accessLog = null;
self::$requestPath = null;
static $registered;
if (!$registered) {
// NOTE: This protects us against multiple calls to didStartup() in the
// same request, but also against repeated requests to the same
// interpreter state, which we may implement in the future.
register_shutdown_function(array(__CLASS__, 'didShutdown'));
$registered = true;
}
self::setupPHP();
self::verifyPHP();
// If we've made it this far, the environment isn't completely broken so
// we can switch over to relying on our own exception recovery mechanisms.
ini_set('display_errors', 0);
self::connectRateLimits();
self::normalizeInput();
self::readRequestPath();
self::beginOutputCapture();
} | @param float $start_time Request start time, from `microtime(true)`.
@task hook | didStartup | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function didShutdown() {
// Disconnect any active rate limits before we shut down. If we don't do
// this, requests which exit early will lock a slot in any active
// connection limits, and won't count for rate limits.
self::disconnectRateLimits(array());
$event = error_get_last();
if (!$event) {
return;
}
switch ($event['type']) {
case E_ERROR:
case E_PARSE:
case E_COMPILE_ERROR:
break;
default:
return;
}
$msg = ">>> UNRECOVERABLE FATAL ERROR <<<\n\n";
if ($event) {
// Even though we should be emitting this as text-plain, escape things
// just to be sure since we can't really be sure what the program state
// is when we get here.
$msg .= htmlspecialchars(
$event['message']."\n\n".$event['file'].':'.$event['line'],
ENT_QUOTES,
'UTF-8');
}
// flip dem tables
$msg .= "\n\n\n";
$msg .= "\xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb\x20\xef\xb8\xb5\x20\xc2\xaf".
"\x5c\x5f\x28\xe3\x83\x84\x29\x5f\x2f\xc2\xaf\x20\xef\xb8\xb5\x20".
"\xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb";
self::didFatal($msg);
} | @task hook | didShutdown | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function setDebugTimeLimit($limit) {
self::$debugTimeLimit = $limit;
static $initialized = false;
if (!$initialized) {
declare(ticks=1);
register_tick_function(array(__CLASS__, 'onDebugTick'));
$initialized = true;
}
} | Set a time limit (in seconds) for the current script. After time expires,
the script fatals.
This works like `max_execution_time`, but prints out a useful stack trace
when the time limit expires. This is primarily intended to make it easier
to debug pages which hang by allowing extraction of a stack trace: set a
short debug limit, then use the trace to figure out what's happening.
The limit is implemented with a tick function, so enabling it implies
some accounting overhead.
@param int $limit Time limit in seconds.
@return void | setDebugTimeLimit | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function didEncounterFatalException(
$note,
$ex,
$show_trace) {
$message = '['.$note.'/'.get_class($ex).'] '.$ex->getMessage();
$full_message = $message;
$full_message .= "\n\n";
$full_message .= $ex->getTraceAsString();
if ($show_trace) {
$message = $full_message;
}
self::didFatal($message, $full_message);
} | Fatal the request completely in response to an exception, sending a plain
text message to the client. Calls @{method:didFatal} internally.
@param string $note Brief description of the exception context, like
`"Rendering Exception"`.
@param Throwable $ex The exception itself.
@param bool $show_trace True if it's okay to show the exception's
stack trace to the user. The trace will always be
logged.
@task apocalypse | didEncounterFatalException | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function didFatal($message, $log_message = null) {
if ($log_message === null) {
$log_message = $message;
}
self::endOutputCapture();
$access_log = self::$accessLog;
if ($access_log) {
// We may end up here before the access log is initialized, e.g. from
// verifyPHP().
$access_log->setData(
array(
'c' => 500,
));
$access_log->write();
}
header(
'Content-Type: text/plain; charset=utf-8',
$replace = true,
$http_error = 500);
error_log($log_message);
echo $message."\n";
exit(1);
} | Fatal the request completely, sending a plain text message to the client.
@param string $message Plain text message to send to the client.
@param string $log_message (optional) Plain text message to send to the
error log. If not provided, the client message is used.
You can pass a more detailed message here (e.g., with
stack traces) to avoid showing it to users.
@return exit This method **does not return**.
@task apocalypse | didFatal | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function getOldMemoryLimit() {
return self::$oldMemoryLimit;
} | @task validation | getOldMemoryLimit | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function rebuildRequest() {
// Rebuild $_REQUEST, respecting order declared in ".ini" files.
$order = ini_get('request_order');
if (!$order) {
$order = ini_get('variables_order');
}
if (!$order) {
// $_REQUEST will be empty, so leave it alone.
return;
}
$_REQUEST = array();
for ($ii = 0; $ii < strlen($order); $ii++) {
switch ($order[$ii]) {
case 'G':
$_REQUEST = array_merge($_REQUEST, $_GET);
break;
case 'P':
$_REQUEST = array_merge($_REQUEST, $_POST);
break;
case 'C':
$_REQUEST = array_merge($_REQUEST, $_COOKIE);
break;
default:
// $_ENV and $_SERVER never go into $_REQUEST.
break;
}
}
} | @task validation | rebuildRequest | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
private static function filterEnvSuperglobal(array $env) {
// In some configurations, we may get "argc" and "argv" set in $_ENV.
// These are not real environmental variables, and "argv" may have an array
// value which can not be forwarded to subprocesses. Remove these from the
// environment if they are present.
unset($env['argc']);
unset($env['argv']);
return $env;
} | Adjust `$_ENV` before execution.
Adjustments here primarily impact the environment as seen by subprocesses.
The environment is forwarded explicitly by @{class:ExecFuture}.
@param map<string, wild> $env Input `$_ENV`.
@return map<string, string> Suitable `$_ENV`.
@task validation | filterEnvSuperglobal | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
private static function verifyPHP() {
$required_version = '7.2.25';
if (version_compare(PHP_VERSION, $required_version) < 0) {
self::didFatal(
"You are running PHP version '".PHP_VERSION."', which is older than ".
"the minimum version, '{$required_version}'. Update to at least ".
"'{$required_version}'.");
}
if (function_exists('get_magic_quotes_gpc')) {
if (@get_magic_quotes_gpc()) {
self::didFatal(
'Your server is configured with the PHP language feature '.
'"magic_quotes_gpc" enabled.'.
"\n\n".
'This feature is "highly discouraged" by PHP\'s developers, and '.
'has been removed entirely in PHP8.'.
"\n\n".
'You must disable "magic_quotes_gpc" to run Phorge. Consult the '.
'PHP manual for instructions.');
}
}
if (extension_loaded('apc')) {
$apc_version = phpversion('apc');
$known_bad = array(
'3.1.14' => true,
'3.1.15' => true,
'3.1.15-dev' => true,
);
if (isset($known_bad[$apc_version])) {
self::didFatal(
"You have APC {$apc_version} installed. This version of APC is ".
"known to be bad, and does not work with Phorge (it will cause ".
"Phorge to fatal unrecoverably with nonsense errors).".
"Downgrade to version 3.1.13.");
}
}
if (isset($_SERVER['HTTP_PROXY'])) {
self::didFatal(
'This HTTP request included a "Proxy:" header, poisoning the '.
'environment (CVE-2016-5385 / httpoxy). Declining to process this '.
'request. For details, see: https://secure.phabricator.com/T11359');
}
} | @task validation | verifyPHP | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
private static function readRequestPath() {
// See T13575. The request path may be provided in:
//
// - the "$_GET" parameter "__path__" (normal for Apache and nginx); or
// - the "$_SERVER" parameter "REQUEST_URI" (normal for the PHP builtin
// webserver).
//
// Locate it wherever it is, and store it for later use. Note that writing
// to "$_REQUEST" here won't always work, because later code may rebuild
// "$_REQUEST" from other sources.
if (isset($_REQUEST['__path__']) && strlen($_REQUEST['__path__'])) {
self::setRequestPath($_REQUEST['__path__']);
return;
}
// Compatibility with PHP 5.4+ built-in web server.
if (php_sapi_name() == 'cli-server') {
$path = parse_url($_SERVER['REQUEST_URI']);
self::setRequestPath($path['path']);
return;
}
if (!isset($_REQUEST['__path__'])) {
self::didFatal(
"Request parameter '__path__' is not set. Your rewrite rules ".
"are not configured correctly.");
}
if (!strlen($_REQUEST['__path__'])) {
self::didFatal(
"Request parameter '__path__' is set, but empty. Your rewrite rules ".
"are not configured correctly. The '__path__' should always ".
"begin with a '/'.");
}
} | @task request-path | readRequestPath | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function getRequestPath() {
$path = self::$requestPath;
if ($path === null) {
self::didFatal(
'Request attempted to access request path, but no request path is '.
'available for this request. You may be calling web request code '.
'from a non-request context, or your webserver may not be passing '.
'a request path to Phorge in a format that it understands.');
}
return $path;
} | @task request-path | getRequestPath | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function setRequestPath($path) {
self::$requestPath = $path;
} | @task request-path | setRequestPath | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function addRateLimit(PhabricatorClientLimit $limit) {
self::$limits[] = $limit;
return $limit;
} | Add a new client limits.
@param PhabricatorClientLimit $limit New limit.
@return PhabricatorClientLimit The limit. | addRateLimit | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
private static function didRateLimit($reason) {
header(
'Content-Type: text/plain; charset=utf-8',
$replace = true,
$http_error = 429);
echo $reason;
exit(1);
} | Emit an HTTP 429 "Too Many Requests" response (indicating that the user
has exceeded application rate limits) and exit.
@return exit This method **does not return**.
@task ratelimit | didRateLimit | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function beginStartupPhase($phase) {
self::recordStartupPhase($phase, microtime(true));
} | Record the beginning of a new startup phase.
For phases which occur before @{class:PhabricatorStartup} loads, save the
time and record it with @{method:recordStartupPhase} after the class is
available.
@param string $phase Phase name.
@task phases | beginStartupPhase | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function recordStartupPhase($phase, $time) {
self::$phases[$phase] = $time;
} | Record the start time of a previously executed startup phase.
For startup phases which occur after @{class:PhabricatorStartup} loads,
use @{method:beginStartupPhase} instead. This method can be used to
record a time before the class loads, then hand it over once the class
becomes available.
@param string $phase Phase name.
@param float $time Phase start time, from `microtime(true)`.
@task phases | recordStartupPhase | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
public static function getPhases() {
return self::$phases;
} | Get information about startup phase timings.
Sometimes, performance problems can occur before we start the profiler.
Since the profiler can't examine these phases, it isn't useful in
understanding their performance costs.
Instead, the startup process marks when it enters various phases using
@{method:beginStartupPhase}. A later call to this method can retrieve this
information, which can be examined to gain greater insight into where
time was spent. The output is still crude, but better than nothing.
@task phases | getPhases | php | phorgeit/phorge | support/startup/PhabricatorStartup.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorStartup.php | Apache-2.0 |
private function getMinimumBucketCacheKey() {
$limit_key = $this->getLimitKey();
return "limit:min:{$limit_key}";
} | Get the APC key for the smallest stored bucket.
@return string APC key for the smallest stored bucket.
@task ratelimit | getMinimumBucketCacheKey | php | phorgeit/phorge | support/startup/PhabricatorClientLimit.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorClientLimit.php | Apache-2.0 |
private function getCurrentBucketID() {
return (int)(time() / $this->getBucketDuration());
} | Get the current bucket ID for storing rate limit scores.
@return int The current bucket ID. | getCurrentBucketID | php | phorgeit/phorge | support/startup/PhabricatorClientLimit.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorClientLimit.php | Apache-2.0 |
private function getBucketCacheKey($bucket_id) {
$limit_key = $this->getLimitKey();
return "limit:bucket:{$limit_key}:{$bucket_id}";
} | Get the APC key for a given bucket.
@param int $bucket_id Bucket to get the key for.
@return string APC key for the bucket. | getBucketCacheKey | php | phorgeit/phorge | support/startup/PhabricatorClientLimit.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorClientLimit.php | Apache-2.0 |
private function addScore($score) {
$is_apcu = (bool)function_exists('apcu_fetch');
$current = $this->getCurrentBucketID();
$bucket_key = $this->getBucketCacheKey($current);
// There's a bit of a race here, if a second process reads the bucket
// before this one writes it, but it's fine if we occasionally fail to
// record a client's score. If they're making requests fast enough to hit
// rate limiting, we'll get them soon enough.
if ($is_apcu) {
$bucket = apcu_fetch($bucket_key);
} else {
$bucket = apc_fetch($bucket_key);
}
if (!is_array($bucket)) {
$bucket = array();
}
$client_key = $this->getClientKey();
if (empty($bucket[$client_key])) {
$bucket[$client_key] = 0;
}
$bucket[$client_key] += $score;
if ($is_apcu) {
@apcu_store($bucket_key, $bucket);
} else {
@apc_store($bucket_key, $bucket);
}
return $this;
} | Add points to the rate limit score for some client.
@param float $score The cost for this request; more points pushes them
toward the limit faster.
@return $this | addScore | php | phorgeit/phorge | support/startup/PhabricatorClientLimit.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorClientLimit.php | Apache-2.0 |
private function getScore() {
$is_apcu = (bool)function_exists('apcu_fetch');
// Identify the oldest bucket stored in APC.
$min_key = $this->getMinimumBucketCacheKey();
if ($is_apcu) {
$min = apcu_fetch($min_key);
} else {
$min = apc_fetch($min_key);
}
// If we don't have any buckets stored yet, store the current bucket as
// the oldest bucket.
$cur = $this->getCurrentBucketID();
if (!$min) {
if ($is_apcu) {
@apcu_store($min_key, $cur);
} else {
@apc_store($min_key, $cur);
}
$min = $cur;
}
// Destroy any buckets that are older than the minimum bucket we're keeping
// track of. Under load this normally shouldn't do anything, but will clean
// up an old bucket once per minute.
$count = $this->getBucketCount();
for ($cursor = $min; $cursor < ($cur - $count); $cursor++) {
$bucket_key = $this->getBucketCacheKey($cursor);
if ($is_apcu) {
apcu_delete($bucket_key);
@apcu_store($min_key, $cursor + 1);
} else {
apc_delete($bucket_key);
@apc_store($min_key, $cursor + 1);
}
}
$client_key = $this->getClientKey();
// Now, sum up the client's scores in all of the active buckets.
$score = 0;
for (; $cursor <= $cur; $cursor++) {
$bucket_key = $this->getBucketCacheKey($cursor);
if ($is_apcu) {
$bucket = apcu_fetch($bucket_key);
} else {
$bucket = apc_fetch($bucket_key);
}
if (isset($bucket[$client_key])) {
$score += $bucket[$client_key];
}
}
return $score;
} | Get the current rate limit score for a given client.
@return float The client's current score.
@task ratelimit | getScore | php | phorgeit/phorge | support/startup/PhabricatorClientLimit.php | https://github.com/phorgeit/phorge/blob/master/support/startup/PhabricatorClientLimit.php | Apache-2.0 |
function preamble_trust_x_forwarded_for_header($layers = 1) {
if (!is_int($layers) || ($layers < 1)) {
echo
'preamble_trust_x_forwarded_for_header(<layers>): '.
'"layers" parameter must an integer larger than 0.'."\n";
echo "\n";
exit(1);
}
if (!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return;
}
$forwarded_for = $_SERVER['HTTP_X_FORWARDED_FOR'];
if (!strlen($forwarded_for)) {
return;
}
$address = preamble_get_x_forwarded_for_address($forwarded_for, $layers);
$_SERVER['REMOTE_ADDR'] = $address;
} | Parse the "X_FORWARDED_FOR" HTTP header to determine the original client
address.
@param int $layers (optional) Number of devices to trust.
@return void | preamble_trust_x_forwarded_for_header | php | phorgeit/phorge | support/startup/preamble-utils.php | https://github.com/phorgeit/phorge/blob/master/support/startup/preamble-utils.php | Apache-2.0 |
public function boot()
{
$this->loadViewsFrom(__DIR__.'/../resources/views', 'larecipe');
Route::group($this->routesConfig(), function () {
$this->loadRoutesFrom(__DIR__.'/../routes/LaRecipe.php');
});
} | Bootstrap the application services.
@return void | boot | php | saleem-hadad/larecipe | src/LaRecipeServiceProvider.php | https://github.com/saleem-hadad/larecipe/blob/master/src/LaRecipeServiceProvider.php | MIT |
protected function routesConfig()
{
return [
'prefix' => config('larecipe.docs.route'),
'namespace' => 'BinaryTorch\LaRecipe\Http\Controllers',
'domain' => config('larecipe.domain', null),
'as' => 'larecipe.',
'middleware' => config('larecipe.docs.middleware'),
];
} | @return array | routesConfig | php | saleem-hadad/larecipe | src/LaRecipeServiceProvider.php | https://github.com/saleem-hadad/larecipe/blob/master/src/LaRecipeServiceProvider.php | MIT |
public function register()
{
$this->registerConfigs();
if ($this->app->runningInConsole()) {
$this->registerPublishableResources();
$this->registerConsoleCommands();
}
$this->app->bind(MarkdownParser::class, ParseDownMarkdownParser::class);
$this->app->alias('LaRecipe', LaRecipeFacade::class);
$this->app->singleton('LaRecipe', function () {
return new LaRecipe();
});
} | Register the application services.
@return void | register | php | saleem-hadad/larecipe | src/LaRecipeServiceProvider.php | https://github.com/saleem-hadad/larecipe/blob/master/src/LaRecipeServiceProvider.php | MIT |
protected function registerConsoleCommands()
{
$this->commands(AssetCommand::class);
$this->commands(ThemeCommand::class);
$this->commands(InstallCommand::class);
$this->commands(GenerateDocumentationCommand::class);
} | Register the commands accessible from the Console. | registerConsoleCommands | php | saleem-hadad/larecipe | src/LaRecipeServiceProvider.php | https://github.com/saleem-hadad/larecipe/blob/master/src/LaRecipeServiceProvider.php | MIT |
protected function registerConfigs()
{
$this->mergeConfigFrom(
dirname(__DIR__).'/publishable/config/larecipe.php',
'larecipe'
);
} | Register the package configs. | registerConfigs | php | saleem-hadad/larecipe | src/LaRecipeServiceProvider.php | https://github.com/saleem-hadad/larecipe/blob/master/src/LaRecipeServiceProvider.php | MIT |
public function __construct(Documentation $documentation)
{
$this->documentation = $documentation;
$this->docsRoute = route('larecipe.index');
$this->defaultVersion = config('larecipe.versions.default');
$this->publishedVersions = config('larecipe.versions.published');
$this->defaultVersionUrl = route('larecipe.show', ['version' => $this->defaultVersion]);
} | DocumentationController constructor.
@param Documentation $documentation | __construct | php | saleem-hadad/larecipe | src/DocumentationRepository.php | https://github.com/saleem-hadad/larecipe/blob/master/src/DocumentationRepository.php | MIT |
public function get($version, $page = null, $data = [])
{
$this->version = $version;
$this->sectionPage = $page ?: config('larecipe.docs.landing');
$this->index = $this->documentation->getIndex($version);
$this->content = $this->documentation->get($version, $this->sectionPage, $data);
if (is_null($this->content)) {
return $this->prepareNotFound();
}
$this->prepareTitle()
->prepareCanonical()
->prepareSection($version, $page);
return $this;
} | @param $version
@param null $page
@param array $data
@return $this|DocumentationRepository | get | php | saleem-hadad/larecipe | src/DocumentationRepository.php | https://github.com/saleem-hadad/larecipe/blob/master/src/DocumentationRepository.php | MIT |
protected function prepareNotFound()
{
$this->title = 'Page not found';
$this->content = view('larecipe::partials.404');
$this->currentSection = '';
$this->canonical = '';
$this->statusCode = 404;
return $this;
} | If the docs content is empty then show 404 page.
@return $this | prepareNotFound | php | saleem-hadad/larecipe | src/DocumentationRepository.php | https://github.com/saleem-hadad/larecipe/blob/master/src/DocumentationRepository.php | MIT |
protected function prepareTitle()
{
$this->title = (new Crawler($this->content))->filterXPath('//h1');
$this->title = count($this->title) ? $this->title->text() : null;
return $this;
} | Prepare the page title from the first h1 found.
@return $this | prepareTitle | php | saleem-hadad/larecipe | src/DocumentationRepository.php | https://github.com/saleem-hadad/larecipe/blob/master/src/DocumentationRepository.php | MIT |
protected function prepareSection($version, $page)
{
if ($this->documentation->sectionExists($version, $page)) {
$this->currentSection = $page;
}
return $this;
} | Prepare the current section page.
@param $version
@param $page
@return $this | prepareSection | php | saleem-hadad/larecipe | src/DocumentationRepository.php | https://github.com/saleem-hadad/larecipe/blob/master/src/DocumentationRepository.php | MIT |
protected function prepareCanonical()
{
if ($this->documentation->sectionExists($this->defaultVersion, $this->sectionPage)) {
$this->canonical = route('larecipe.show', [
'version' => $this->defaultVersion,
'page' => $this->sectionPage
]);
}
return $this;
} | Prepare the canonical link.
@return $this | prepareCanonical | php | saleem-hadad/larecipe | src/DocumentationRepository.php | https://github.com/saleem-hadad/larecipe/blob/master/src/DocumentationRepository.php | MIT |
public function isPublishedVersion($version)
{
return in_array($version, $this->publishedVersions);
} | Check if the given version is in the published versions.
@param $version
@return bool | isPublishedVersion | php | saleem-hadad/larecipe | src/DocumentationRepository.php | https://github.com/saleem-hadad/larecipe/blob/master/src/DocumentationRepository.php | MIT |
public function isNotPublishedVersion($version)
{
return ! $this->isPublishedVersion($version);
} | Check if the given version is not in the published versions.
@param $version
@return bool | isNotPublishedVersion | php | saleem-hadad/larecipe | src/DocumentationRepository.php | https://github.com/saleem-hadad/larecipe/blob/master/src/DocumentationRepository.php | MIT |
public function search($version)
{
return $this->documentation->index($version);
} | @param $version
@return $this | search | php | saleem-hadad/larecipe | src/DocumentationRepository.php | https://github.com/saleem-hadad/larecipe/blob/master/src/DocumentationRepository.php | MIT |
public function __get($key)
{
return $this->getAttribute($key);
} | Dynamically retrieve attributes on the model.
@param string $key
@return mixed | __get | php | saleem-hadad/larecipe | src/DocumentationRepository.php | https://github.com/saleem-hadad/larecipe/blob/master/src/DocumentationRepository.php | MIT |
public function __construct(Repository $cache)
{
$this->cache = $cache;
} | Create a new documentation instance.
@param Repository $cache
@return void | __construct | php | saleem-hadad/larecipe | src/Cache.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Cache.php | MIT |
public function remember(\Closure $callback, $key)
{
if (! config('larecipe.cache.enabled')) {
return $callback();
}
$cachePeriod = $this->checkTtlNeedsChanged(config('larecipe.cache.period'));
return $this->cache->remember($key, $cachePeriod, $callback);
} | Wrapper.
@param \Closure $callback
@param string $key
@return mixed | remember | php | saleem-hadad/larecipe | src/Cache.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Cache.php | MIT |
public function checkTtlNeedsChanged($ttl)
{
$app_version = explode('.', app()->version());
if (((int) $app_version[0] == 5 && (int) $app_version[1] >= 8) || $app_version[0] > 5) {
return config('larecipe.cache.period') * 60;
}
return $ttl;
} | Checks if minutes need to be changed to seconds
@param $ttl
@return float|int | checkTtlNeedsChanged | php | saleem-hadad/larecipe | src/Cache.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Cache.php | MIT |
public static function version()
{
return '2.0.0';
} | Get the current Larecipe version.
@return string | version | php | saleem-hadad/larecipe | src/LaRecipe.php | https://github.com/saleem-hadad/larecipe/blob/master/src/LaRecipe.php | MIT |
public static function script($name, $path)
{
static::$scripts[$name] = $path;
return new static;
} | Register the given script file with LaReipce.
@param string $name
@param string $path
@return static | script | php | saleem-hadad/larecipe | src/LaRecipe.php | https://github.com/saleem-hadad/larecipe/blob/master/src/LaRecipe.php | MIT |
public static function style($name, $path)
{
static::$styles[$name] = $path;
return new static;
} | Register the given CSS file with LaRecipe.
@param string $name
@param string $path
@return static | style | php | saleem-hadad/larecipe | src/LaRecipe.php | https://github.com/saleem-hadad/larecipe/blob/master/src/LaRecipe.php | MIT |
public static function allScripts()
{
return static::$scripts;
} | Get all of the additional scripts.
@return array | allScripts | php | saleem-hadad/larecipe | src/LaRecipe.php | https://github.com/saleem-hadad/larecipe/blob/master/src/LaRecipe.php | MIT |
public static function allStyles()
{
$styles = static::$styles;
if (config('larecipe.ui.theme_order')) {
$newStyleOrder = [];
foreach (config('larecipe.ui.theme_order') as $styleName) {
$newStyleOrder[$styleName] = $styles[$styleName];
}
$styles = $newStyleOrder;
}
return $styles;
} | Get all of the additional stylesheets.
@return array | allStyles | php | saleem-hadad/larecipe | src/LaRecipe.php | https://github.com/saleem-hadad/larecipe/blob/master/src/LaRecipe.php | MIT |
protected function getPages($version)
{
$path = base_path(config('larecipe.docs.path').'/'.$version.'/index.md');
// match all markdown urls => [title](url)
preg_match_all('/\[.+\]\((.+)\)/', $this->files->get($path), $matches);
return $matches[1];
} | @param $version
@return mixed | getPages | php | saleem-hadad/larecipe | src/Traits/Indexable.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/Indexable.php | MIT |
public function getTitleAttribute()
{
return $this->title;
} | @return string | getTitleAttribute | php | saleem-hadad/larecipe | src/Traits/HasDocumentationAttributes.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/HasDocumentationAttributes.php | MIT |
public function getIndexAttribute()
{
return $this->index;
} | @return mixed | getIndexAttribute | php | saleem-hadad/larecipe | src/Traits/HasDocumentationAttributes.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/HasDocumentationAttributes.php | MIT |
public function getVersionAttribute()
{
return $this->version;
} | @return string | getVersionAttribute | php | saleem-hadad/larecipe | src/Traits/HasDocumentationAttributes.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/HasDocumentationAttributes.php | MIT |
public function getContentAttribute()
{
return $this->content;
} | @return string | getContentAttribute | php | saleem-hadad/larecipe | src/Traits/HasDocumentationAttributes.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/HasDocumentationAttributes.php | MIT |
public function getCanonicalAttribute()
{
return $this->canonical;
} | @return string | getCanonicalAttribute | php | saleem-hadad/larecipe | src/Traits/HasDocumentationAttributes.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/HasDocumentationAttributes.php | MIT |
public function getDefaultVersionUrlAttribute()
{
return $this->defaultVersionUrl;
} | @return string | getDefaultVersionUrlAttribute | php | saleem-hadad/larecipe | src/Traits/HasDocumentationAttributes.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/HasDocumentationAttributes.php | MIT |
public function getCurrentSectionAttribute()
{
return $this->currentSection;
} | @return string | getCurrentSectionAttribute | php | saleem-hadad/larecipe | src/Traits/HasDocumentationAttributes.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/HasDocumentationAttributes.php | MIT |
public function getStatusCodeAttribute()
{
return $this->statusCode;
} | @return int | getStatusCodeAttribute | php | saleem-hadad/larecipe | src/Traits/HasDocumentationAttributes.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/HasDocumentationAttributes.php | MIT |
public function getPublishedVersionsAttribute()
{
return $this->publishedVersions;
} | @return string | getPublishedVersionsAttribute | php | saleem-hadad/larecipe | src/Traits/HasDocumentationAttributes.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/HasDocumentationAttributes.php | MIT |
public function parse($text)
{
return App::make(MarkdownParser::class)->parse($text);
} | @param $text
@return null|string|string[]
@throws \Exception | parse | php | saleem-hadad/larecipe | src/Traits/HasMarkdownParser.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/HasMarkdownParser.php | MIT |
public function renderBlade($content, $data = [])
{
$content = $this->compileBlade($content);
$obLevel = ob_get_level();
ob_start();
extract($data, EXTR_SKIP);
try {
eval('?'.'>'.$content);
} catch (\Exception $e) {
while (ob_get_level() > $obLevel) {
ob_end_clean();
}
throw $e;
} catch (\Throwable $e) {
while (ob_get_level() > $obLevel) {
ob_end_clean();
}
throw new \Exception($e);
}
$contents = ob_get_clean();
return $contents;
} | Render markdown contain blade syntax.
@param $content
@param array $data
@return false|string
@throws \Exception | renderBlade | php | saleem-hadad/larecipe | src/Traits/HasBladeParser.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/HasBladeParser.php | MIT |
public function compileBlade($rawContent)
{
$compilableContent = $this->stripCodeBlocks($rawContent);
$compiledContent = Blade::compileString($compilableContent);
return $this->mergeContent($compiledContent, $rawContent);
} | Compile blade content, except within code blocks.
@param $rawContent
@return string | compileBlade | php | saleem-hadad/larecipe | src/Traits/HasBladeParser.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/HasBladeParser.php | MIT |
private function stripCodeBlocks($content)
{
return preg_replace(
config('larecipe.blade-parser.regex.code-blocks.match'),
config('larecipe.blade-parser.regex.code-blocks.replacement'),
$content
);
} | Replace code blocks with a placeholder string.
@param $content
@return string|string[]|null | stripCodeBlocks | php | saleem-hadad/larecipe | src/Traits/HasBladeParser.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/HasBladeParser.php | MIT |
private function getCodeBlocks($rawContent)
{
$pattern = config('larecipe.blade-parser.regex.code-blocks.match');
preg_match_all(
$pattern,
$rawContent,
$codeBlocks
);
return $codeBlocks[0];
} | Find all code blocks in the current content.
@param $rawContent
@return mixed | getCodeBlocks | php | saleem-hadad/larecipe | src/Traits/HasBladeParser.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/HasBladeParser.php | MIT |
protected function runProcess($command, $path)
{
$process = (new Process(explode(" ", $command), $path))->setTimeout(null);
if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
$process->setTty(true);
}
$process->run(function ($type, $line) {
$this->output->write($line);
});
} | Run the given command as a process.
@param string $command
@param string $path
@return void | runProcess | php | saleem-hadad/larecipe | src/Traits/RunProcess.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Traits/RunProcess.php | MIT |
public function __invoke(Request $request)
{
return response(
file_get_contents(LaRecipe::allStyles()[$request->style]),
200, ['Content-Type' => 'text/css']
);
} | @param Request $request
@return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response | __invoke | php | saleem-hadad/larecipe | src/Http/Controllers/StyleController.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Http/Controllers/StyleController.php | MIT |
public function __construct(DocumentationRepository $documentationRepository)
{
$this->documentationRepository = $documentationRepository;
if (config('larecipe.settings.auth')) {
$this->middleware(['auth']);
}else{
if(config('larecipe.settings.middleware')){
$this->middleware(config('larecipe.settings.middleware'));
}
}
} | SearchController constructor.
@param DocumentationRepository $documentationRepository | __construct | php | saleem-hadad/larecipe | src/Http/Controllers/SearchController.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Http/Controllers/SearchController.php | MIT |
public function __invoke($version)
{
$this->authorizeAccessSearch($version);
return response()->json(
$this->documentationRepository->search($version)
);
} | Get the index of a given version.
@param $version
@return \Illuminate\Http\JsonResponse | __invoke | php | saleem-hadad/larecipe | src/Http/Controllers/SearchController.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Http/Controllers/SearchController.php | MIT |
protected function authorizeAccessSearch($version)
{
abort_if(
$this->documentationRepository->isNotPublishedVersion($version)
||
config('larecipe.search.default') != 'internal'
||
! config('larecipe.search.enabled')
, 403);
} | @param $version | authorizeAccessSearch | php | saleem-hadad/larecipe | src/Http/Controllers/SearchController.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Http/Controllers/SearchController.php | MIT |
public function __construct(DocumentationRepository $documentationRepository)
{
$this->documentationRepository = $documentationRepository;
if (config('larecipe.settings.guard')) {
Auth::shouldUse(config('larecipe.settings.guard'));
}
if (config('larecipe.settings.auth')) {
$this->middleware(['auth']);
}else{
if(config('larecipe.settings.middleware')){
$this->middleware(config('larecipe.settings.middleware'));
}
}
} | DocumentationController constructor.
@param DocumentationRepository $documentationRepository | __construct | php | saleem-hadad/larecipe | src/Http/Controllers/DocumentationController.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Http/Controllers/DocumentationController.php | MIT |
public function index()
{
return redirect()->route(
'larecipe.show',
[
'version' => config('larecipe.versions.default'),
'page' => config('larecipe.docs.landing')
]
);
} | Redirect the index page of docs to the default version.
@return \Illuminate\Http\RedirectResponse | index | php | saleem-hadad/larecipe | src/Http/Controllers/DocumentationController.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Http/Controllers/DocumentationController.php | MIT |
public function show($version, $page = null)
{
$documentation = $this->documentationRepository->get($version, $page);
if (Gate::has('viewLarecipe')) {
$this->authorize('viewLarecipe', $documentation);
}
if ($this->documentationRepository->isNotPublishedVersion($version)) {
return redirect()->route(
'larecipe.show',
[
'version' => config('larecipe.versions.default'),
'page' => config('larecipe.docs.landing')
]
);
}
return response()->view('larecipe::docs', [
'title' => $documentation->title,
'index' => $documentation->index,
'content' => $documentation->content,
'currentVersion' => $version,
'versions' => $documentation->publishedVersions,
'currentSection' => $documentation->currentSection,
'canonical' => $documentation->canonical,
], $documentation->statusCode);
} | Show a documentation page.
@param $version
@param null $page
@return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|\Illuminate\Routing\Redirector
@throws \Illuminate\Auth\Access\AuthorizationException | show | php | saleem-hadad/larecipe | src/Http/Controllers/DocumentationController.php | https://github.com/saleem-hadad/larecipe/blob/master/src/Http/Controllers/DocumentationController.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.