abstract class Component (View source)

Properties

protected array $except

The properties / methods that should not be exposed to the component.

string $componentName

The component alias name.

ComponentAttributeBag $attributes

The component attributes.

static protected Factory|null $factory

The view factory instance, if any.

static protected $componentsResolver

The component resolver callback.

static protected array<string,string> $bladeViewCache

The cache of blade view names, keyed by contents.

static protected array $propertyCache

The cache of public property names, keyed by class.

static protected array $methodCache

The cache of public method names, keyed by class.

static protected array<class-string,array<int,string>> $constructorParametersCache

The cache of constructor parameters, keyed by class.

static protected array $ignoredParameterNames

The cache of ignored parameter names.

Methods

render()

Get the view / view contents that represent the component.

static Component
resolve(array $data)

Resolve the component instance with the given data.

static array
extractConstructorParameters()

Extract the constructor parameters for the component.

resolveView()

Resolve the Blade view or view file that should be used when rendering the component.

string
extractBladeViewFromString(string $contents)

Create a Blade view with the raw component string content.

string
createBladeViewFromString(Factory $factory, string $contents)

Create a Blade view with the raw component string content.

array
data()

Get the data that should be supplied to the view.

array
extractPublicProperties()

Extract the public properties for the component.

array
extractPublicMethods()

Extract the public methods for the component.

mixed
createVariableFromMethod(ReflectionMethod $method)

Create a callable variable from the given method.

createInvokableVariable(string $method)

Create an invokable, toStringable variable for the given component method.

bool
shouldIgnore(string $name)

Determine if the given property / method should be ignored.

array
ignoredMethods()

Get the methods that should be ignored.

$this
withName(string $name)

Set the component alias name.

$this
withAttributes(array $attributes)

Set the extra attributes that the component should make available.

newAttributeBag(array $attributes = [])

Get a new attribute bag instance.

bool
shouldRender()

Determine if the component should be rendered.

view(string|null $view, Arrayable|array $data = [], array $mergeData = [])

Get the evaluated view contents for the given view.

factory()

Get the view factory instance.

static array
ignoredParameterNames()

Get the cached set of anonymous component constructor parameter names to exclude.

static void
flushCache()

Flush the component's cached state.

static void
forgetFactory()

Forget the component's factory instance.

static void
forgetComponentsResolver()

Forget the component's resolver callback.

static void
resolveComponentsUsing($resolver)

Set the callback that should be used to resolve components within views.

Details

abstract View|Htmlable|Closure|string render()

Get the view / view contents that represent the component.

Return Value

View|Htmlable|Closure|string

static Component resolve(array $data)

Resolve the component instance with the given data.

Parameters

array $data

Return Value

Component

static protected array extractConstructorParameters()

Extract the constructor parameters for the component.

Return Value

array

View|Htmlable|Closure|string resolveView()

Resolve the Blade view or view file that should be used when rendering the component.

Return Value

View|Htmlable|Closure|string

protected string extractBladeViewFromString(string $contents)

Create a Blade view with the raw component string content.

Parameters

string $contents

Return Value

string

protected string createBladeViewFromString(Factory $factory, string $contents)

Create a Blade view with the raw component string content.

Parameters

Factory $factory
string $contents

Return Value

string

array data()

Get the data that should be supplied to the view.

Return Value

array

protected array extractPublicProperties()

Extract the public properties for the component.

Return Value

array

protected array extractPublicMethods()

Extract the public methods for the component.

Return Value

array

protected mixed createVariableFromMethod(ReflectionMethod $method)

Create a callable variable from the given method.

Parameters

ReflectionMethod $method

Return Value

mixed

protected InvokableComponentVariable createInvokableVariable(string $method)

Create an invokable, toStringable variable for the given component method.

Parameters

string $method

Return Value

InvokableComponentVariable

protected bool shouldIgnore(string $name)

Determine if the given property / method should be ignored.

Parameters

string $name

Return Value

bool

protected array ignoredMethods()

Get the methods that should be ignored.

Return Value

array

$this withName(string $name)

Set the component alias name.

Parameters

string $name

Return Value

$this

$this withAttributes(array $attributes)

Set the extra attributes that the component should make available.

Parameters

array $attributes

Return Value

$this

protected ComponentAttributeBag newAttributeBag(array $attributes = [])

Get a new attribute bag instance.

Parameters

array $attributes

Return Value

ComponentAttributeBag

bool shouldRender()

Determine if the component should be rendered.

Return Value

bool

View view(string|null $view, Arrayable|array $data = [], array $mergeData = [])

Get the evaluated view contents for the given view.

Parameters

string|null $view
Arrayable|array $data
array $mergeData

Return Value

View

protected Factory factory()

Get the view factory instance.

Return Value

Factory

static array ignoredParameterNames()

Get the cached set of anonymous component constructor parameter names to exclude.

Return Value

array

static void flushCache()

Flush the component's cached state.

Return Value

void

static void forgetFactory()

Forget the component's factory instance.

Return Value

void

static void forgetComponentsResolver()

internal  
 

Forget the component's resolver callback.

Return Value

void

static void resolveComponentsUsing($resolver)

internal  
 

Set the callback that should be used to resolve components within views.

Parameters

$resolver

Return Value

void