Yaf_Registry::get

(Yaf >=1.0.0)

Yaf_Registry::getRetrieve an item from registry

Опис

public static function Yaf_Registry::get(string $name): mixed

Retrieves a value from the registry.

Параметри

name

The name of the registry entry.

Значення, що повертаються

The value stored under name, or null if there is no entry with that name.

Приклади

Приклад #1 Yaf_Registry::get() example

<?php
class IndexController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        $redis = Yaf_Registry::get("redis");
        if ($redis === null) {
            throw new Exception("the redis connection is not registered");
        }

        $this->getView()->assign("visits", $redis->get("site:visits"));

        return true;
    }
}
?>

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top