class Factory implements Factory (View source)

Methods

void
__construct(EngineResolver $engines, ViewFinderInterface $finder, Dispatcher $events)

Create a new view factory instance.

file(string $path, array $data = array(), array $mergeData = array())

Get the evaluated view contents for the given view.

make(string $view, array $data = array(), array $mergeData = array())

Get the evaluated view contents for the given view.

of(string $view, mixed $data = array())

Get the evaluated view contents for a named view.

void
name(string $view, string $name)

Register a named view.

void
alias(string $view, string $alias)

Add an alias for a view.

bool
exists(string $view)

Determine if a given view exists.

string
renderEach(string $view, array $data, string $iterator, string $empty = 'raw|')

Get the rendered contents of a partial from a loop.

getEngineFromPath(string $path)

Get the appropriate view engine for the given path.

mixed
share(array|string $key, mixed $value = null)

Add a piece of shared data to the environment.

array
creator(array|string $views, Closure|string $callback)

Register a view creator event.

array
composers(array $composers)

Register multiple view composers via an array.

array
composer(array|string $views, Closure|string $callback, int|null $priority = null)

Register a view composer event.

void
callComposer(View $view)

Call the composer for a given view.

void
callCreator(View $view)

Call the creator for a given view.

void
startSection(string $section, string $content = '')

Start injecting content into a section.

void
inject(string $section, string $content)

Inject inline content into a section.

string
yieldSection()

Stop injecting content into a section and return its contents.

string
stopSection(bool $overwrite = false)

Stop injecting content into a section.

string
appendSection()

Stop injecting content into a section and append it.

string
yieldContent(string $section, string $default = '')

Get the string contents of a section.

void
startPush(string $section, string $content = '')

Start injecting content into a push section.

string
stopPush()

Stop injecting content into a push section.

string
yieldPushContent(string $section, string $default = '')

Get the string contents of a push section.

void
flushSections()

Flush all of the section contents.

void
flushSectionsIfDoneRendering()

Flush all of the section contents if done rendering.

void
incrementRender()

Increment the rendering counter.

void
decrementRender()

Decrement the rendering counter.

bool
doneRendering()

Check if there are no active render operations.

void
addLoop(Countable|array $data)

Add new loop to the stack.

void
incrementLoopIndices()

Increment the top loop's indices.

void
popLoop()

Pop a loop from the top of the loop stack.

array
getFirstLoop()

Get an instance of the first loop in the stack.

array
getLoopStack()

Get the entire loop stack.

void
addLocation(string $location)

Add a location to the array of view locations.

void
addNamespace(string $namespace, string|array $hints)

Add a new namespace to the loader.

void
prependNamespace(string $namespace, string|array $hints)

Prepend a new namespace to the loader.

void
addExtension(string $extension, string $engine, Closure $resolver = null)

Register a valid view extension and its engine.

array
getExtensions()

Get the extension to engine bindings.

getEngineResolver()

Get the engine resolver instance.

getFinder()

Get the view finder instance.

void
setFinder(ViewFinderInterface $finder)

Set the view finder instance.

getDispatcher()

Get the event dispatcher instance.

void
setDispatcher(Dispatcher $events)

Set the event dispatcher instance.

getContainer()

Get the IoC container instance.

void
setContainer(Container $container)

Set the IoC container instance.

mixed
shared(string $key, mixed $default = null)

Get an item from the shared data.

array
getShared()

Get all of the shared data for the environment.

bool
hasSection(string $name)

Check if section exists.

array
getSections()

Get the entire array of sections.

array
getNames()

Get all of the registered named views in environment.

Details

at line line 132
void __construct(EngineResolver $engines, ViewFinderInterface $finder, Dispatcher $events)

Create a new view factory instance.

Parameters

EngineResolver $engines
ViewFinderInterface $finder
Dispatcher $events

Return Value

void

at line line 149
View file(string $path, array $data = array(), array $mergeData = array())

Get the evaluated view contents for the given view.

Parameters

string $path
array $data
array $mergeData

Return Value

View

at line line 166
View make(string $view, array $data = array(), array $mergeData = array())

Get the evaluated view contents for the given view.

Parameters

string $view
array $data
array $mergeData

Return Value

View

at line line 220
View of(string $view, mixed $data = array())

Get the evaluated view contents for a named view.

Parameters

string $view
mixed $data

Return Value

View

at line line 232
void name(string $view, string $name)

Register a named view.

Parameters

string $view
string $name

Return Value

void

at line line 244
void alias(string $view, string $alias)

Add an alias for a view.

Parameters

string $view
string $alias

Return Value

void

at line line 255
bool exists(string $view)

Determine if a given view exists.

Parameters

string $view

Return Value

bool

at line line 275
string renderEach(string $view, array $data, string $iterator, string $empty = 'raw|')

Get the rendered contents of a partial from a loop.

Parameters

string $view
array $data
string $iterator
string $empty

Return Value

string

at line line 312
EngineInterface getEngineFromPath(string $path)

Get the appropriate view engine for the given path.

Parameters

string $path

Return Value

EngineInterface

Exceptions

InvalidArgumentException

at line line 345
mixed share(array|string $key, mixed $value = null)

Add a piece of shared data to the environment.

Parameters

array|string $key
mixed $value

Return Value

mixed

at line line 363
array creator(array|string $views, Closure|string $callback)

Register a view creator event.

Parameters

array|string $views
Closure|string $callback

Return Value

array

at line line 380
array composers(array $composers)

Register multiple view composers via an array.

Parameters

array $composers

Return Value

array

at line line 399
array composer(array|string $views, Closure|string $callback, int|null $priority = null)

Register a view composer event.

Parameters

array|string $views
Closure|string $callback
int|null $priority

Return Value

array

at line line 517
void callComposer(View $view)

Call the composer for a given view.

Parameters

View $view

Return Value

void

at line line 528
void callCreator(View $view)

Call the creator for a given view.

Parameters

View $view

Return Value

void

at line line 540
void startSection(string $section, string $content = '')

Start injecting content into a section.

Parameters

string $section
string $content

Return Value

void

at line line 558
void inject(string $section, string $content)

Inject inline content into a section.

Parameters

string $section
string $content

Return Value

void

at line line 568
string yieldSection()

Stop injecting content into a section and return its contents.

Return Value

string

at line line 584
string stopSection(bool $overwrite = false)

Stop injecting content into a section.

Parameters

bool $overwrite

Return Value

string

Exceptions

InvalidArgumentException

at line line 607
string appendSection()

Stop injecting content into a section and append it.

Return Value

string

Exceptions

InvalidArgumentException

at line line 647
string yieldContent(string $section, string $default = '')

Get the string contents of a section.

Parameters

string $section
string $default

Return Value

string

at line line 669
void startPush(string $section, string $content = '')

Start injecting content into a push section.

Parameters

string $section
string $content

Return Value

void

at line line 686
string stopPush()

Stop injecting content into a push section.

Return Value

string

Exceptions

InvalidArgumentException

at line line 725
string yieldPushContent(string $section, string $default = '')

Get the string contents of a push section.

Parameters

string $section
string $default

Return Value

string

at line line 739
void flushSections()

Flush all of the section contents.

Return Value

void

at line line 755
void flushSectionsIfDoneRendering()

Flush all of the section contents if done rendering.

Return Value

void

at line line 767
void incrementRender()

Increment the rendering counter.

Return Value

void

at line line 777
void decrementRender()

Decrement the rendering counter.

Return Value

void

at line line 787
bool doneRendering()

Check if there are no active render operations.

Return Value

bool

at line line 798
void addLoop(Countable|array $data)

Add new loop to the stack.

Parameters

Countable|array $data

Return Value

void

at line line 821
void incrementLoopIndices()

Increment the top loop's indices.

Return Value

void

at line line 842
void popLoop()

Pop a loop from the top of the loop stack.

Return Value

void

at line line 852
array getFirstLoop()

Get an instance of the first loop in the stack.

Return Value

array

at line line 862
array getLoopStack()

Get the entire loop stack.

Return Value

array

at line line 873
void addLocation(string $location)

Add a location to the array of view locations.

Parameters

string $location

Return Value

void

at line line 885
void addNamespace(string $namespace, string|array $hints)

Add a new namespace to the loader.

Parameters

string $namespace
string|array $hints

Return Value

void

at line line 897
void prependNamespace(string $namespace, string|array $hints)

Prepend a new namespace to the loader.

Parameters

string $namespace
string|array $hints

Return Value

void

at line line 910
void addExtension(string $extension, string $engine, Closure $resolver = null)

Register a valid view extension and its engine.

Parameters

string $extension
string $engine
Closure $resolver

Return Value

void

at line line 928
array getExtensions()

Get the extension to engine bindings.

Return Value

array

at line line 938
EngineResolver getEngineResolver()

Get the engine resolver instance.

Return Value

EngineResolver

at line line 948
ViewFinderInterface getFinder()

Get the view finder instance.

Return Value

ViewFinderInterface

at line line 959
void setFinder(ViewFinderInterface $finder)

Set the view finder instance.

Parameters

ViewFinderInterface $finder

Return Value

void

at line line 969
Dispatcher getDispatcher()

Get the event dispatcher instance.

Return Value

Dispatcher

at line line 980
void setDispatcher(Dispatcher $events)

Set the event dispatcher instance.

Parameters

Dispatcher $events

Return Value

void

at line line 990
Container getContainer()

Get the IoC container instance.

Return Value

Container

at line line 1001
void setContainer(Container $container)

Set the IoC container instance.

Parameters

Container $container

Return Value

void

at line line 1013
mixed shared(string $key, mixed $default = null)

Get an item from the shared data.

Parameters

string $key
mixed $default

Return Value

mixed

at line line 1023
array getShared()

Get all of the shared data for the environment.

Return Value

array

at line line 1034
bool hasSection(string $name)

Check if section exists.

Parameters

string $name

Return Value

bool

at line line 1044
array getSections()

Get the entire array of sections.

Return Value

array

at line line 1054
array getNames()

Get all of the registered named views in environment.

Return Value

array