View
class View implements ArrayAccess, Htmlable, Stringable, View
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected array | $data | The array of view data. |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically bind parameters to the view.
Create a new view instance.
Get the evaluated contents of a given fragment.
Get the evaluated contents for a given array of fragments or return all fragments.
Get the evaluated contents of a given fragment if the given condition is true.
Get the evaluated contents for a given array of fragments if the given condition is true.
Get all fragments as a single string.
Get the string contents of the view.
Render the view and return the callback result or the contents.
Get the contents of the view instance.
Get the view contents while notifying completion observers.
Get the evaluated contents of the view.
Get the data bound to the view instance.
Get the sections of the rendered view.
Add validation errors to the view.
Parse the given errors into an appropriate value.
Get the name of the view.
Get the name of the view.
Get the array of view data.
Get the path to the view file.
Set the path to the view.
Get the view factory instance.
Determine if a piece of data is bound.
Get a piece of bound data to the view.
Set a piece of data on the view.
Unset a piece of data from the view.
Flush all static state.
Get a piece of data from the view.
Set a piece of data on the view.
Check if a piece of data is bound to the view.
Remove a piece of bound data from the view.
Get content as a string of HTML.
Get the string contents of the view.
Details
in
Macroable at line 30
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 44
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 61
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 72
static void
flushMacros()
Flush the existing macros.
Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 83
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
at line 443
mixed
__call(string $method, array $parameters)
Dynamically bind parameters to the view.
at line 43
__construct(Factory $factory, Engine $engine, string $view, string $path, mixed $data = [])
Create a new view instance.
at line 56
HtmlString
fragment(string $fragment)
Get the evaluated contents of a given fragment.
at line 68
string
fragments(array|null $fragments = null)
Get the evaluated contents for a given array of fragments or return all fragments.
at line 78
string|Htmlable
fragmentIf(bool $boolean, string $fragment)
Get the evaluated contents of a given fragment if the given condition is true.
at line 90
string
fragmentsIf(bool $boolean, array|null $fragments = null)
Get the evaluated contents for a given array of fragments if the given condition is true.
at line 102
protected string
allFragments()
Get all fragments as a single string.
at line 113
string
render(callable|null $callback = null)
Get the string contents of the view.
at line 128
protected mixed
doRender(callable|null $callback = null)
Render the view and return the callback result or the contents.
at line 151
protected string
renderContents()
Get the contents of the view instance.
at line 179
protected string
renderContentsWithObservers()
Get the view contents while notifying completion observers.
at line 210
protected string
getContents()
Get the evaluated contents of the view.
at line 218
array
gatherData()
Get the data bound to the view instance.
at line 239
array
renderSections()
Get the sections of the rendered view.
This function is similar to render. We need to call renderContents function first.
Because sections are only populated during the view rendering process.
at line 264
View
with(string|array $key, mixed $value = null)
Add a piece of data to the view.
at line 280
View
nest(string $key, string $view, array $data = [])
Add a view instance to the view data.
at line 290
View
withErrors(MessageProvider|array|string $provider, string $bag = 'default')
Add validation errors to the view.
at line 301
protected MessageBag
formatErrors(MessageProvider|array|string $provider)
Parse the given errors into an appropriate value.
at line 311
string
name()
Get the name of the view.
at line 319
string
getName()
Get the name of the view.
at line 327
array
getData()
Get the array of view data.
at line 335
string
getPath()
Get the path to the view file.
at line 343
void
setPath(string $path)
Set the path to the view.
at line 351
Factory
getFactory()
Get the view factory instance.
at line 359
Engine
getEngine()
Get the view's rendering engine.
at line 367
bool
offsetExists(mixed $offset)
Determine if a piece of data is bound.
at line 375
mixed
offsetGet(mixed $offset)
Get a piece of bound data to the view.
at line 383
void
offsetSet(mixed $offset, mixed $value)
Set a piece of data on the view.
at line 391
void
offsetUnset(mixed $offset)
Unset a piece of data from the view.
at line 399
static void
flushState()
Flush all static state.
at line 407
mixed
__get(string $key)
Get a piece of data from the view.
at line 415
void
__set(string $key, mixed $value)
Set a piece of data on the view.
at line 423
bool
__isset(string $key)
Check if a piece of data is bound to the view.
at line 431
void
__unset(string $key)
Remove a piece of bound data from the view.
at line 465
string
toHtml()
Get content as a string of HTML.
at line 475
string
__toString()
Get the string contents of the view.