code
stringlengths 17
247k
| docstring
stringlengths 30
30.3k
| func_name
stringlengths 1
89
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
153
| url
stringlengths 51
209
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public function setEventDispatcher(Dispatcher $dispatcher)
{
$this->dispatcher = $dispatcher;
} | Set the event dispatcher instance.
@param \Illuminate\Contracts\Events\Dispatcher $dispatcher
@return void | setEventDispatcher | php | bugsnag/bugsnag-laravel | src/EventTrait.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/EventTrait.php | MIT |
public function listen(Closure $callback)
{
if (!isset($this->dispatcher)) {
throw new RuntimeException('Events dispatcher has not been set.');
}
$this->dispatcher->listen(class_exists(MessageLogged::class) ? MessageLogged::class : 'illuminate.log', $callback);
} | Register a new callback handler for when a log event is triggered.
@param \Closure $callback
@throws \RuntimeException
@return void | listen | php | bugsnag/bugsnag-laravel | src/EventTrait.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/EventTrait.php | MIT |
protected function cleanup()
{
Bugsnag::flush();
Bugsnag::clearBreadcrumbs();
Bugsnag::clearFeatureFlags();
// Reset metadata
// Bugsnag's default values are set in a report callback
// so it will be filled again on the next report
Bugsnag::setMetaData([], false);
} | Reset all data between requests, tasks and worker resets in Octane.
@return void | cleanup | php | bugsnag/bugsnag-laravel | src/OctaneEventSubscriber.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/OctaneEventSubscriber.php | MIT |
protected function getGuzzle(array $config)
{
// If a 'bugsnag.guzzle' instance exists in the container, use it
if ($this->app->bound('bugsnag.guzzle')) {
return $this->app->make('bugsnag.guzzle');
}
$options = [];
if (isset($config['proxy']) && $config['proxy']) {
if (isset($config['proxy']['http']) && php_sapi_name() != 'cli') {
unset($config['proxy']['http']);
}
$options['proxy'] = $config['proxy'];
}
return Client::makeGuzzle(null, $options);
} | Get the guzzle client instance.
@param array $config
@return \GuzzleHttp\ClientInterface | getGuzzle | php | bugsnag/bugsnag-laravel | src/BugsnagServiceProvider.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/BugsnagServiceProvider.php | MIT |
protected function getRuntimeVersion()
{
$version = $this->app->version();
if (preg_match('/(\d+\.\d+\.\d+)/', $version, $versionMatches)) {
$version = $versionMatches[0];
}
return [($this->app instanceof LumenApplication ? 'lumen' : 'laravel') => $version];
} | Returns the framework name and version to add to the device data.
Attempt to parse a semantic framework version from $app or else return
the full version string.
e.g. Lumen: "Lumen (x.x.x) (Laravel Components y.y.*)" => "x.x.x"
@return array | getRuntimeVersion | php | bugsnag/bugsnag-laravel | src/BugsnagServiceProvider.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/BugsnagServiceProvider.php | MIT |
protected function isSessionTrackingAllowed($config)
{
// Session support removed in Lumen 5.3 - only setup automatic session
// tracking if the session function is avaiable
return isset($config['auto_capture_sessions'])
&& $config['auto_capture_sessions']
&& function_exists('session');
} | Tests whether session tracking can/should be enabled.
@param array $config The configuration array
@return bool true if session tracking should be enabled. | isSessionTrackingAllowed | php | bugsnag/bugsnag-laravel | src/BugsnagServiceProvider.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/BugsnagServiceProvider.php | MIT |
public function bootstrap()
{
$this->reservedMemory = str_repeat(' ', 1024 * 256);
register_shutdown_function(function () {
$this->reservedMemory = null;
$lastError = error_get_last();
if (!$lastError) {
return;
}
$isOom = preg_match($this->oomRegex, $lastError['message'], $matches) === 1;
if (!$isOom) {
return;
}
/** @var \Bugsnag\Client|null $client */
$client = app('bugsnag');
// If the client exists and memory increase is enabled, bump the
// memory limit so we can report it. The client can be missing when
// the container isn't complete, e.g. when unit tests are running
if ($client && $client->getMemoryLimitIncrease() !== null) {
$currentMemoryLimit = (int) $matches[1];
ini_set('memory_limit', $currentMemoryLimit + $client->getMemoryLimitIncrease());
}
});
} | Allow Bugsnag to handle OOMs by registering a shutdown function that
increases the memory limit. This must happen before Laravel's shutdown
function is registered or it will have no effect.
@return void | bootstrap | php | bugsnag/bugsnag-laravel | src/OomBootstrapper.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/OomBootstrapper.php | MIT |
public function __construct(array $loggers, $dispatcher = null)
{
parent::__construct($loggers);
$this->dispatcher = $dispatcher;
} | Create a new multi logger instance.
@param \Psr\Log\LoggerInterface[] $loggers
@param \Illuminate\Contracts\Events\Dispatcher|null $dispatcher
@return void | __construct | php | bugsnag/bugsnag-laravel | src/MultiLogger.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/MultiLogger.php | MIT |
public function useDailyFiles($path, $days = 0, $level = 'debug')
{
foreach ($this->loggers as $logger) {
if ($logger instanceof Log) {
$logger->useDailyFiles($path, $days, $level);
}
}
} | Register a daily file log handler.
@param string $path
@param int $days
@param string $level
@return void | useDailyFiles | php | bugsnag/bugsnag-laravel | src/MultiLogger.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/MultiLogger.php | MIT |
public function getMonolog()
{
foreach ($this->loggers as $logger) {
if (is_callable([$logger, 'getMonolog'])) {
$monolog = $logger->getMonolog();
if ($monolog === null) {
continue;
}
return $monolog;
}
}
} | Get the underlying Monolog instance.
@return \Monolog\Logger | getMonolog | php | bugsnag/bugsnag-laravel | src/MultiLogger.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/MultiLogger.php | MIT |
public function __construct(Client $client, $dispatcher = null)
{
parent::__construct($client);
$this->dispatcher = $dispatcher;
} | Create a new laravel logger instance.
@param \Bugsnag\Client $client
@param \Illuminate\Contracts\Events\Dispatcher|null $dispatcher
@return void | __construct | php | bugsnag/bugsnag-laravel | src/LaravelLogger.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/LaravelLogger.php | MIT |
protected function formatMessage($message)
{
if (is_array($message)) {
return var_export($message, true);
}
if ($message instanceof Jsonable) {
return $message->toJson();
}
if ($message instanceof Arrayable) {
return var_export($message->toArray(), true);
}
return $message;
} | Format the parameters for the logger.
@param mixed $message
@return string | formatMessage | php | bugsnag/bugsnag-laravel | src/LaravelLogger.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/LaravelLogger.php | MIT |
public function get()
{
return $this->job;
} | Get the current job information.
@return array|null | get | php | bugsnag/bugsnag-laravel | src/Queue/Tracker.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/Queue/Tracker.php | MIT |
public function set(array $job)
{
$this->job = $job;
} | Set the current job information.
@param array $job
@return void | set | php | bugsnag/bugsnag-laravel | src/Queue/Tracker.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/Queue/Tracker.php | MIT |
public function clear()
{
$this->job = null;
} | Clear the current job information.
@return void | clear | php | bugsnag/bugsnag-laravel | src/Queue/Tracker.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/Queue/Tracker.php | MIT |
private function isVendor($class)
{
return $this->isInNamespace($class, self::LARAVEL_VENDOR_NAMESPACE)
|| $this->isInNamespace($class, self::LUMEN_VENDOR_NAMESPACE)
|| $this->isInNamespace($class, self::COLLISION_VENDOR_NAMESPACE);
} | Does the given class belong to a vendor namespace?
@see self::VENDOR_NAMESPACES
@param string $class
@return bool | isVendor | php | bugsnag/bugsnag-laravel | src/Internal/BacktraceProcessor.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/Internal/BacktraceProcessor.php | MIT |
private function isInNamespace($class, $namespace)
{
return substr($class, 0, strlen($namespace)) === $namespace;
} | Check if the given class is in the given namespace.
@param string $class
@param string $namespace
@return bool | isInNamespace | php | bugsnag/bugsnag-laravel | src/Internal/BacktraceProcessor.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/Internal/BacktraceProcessor.php | MIT |
private function isFrameworkExceptionHandler($class)
{
return $class === self::LARAVEL_HANDLER_CLASS
|| $class === self::LUMEN_HANDLER_CLASS;
} | Is the given class Laravel or Lumen's exception handler?
@param string $class
@return bool | isFrameworkExceptionHandler | php | bugsnag/bugsnag-laravel | src/Internal/BacktraceProcessor.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/Internal/BacktraceProcessor.php | MIT |
private function isAppExceptionHandler($class)
{
return $class === self::LARAVEL_APP_EXCEPTION_HANDLER
|| $class === self::LUMEN_APP_EXCEPTION_HANDLER;
} | Is the given class an App's exception handler?
@param string $class
@return bool | isAppExceptionHandler | php | bugsnag/bugsnag-laravel | src/Internal/BacktraceProcessor.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/Internal/BacktraceProcessor.php | MIT |
public function __construct(Container $app)
{
$this->app = $app;
} | Create a new laravel request resolver instance.
@param \Illuminate\Contracts\Container\Container $app
@return void | __construct | php | bugsnag/bugsnag-laravel | src/Request/LaravelResolver.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/src/Request/LaravelResolver.php | MIT |
protected function getPackageProviders($app)
{
return [
BugsnagServiceProvider::class,
];
} | Get the service provider class.
@param \Illuminate\Contracts\Foundation\Application $app
@return array<string> | getPackageProviders | php | bugsnag/bugsnag-laravel | tests/AbstractTestCase.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/tests/AbstractTestCase.php | MIT |
protected function getProperty($object, $property)
{
$propertyAccessor = function ($property) {
return $this->{$property};
};
return call_user_func($propertyAccessor->bindTo($object, $object), $property);
} | Get the value of the given property on the given object.
@param object $object
@param string $property
@return mixed | getProperty | php | bugsnag/bugsnag-laravel | tests/AbstractTestCase.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/tests/AbstractTestCase.php | MIT |
protected function setEnvironmentVariable($name, $value)
{
// Workaround a PHP 5 parser issue - '$app::VERSION' is valid but
// '$this->app::VERSION' is not
$app = $this->app;
// Laravel >= 5.8.0 uses "$_ENV" instead of "putenv" by default
if (version_compare($app::VERSION, '5.8.0', '>=')) {
$_ENV[$name] = $value;
} else {
putenv("{$name}={$value}");
}
} | Set the environment variable "$name" to the given value.
@param string $name
@param string $value
@return void | setEnvironmentVariable | php | bugsnag/bugsnag-laravel | tests/AbstractTestCase.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/tests/AbstractTestCase.php | MIT |
protected function removeEnvironmentVariable($name)
{
// Workaround a PHP 5 parser issue - '$app::VERSION' is valid but
// '$this->app::VERSION' is not
$app = $this->app;
// Laravel >= 5.8.0 uses "$_ENV" instead of "putenv" by default
if (version_compare($app::VERSION, '5.8.0', '>=')) {
unset($_ENV[$name]);
} else {
putenv("{$name}");
}
} | Remove the environment variable "$name" from the environment.
@param string $name
@param string $value
@return void | removeEnvironmentVariable | php | bugsnag/bugsnag-laravel | tests/AbstractTestCase.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/tests/AbstractTestCase.php | MIT |
protected static function backwardsCompatibleGetApplicationBasePath()
{
// testbench v4+
if (method_exists(static::class, 'applicationBasePath')) {
return static::applicationBasePath();
}
static $applicationBasePath;
if ($applicationBasePath) {
return $applicationBasePath;
}
$packages = ['testbench', 'testbench-core'];
$fixtureDirectories = ['fixture', 'laravel'];
$sourceDirectories = ['Concerns', 'Traits'];
$vendorDirectory = realpath(__DIR__.'/../vendor');
foreach ($packages as $package) {
foreach ($fixtureDirectories as $fixtureDirectory) {
foreach ($sourceDirectories as $sourceDirectory) {
$path = "{$vendorDirectory}/orchestra/{$package}/src/{$sourceDirectory}/../../{$fixtureDirectory}";
if (is_readable($path)) {
return $applicationBasePath = $path;
}
}
}
}
throw new Exception('Unable to determine application base path!');
} | A getter for the laravel app's base path that's backwards compatible with
testbench v3
@return string | backwardsCompatibleGetApplicationBasePath | php | bugsnag/bugsnag-laravel | tests/AbstractTestCase.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/tests/AbstractTestCase.php | MIT |
private static function pathToRegex($path)
{
return sprintf('/^%s[\\/]?/i', preg_quote($path, '/'));
} | Convert a file path to a regex that matches the path and any sub paths.
@param string $path
@return string | pathToRegex | php | bugsnag/bugsnag-laravel | tests/ServiceProviderTest.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/tests/ServiceProviderTest.php | MIT |
public function render($request, Exception $e)
{
return parent::render($request, $e);
} | Render an exception into an HTTP response.
@param \Illuminate\Http\Request $request
@param \Exception $e
@return \Illuminate\Http\Response | render | php | bugsnag/bugsnag-laravel | example/laravel-5.2/app/Exceptions/Handler.php | https://github.com/bugsnag/bugsnag-laravel/blob/master/example/laravel-5.2/app/Exceptions/Handler.php | MIT |
public function getEndpointTemplateMetaName()
{
return $this->container['endpoint_template_meta_name'];
} | Gets endpoint_template_meta_name
@return string|null | getEndpointTemplateMetaName | php | influxdata/influxdb-client-php | src/InfluxDB2/Model/TemplateSummarySummaryNotificationRules.php | https://github.com/influxdata/influxdb-client-php/blob/master/src/InfluxDB2/Model/TemplateSummarySummaryNotificationRules.php | MIT |
public function setEndpointTemplateMetaName($endpoint_template_meta_name)
{
$this->container['endpoint_template_meta_name'] = $endpoint_template_meta_name;
return $this;
} | Sets endpoint_template_meta_name
@param string|null $endpoint_template_meta_name endpoint_template_meta_name
@return $this | setEndpointTemplateMetaName | php | influxdata/influxdb-client-php | src/InfluxDB2/Model/TemplateSummarySummaryNotificationRules.php | https://github.com/influxdata/influxdb-client-php/blob/master/src/InfluxDB2/Model/TemplateSummarySummaryNotificationRules.php | MIT |
public function getResourceTemplateMetaName()
{
return $this->container['resource_template_meta_name'];
} | Gets resource_template_meta_name
@return string|null | getResourceTemplateMetaName | php | influxdata/influxdb-client-php | src/InfluxDB2/Model/TemplateSummarySummaryLabelMappings.php | https://github.com/influxdata/influxdb-client-php/blob/master/src/InfluxDB2/Model/TemplateSummarySummaryLabelMappings.php | MIT |
public function setResourceTemplateMetaName($resource_template_meta_name)
{
$this->container['resource_template_meta_name'] = $resource_template_meta_name;
return $this;
} | Sets resource_template_meta_name
@param string|null $resource_template_meta_name resource_template_meta_name
@return $this | setResourceTemplateMetaName | php | influxdata/influxdb-client-php | src/InfluxDB2/Model/TemplateSummarySummaryLabelMappings.php | https://github.com/influxdata/influxdb-client-php/blob/master/src/InfluxDB2/Model/TemplateSummarySummaryLabelMappings.php | MIT |
public static function toMin(iterable $data, ?callable $compareBy = null)
{
if ($compareBy !== null) {
return static::toValue(
$data,
fn ($carry, $datum) => $compareBy($datum) < $compareBy($carry ?? $datum)
? $datum
: $carry ?? $datum
);
}
return static::toValue($data, fn ($carry, $datum) => \min($carry ?? $datum, $datum));
} | Reduces given iterable to its min value.
Optional callable param $compareBy must return comparable value.
If $compareBy is not provided then items of given collection must be comparable.
Returns null if given collection is empty.
@param iterable<mixed> $data
@param callable|null $compareBy (optional) function to extract comparable value from element. Ex: $item->getSomeValue()
@return mixed|null | toMin | php | markrogoyski/itertools-php | src/Reduce.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Reduce.php | MIT |
public static function toMax(iterable $data, ?callable $compareBy = null)
{
if ($compareBy !== null) {
return static::toValue(
$data,
fn ($carry, $datum) => $compareBy($datum) > $compareBy($carry ?? $datum)
? $datum
: $carry ?? $datum
);
}
return static::toValue($data, fn ($carry, $datum) => \max($carry ?? $datum, $datum));
} | Reduces given iterable to its max value.
Optional callable param $compareBy must return comparable value.
If $compareBy is not provided then items of given collection must be comparable.
Returns null if given collection is empty.
@param iterable<mixed> $data
@param callable|null $compareBy (optional) function to extract comparable value from element. Ex: $item->getSomeValue()
@return mixed|null | toMax | php | markrogoyski/itertools-php | src/Reduce.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Reduce.php | MIT |
public static function toSum(iterable $data)
{
return static::toValue($data, fn ($carry, $datum) => $carry + $datum, 0);
} | Reduces given collection to the sum of its items.
@param iterable<numeric> $data
@return int|float | toSum | php | markrogoyski/itertools-php | src/Reduce.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Reduce.php | MIT |
public static function toProduct(iterable $data)
{
return static::toValue($data, fn ($carry, $datum) => ($carry ?? 1) * $datum);
} | Reduces given collection to the product of its items.
Returns null if given collection is empty.
@param iterable<numeric> $data
@return int|float|null | toProduct | php | markrogoyski/itertools-php | src/Reduce.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Reduce.php | MIT |
public static function toRange(iterable $numbers)
{
[$min, $max] = static::toMinMax($numbers);
return ($max ?? 0) - ($min ?? 0);
} | Reduces given collection to its range.
Returns 0 if given collection is empty.
@param iterable<numeric> $numbers
@return int|float | toRange | php | markrogoyski/itertools-php | src/Reduce.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Reduce.php | MIT |
public static function toFirst(iterable $data)
{
foreach ($data as $datum) {
return $datum;
}
throw new \LengthException('collection is empty');
} | Reduces given collection to its first value.
@param iterable<mixed> $data
@return mixed
@throws \LengthException if collection is empty | toFirst | php | markrogoyski/itertools-php | src/Reduce.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Reduce.php | MIT |
public static function toLast(iterable $data)
{
/** @var mixed|NoValueMonad $result */
$result = static::toValue($data, fn ($carry, $datum) => $datum, NoValueMonad::getInstance());
if ($result instanceof NoValueMonad) {
throw new \LengthException('collection is empty');
}
return $result;
} | Reduces given collection to its last value.
@param iterable<mixed> $data
@return mixed
@throws \LengthException if collection is empty | toLast | php | markrogoyski/itertools-php | src/Reduce.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Reduce.php | MIT |
public static function toRandomValue(iterable $data)
{
if (\is_countable($data)) {
if (\count($data) === 0) {
throw new \LengthException('Given iterable must be non-empty');
}
$targetIndex = \mt_rand(0, \count($data) - 1);
$index = 0;
foreach ($data as $datum) {
if ($targetIndex === $index) {
return $datum;
}
++$index;
}
}
$data = Transform::toArray($data);
if (\count($data) === 0) {
throw new \LengthException('Given iterable must be non-empty');
}
return $data[\array_rand($data)];
} | Reduces given collection random value in from within it.
@param iterable<mixed> $data
@return mixed
@throws \LengthException if given iterable is empty | toRandomValue | php | markrogoyski/itertools-php | src/Reduce.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Reduce.php | MIT |
public static function toNth(iterable $data, int $position)
{
if (\is_countable($data) && \count($data) <= $position) {
throw new \LengthException("Given iterable does not contain item with position {$position}");
}
$i = 0;
foreach ($data as $datum) {
if ($i === $position) {
return $datum;
}
++$i;
}
throw new \LengthException("Given iterable does not contain item with position {$position}");
} | Reduces given iterable to the value at the nth position.
@template T
@param iterable<T> $data
@param int $position
@return T
@throws \LengthException if given iterable does not contain item with target position. | toNth | php | markrogoyski/itertools-php | src/Reduce.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Reduce.php | MIT |
public function toAverage()
{
/** @var iterable<numeric> $iterable */
$iterable = $this->iterable;
return Reduce::toAverage($iterable);
} | Reduces iterable source to the mean average of its items.
Returns null if iterable source is empty.
@return int|float|null
@see Reduce::toAverage() | toAverage | php | markrogoyski/itertools-php | src/Stream.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Stream.php | MIT |
public function toMax(?callable $compareBy = null)
{
return Reduce::toMax($this->iterable, $compareBy);
} | Reduces iterable source to its max value.
Callable param $compareBy must return comparable value.
If $compareBy is not proposed then items of iterable source must be comparable.
Returns null if iterable source is empty.
@param callable|null $compareBy
@return mixed
@see Reduce::toMax() | toMax | php | markrogoyski/itertools-php | src/Stream.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Stream.php | MIT |
public function toMin(?callable $compareBy = null)
{
return Reduce::toMin($this->iterable, $compareBy);
} | Reduces iterable source to its min value.
Callable param $compareBy must return comparable value.
If $compareBy is not proposed then items of iterable source must be comparable.
Returns null if iterable source is empty.
@param callable|null $compareBy
@return mixed
@see Reduce::toMin() | toMin | php | markrogoyski/itertools-php | src/Stream.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Stream.php | MIT |
public function toProduct()
{
/** @var iterable<numeric> $iterable */
$iterable = $this->iterable;
return Reduce::toProduct($iterable);
} | Reduces iterable source to the product of its items.
Returns null if iterable source is empty.
@return int|float|null
@see Reduce::toProduct() | toProduct | php | markrogoyski/itertools-php | src/Stream.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Stream.php | MIT |
public function toSum()
{
/** @var iterable<numeric> $iterable */
$iterable = $this->iterable;
return Reduce::toSum($iterable);
} | Reduces iterable source to the sum of its items.
@return int|float
@see Reduce::toSum() | toSum | php | markrogoyski/itertools-php | src/Stream.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Stream.php | MIT |
public function toRange()
{
/** @var iterable<numeric> $iterable */
$iterable = $this->iterable;
return Reduce::toRange($iterable);
} | Reduces iterable source to its amplitude.
Returns 0 if iterable source is empty.
@return int|float
@see Reduce::toRange() | toRange | php | markrogoyski/itertools-php | src/Stream.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Stream.php | MIT |
public function toFirst()
{
return Reduce::toFirst($this->iterable);
} | Returns the first element of iterable source.
@return mixed
@throws \LengthException if iterable source is empty.
@see Reduce::toFirst() | toFirst | php | markrogoyski/itertools-php | src/Stream.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Stream.php | MIT |
public function toLast()
{
return Reduce::toLast($this->iterable);
} | Returns the last element of iterable source.
@return mixed
@throws \LengthException if iterable source is empty.
@see Reduce::toLast() | toLast | php | markrogoyski/itertools-php | src/Stream.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Stream.php | MIT |
public function toRandomValue()
{
return Reduce::toRandomValue($this->iterable);
} | Returns a random element of stream.
@return mixed
@throws \LengthException if iterable source is empty.
@see Reduce::toRandomValue() | toRandomValue | php | markrogoyski/itertools-php | src/Stream.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Stream.php | MIT |
public function toValue(callable $reducer, $initialValue = null)
{
return Reduce::toValue($this->iterable, $reducer, $initialValue);
} | Reduces iterable source like array_reduce() function.
But unlike array_reduce(), it works with all iterable types.
@param callable $reducer
@param mixed $initialValue
@return mixed
@see Reduce::toValue() | toValue | php | markrogoyski/itertools-php | src/Stream.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Stream.php | MIT |
public function toNth(int $position)
{
return Reduce::toNth($this->iterable, $position);
} | Reduces iterable source to its nth element.
@param int $position
@return mixed
@see Reduce::toNth() | toNth | php | markrogoyski/itertools-php | src/Stream.php | https://github.com/markrogoyski/itertools-php/blob/master/src/Stream.php | MIT |
public function __construct(
protected Repository $config,
protected Request $request,
protected string $input,
protected string $safeDeviceInput,
) {
//
} | Creates a new Laraguard instance. | __construct | php | Laragear/TwoFactor | src/TwoFactor.php | https://github.com/Laragear/TwoFactor/blob/master/src/TwoFactor.php | MIT |
public function __construct(
protected AuthManager $auth,
protected Session $session,
protected Request $request,
protected string $view,
protected string $sessionKey,
protected bool $useFlash,
protected string $input = '2fa_code',
protected ?string $guard = null,
protected ?string $message = null,
protected string $redirect = '',
) {
//
} | Create a new Two-Factor Login Helper instance. | __construct | php | Laragear/TwoFactor | src/TwoFactorLoginHelper.php | https://github.com/Laragear/TwoFactor/blob/master/src/TwoFactorLoginHelper.php | MIT |
public function __construct(protected ?Authenticatable $user = null)
{
//
} | Create a new "totp code" rule instance. | __construct | php | Laragear/TwoFactor | src/Rules/Totp.php | https://github.com/Laragear/TwoFactor/blob/master/src/Rules/Totp.php | MIT |
protected function registerAssets()
{
InfiniteAjaxScrollAsset::register($this->view);
} | Register required asset bundles.
You can override this method in case if you want to use your own JQuery Infinite Ajax Scroll plugin files
(for example, some forked plugin version). | registerAssets | php | kop/yii2-scroll-pager | ScrollPager.php | https://github.com/kop/yii2-scroll-pager/blob/master/ScrollPager.php | MIT |
protected function checkEnabledExtensions($extensions)
{
$extensions = (array)$extensions;
if (empty($extensions)) {
return true;
} else {
return (count(array_intersect($this->enabledExtensions, $extensions)) == count($extensions));
}
} | Check whether the given extensions are enabled.
@param string|array $extensions Single or multiple extensions names.
@return bool Operation result. | checkEnabledExtensions | php | kop/yii2-scroll-pager | ScrollPager.php | https://github.com/kop/yii2-scroll-pager/blob/master/ScrollPager.php | MIT |
public function assertReceivedTimes($event, $times = 1)
{
$count = $this->received($event)->count();
assertSame(
$times,
$count,
"The expected [{$event}] event was received {$count} times instead of {$times} times."
);
} | Assert if an event was received a number of times.
@param string $event
@param int $times
@return void | assertReceivedTimes | php | qruto/laravel-wave | tests/Pest.php | https://github.com/qruto/laravel-wave/blob/master/tests/Pest.php | MIT |
public function hasReceived($event)
{
return isset($this->getSentEvents()[$event]) && ! empty($this->getSentEvents()[$event]);
} | Determine if the given event has been received.
@param string $event
@return bool | hasReceived | php | qruto/laravel-wave | tests/Pest.php | https://github.com/qruto/laravel-wave/blob/master/tests/Pest.php | MIT |
public function __construct()
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be renamed to SilverStripe\\Forms\\Validation\\RequiredFieldsValidator',
Deprecation::SCOPE_CLASS
);
$required = func_get_args();
if (isset($required[0]) && is_array($required[0])) {
$required = $required[0];
}
if (!empty($required)) {
$this->required = ArrayLib::valuekey($required);
} else {
$this->required = [];
}
parent::__construct();
} | Pass each field to be validated as a separate argument to the constructor
of this object. (an array of elements are ok). | __construct | php | silverstripe/silverstripe-framework | src/Forms/RequiredFields.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/RequiredFields.php | BSD-3-Clause |
public function setAllowWhitespaceOnly(?bool $allow)
{
$this->allowWhitespaceOnly = $allow;
} | Set whether to allow whitespace only as a valid value for a required field | setAllowWhitespaceOnly | php | silverstripe/silverstripe-framework | src/Forms/RequiredFields.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/RequiredFields.php | BSD-3-Clause |
public function removeValidation()
{
parent::removeValidation();
$this->required = [];
return $this;
} | Clears all the validation from this object.
@return $this | removeValidation | php | silverstripe/silverstripe-framework | src/Forms/RequiredFields.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/RequiredFields.php | BSD-3-Clause |
public function addRequiredField($field)
{
$this->required[$field] = $field;
return $this;
} | Adds a single required field to required fields stack.
@param string $field
@return $this | addRequiredField | php | silverstripe/silverstripe-framework | src/Forms/RequiredFields.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/RequiredFields.php | BSD-3-Clause |
public function fieldIsRequired($fieldName)
{
return isset($this->required[$fieldName]);
} | Returns true if the named field is "required".
Used by {@link FormField} to return a value for FormField::Required(),
to do things like show *s on the form template.
@param string $fieldName
@return boolean | fieldIsRequired | php | silverstripe/silverstripe-framework | src/Forms/RequiredFields.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/RequiredFields.php | BSD-3-Clause |
public function __construct(
RequestHandler $controller = null,
$name = Form::DEFAULT_NAME,
FieldList $fields = null,
FieldList $actions = null,
Validator $validator = null
) {
parent::__construct();
$fields = $fields ? $fields : FieldList::create();
$actions = $actions ? $actions : FieldList::create();
$fields->setForm($this);
$actions->setForm($this);
$this->fields = $fields;
$this->actions = $actions;
$this->setController($controller);
$this->setName($name);
// Form validation
$this->validator = ($validator) ? $validator : new RequiredFields();
$this->validator->setForm($this);
// Form error controls
$this->restoreFormState();
// Check if CSRF protection is enabled, either on the parent controller or from the default setting. Note that
// method_exists() is used as some controllers (e.g. GroupTest) do not always extend from Object.
if (ClassInfo::hasMethod($controller, 'securityTokenEnabled')) {
$securityEnabled = $controller->securityTokenEnabled();
} else {
$securityEnabled = SecurityToken::is_enabled();
}
$this->securityToken = ($securityEnabled) ? new SecurityToken() : new NullSecurityToken();
$this->setupDefaultClasses();
} | Create a new form, with the given fields an action buttons.
@param RequestHandler $controller Optional parent request handler
@param string $name The method on the controller that will return this form object.
@param FieldList $fields All of the fields in the form - a {@link FieldList} of {@link FormField} objects.
@param FieldList $actions All of the action buttons in the form - a {@link FieldLis} of
{@link FormAction} objects
@param Validator|null $validator Override the default validator instance (Default: {@link RequiredFields}) | __construct | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function restoreFormState()
{
// Restore messages
$result = $this->getSessionValidationResult();
if (isset($result)) {
$this->loadMessagesFrom($result);
}
// load data in from previous submission upon error
$data = $this->getSessionData();
if (isset($data)) {
$this->loadDataFrom($data, Form::MERGE_AS_INTERNAL_VALUE);
}
return $this;
} | Load form state from session state
@return $this | restoreFormState | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function clearFormState()
{
$this
->getSession()
->clear("FormInfo.{$this->FormName()}.result")
->clear("FormInfo.{$this->FormName()}.data");
return $this;
} | Flush persistent form state details
@return $this | clearFormState | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
protected function getRequest()
{
// Check if current request handler has a request object
$controller = $this->getController();
if ($controller && !($controller->getRequest() instanceof NullHTTPRequest)) {
return $controller->getRequest();
}
// Fall back to current controller
if (Controller::has_curr() && !(Controller::curr()->getRequest() instanceof NullHTTPRequest)) {
return Controller::curr()->getRequest();
}
return null;
} | Helper to get current request for this form
@return HTTPRequest|null | getRequest | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function getSessionData()
{
return $this->getSession()->get("FormInfo.{$this->FormName()}.data");
} | Return any form data stored in the session
@return array | getSessionData | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setSessionData($data)
{
$this->getSession()->set("FormInfo.{$this->FormName()}.data", $data);
return $this;
} | Store the given form data in the session
@param array $data
@return $this | setSessionData | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function getSessionValidationResult()
{
$resultData = $this->getSession()->get("FormInfo.{$this->FormName()}.result");
if (isset($resultData)) {
return unserialize($resultData ?? '');
}
return null;
} | Return any ValidationResult instance stored for this object
@return ValidationResult|null The ValidationResult object stored in the session | getSessionValidationResult | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setSessionValidationResult(ValidationResult $result, $combineWithExisting = false)
{
// Combine with existing result
if ($combineWithExisting) {
$existingResult = $this->getSessionValidationResult();
if ($existingResult) {
if ($result) {
$existingResult->combineAnd($result);
} else {
$result = $existingResult;
}
}
}
// Serialise
$resultData = $result ? serialize($result) : null;
$this->getSession()->set("FormInfo.{$this->FormName()}.result", $resultData);
return $this;
} | Sets the ValidationResult in the session to be used with the next view of this form.
@param ValidationResult $result The result to save
@param bool $combineWithExisting If true, then this will be added to the existing result.
@return $this | setSessionValidationResult | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function clearMessage()
{
$this->setMessage(null);
$this->clearFormState();
return $this;
} | Clear form message (and in session)
@return $this | clearMessage | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setFieldMessage(
$fieldName,
$message,
$messageType = ValidationResult::TYPE_ERROR,
$messageCast = ValidationResult::CAST_TEXT
) {
$field = $this->fields->dataFieldByName($fieldName);
if ($field) {
$field->setMessage($message, $messageType, $messageCast);
}
return $this;
} | Set message on a given field name. This message will not persist via redirect.
@param string $fieldName
@param string $message
@param string $messageType
@param string $messageCast
@return $this | setFieldMessage | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function makeReadonly()
{
$this->transform(new ReadonlyTransformation());
return $this;
} | Convert this form into a readonly form
@return $this | makeReadonly | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setRedirectToFormOnValidationError($bool)
{
$this->redirectToFormOnValidationError = $bool;
return $this;
} | Set whether the user should be redirected back down to the
form on the page upon validation errors in the form or if
they just need to redirect back to the page
@param bool $bool Redirect to form on error?
@return $this | setRedirectToFormOnValidationError | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function getRedirectToFormOnValidationError()
{
return $this->redirectToFormOnValidationError;
} | Get whether the user should be redirected back down to the
form on the page upon validation errors
@return bool | getRedirectToFormOnValidationError | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setValidationExemptActions($actions)
{
$this->validationExemptActions = $actions;
return $this;
} | Set actions that are exempt from validation
@param array $actions
@return $this | setValidationExemptActions | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function getValidationExemptActions()
{
return $this->validationExemptActions;
} | Get a list of actions that are exempt from validation
@return array | getValidationExemptActions | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function actionIsValidationExempt($action)
{
// Non-actions don't bypass validation
if (!$action) {
return false;
}
if ($action->getValidationExempt()) {
return true;
}
if (in_array($action->actionName(), $this->getValidationExemptActions() ?? [])) {
return true;
}
return false;
} | Passed a FormAction, returns true if that action is exempt from Form validation
@param FormAction $action
@return bool | actionIsValidationExempt | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function getExtraFields()
{
$extraFields = new FieldList();
$token = $this->getSecurityToken();
if ($token) {
$tokenField = $token->updateFieldSet($this->fields);
if ($tokenField) {
$tokenField->setForm($this);
}
}
$this->securityTokenAdded = true;
// add the "real" HTTP method if necessary (for PUT, DELETE and HEAD)
if (strtoupper($this->FormMethod() ?? '') != $this->FormHttpMethod()) {
$methodField = new HiddenField('_method', '', $this->FormHttpMethod());
$methodField->setForm($this);
$extraFields->push($methodField);
}
return $extraFields;
} | Generate extra special fields - namely the security token field (if required).
@return FieldList | getExtraFields | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function Fields()
{
foreach ($this->getExtraFields() as $field) {
if (!$this->fields->fieldByName($field->getName())) {
$this->fields->push($field);
}
}
return $this->fields;
} | Return the form's fields - used by the templates
@return FieldList The form fields | Fields | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function HiddenFields()
{
return $this->Fields()->HiddenFields();
} | Return all <input type="hidden"> fields
in a form - including fields nested in {@link CompositeFields}.
Useful when doing custom field layouts.
@return FieldList | HiddenFields | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function VisibleFields()
{
return $this->Fields()->VisibleFields();
} | Return all fields except for the hidden fields.
Useful when making your own simplified form layouts. | VisibleFields | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function Actions()
{
return $this->actions;
} | Return the form's action buttons - used by the templates
@return FieldList The action list | Actions | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setTemplateHelper($helper)
{
$this->templateHelper = $helper;
} | Set the target of this form to any value - useful for opening the form contents in a new window or refreshing
another frame
@param string|FormTemplateHelper $helper | setTemplateHelper | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function getTemplateHelper()
{
if ($this->templateHelper) {
if (is_string($this->templateHelper)) {
return Injector::inst()->get($this->templateHelper);
}
return $this->templateHelper;
}
return FormTemplateHelper::singleton();
} | Return a {@link FormTemplateHelper} for this form. If one has not been
set, return the default helper.
@return FormTemplateHelper | getTemplateHelper | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setTarget($target)
{
$this->target = $target;
return $this;
} | Set the target of this form to any value - useful for opening the form
contents in a new window or refreshing another frame.
@param string $target The value of the target
@return $this | setTarget | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setLegend($legend)
{
$this->legend = $legend;
return $this;
} | Set the legend value to be inserted into
the <legend> element in the Form.ss template.
@param string $legend
@return $this | setLegend | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setTemplate($template)
{
$this->template = $template;
return $this;
} | Set the SS template that this form should use
to render with. The default is "Form".
@param string|array $template The name of the template (without the .ss extension) or array form
@return $this | setTemplate | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function getTemplates()
{
$templates = SSViewer::get_templates_by_class(static::class, '', __CLASS__);
// Prefer any custom template
if ($this->getTemplate()) {
array_unshift($templates, $this->getTemplate());
}
return $templates;
} | Returns the ordered list of preferred templates for rendering this form
If the template isn't set, then default to the
form class name e.g "Form".
@return array | getTemplates | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function getEncType()
{
if ($this->encType) {
return $this->encType;
}
if ($fields = $this->fields->dataFields()) {
foreach ($fields as $field) {
if ($field instanceof FileField) {
return Form::ENC_TYPE_MULTIPART;
}
}
}
return Form::ENC_TYPE_URLENCODED;
} | Returns the encoding type for the form.
By default this will be URL encoded, unless there is a file field present
in which case multipart is used. You can also set the enc type using
{@link setEncType}. | getEncType | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setEncType($encType)
{
$this->encType = $encType;
return $this;
} | Sets the form encoding type. The most common encoding types are defined
in {@link ENC_TYPE_URLENCODED} and {@link ENC_TYPE_MULTIPART}.
@param string $encType
@return $this | setEncType | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function FormHttpMethod()
{
return $this->formMethod;
} | Returns the real HTTP method for the form:
GET, POST, PUT, DELETE or HEAD.
As most browsers only support GET and POST in
form submissions, all other HTTP methods are
added as a hidden field "_method" that
gets evaluated in {@link HTTPRequest::detect_method()}.
See {@link FormMethod()} to get a HTTP method
for safe insertion into a <form> tag.
@return string HTTP method | FormHttpMethod | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function FormMethod()
{
if (in_array($this->formMethod, ['GET','POST'])) {
return $this->formMethod;
} else {
return 'POST';
}
} | Returns the form method to be used in the <form> tag.
See {@link FormHttpMethod()} to get the "real" method.
@return string Form HTTP method restricted to 'GET' or 'POST' | FormMethod | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setFormMethod($method, $strict = null)
{
$this->formMethod = strtoupper($method ?? '');
if ($strict !== null) {
$this->setStrictFormMethodCheck($strict);
}
return $this;
} | Set the form method: GET, POST, PUT, DELETE.
@param string $method
@param bool $strict If non-null, pass value to {@link setStrictFormMethodCheck()}.
@return $this | setFormMethod | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setStrictFormMethodCheck($bool)
{
$this->strictFormMethodCheck = (bool)$bool;
return $this;
} | If set to true (the default), enforces the matching of the form method.
This will mean two things:
- GET vars will be ignored by a POST form, and vice versa
- A submission where the HTTP method used doesn't match the form will return a 400 error.
If set to false then the form method is only used to construct the default
form.
@param $bool boolean
@return $this | setStrictFormMethodCheck | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function FormAction()
{
if ($this->formActionPath) {
return $this->formActionPath;
}
// Get action from request handler link
return $this->getRequestHandler()->Link();
} | Return the form's action attribute.
This is build by adding an executeForm get variable to the parent controller's Link() value
@return string | FormAction | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setFormAction($path)
{
$this->formActionPath = $path;
return $this;
} | Set the form action attribute to a custom URL.
Note: For "normal" forms, you shouldn't need to use this method. It is
recommended only for situations where you have two relatively distinct
parts of the system trying to communicate via a form post.
@param string $path
@return $this | setFormAction | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setHTMLID($id)
{
$this->htmlID = $id;
return $this;
} | Set the HTML ID attribute of the form.
@param string $id
@return $this | setHTMLID | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
public function setController(RequestHandler $controller = null)
{
$this->controller = $controller;
return $this;
} | Set the controller or parent request handler.
@param RequestHandler $controller
@return $this | setController | php | silverstripe/silverstripe-framework | src/Forms/Form.php | https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form.php | BSD-3-Clause |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.