class View implements ArrayAccess (View source)

Constants

LOADER

Nama event view loader.

ENGINE

Nama event view engine.

Properties

string $view

Berisi nama view.

array $data

Berisi data-data view.

string $path

Berisi path (absolut) view di disk.

static array $shared

Berisi data-data view yang di-share.

static array $names

Berisi list nama-nama view terdaftar.

static array $cache

Berisi list konten cache view.

static string $last

Berisi view terakhir yang akan di-render.

static int $rendered

Counter operasi render view.

Methods

__construct(string $view, array $data = [])

Buat instance view baru.

static string|bool
exists(string $view, bool $return_path = false)

Periksa apakah view yang diberikan ada atau tidak.

string
path(string $view)

Ambil path (absolut) view di disk.

static string
file(string $package, string $view, string $directory)

Ambil path ke view menggunakan kovensi default.

static View
make(string $view, array $data = [])

Buat sebuah instance view baru.

static View
of(string $name, array $data = [])

Buat sebuah instance view baru dari sebuah named view.

static 
name(string $view, string $name)

Beri nama ke sebuah view.

static 
composer(string|array $views, Closure $composer)

Daftarkan view composer menggunakan kelas \System\Event.

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

Ambil hasil render view parsial dari sebuah loop.

string
render()

Ambil string konten hasil evaluasi dari sebuah view.

string
get()

Ambil konten hasil evaluasi sebuah view.

array
data()

Ambil array view data untuk instance view.

nest(string $key, string $view, array $data = [])

Tambahkan instance view ke view data.

with(string $key, mixed $value = null)

Tambahkan sebuah data key-value ke view data, data ini bisa diakses di view sebagai variabel.

shares(string $key, mixed $value)

Chainable View::share().

static 
share(string $key, mixed $value)

Tambahkan sebuah data key-value ke shared view data, Shared view data bisa diakses oleh semua view di lingkup aplikasi.

static 
flush()

Bersihkan seluruh file hasil kompilasi blade.

offsetExists($offset)

Implementasi ArrayAccess::offsetExists().

offsetGet($offset)

Implementasi ArrayAccess::offsetGet().

offsetSet($offset, $value)

Implementasi ArrayAccess::offsetSet().

offsetUnset($offset)

Implementasi ArrayAccess::offsetUnset().

__get($key)

Magic Method getter.

__set($key, $value)

Magic Method setter.

__isset($key)

Magic Method untuk data checking.

string
__toString()

Mereturn string hasil eveluasi view.

$this
__call($method, array $parameters)

Magic Method menangani pemanggilan method secara dinamis.

Details

__construct(string $view, array $data = [])

Buat instance view baru.


     // Buat sebuah instance view baru
     $view = new View('home.index');

     // Buat sebuah instance view baru (milik paket)
     $view = new View('admin::home.index');

     // Buat sebuah instance view baru dengan view data
     $view = new View('home.index', ['name' => 'Budi']);

Parameters

string $view
array $data

static string|bool exists(string $view, bool $return_path = false)

Periksa apakah view yang diberikan ada atau tidak.

Parameters

string $view
bool $return_path

Return Value

string|bool

protected string path(string $view)

Ambil path (absolut) view di disk.

Parameters

string $view

Return Value

string

static string file(string $package, string $view, string $directory)

Ambil path ke view menggunakan kovensi default.

Parameters

string $package
string $view
string $directory

Return Value

string

static View make(string $view, array $data = [])

Buat sebuah instance view baru.


     // Buat sebuah instance view baru
     $view = View::make('home.index');

     // Buat sebuah instance view baru (milik paket)
     $view = View::make('admin::home.index');

     // Buat sebuah instance view baru dengan view data
     $view = View::make('home.index', ['name' => 'Budi']);

Parameters

string $view
array $data

Return Value

View

static View of(string $name, array $data = [])

Buat sebuah instance view baru dari sebuah named view.


     // Buat sebuah instance view baru dari sebuah named view
     $view = View::of('profile');

     // Buat sebuah instance view baru dari sebuah named view dengan view data
     $view = View::of('profile', ['name' => 'Budi']);

Parameters

string $name
array $data

Return Value

View

static name(string $view, string $name)

Beri nama ke sebuah view.


     // Beri nama ke sebuah view
     View::name('partials.profile', 'profile');

     // Resolve instance ke sebuah named view
     $view = View::of('profile');

Parameters

string $view
string $name

static composer(string|array $views, Closure $composer)

Daftarkan view composer menggunakan kelas \System\Event.


     // Daftarkan view composer untuk view 'home.index'
     View::composer('home.index', function ($view) {
         $view['title'] = 'Beranda';
     });

Parameters

string|array $views
Closure $composer

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

Ambil hasil render view parsial dari sebuah loop.

Parameters

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

Return Value

string

string render()

Ambil string konten hasil evaluasi dari sebuah view.

Return Value

string

string get()

Ambil konten hasil evaluasi sebuah view.

Return Value

string

array data()

Ambil array view data untuk instance view.

Shared view data akan dicampur dengan view data biasa.

Return Value

array

View nest(string $key, string $view, array $data = [])

Tambahkan instance view ke view data.


     // Tambahkan instance view ke view data (cara 1)
     $view = View::make('foo')->nest('footer', 'partials.footer');

     // Tambahkan instance view ke view data (cara 2)
     $view = View::make('foo')->with('footer', View::make('partials.footer'));

Parameters

string $key
string $view
array $data

Return Value

View

View with(string $key, mixed $value = null)

Tambahkan sebuah data key-value ke view data, data ini bisa diakses di view sebagai variabel.

Parameters

string $key
mixed $value

Return Value

View

View shares(string $key, mixed $value)

Chainable View::share().

Parameters

string $key
mixed $value

Return Value

View

static share(string $key, mixed $value)

Tambahkan sebuah data key-value ke shared view data, Shared view data bisa diakses oleh semua view di lingkup aplikasi.

Parameters

string $key
mixed $value

static flush()

Bersihkan seluruh file hasil kompilasi blade.

offsetExists($offset)

Implementasi ArrayAccess::offsetExists().

Parameters

$offset

offsetGet($offset)

Implementasi ArrayAccess::offsetGet().

Parameters

$offset

offsetSet($offset, $value)

Implementasi ArrayAccess::offsetSet().

Parameters

$offset
$value

offsetUnset($offset)

Implementasi ArrayAccess::offsetUnset().

Parameters

$offset

__get($key)

Magic Method getter.

Parameters

$key

__set($key, $value)

Magic Method setter.

Parameters

$key
$value

__isset($key)

Magic Method untuk data checking.

Parameters

$key

string __toString()

Mereturn string hasil eveluasi view.

Return Value

string

$this __call($method, array $parameters)

Magic Method menangani pemanggilan method secara dinamis.

Method ini menangai pemanggilan helper 'with_xxx'.

Parameters

$method
array $parameters

Return Value

$this