class Illuminate / View / Factory
You're browsing the documentation for an upcoming version of Laravel. The documentation and features of this release are subject to change.

Factory

Implements

Uses

Properties

protected

$engines EngineResolver

The engine implementation.

Default: null
protected

$finder ViewFinderInterface

The view finder implementation.

Default: null
protected

$events Dispatcher

The event dispatcher instance.

Default: null
protected

$container Container

The IoC container instance.

Default: null
protected

$shared array

Data that should be available to all templates.

Default: []
protected

$extensions array

The extension to engine bindings.

Default: array
protected

$composers array

The view composer events.

Default: []
protected

$renderCount int

The number of active rendering operations.

protected

$renderedOnce array

The "once" block IDs that have been rendered.

Default: []

Methods

public

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

Create a new view factory instance.

Parameters

public

file ( $path , $data , $mergeData ) : View

Get the evaluated view contents for the given view.

Parameters

  • $path string
  • $data Illuminate\...\Arrayable|array
  • $mergeData array
public

make ( $view , $data , $mergeData ) : View

Get the evaluated view contents for the given view.

Parameters

  • $view string
  • $data Illuminate\...\Arrayable|array
  • $mergeData array
public

first ( array $views , $data , $mergeData ) : View

Get the first view that actually exists from the given list.

Parameters

  • $views array
  • $data Illuminate\...\Arrayable|array
  • $mergeData array
public

renderWhen ( $condition , $view , $data , $mergeData ) : string

Get the rendered content of the view based on a given condition.

Parameters

  • $condition bool
  • $view string
  • $data Illuminate\...\Arrayable|array
  • $mergeData array
public

renderUnless ( $condition , $view , $data , $mergeData ) : string

Get the rendered content of the view based on the negation of a given condition.

Parameters

  • $condition bool
  • $view string
  • $data Illuminate\...\Arrayable|array
  • $mergeData array
public

renderEach ( $view , $data , $iterator , $empty ) : string

Get the rendered contents of a partial from a loop.

Parameters

  • $view string
  • $data array
  • $iterator string
  • $empty string
protected

normalizeName ( $name ) : string

Normalize a view name.

Parameters

  • $name string
protected

parseData ( $data ) : array

Parse the given data into a raw array.

Parameters

  • $data mixed
protected

viewInstance ( $view , $path , $data ) : View

Create a new view instance from the given arguments.

Parameters

  • $view string
  • $path string
  • $data Illuminate\...\Arrayable|array
public

exists ( $view ) : bool

Determine if a given view exists.

Parameters

  • $view string
public

getEngineFromPath ( $path ) : Engine

Get the appropriate view engine for the given path.

Parameters

  • $path string
protected

getExtension ( $path ) : string|null

Get the extension used by the view file.

Parameters

  • $path string
public

share ( $key , $value ) : mixed

Add a piece of shared data to the environment.

Parameters

  • $key array|string
  • $value mixed|null
public

incrementRender ( ) : void

Increment the rendering counter.

public

decrementRender ( ) : void

Decrement the rendering counter.

public

doneRendering ( ) : bool

Check if there are no active render operations.

public

hasRenderedOnce ( string $id ) : bool

Determine if the given once token has been rendered.

Parameters

  • $id string
public

markAsRenderedOnce ( string $id ) : void

Mark the given once token as having been rendered.

Parameters

  • $id string
public

addLocation ( $location ) : void

Add a location to the array of view locations.

Parameters

  • $location string
public

addNamespace ( $namespace , $hints ) : $this

Add a new namespace to the loader.

Parameters

  • $namespace string
  • $hints string|array
public

prependNamespace ( $namespace , $hints ) : $this

Prepend a new namespace to the loader.

Parameters

  • $namespace string
  • $hints string|array
public

replaceNamespace ( $namespace , $hints ) : $this

Replace the namespace hints for the given namespace.

Parameters

  • $namespace string
  • $hints string|array
public

addExtension ( $extension , $engine , $resolver ) : void

Register a valid view extension and its engine.

Parameters

  • $extension string
  • $engine string
  • $resolver Closure |null
public

flushState ( ) : void

Flush all of the factory state like sections and stacks.

public

flushStateIfDoneRendering ( ) : void

Flush all of the section contents if done rendering.

public

getExtensions ( ) : array

Get the extension to engine bindings.

public

getEngineResolver ( ) : EngineResolver

Get the engine resolver instance.

public

getFinder ( ) : ViewFinderInterface

Get the view finder instance.

public

setFinder ( ViewFinderInterface $finder ) : void

Set the view finder instance.

Parameters

public

flushFinderCache ( ) : void

Flush the cache of views located by the finder.

public

getDispatcher ( ) : Dispatcher

Get the event dispatcher instance.

public

setDispatcher ( Dispatcher $events ) : void

Set the event dispatcher instance.

Parameters

public

getContainer ( ) : Container

Get the IoC container instance.

public

setContainer ( Container $container ) : void

Set the IoC container instance.

Parameters

public

shared ( $key , $default ) : mixed

Get an item from the shared data.

Parameters

  • $key string
  • $default mixed
public

getShared ( ) : array

Get all of the shared data for the environment.